skyouc
2025-03-27 97aea7e059c7cb6c9c19402b423a8bca39eca017
rsf-admin/src/page/asnOrder/AsnOrderModal.jsx
@@ -54,6 +54,7 @@
import _ from 'lodash';
import { DataGrid } from '@mui/x-data-grid';
import DictionarySelect from "../components/DictionarySelect";
import DictSelect from "../components/DictSelect";
const AsnOrderModal = (props) => {
    const { open, setOpen, asnId } = props;
@@ -61,6 +62,7 @@
    const translate = useTranslate();
    const notify = useNotify();
    const refresh = useRefresh();
    const [createDialog, setCreateDialog] = useState(false);
    useEffect(() => {
@@ -74,13 +76,14 @@
        if (reason !== "backdropClick") {
            setOpen(false);
            refresh();
            setFormData({ type: '' })
            setFormData({ type: '', wkType: '' })
            setTableData([])
        }
    };
    const [formData, setFormData] = useState({
        type: '',
        wkType: '',
    });
    const [tabelData, setTableData] = useState([]);
@@ -99,6 +102,7 @@
                "orders": formData,
                "items": tabelData,
            }
            const res = await request.post(`/asnOrder/items/save`, parmas);
            if (res?.data?.code === 200) {
                setOpen(false);
@@ -107,8 +111,21 @@
                notify(res.data.msg);
            }
        } else {
            setOpen(false);
            const parmas = {
                "orders": formData,
                "items": tabelData,
            }
            console.log(parmas);
            // const res = await request.post(`/asnOrder/items/save`, parmas);
            // if (res?.data?.code === 200) {
            //     setOpen(false);
            //     refresh();
            // } else {
            //     notify(res.data.msg);
            // }
            // setOpen(false);
        }
    };
@@ -141,14 +158,6 @@
        }
    }
    const requestSetHead = async () => {
        if (asnId !== 0) {
            const res = await request.post(`/asnOrder/update`, { ...formData });
            refresh()
        }
    }
    return (
        <>
            <Dialog
@@ -176,25 +185,24 @@
                        <Form>
                            <Grid container spacing={2}>
                                <Grid item xs={4}>
                                    <DictionarySelect
                                    <DictSelect
                                        label={translate("table.field.asnOrder.type")}
                                        name="type"
                                        value={formData.type}
                                        onChange={(e) => handleChange(+e.target.value, 'type')}
                                        size="small"
                                        onChange={(e) => handleChange(e.target.value, 'type')}
                                        dictTypeCode="sys_order_type"
                                        required
                                    />
                                </Grid>
                                <Grid item xs={4}>
                                    <DictionarySelect
                                    <DictSelect
                                        label={translate("table.field.asnOrder.wkType")}
                                        name="wkType"
                                        value={formData.wkType}
                                        onChange={(e) => handleChange(+e.target.value, 'wkType')}
                                        size="small"
                                        onChange={(e) => handleChange(e.target.value, 'wkType')}
                                        dictTypeCode="sys_business_type"
                                        required
                                    />
                                </Grid>
                            </Grid>
@@ -237,14 +245,14 @@
const AsnOrderModalTable = ({ tabelData, setTableData, asnId }) => {
    const translate = useTranslate();
    const notify = useNotify();
    const columns = [
    const [columns, setColumns] = useState([
        {
            field: 'action',
            headerName: '操作',
            minWidth: 100,
            sticky: 'right',
            flex: 1,
            width: 70,
            lockPosition: 'left',
            renderCell: (params) => (
                <Tooltip title="Delete">
                    <IconButton onClick={() => handleDelete(params.row)}>
@@ -252,6 +260,7 @@
                    </IconButton>
                </Tooltip>
            ),
        },
        {
            field: 'matnrId',
@@ -291,7 +300,7 @@
            headerName: translate('table.field.asnOrderItem.stockUnit'),
            minWidth: 100,
            flex: 1,
            editable: true,
            editable: false,
        },
        {
            field: 'purQty',
@@ -305,7 +314,7 @@
            headerName: translate('table.field.asnOrderItem.purUnit'),
            minWidth: 100,
            flex: 1,
            editable: true,
            editable: false,
        },
        {
            field: 'splrCode',
@@ -322,20 +331,6 @@
            editable: true,
        },
        {
            field: 'qrcode',
            headerName: translate('table.field.asnOrderItem.qrcode'),
            minWidth: 100,
            flex: 1,
            editable: true,
        },
        {
            field: 'barcode',
            headerName: translate('table.field.asnOrderItem.barcode'),
            minWidth: 100,
            flex: 1,
            editable: true,
        },
        {
            field: 'packName',
            headerName: translate('table.field.asnOrderItem.packName'),
            minWidth: 100,
@@ -343,17 +338,42 @@
            editable: true,
        },
    ];
    ])
    const requestSetBody = async (row) => {
        if (asnId !== 0) {
            const res = await request.post(`/asnOrderItem/update`, row);
    let cdata = useRef([]);
    useEffect(() => {
        getDynamicFields();
    }, []);
    useEffect(() => {
        cdata.current = tabelData
    }, [tabelData]);
    const getDynamicFields = async () => {
        const {
            data: { code, data, msg },
        } = await request.get("/fields/enable/list");
        if (code === 200) {
            const cols = data.map(el => ({
                field: el.fields,
                headerName: el.fieldsAlise,
                minWidth: 100,
                flex: 1,
                editable: el.unique
            }))
            setColumns([...columns, ...cols])
        } else {
            notify(msg);
        }
    }
    const handleDelete = (row) => {
        const newData = _.filter(tabelData, (item) => item.matnrId !== row.matnrId);
        const newData = _.filter(cdata.current, (item) => item.matnrId !== row.matnrId);
        setTableData(newData);
    };
@@ -365,7 +385,6 @@
            )
        );
        requestSetBody(newRow)
        return newRow;
    };
@@ -382,6 +401,7 @@
                disableColumnSorting
                disableMultipleColumnsSorting
                processRowUpdate={processRowUpdate}
                autoPageSize
            />
        </div>
    );