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 | 3 | // 参考文档 https://umijs.org/docs/max/access |
4 | 4 | const { roleSmallVO } = initialState; |
5 | 5 | |
6 | - console.log(roleSmallVO?.code === 'admin'); | |
7 | 6 | return { |
8 | 7 | canReadAdmin: roleSmallVO?.code === 'admin', |
9 | 8 | canReadProcure: roleSmallVO?.code === 'procure', | ... | ... |
src/pages/Order/components/AfterSalesDrawer.tsx
... | ... | @@ -6,6 +6,7 @@ import { |
6 | 6 | ProFormDigit, |
7 | 7 | ProFormSelect, |
8 | 8 | ProFormTextArea, |
9 | + ProFormUploadDragger, | |
9 | 10 | } from '@ant-design/pro-components'; |
10 | 11 | import { Form, message } from 'antd'; |
11 | 12 | import { AFTE_SALES_PLAN_OPTIONS } from '../constant'; |
... | ... | @@ -13,12 +14,14 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { |
13 | 14 | let subOrderIds = subOrders?.map((item: { id: any }) => { |
14 | 15 | return item.id; |
15 | 16 | }); |
17 | + | |
16 | 18 | let mainOrderId = mainOrder.id; |
17 | 19 | const [form] = Form.useForm<{ |
18 | 20 | afterSalesNotes: string; |
19 | 21 | afterSalesPlan: string; |
20 | 22 | ids: []; |
21 | 23 | totalPayment: number; |
24 | + filePaths: any[]; | |
22 | 25 | }>(); |
23 | 26 | |
24 | 27 | return ( |
... | ... | @@ -28,6 +31,7 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { |
28 | 31 | subOrderIds: []; |
29 | 32 | totalPayment: number; |
30 | 33 | mainId: number; |
34 | + filePaths: any[]; | |
31 | 35 | }> |
32 | 36 | title="申请售后" |
33 | 37 | open |
... | ... | @@ -49,6 +53,9 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { |
49 | 53 | onFinish={async (values) => { |
50 | 54 | values.subOrderIds = subOrderIds; |
51 | 55 | values.mainId = mainOrderId; |
56 | + values.filePaths = values.filePaths?.map((file) => { | |
57 | + return { url: file.response.data[0] }; | |
58 | + }); | |
52 | 59 | let res = await postServiceOrderApplyAfterSales({ data: values }); |
53 | 60 | if (res?.result === RESPONSE_CODE.SUCCESS) { |
54 | 61 | message.success(res.message); |
... | ... | @@ -80,6 +87,15 @@ export default ({ setVisible, mainOrder, subOrders, onClose }) => { |
80 | 87 | name="afterSalesNotes" |
81 | 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 | 99 | </DrawerForm> |
84 | 100 | ); |
85 | 101 | }; | ... | ... |
src/pages/Order/components/CheckModal.tsx
... | ... | @@ -32,10 +32,8 @@ export default ({ |
32 | 32 | reader.onerror = (error) => reject(error); |
33 | 33 | }); |
34 | 34 | const [fileList, setFileList] = useState<UploadFile[]>([]); |
35 | - const [uploading, setUploading] = useState(false); | |
36 | 35 | const handleCancel = () => setPreviewOpen(false); |
37 | 36 | const [messageApi, contextHolder] = message.useMessage(); |
38 | - console.log(uploading); | |
39 | 37 | const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { |
40 | 38 | //fileListObj得在change里变化,change的参数是已经处理过的file数组 |
41 | 39 | //beforeUpload中的参数file是未处理过,还需要Base64拿到文件数据处理 |
... | ... | @@ -295,7 +293,6 @@ export default ({ |
295 | 293 | let values = { name: form.getFieldValue('name') }; |
296 | 294 | doFinancailCheck(values, false); |
297 | 295 | } |
298 | - setUploading(false); | |
299 | 296 | }} |
300 | 297 | > |
301 | 298 | 驳回 | ... | ... |
src/pages/Order/components/ImportModal.tsx
src/pages/Order/components/ProcureCheckModal.tsx
... | ... | @@ -95,6 +95,10 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { |
95 | 95 | }} |
96 | 96 | submitTimeout={2000} |
97 | 97 | onFinish={async (values) => { |
98 | + if (values.name === '0') { | |
99 | + message.error('选择转回仓库请点击转回仓库按钮!'); | |
100 | + return; | |
101 | + } | |
98 | 102 | let procureIsPrintAndSend = false; |
99 | 103 | if (values.name === '采购自行发货') { |
100 | 104 | procureIsPrintAndSend = true; |
... | ... | @@ -117,9 +121,11 @@ export default ({ setCheckVisible, data, subOrders, onClose }) => { |
117 | 121 | rules={[{ required: true, message: '供应商必填' }]} |
118 | 122 | request={async () => { |
119 | 123 | const res = await postServiceOrderQuerySupplier(); |
120 | - return res.data?.map((item) => { | |
124 | + let options = res.data?.map((item) => { | |
121 | 125 | return { label: item, value: item }; |
122 | 126 | }); |
127 | + options.push({ label: '转回仓库', value: '0' }); | |
128 | + return options; | |
123 | 129 | }} |
124 | 130 | /> |
125 | 131 | </ModalForm> | ... | ... |
src/pages/Order/constant.ts
... | ... | @@ -191,7 +191,7 @@ export const SALES_CODE_OPTIONS = [ |
191 | 191 | { label: 'X-Lulu', value: 'X-Lulu' }, |
192 | 192 | { label: 'X-P', value: 'X-P' }, |
193 | 193 | { label: 'TB', value: 'TB' }, |
194 | - { label: 'HCTB', value: 'HCTB' }, | |
194 | + { label: 'TBHC', value: 'TBHC' }, | |
195 | 195 | { label: 'TBC', value: 'TBC' }, |
196 | 196 | { label: 'G-Lisa', value: 'G-Lisa' }, |
197 | 197 | { label: 'G-Lynn', value: 'G-Lynn' }, | ... | ... |
src/pages/Order/index.tsx
... | ... | @@ -46,7 +46,7 @@ import { |
46 | 46 | message, |
47 | 47 | } from 'antd'; |
48 | 48 | import { cloneDeep } from 'lodash'; |
49 | -import { Key, useRef, useState } from 'react'; | |
49 | +import React, { Key, useRef, useState } from 'react'; | |
50 | 50 | import OrderPrintModal from '../OrderPrint/OrderPrintModal'; |
51 | 51 | import AfterSalesDrawer from './components/AfterSalesDrawer'; |
52 | 52 | import ApplyForInvoicingModal from './components/ApplyForInvoicingModal'; |
... | ... | @@ -332,6 +332,7 @@ const OrderPage = () => { |
332 | 332 | if (orderStatus === 'AUDIT_FAILED') { |
333 | 333 | return ( |
334 | 334 | <MyToolTip |
335 | + key="key" | |
335 | 336 | title={optRecord.checkNotes} |
336 | 337 | content={ |
337 | 338 | <> |
... | ... | @@ -357,6 +358,7 @@ const OrderPage = () => { |
357 | 358 | ) { |
358 | 359 | return ( |
359 | 360 | <MyToolTip |
361 | + key="key" | |
360 | 362 | title={ |
361 | 363 | enumValueToLabel( |
362 | 364 | optRecord.afterSalesPlan, |
... | ... | @@ -386,6 +388,7 @@ const OrderPage = () => { |
386 | 388 | if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') { |
387 | 389 | return ( |
388 | 390 | <MyToolTip |
391 | + key="key" | |
389 | 392 | title={optRecord.checkNotes} |
390 | 393 | content={ |
391 | 394 | <> |
... | ... | @@ -406,7 +409,7 @@ const OrderPage = () => { |
406 | 409 | } |
407 | 410 | |
408 | 411 | return ( |
409 | - <Tag color={TAGS_COLOR.get(optRecord.orderStatus)}> | |
412 | + <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}> | |
410 | 413 | {enumValueToLabel(optRecord.orderStatus, ORDER_STATUS_OPTIONS)} |
411 | 414 | </Tag> |
412 | 415 | ); |
... | ... | @@ -420,7 +423,7 @@ const OrderPage = () => { |
420 | 423 | if (afterAnnexList?.length > 0) { |
421 | 424 | for (let url of afterAnnexList) { |
422 | 425 | links.push( |
423 | - <a className="pl-2" href={url}> | |
426 | + <a key={i} className="pl-2" href={url}> | |
424 | 427 | 附件{i++} |
425 | 428 | </a>, |
426 | 429 | ); |
... | ... | @@ -443,11 +446,11 @@ const OrderPage = () => { |
443 | 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 | 451 | <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '} |
449 | 452 | <Divider type="vertical" /> |
450 | - </> | |
453 | + </React.Fragment> | |
451 | 454 | ))} |
452 | 455 | </Image.PreviewGroup> |
453 | 456 | </div> |
... | ... | @@ -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 | 915 | {optRecord.subPath?.includes('financeCheckOrder') ? ( |
896 | 916 | <Button |
897 | 917 | className="p-0" |
... | ... | @@ -1327,6 +1347,37 @@ const OrderPage = () => { |
1327 | 1347 | <Flex justify="flex-end"> |
1328 | 1348 | <Space.Compact direction="vertical" align="end"> |
1329 | 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 | 1381 | {record.mainPath?.includes('sendProduct') ? ( |
1331 | 1382 | <Button |
1332 | 1383 | className="p-0" |
... | ... | @@ -1596,7 +1647,6 @@ const OrderPage = () => { |
1596 | 1647 | if (selectedSubOrders === undefined) { |
1597 | 1648 | setSelectedRows(record.subOrderInformationLists); |
1598 | 1649 | } |
1599 | - console.log(selectedRows); | |
1600 | 1650 | for (let i = 0; i < selectedRows.length; i++) { |
1601 | 1651 | if ( |
1602 | 1652 | selectedRows[i].orderStatus !== 'UNAUDITED' && |
... | ... | @@ -1617,7 +1667,7 @@ const OrderPage = () => { |
1617 | 1667 | '' |
1618 | 1668 | )} |
1619 | 1669 | |
1620 | - {record.mainPath?.includes('') ? ( | |
1670 | + {record.mainPath?.includes('afterSalesCheck') ? ( | |
1621 | 1671 | <Button |
1622 | 1672 | className="p-0" |
1623 | 1673 | type="link" |
... | ... | @@ -1628,8 +1678,10 @@ const OrderPage = () => { |
1628 | 1678 | setSelectedRows(record.subOrderInformationLists); |
1629 | 1679 | } |
1630 | 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 | 1685 | return; |
1634 | 1686 | } |
1635 | 1687 | } |
... | ... | @@ -1702,10 +1754,6 @@ const OrderPage = () => { |
1702 | 1754 | setSelectedRows(selectedSubOrders); |
1703 | 1755 | if (selectedSubOrders === undefined) { |
1704 | 1756 | setSelectedRows(record.subOrderInformationLists); |
1705 | - console.log( | |
1706 | - 'subOrderInformationLists:' + | |
1707 | - record.subOrderInformationLists, | |
1708 | - ); | |
1709 | 1757 | } |
1710 | 1758 | for (let i = 0; i < selectedRows.length; i++) { |
1711 | 1759 | if ( |
... | ... | @@ -1737,10 +1785,6 @@ const OrderPage = () => { |
1737 | 1785 | setSelectedRows(selectedSubOrders); |
1738 | 1786 | if (selectedSubOrders === undefined) { |
1739 | 1787 | setSelectedRows(record.subOrderInformationLists); |
1740 | - console.log( | |
1741 | - 'subOrderInformationLists:' + | |
1742 | - record.subOrderInformationLists, | |
1743 | - ); | |
1744 | 1788 | } |
1745 | 1789 | for (let i = 0; i < selectedRows.length; i++) { |
1746 | 1790 | if ( |
... | ... | @@ -1790,7 +1834,7 @@ const OrderPage = () => { |
1790 | 1834 | '' |
1791 | 1835 | )} |
1792 | 1836 | |
1793 | - {record.mainPath?.includes('afterSalesCompletion') ? ( | |
1837 | + {/* {record.mainPath?.includes('afterSalesCompletion') ? ( | |
1794 | 1838 | <ButtonConfirm |
1795 | 1839 | className="p-0" |
1796 | 1840 | title="售后是否已完成?" |
... | ... | @@ -1832,7 +1876,7 @@ const OrderPage = () => { |
1832 | 1876 | /> |
1833 | 1877 | ) : ( |
1834 | 1878 | '' |
1835 | - )} | |
1879 | + )} */} | |
1836 | 1880 | |
1837 | 1881 | {record.mainPath?.includes('orderCancel') ? ( |
1838 | 1882 | <ButtonConfirm |
... | ... | @@ -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 | 1993 | mainOrdersColumns.push({ |
1948 | 1994 | title: '采购下单状态', |
1949 | 1995 | dataIndex: 'procureOrderStatus', | ... | ... |
src/utils/index.ts
... | ... | @@ -67,7 +67,6 @@ function formatdate(inputDateTime: string) { |
67 | 67 | } |
68 | 68 | |
69 | 69 | function formatSalesCode(salesCode: any) { |
70 | - console.log('in'); | |
71 | 70 | let newSalesCode = salesCode; |
72 | 71 | if (newSalesCode.indexOf('_')) { |
73 | 72 | newSalesCode = newSalesCode.split('_'); |
... | ... | @@ -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 | 134 | function getAliYunOSSFileNameFromUrl(url: string) { |
128 | 135 | try { |
129 | 136 | // 使用URL对象解析链接 |
... | ... | @@ -135,7 +142,15 @@ function getAliYunOSSFileNameFromUrl(url: string) { |
135 | 142 | |
136 | 143 | // 检查文件名是否包含至少一个点(.)以确保是一个合法的文件名 |
137 | 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 | 154 | } else { |
140 | 155 | throw new Error('Invalid file name in the URL'); |
141 | 156 | } |
... | ... | @@ -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 | 227 | export { |
192 | 228 | appendFormData, |
193 | 229 | blobToFile, |
... | ... | @@ -202,5 +238,6 @@ export { |
202 | 238 | formatdate, |
203 | 239 | getAliYunOSSFileNameFromUrl, |
204 | 240 | getUserInfo, |
241 | + splitByFirstTwoDashes, | |
205 | 242 | transImageFile, |
206 | 243 | }; | ... | ... |