From 5b5fcdd41bc6e8bb51a8d28982bb41ea90beb363 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Fri, 23 Feb 2024 17:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/device/deviceVesion/index.jsx | 90 +++++++++++++------------ 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/src/pages/device/deviceVesion/index.jsx b/src/pages/device/deviceVesion/index.jsx index f1a9d77..30270ea 100644 --- a/src/pages/device/deviceVesion/index.jsx +++ b/src/pages/device/deviceVesion/index.jsx @@ -9,6 +9,50 @@ import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesi import { history } from 'umi'; const key = 'message'; + +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 [isAddGoodsTemplate,setIsAddGoodsTemplate]=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,"isAddGoodsTemplate":isAddGoodsTemplate}, + action: '/saasbase/api/goods/goodstemplateexport', + headers: { + Authorization: 'Bearer ' + localStorage.getItem('token') + }, + onChange(info) { + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + setIsAddGoodsTemplate(false); + 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 handleAdd = async (fields) => { try { @@ -17,6 +61,7 @@ const handleAdd = async (fields) => { message.destroy(key); if (r.data) { message.success('添加成功'); + actionRef.current?.reloadAndRest?.(); return true; } else { message.error('添加失败'); @@ -39,6 +84,7 @@ const handleUpdate = async (fields) => { message.destroy(key); if (r.data) { message.success('修改成功',); + actionRef.current?.reloadAndRest?.(); return true; } else { message.success('修改失败'); @@ -63,6 +109,7 @@ const handleRemove = async (selectedRows) => { await DelDeviceVesion(ids).then((r) => { if (r.data) { message.success('删除成功'); + actionRef.current?.reloadAndRest?.(); return true; } else { message.error(r.errors); @@ -75,49 +122,6 @@ 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 [isAddGoodsTemplate,setIsAddGoodsTemplate]=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,"isAddGoodsTemplate":isAddGoodsTemplate}, - action: '/saasbase/api/goods/goodstemplateexport', - headers: { - Authorization: 'Bearer ' + localStorage.getItem('token') - }, - onChange(info) { - if (info.file.status !== 'uploading') { - console.log(info.file, info.fileList); - } - setIsAddGoodsTemplate(false); - 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: '主键',