From 69c716f2fe24615f7f17ad2dfe240344e84c7ec7 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Fri, 23 Feb 2024 16:08:29 +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 | 133 ++++++++++++------------ 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/src/pages/device/deviceVesion/index.jsx b/src/pages/device/deviceVesion/index.jsx index 2167f88..e4efe31 100644 --- a/src/pages/device/deviceVesion/index.jsx +++ b/src/pages/device/deviceVesion/index.jsx @@ -9,71 +9,10 @@ import { GetDeviceVesionPage, AddDeviceVesion, DelDeviceVesion, UpdateDeviceVesi import { history } from 'umi'; const key = 'message'; -//添加 -const handleAdd = async (fields) => { - try { - message.loading('正在添加', key); - await AddDeviceVesion(JSON.stringify(fields)).then((r) => { - message.destroy(key); - if (r.data) { - message.success('添加成功'); - return true; - } else { - message.error('添加失败'); - return false; - } - }); - } catch (error) { - message.error('添加失败请重试!'); - return false; - } -}; -//修改 -const handleUpdate = async (fields) => { - try { - message.loading('正在修改', key); - message.destroy(key); - await UpdateDeviceVesion(JSON.stringify(fields)).then((r) => { - message.destroy(key); - if (r.data) { - message.success('修改成功',); - return true; - } else { - message.success('修改失败'); - return false; - } - }); - } catch (error) { - message.error('修改失败请重试!'); - return false; - } -}; -//删除 -const handleRemove = async (selectedRows) => { - try { - message.loading('正在删除'); - let ids = []; - selectedRows.forEach((item) => { - ids.push(item.id); - }); - await DelDeviceVesion(ids).then((r) => { - if (r.data) { - message.success('删除成功'); - return true; - } else { - message.error(r.errors); - return false; - } - }); - } catch (error) { - message.error('删除失败请重试!'); - return false; - } -}; const GoodsTypeManage = () => { @@ -236,6 +175,74 @@ const GoodsTypeManage = () => { } }); }, []) + +//添加 +const handleAdd = async (fields) => { + try { + message.loading('正在添加', key); + await AddDeviceVesion(JSON.stringify(fields)).then((r) => { + message.destroy(key); + if (r.data) { + message.success('添加成功'); + actionRef.current.reloadAndRest(); + return true; + } else { + message.error('添加失败'); + return false; + } + }); + } catch (error) { + message.error('添加失败请重试!'); + return false; + } +}; + +//修改 +const handleUpdate = async (fields) => { + try { + message.loading('正在修改', key); + message.destroy(key); + await UpdateDeviceVesion(JSON.stringify(fields)).then((r) => { + message.destroy(key); + if (r.data) { + message.success('修改成功',); + actionRef.current.reloadAndRest(); + return true; + } else { + message.success('修改失败'); + return false; + } + }); + } catch (error) { + message.error('修改失败请重试!'); + return false; + } +}; + + +//删除 +const handleRemove = async (selectedRows) => { + try { + message.loading('正在删除'); + let ids = []; + selectedRows.forEach((item) => { + ids.push(item.id); + }); + await DelDeviceVesion(ids).then((r) => { + if (r.data) { + message.success('删除成功'); + actionRef.current.reloadAndRest(); + return true; + } else { + message.error(r.errors); + return false; + } + }); + } catch (error) { + message.error('删除失败请重试!'); + return false; + } +}; return ( { var success = false; if (value.id) { success = handleUpdate(value); - actionRef.current.reload(); } else { success = handleAdd(value); - actionRef.current.reload(); } if (success) { handleModalVisible(false); setCurrentRow(undefined); } - actionRef.current.reloadAndRest(); + }} onCancel={() => { handleModalVisible(false);