Commit dccb02bf972edf6ffe790241ff0477e8e44021d5
1 parent
af1fb285
订件
Showing
2 changed files
with
14 additions
and
12 deletions
src/pages/pms/comonents/PartModal.tsx
... | ... | @@ -33,7 +33,7 @@ export default function Index({ onCancel, visible, parts=[], onOk }: Props) { |
33 | 33 | } |
34 | 34 | |
35 | 35 | const handleChange = debounce((value) => { |
36 | - setPartList(partList.filter(it => { | |
36 | + setPartList(parts.filter(it => { | |
37 | 37 | return (it.partCode || '').includes(value) |
38 | 38 | || (it.partName || '').includes(value) |
39 | 39 | || (it.supplierName || '').includes(value); |
... | ... | @@ -74,9 +74,9 @@ export default function Index({ onCancel, visible, parts=[], onOk }: Props) { |
74 | 74 | pagination={false} |
75 | 75 | rowSelection={{ |
76 | 76 | type: "checkbox", |
77 | - selectedRowKeys: selectedParts.map(part => part.partCode || ''), | |
77 | + selectedRowKeys: selectedParts.map(part => `${part.partCode}-${part.storageId}`), | |
78 | 78 | onSelect: (row: PartVO, _selected: boolean) => { |
79 | - const index = selectedParts.findIndex(_row => _row.partCode == row.partCode); | |
79 | + const index = selectedParts.findIndex(_row => _row.partCode == row.partCode && _row.storageId == row.storageId); | |
80 | 80 | let newData = [...selectedParts]; |
81 | 81 | if (_selected) { |
82 | 82 | newData.unshift(row); |
... | ... | @@ -86,23 +86,25 @@ export default function Index({ onCancel, visible, parts=[], onOk }: Props) { |
86 | 86 | setSelectedParts([...newData]); |
87 | 87 | }, |
88 | 88 | onSelectAll: (selected, selectedRows, changeRows) => { |
89 | - const changedKeys = changeRows.map(row => row.partCode); | |
89 | + const changedKeys = changeRows.map(row => `${row.partCode}-${row.storageId}`); | |
90 | 90 | let newData = [...selectedParts]; |
91 | 91 | // 全选 |
92 | 92 | if (selected) { |
93 | 93 | // 过滤掉已选的 |
94 | - newData = selectedParts.concat(changeRows.filter(row => !selectedParts.some(item => item.partCode == row.partCode)),); | |
94 | + newData = selectedParts.concat(changeRows.filter(row => !selectedParts.some(item => item.partCode == row.partCode && item.storageId == row.storageId)),); | |
95 | 95 | } else { |
96 | 96 | // 全不选 - 去掉已选的 |
97 | - newData = selectedParts.filter(row => !changedKeys.includes(row.partCode)); | |
97 | + newData = selectedParts.filter(row => !changedKeys.includes(`${row.partCode}-${row.storageId}`)); | |
98 | 98 | } |
99 | 99 | setSelectedParts(newData); |
100 | 100 | }, |
101 | 101 | }} |
102 | - rowKey={(record) => `${record.partCode}`} | |
102 | + rowKey={(record) => `${record.partCode}-${record.storageId}`} | |
103 | 103 | > |
104 | 104 | <Column title="配件编码" dataIndex="partCode" /> |
105 | 105 | <Column title="配件名称" dataIndex="partName" /> |
106 | + <Column title="库房名称" dataIndex="storageName" /> | |
107 | + <Column title="门店名称" dataIndex="shopName" /> | |
106 | 108 | <Column title="配件数量" dataIndex="count" /> |
107 | 109 | <Column title="上次采购供应商" dataIndex="supplierName" /> |
108 | 110 | </Table> | ... | ... |
src/pages/pms/comonents/SupplierModal.tsx
... | ... | @@ -96,7 +96,7 @@ export default function Index({ onCancel, brandId, visible, parts = [], onOk, su |
96 | 96 | dataSource={selectedParts} |
97 | 97 | pagination={false} |
98 | 98 | scroll={{y: 600}} |
99 | - rowKey="partCode" | |
99 | + rowKey={(t, _) => `${t.partCode}-${t.storageId}`} | |
100 | 100 | > |
101 | 101 | <Column title="配件编码" dataIndex="partCode" /> |
102 | 102 | <Column title="配件名称" dataIndex="partName" /> |
... | ... | @@ -107,7 +107,7 @@ export default function Index({ onCancel, brandId, visible, parts = [], onOk, su |
107 | 107 | <Column |
108 | 108 | title="操作" |
109 | 109 | render={(text, _item: any) => ( |
110 | - <a onClick={() => setSelectedParts(selectedParts.filter(i => i.partCode != _item.partCode))}> | |
110 | + <a onClick={() => setSelectedParts(selectedParts.filter(i => i.partCode != _item.partCode || i.storageId != _item.storageId))}> | |
111 | 111 | 删除 |
112 | 112 | </a> |
113 | 113 | )} |
... | ... | @@ -116,10 +116,10 @@ export default function Index({ onCancel, brandId, visible, parts = [], onOk, su |
116 | 116 | <PartModal |
117 | 117 | visible={visiblePart} |
118 | 118 | onCancel={() => setVisiblePart(false)} |
119 | - parts={partData.filter(it => !selectedParts.map(i => i.partCode).includes(it.partCode))} | |
119 | + parts={partData.filter(it => !selectedParts.map(i => `${i.partCode}-${i.storageId}`).includes(`${it.partCode}-${it.storageId}`))} | |
120 | 120 | onOk={(ps=[]) => { |
121 | - const ids = [...selectedParts, ...ps].map(it => it.partCode); | |
122 | - setSelectedParts(parts.filter(it => ids.includes(it.partCode))); | |
121 | + const ids = [...selectedParts, ...ps].map(it => `${it.partCode}-${it.storageId}`); | |
122 | + setSelectedParts(parts.filter(it => ids.includes(`${it.partCode}-${it.storageId}`))); | |
123 | 123 | }} |
124 | 124 | /> |
125 | 125 | </Modal> | ... | ... |