|  |  |  | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | import AsnOrderModal from "./AsnOrderModal"; | 
|---|
|  |  |  | import EmptyData from "../../components/EmptyData"; | 
|---|
|  |  |  | import MyCreateButton from "../../components/MyCreateButton"; | 
|---|
|  |  |  | import MyExportButton from '../../components/MyExportButton'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import ConfirmButton from '../../components/ConfirmButton'; | 
|---|
|  |  |  | import PageDrawer from "../../components/PageDrawer"; | 
|---|
|  |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
|---|
|  |  |  | import ConstructionIcon from "@mui/icons-material/Construction"; | 
|---|
|  |  |  | import EditIcon from '@mui/icons-material/Edit'; | 
|---|
|  |  |  | import TaskIcon from '@mui/icons-material/Task'; | 
|---|
|  |  |  | import CloseIcon from '@mui/icons-material/Close'; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | import DictionarySelect from "../../components/DictionarySelect"; | 
|---|
|  |  |  | import ExitToAppIcon from '@mui/icons-material/ExitToApp'; | 
|---|
|  |  |  | import ImportButton from "../../components/ImportButton"; | 
|---|
|  |  |  | import DetailsIcon from '@mui/icons-material/Details'; | 
|---|
|  |  |  | import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; | 
|---|
|  |  |  | import OutOrderCreate from "./OutOrderCreate"; | 
|---|
|  |  |  | import AddIcon from '@mui/icons-material/Add'; | 
|---|
|  |  |  | import OutOrderModal from "./OutOrderModal"; | 
|---|
|  |  |  | import PublicIcon from '@mui/icons-material/Public'; | 
|---|
|  |  |  | import SelectMatnrModal from "./SelectMatnrModal"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const filters = [ | 
|---|
|  |  |  | <SearchInput source="condition" alwaysOn />, | 
|---|
|  |  |  | <TextInput source="code" label="table.field.asnOrder.code" />, | 
|---|
|  |  |  | <TextInput source="poCode" label="table.field.asnOrder.poCode" />, | 
|---|
|  |  |  | <NumberInput source="poId" label="table.field.asnOrder.poId" />, | 
|---|
|  |  |  | <TextInput source="type" label="table.field.asnOrder.type" />, | 
|---|
|  |  |  | <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_business_type' }} label="table.field.asnOrder.wkType"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.asnOrder.wkType" optionValue="value" /> | 
|---|
|  |  |  | <TextInput source="code" label="table.field.outStock.code" alwaysOn />, | 
|---|
|  |  |  | <TextInput source="poCode" label="table.field.outStock.poCode" />, | 
|---|
|  |  |  | <NumberInput source="poId" label="table.field.outStock.poId" />, | 
|---|
|  |  |  | <ReferenceInput source="type" reference="dictData" filter={{ dictTypeCode: 'sys_order_type', group: '2' }} label="table.field.outStock.type" alwaysOn> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.outStock.type" optionValue="value" /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <NumberInput source="anfme" label="table.field.asnOrder.anfme" />, | 
|---|
|  |  |  | <NumberInput source="qty" label="table.field.asnOrder.qty" />, | 
|---|
|  |  |  | <TextInput source="logisNo" label="table.field.asnOrder.logisNo" />, | 
|---|
|  |  |  | <DateInput source="arrTime" label="table.field.asnOrder.arrTime" />, | 
|---|
|  |  |  | <SelectInput source="rleStatus" label="table.field.asnOrder.rleStatus" | 
|---|
|  |  |  | <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_business_type', group: '2'}} label="table.field.outStock.wkType" alwaysOn> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.outStock.wkType" optionValue="value" /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <NumberInput source="anfme" label="table.field.outStock.anfme" />, | 
|---|
|  |  |  | <NumberInput source="qty" label="table.field.outStock.qty" />, | 
|---|
|  |  |  | <TextInput source="logisNo" label="table.field.outStock.logisNo" />, | 
|---|
|  |  |  | <DateInput source="arrTime" label="table.field.outStock.arrTime" />, | 
|---|
|  |  |  | <SelectInput source="rleStatus" label="table.field.outStock.rleStatus" | 
|---|
|  |  |  | choices={[ | 
|---|
|  |  |  | { id: 0, name: ' 正常' }, | 
|---|
|  |  |  | { id: 1, name: ' 已释放' }, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <TextInput label="common.field.memo" source="memo" />, | 
|---|
|  |  |  | <DictionarySelect | 
|---|
|  |  |  | label='table.field.asnOrder.exceStatus' | 
|---|
|  |  |  | label='table.field.outStock.exceStatus' | 
|---|
|  |  |  | name="exceStatus" | 
|---|
|  |  |  | dictTypeCode="sys_asn_exce_status" | 
|---|
|  |  |  | alwaysOn | 
|---|
|  |  |  | 
|---|
|  |  |  | const OutOrderList = (props) => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [manualDialog, setManualDialog] = useState(false); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  | const [modalType, setmodalType] = useState(0); | 
|---|
|  |  |  | const [select, setSelect] = useState(0); | 
|---|
|  |  |  | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | resource="outStock" | 
|---|
|  |  |  | storeKey='outStock' | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.outStock"} | 
|---|
|  |  |  | empty={<EmptyData onClick={() => { setCreateDialog(true); setmodalType(0) }} />} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | filter={{deleted: 0, type: 'out'}} | 
|---|
|  |  |  | filter={{ deleted: 0, type: 'out' }} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setCreateDialog(true); setmodalType(0) }} /> | 
|---|
|  |  |  | <CreateByOrderButton setCreateDialog={setCreateDialog} /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setManualDialog(true); setmodalType(0) }} /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='outStock' /> | 
|---|
|  |  |  | <ImportButton value={'asnOrderItem'}  /> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | <ImportButton value={'asnOrderItem'} /> | 
|---|
|  |  |  | {/* <MyExportButton /> */} | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | perPage={DEFAULT_PAGE_SIZE} | 
|---|
|  |  |  | 
|---|
|  |  |  | sx={{ width: '100%' }} | 
|---|
|  |  |  | preferenceKey='outStock' | 
|---|
|  |  |  | bulkActionButtons={ | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | {/* <BtnBulkExport></BtnBulkExport> */} | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | <PublicTaskButton />} | 
|---|
|  |  |  | rowClick={false} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo', 'poId', 'rleStatus$']} | 
|---|
|  |  |  | 
|---|
|  |  |  | <BillStatusField cellClassName="status" source="exceStatus" label="table.field.outStock.exceStatus" /> | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt" > | 
|---|
|  |  |  | <MyButton setCreateDialog={setManualDialog} setmodalType={setmodalType} /> | 
|---|
|  |  |  | <EditButton label="toolbar.detail" icon={(<DetailsIcon />)}></EditButton> | 
|---|
|  |  |  | <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} /> | 
|---|
|  |  |  | {/* <CompleteButton /> */} | 
|---|
|  |  |  | <CancelButton /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | <AsnOrderModal | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | {/* <OutOrderCreate | 
|---|
|  |  |  | open={manualDialog} | 
|---|
|  |  |  | setOpen={setManualDialog} | 
|---|
|  |  |  | /> */} | 
|---|
|  |  |  | <SelectMatnrModal | 
|---|
|  |  |  | asnId={modalType} | 
|---|
|  |  |  | billReload={billReload} | 
|---|
|  |  |  | open={manualDialog} | 
|---|
|  |  |  | setOpen={setManualDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <OutOrderModal | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <PageDrawer | 
|---|
|  |  |  | title='AsnOrder Detail' | 
|---|
|  |  |  | drawerVal={drawerVal} | 
|---|
|  |  |  | setDrawerVal={setDrawerVal} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </PageDrawer> | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Box > | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | export default OutOrderList; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const PublicTaskButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const { selectedIds, onUnselectItems } = useListContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const pubClick = async (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | onUnselectItems(); | 
|---|
|  |  |  | const res = await request.post(`/outStock/generate/wave`, { ids: selectedIds }); | 
|---|
|  |  |  | if (res?.data?.code === 200) { | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | redirect("/wave") | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | refresh(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | onClick={pubClick} | 
|---|
|  |  |  | label={"toolbar.createWave"} | 
|---|
|  |  |  | startIcon={<PublicIcon />} | 
|---|
|  |  |  | />); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MyButton = ({ setCreateDialog, setmodalType }) => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | 
|---|
|  |  |  | const id = record.id; | 
|---|
|  |  |  | setmodalType(id); | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const CompleteButton = () => { | 
|---|
|  |  |  | const CreateByOrderButton = ({ setCreateDialog }) => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const requestComplete = async () => { | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post(`/asnOrder/complete/${record.id}`); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | refresh() | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const createByOrder = async (event) => { | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | setCreateDialog(true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | record.exceStatus === 1 && (record.anfme === record.qty ? <Button onClick={requestComplete} label={"toolbar.complete"} color="success"> | 
|---|
|  |  |  | <TaskIcon /> | 
|---|
|  |  |  | </Button> : <ConfirmButton label={"toolbar.complete"} color="success" data={'当前收货数量小于计划数量,是否确认完成'} startIcon={<TaskIcon />} onConfirm={requestComplete} />) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <Button onClick={createByOrder} label={'toolbar.asnCreate'}> <AddIcon /> </Button> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const CloseButton = () => { | 
|---|
|  |  |  | const CancelButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const requestClose = async () => { | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.post(`/asnOrder/close/${record.id}`); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const cancelOrder = async () => { | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.get(`/outStock/cancel/${record?.id}`); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | refresh() | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.close"} color="error" data={'确认是否关闭?'} startIcon={<CloseIcon />} onConfirm={requestClose} /> | 
|---|
|  |  |  | record?.exceStatus == 0 ? <ConfirmButton label={"toolbar.cancel"} startIcon={<CancelOutlinedIcon />  } onConfirm={cancelOrder} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|