diff --git a/config/proxy.js b/config/proxy.js index ad12652..f0fecc9 100644 --- a/config/proxy.js +++ b/config/proxy.js @@ -9,7 +9,7 @@ export default { dev: { '/kitchen/': { - target: 'http://localhost:5001', + target: 'http://localhost:5000', changeOrigin: true, secure: false, //关闭证书验证 pathRewrite: { diff --git a/src/pages/device/deviceVesion/index.jsx b/src/pages/device/deviceVesion/index.jsx index 09aed02..b597541 100644 --- a/src/pages/device/deviceVesion/index.jsx +++ b/src/pages/device/deviceVesion/index.jsx @@ -1,11 +1,11 @@ -import { Modal,Button, message,Form } from 'antd'; -import React, { useState, useRef,useEffect } from 'react'; +import { Modal, Button, message, Form, Upload } from 'antd'; +import React, { useState, useRef, useEffect } from 'react'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PlusOutlined } from '@ant-design/icons'; import ProTable from '@ant-design/pro-table'; import CreateForm from './components/CreateForm'; -import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesion, GetDicList} from "./services" +import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesion, GetDicList } from "./services" const key = 'message'; @@ -75,13 +75,47 @@ const handleRemove = async (selectedRows) => { } }; + const GoodsTypeManage = () => { const [createModalVisible, handleModalVisible] = useState(false); const actionRef = useRef(); const [DictData, setDictData] = useState([]); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); + const [isModalOpen, setIsModalOpen] = useState(false); const [form] = Form.useForm(); + const props = { + beforeUpload: (file) => { + if ( + file.type !== 'application/vnd.ms-excel' && + file.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + ) { + message.error(`${file.name} 不是 exelce 文件`); + } + return file.type == 'application/vnd.ms-excel' || + file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + ? true + : Upload.LIST_IGNORE; + }, + name: 'file', + data:{"id":currentRow?.id,"deviceClientType":currentRow?.deviceTypeKey,"version":currentRow?.vesion}, + action: '/kitchen/api/goodes/DeviceVersionTemplateImport', + headers: { + Authorization: 'Bearer ' + localStorage.getItem('token') + }, + onChange(info) { + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (info.file.status === 'done') { + setIsModalOpen(false); + actionRef.current.reload(); + message.success(`${info.file.name} 文件上传成功.`); + } else if (info.file.status === 'error') { + message.error(`${info.file.name} 文件上载失败.`); + } + } + }; const columns = [ { title: '主键', @@ -117,33 +151,39 @@ const GoodsTypeManage = () => { setCurrentRow(record); // form.setFielsValue(record) }} > 更新, + { + setCurrentRow(record); + setIsModalOpen(true); + }} > 上传版本工艺模版, - 下载工艺模板 + + > 下载工艺模板 ], }, ]; useEffect(() => { GetDicList('DeviceClientType').then((r) => { - var arr = r.data; - let data = {}; - if (r.succeeded) { - var list = []; - arr.forEach((item) => { - data[item.code] = { text: item.code }; - list.push({ - code: item.code, - value: item.code, - }); + var arr = r.data; + let data = {}; + if (r.succeeded) { + var list = []; + arr.forEach((item) => { + data[item.code] = { text: item.code }; + list.push({ + code: item.code, + value: item.code, }); - //setDicDataAny(data); - setDictData(list); - } - }); + }); + //setDicDataAny(data); + setDictData(list); + } + }); }, []) return ( @@ -236,6 +276,12 @@ const GoodsTypeManage = () => { form={form} dicData={DictData} /> + { setIsModalOpen(false) }}> + + + + + ); }; diff --git a/src/pages/goods/newgoods/index.jsx b/src/pages/goods/newgoods/index.jsx index e4c4c70..2b4ddb2 100644 --- a/src/pages/goods/newgoods/index.jsx +++ b/src/pages/goods/newgoods/index.jsx @@ -361,7 +361,7 @@ const GoodsManage = () => { if (info.file.status === 'done') { message.success(`${info.file.name} file uploaded successfully`); } else if (info.file.status === 'error') { - message.error(`${info.file.name} file upload failed.`); + message.error(`${info.file.name}:${info.file.response} `); } } }; @@ -404,7 +404,7 @@ const GoodsManage = () => { // link.href = url; // link.click(); const link = document.createElement('a'); - link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/gzaxn@163.com/goods/133459074056631972.xlsx"; + link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/goods/133461572557666278.xlsx"; link.click(); }} >