Commit 08ac50b94c027ab40f2df2bd9fd0f1d3b22409d7
1 parent
2b8cbfa6
feat(cas): 工单时效配置
Showing
2 changed files
with
51 additions
and
51 deletions
src/pages/cas/baseConfig/OrderAging/components/EditModal.tsx
1 | 1 | import React, { useEffect, useMemo, useState } from 'react'; |
2 | 2 | import { Form, Input, InputNumber, message, Modal, Select } from 'antd'; |
3 | 3 | |
4 | -// import SelectorWithFull from '@/components/SelectorWithFull'; | |
4 | +import SelectorWithFull from '@/components/SelectorWithFull'; | |
5 | 5 | import useInitail from '@/hooks/useInitail'; |
6 | 6 | |
7 | 7 | import { getDealerApi, getShopByBizApi } from '@/common/api'; |
... | ... | @@ -19,13 +19,13 @@ interface Props { |
19 | 19 | export default function EditModal({ open, onCancel, detail }: Props) { |
20 | 20 | const [form] = Form.useForm(); |
21 | 21 | |
22 | - // const selectDealerIds = Form.useWatch('dealers', form) || []; | |
22 | + const selectDealerIds = Form.useWatch('dealers', form) || []; | |
23 | 23 | |
24 | 24 | const [delay, setDelay] = useState(true); |
25 | 25 | const { data: dealers, setParams: setDealerParams } = useInitail(getDealerApi, [], {}, delay); |
26 | 26 | // const { data: shops, setParams: setShopParams } = useInitail(getShopByBizApi, [], { bizType: 2 }, delay); |
27 | - // const [dealerShopsMap, setDealerShopsMap] = useState(new Map<number, CommonApi.OptionVO[]>()); | |
28 | - // let shops = Array.from(dealerShopsMap.values()).flat(); | |
27 | + const [dealerShopsMap, setDealerShopsMap] = useState(new Map<number, CommonApi.OptionVO[]>()); | |
28 | + const shops = Array.from(dealerShopsMap.values()).flat(); | |
29 | 29 | |
30 | 30 | useEffect(() => { |
31 | 31 | if (open) { |
... | ... | @@ -47,25 +47,25 @@ export default function EditModal({ open, onCancel, detail }: Props) { |
47 | 47 | } |
48 | 48 | }, [open]); |
49 | 49 | |
50 | - // function handleDealerChange(selectIds: number[]) { | |
51 | - // let prevDealerIds = Array.from(dealerShopsMap.keys()); | |
52 | - // let delDealerIds = prevDealerIds.filter((id) => !selectIds.includes(id)); | |
53 | - // // 如果商家被移出,则同步删除对应的门店 | |
54 | - // if (delDealerIds.length > 0) { | |
55 | - // delDealerIds.forEach((id) => dealerShopsMap.delete(id)); | |
56 | - // } | |
57 | - // | |
58 | - // // 如果商家被选中,则同步获取对应的门店 | |
59 | - // selectIds.forEach((id) => { | |
60 | - // if (!dealerShopsMap.has(id)) { | |
61 | - // getShopByBizApi({ bizType: 2, dealerId: id }).then((res) => { | |
62 | - // const shops = res.data || []; | |
63 | - // dealerShopsMap.set(id, shops); | |
64 | - // }); | |
65 | - // } | |
66 | - // }); | |
67 | - // setDealerShopsMap(new Map(dealerShopsMap)); | |
68 | - // } | |
50 | + function handleDealerChange(selectIds: number[]) { | |
51 | + const prevDealerIds = Array.from(dealerShopsMap.keys()); | |
52 | + const delDealerIds = prevDealerIds.filter((id) => !selectIds.includes(id)); | |
53 | + // 如果商家被移出,则同步删除对应的门店 | |
54 | + if (delDealerIds.length > 0) { | |
55 | + delDealerIds.forEach((id) => dealerShopsMap.delete(id)); | |
56 | + } | |
57 | + | |
58 | + // 如果商家被选中,则同步获取对应的门店 | |
59 | + selectIds.forEach((id) => { | |
60 | + if (!dealerShopsMap.has(id)) { | |
61 | + getShopByBizApi({ bizType: 2, dealerId: id }).then((res) => { | |
62 | + const shops = res.data || []; | |
63 | + dealerShopsMap.set(id, shops); | |
64 | + }); | |
65 | + } | |
66 | + }); | |
67 | + setDealerShopsMap(new Map(dealerShopsMap)); | |
68 | + } | |
69 | 69 | |
70 | 70 | function handleSave(formValue: any) { |
71 | 71 | saveApi({ ...formValue }) |
... | ... | @@ -87,6 +87,32 @@ export default function EditModal({ open, onCancel, detail }: Props) { |
87 | 87 | > |
88 | 88 | <Form form={form} labelCol={{ span: 6 }} wrapperCol={{ span: 16 }} initialValues={{ agingUnit: 3 }} onFinish={handleSave}> |
89 | 89 | <FormItem name="id" hidden /> |
90 | + <FormItem name="dealers" label="适用商家" rules={[{ required: true, message: '请选择商家' }]}> | |
91 | + <SelectorWithFull | |
92 | + placeholder="请选择商家" | |
93 | + data={dealers} | |
94 | + allowClear | |
95 | + multiple | |
96 | + showSearch | |
97 | + treeNodeFilterProp="label" | |
98 | + autoClearSearchValue={false} | |
99 | + fieldKeyNames={{ keyName: 'id', valueName: 'id', labelName: 'name' }} | |
100 | + onChange={(selectedVal) => handleDealerChange(selectedVal)} | |
101 | + /> | |
102 | + </FormItem> | |
103 | + <FormItem name="shops" label="适用门店" rules={[{ required: true, message: '请选择门店' }]}> | |
104 | + <SelectorWithFull | |
105 | + placeholder="请选择门店" | |
106 | + data={shops} | |
107 | + allowClear | |
108 | + multiple | |
109 | + showSearch | |
110 | + treeNodeFilterProp="label" | |
111 | + autoClearSearchValue={false} | |
112 | + disabled={shops.length === 0} | |
113 | + fieldKeyNames={{ keyName: 'id', valueName: 'id', labelName: 'name' }} | |
114 | + /> | |
115 | + </FormItem> | |
90 | 116 | <FormItem name="serviceType" label="工单类型" rules={[{ required: true, message: '请选择工单类型' }]}> |
91 | 117 | <Select style={{ width: 240 }} placeholder="选择工单类型"> |
92 | 118 | <Option value={2}>机修</Option> |
... | ... | @@ -109,32 +135,6 @@ export default function EditModal({ open, onCancel, detail }: Props) { |
109 | 135 | </FormItem> |
110 | 136 | </Input.Group> |
111 | 137 | </FormItem> |
112 | - {/*<FormItem name="dealers" label="适用商家" rules={[{ required: true, message: '请选择商家' }]}>*/} | |
113 | - {/* <SelectorWithFull*/} | |
114 | - {/* placeholder="请选择商家"*/} | |
115 | - {/* data={dealers}*/} | |
116 | - {/* allowClear*/} | |
117 | - {/* multiple*/} | |
118 | - {/* showSearch*/} | |
119 | - {/* treeNodeFilterProp="label"*/} | |
120 | - {/* autoClearSearchValue={false}*/} | |
121 | - {/* fieldKeyNames={{ keyName: 'id', valueName: 'id', labelName: 'name' }}*/} | |
122 | - {/* onChange={(selectedVal) => handleDealerChange(selectedVal)}*/} | |
123 | - {/* />*/} | |
124 | - {/*</FormItem>*/} | |
125 | - {/*<FormItem name="shops" label="适用门店" rules={[{ required: true, message: '请选择门店' }]}>*/} | |
126 | - {/* <SelectorWithFull*/} | |
127 | - {/* placeholder="请选择门店"*/} | |
128 | - {/* data={shops}*/} | |
129 | - {/* allowClear*/} | |
130 | - {/* multiple*/} | |
131 | - {/* showSearch*/} | |
132 | - {/* treeNodeFilterProp="label"*/} | |
133 | - {/* autoClearSearchValue={false}*/} | |
134 | - {/* disabled={selectDealerIds.length === 0}*/} | |
135 | - {/* fieldKeyNames={{ keyName: 'id', valueName: 'id', labelName: 'name' }}*/} | |
136 | - {/* />*/} | |
137 | - {/*</FormItem>*/} | |
138 | 138 | </Form> |
139 | 139 | </Modal> |
140 | 140 | ); | ... | ... |
src/pages/cas/baseConfig/OrderAging/index.tsx
... | ... | @@ -47,14 +47,14 @@ export default function WorkStationIndex() { |
47 | 47 | </Row> |
48 | 48 | |
49 | 49 | <Table dataSource={list} pagination={paginationConfig} rowKey="id" loading={loading}> |
50 | - <Column title="工单类型" dataIndex="serviceType" render={(val) => <Tag>{ServiceTypeNameEnum[val]}</Tag>} /> | |
51 | - <Column title="时效时长" dataIndex="aging" render={(val, record: ListResult) => `${val}${AgingUnitNameEnum[record.agingUnit]}`} /> | |
52 | 50 | <Column |
53 | 51 | title="适用商家" |
54 | 52 | dataIndex="dealers" |
55 | 53 | render={(dealers: any) => <TextWithMore title="适用商家" list={dealers} dataIndex="dealerName" />} |
56 | 54 | /> |
57 | 55 | <Column title="适用门店" dataIndex="shops" render={(shops: any) => <TextWithMore title="适用门店" list={shops} dataIndex="shopName" />} /> |
56 | + <Column title="工单类型" dataIndex="serviceType" render={(val) => <Tag>{ServiceTypeNameEnum[val]}</Tag>} /> | |
57 | + <Column title="时效时长" dataIndex="aging" render={(val, record: ListResult) => `${val}${AgingUnitNameEnum[record.agingUnit]}`} /> | |
58 | 58 | <Column |
59 | 59 | title="操作" |
60 | 60 | dataIndex="id" | ... | ... |