Commit a083360967181e8d498ac5be46e57dbe406e6caa

Authored by 莫红玲
1 parent 7e2d5375

add启票发动机号导入

src/pages/stock/TicketImport/api.ts
... ... @@ -58,11 +58,16 @@ export function getTemplateCheck(params: { brandId: number, fid: string }): http
58 58  
59 59 /**
60 60 * 押品数据导入解析
61   - * /erp/ticket/collateral/import
62 61 */
63 62 export function importCollateralApi(params?: TicketImport.InvoiceParams): http.PromiseResp<any> {
64 63 return request.post(`${FVM_HOST}/erp/ticket/collateral/import`, params);
65 64 }
  65 +/**
  66 + * 发动机号导入
  67 + */
  68 +export function importEnginenoApi(params?: TicketImport.InvoiceParams): http.PromiseResp<any> {
  69 + return request.get(`${FVM_HOST}/erp/ticket/engineNoImport`, { params });
  70 +}
66 71  
67 72 /**
68 73 * 押品数据确认提交
... ...
src/pages/stock/TicketImport/components/EnginenoUpload.tsx 0 → 100644
  1 +import React, { useState, useEffect } from "react";
  2 +import { RightOutlined, UploadOutlined } from "@ant-design/icons";
  3 +import { Button, Modal, Upload, message, Select, Form } from "antd";
  4 +import { bankList } from "../entity";
  5 +import { importEnginenoApi } from '../api';
  6 +import { useStore } from "../index";
  7 +
  8 +const Option = Select.Option;
  9 +interface Props {
  10 + visible: boolean;
  11 + onCancel: () => any;
  12 +}
  13 +const invoiceFilePath = {
  14 + 1: "invoice/bill-chang-an-template.xlsx",
  15 + 2: "invoice/bill-ceb-template.xls",
  16 + 3: "invoice/bill-spde-template.xls",
  17 +};
  18 +
  19 +export default function Collateral({ visible, onCancel }: Props) {
  20 + const { setBreadcrumbs, breadcrumbs, setCollateralItem, setUploadCollateralModal, uploadCollateralModal } = useStore();
  21 + const [form] = Form.useForm();
  22 + const [saveLoading, setSaveLoading] = useState(false);
  23 + const [bankType, setBankType] = useState<string>();
  24 +
  25 + useEffect(() => {
  26 + if (visible) {
  27 + if (uploadCollateralModal) {
  28 + form.setFieldsValue({
  29 + ...uploadCollateralModal,
  30 + });
  31 + }
  32 + }
  33 + }, [visible]);
  34 +
  35 + function beforeUpload(file: any) {
  36 + const isLt2M = file.size / 1024 / 1024 < 20;
  37 + if (!isLt2M) {
  38 + message.error("文件不能超过20MB!");
  39 + }
  40 + return isLt2M;
  41 + }
  42 + function handleChange(e: any) {
  43 + if (Array.isArray(e)) {
  44 + return e.slice(-1);
  45 + }
  46 + if (!e.file.status) return [];
  47 + if (e.file.status == "error") {
  48 + message.error("文件上传出错,请重新上传");
  49 + return "";
  50 + }
  51 + return e && e.fileList.slice(-1);
  52 + }
  53 + const uploadProps = {
  54 + accept: ".xlsx,.xls",
  55 + name: "file",
  56 + multiple: false,
  57 + action: `api/file/upload`,
  58 + beforeUpload: (info: any) => beforeUpload(info),
  59 + };
  60 + function saveBill(fieldsValue: any) {
  61 + setSaveLoading(true);
  62 + const pa = {
  63 + fid: fieldsValue.fid[0].response.data,
  64 + // invoiceType: fieldsValue.invoiceType,
  65 + };
  66 +
  67 + // 点击确定按钮,发送请求
  68 + importEnginenoApi(pa)
  69 + .then((res) => {
  70 + message.success("操作成功");
  71 + setSaveLoading(false);
  72 + onCancel(); //添加押品数据modal不可见
  73 + // setCollateralItem(res.data);
  74 + // setBreadcrumbs([...breadcrumbs, { name: "确认押品清单", key: "comfirmCollateral" }]);
  75 + // setUploadCollateralModal(fieldsValue);
  76 + })
  77 + .catch((e) => {
  78 + setSaveLoading(false);
  79 + message.error(e.message);
  80 + });
  81 + }
  82 + return (
  83 + <Modal
  84 + visible={visible}
  85 + maskClosable={false}
  86 + title="发动机号导入"
  87 + onCancel={() => onCancel()}
  88 + confirmLoading={saveLoading}
  89 + onOk={form.submit}
  90 + afterClose={() => {
  91 + form.resetFields();
  92 + // setBankType(undefined);
  93 + }}
  94 + >
  95 + <Form form={form} labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} onFinish={saveBill}>
  96 + <Form.Item
  97 + label="数据文档"
  98 + name="fid"
  99 + extra={
  100 + <a href="api/fvm/ticket/engineNoTemplateExport" rel="noopener noreferrer">
  101 + 下载模板
  102 + <RightOutlined />
  103 + </a>
  104 + }
  105 + rules={[{ required: true, message: "请上传发动机号数据文档" }]}
  106 + valuePropName="fileList"
  107 + getValueFromEvent={handleChange}
  108 + >
  109 + <Upload {...uploadProps}>
  110 + <Button icon={<UploadOutlined />} style={{ width: 300 }}>
  111 + 上传票据押品数据文档
  112 + </Button>
  113 + </Upload>
  114 + </Form.Item>
  115 + </Form>
  116 + </Modal>
  117 + );
  118 +}
... ...
src/pages/stock/TicketImport/components/List.tsx
... ... @@ -11,6 +11,7 @@ import useInitial from &#39;@/hooks/useInitail&#39;;
11 11 import _ from 'lodash';
12 12 import { useStore } from '../index';
13 13 import Collateral from './Collateral';
  14 +import EnginenoUpload from './EnginenoUpload';
14 15  
15 16 const Column = Table.Column;
16 17 const { MonthPicker } = DatePicker;
... ... @@ -20,6 +21,7 @@ export default function TicketImport() {
20 21 const [delay, setDelay] = useState(true);
21 22 const { loading, data, setParams, params } = useInitial<TicketImport.Item[], TicketImport.QueryParams>(api.getPageListApi, [], {}, delay);
22 23 const [templateVisble, setTemplateVisible] = useState(false);
  24 + const [engineVisible, setEngineVisible] = useState(false);
23 25  
24 26 useEffect(() => {
25 27 if (brandList.length > 0) {
... ... @@ -49,36 +51,37 @@ export default function TicketImport() {
49 51  
50 52 return (
51 53 <Card>
52   - <Row style={{ marginBottom: 10 }}>
53   - <Col span={14} style={{ display: "flex", flexWrap: "nowrap" }}>
54   - <MonthPicker
55   - allowClear={false}
56   - defaultValue={moment()}
57   - placeholder="请选择月份"
58   - style={{ width: 200, marginRight: 20 }}
59   - onChange={(date) => {
60   - setParams({ ticketTime: (date && date.valueOf()) || undefined }, true);
61   - }}
62   - />
63   - <Select style={{ width: 200, marginRight: 20 }} placeholder="请选择品牌" value={params.brandId} onChange={(v) => setParams({ ...params, brandId: v }, true)}>
64   - {brandList.map((item) => (
65   - <Select.Option value={item.brandId} key={item.brandId}>
66   - {item.brandName}
67   - </Select.Option>
68   - ))}
69   - </Select>
70   - <Select allowClear style={{ width: 200 }} showSearch optionFilterProp="children" value={params.dealerId} placeholder="搜索商家" onChange={(v) => setParams({ ...params, dealerId: v }, true)}>
71   - {dealerList.map((d) => (
72   - <Select.Option key={d.id} value={d.id!}>
73   - {d.name}
74   - </Select.Option>
75   - ))}
76   - </Select>
77   - </Col>
78   -
  54 + <Row justify="space-between" style={{ marginBottom: 10 }}>
  55 + {/* <Col span={14} style={{ display: "flex", flexWrap: "nowrap" }}> */}
  56 + <MonthPicker
  57 + allowClear={false}
  58 + defaultValue={moment()}
  59 + placeholder="请选择月份"
  60 + style={{ width: 200, marginRight: 20 }}
  61 + onChange={(date) => {
  62 + setParams({ ticketTime: (date && date.valueOf()) || undefined }, true);
  63 + }}
  64 + />
  65 + <Select style={{ width: 200, marginRight: 20 }} placeholder="请选择品牌" value={params.brandId} onChange={(v) => setParams({ ...params, brandId: v }, true)}>
  66 + {brandList.map((item) => (
  67 + <Select.Option value={item.brandId} key={item.brandId}>
  68 + {item.brandName}
  69 + </Select.Option>
  70 + ))}
  71 + </Select>
  72 + <Select allowClear style={{ width: 200 }} showSearch optionFilterProp="children" value={params.dealerId} placeholder="搜索商家" onChange={(v) => setParams({ ...params, dealerId: v }, true)}>
  73 + {dealerList.map((d) => (
  74 + <Select.Option key={d.id} value={d.id!}>
  75 + {d.name}
  76 + </Select.Option>
  77 + ))}
  78 + </Select>
  79 + {/* </Col> */}
  80 + </Row>
  81 + <Row justify="end" style={{ marginBottom: 15 }}>
79 82 <Col span={10} style={{ display: "flex", justifyContent: "flex-end" }}>
80   - <Button type="primary" onClick={() => setTemplateVisible(true)} style={{ width: 100, marginRight: 20 }}>
81   - 模板校验
  83 + <Button type="primary" onClick={() => setTemplateVisible(true)} style={{ marginRight: 20 }}>
  84 + 长安模板校验
82 85 </Button>
83 86 <Dropdown
84 87 overlay={
... ... @@ -98,6 +101,9 @@ export default function TicketImport() {
98 101 <Button icon={<UploadOutlined />} type="primary" onClick={() => setCollateralVisible(true)} style={{ width: 100, marginRight: 20 }}>
99 102 押品导入
100 103 </Button>
  104 + <Button icon={<UploadOutlined />} type="primary" onClick={() => setEngineVisible(true)} style={{ marginRight: 20 }}>
  105 + 发动机号导入
  106 + </Button>
101 107 </Col>
102 108 </Row>
103 109  
... ... @@ -144,6 +150,7 @@ export default function TicketImport() {
144 150 />
145 151 {/* <Collateral visible={collateralVisible} onCancel={() => setCollateralVisible(false)} onsave={saveBills} /> */}
146 152 <Collateral visible={collateralVisible} onCancel={() => setCollateralVisible(false)} />
  153 + <EnginenoUpload visible={engineVisible} onCancel={() => setEngineVisible(false)} />
147 154 </Card>
148 155 );
149 156 }
150 157 \ No newline at end of file
... ...
src/pages/stock/TicketImport/components/TemplateCheck.tsx
... ... @@ -113,6 +113,7 @@ export default function TemplateCheck(props: Props) {
113 113 wrapperCol={{ span: 15 }}
114 114 >
115 115 <Form.Item label="品牌" name="brandId" rules={[{ required: true, message: '请选择品牌' }]}>
  116 + {/* 暂时过滤哈佛、魏牌品牌 */}
116 117 <Select
117 118 labelInValue
118 119 placeholder="请选择品牌"
... ... @@ -123,7 +124,7 @@ export default function TemplateCheck(props: Props) {
123 124 onChange={(v: any) => { setBrandId(v); brandId && form.setFieldsValue({ fid1: undefined, fid2: undefined }); }}
124 125 >
125 126 {
126   - brandList && brandList.map((item) => {
  127 + brandList && brandList.filter(i => !["59", "148"].includes(String(i.brandId))).map((item) => {
127 128 return <Option value={item.brandId} key={item.brandId}>{item.brandName}</Option>;
128 129 })
129 130 }
... ...
src/pages/stock/TicketImport/components/UploadExcel.tsx
... ... @@ -157,7 +157,7 @@ export default function UploadExcel(props: Props) {
157 157 }}
158 158 >
159 159 {
160   - brandList && brandList.map((item) => {
  160 + brandList && brandList.filter(i => !["59", "148"].includes(String(i.brandId))).map((item) => {
161 161 return <Option value={item.brandId} key={item.brandId}>{item.brandName}</Option>;
162 162 })
163 163 }
... ...