| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import React, { useState, useEffect } from "react"; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | EditButton, |
| | | ColumnsButton, |
| | | 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 { Box, LinearProgress } from '@mui/material'; |
| | | 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' |
| | | } |
| | | })); |
| | | import { DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import StickyDataTable from "../components/StickyDataTable"; |
| | | import WarehouseIsptResult from "./WarehouseIsptResult"; |
| | | import useTableLayout from '@/utils/useTableLayout'; |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | |
| | | ] |
| | | |
| | | const WarehouseAreasItemList = () => { |
| | | const translate = useTranslate(); |
| | | const [itemInfo, setItemInfo] = useState({}) |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <SelectColumnsButton preferenceKey='warehouseAreasItem' /> |
| | | <ColumnsButton storeKey='warehouseAreasItem' /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <DynamicFields |
| | | drawerVal={drawerVal} |
| | | setDrawerVal={setDrawerVal} |
| | | itemInfo={itemInfo} |
| | | setItemInfo={setItemInfo} /> |
| | | <DynamicFields /> |
| | | </List> |
| | | <WarehouseAreasItemCreate |
| | | open={createDialog} |
| | |
| | | export default WarehouseAreasItemList; |
| | | |
| | | |
| | | const DynamicFields = (props) => { |
| | | const { drawerVal, setDrawerVal, itemInfo, setItemInfo } = props |
| | | const translate = useTranslate(); |
| | | const DynamicFields = () => { |
| | | const notify = useNotify(); |
| | | const [columns, setColumns] = useState([]); |
| | | const { isLoading } = useListContext(); |
| | | const refresh = useRefresh(); |
| | | const { boxMaxWidth, boxMaxHeight } = useTableLayout(); |
| | | |
| | | const hiddenColumns = [ |
| | | 'prodTime', 'platOrderCode', 'id', 'createTime', 'memo', 'areaId', 'brand', |
| | | 'weight', 'splrId', 'projectCode', 'statusBool', 'extendFields.[priceUnitId]', 'isptResult$', |
| | | 'extendFields.[inStockType]', 'matnrId', 'trackCode', 'workQty', 'batch', 'shipperId', |
| | | 'isptResult', 'createBy$', 'extendFields.[baseUnitId]' |
| | | ]; |
| | | |
| | | useEffect(() => { |
| | | getDynamicFields(); |
| | | }, []); |
| | | |
| | | const getDynamicFields = async () => { |
| | | const { data: { code, data, msg }, } = await request.get("/fields/enable/list"); |
| | | if (code == 200) { |
| | | if (code === 200) { |
| | | const arr = [ |
| | | <NumberField key="id" source="id" />, |
| | | // <NumberField key="areaId" source="areaId" label="table.field.warehouseAreasItem.areaId" />, |
| | |
| | | ] |
| | | setColumns([...arr, ...fields, ...lastArr]); |
| | | //filters添加过滤字段 |
| | | data.map(el => { |
| | | data.forEach(el => { |
| | | var i = 0; |
| | | filters.map((item) => { |
| | | filters.forEach((item) => { |
| | | if (item.key === el.fields) { |
| | | i = 1; |
| | | } |
| | | }) |
| | | i === 0 && filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />) |
| | | }) |
| | | }); |
| | | if (i === 0) { |
| | | filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />); |
| | | } |
| | | }); |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Box sx={{ position: 'relative', minHeight: "82vh", }}> |
| | | <Box sx={{ |
| | | position: 'relative', |
| | | maxHeight: boxMaxHeight, |
| | | maxWidth: boxMaxWidth, |
| | | overflowX: 'auto', |
| | | overflowY: 'auto', |
| | | '& .MuiTableCell-root': { |
| | | whiteSpace: 'nowrap', |
| | | } |
| | | }}> |
| | | {isLoading && ( |
| | | <LinearProgress |
| | | sx={{ |
| | |
| | | /> |
| | | )} |
| | | {columns.length > 0 && |
| | | <StyledDatagrid |
| | | preferenceKey='warehouseAreasItem' |
| | | <StickyDataTable |
| | | storeKey='warehouseAreasItem' |
| | | bulkActionButtons={false} |
| | | rowClick={(id, resource, record) => false} |
| | | omit={['prodTime','platOrderCode','id', 'createTime', 'memo', 'areaId', 'brand', |
| | | 'weight', 'splrId', 'projectCode','statusBool', 'extendFields.[priceUnitId]', 'isptResult$', 'extendFields.[inStockType]', |
| | | 'matnrId', 'trackCode', 'workQty', 'batch', 'shipperId', 'isptResult', 'createBy$', 'createTime', 'extendFields.[baseUnitId]']} |
| | | rowClick={false} |
| | | hiddenColumns={hiddenColumns} |
| | | > |
| | | {columns.map((column) => column)} |
| | | </StyledDatagrid>} |
| | | {columns} |
| | | </StickyDataTable>} |
| | | </Box> |
| | | ) |
| | | } |