| import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
| import { useLocation, useNavigate } from 'react-router-dom'; | 
| import { | 
|   List, | 
|   DatagridConfigurable, | 
|   SearchInput, | 
|   TopToolbar, | 
|   SelectColumnsButton, | 
|   EditButton, | 
|   FilterButton, | 
|   WrapperField, | 
|   useRecordContext, | 
|   useTranslate, | 
|   useNotify, | 
|   useRefresh, | 
|   useListContext, | 
|   TextField, | 
|   NumberField, | 
|   DateField, | 
|   TextInput, | 
|   DateInput, | 
|   SelectInput, | 
|   NumberInput, | 
|   ReferenceInput, | 
|   AutocompleteInput, | 
|   Button, | 
|   BulkDeleteButton, | 
|   useRedirect, | 
| } from 'react-admin'; | 
| import { styled } from '@mui/material/styles'; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; | 
| import { Box, Typography, Card, Stack, Drawer } from '@mui/material'; | 
| import DictionarySelect from "../../components/DictionarySelect"; | 
| import BillStatusField from '../../components/BillStatusField'; | 
| import MyCreateButton from "../../components/MyCreateButton"; | 
| import ConfirmButton from '../../components/ConfirmButton'; | 
| import ImportButton from "../../components/ImportButton"; | 
| import DetailsIcon from '@mui/icons-material/Details'; | 
| import AddTaskIcon from '@mui/icons-material/AddTask'; | 
| import PublicIcon from '@mui/icons-material/Public'; | 
| import SelectMatnrModal from "./SelectMatnrModal"; | 
| import EditIcon from '@mui/icons-material/Edit'; | 
| import AddIcon from '@mui/icons-material/Add'; | 
| import request from '@/utils/request'; | 
| import PageEditDrawer from "../../components/PageEditDrawer"; | 
| import CheckOrderPub from "./CheckOrderPub"; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|   '& .css-1vooibu-MuiSvgIcon-root': { | 
|     height: '.9em' | 
|   }, | 
|   '& .RaDatagrid-row': { | 
|     cursor: 'auto' | 
|   }, | 
|   '& .column-name': { | 
|   }, | 
|   '& .opt': { | 
|     width: 220 | 
|   }, | 
|   '& .wkType': { | 
|     width: 110 | 
|   }, | 
|   '& .status': { | 
|     width: 90 | 
|   }, | 
| })); | 
|   | 
| const filters = [ | 
|   <SearchInput source="condition" alwaysOn />, | 
|   <TextInput source="code" label="table.field.checkOrder.code" alwaysOn />, | 
|   <ReferenceInput source="type" reference="dictData" filter={{ dictTypeCode: 'sys_order_type', group: '3' }} label="table.field.checkOrder.type" alwaysOn> | 
|     <AutocompleteInput label="table.field.checkOrder.type" optionValue="value" /> | 
|   </ReferenceInput>, | 
|   <ReferenceInput source="wkType" reference="dictData" filter={{ dictTypeCode: 'sys_check_order_type' }} label="table.field.checkOrder.checkType" alwaysOn> | 
|     <AutocompleteInput label="table.field.checkOrder.checkType" optionValue="value" /> | 
|   </ReferenceInput>, | 
|   <TextInput source="logisNo" label="table.field.checkOrder.logisNo" />, | 
|   <DateInput source="arrTime" label="table.field.checkOrder.arrTime" />, | 
|   <TextInput label="common.field.memo" source="memo" />, | 
|   <DictionarySelect | 
|     label='table.field.checkOrder.exceStatus' | 
|     name="exceStatus" | 
|     dictTypeCode="sys_check_exce_status" | 
|     alwaysOn | 
|   />, | 
| ] | 
|   | 
| const CheckOrderList = (props) => { | 
|   const translate = useTranslate(); | 
|   const refresh = useRefresh(); | 
|   const notify = useNotify(); | 
|   const [createDialog, setCreateDialog] = useState(false); | 
|   const [manualDialog, setManualDialog] = useState(false); | 
|   const [selectIds, setSelectIds] = useState([]); | 
|   const [preview, setPreview] = useState(false); | 
|   const [waveRule, setWaveRule] = useState(false); | 
|   const [drawerVal, setDrawerVal] = useState(false); | 
|   const [modalType, setmodalType] = useState(0); | 
|   const [select, setSelect] = useState(0); | 
|   const billReload = useRef(); | 
|   const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_check_order_type')) || []; | 
|   | 
|   //获取波次规则 | 
|   // const closeDialog = async (value) => { | 
|   //   setWaveRule(false) | 
|   //   const res = await request.post(`/outStock/generate/wave`, { ids: selectIds, waveRuleId: value.id }); | 
|   //   if (res?.data?.code === 200) { | 
|   //     notify(res.data.msg); | 
|   //   } else { | 
|   //     notify(res.data.msg); | 
|   //   } | 
|   //   refresh() | 
|   // } | 
|   | 
|   return ( | 
|     <Box display="flex"> | 
|       <List | 
|         resource="check" | 
|         sx={{ | 
|           flexGrow: 1, | 
|           transition: (theme) => | 
|             theme.transitions.create(['all'], { | 
|               duration: theme.transitions.duration.enteringScreen, | 
|             }), | 
|         }} | 
|         title={"menu.checkOrder"} | 
|         empty={false} | 
|         filters={filters} | 
|         filter={{ deleted: 0, type: 'check' }} | 
|         sort={{ field: "create_time", order: "desc" }} | 
|         actions={( | 
|           <TopToolbar> | 
|             <FilterButton /> | 
|             <MyCreateButton onClick={() => { setManualDialog(true); setmodalType(0) }} /> | 
|             <SelectColumnsButton preferenceKey='check' /> | 
|             <ImportButton value={'check'} /> | 
|           </TopToolbar> | 
|         )} | 
|         perPage={DEFAULT_PAGE_SIZE} | 
|       > | 
|         <StyledDatagrid | 
|           preferenceKey='check' | 
|           bulkActionButtons={() => <BulkDeleteButton mutationMode="pessimistic" />} | 
|           rowClick={false} | 
|           expandSingle={true} | 
|           omit={['id', 'createTime', 'createBy', 'memo', 'rleStatus$']} | 
|         > | 
|           <NumberField source="id" /> | 
|           <TextField source="code" label="table.field.checkOrder.code" /> | 
|           {/* <TextField source="type$" label="table.field.checkOrder.type" /> */} | 
|           <TextField cellClassName="wkType" source="wkType$" label="table.field.checkOrder.type" /> | 
|           <TextField  source="checkType$" label="table.field.checkOrder.checkType" /> | 
|           <NumberField source="anfme" label="table.field.checkOrder.anfme" /> | 
|           <NumberField source="workQty" label="table.field.checkOrder.workQty" /> | 
|           <NumberField source="qty" label="table.field.checkOrder.qty" /> | 
|           <DateField source="arrTime" label="table.field.checkOrder.arrTime" /> | 
|           <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.checkOrder.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> | 
|             <CancelButton /> | 
|             <PublicButton setDrawerVal={setDrawerVal} drawerVal={drawerVal} setSelect={setSelect} /> | 
|           </WrapperField> | 
|         </StyledDatagrid> | 
|       </List> | 
|       <SelectMatnrModal | 
|         asnId={modalType} | 
|         billReload={billReload} | 
|         open={manualDialog} | 
|         setOpen={setManualDialog} | 
|       /> | 
|       {/* <OutStockWaveDialog open={waveRule} setOpen={setWaveRule} onClose={closeDialog} /> | 
|       <OutOrderPreview open={preview} setOpen={setPreview} />*/} | 
|       <PageEditDrawer | 
|         title={"toolbar.publicWorking"} | 
|         drawerVal={drawerVal} | 
|         setDrawerVal={setDrawerVal} | 
|       > | 
|         <CheckOrderPub record={select} open={drawerVal} setOpen={setDrawerVal} /> | 
|       </PageEditDrawer> | 
|     </Box > | 
|   ) | 
| } | 
| export default CheckOrderList; | 
|   | 
|   | 
| const PublicTaskButton = ({ setWaveRule, setSelectIds }) => { | 
|   const record = useRecordContext(); | 
|   const { selectedIds, onUnselectItems } = useListContext(); | 
|   const notify = useNotify(); | 
|   const redirect = useRedirect(); | 
|   | 
|   const pubClick = async () => { | 
|     onUnselectItems(); | 
|     setWaveRule(true); | 
|     setSelectIds(selectedIds) | 
|   } | 
|   | 
|   return ( | 
|     <Button | 
|       onClick={pubClick} | 
|       label={"toolbar.createWave"} | 
|       startIcon={<PublicIcon />} | 
|     /> | 
|   ); | 
| } | 
|   | 
| const MyButton = ({ setCreateDialog, setmodalType }) => { | 
|   const record = useRecordContext(); | 
|   const handleEditClick = (btn) => { | 
|     btn.stopPropagation(); | 
|     const id = record.id; | 
|     setmodalType(id); | 
|     setCreateDialog(true); | 
|   }; | 
|   return ( | 
|     <Button | 
|       color="primary" | 
|       startIcon={<EditIcon />} | 
|       onClick={(btn) => handleEditClick(btn)} | 
|       sx={{ ml: 1 }} | 
|       label={'ra.action.edit'} | 
|     > | 
|     </Button> | 
|   ) | 
| } | 
|   | 
|   | 
| const CancelButton = () => { | 
|   const record = useRecordContext(); | 
|   const notify = useNotify(); | 
|   const refresh = useRefresh(); | 
|   const cancelOrder = async () => { | 
|     const { data: { code, data, msg } } = await request.get(`/check/cancel/${record?.id}`); | 
|     if (code === 200) { | 
|       notify(msg); | 
|       refresh() | 
|     } else { | 
|       notify(msg); | 
|     } | 
|   } | 
|   | 
|   return ( | 
|     record?.exceStatus == 0 ? <ConfirmButton label={"toolbar.cancel"} startIcon={<CancelOutlinedIcon />} onConfirm={cancelOrder} size={"small"} /> : <></> | 
|   ) | 
| } | 
|   | 
|   | 
| //下发执行 | 
| const PublicButton = ({ setDrawerVal, setSelect }) => { | 
|   const record = useRecordContext(); | 
|   const refresh = useRefresh(); | 
|   const taskEvent = () => { | 
|     setDrawerVal(true) | 
|     setSelect(record) | 
|     refresh(); | 
|   } | 
|   | 
|   return ( | 
|     record.workQty < record.anfme ? <Button label={"toolbar.publicWorking"} startIcon={<AddTaskIcon />} onClick={taskEvent} size={"small"} /> : <></> | 
|   ) | 
| } |