| | |
| | | DateInput, |
| | | ReferenceInput, |
| | | AutocompleteInput, |
| | | SelectColumnsButton, |
| | | DatagridConfigurable, |
| | | Toolbar, |
| | | required, |
| | | useNotify, |
| | | DeleteButton, |
| | | BooleanField, |
| | | EditButton, |
| | | WrapperField, |
| | | SaveButton, |
| | | SimpleForm, |
| | | NumberField, |
| | | useRefresh, |
| | | TextField, |
| | | DateField, |
| | | CreateBase, |
| | | TopToolbar, |
| | | FilterButton, |
| | | SearchInput, |
| | | List, |
| | | Create, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | | DialogActions, |
| | | DialogContent, |
| | | DialogTitle, |
| | | TextField, |
| | | IconButton, |
| | | MenuItem, |
| | | Tooltip, |
| | |
| | | Button, |
| | | Stack, |
| | | Grid, |
| | | Card, |
| | | Box, |
| | | CardContent, |
| | | } from '@mui/material'; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import ConfirmationNumberIcon from '@mui/icons-material/ConfirmationNumber'; |
| | | import DialogCloseButton from "../../components/DialogCloseButton.jsx"; |
| | | import WarehouseSelect from "../../components/WarehouseSelect.jsx"; |
| | |
| | | import { DataGrid, useGridApiRef } from '@mui/x-data-grid'; |
| | | import ConfirmButton from "../../components/ConfirmButton"; |
| | | import { Add, Edit, Delete } from '@mui/icons-material'; |
| | | import SelectLocsRevise from "./SelectLocsRevise.jsx"; |
| | | import DictSelect from "../../components/DictSelect"; |
| | | import SaveIcon from '@mui/icons-material/Save'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import { redirect } from "react-router"; |
| | | import request from '@/utils/request'; |
| | | import _, { set } from 'lodash'; |
| | | |
| | | const StyledSimpleForm = styled(SimpleForm)(({ theme }) => ({ |
| | | '& .MuiToolbar-root-RaToolbar-root': { |
| | | '& .RaToolbar-defaultToolbar': { |
| | | justifyContent: 'flex-end', |
| | | } |
| | | } |
| | | |
| | | })); |
| | | |
| | | |
| | | const LocReviseCreate = (props) => { |
| | | const { open, setOpen, orderId } = props; |
| | |
| | | const translate = useTranslate(); |
| | | const [tabelData, setTableData] = useState([]); |
| | | const [disabled, setDisabled] = useState(false); |
| | | const [isVisible, setIsVisible] = useState("block"); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [formData, setFormData] = useState({ type: '0', orgAreaId: null, tarAreaId: null, exceTime: null, code: null }); |
| | |
| | | setTableData([...tabelData]); |
| | | } |
| | | |
| | | const handleSubmit = async () => { |
| | | setFinally() |
| | | setDisabled(true) |
| | | const FormToolbar = () => { |
| | | return ( |
| | | <Toolbar sx={{ justifyContent: 'flex-end' }}> |
| | | <SaveButton disabled={disabled} /> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | </Toolbar> |
| | | ) |
| | | } |
| | | // const handleSubmit = async () => { |
| | | // setFinally() |
| | | // setDisabled(true) |
| | | |
| | | if (orderId == null || orderId == undefined) { |
| | | const parmas = { |
| | | "revise": formData, |
| | | "items": tabelData, |
| | | } |
| | | // if (orderId == null || orderId == undefined) { |
| | | // const parmas = { |
| | | // "revise": formData, |
| | | // "items": tabelData, |
| | | // } |
| | | |
| | | const res = await request.post(`/transfer/items/save`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } else { |
| | | const parmas = { |
| | | "transfer": formData, |
| | | "items": tabelData, |
| | | } |
| | | const res = await request.post(`/transfer/items/update`, parmas); |
| | | if (res?.data?.code === 200) { |
| | | setOpen(false); |
| | | } else { |
| | | notify(res.data.msg); |
| | | } |
| | | } |
| | | setDisabled(false) |
| | | refresh(); |
| | | // const res = await request.post(`/transfer/items/save`, parmas); |
| | | // if (res?.data?.code === 200) { |
| | | // setOpen(false); |
| | | // } else { |
| | | // notify(res.data.msg); |
| | | // } |
| | | // } else { |
| | | // const parmas = { |
| | | // "transfer": formData, |
| | | // "items": tabelData, |
| | | // } |
| | | // const res = await request.post(`/transfer/items/update`, parmas); |
| | | // if (res?.data?.code === 200) { |
| | | // setOpen(false); |
| | | // } else { |
| | | // notify(res.data.msg); |
| | | // } |
| | | // } |
| | | // setDisabled(false) |
| | | // refresh(); |
| | | |
| | | }; |
| | | // }; |
| | | |
| | | const handleDeleteItem = () => { |
| | | const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId)); |
| | |
| | | } |
| | | |
| | | const newAddClick = () => { |
| | | if (formData.areaId == null || formData.areaId == undefined) { |
| | | notify("库区不能为空!!", { type: 'error' }) |
| | | return |
| | | } |
| | | setCreateDialog(true) |
| | | } |
| | | |
| | | const mutationOptions = { |
| | | onSuccess: (data) => { |
| | | notify(`文章 "${data.title}" 创建成功`, { type: 'success' }); |
| | | setIsVisible("block") |
| | | setDisabled(true) |
| | | refresh() |
| | | }, |
| | | onError: (error) => { |
| | | notify(`创建失败: ${error.message}`, { type: 'error' }); |
| | | } |
| | | }; |
| | | |
| | | const handleChange = (value, name) => { |
| | |
| | | return ( |
| | | <> |
| | | <Box sx={{ padding: 1 }}> |
| | | <CreateBase resource="locRevise" mutationOptions={mutationOptions} > |
| | | <SimpleForm > |
| | | <Create resource="locRevise" |
| | | title={false} |
| | | mutationOptions={mutationOptions} > |
| | | <SimpleForm toolbar={<FormToolbar />}> |
| | | <Grid container spacing={2} sx={{ |
| | | '& .MuiToolbar-root-RaToolbar-root.RaToolbar-defaultToolbar': { |
| | | justifyContent: 'flex-end', |
| | | } |
| | | }}> |
| | | <Grid item md={2}> |
| | | <TextInput |
| | | source="code" |
| | | label={translate("table.field.locRevise.code")} |
| | | readOnly |
| | | /> |
| | | </Grid> |
| | | <Grid item md={2}> |
| | | <AutocompleteInput |
| | | choices={dicts} |
| | |
| | | optionValue="value" |
| | | defaultValue="1" |
| | | source="type" |
| | | parse={v => v} |
| | | label={translate("table.field.transfer.type")} |
| | | /> |
| | | </Grid> |
| | |
| | | <AutocompleteInput |
| | | optionText='name' |
| | | optionValue="id" |
| | | parse={v => v} |
| | | label={translate("table.field.locRevise.areaName")} |
| | | /> |
| | | </ReferenceInput> |
| | |
| | | <Grid item md={2}> |
| | | <DateInput |
| | | source="exceTime" |
| | | parse={v => v} |
| | | label="table.field.locRevise.exceTime" |
| | | /> |
| | | </Grid> |
| | | </Grid> |
| | | </SimpleForm> |
| | | </CreateBase> |
| | | </Create> |
| | | <Box sx={{ display: isVisible }}> |
| | | <Card sx={{ height: 630 }}> |
| | | <Box> |
| | | <Box sx={{ mt: 2 }}> |
| | | <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-end" }}> |
| | | <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-start" }}> |
| | | <Button variant="contained" onClick={newAddClick} > |
| | | {translate('common.action.newAddMats')} |
| | | </Button> |
| | |
| | | tableRef={tableRef}> |
| | | </TransferTableView> |
| | | </Box> |
| | | <Toolbar sx={{ width: '100%', justifyContent: 'flex-start', bgcolor: 'white' }} > |
| | | <Button disabled={disabled} onClick={handleSubmit} variant="contained" startIcon={<SaveIcon />}> |
| | | {translate('toolbar.confirm')} |
| | | </Button> |
| | | </Toolbar> |
| | | {/* <CreateBySelectMats |
| | | </Box> |
| | | </Card> |
| | | </Box> |
| | | <SelectLocsRevise |
| | | data={tabelData} |
| | | queryForm={formData} |
| | | open={createDialog} |
| | |
| | | selectedRows={selectedRows} |
| | | setSelectedRows={setSelectedRows} |
| | | setData={setTableData} |
| | | /> */} |
| | | /> |
| | | </Box> |
| | | </> |
| | | ) |
| | |
| | | rowSelectionModel={tableIds} |
| | | onRowSelectionModelChange={handleSelectionChange} |
| | | sx={{ |
| | | height: 580, |
| | | height: 500, |
| | | '& .MuiDataGrid-cell input': { |
| | | border: '1px solid #ccc' |
| | | }, |