|  |  |  | 
|---|
|  |  |  | TableCell, | 
|---|
|  |  |  | Tooltip, | 
|---|
|  |  |  | IconButton, | 
|---|
|  |  |  | styled | 
|---|
|  |  |  | styled, | 
|---|
|  |  |  | Select, | 
|---|
|  |  |  | MenuItem | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } from '@mui/material'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import { DataGrid, useGridApiRef } from '@mui/x-data-grid'; | 
|---|
|  |  |  | import DictionarySelect from "../../components/DictionarySelect"; | 
|---|
|  |  |  | import DictSelect from "../../components/DictSelect"; | 
|---|
|  |  |  | import "./asnOrder.css"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const [disabled, setDisabled] = useState(false) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const tableRef = useRef(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | 
|---|
|  |  |  | ...prevData, | 
|---|
|  |  |  | [name]: value | 
|---|
|  |  |  | })); | 
|---|
|  |  |  | console.log(formData); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const resetData = () => { | 
|---|
|  |  |  | 
|---|
|  |  |  | </DialogTitle> | 
|---|
|  |  |  | <DialogContent sx={{ mt: 2 }}> | 
|---|
|  |  |  | <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> | 
|---|
|  |  |  | <Form> | 
|---|
|  |  |  | <Form defaultValues={formData}> | 
|---|
|  |  |  | <Grid container spacing={2}> | 
|---|
|  |  |  | <Grid item md={3}> | 
|---|
|  |  |  | <DictSelect | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | 
|---|
|  |  |  | <DictSelect | 
|---|
|  |  |  | label={translate("table.field.asnOrder.wkType")} | 
|---|
|  |  |  | value={formData.wkType} | 
|---|
|  |  |  | group='2' | 
|---|
|  |  |  | onChange={(e) => handleChange(e.target.value, 'wkType')} | 
|---|
|  |  |  | dictTypeCode="sys_business_type" | 
|---|
|  |  |  | required | 
|---|
|  |  |  | 
|---|
|  |  |  | <Stack direction="row" spacing={2}> | 
|---|
|  |  |  | <Button variant="contained" onClick={() => setCreateDialog(true)}>新增物料</Button> | 
|---|
|  |  |  | {/* {asnId !== '' && <ConfirmButton label={'删除'} variant="outlined" color="error" onConfirm={handleDelete} />} */} | 
|---|
|  |  |  | <ConfirmButton label={'删除'} variant="outlined" color="error" onConfirm={handleDeleteItem} /> | 
|---|
|  |  |  | <ConfirmButton label={'ra.action.delete'} variant="outlined" color="error" onConfirm={handleDeleteItem} /> | 
|---|
|  |  |  | </Stack> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | <Box sx={{ mt: 2 }}> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default AsnOrderModal; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const SelectInputSplrNameEditCell = (params) => { | 
|---|
|  |  |  | const [formData, setFormData] = useState([{}]) | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | getOptions(); | 
|---|
|  |  |  | }, []); | 
|---|
|  |  |  | const getOptions = async () => { | 
|---|
|  |  |  | const parmas = { | 
|---|
|  |  |  | "type": "supplier" | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | data: { code, data, msg }, | 
|---|
|  |  |  | } = await request.post("companys/page", parmas); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | setFormData(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, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | fullWidth | 
|---|
|  |  |  |  | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {formData.map(e => { | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <MenuItem value={e.name} children={e.name} key={e.id} /> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | })} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </Select> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const SelectInputSplrCodeEditCell = (params) => { | 
|---|
|  |  |  | const [formData, setFormData] = useState([{}]) | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | getOptions(); | 
|---|
|  |  |  | }, []); | 
|---|
|  |  |  | const getOptions = async () => { | 
|---|
|  |  |  | const parmas = { | 
|---|
|  |  |  | "type": "supplier" | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | data: { code, data, msg }, | 
|---|
|  |  |  | } = await request.post("companys/page", parmas); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | setFormData(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) { | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const AsnOrderModalTable = ({ tabelData, setTableData, asnId, selectedRows, setSelectedRows, tableRef }) => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | field: 'anfme', | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.anfme'), | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.anfme') + "*", | 
|---|
|  |  |  | type: 'number', | 
|---|
|  |  |  | minWidth: 100, | 
|---|
|  |  |  | flex: 1, | 
|---|
|  |  |  | editable: true, | 
|---|
|  |  |  | valueFormatter: (val) => val < 0 ? 0 : val | 
|---|
|  |  |  | valueFormatter: (val) => val < 0 ? 0 : val, | 
|---|
|  |  |  | headerClassName: "custom", | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 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", | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | field: 'splrName', | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.splrName'), | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.splrName') + "*", | 
|---|
|  |  |  | minWidth: 100, | 
|---|
|  |  |  | flex: 1, | 
|---|
|  |  |  | editable: true, | 
|---|
|  |  |  | renderEditCell: (params) => ( | 
|---|
|  |  |  | <SelectInputSplrNameEditCell {...params} /> | 
|---|
|  |  |  | ), | 
|---|
|  |  |  | headerClassName: "custom", | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // { | 
|---|
|  |  |  | //     field: 'packName', | 
|---|
|  |  |  | 
|---|
|  |  |  | // }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | field: 'poCode', | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.poDetlCode'), | 
|---|
|  |  |  | headerName: translate('table.field.asnOrderItem.poDetlCode') + "*", | 
|---|
|  |  |  | minWidth: 100, | 
|---|
|  |  |  | flex: 1, | 
|---|
|  |  |  | editable: true, | 
|---|
|  |  |  | headerClassName: "custom", | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | { | 
|---|