verou
2025-03-25 e0351f5e0d75ab4f1da19696b55a1d3cd70b0a68
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>