Browse Source

提交

storemanagementweb
gwbvipvip 10 months ago
parent
commit
69c716f2fe
1 changed files with 69 additions and 64 deletions
  1. +69
    -64
      src/pages/device/deviceVesion/index.jsx

+ 69
- 64
src/pages/device/deviceVesion/index.jsx View File

@@ -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 (
<PageContainer host header={{
title: '',
@@ -313,16 +320,14 @@ const GoodsTypeManage = () => {
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);


Loading…
Cancel
Save