Commit d90ecca7ce1c14e5f056c5c09b9faccbc3968801
Merge branch 'feature-invoiceOrderId' into 'master'
fix: 显示发票id See merge request !56
Showing
2 changed files
with
57 additions
and
3 deletions
src/pages/Invoice/Invoice/index.tsx
... | ... | @@ -52,6 +52,11 @@ const InvoiceRecord = () => { |
52 | 52 | let dataIndex = item.dataIndex; |
53 | 53 | let dataType = item.valueType; |
54 | 54 | |
55 | + // 如果是mainOrderIds列并且已经有自己的render函数,不要覆盖 | |
56 | + if (dataIndex === 'mainOrderIds' && item.render) { | |
57 | + return newItem; | |
58 | + } | |
59 | + | |
55 | 60 | newItem.render = (text, record) => { |
56 | 61 | let textValue = record[dataIndex]; |
57 | 62 | |
... | ... | @@ -108,16 +113,17 @@ const InvoiceRecord = () => { |
108 | 113 | if (record.paths?.includes('edit')) { |
109 | 114 | btns.push( |
110 | 115 | <a |
116 | + className="p-0" | |
111 | 117 | key="editable" |
112 | 118 | onClick={() => { |
113 | 119 | action?.startEditable?.(record.id); |
114 | 120 | }} |
121 | + style={{ marginRight: 8, whiteSpace: 'nowrap' }} | |
115 | 122 | > |
116 | 123 | 编辑 |
117 | 124 | </a>, |
118 | 125 | ); |
119 | 126 | } |
120 | - | |
121 | 127 | if (record.paths?.includes('writeOff') && !record.writeOffId) { |
122 | 128 | btns.push( |
123 | 129 | <InvoiceWriteOffModal | ... | ... |
src/pages/Invoice/constant.tsx
1 | +import EllipsisDiv from '@/components/Div/EllipsisDiv'; | |
1 | 2 | import { enumToProTableEnumValue } from '@/utils'; |
2 | 3 | import { PAYEE_OPTIONS } from '../Order/constant'; |
3 | 4 | |
... | ... | @@ -45,6 +46,53 @@ export const INVOICE_COLUMNS = [ |
45 | 46 | width: 100, |
46 | 47 | }, |
47 | 48 | { |
49 | + dataIndex: 'mainOrderIds', | |
50 | + title: '主订单id', | |
51 | + valueType: 'text', | |
52 | + width: 160, | |
53 | + hideInTable: false, | |
54 | + hideInSearch: true, | |
55 | + readonly: true, | |
56 | + render: (text: any, record: any) => { | |
57 | + if (!record.mainOrderIds || record.mainOrderIds.length === 0) { | |
58 | + return '-'; | |
59 | + } | |
60 | + | |
61 | + let content = ''; | |
62 | + | |
63 | + // 直接从text参数中处理,可能是已处理过的数组 | |
64 | + if (text && Array.isArray(text)) { | |
65 | + content = text.join(', '); | |
66 | + } | |
67 | + // 如果record.mainOrderIds是数组,直接join | |
68 | + else if (Array.isArray(record.mainOrderIds)) { | |
69 | + content = record.mainOrderIds.join(', '); | |
70 | + } | |
71 | + // 如果是字符串,检查是否为JSON格式的数组 | |
72 | + else if (typeof record.mainOrderIds === 'string') { | |
73 | + try { | |
74 | + // 尝试解析JSON | |
75 | + const parsedData = JSON.parse(record.mainOrderIds); | |
76 | + if (Array.isArray(parsedData)) { | |
77 | + content = parsedData.join(', '); | |
78 | + } else { | |
79 | + content = record.mainOrderIds; | |
80 | + } | |
81 | + } catch (e) { | |
82 | + // 不是JSON格式,使用原始字符串 | |
83 | + content = record.mainOrderIds; | |
84 | + } | |
85 | + } | |
86 | + // 其他情况直接返回原值 | |
87 | + else { | |
88 | + content = String(record.mainOrderIds); | |
89 | + } | |
90 | + | |
91 | + // 使用EllipsisDiv组件显示带省略号的内容 | |
92 | + return <EllipsisDiv text={content} />; | |
93 | + }, | |
94 | + }, | |
95 | + { | |
48 | 96 | dataIndex: 'mainOrderId', |
49 | 97 | title: '主订单id', |
50 | 98 | valueType: 'text', |
... | ... | @@ -65,7 +113,7 @@ export const INVOICE_COLUMNS = [ |
65 | 113 | title: '状态', |
66 | 114 | dataIndex: 'statusText', |
67 | 115 | valueType: 'text', |
68 | - width: 180, | |
116 | + width: 100, | |
69 | 117 | readonly: true, |
70 | 118 | hideInSearch: true, |
71 | 119 | }, |
... | ... | @@ -73,7 +121,7 @@ export const INVOICE_COLUMNS = [ |
73 | 121 | title: '状态', |
74 | 122 | dataIndex: 'writeOffIdIsNull', |
75 | 123 | valueType: 'select', |
76 | - width: 100, | |
124 | + width: 80, | |
77 | 125 | valueEnum: { |
78 | 126 | true: { |
79 | 127 | text: '未核销', | ... | ... |