| import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
| import { useNavigate } from 'react-router-dom'; | 
| import { | 
|     List, | 
|     DatagridConfigurable, | 
|     SearchInput, | 
|     TopToolbar, | 
|     SelectColumnsButton, | 
|     EditButton, | 
|     FilterButton, | 
|     CreateButton, | 
|     ExportButton, | 
|     BulkDeleteButton, | 
|     WrapperField, | 
|     useRecordContext, | 
|     useTranslate, | 
|     useNotify, | 
|     useListContext, | 
|     FunctionField, | 
|     TextField, | 
|     NumberField, | 
|     DateField, | 
|     BooleanField, | 
|     ReferenceField, | 
|     TextInput, | 
|     DateTimeInput, | 
|     DateInput, | 
|     SelectInput, | 
|     NumberInput, | 
|     ReferenceInput, | 
|     ReferenceArrayInput, | 
|     AutocompleteInput, | 
|     DeleteButton, | 
|     Button, | 
|     useRefresh, | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import EmptyData from "../../components/EmptyData"; | 
| import MyCreateButton from "../../components/MyCreateButton"; | 
| import MyExportButton from '../../components/MyExportButton'; | 
| 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 CloseIcon from "@mui/icons-material/Close"; | 
| import TaskIcon from '@mui/icons-material/Task'; | 
| import AddIcon from '@mui/icons-material/Add'; | 
| import request from '@/utils/request'; | 
| import AsnSelModal from "./AsnSelModal"; | 
| import InspectModal from "./InspectModal"; | 
| import QlyInspectOpCreate from './QlyInspectOpCreate'; | 
| import ConfirmButton from "../../components/ConfirmButton"; | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
| })); | 
|   | 
| const filters = [ | 
|     <SearchInput source="condition" alwaysOn />, | 
|     <ReferenceInput source="isptStatus" label="table.field.qlyInspect.isptStatus" reference="dictData" filter={{ dictTypeCode: 'sys_qly_inspect_status' }} alwaysOn> | 
|         <AutocompleteInput source="value" optionText='label' optionValue="value" label="table.field.qlyInspect.isptStatus"></AutocompleteInput> | 
|     </ReferenceInput>, | 
|     <TextInput source="code" label="table.field.qlyInspect.code" />, | 
|     <TextInput source="wkType" label="table.field.qlyInspect.wkType" />, | 
|     <NumberInput source="safeQty" label="table.field.qlyInspect.safeQty" />, | 
|     <NumberInput source="dlyQty" label="table.field.qlyInspect.dlyQty" />, | 
|     <NumberInput source="rcptQty" label="table.field.qlyInspect.rcptQty" />, | 
|     <NumberInput source="isptQty" label="table.field.qlyInspect.isptQty" />, | 
|     <TextInput label="common.field.memo" source="memo" />, | 
|     <SelectInput | 
|         label="common.field.status" | 
|         source="status" | 
|         choices={[ | 
|             { id: '1', name: 'common.enums.statusTrue' }, | 
|             { id: '0', name: 'common.enums.statusFalse' }, | 
|         ]} | 
|         resettable | 
|     />, | 
| ] | 
|   | 
| const QlyInspectList = () => { | 
|     const translate = useTranslate(); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|     const [opCreateDialog, setOpCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <Box display="flex"> | 
|             <List | 
|                 resource="qlyInspect" | 
|                 sx={{ | 
|                     flexGrow: 1, | 
|                     transition: (theme) => | 
|                         theme.transitions.create(['all'], { | 
|                             duration: theme.transitions.duration.enteringScreen, | 
|                         }), | 
|                     marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|                 }} | 
|                 title={"menu.qlyInspect"} | 
|                 empty={<EmptyData | 
|                     children={ | 
|                         <Box sx={{ gap: 2, display: 'flex' }}> | 
|                             <AsnCreatButton isInit={true} /> | 
|                         </Box> | 
|                     } | 
|                     onClick={() => { }} />} | 
|                 filters={filters} | 
|                 sort={{ field: "create_time", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <AsnCreatButton /> | 
|                         {/* <MyCreateButton onClick={() => { setOpCreateDialog(true) }} /> */} | 
|                         <FilterButton /> | 
|                         <SelectColumnsButton preferenceKey='qlyInspect' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             > | 
|                 <StyledDatagrid | 
|                     preferenceKey='qlyInspect' | 
|                     bulkActionButtons={<BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
|                     rowClick={false} | 
|                     expandSingle={true} | 
|                     omit={['id', 'createTime', 'createBy', 'memo', 'asnId', 'statusBool']} | 
|                 > | 
|                     <NumberField source="id" /> | 
|                     <TextField source="code" label="table.field.qlyInspect.code" /> | 
|                     <TextField source="wkType$" label="table.field.qlyInspect.wkType" /> | 
|                     <NumberField source="asnId" label="table.field.qlyInspect.asnId" /> | 
|                     <NumberField source="asnCode" label="table.field.qlyInspect.asnCode" /> | 
|                     <NumberField source="isptQty" label="table.field.qlyInspect.isptQty" /> | 
|                     <TextField source="isptStatus$" label="table.field.qlyInspect.isptStatus" /> | 
|                     <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 /> | 
|                     <BooleanField source="statusBool" label="common.field.status" sortable={false} /> | 
|                     <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|                     <WrapperField cellClassName="opt" label="common.field.opt"> | 
|                         <EditButton label="toolbar.detail" /> | 
|                         <InspectionButton /> | 
|                         <CompleteButton /> | 
|                         {/* <CloseButton /> */} | 
|                     </WrapperField> | 
|                 </StyledDatagrid> | 
|             </List> | 
|             {/* <QlyInspectCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> */} | 
|             <QlyInspectOpCreate | 
|                 open={opCreateDialog} | 
|                 setOpen={setOpCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='QlyInspect Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|         </Box > | 
|     ) | 
| } | 
|   | 
| export default QlyInspectList; | 
|   | 
| const PrintLabelButton = () => { | 
|     const record = useRecordContext(); | 
|   | 
|   | 
| } | 
|   | 
| const InspectionButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         record.isptStatus != 1 && record.isptStatus != 3 ? (<> | 
|             <Button onClick={() => setCreateDialog(true)} label={"toolbar.quality"}> | 
|                 <ConstructionIcon /> | 
|             </Button> | 
|             <InspectModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|                 ispectId={record.id} | 
|             /> | 
|         </>) : (<></>) | 
|     ) | 
| } | 
|   | 
| const CompleteButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|     const requestComplete = async () => { | 
|         const { data: { code, data, msg } } = await request.post(`/qlyInspect/verify/complate/` + record?.id); | 
|         if (code === 200) { | 
|             notify(msg); | 
|             refresh() | 
|         } else { | 
|             notify(msg); | 
|         } | 
|     } | 
|   | 
|     return ( | 
|         record.isptStatus == 2 ? (<ConfirmButton label={"toolbar.verifyComfirm"} color="secondary" startIcon={<TaskIcon />} onConfirm={requestComplete} />) : (<></>) | 
|     ) | 
| } | 
|   | 
| const CloseButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|   | 
|     const requestClose = async () => { | 
|         const { data: { code, data, msg } } = await request.post(`/qlyInspect/update`, { ...record, isptStatus: '3' }); | 
|   | 
|         if (code === 200) { | 
|             notify(msg); | 
|             refresh() | 
|         } else { | 
|             notify(msg); | 
|         } | 
|     } | 
|   | 
|     return ( | 
|         <Button onClick={requestClose} label={"toolbar.close"}> | 
|             <CloseIcon /> | 
|         </Button> | 
|     ) | 
| } | 
|   | 
| const AsnCreatButton = ({ isInit }) => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <> | 
|             { | 
|                 isInit ? <Button onClick={() => setCreateDialog(true)} label={"toolbar.asnCreate"} variant="contained" | 
|                     color="primary"> | 
|                     <AddIcon /> | 
|                 </Button> : <Button onClick={() => setCreateDialog(true)} label={"toolbar.asnCreate"} > | 
|                     <AddIcon /> | 
|                 </Button> | 
|             } | 
|             <AsnSelModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|         </> | 
|     ) | 
| } |