From ad9930c5cf8624b8056bb9fda164fa65e66ef9cd Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 26 三月 2025 13:30:11 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop

---
 rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx |   90 +++++++++++++++++++++++++--------------------
 1 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx
index dffba6b..a203630 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrCreate.jsx
@@ -33,8 +33,8 @@
 import DialogCloseButton from "@/page/components/DialogCloseButton";
 import StatusSelectInput from "@/page/components/StatusSelectInput";
 import MemoInput from "@/page/components/MemoInput";
-import { tr } from "date-fns/locale";
-
+import TreeSelectInput from "@/page/components/TreeSelectInput";
+import request from '@/utils/request';
 function CustomTabPanel(props) {
     const { children, value, index, ...other } = props;
 
@@ -69,7 +69,21 @@
     const translate = useTranslate();
     const notify = useNotify();
     const [value, setValue] = React.useState(0);
+    const [dynamicFields, setDynamicFields] = useState([]);
 
+    useEffect(() => {
+        getDynamicFields();
+    }, []);
+    const getDynamicFields = async () => {
+        const {
+            data: { code, data, msg },
+        } = await request.get("/fields/enable/list");
+        if (code === 200) {
+            setDynamicFields(data || [])
+        } else {
+            notify(msg);
+        }
+    };
     const handleChange = (event, newValue) => {
         setValue(newValue);
     };
@@ -88,19 +102,15 @@
     const handleError = async (error) => {
         notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
     };
-    const validateForm = (values) => {
-        const errors = {};
-        if (!values.shipperId) {
-            errors.shipperId = translate('form.matnr.shipper');
-        }
-        if (!values.groupId) {
-            errors.groupId = translate('form.matnr.groupId');
-        }
-        if (!values.name) {
-            errors.name = translate('form.matnr.name');
-        }
-        return errors;
-    };
+    // const validateForm = (values) => {
+    //     const errors = {};
+    //     if (!values.name) errors.name = translate('form.matnr.name');
+    //     if (!values.shipperId) errors.shipperId = translate('form.matnr.shipper');
+    //     if (!values.groupId) errors.groupId = translate('form.matnr.groupId');
+    //     if (!values.code) errors.code = translate('form.matnr.code');
+
+    //     return errors;
+    // };
 
     return (
         <>
@@ -119,7 +129,7 @@
                     disableRestoreFocus
                     maxWidth="md"   // 'xs' | 'sm' | 'md' | 'lg' | 'xl'
                 >
-                    <Form validate={validateForm}>
+                    <Form >
                         <DialogTitle id="form-dialog-title" sx={{
                             position: 'sticky',
                             top: 0,
@@ -152,42 +162,31 @@
                                     <Grid item xs={6} display="flex" gap={1}>
                                         <TextInput
                                             label="table.field.matnr.code"
-                                            required
+                                            validate={[required()]}
                                             source="code"
                                             parse={v => v}
                                         />
                                     </Grid>
                                     <Grid item xs={6} display="flex" gap={1}>
-                                        <ReferenceInput
-                                            source="shipperId"
-                                            reference="shipper"
-                                        >
+                                        <ReferenceInput source="shipperId" reference="companys" filter={{ type: 'shipper' }}>
                                             <AutocompleteInput
                                                 label="table.field.matnr.shipperId"
                                                 optionText="name"
-                                                validate={[required()]}
                                                 filterToQuery={(val) => ({ name: val })}
                                             />
                                         </ReferenceInput>
                                     </Grid>
                                     <Grid item xs={6} display="flex" gap={1}>
-                                        <ReferenceInput
+                                        <TreeSelectInput
+                                            label="table.field.matnr.groupId"
+                                            resource={'matnrGroup'}
                                             source="groupId"
-                                            reference="matnrGroup"
-                                        >
-                                            <AutocompleteInput
-                                                label="table.field.matnr.groupId"
-                                                optionText="code"
-                                                validate={[required()]}
-                                                filterToQuery={(val) => ({ code: val })}
-                                            />
-                                        </ReferenceInput>
+                                        />
                                     </Grid>
                                     <Grid item xs={6} display="flex" gap={1}>
                                         <TextInput
-                                            label="table.field.matnr.erpCode"
-                                            source="erpCode"
-                                            required
+                                            label="table.field.matnr.platCode"
+                                            source="platCode"
                                             parse={v => v}
                                         />
                                     </Grid>
@@ -273,7 +272,7 @@
                                     <Grid item xs={6} display="flex" gap={1}>
                                         <SelectInput
                                             label="table.field.matnr.isLabelMange"
-                                            source="isLabelMange"
+                                            source="flagLabelMange"
                                             choices={[
                                                 { id: 0, name: ' 鍚�' },
                                                 { id: 1, name: ' 鏄�' },
@@ -281,6 +280,17 @@
                                         />
                                     </Grid>
 
+                                    {dynamicFields.map((item) => {
+                                        return (
+                                            <Grid key={item.id} item xs={6} display="flex" gap={1}>
+                                                <TextInput
+                                                    label={item.fieldsAlise}
+                                                    source={item.fields}
+                                                    validate={required()}
+                                                />
+                                            </Grid>
+                                        )
+                                    })}
 
                                     <Grid item xs={6} display="flex" gap={1}>
                                         <StatusSelectInput />
@@ -346,13 +356,13 @@
                                 <Grid container rowSpacing={2} columnSpacing={2}>
                                     <Grid item xs={6} display="flex" gap={1}>
                                         <ReferenceInput
-                                            source="rglarId"
-                                            reference="batchRegular"
+                                            source="rglar_id"
+                                            reference="serialRule"
                                         >
                                             <AutocompleteInput
                                                 label="table.field.matnr.rglarId"
-                                                optionText="code"
-                                                filterToQuery={(val) => ({ code: val })}
+                                                optionText="name"
+                                                filterToQuery={(val) => ({ name: val })}
                                             />
                                         </ReferenceInput>
                                     </Grid>

--
Gitblit v1.9.1