Commit 759652c1700fd93379e63666b38e9fc63efbd2ce
1 parent
a0d76721
fix: 显示发票id
Showing
2 changed files
with
57 additions
and
3 deletions
src/pages/Invoice/Invoice/index.tsx
@@ -52,6 +52,11 @@ const InvoiceRecord = () => { | @@ -52,6 +52,11 @@ const InvoiceRecord = () => { | ||
52 | let dataIndex = item.dataIndex; | 52 | let dataIndex = item.dataIndex; |
53 | let dataType = item.valueType; | 53 | let dataType = item.valueType; |
54 | 54 | ||
55 | + // 如果是mainOrderIds列并且已经有自己的render函数,不要覆盖 | ||
56 | + if (dataIndex === 'mainOrderIds' && item.render) { | ||
57 | + return newItem; | ||
58 | + } | ||
59 | + | ||
55 | newItem.render = (text, record) => { | 60 | newItem.render = (text, record) => { |
56 | let textValue = record[dataIndex]; | 61 | let textValue = record[dataIndex]; |
57 | 62 | ||
@@ -108,16 +113,17 @@ const InvoiceRecord = () => { | @@ -108,16 +113,17 @@ const InvoiceRecord = () => { | ||
108 | if (record.paths?.includes('edit')) { | 113 | if (record.paths?.includes('edit')) { |
109 | btns.push( | 114 | btns.push( |
110 | <a | 115 | <a |
116 | + className="p-0" | ||
111 | key="editable" | 117 | key="editable" |
112 | onClick={() => { | 118 | onClick={() => { |
113 | action?.startEditable?.(record.id); | 119 | action?.startEditable?.(record.id); |
114 | }} | 120 | }} |
121 | + style={{ marginRight: 8, whiteSpace: 'nowrap' }} | ||
115 | > | 122 | > |
116 | 编辑 | 123 | 编辑 |
117 | </a>, | 124 | </a>, |
118 | ); | 125 | ); |
119 | } | 126 | } |
120 | - | ||
121 | if (record.paths?.includes('writeOff') && !record.writeOffId) { | 127 | if (record.paths?.includes('writeOff') && !record.writeOffId) { |
122 | btns.push( | 128 | btns.push( |
123 | <InvoiceWriteOffModal | 129 | <InvoiceWriteOffModal |
src/pages/Invoice/constant.tsx
1 | +import EllipsisDiv from '@/components/Div/EllipsisDiv'; | ||
1 | import { enumToProTableEnumValue } from '@/utils'; | 2 | import { enumToProTableEnumValue } from '@/utils'; |
2 | import { PAYEE_OPTIONS } from '../Order/constant'; | 3 | import { PAYEE_OPTIONS } from '../Order/constant'; |
3 | 4 | ||
@@ -45,6 +46,53 @@ export const INVOICE_COLUMNS = [ | @@ -45,6 +46,53 @@ export const INVOICE_COLUMNS = [ | ||
45 | width: 100, | 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 | dataIndex: 'mainOrderId', | 96 | dataIndex: 'mainOrderId', |
49 | title: '主订单id', | 97 | title: '主订单id', |
50 | valueType: 'text', | 98 | valueType: 'text', |
@@ -65,7 +113,7 @@ export const INVOICE_COLUMNS = [ | @@ -65,7 +113,7 @@ export const INVOICE_COLUMNS = [ | ||
65 | title: '状态', | 113 | title: '状态', |
66 | dataIndex: 'statusText', | 114 | dataIndex: 'statusText', |
67 | valueType: 'text', | 115 | valueType: 'text', |
68 | - width: 180, | 116 | + width: 100, |
69 | readonly: true, | 117 | readonly: true, |
70 | hideInSearch: true, | 118 | hideInSearch: true, |
71 | }, | 119 | }, |
@@ -73,7 +121,7 @@ export const INVOICE_COLUMNS = [ | @@ -73,7 +121,7 @@ export const INVOICE_COLUMNS = [ | ||
73 | title: '状态', | 121 | title: '状态', |
74 | dataIndex: 'writeOffIdIsNull', | 122 | dataIndex: 'writeOffIdIsNull', |
75 | valueType: 'select', | 123 | valueType: 'select', |
76 | - width: 100, | 124 | + width: 80, |
77 | valueEnum: { | 125 | valueEnum: { |
78 | true: { | 126 | true: { |
79 | text: '未核销', | 127 | text: '未核销', |