Commit 21c88431ec235be47bef09789a17205b9af19b0e

Authored by jiangwei
1 parent 79c03b69

加入计划配件上次供应商与本次供应商不同时进行提示

src/pages/pms/partPlan/PlanManage/subpages/Apply/components/PartModal.tsx
@@ -13,12 +13,15 @@ interface Props { @@ -13,12 +13,15 @@ interface Props {
13 parts: any[] 13 parts: any[]
14 onOk: (parts: any[]) => any 14 onOk: (parts: any[]) => any
15 setParams: Function 15 setParams: Function
  16 + _supplierId: number | undefined
16 } 17 }
17 const {Option} = Select; 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 const [selectedParts, setSelectedParts] = useState<any[]>([]); 20 const [selectedParts, setSelectedParts] = useState<any[]>([]);
20 const [dfParam, setDfParam] = useState<any>({keywords: ''}); 21 const [dfParam, setDfParam] = useState<any>({keywords: ''});
21 const [partList, setPartList] = useState(parts); 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 const shopNames = useMemo(() => { 26 const shopNames = useMemo(() => {
24 return Array.from(new Set(parts.map(it => it.shopName || '').filter(it => !!it))); 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,6 +40,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
37 useEffect(() => { 40 useEffect(() => {
38 if (!visible) { 41 if (!visible) {
39 setSelectedParts([]); 42 setSelectedParts([]);
  43 + setPartArr([]);
40 setPartList(parts); 44 setPartList(parts);
41 } 45 }
42 }, [visible, parts]); 46 }, [visible, parts]);
@@ -46,6 +50,14 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: @@ -46,6 +50,14 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
46 message.error("请选择配件"); 50 message.error("请选择配件");
47 return; 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 onOk && onOk(selectedParts); 61 onOk && onOk(selectedParts);
50 onCancel && onCancel(); 62 onCancel && onCancel();
51 } 63 }
@@ -81,6 +93,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: @@ -81,6 +93,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
81 visible={visible} 93 visible={visible}
82 title="配件采购明细" 94 title="配件采购明细"
83 onCancel={onCancel} 95 onCancel={onCancel}
  96 + maskClosable={false}
84 footer={[ 97 footer={[
85 <Button key="cancel" onClick={onCancel}>取消</Button>, 98 <Button key="cancel" onClick={onCancel}>取消</Button>,
86 <Button 99 <Button
@@ -195,6 +208,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: @@ -195,6 +208,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
195 } else if (index > -1) { 208 } else if (index > -1) {
196 newData.splice(index, 1); 209 newData.splice(index, 1);
197 } 210 }
  211 + setPartArr(newData);
198 setSelectedParts([...newData]); 212 setSelectedParts([...newData]);
199 }, 213 },
200 onSelectAll: (selected, selectedRows, changeRows) => { 214 onSelectAll: (selected, selectedRows, changeRows) => {
@@ -206,6 +220,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: @@ -206,6 +220,7 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
206 } else { 220 } else {
207 newData = selectedParts.filter(row => !changedKeys.includes(`${row.poolId}`)); 221 newData = selectedParts.filter(row => !changedKeys.includes(`${row.poolId}`));
208 } 222 }
  223 + setPartArr(newData);
209 setSelectedParts(newData); 224 setSelectedParts(newData);
210 }, 225 },
211 }} 226 }}
@@ -220,6 +235,24 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }: @@ -220,6 +235,24 @@ export default function Index({ onCancel, visible, parts=[], onOk, setParams }:
220 <Column title="配件来源类型" dataIndex="typeName" /> 235 <Column title="配件来源类型" dataIndex="typeName" />
221 <Column title="上次采购供应商" dataIndex="supplierName" /> 236 <Column title="上次采购供应商" dataIndex="supplierName" />
222 </Table> 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 </Modal> 256 </Modal>
224 ); 257 );
225 } 258 }
src/pages/pms/partPlan/PlanManage/subpages/Apply/index.tsx
@@ -41,6 +41,7 @@ export default function Index() { @@ -41,6 +41,7 @@ export default function Index() {
41 const partList = flattenDeep(dealerList.map(it => (it.suppliers || []).map((su: any) => (su.storages || []).map((st: any) => (st.parts || []))))); 41 const partList = flattenDeep(dealerList.map(it => (it.suppliers || []).map((su: any) => (su.storages || []).map((st: any) => (st.parts || [])))));
42 const poolIds = partList.map((it: any) => it.poolId); 42 const poolIds = partList.map((it: any) => it.poolId);
43 const [info, setInfo] = useState<{ remark?: string, fids?: any }>(); 43 const [info, setInfo] = useState<{ remark?: string, fids?: any }>();
  44 + const [_supplierId, setSupplierId] = useState<number| undefined>(undefined);
44 45
45 useEffect(() => { 46 useEffect(() => {
46 if (planId?.planId) { 47 if (planId?.planId) {
@@ -254,7 +255,7 @@ export default function Index() { @@ -254,7 +255,7 @@ export default function Index() {
254 <div key={`supplier${supplier.supplierId}`} style={{ marginTop: 10, marginLeft: 40 }}> 255 <div key={`supplier${supplier.supplierId}`} style={{ marginTop: 10, marginLeft: 40 }}>
255 <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center'}}> 256 <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center'}}>
256 <div style={{ fontWeight: "bold" }}>{`供应商: ${supplier.supplierName || ''}`}</div> 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 </a> 260 </a>
260 <Popconfirm 261 <Popconfirm
@@ -322,6 +323,7 @@ export default function Index() { @@ -322,6 +323,7 @@ export default function Index() {
322 parts={parts.filter(it => !poolIds.includes(it.poolId))} 323 parts={parts.filter(it => !poolIds.includes(it.poolId))}
323 onOk={onOk} 324 onOk={onOk}
324 setParams={setParams} 325 setParams={setParams}
  326 + _supplierId={_supplierId}
325 /> 327 />
326 <PartDetailModal 328 <PartDetailModal
327 visible={visiblePartDetail} 329 visible={visiblePartDetail}