From 9e27b1b292872bd83b761091554fbd8db72b595e Mon Sep 17 00:00:00 2001
From: yangyang
Date: 星期四, 20 三月 2025 10:47:13 +0800
Subject: [PATCH] #优化 物料扩展字段修改优化
---
rsf-admin/src/page/basicInfo/loc/BatchModal.jsx | 66 +++++++++++++++++++++-----------
1 files changed, 43 insertions(+), 23 deletions(-)
diff --git a/rsf-admin/src/page/basicInfo/loc/BatchModal.jsx b/rsf-admin/src/page/basicInfo/loc/BatchModal.jsx
index 5e9cfb7..cee27c7 100644
--- a/rsf-admin/src/page/basicInfo/loc/BatchModal.jsx
+++ b/rsf-admin/src/page/basicInfo/loc/BatchModal.jsx
@@ -50,7 +50,7 @@
import { Add, Edit, Delete } from '@mui/icons-material';
import _ from 'lodash';
import { DataGrid } from '@mui/x-data-grid';
-
+import StatusSelectInput from "../../components/StatusSelectInput";
@@ -62,16 +62,29 @@
const notify = useNotify();
const [formData, setFormData] = useState({
- "areaId": undefined,
- "locType": "",
- "type": ""
+ "areaId": null,
+ "type": null,
+ 'status': null
});
+
+ const { selectedIds, onUnselectItems } = useListContext();
const handleClose = (event, reason) => {
if (reason !== "backdropClick") {
setOpen(false);
+ reset()
+ refresh();
+ onUnselectItems()
}
};
+
+ const reset = () => {
+ setFormData({
+ "areaId": null,
+ "type": null,
+ 'status': null
+ })
+ }
const handleReset = (e) => {
e.preventDefault();
@@ -80,20 +93,34 @@
const handleChange = (value, name) => {
setFormData((prevData) => ({
...prevData,
- [name]: ['locType', 'type'].includes(name) ? value : +value
+ [name]: value
}));
};
+ const removeEmptyKeys = (obj) => {
+ return _.pickBy(obj, (value) => {
+ if (_.isObject(value)) {
+ const newObj = removeEmptyKeys(value);
+ return !_.isEmpty(newObj);
+ }
+ return !_.isNil(value) && (_.isNumber(value) ? value !== 0 : !_.isEmpty(value));
+ });
+ }
+
const handleSubmit = async () => {
- const res = await request.post(`/loc/init`, formData);
+ const parmas = {
+ id: selectedIds,
+ loc: removeEmptyKeys(formData)
+ }
+
+ const res = await request.post(`/loc/modify`, parmas);
if (res?.data?.code === 200) {
- setOpen(false);
- refresh();
+ handleClose()
+
} else {
notify(res.data.msg);
}
}
-
return (
<Dialog open={open} maxWidth="md" fullWidth>
@@ -113,23 +140,10 @@
optionText="name"
onChange={(value) => handleChange(value, 'areaId')}
value={formData.areaId}
- validate={[required()]}
filterToQuery={(val) => ({ name: val })}
/>
</ReferenceInput>
- </Grid>
-
- <Grid item xs={4}>
- <DictionarySelect
- label={translate("table.field.loc.locType")}
- name="locType"
- value={formData.locType}
- onChange={(e) => handleChange(e.target.value, 'locType')}
- size="small"
- validate={[required()]}
- dictTypeCode="sys_width_type"
- />
</Grid>
<Grid item xs={4}>
@@ -139,11 +153,17 @@
value={formData.type}
onChange={(e) => handleChange(e.target.value, 'type')}
size="small"
- validate={[required()]}
dictTypeCode="sys_loc_type"
/>
</Grid>
+ <Grid item xs={4}>
+ <StatusSelectInput
+ onChange={(e) => handleChange(e.target.value, 'status')}
+ defaultValue={''}
+ require={false}
+ />
+ </Grid>
</Grid>
--
Gitblit v1.9.1