skyouc
2025-04-30 2d5ffc17e5d76a468493b21c45df1ca547b10da3
rsf-admin/src/page/orders/asnOrder/AsnOrderModal.jsx
@@ -61,6 +61,7 @@
const AsnOrderModal = (props) => {
    const { open, setOpen, asnId, billReload } = props;
    const business = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_business_type') && dict.group == '2') || [];
    const translate = useTranslate();
    const notify = useNotify();
@@ -180,7 +181,7 @@
            setFormData(res.data.data)
        } else {
            notify(res.data.msg);
        }
        }
    }
    const requestGetBody = async () => {
@@ -202,7 +203,7 @@
    }
    return (
        <>
        <>
            <Dialog
                open={open}
                onClose={handleClose}
@@ -211,7 +212,7 @@
                fullWidth
                disableRestoreFocus
                maxWidth="lg"   // 'xs' | 'sm' | 'md' | 'lg' | 'xl'
            >
            >
                <DialogTitle id="form-dialog-title" sx={{
                    position: 'sticky',
                    top: 0,
@@ -232,7 +233,7 @@
                                        label={translate("table.field.asnOrder.type")}
                                        value={formData.type}
                                        onChange={(e) => handleChange(e.target.value, 'type')}
                                        dictTypeCode="sys_order_type"
                                        dictTypeCode="sys_in_stock_type"
                                        required
                                    />
                                </Grid>
@@ -240,6 +241,7 @@
                                    <DictSelect
                                        label={translate("table.field.asnOrder.wkType")}
                                        value={formData.wkType}
                                        group='2'
                                        onChange={(e) => handleChange(e.target.value, 'wkType')}
                                        dictTypeCode="sys_business_type"
                                        required
@@ -316,114 +318,114 @@
    useEffect(() => {
        getOptions();
    }, []);
    const getOptions = async () => {
        const parmas = {
            "type": "supplier"
    const getOptions = async () => {
        const parmas = {
            "type": "supplier"
        }
        const {
            data: { code, data, msg },
        } = await request.post("companys/page",parmas);
        } = await request.post("companys/page", parmas);
        if (code === 200) {
            setFormData(data.records)
            console.log(data.records)
            console.log(data.records)
        } else {
            notify(msg);
        }
    }
    }
    return (
        <Select
        value={params.value}
        onChange={(e) =>{
            params.api.setEditCellValue({
                id: params.id,
                field: params.field,
                value: e.target.value,
              })
              // 找到选中的供应商记录
          const selectedSupplier = formData.find(supplier => supplier.name === e.target.value);
          // 如果找到对应的供应商记录,同时更新splrCode字段
          if (selectedSupplier) {
            params.api.setEditCellValue({
              id: params.id,
              field: 'splrCode',
              value: selectedSupplier.id,
            });
          }
            value={params.value}
            onChange={(e) => {
                params.api.setEditCellValue({
                    id: params.id,
                    field: params.field,
                    value: e.target.value,
                })
                // 找到选中的供应商记录
                const selectedSupplier = formData.find(supplier => supplier.name === e.target.value);
        }
        }
        fullWidth
      >
          {formData.map(e => {
            return(
                <MenuItem value={e.name} children={e.name} key={e.id} />
            );
          })}
      </Select>
                // 如果找到对应的供应商记录,同时更新splrCode字段
                if (selectedSupplier) {
                    params.api.setEditCellValue({
                        id: params.id,
                        field: 'splrCode',
                        value: selectedSupplier.id,
                    });
                }
            }
            }
            fullWidth
        >
            {formData.map(e => {
                return (
                    <MenuItem value={e.name} children={e.name} key={e.id} />
                );
            })}
        </Select>
    );
  };
};
  const SelectInputSplrCodeEditCell = (params) => {
const SelectInputSplrCodeEditCell = (params) => {
    const [formData, setFormData] = useState([{}])
    useEffect(() => {
        getOptions();
    }, []);
    const getOptions = async () => {
        const parmas = {
            "type": "supplier"
    const getOptions = async () => {
        const parmas = {
            "type": "supplier"
        }
        const {
            data: { code, data, msg },
        } = await request.post("companys/page",parmas);
        } = await request.post("companys/page", parmas);
        if (code === 200) {
            setFormData(data.records)
            console.log(data.records)
            console.log(data.records)
        } else {
            notify(msg);
        }
    }
    }
    return (
        <Select
        value={params.value}
        onChange={(e) =>{
            params.api.setEditCellValue({
                id: params.id,
                field: params.field,
                value: e.target.value,
              })
              const selectedSupplier = formData.find(supplier => supplier.id === e.target.value);
              // 如果找到对应的供应商记录,同时更新splrCode字段
              if (selectedSupplier) {
            value={params.value}
            onChange={(e) => {
                params.api.setEditCellValue({
                  id: params.id,
                  field: 'splrName',
                  value: selectedSupplier.name,
                });
              }
        }
        }
        fullWidth
      >
          {formData.map(e => {
            return(
                <MenuItem value={e.id} children={e.name} key={e.id} />
            );
          })}
      </Select>
                    id: params.id,
                    field: params.field,
                    value: e.target.value,
                })
                const selectedSupplier = formData.find(supplier => supplier.id === e.target.value);
                // 如果找到对应的供应商记录,同时更新splrCode字段
                if (selectedSupplier) {
                    params.api.setEditCellValue({
                        id: params.id,
                        field: 'splrName',
                        value: selectedSupplier.name,
                    });
                }
            }
            }
            fullWidth
        >
            {formData.map(e => {
                return (
                    <MenuItem value={e.id} children={e.name} key={e.id} />
                );
            })}
        </Select>
    );
  };
};
@@ -448,7 +450,7 @@
        },
        {
            field: 'anfme',
            headerName: translate('table.field.asnOrderItem.anfme')+"*",
            headerName: translate('table.field.asnOrderItem.anfme') + "*",
            type: 'number',
            minWidth: 100,
            flex: 1,
@@ -458,18 +460,18 @@
        },
        {
            field: 'splrCode',
            headerName: translate('table.field.asnOrderItem.splrCode')+"*",
            headerName: translate('table.field.asnOrderItem.splrCode') + "*",
            minWidth: 100,
            flex: 1,
            editable: true,
            renderEditCell: (params) => (
                <SelectInputSplrCodeEditCell {...params} />
            ),
            headerClassName: "custom",
            headerClassName: "custom",
        },
        {
            field: 'splrName',
            headerName: translate('table.field.asnOrderItem.splrName')+"*",
            headerName: translate('table.field.asnOrderItem.splrName') + "*",
            minWidth: 100,
            flex: 1,
            editable: true,
@@ -493,7 +495,7 @@
        // },
        {
            field: 'poCode',
            headerName: translate('table.field.asnOrderItem.poDetlCode')+"*",
            headerName: translate('table.field.asnOrderItem.poDetlCode') + "*",
            minWidth: 100,
            flex: 1,
            editable: true,