From e0351f5e0d75ab4f1da19696b55a1d3cd70b0a68 Mon Sep 17 00:00:00 2001
From: verou <857149855@qq.com>
Date: 星期二, 25 三月 2025 16:43:06 +0800
Subject: [PATCH] feat:库区批量

---
 rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx          |   92 +++++++++++++++++++++++++-----
 rsf-admin/src/page/warehouseAreas/BatchModal.jsx           |   13 ++-
 rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx |    1 
 rsf-admin/src/page/components/TreeSelectInput.jsx          |    4 
 rsf-admin/src/i18n/zh.js                                   |    5 +
 rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx           |   31 +++++++++-
 rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupList.jsx |    2 
 rsf-admin/src/i18n/en.js                                   |    1 
 rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx           |   10 +++
 9 files changed, 129 insertions(+), 30 deletions(-)

diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js
index b970d00..e6b9ca2 100644
--- a/rsf-admin/src/i18n/en.js
+++ b/rsf-admin/src/i18n/en.js
@@ -649,6 +649,7 @@
         batchStatus: 'batchStatus',
         batchMix: 'batchFiexed',
         batchWarehouse: 'batchWarehouse',
+        batchStockLevel: "batchStockLevel",
     },
 };
 
diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js
index 6e7ede8..dc195f9 100644
--- a/rsf-admin/src/i18n/zh.js
+++ b/rsf-admin/src/i18n/zh.js
@@ -278,8 +278,8 @@
                 minQty: "鏈�灏忓��",
                 maxQty: "鏈�澶у��",
                 stagn: "鍋滄粸棰勮鍊�",
-                valid: "淇濊川鏈�",
-                validWarn: "鏁堟湡棰勮",
+                valid: "淇濊川鏈�(澶�)",
+                validWarn: "鏁堟湡棰勮(澶�)",
                 flagCheck: "鍏嶆",
             },
             matnrGroup: {
@@ -651,6 +651,7 @@
         batchStatus: '鎵归噺鐘舵��',
         batchMix: '鎵归噺娣锋斁',
         batchWarehouse: '鎵归噺浠撳簱',
+        batchStockLevel: "鎵归噺ABC鍒嗙被",
     },
 };
 
diff --git a/rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx b/rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx
index 25a484e..8c10825 100644
--- a/rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/BatchModal.jsx
@@ -43,7 +43,6 @@
 
 } from '@mui/material';
 import DialogCloseButton from "../../components/DialogCloseButton";
-import DictionarySelect from "../../components/DictionarySelect";
 import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form";
 import SaveIcon from '@mui/icons-material/Save';
 import request from '@/utils/request';
@@ -52,7 +51,7 @@
 import { DataGrid } from '@mui/x-data-grid';
 import StatusSelectInput from "../../components/StatusSelectInput";
 
-const InitModal = ({ open, setOpen }) => {
+const InitModal = ({ open, setOpen, fieldType }) => {
     const refresh = useRefresh();
     const translate = useTranslate();
 
@@ -60,7 +59,11 @@
     const notify = useNotify();
 
     const [formData, setFormData] = useState({
-        'status': null
+        'status': null,
+        'stockLevel': null,
+        'validWarn': null,
+        'valid': null,
+        'flagCheck': null,
     });
 
     const { selectedIds, onUnselectItems } = useListContext();
@@ -76,7 +79,11 @@
 
     const reset = () => {
         setFormData({
-            'status': null
+            'status': null,
+            'stockLevel': null,
+            'validWarn': null,
+            'valid': null,
+            'flagCheck': null,
         })
     }
 
@@ -87,7 +94,7 @@
     const handleChange = (value, name) => {
         setFormData((prevData) => ({
             ...prevData,
-            [name]: ['locType', 'type'].includes(name) ? value : +value
+            [name]: value
         }));
     };
 
@@ -97,17 +104,20 @@
                 const newObj = removeEmptyKeys(value);
                 return !_.isEmpty(newObj);
             }
-            return !_.isNil(value) && (_.isNumber(value) ? value !== 0 : !_.isEmpty(value));
+            return !_.isNil(value);
         });
     }
 
+
     const handleSubmit = async () => {
         const parmas = {
-            id: selectedIds,
-            matnr: removeEmptyKeys(formData)
+            ids: selectedIds,
+            matnr: {
+                ...removeEmptyKeys(formData)
+            }
         }
 
-        const res = await request.post(`/matnr/modify`, parmas);
+        const res = await request.post(`/matnr/batch/update`, parmas);
         if (res?.data?.code === 200) {
             handleClose()
 
@@ -117,20 +127,68 @@
     }
 
     return (
-        <Dialog open={open} maxWidth="md" fullWidth>
+        <Dialog open={open} maxWidth="xs" fullWidth>
             <Form onSubmit={handleSubmit}>
                 <DialogCloseButton onClose={handleClose} />
                 <DialogTitle>{translate('toolbar.batch')}</DialogTitle>
                 <DialogContent sx={{ mt: 2 }}>
                     <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
                         <Grid container spacing={2}>
-                            <Grid item xs={4}>
-                                <StatusSelectInput
-                                    onChange={(e) => handleChange(e.target.value, 'status')}
-                                    defaultValue={''}
-                                    require={false}
-                                />
-                            </Grid>
+                            {fieldType === 'status' &&
+                                <Grid item xs={6}>
+                                    <StatusSelectInput
+                                        onChange={(e) => handleChange(+e.target.value, 'status')}
+                                        defaultValue={''}
+                                        require={false}
+                                    />
+                                </Grid>
+                            }
+                            {fieldType === 'stockLevel' &&
+                                <Grid item xs={6}>
+                                    <SelectInput
+                                        label="table.field.matnr.stockLevel"
+                                        source="stockLevel"
+                                        onChange={(e) => handleChange(e.target.value, 'stockLevel')}
+                                        choices={[
+                                            { id: 0, name: ' A' },
+                                            { id: 1, name: ' B' },
+                                            { id: 2, name: 'C' },
+                                        ]}
+                                        validate={required()}
+                                    />
+                                </Grid>
+                            }
+                            {fieldType === 'validWarn' &&
+                                <Grid item xs={6}>
+                                    <NumberInput
+                                        onChange={(e) => handleChange(e.target.value, 'validWarn')}
+                                        label="table.field.matnr.validWarn"
+                                        source="validWarn"
+                                    />
+                                </Grid>
+                            }
+                            {fieldType === 'validWarn' &&
+                                <Grid item xs={6}>
+                                    <NumberInput
+                                        onChange={(e) => handleChange(e.target.value, 'valid')}
+                                        label="table.field.matnr.valid"
+                                        source="valid"
+                                    />
+                                </Grid>
+                            }
+                            {fieldType === 'flagCheck' &&
+                                <Grid item xs={6}>
+                                    <SelectInput
+                                        onChange={(e) => handleChange(e.target.value, 'flagCheck')}
+                                        label="table.field.matnr.flagCheck"
+                                        source="flagCheck"
+                                        choices={[
+                                            { id: 0, name: ' 鍚�' },
+                                            { id: 1, name: ' 鏄�' },
+                                        ]}
+                                    />
+                                </Grid>
+                            }
                         </Grid>
 
                     </Box>
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
index c86aeef..003de96 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrEdit.jsx
@@ -318,6 +318,16 @@
                                         source="valid"
                                     />
                                 </Grid>
+                                <Grid item xs={6} display="flex" gap={1}>
+                                    <SelectInput
+                                        label="table.field.matnr.flagCheck"
+                                        source="flagCheck"
+                                        choices={[
+                                            { id: 0, name: ' 鍚�' },
+                                            { id: 1, name: ' 鏄�' },
+                                        ]}
+                                    />
+                                </Grid>
                             </Grid>
                         </CustomTabPanel>
                         <CustomTabPanel value={value} index={2}>
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
index 9bf7cfc..4114430 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
@@ -242,7 +242,8 @@
                     preferenceKey='matnr'
                     bulkActionButtons={<>
                         <BatchGroupButton />
-                        <BatchButton />
+                        <BatchStatusButton />
+                        <BatchLevelButton />
                         <BindButton />
                         <PrintButton />
                         <BulkDeleteButton mutationMode={OPERATE_MODE} />
@@ -340,7 +341,7 @@
     )
 }
 
-const BatchButton = () => {
+const BatchStatusButton = () => {
     const record = useRecordContext();
     const notify = useNotify();
     const refresh = useRefresh();
@@ -350,13 +351,37 @@
 
     return (
         <>
-            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batch"}>
+            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchStatus"}>
                 <EditIcon />
             </Button>
 
             <BatchModal
                 open={createDialog}
                 setOpen={setCreateDialog}
+                fieldType={'status'}
+            />
+        </>
+
+    )
+}
+const BatchLevelButton = () => {
+    const record = useRecordContext();
+    const notify = useNotify();
+    const refresh = useRefresh();
+
+
+    const [createDialog, setCreateDialog] = useState(false);
+
+    return (
+        <>
+            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchStockLevel"}>
+                <EditIcon />
+            </Button>
+
+            <BatchModal
+                open={createDialog}
+                setOpen={setCreateDialog}
+                fieldType={'stockLevel'}
             />
         </>
 
diff --git a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx
index e381f93..c2e5226 100644
--- a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx
+++ b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupEdit.jsx
@@ -73,6 +73,7 @@
                     isTranslate
                     resource={resource}
                     onChange={(e) => pChange(e.target.value)}
+                    required
                 />
             </Grid>
             <Grid item xs={6} display="flex" gap={1}>
diff --git a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupList.jsx b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupList.jsx
index b7436b2..74b125e 100644
--- a/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupList.jsx
+++ b/rsf-admin/src/page/basicInfo/matnrGroup/MatnrGroupList.jsx
@@ -269,7 +269,7 @@
                         {expandAll ? translate('common.action.collapseAll') : translate('common.action.expandAll')}
                     </Button>
                     <TextField
-                        label="鎼滅储"
+                        label="鎼滅储鍚嶇О"
                         value={filter}
                         onChange={({ target }) => {
                             setFilter(target.value)
diff --git a/rsf-admin/src/page/components/TreeSelectInput.jsx b/rsf-admin/src/page/components/TreeSelectInput.jsx
index 569451a..2c51cc5 100644
--- a/rsf-admin/src/page/components/TreeSelectInput.jsx
+++ b/rsf-admin/src/page/components/TreeSelectInput.jsx
@@ -5,7 +5,7 @@
 import * as Common from '@/utils/common';
 import { useFormContext } from 'react-hook-form';
 
-const TreeSelectInput = ({ resource, onChange, label, source = 'parentId', value, isTranslate = false, ...rest }) => {
+const TreeSelectInput = ({ resource, required, onChange, label, source = 'parentId', value, isTranslate = false, ...rest }) => {
     const translate = useTranslate();
     const { setValue } = useFormContext();
     const [filter, setFilter] = React.useState("");
@@ -42,7 +42,7 @@
     };
 
     return (
-        <FormControl fullWidth>
+        <FormControl fullWidth required={required}>
             <InputLabel>{translate(label)}</InputLabel>
             <Select
                 value={proxyVal || ''}
diff --git a/rsf-admin/src/page/warehouseAreas/BatchModal.jsx b/rsf-admin/src/page/warehouseAreas/BatchModal.jsx
index 1f64a7b..7b8558c 100644
--- a/rsf-admin/src/page/warehouseAreas/BatchModal.jsx
+++ b/rsf-admin/src/page/warehouseAreas/BatchModal.jsx
@@ -100,17 +100,20 @@
                 const newObj = removeEmptyKeys(value);
                 return !_.isEmpty(newObj);
             }
-            return !_.isNil(value) && (_.isNumber(value) ? value !== 0 : !_.isEmpty(value));
+            return !_.isNil(value);
         });
     }
 
+
     const handleSubmit = async () => {
         const parmas = {
-            id: selectedIds,
-            ...removeEmptyKeys(formData)
+            ids: selectedIds,
+            warehouseAreas: {
+                ...removeEmptyKeys(formData)
+            }
         }
 
-        const res = await request.post(`/warehouseAreas/modify`, parmas);
+        const res = await request.post(`/warehouseAreas/batch/update`, parmas);
         if (res?.data?.code === 200) {
             handleClose()
 
@@ -130,7 +133,7 @@
                             {fieldType === 'status' &&
                                 <Grid item xs={6}>
                                     <StatusSelectInput
-                                        onChange={(e) => handleChange(e.target.value, 'status')}
+                                        onChange={(e) => handleChange(+e.target.value, 'status')}
                                         defaultValue={''}
                                         require={false}
                                     />

--
Gitblit v1.9.1