| 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, | 
|     useRefresh, | 
|     AutocompleteInput, | 
|     DeleteButton, | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack, LinearProgress } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import WarehouseAreasItemCreate from "./WarehouseAreasItemCreate"; | 
| import WarehouseAreasItemPanel from "./WarehouseAreasItemPanel"; | 
| import EmptyData from "../components/EmptyData"; | 
| import request from '@/utils/request'; | 
| import MyCreateButton from "../components/MyCreateButton"; | 
| import MyExportButton from '../components/MyExportButton'; | 
| 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 WarehouseIsptResult from "./WarehouseIsptResult" | 
|   | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
|     '& .MuiTableCell-root': { | 
|     whiteSpace: 'nowrap', | 
|     overflow: 'visible', | 
|     textOverflow: 'unset' | 
|   } | 
| })); | 
|   | 
| const filters = [ | 
|     <SearchInput source="condition" alwaysOn />, | 
|     <NumberInput source="areaId" label="table.field.warehouseAreasItem.areaId" />, | 
|     <TextInput source="asnCode" label="table.field.warehouseAreasItem.asnCode" />, | 
|     <TextInput source="areaName" label="table.field.warehouseAreasItem.areaName" />, | 
|     <NumberInput source="matnrId" label="table.field.warehouseAreasItem.matnrId" />, | 
|     <TextInput source="matnrName" label="table.field.warehouseAreasItem.matnrName" />, | 
|     <TextInput source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />, | 
|     <TextInput source="barcode" label="table.field.warehouseAreasItem.barcode" />, | 
|     <NumberInput source="anfme" label="table.field.warehouseAreasItem.anfme" />, | 
|     <TextInput source="batch" label="table.field.warehouseAreasItem.batch" />, | 
|     <TextInput source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />, | 
|     <TextInput source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />, | 
|     <TextInput source="projectCode" label="table.field.asnOrderItem.projectCode" />, | 
|     <TextInput source="unit" label="table.field.warehouseAreasItem.unit" />, | 
|     <TextInput source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />, | 
|     <TextInput source="brand" label="table.field.warehouseAreasItem.brand" />, | 
|     <ReferenceInput source="shipperId" label="table.field.warehouseAreasItem.shipperId" reference="companys"> | 
|         <AutocompleteInput label="table.field.warehouseAreasItem.shipperId" optionText="name" filterToQuery={(val) => ({ name: val })} /> | 
|     </ReferenceInput>, | 
|     <TextInput source="splrId" label="table.field.warehouseAreasItem.splrId" />, | 
|     <NumberInput source="weight" label="table.field.warehouseAreasItem.weight" />, | 
|     <TextInput source="prodTime" label="table.field.warehouseAreasItem.prodTime" />, | 
|     <TextInput source="splrBtch" label="table.field.warehouseAreasItem.splrBtch" />, | 
|   | 
|     <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 WarehouseAreasItemList = () => { | 
|     const translate = useTranslate(); | 
|     const [itemInfo, setItemInfo] = useState({}) | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|   | 
|     return ( | 
|         <Box display="flex"> | 
|             <List | 
|                 title={"menu.warehouseAreasItem"} | 
|                 empty={false} | 
|                 filters={filters} | 
|                 sort={{ field: "create_time", order: "desc" }} | 
|                 sx={{ | 
|                     flexGrow: 1, | 
|                     transition: (theme) => | 
|                         theme.transitions.create(['all'], { | 
|                             duration: theme.transitions.duration.enteringScreen, | 
|                         }), | 
|                 }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <FilterButton /> | 
|                         <SelectColumnsButton preferenceKey='warehouseAreasItem' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             > | 
|                 <DynamicFields | 
|                     drawerVal={drawerVal} | 
|                     setDrawerVal={setDrawerVal} | 
|                     itemInfo={itemInfo} | 
|                     setItemInfo={setItemInfo} /> | 
|             </List> | 
|             <WarehouseAreasItemCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <WarehouseIsptResult | 
|                 record={itemInfo} | 
|                 drawerVal={drawerVal} | 
|                 from="warehosueItem" | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </WarehouseIsptResult> | 
|             {/* <PageDrawer | 
|                 title='WarehouseAreasItem Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> */} | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default WarehouseAreasItemList; | 
|   | 
|   | 
| const DynamicFields = (props) => { | 
|     const { drawerVal, setDrawerVal, itemInfo, setItemInfo } = props | 
|     const translate = useTranslate(); | 
|     const notify = useNotify(); | 
|     const [columns, setColumns] = useState([]); | 
|     const { isLoading } = useListContext(); | 
|     const refresh = useRefresh(); | 
|     useEffect(() => { | 
|         getDynamicFields(); | 
|     }, []); | 
|   | 
|     const getDynamicFields = async () => { | 
|         const { data: { code, data, msg }, } = await request.get("/fields/enable/list"); | 
|         if (code == 200) { | 
|             const arr = [ | 
|                 <NumberField key="id" source="id" />, | 
|                 <TextField key="asnCode" source="asnCode" label="table.field.warehouseAreasItem.asnCode" />, | 
|                 <NumberField key="areaId" source="areaId" label="table.field.warehouseAreasItem.areaId" />, | 
|                 <TextField key="areaName" source="areaName" label="table.field.warehouseAreasItem.areaName" />, | 
|                 <NumberField key="matnrId" source="matnrId" label="table.field.warehouseAreasItem.matnrId" />, | 
|                 <TextField key="maktx" source="maktx" label="table.field.warehouseAreasItem.matnrName" />, | 
|                 <TextField key="matnrCode" source="matnrCode" label="table.field.warehouseAreasItem.matnrCode" />, | 
|                 <TextField key="trackCode" source="trackCode" label="table.field.warehouseAreasItem.barcode" />, | 
|                 <NumberField key="anfme" source="anfme" label="table.field.warehouseAreasItem.anfme" />, | 
|                 <NumberField key="workQty" source="workQty" label="table.field.warehouseAreasItem.workQty" />, | 
|                 <NumberField key="qty" source="qty" label="table.field.warehouseAreasItem.qty" />, | 
|                 <TextField source="platOrderCode" label="table.field.asnOrderItem.platOrderCode" />, | 
|                 <TextField source="platWorkCode" label="table.field.asnOrderItem.platWorkCode" />, | 
|                 <TextField source="projectCode" label="table.field.asnOrderItem.projectCode" />, | 
|                 // <MyField source="isptQty" label="table.field.qlyIsptItem.anfme" | 
|                 //     onClick={(event, record, val) => { | 
|                 //         event.stopPropagation(); | 
|                 //         setItemInfo(record) | 
|                 //         setDrawerVal(!!drawerVal && drawerVal === val ? null : val); | 
|                 //     }} | 
|                 // />, | 
|                 <TextField key="splrBatch" source="splrBatch" label="table.field.warehouseAreasItem.splrBtch" />, | 
|                 <TextField key="batch" source="batch" label="table.field.warehouseAreasItem.batch" />, | 
|                 <TextField key="unit" source="unit" label="table.field.warehouseAreasItem.unit" />, | 
|                 <TextField key="stockUnit" source="stockUnit" label="table.field.warehouseAreasItem.stockUnit" />, | 
|                 <TextField key="brand" source="brand" label="table.field.warehouseAreasItem.brand" />, | 
|                 <TextField key="shipperId" source="shipperId" label="table.field.warehouseAreasItem.shipperId" />, | 
|                 <TextField key="splrId" source="splrId" label="table.field.warehouseAreasItem.splrId" />, | 
|                 <TextField key="isptResult" source="isptResult$" label="table.field.warehouseAreasItem.isptResult" sortable={false} />, | 
|                 <NumberField key="weight" source="weight" label="table.field.warehouseAreasItem.weight" />, | 
|                 <TextField key="prodTime" source="prodTime" label="table.field.warehouseAreasItem.prodTime" />, | 
|             ] | 
|             const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />) | 
|             const lastArr = [ | 
|                 <TextField key="updateBy" source="updateBy$" label="common.field.updateBy" />, | 
|                 <DateField key="updateTime" source="updateTime" label="common.field.updateTime" showTime />, | 
|                 <TextField key="createBy" source="createBy$" label="common.field.createBy" />, | 
|                 <DateField key="createTime" source="createTime" label="common.field.createTime" showTime />, | 
|                 <BooleanField key="statusBool" source="statusBool" label="common.field.status" sortable={false} />, | 
|                 <TextField key="memo" source="memo" label="common.field.memo" sortable={false} />, | 
|             ] | 
|             setColumns([...arr, ...fields, ...lastArr]); | 
|             //filters添加过滤字段 | 
|             data.map(el => { | 
|                 var i = 0; | 
|                 filters.map((item) => { | 
|                     if (item.key === el.fields) { | 
|                         i = 1; | 
|                     } | 
|                 }) | 
|                 i === 0 && filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />) | 
|             }) | 
|         } else { | 
|             notify(msg); | 
|         } | 
|     } | 
|   | 
|     return ( | 
|         <Box sx={{ position: 'relative', minHeight: "82vh", }}> | 
|             {isLoading && ( | 
|                 <LinearProgress | 
|                     sx={{ | 
|                         height: "2px", | 
|                         position: 'absolute', | 
|                         top: 0, | 
|                         left: 0, | 
|                         right: 0, | 
|                     }} | 
|                 /> | 
|             )} | 
|             {columns.length > 0 && | 
|                 <StyledDatagrid | 
|                     preferenceKey='warehouseAreasItem' | 
|                     bulkActionButtons={false} | 
|                     rowClick={(id, resource, record) => false} | 
|                     omit={['prodTime','unit','platOrderCode','trackCode','id', 'createTime', 'memo', 'areaId', 'brand', 'createBy$', | 
|                          'weight', 'matnrId', 'batch', 'shipperId', 'splrId', 'platWorkCode', 'projectCode','statusBool']} | 
|                 > | 
|                     {columns.map((column) => column)} | 
|                 </StyledDatagrid>} | 
|         </Box> | 
|     ) | 
| } |