Commit 556c9f1576df5ba48d444f6e8769989f86e5b3e2

Authored by 莫红玲
1 parent 768deac2

加装车选择车型展示配置代码

src/pages/stock/TicketImport/api.ts
... ... @@ -53,7 +53,7 @@ export function getTicketBrand(): http.PromiseRespA<TicketImport.BrandListVO> {
53 53  
54 54 //启票模板校验
55 55 export function getTemplateCheck(params: { brandId: number, fid: string }): http.PromiseResp<void> {
56   - return request.get(`${FVM_HOST}/erp/ticket/template/valid`, {params});
  56 + return request.get(`${FVM_HOST}/erp/ticket/template/valid`, { params });
57 57 }
58 58  
59 59 /**
... ... @@ -74,12 +74,12 @@ export function saveCollateralApi(params: TicketImport.CollateralItem[]): http.P
74 74 /**
75 75 * 物料等待数据列表(选择指定客户列表)
76 76 */
77   -export function queryPersonApi(params: { keyword?: string, current?: number, pageSize?: number }): http.PromisePageResp<TicketImport.PersonItem> {
  77 +export function queryPersonApi(params: { keyword?: string, current?: number, pageSize?: number, seriesId?: number }): http.PromisePageResp<TicketImport.PersonItem> {
78 78 return request.get(`${FVM_HOST}/erp/ticket/waiting/material/query`, { params });
79 79 }
80 80 /**
81 81 * 查询物料选装项(加装车)
82 82 */
83   -export function queryOptionalListApi(params: { materialCode: string}): http.PromiseResp<TicketImport.OptionalList[]> {
  83 +export function queryOptionalListApi(params: { materialCode: string, keyword?: string }): http.PromiseResp<TicketImport.OptionalList[]> {
84 84 return request.get(`${FVM_HOST}/erp/ticket/material/optional/item`, { params });
85 85 }
... ...
src/pages/stock/TicketImport/components/ComfirmOrder.tsx
... ... @@ -46,7 +46,7 @@ export default function ComfirmModal() {
46 46  
47 47 useEffect(() => {
48 48 if (visible) {
49   - setParams({ ...innerParams, optionalTag: currentItem.optionalTag }, true);
  49 + setParams({ ...innerParams, optionalTag: currentItem.optionalTag, seriesId: currentItem.seriesId }, true);
50 50 }
51 51 }, [currentItem.optionalTag]);
52 52  
... ... @@ -69,9 +69,9 @@ export default function ComfirmModal() {
69 69 setCurrentItem({ ...currentItem, ...pa });
70 70 };
71 71  
72   - function getOptionals(materialCode: string) {
  72 + function getOptionals(materialCode: string, keyword?: string) {
73 73 setOptionalLoading(true);
74   - materialCode && queryOptionalListApi({ materialCode }).then((res) => {
  74 + materialCode && queryOptionalListApi({ materialCode, keyword }).then((res) => {
75 75 setOptionalList(res.data || []);
76 76 setOptionalLoading(false);
77 77 }).catch((err) => {
... ... @@ -262,7 +262,16 @@ export default function ComfirmModal() {
262 262 </Table>
263 263 ) : currentItem.optionalTag && !currentItem.customTag ? (
264 264 <>
265   - <div style={{ marginTop: 20 }}>选择加装车项目:</div>
  265 + <Row style={{ marginTop: 20, marginBottom: 10, alignItems: "center" }} justify="space-between">
  266 + <div>选择加装车项目:</div>
  267 + <Input.Search
  268 + style={{ width: 250 }}
  269 + enterButton="搜索"
  270 + allowClear
  271 + placeholder="项目名称"
  272 + onSearch={(v) => getOptionals(currentItem.materialCode!, v)}
  273 + />
  274 + </Row>
266 275 <Table
267 276 rowSelection={{
268 277 type: "checkbox",
... ...
src/pages/stock/VehicleAdditional/SelelctCarTreeAuth/SelectSpec.tsx 0 → 100644
  1 +import React, { useEffect, useState } from "react";
  2 +import {
  3 + Table,
  4 + Select,
  5 +} from "antd";
  6 +import {
  7 + CarOptionVo,
  8 +} from "@/pages/stock/Components/api";
  9 +import { ColumnsType } from 'antd/lib/table';
  10 +
  11 +interface Props {
  12 + onChange?: (pa: any) => void;
  13 + value?: any[];
  14 + disabled?: boolean;
  15 + level?: number; //1品牌,2车系,3车型
  16 + specList?: CarOptionVo[]
  17 +}
  18 +
  19 +interface Item {
  20 + label: string;
  21 + value: number;
  22 + key?: number;
  23 +}
  24 +const { Column } = Table;
  25 +const { Option } = Select;
  26 +
  27 +const columns: ColumnsType<CarOptionVo> = [
  28 + {
  29 + title: '车型',
  30 + dataIndex: 'name',
  31 + },
  32 + {
  33 + title: '配置代码',
  34 + dataIndex: 'specConfigCodeList',
  35 + render: (t) => t.map((i: string, key: number) => (<div key={i}>{key + 1}.{i}</div>))
  36 + },
  37 +];
  38 +export default function index({ onChange: onSelected, value, disabled, specList = [] }: Props) {
  39 + const rowSelection = {
  40 + onChange: (selectedRowKeys: React.Key[], selectedRows: CarOptionVo[]) => {
  41 + onSelected && onSelected(selectedRows);
  42 + },
  43 + };
  44 +
  45 + return (
  46 + <>
  47 + <Table
  48 + rowSelection={{
  49 + type: "checkbox",
  50 + selectedRowKeys: value && value.map(item => item.id),
  51 + ...rowSelection,
  52 + }}
  53 + pagination={false}
  54 + // loading={}
  55 + rowKey="id"
  56 + size="small"
  57 + scroll={{ y: 500 }}
  58 + columns={columns}
  59 + dataSource={specList}
  60 + />
  61 + </>
  62 + );
  63 +}
... ...
src/pages/stock/VehicleAdditional/components/CarSelect.tsx renamed to src/pages/stock/VehicleAdditional/SelelctCarTreeAuth/index.tsx
... ... @@ -7,22 +7,24 @@ import {
7 7 Form,
8 8 Select,
9 9 Space,
  10 + Spin,
  11 + message,
10 12 } from "antd";
11   -import useInitial from "@/hooks/useInitail";
12 13 import {
13 14 CarOptionVo,
14   - getOnsaleBrandApi,
15 15 getOnsaleSeriesApi,
16 16 getOnsaleSpecApi,
17 17 } from "@/pages/stock/Components/api";
18 18 import { PlusOutlined } from '@ant-design/icons';
  19 +import { ColumnsType } from 'antd/lib/table';
  20 +import SelectSpec from './SelectSpec';
19 21  
20 22 interface Props {
21 23 onChange?: (pa: any) => void;
22 24 value?: any[];
23 25 disabled?: boolean;
24 26 level?: number; //1品牌,2车系,3车型
25   - brandList?: CarOptionVo[]
  27 + brandList?: CommonApi.OptionVO[]
26 28 }
27 29  
28 30 interface Item {
... ... @@ -33,7 +35,18 @@ interface Item {
33 35 const { Column } = Table;
34 36 const { Option } = Select;
35 37  
36   -export default function index({ onChange, value, disabled, brandList }: Props) {
  38 +const columns: ColumnsType<CarOptionVo> = [
  39 + {
  40 + title: '车型',
  41 + dataIndex: 'name',
  42 + },
  43 + {
  44 + title: '配置代码',
  45 + dataIndex: 'specConfigCodeList',
  46 + render: (t) => t.map((i: string, key: number) => (<div key={i}>{key + 1}.{i}</div>))
  47 + },
  48 +];
  49 +export default function index({ onChange, value, disabled, brandList = [] }: Props) {
37 50 const [form] = Form.useForm();
38 51 // 控制Modal是否可见
39 52 const [visible, setVisible] = useState<boolean>(false);
... ... @@ -49,6 +62,7 @@ export default function index({ onChange, value, disabled, brandList }: Props) {
49 62 const [savaData, setSavadata] = useState<any>([]);
50 63 // 存储已经选中的车系
51 64 const [selectedSeries, setSelectedSeries] = useState<any[]>([]);
  65 + const [fetchLoading, setFetchLoading] = useState(false);
52 66  
53 67 useEffect(() => {
54 68 if (value && value.length) {
... ... @@ -94,9 +108,9 @@ export default function index({ onChange, value, disabled, brandList }: Props) {
94 108 }
95 109 if (level === 3) {
96 110 const { spec } = fileds;
97   - const _spec = spec.map((item: Item) => ({
98   - specId: item.value,
99   - specName: item.label,
  111 + const _spec = spec.map((item: any) => ({
  112 + specId: item.id,
  113 + specName: item.name,
100 114 }));
101 115 currentItem.children = _spec;
102 116 currentItem.authType = 2;
... ... @@ -153,16 +167,30 @@ export default function index({ onChange, value, disabled, brandList }: Props) {
153 167 setVisible(true);
154 168 if (record.brandId) {
155 169 setLevel(2);
156   - const { data } = await getOnsaleSeriesApi(record.brandId);
157   - const selectedSeries = savaData.filter((brand: any) => brand.brandId === record.brandId)[0].children;
158   - selectedSeries && form.setFieldValue("series", selectedSeries.map(i => ({ value: i.seriesId, label: i.seriesName })));
159   - setSeries(data);
  170 + setFetchLoading(true);
  171 + try {
  172 + const { data } = await getOnsaleSeriesApi(record.brandId);
  173 + const selectedSeries = savaData.filter((brand: any) => brand.brandId === record.brandId)[0].children;
  174 + selectedSeries && form.setFieldValue("series", selectedSeries.map(i => ({ value: i.seriesId, label: i.seriesName })));
  175 + setSeries(data);
  176 + setFetchLoading(false);
  177 + } catch (err: any) {
  178 + message.error(err.message);
  179 + setFetchLoading(false);
  180 + }
160 181 }
161 182 if (record.seriesId) {
162 183 setLevel(3);
163   - const { data } = await getOnsaleSpecApi(record.seriesId);
164   - record.children && form.setFieldValue("spec", record.children.map(i => ({ value: i.specId, label: i.specName })));
165   - setSpecList(data);
  184 + setFetchLoading(true);
  185 + try {
  186 + const { data } = await getOnsaleSpecApi(record.seriesId);
  187 + record.children && form.setFieldValue("spec", record.children.map(i => ({ id: i.specId, name: i.specName })));
  188 + setSpecList(data);
  189 + setFetchLoading(false);
  190 + } catch (err: any) {
  191 + message.error(err.message);
  192 + setFetchLoading(false);
  193 + }
166 194 }
167 195 };
168 196  
... ... @@ -231,8 +259,8 @@ export default function index({ onChange, value, disabled, brandList }: Props) {
231 259 return (
232 260 <Space>
233 261 <Button
234   - type="link"
235   - style={{ padding: 0 }}
  262 + type={record.brandId ? "primary" : "link"}
  263 + style={{ padding: 2 }}
236 264 onClick={() => onSelectSpec(record)}
237 265 disabled={disabled}
238 266 >
... ... @@ -271,59 +299,60 @@ export default function index({ onChange, value, disabled, brandList }: Props) {
271 299 setCurrentItem({});
272 300 }}
273 301 >
274   - <Form onFinish={_onOk} form={form}>
275   - {level === 1 ? (
276   - <Form.Item
277   - label="品牌"
278   - name="brand"
279   - // rules={[{ required: true, message: "请选择品牌:" }]}
280   - >
281   - <Select
282   - labelInValue
283   - mode="multiple"
284   - placeholder="选择品牌"
  302 + <Spin spinning={fetchLoading}>
  303 + <Form onFinish={_onOk} form={form}>
  304 + {level === 1 ? (
  305 + <Form.Item
  306 + label="品牌"
  307 + name="brand"
285 308 >
286   - {brandList.map((item) => (
287   - <Option value={item.id} key={item.id}>
288   - {item.name}
289   - </Option>
290   - ))}
291   - </Select>
292   - </Form.Item>
293   - ) : null}
  309 + <Select
  310 + labelInValue
  311 + mode="multiple"
  312 + placeholder="选择品牌"
  313 + >
  314 + {brandList.map((item) => (
  315 + <Option value={item.id} key={item.id}>
  316 + {item.name}
  317 + </Option>
  318 + ))}
  319 + </Select>
  320 + </Form.Item>
  321 + ) : null}
294 322  
295   - {/* 车系 */}
296   - {level === 2 && (
297   - <Form.Item
298   - label="车系"
299   - name="series"
300   - // rules={[{ required: true, message: "请选择车系" }]}
301   - >
302   - <Select labelInValue mode="multiple" placeholder="选择车系" allowClear>
303   - {series.map((item: any) => (
304   - <Option value={item.id} key={item.id}>
305   - {item.name}
306   - </Option>
307   - ))}
308   - </Select>
309   - </Form.Item>
310   - )}
311   - {level === 3 ? (
312   - <Form.Item
313   - label="车型"
314   - name="spec"
315   - // rules={[{ required: true, message: "请选择车型" }]}
316   - >
317   - <Select labelInValue mode="multiple" placeholder="选择车型" allowClear>
318   - {specList.map((item: any) => (
319   - <Option value={item.id} key={item.id}>
320   - {item.name}
321   - </Option>
322   - ))}
323   - </Select>
324   - </Form.Item>
325   - ) : null}
326   - </Form>
  323 + {/* 车系 */}
  324 + {level === 2 && (
  325 + <Form.Item
  326 + label="车系"
  327 + name="series"
  328 + // rules={[{ required: true, message: "请选择车系" }]}
  329 + >
  330 + <Select labelInValue mode="multiple" placeholder="选择车系" allowClear>
  331 + {series.map((item: any) => (
  332 + <Option value={item.id} key={item.id}>
  333 + {item.name}
  334 + </Option>
  335 + ))}
  336 + </Select>
  337 + </Form.Item>
  338 + )}
  339 + {level === 3 ? (
  340 + <Form.Item
  341 + label=""
  342 + name="spec"
  343 + >
  344 + {/* <Select labelInValue mode="multiple" placeholder="选择车型" allowClear>
  345 + {specList.map((item: any) => (
  346 + <Option value={item.id} key={item.id}>
  347 + {item.name}
  348 + </Option>
  349 + ))}
  350 + </Select> */}
  351 + <SelectSpec specList={specList} />
  352 + </Form.Item>
  353 + ) : null}
  354 + </Form>
  355 + </Spin>
327 356 </Modal>
328 357 </>
329 358 );
... ...
src/pages/stock/VehicleAdditional/components/EditModal.tsx
... ... @@ -5,8 +5,7 @@ import { saveApi } from &#39;../api&#39;;
5 5 import { UploadOutlined, PlusSquareOutlined } from '@ant-design/icons';
6 6 import _ from 'lodash';
7 7 import FeeweeUploadAttachment from '@/components/FeeweeUploadAttachment';
8   -import CarSelect from './CarSelect';
9   -import { CarOptionVo } from '@/pages/stock/Components/api';
  8 +import CarSelect from '../SelelctCarTreeAuth';
10 9  
11 10 const Item = Form.Item;
12 11 const Option = Select.Option;
... ... @@ -14,23 +13,22 @@ interface Props {
14 13 visible: boolean,
15 14 onCancel: Function,
16 15 item?: AdditionalCarSpace.Item,
17   - brands: CarOptionVo[],
  16 + brands: CommonApi.OptionVO[],
18 17 fetchList: () => any,
19   -
20 18 }
21 19  
22 20 function EditModal(props: Props) {
23 21 const { item, onCancel, fetchList, brands, visible } = props;
24 22 const [loading, setLoading] = useState(false);
25   - const [brandId, setBrandId] = useState<number>();
26   - const [storageList, setStorageList] = useState<any[]>([]);
27 23 const [form] = Form.useForm();
28 24  
29 25 useEffect(() => {
30 26 if (visible && item != null) {
31 27 const a = item.optionalAuth.map((brand: any) => {
32 28 if (brand.authSeries) {
33   - const newItem = brand.authSeries.map((child: any) => (child.authSpec ? { ...child, children: child.authSpec, authSpec: undefined } : child));
  29 + const newItem = brand.authSeries.map((child: any) => (child.authSpec ? {
  30 + ...child, brandId: undefined, children: child.authSpec.map((i: any) => ({ ...i, seriesId: undefined })), authSpec: undefined
  31 + } : child));
34 32 return { ...brand, children: newItem, authSeries: undefined };
35 33 }
36 34 return brand;
... ... @@ -42,7 +40,6 @@ function EditModal(props: Props) {
42 40 });
43 41 } else {
44 42 form.resetFields();
45   - setBrandId(undefined);
46 43 }
47 44 }, [visible]);
48 45  
... ... @@ -72,10 +69,6 @@ function EditModal(props: Props) {
72 69 });
73 70 }
74 71  
75   - /**获取授权库 */
76   - function onChange(values: any, option: any) {
77   - setStorageList(option.map((i: any) => ({ type: i.type, storageId: i.value, storageName: i.children })));
78   - }
79 72 return (
80 73 <Modal
81 74 title={item ? '编辑' : '新增'}
... ... @@ -138,7 +131,7 @@ function EditModal(props: Props) {
138 131 rules={[{ required: true, message: "选择车辆" }]}
139 132 tooltip={<span style={{ color: '#ccc', fontSize: 12 }}>*点击图标<PlusSquareOutlined />展开授权详情</span>}
140 133 >
141   - <CarSelect disabled={!!item && item.disabled} brandList={brands} />
  134 + <CarSelect disabled={!!item && item.disabled} brandList={brands.filter(i => !!i.optional)} />
142 135 </Item>
143 136 </Form>
144 137 </Modal>
... ...
src/pages/stock/VehicleAdditional/index.tsx
... ... @@ -75,7 +75,7 @@ export default function StorageList() {
75 75 <Table size="small" loading={loading} pagination={paginationConfig} rowKey={(item) => String(item.id)} dataSource={list} onChange={(_pagination) => setParams({ ..._pagination }, true)}>
76 76 <Column title="加装项目" dataIndex="name" />
77 77 <Column
78   - title="图片"
  78 + title="加装项目图片"
79 79 dataIndex="image"
80 80 render={(image, record: AdditionalCarSpace.Item) => (
81 81 <>
... ...