Commit 7bd04f86618124ad6c34f5307570c0a98ccc0fd7
1 parent
4fa3b887
feat: update 附件名称显示优化
Showing
8 changed files
with
132 additions
and
32 deletions
src/access.ts
@@ -3,7 +3,6 @@ export default (initialState: API.UserInfo) => { | @@ -3,7 +3,6 @@ export default (initialState: API.UserInfo) => { | ||
3 | // 参考文档 https://umijs.org/docs/max/access | 3 | // 参考文档 https://umijs.org/docs/max/access |
4 | const { roleSmallVO } = initialState; | 4 | const { roleSmallVO } = initialState; |
5 | 5 | ||
6 | - console.log(roleSmallVO?.code === 'admin'); | ||
7 | return { | 6 | return { |
8 | canReadAdmin: roleSmallVO?.code === 'admin', | 7 | canReadAdmin: roleSmallVO?.code === 'admin', |
9 | canReadProcure: roleSmallVO?.code === 'procure', | 8 | canReadProcure: roleSmallVO?.code === 'procure', |
src/pages/Order/components/AfterSalesDrawer.tsx
@@ -6,6 +6,7 @@ import { | @@ -6,6 +6,7 @@ import { | ||
6 | ProFormDigit, | 6 | ProFormDigit, |
7 | ProFormSelect, | 7 | ProFormSelect, |
8 | ProFormTextArea, | 8 | ProFormTextArea, |
9 | + ProFormUploadDragger, | ||
9 | } from '@ant-design/pro-components'; | 10 | } from '@ant-design/pro-components'; |
10 | import { Form, message } from 'antd'; | 11 | import { Form, message } from 'antd'; |
11 | import { AFTE_SALES_PLAN_OPTIONS } from '../constant'; | 12 | import { AFTE_SALES_PLAN_OPTIONS } from '../constant'; |
@@ -13,12 +14,14 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | @@ -13,12 +14,14 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | ||
13 | let subOrderIds = subOrders?.map((item: { id: any }) => { | 14 | let subOrderIds = subOrders?.map((item: { id: any }) => { |
14 | return item.id; | 15 | return item.id; |
15 | }); | 16 | }); |
17 | + | ||
16 | let mainOrderId = mainOrder.id; | 18 | let mainOrderId = mainOrder.id; |
17 | const [form] = Form.useForm<{ | 19 | const [form] = Form.useForm<{ |
18 | afterSalesNotes: string; | 20 | afterSalesNotes: string; |
19 | afterSalesPlan: string; | 21 | afterSalesPlan: string; |
20 | ids: []; | 22 | ids: []; |
21 | totalPayment: number; | 23 | totalPayment: number; |
24 | + filePaths: any[]; | ||
22 | }>(); | 25 | }>(); |
23 | 26 | ||
24 | return ( | 27 | return ( |
@@ -28,6 +31,7 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | @@ -28,6 +31,7 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | ||
28 | subOrderIds: []; | 31 | subOrderIds: []; |
29 | totalPayment: number; | 32 | totalPayment: number; |
30 | mainId: number; | 33 | mainId: number; |
34 | + filePaths: any[]; | ||
31 | }> | 35 | }> |
32 | title="申请售后" | 36 | title="申请售后" |
33 | open | 37 | open |
@@ -49,6 +53,9 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | @@ -49,6 +53,9 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | ||
49 | onFinish={async (values) => { | 53 | onFinish={async (values) => { |
50 | values.subOrderIds = subOrderIds; | 54 | values.subOrderIds = subOrderIds; |
51 | values.mainId = mainOrderId; | 55 | values.mainId = mainOrderId; |
56 | + values.filePaths = values.filePaths?.map((file) => { | ||
57 | + return { url: file.response.data[0] }; | ||
58 | + }); | ||
52 | let res = await postServiceOrderApplyAfterSales({ data: values }); | 59 | let res = await postServiceOrderApplyAfterSales({ data: values }); |
53 | if (res?.result === RESPONSE_CODE.SUCCESS) { | 60 | if (res?.result === RESPONSE_CODE.SUCCESS) { |
54 | message.success(res.message); | 61 | message.success(res.message); |
@@ -80,6 +87,15 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | @@ -80,6 +87,15 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { | ||
80 | name="afterSalesNotes" | 87 | name="afterSalesNotes" |
81 | rules={[{ required: true, message: '售后原因必填' }]} | 88 | rules={[{ required: true, message: '售后原因必填' }]} |
82 | /> | 89 | /> |
90 | + <ProFormUploadDragger | ||
91 | + key="filePaths" | ||
92 | + label="附件" | ||
93 | + name="filePaths" | ||
94 | + action="/api/service/order/fileProcess" | ||
95 | + fieldProps={{ | ||
96 | + headers: { Authorization: localStorage.getItem('token') }, | ||
97 | + }} | ||
98 | + /> | ||
83 | </DrawerForm> | 99 | </DrawerForm> |
84 | ); | 100 | ); |
85 | }; | 101 | }; |
src/pages/Order/components/CheckModal.tsx
@@ -32,10 +32,8 @@ export default ({ | @@ -32,10 +32,8 @@ export default ({ | ||
32 | reader.onerror = (error) => reject(error); | 32 | reader.onerror = (error) => reject(error); |
33 | }); | 33 | }); |
34 | const [fileList, setFileList] = useState<UploadFile[]>([]); | 34 | const [fileList, setFileList] = useState<UploadFile[]>([]); |
35 | - const [uploading, setUploading] = useState(false); | ||
36 | const handleCancel = () => setPreviewOpen(false); | 35 | const handleCancel = () => setPreviewOpen(false); |
37 | const [messageApi, contextHolder] = message.useMessage(); | 36 | const [messageApi, contextHolder] = message.useMessage(); |
38 | - console.log(uploading); | ||
39 | const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { | 37 | const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { |
40 | //fileListObj得在change里变化,change的参数是已经处理过的file数组 | 38 | //fileListObj得在change里变化,change的参数是已经处理过的file数组 |
41 | //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 | 39 | //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 |
@@ -295,7 +293,6 @@ export default ({ | @@ -295,7 +293,6 @@ export default ({ | ||
295 | let values = { name: form.getFieldValue('name') }; | 293 | let values = { name: form.getFieldValue('name') }; |
296 | doFinancailCheck(values, false); | 294 | doFinancailCheck(values, false); |
297 | } | 295 | } |
298 | - setUploading(false); | ||
299 | }} | 296 | }} |
300 | > | 297 | > |
301 | 驳回 | 298 | 驳回 |
src/pages/Order/components/ImportModal.tsx
@@ -47,7 +47,6 @@ export default ({ onClose }) => { | @@ -47,7 +47,6 @@ export default ({ onClose }) => { | ||
47 | }, | 47 | }, |
48 | }); | 48 | }); |
49 | 49 | ||
50 | - console.log(res); | ||
51 | if (res.result === RESPONSE_CODE.SUCCESS) { | 50 | if (res.result === RESPONSE_CODE.SUCCESS) { |
52 | message.success(res.message); | 51 | message.success(res.message); |
53 | onClose(); | 52 | onClose(); |
src/pages/Order/components/ProcureCheckModal.tsx
@@ -95,6 +95,10 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { | @@ -95,6 +95,10 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { | ||
95 | }} | 95 | }} |
96 | submitTimeout={2000} | 96 | submitTimeout={2000} |
97 | onFinish={async (values) => { | 97 | onFinish={async (values) => { |
98 | + if (values.name === '0') { | ||
99 | + message.error('选择转回仓库请点击转回仓库按钮!'); | ||
100 | + return; | ||
101 | + } | ||
98 | let procureIsPrintAndSend = false; | 102 | let procureIsPrintAndSend = false; |
99 | if (values.name === '采购自行发货') { | 103 | if (values.name === '采购自行发货') { |
100 | procureIsPrintAndSend = true; | 104 | procureIsPrintAndSend = true; |
@@ -117,9 +121,11 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { | @@ -117,9 +121,11 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { | ||
117 | rules={[{ required: true, message: '供应商必填' }]} | 121 | rules={[{ required: true, message: '供应商必填' }]} |
118 | request={async () => { | 122 | request={async () => { |
119 | const res = await postServiceOrderQuerySupplier(); | 123 | const res = await postServiceOrderQuerySupplier(); |
120 | - return res.data?.map((item) => { | 124 | + let options = res.data?.map((item) => { |
121 | return { label: item, value: item }; | 125 | return { label: item, value: item }; |
122 | }); | 126 | }); |
127 | + options.push({ label: '转回仓库', value: '0' }); | ||
128 | + return options; | ||
123 | }} | 129 | }} |
124 | /> | 130 | /> |
125 | </ModalForm> | 131 | </ModalForm> |
src/pages/Order/constant.ts
@@ -191,7 +191,7 @@ export const SALES_CODE_OPTIONS = [ | @@ -191,7 +191,7 @@ export const SALES_CODE_OPTIONS = [ | ||
191 | { label: 'X-Lulu', value: 'X-Lulu' }, | 191 | { label: 'X-Lulu', value: 'X-Lulu' }, |
192 | { label: 'X-P', value: 'X-P' }, | 192 | { label: 'X-P', value: 'X-P' }, |
193 | { label: 'TB', value: 'TB' }, | 193 | { label: 'TB', value: 'TB' }, |
194 | - { label: 'HCTB', value: 'HCTB' }, | 194 | + { label: 'TBHC', value: 'TBHC' }, |
195 | { label: 'TBC', value: 'TBC' }, | 195 | { label: 'TBC', value: 'TBC' }, |
196 | { label: 'G-Lisa', value: 'G-Lisa' }, | 196 | { label: 'G-Lisa', value: 'G-Lisa' }, |
197 | { label: 'G-Lynn', value: 'G-Lynn' }, | 197 | { label: 'G-Lynn', value: 'G-Lynn' }, |
src/pages/Order/index.tsx
@@ -46,7 +46,7 @@ import { | @@ -46,7 +46,7 @@ import { | ||
46 | message, | 46 | message, |
47 | } from 'antd'; | 47 | } from 'antd'; |
48 | import { cloneDeep } from 'lodash'; | 48 | import { cloneDeep } from 'lodash'; |
49 | -import { Key, useRef, useState } from 'react'; | 49 | +import React, { Key, useRef, useState } from 'react'; |
50 | import OrderPrintModal from '../OrderPrint/OrderPrintModal'; | 50 | import OrderPrintModal from '../OrderPrint/OrderPrintModal'; |
51 | import AfterSalesDrawer from './components/AfterSalesDrawer'; | 51 | import AfterSalesDrawer from './components/AfterSalesDrawer'; |
52 | import ApplyForInvoicingModal from './components/ApplyForInvoicingModal'; | 52 | import ApplyForInvoicingModal from './components/ApplyForInvoicingModal'; |
@@ -332,6 +332,7 @@ const OrderPage = () => { | @@ -332,6 +332,7 @@ const OrderPage = () => { | ||
332 | if (orderStatus === 'AUDIT_FAILED') { | 332 | if (orderStatus === 'AUDIT_FAILED') { |
333 | return ( | 333 | return ( |
334 | <MyToolTip | 334 | <MyToolTip |
335 | + key="key" | ||
335 | title={optRecord.checkNotes} | 336 | title={optRecord.checkNotes} |
336 | content={ | 337 | content={ |
337 | <> | 338 | <> |
@@ -357,6 +358,7 @@ const OrderPage = () => { | @@ -357,6 +358,7 @@ const OrderPage = () => { | ||
357 | ) { | 358 | ) { |
358 | return ( | 359 | return ( |
359 | <MyToolTip | 360 | <MyToolTip |
361 | + key="key" | ||
360 | title={ | 362 | title={ |
361 | enumValueToLabel( | 363 | enumValueToLabel( |
362 | optRecord.afterSalesPlan, | 364 | optRecord.afterSalesPlan, |
@@ -386,6 +388,7 @@ const OrderPage = () => { | @@ -386,6 +388,7 @@ const OrderPage = () => { | ||
386 | if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') { | 388 | if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') { |
387 | return ( | 389 | return ( |
388 | <MyToolTip | 390 | <MyToolTip |
391 | + key="key" | ||
389 | title={optRecord.checkNotes} | 392 | title={optRecord.checkNotes} |
390 | content={ | 393 | content={ |
391 | <> | 394 | <> |
@@ -406,7 +409,7 @@ const OrderPage = () => { | @@ -406,7 +409,7 @@ const OrderPage = () => { | ||
406 | } | 409 | } |
407 | 410 | ||
408 | return ( | 411 | return ( |
409 | - <Tag color={TAGS_COLOR.get(optRecord.orderStatus)}> | 412 | + <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}> |
410 | {enumValueToLabel(optRecord.orderStatus, ORDER_STATUS_OPTIONS)} | 413 | {enumValueToLabel(optRecord.orderStatus, ORDER_STATUS_OPTIONS)} |
411 | </Tag> | 414 | </Tag> |
412 | ); | 415 | ); |
@@ -420,7 +423,7 @@ const OrderPage = () => { | @@ -420,7 +423,7 @@ const OrderPage = () => { | ||
420 | if (afterAnnexList?.length > 0) { | 423 | if (afterAnnexList?.length > 0) { |
421 | for (let url of afterAnnexList) { | 424 | for (let url of afterAnnexList) { |
422 | links.push( | 425 | links.push( |
423 | - <a className="pl-2" href={url}> | 426 | + <a key={i} className="pl-2" href={url}> |
424 | 附件{i++} | 427 | 附件{i++} |
425 | </a>, | 428 | </a>, |
426 | ); | 429 | ); |
@@ -443,11 +446,11 @@ const OrderPage = () => { | @@ -443,11 +446,11 @@ const OrderPage = () => { | ||
443 | console.log(`current index: ${current}, prev index: ${prev}`), | 446 | console.log(`current index: ${current}, prev index: ${prev}`), |
444 | }} | 447 | }} |
445 | > | 448 | > |
446 | - {invoicingCheckAnnexList.map((url) => ( | ||
447 | - <> | 449 | + {invoicingCheckAnnexList.map((url, index) => ( |
450 | + <React.Fragment key={index}> | ||
448 | <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '} | 451 | <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '} |
449 | <Divider type="vertical" /> | 452 | <Divider type="vertical" /> |
450 | - </> | 453 | + </React.Fragment> |
451 | ))} | 454 | ))} |
452 | </Image.PreviewGroup> | 455 | </Image.PreviewGroup> |
453 | </div> | 456 | </div> |
@@ -892,6 +895,23 @@ const OrderPage = () => { | @@ -892,6 +895,23 @@ const OrderPage = () => { | ||
892 | '' | 895 | '' |
893 | )} | 896 | )} |
894 | 897 | ||
898 | + {optRecord.subPath?.includes('afterSalesCheck') ? ( | ||
899 | + <Button | ||
900 | + className="p-0" | ||
901 | + type="link" | ||
902 | + onClick={() => { | ||
903 | + setOrderRow(optRecord); | ||
904 | + setCheckVisible(true); | ||
905 | + setSelectedRows([optRecord]); | ||
906 | + setOrderCheckType(CHECK_TYPE.AFTER_SALES); | ||
907 | + }} | ||
908 | + > | ||
909 | + 售后审核 | ||
910 | + </Button> | ||
911 | + ) : ( | ||
912 | + '' | ||
913 | + )} | ||
914 | + | ||
895 | {optRecord.subPath?.includes('financeCheckOrder') ? ( | 915 | {optRecord.subPath?.includes('financeCheckOrder') ? ( |
896 | <Button | 916 | <Button |
897 | className="p-0" | 917 | className="p-0" |
@@ -1327,6 +1347,37 @@ const OrderPage = () => { | @@ -1327,6 +1347,37 @@ const OrderPage = () => { | ||
1327 | <Flex justify="flex-end"> | 1347 | <Flex justify="flex-end"> |
1328 | <Space.Compact direction="vertical" align="end"> | 1348 | <Space.Compact direction="vertical" align="end"> |
1329 | <Space> | 1349 | <Space> |
1350 | + {record.mainPath?.includes('procureConvertProcure') ? ( | ||
1351 | + <Button | ||
1352 | + className="p-0" | ||
1353 | + type="link" | ||
1354 | + onClick={() => { | ||
1355 | + let selectedSubOrders = selectedRowObj[record.id]; | ||
1356 | + if (selectedSubOrders === undefined) { | ||
1357 | + selectedSubOrders = record.subOrderInformationLists; | ||
1358 | + } | ||
1359 | + | ||
1360 | + setSelectedRows(selectedSubOrders); | ||
1361 | + for (let i = 0; i < selectedSubOrders.length; i++) { | ||
1362 | + if ( | ||
1363 | + !selectedSubOrders[i].subPath.includes( | ||
1364 | + 'procureConvertProcure', | ||
1365 | + ) | ||
1366 | + ) { | ||
1367 | + message.error('请选择允许转发的子订单进行转发'); | ||
1368 | + return; | ||
1369 | + } | ||
1370 | + } | ||
1371 | + setSelectedRows(selectedSubOrders); | ||
1372 | + setOrderCheckType(CHECK_TYPE.PROCURE); | ||
1373 | + setProcureConvertModalVisible(true); | ||
1374 | + }} | ||
1375 | + > | ||
1376 | + 转发 | ||
1377 | + </Button> | ||
1378 | + ) : ( | ||
1379 | + '' | ||
1380 | + )} | ||
1330 | {record.mainPath?.includes('sendProduct') ? ( | 1381 | {record.mainPath?.includes('sendProduct') ? ( |
1331 | <Button | 1382 | <Button |
1332 | className="p-0" | 1383 | className="p-0" |
@@ -1596,7 +1647,6 @@ const OrderPage = () => { | @@ -1596,7 +1647,6 @@ const OrderPage = () => { | ||
1596 | if (selectedSubOrders === undefined) { | 1647 | if (selectedSubOrders === undefined) { |
1597 | setSelectedRows(record.subOrderInformationLists); | 1648 | setSelectedRows(record.subOrderInformationLists); |
1598 | } | 1649 | } |
1599 | - console.log(selectedRows); | ||
1600 | for (let i = 0; i < selectedRows.length; i++) { | 1650 | for (let i = 0; i < selectedRows.length; i++) { |
1601 | if ( | 1651 | if ( |
1602 | selectedRows[i].orderStatus !== 'UNAUDITED' && | 1652 | selectedRows[i].orderStatus !== 'UNAUDITED' && |
@@ -1617,7 +1667,7 @@ const OrderPage = () => { | @@ -1617,7 +1667,7 @@ const OrderPage = () => { | ||
1617 | '' | 1667 | '' |
1618 | )} | 1668 | )} |
1619 | 1669 | ||
1620 | - {record.mainPath?.includes('') ? ( | 1670 | + {record.mainPath?.includes('afterSalesCheck') ? ( |
1621 | <Button | 1671 | <Button |
1622 | className="p-0" | 1672 | className="p-0" |
1623 | type="link" | 1673 | type="link" |
@@ -1628,8 +1678,10 @@ const OrderPage = () => { | @@ -1628,8 +1678,10 @@ const OrderPage = () => { | ||
1628 | setSelectedRows(record.subOrderInformationLists); | 1678 | setSelectedRows(record.subOrderInformationLists); |
1629 | } | 1679 | } |
1630 | for (let i = 0; i < selectedRows.length; i++) { | 1680 | for (let i = 0; i < selectedRows.length; i++) { |
1631 | - if (selectedRows[i].orderStatus !== 'UNAUDITED') { | ||
1632 | - message.error('请选择未审核的子订单进行审核'); | 1681 | + if ( |
1682 | + selectedRows[i].orderStatus !== 'IN_AFTER_SALES' | ||
1683 | + ) { | ||
1684 | + message.error('请选择售后中的子订单进行审核'); | ||
1633 | return; | 1685 | return; |
1634 | } | 1686 | } |
1635 | } | 1687 | } |
@@ -1702,10 +1754,6 @@ const OrderPage = () => { | @@ -1702,10 +1754,6 @@ const OrderPage = () => { | ||
1702 | setSelectedRows(selectedSubOrders); | 1754 | setSelectedRows(selectedSubOrders); |
1703 | if (selectedSubOrders === undefined) { | 1755 | if (selectedSubOrders === undefined) { |
1704 | setSelectedRows(record.subOrderInformationLists); | 1756 | setSelectedRows(record.subOrderInformationLists); |
1705 | - console.log( | ||
1706 | - 'subOrderInformationLists:' + | ||
1707 | - record.subOrderInformationLists, | ||
1708 | - ); | ||
1709 | } | 1757 | } |
1710 | for (let i = 0; i < selectedRows.length; i++) { | 1758 | for (let i = 0; i < selectedRows.length; i++) { |
1711 | if ( | 1759 | if ( |
@@ -1737,10 +1785,6 @@ const OrderPage = () => { | @@ -1737,10 +1785,6 @@ const OrderPage = () => { | ||
1737 | setSelectedRows(selectedSubOrders); | 1785 | setSelectedRows(selectedSubOrders); |
1738 | if (selectedSubOrders === undefined) { | 1786 | if (selectedSubOrders === undefined) { |
1739 | setSelectedRows(record.subOrderInformationLists); | 1787 | setSelectedRows(record.subOrderInformationLists); |
1740 | - console.log( | ||
1741 | - 'subOrderInformationLists:' + | ||
1742 | - record.subOrderInformationLists, | ||
1743 | - ); | ||
1744 | } | 1788 | } |
1745 | for (let i = 0; i < selectedRows.length; i++) { | 1789 | for (let i = 0; i < selectedRows.length; i++) { |
1746 | if ( | 1790 | if ( |
@@ -1790,7 +1834,7 @@ const OrderPage = () => { | @@ -1790,7 +1834,7 @@ const OrderPage = () => { | ||
1790 | '' | 1834 | '' |
1791 | )} | 1835 | )} |
1792 | 1836 | ||
1793 | - {record.mainPath?.includes('afterSalesCompletion') ? ( | 1837 | + {/* {record.mainPath?.includes('afterSalesCompletion') ? ( |
1794 | <ButtonConfirm | 1838 | <ButtonConfirm |
1795 | className="p-0" | 1839 | className="p-0" |
1796 | title="售后是否已完成?" | 1840 | title="售后是否已完成?" |
@@ -1832,7 +1876,7 @@ const OrderPage = () => { | @@ -1832,7 +1876,7 @@ const OrderPage = () => { | ||
1832 | /> | 1876 | /> |
1833 | ) : ( | 1877 | ) : ( |
1834 | '' | 1878 | '' |
1835 | - )} | 1879 | + )} */} |
1836 | 1880 | ||
1837 | {record.mainPath?.includes('orderCancel') ? ( | 1881 | {record.mainPath?.includes('orderCancel') ? ( |
1838 | <ButtonConfirm | 1882 | <ButtonConfirm |
@@ -1942,8 +1986,10 @@ const OrderPage = () => { | @@ -1942,8 +1986,10 @@ const OrderPage = () => { | ||
1942 | ); | 1986 | ); |
1943 | 1987 | ||
1944 | //判断是否是采购,是的话新增一个筛选条件 | 1988 | //判断是否是采购,是的话新增一个筛选条件 |
1945 | - console.log(userInfo?.roleSmallVO?.code === 'procure'); | ||
1946 | - if (userInfo?.roleSmallVO?.code === 'procure') { | 1989 | + if ( |
1990 | + userInfo?.roleSmallVO?.code === 'procure' || | ||
1991 | + userInfo?.roleSmallVO?.code === 'admin' | ||
1992 | + ) { | ||
1947 | mainOrdersColumns.push({ | 1993 | mainOrdersColumns.push({ |
1948 | title: '采购下单状态', | 1994 | title: '采购下单状态', |
1949 | dataIndex: 'procureOrderStatus', | 1995 | dataIndex: 'procureOrderStatus', |
src/utils/index.ts
@@ -67,7 +67,6 @@ function formatdate(inputDateTime: string) { | @@ -67,7 +67,6 @@ function formatdate(inputDateTime: string) { | ||
67 | } | 67 | } |
68 | 68 | ||
69 | function formatSalesCode(salesCode: any) { | 69 | function formatSalesCode(salesCode: any) { |
70 | - console.log('in'); | ||
71 | let newSalesCode = salesCode; | 70 | let newSalesCode = salesCode; |
72 | if (newSalesCode.indexOf('_')) { | 71 | if (newSalesCode.indexOf('_')) { |
73 | newSalesCode = newSalesCode.split('_'); | 72 | newSalesCode = newSalesCode.split('_'); |
@@ -123,7 +122,15 @@ function appendFormData(formData: any, data: any, parentKey = null) { | @@ -123,7 +122,15 @@ function appendFormData(formData: any, data: any, parentKey = null) { | ||
123 | } | 122 | } |
124 | } | 123 | } |
125 | } | 124 | } |
126 | - | 125 | +function getName(str: string) { |
126 | + let parts = str.split('-'); | ||
127 | + if (parts.length < 2) { | ||
128 | + return null; // 字符串不包含'-' | ||
129 | + } | ||
130 | + let namePart = parts.slice(2).join('-') || parts[1]; | ||
131 | + let name = namePart.replace(/^\d+/, ''); // 移除名字前的数字 | ||
132 | + return name; | ||
133 | +} | ||
127 | function getAliYunOSSFileNameFromUrl(url: string) { | 134 | function getAliYunOSSFileNameFromUrl(url: string) { |
128 | try { | 135 | try { |
129 | // 使用URL对象解析链接 | 136 | // 使用URL对象解析链接 |
@@ -135,7 +142,15 @@ function getAliYunOSSFileNameFromUrl(url: string) { | @@ -135,7 +142,15 @@ function getAliYunOSSFileNameFromUrl(url: string) { | ||
135 | 142 | ||
136 | // 检查文件名是否包含至少一个点(.)以确保是一个合法的文件名 | 143 | // 检查文件名是否包含至少一个点(.)以确保是一个合法的文件名 |
137 | if (fileName.includes('.')) { | 144 | if (fileName.includes('.')) { |
138 | - return fileName; | 145 | + let originName = getName(fileName); |
146 | + if ( | ||
147 | + originName === '' || | ||
148 | + originName === undefined || | ||
149 | + originName === null | ||
150 | + ) { | ||
151 | + return url; | ||
152 | + } | ||
153 | + return decodeURIComponent(originName); | ||
139 | } else { | 154 | } else { |
140 | throw new Error('Invalid file name in the URL'); | 155 | throw new Error('Invalid file name in the URL'); |
141 | } | 156 | } |
@@ -188,6 +203,27 @@ function copyToClipboard(text: string) { | @@ -188,6 +203,27 @@ function copyToClipboard(text: string) { | ||
188 | } | 203 | } |
189 | } | 204 | } |
190 | 205 | ||
206 | +/** | ||
207 | + * 按照前两个-,分割为数组 | ||
208 | + * @param str 字符串处理 | ||
209 | + * @returns | ||
210 | + */ | ||
211 | +function splitByFirstTwoDashes(str: string) { | ||
212 | + let index1 = str.indexOf('-'); | ||
213 | + if (index1 === -1) { | ||
214 | + return [str]; | ||
215 | + } | ||
216 | + let index2 = str.indexOf('-', index1 + 1); | ||
217 | + if (index2 === -1) { | ||
218 | + return [str.slice(0, index1), str.slice(index1 + 1)]; | ||
219 | + } | ||
220 | + return [ | ||
221 | + str.slice(0, index1), | ||
222 | + str.slice(index1 + 1, index2), | ||
223 | + str.slice(index2 + 1), | ||
224 | + ]; | ||
225 | +} | ||
226 | + | ||
191 | export { | 227 | export { |
192 | appendFormData, | 228 | appendFormData, |
193 | blobToFile, | 229 | blobToFile, |
@@ -202,5 +238,6 @@ export { | @@ -202,5 +238,6 @@ export { | ||
202 | formatdate, | 238 | formatdate, |
203 | getAliYunOSSFileNameFromUrl, | 239 | getAliYunOSSFileNameFromUrl, |
204 | getUserInfo, | 240 | getUserInfo, |
241 | + splitByFirstTwoDashes, | ||
205 | transImageFile, | 242 | transImageFile, |
206 | }; | 243 | }; |