Commit 21c88431ec235be47bef09789a17205b9af19b0e
1 parent
79c03b69
加入计划配件上次供应商与本次供应商不同时进行提示
Showing
2 changed files
with
37 additions
and
2 deletions
src/pages/pms/partPlan/PlanManage/subpages/Apply/components/PartModal.tsx
... | ... | @@ -13,12 +13,15 @@ interface Props { |
13 | 13 | parts: any[] |
14 | 14 | onOk: (parts: any[]) => any |
15 | 15 | setParams: Function |
16 | + _supplierId: number | undefined | |
16 | 17 | } |
17 | 18 | const {Option} = Select; |
18 | -export default function Index({ onCancel, visible, parts=[], onOk, setParams }: Props) { | |
19 | +export default function Index({ onCancel, visible, parts = [], onOk, setParams, _supplierId }: Props) { | |
19 | 20 | const [selectedParts, setSelectedParts] = useState<any[]>([]); |
20 | 21 | const [dfParam, setDfParam] = useState<any>({keywords: ''}); |
21 | 22 | const [partList, setPartList] = useState(parts); |
23 | + const [info, setInfo] = useState<{open: boolean, partName: string, poolId?: number}>({open: false, partName: '', poolId: undefined}); | |
24 | + const [partArr, setPartArr] = useState<any[]>([]); | |
22 | 25 | |
23 | 26 | const shopNames = useMemo(() => { |
24 | 27 | return Array.from(new Set(parts.map(it => it.shopName || '').filter(it => !!it))); |
... | ... | @@ -37,6 +40,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
37 | 40 | useEffect(() => { |
38 | 41 | if (!visible) { |
39 | 42 | setSelectedParts([]); |
43 | + setPartArr([]); | |
40 | 44 | setPartList(parts); |
41 | 45 | } |
42 | 46 | }, [visible, parts]); |
... | ... | @@ -46,6 +50,14 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
46 | 50 | message.error("请选择配件"); |
47 | 51 | return; |
48 | 52 | } |
53 | + if (partArr.some(it => !!it.supplierId)) { | |
54 | + for (const item of partArr) { | |
55 | + if (!!item.supplierId && item.supplierId != _supplierId) { | |
56 | + setInfo({ open: true, partName: item.partName, poolId: item.poolId }); | |
57 | + return; | |
58 | + } | |
59 | + } | |
60 | + } | |
49 | 61 | onOk && onOk(selectedParts); |
50 | 62 | onCancel && onCancel(); |
51 | 63 | } |
... | ... | @@ -81,6 +93,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
81 | 93 | visible={visible} |
82 | 94 | title="配件采购明细" |
83 | 95 | onCancel={onCancel} |
96 | + maskClosable={false} | |
84 | 97 | footer={[ |
85 | 98 | <Button key="cancel" onClick={onCancel}>取消</Button>, |
86 | 99 | <Button |
... | ... | @@ -195,6 +208,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
195 | 208 | } else if (index > -1) { |
196 | 209 | newData.splice(index, 1); |
197 | 210 | } |
211 | + setPartArr(newData); | |
198 | 212 | setSelectedParts([...newData]); |
199 | 213 | }, |
200 | 214 | onSelectAll: (selected, selectedRows, changeRows) => { |
... | ... | @@ -206,6 +220,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
206 | 220 | } else { |
207 | 221 | newData = selectedParts.filter(row => !changedKeys.includes(`${row.poolId}`)); |
208 | 222 | } |
223 | + setPartArr(newData); | |
209 | 224 | setSelectedParts(newData); |
210 | 225 | }, |
211 | 226 | }} |
... | ... | @@ -220,6 +235,24 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: |
220 | 235 | <Column title="配件来源类型" dataIndex="typeName" /> |
221 | 236 | <Column title="上次采购供应商" dataIndex="supplierName" /> |
222 | 237 | </Table> |
238 | + <Modal | |
239 | + title="提示" | |
240 | + open={info.open} | |
241 | + maskClosable={false} | |
242 | + cancelText="重新选择" | |
243 | + okText="继续" | |
244 | + onCancel={() => { | |
245 | + setPartArr(partArr.filter((i => i.poolId != info.poolId))); | |
246 | + setSelectedParts(selectedParts.filter((i => i.poolId != info.poolId))); | |
247 | + setInfo({open: false, partName: '', poolId: undefined}); | |
248 | + }} | |
249 | + onOk={() => { | |
250 | + setPartArr(partArr.filter((i => i.poolId != info.poolId))); | |
251 | + setInfo({ open: false, partName: '', poolId: undefined }); | |
252 | + }} | |
253 | + > | |
254 | + <p style={{ color: '#666666' }}><span style={{ color: '#333333', fontWeight: '500', marginRight: 3}}>{info.partName}</span>本次采购供应商和上次采购供应商不一致,是否继续?</p> | |
255 | + </Modal> | |
223 | 256 | </Modal> |
224 | 257 | ); |
225 | 258 | } | ... | ... |
src/pages/pms/partPlan/PlanManage/subpages/Apply/index.tsx
... | ... | @@ -41,6 +41,7 @@ export default function Index() { |
41 | 41 | const partList = flattenDeep(dealerList.map(it => (it.suppliers || []).map((su: any) => (su.storages || []).map((st: any) => (st.parts || []))))); |
42 | 42 | const poolIds = partList.map((it: any) => it.poolId); |
43 | 43 | const [info, setInfo] = useState<{ remark?: string, fids?: any }>(); |
44 | + const [_supplierId, setSupplierId] = useState<number| undefined>(undefined); | |
44 | 45 | |
45 | 46 | useEffect(() => { |
46 | 47 | if (planId?.planId) { |
... | ... | @@ -254,7 +255,7 @@ export default function Index() { |
254 | 255 | <div key={`supplier${supplier.supplierId}`} style={{ marginTop: 10, marginLeft: 40 }}> |
255 | 256 | <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center'}}> |
256 | 257 | <div style={{ fontWeight: "bold" }}>{`供应商: ${supplier.supplierName || ''}`}</div> |
257 | - <a style={{marginLeft: 20}} onClick={() => { setVisiblePart(true); setDealer({...dealer, ...supplier}); }}> | |
258 | + <a style={{ marginLeft: 20 }} onClick={() => { setVisiblePart(true); setDealer({ ...dealer, ...supplier }); setSupplierId(supplier.supplierId); }}> | |
258 | 259 | 添加采购配件 |
259 | 260 | </a> |
260 | 261 | <Popconfirm |
... | ... | @@ -322,6 +323,7 @@ export default function Index() { |
322 | 323 | parts={parts.filter(it => !poolIds.includes(it.poolId))} |
323 | 324 | onOk={onOk} |
324 | 325 | setParams={setParams} |
326 | + _supplierId={_supplierId} | |
325 | 327 | /> |
326 | 328 | <PartDetailModal |
327 | 329 | visible={visiblePartDetail} | ... | ... |