| | |
| | | useNotify, |
| | | Form, |
| | | useCreateController, |
| | | SimpleForm, |
| | | useRefresh, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | |
| | | Grid, |
| | | Box, |
| | | } from '@mui/material'; |
| | | import DialogCloseButton from "../../components/DialogCloseButton.jsx"; |
| | | import ConfirmationNumberIcon from '@mui/icons-material/ConfirmationNumber'; |
| | | import CreateBySelectMats from "./CreateBySelectMats.jsx"; |
| | | import DialogCloseButton from "../../components/DialogCloseButton.jsx"; |
| | | import WarehouseSelect from "../../components/WarehouseSelect.jsx"; |
| | | import { DataGrid, useGridApiRef } from '@mui/x-data-grid'; |
| | | import { Add, Edit, Delete } from '@mui/icons-material'; |
| | | import ConfirmButton from "../../components/ConfirmButton"; |
| | | import CreateBySelectMats from "./CreateBySelectMats.jsx"; |
| | | import { Add, Edit, Delete } from '@mui/icons-material'; |
| | | import DictSelect from "../../components/DictSelect"; |
| | | import { useFormContext, useWatch } from "react-hook-form"; |
| | | import { minHeight, padding } from "@mui/system"; |
| | | import SaveIcon from '@mui/icons-material/Save'; |
| | | import request from '@/utils/request'; |
| | | import _, { set } from 'lodash'; |
| | | |
| | | const ManualCreate = (props) => { |
| | | const { open, setOpen, orderId } = props; |
| | | const tableRef = useRef(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const translate = useTranslate(); |
| | | const [tabelData, setTableData] = useState([]); |
| | | const [disabled, setDisabled] = useState(false); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [formData, setFormData] = useState({}); |
| | | const [list, setList] = useState([]); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | } |
| | | }; |
| | | |
| | | const setFinally = () => { |
| | | const rows = tableRef.current.state.editRows; |
| | | for (const key in rows) { |
| | | const find = tabelData.find(item => item.matnrId === +key); |
| | | find.anfme = rows[key].anfme.value; |
| | | } |
| | | setTableData([...tabelData]); |
| | | } |
| | | |
| | | |
| | | const handleSubmit = async () => { |
| | | setFinally() |
| | | setDisabled(true) |
| | | |
| | | if (asnId === 0) { |
| | | if (orderId == null || orderId == undefined) { |
| | | const parmas = { |
| | | "orders": formData, |
| | | "transfer": formData, |
| | | "items": tabelData, |
| | | } |
| | | const res = await request.post(`/outStock/items/save`, parmas); |
| | | |
| | | const res = await request.post(`/transfer/items/save`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | refresh(); |
| | | resetData() |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } else { |
| | | const parmas = { |
| | | "orders": formData, |
| | | "transfer": formData, |
| | | "items": tabelData, |
| | | } |
| | | const res = await request.post(`/outStock/items/update`, parmas); |
| | | const res = await request.post(`/transfer/items/update`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | refresh(); |
| | | resetData() |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } |
| | | setDisabled(false) |
| | | refresh(); |
| | | |
| | | }; |
| | | |
| | |
| | | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); |
| | | }; |
| | | |
| | | const getWarehouse = async () => { |
| | | const res = await request.post('/warehouseAreas/page'); |
| | | if (res?.data?.code === 200) { |
| | | setList(res.data.data.records.map((item) => { |
| | | return { |
| | | id: item.id, |
| | | name: item.name |
| | | }; |
| | | })); |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } |
| | | |
| | | |
| | | const handleChange = (value, name) => { |
| | | setFormData((prevData) => ({ |
| | | ...prevData, |
| | | [name]: value |
| | | })); |
| | | }; |
| | | |
| | | return ( |
| | | <> |
| | | <Box sx={{ padding: 1 }}> |
| | | <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}> |
| | | <Form defaultValues={formData}> |
| | | <Grid container spacing={2}> |
| | | <Grid item md={2}> |
| | | <DictSelect |
| | | label={translate("table.field.transfer.type")} |
| | | value={formData.wkType} |
| | | variant="filled" |
| | | group='2' |
| | | onChange={(e) => handleChange(e.target.value, 'wkType')} |
| | | dictTypeCode="sys_business_type" |
| | | required |
| | | /> |
| | | </Grid> |
| | | <Grid item md={2}> |
| | | <ReferenceInput reference="warehouseAreas" source="name"> |
| | | <AutocompleteInput optionText="name" label="table.field.transfer.orgAreaName" /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <Grid item md={2}> |
| | | <ReferenceInput reference="warehouseAreas" source="name"> |
| | | <AutocompleteInput optionText="name" label="table.field.transfer.orgAreaName" /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <SimpleForm toolbar={false}> |
| | | <Grid container spacing={2}> |
| | | <Grid item md={2}> |
| | | <DictSelect |
| | | label={translate("table.field.transfer.type")} |
| | | value={formData.type} |
| | | variant="filled" |
| | | onChange={(e) => handleChange(e.target.value, 'type')} |
| | | dictTypeCode="sys_transfer_type" |
| | | required |
| | | /> |
| | | </Grid> |
| | | </Form> |
| | | </Box> |
| | | <Grid item md={2}> |
| | | <WarehouseSelect |
| | | value={formData.orgAreaId} |
| | | variant="filled" |
| | | dictTypeCode="warehouse" |
| | | required |
| | | onChange={(e) => handleChange(e.target.value, 'orgAreaId')} |
| | | label={translate("table.field.transfer.orgAreaName")} /> |
| | | </Grid> |
| | | <Grid item md={2}> |
| | | <WarehouseSelect |
| | | label={translate("table.field.transfer.tarAreaName")} |
| | | value={formData.tarAreaId} |
| | | dictTypeCode="warehouse" |
| | | variant="filled" |
| | | required |
| | | onChange={(e) => handleChange(e.target.value, 'tarAreaId')} |
| | | /> |
| | | </Grid> |
| | | </Grid> |
| | | </SimpleForm> |
| | | <Box sx={{ mt: 2 }}> |
| | | <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-end" }}> |
| | | <Button variant="contained" onClick={() => setCreateDialog(true)} > |
| | |
| | | headerClassName: "custom", |
| | | }, |
| | | { |
| | | field: 'splrBatch', |
| | | field: 'batch', |
| | | headerName: translate('table.field.outStockItem.splrBatch'), |
| | | minWidth: 100, |
| | | flex: 1, |
| | |
| | | onRowSelectionModelChange={handleSelectionChange} |
| | | selectionModel={selectedRows} |
| | | sx={{ |
| | | height: 610, |
| | | height: 580, |
| | | '& .MuiDataGrid-cell input': { |
| | | border: '1px solid #ccc' |
| | | }, |