|  |  |  | 
|---|
|  |  |  | CreateButton, | 
|---|
|  |  |  | ExportButton, | 
|---|
|  |  |  | BulkDeleteButton, | 
|---|
|  |  |  | useDataProvider, | 
|---|
|  |  |  | WrapperField, | 
|---|
|  |  |  | useRecordContext, | 
|---|
|  |  |  | useTranslate, | 
|---|
|  |  |  | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | useRedirect, | 
|---|
|  |  |  | useUnselectAll, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | 
|---|
|  |  |  | import BillStatusField from '../../components/BillStatusField'; | 
|---|
|  |  |  | import ConfirmButton from '../../components/ConfirmButton'; | 
|---|
|  |  |  | import PageDrawer from "../../components/PageDrawer"; | 
|---|
|  |  |  | import MyField from "../../components/MyField"; | 
|---|
|  |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
|---|
|  |  |  | import * as Common from '@/utils/common'; | 
|---|
|  |  |  | import ConstructionIcon from "@mui/icons-material/Construction"; | 
|---|
|  |  |  | import FileDownloadIcon from '@mui/icons-material/FileDownload'; | 
|---|
|  |  |  | 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"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | 
|---|
|  |  |  | '& .column-name': { | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .opt': { | 
|---|
|  |  |  | width: 180 | 
|---|
|  |  |  | width: 220 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .wkType': { | 
|---|
|  |  |  | width: 110 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .status': { | 
|---|
|  |  |  | width: 90 | 
|---|
|  |  |  | 
|---|
|  |  |  | <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"> | 
|---|
|  |  |  | <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_business_type' }} label="table.field.asnOrder.wkType"> | 
|---|
|  |  |  | <AutocompleteInput label="table.field.asnOrder.wkType" optionValue="value" /> | 
|---|
|  |  |  | </ReferenceInput>, | 
|---|
|  |  |  | <NumberInput source="anfme" label="table.field.asnOrder.anfme" />, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ] | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const AsnOrderList = () => { | 
|---|
|  |  |  | const AsnOrderList = (props) => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  | const [modalType, setmodalType] = useState(0); | 
|---|
|  |  |  | const [select, setSelect] = useState(0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const billReload = useRef(); | 
|---|
|  |  |  | const location = useLocation(); | 
|---|
|  |  |  | const redirect = useRedirect(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_business_type')) || []; | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | resource="asnOrder" | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.asnOrder"} | 
|---|
|  |  |  | empty={<EmptyData onClick={() => { setCreateDialog(true); setmodalType(0) }} />} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | filter={{ deleted: 0 }} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setCreateDialog(true); setmodalType(0) }} /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='asnOrder' /> | 
|---|
|  |  |  | <ImportButton value={'asnOrderItem'} /> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | sx={{ width: '100%' }} | 
|---|
|  |  |  | preferenceKey='asnOrder' | 
|---|
|  |  |  | bulkActionButtons={<> <InspectionsButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>} | 
|---|
|  |  |  | rowClick='edit' | 
|---|
|  |  |  | bulkActionButtons={ | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <InspectionsButton /> | 
|---|
|  |  |  | <MyExportButton /> | 
|---|
|  |  |  | {/* <BtnBulkExport></BtnBulkExport> */} | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | rowClick={false} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo', 'poId', 'rleStatus$']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | 
|---|
|  |  |  | <TextField source="poCode" label="table.field.asnOrder.poCode" /> | 
|---|
|  |  |  | <NumberField source="poId" label="table.field.asnOrder.poId" /> | 
|---|
|  |  |  | <TextField source="type$" label="table.field.asnOrder.type" /> | 
|---|
|  |  |  | <TextField source="wkType$" label="table.field.asnOrder.wkType" /> | 
|---|
|  |  |  | <TextField cellClassName="wkType" source="wkType$" label="table.field.asnOrder.wkType" /> | 
|---|
|  |  |  | <NumberField source="anfme" label="table.field.asnOrder.anfme" /> | 
|---|
|  |  |  | <NumberField source="qty" label="table.field.asnOrder.qty" /> | 
|---|
|  |  |  | <TextField source="logisNo" label="table.field.asnOrder.logisNo" /> | 
|---|
|  |  |  | <DateField source="arrTime" label="table.field.asnOrder.arrTime" showTime /> | 
|---|
|  |  |  | <TextField source="rleStatus$" label="table.field.asnOrder.rleStatus" sortable={false} /> | 
|---|
|  |  |  | <TextField source="ntyStatus$" label="table.field.asnOrder.ntyStatus" /> | 
|---|
|  |  |  | <TextField source="updateBy$" label="common.field.updateBy" /> | 
|---|
|  |  |  | <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|---|
|  |  |  | <TextField source="createBy$" label="common.field.createBy" /> | 
|---|
|  |  |  | <DateField source="createTime" label="common.field.createTime" showTime /> | 
|---|
|  |  |  | <BillStatusField cellClassName="status" source="exceStatus" label="table.field.asnOrder.exceStatus" /> | 
|---|
|  |  |  | <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt" width={300} > | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt" > | 
|---|
|  |  |  | <EditButton label="toolbar.detail"></EditButton> | 
|---|
|  |  |  | <MyButton setCreateDialog={setCreateDialog} setmodalType={setmodalType} /> | 
|---|
|  |  |  | <InspectionButton /> | 
|---|
|  |  |  | <CompleteButton /> | 
|---|
|  |  |  | <CloseButton /> | 
|---|
|  |  |  | <ODeleteButton  /> | 
|---|
|  |  |  | {/* <CloseButton /> */} | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | export default AsnOrderList; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const ODeleteButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | record.exceStatus === 0 ? <DeleteButton  mutationMode="pessimistic"/> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MyButton = ({ setCreateDialog, setmodalType }) => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const handleEditClick = (btn) => { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | record.exceStatus === 1 || record.exceStatus === 0 ? | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | color="primary" | 
|---|
|  |  |  | startIcon={<EditIcon />} | 
|---|
|  |  |  | 
|---|
|  |  |  | label={'ra.action.edit'} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //报检 | 
|---|
|  |  |  | const InspectionButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button onClick={inspection} label={"toolbar.inspection"}> | 
|---|
|  |  |  | <ConstructionIcon /> | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.inspection"} color="secondary" startIcon={<ConstructionIcon />} onConfirm={inspection} /> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | const { selectedIds, onUnselectItems, data } = useListContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const inspection = (btn) => { | 
|---|
|  |  |  | btn.stopPropagation(); | 
|---|
|  |  |  | if (selectedIds.length === 0) { | 
|---|
|  |  |  | notify('请选择通知单'); | 
|---|
|  |  |  | notify(translate("request.error.select_error_order")); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | const rows = data.filter((item) => selectedIds.includes(item.id)) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button onClick={inspection} label={"toolbar.inspection"}> | 
|---|
|  |  |  | <ConstructionIcon /> | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const BtnBulkExport = () => { | 
|---|
|  |  |  | const { filter, selectedIds, filterValues, resource, sort, total } = useListContext(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const dataProvider = useDataProvider(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const unSelect = useUnselectAll(resource); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const bulkExport = () => { | 
|---|
|  |  |  | getExport() | 
|---|
|  |  |  | unSelect(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const getExport = () => { | 
|---|
|  |  |  | dataProvider | 
|---|
|  |  |  | .export(resource, { | 
|---|
|  |  |  | ids: selectedIds, | 
|---|
|  |  |  | pagination: { page: 1, perPage: 1000 }, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .then((res) => { | 
|---|
|  |  |  | const url = window.URL.createObjectURL( | 
|---|
|  |  |  | new Blob([res.data], { type: res.headers["content-type"] }), | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | const link = document.createElement("a"); | 
|---|
|  |  |  | link.href = url; | 
|---|
|  |  |  | link.setAttribute("download", `${resource}.xlsx`); | 
|---|
|  |  |  | document.body.appendChild(link); | 
|---|
|  |  |  | link.click(); | 
|---|
|  |  |  | link.remove(); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch((error) => { | 
|---|
|  |  |  | console.error(error); | 
|---|
|  |  |  | notify("ra.notification.http_error", { type: "error" }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (typeof onClick === "function") { | 
|---|
|  |  |  | onClick(event); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Button label="toolbar.bulkExport" onClick={bulkExport}> | 
|---|
|  |  |  | <ExitToAppIcon /> | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //完成单据 | 
|---|
|  |  |  | const CompleteButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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} />) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // record.exceStatus === 1 && (record.anfme === record.qty ? <Button onClick={requestComplete} label={"toolbar.complete"} color="secondary"> | 
|---|
|  |  |  | //   <TaskIcon /> | 
|---|
|  |  |  | // </Button> : ) | 
|---|
|  |  |  | record.exceStatus === 1 ? <ConfirmButton label={"toolbar.complete"} color="secondary"  startIcon={<TaskIcon />} onConfirm={requestComplete} /> : <></> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.close"} color="error" data={'确认是否关闭?'} startIcon={<CloseIcon />} onConfirm={requestClose} /> | 
|---|
|  |  |  | <ConfirmButton label={"toolbar.close"} color="error"  startIcon={<CloseIcon />} onConfirm={requestClose} /> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|