copy from rsf-admin/src/page/locPreview/LocQueryList.jsx
copy to rsf-admin/src/page/locItem/LocItemList.jsx
| File was copied from rsf-admin/src/page/locPreview/LocQueryList.jsx |
| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | |
| | | DateInput, |
| | | SelectInput, |
| | | NumberInput, |
| | | useRefresh, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | useRefresh, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | useGetRecordId, |
| | | } from 'react-admin'; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import { Box, Typography, Card, Stack, LinearProgress } from '@mui/material'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { Box, Typography, Card, Stack , LinearProgress} from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import LocItemCreate from "./LocItemCreate"; |
| | | import EmptyData from "../components/EmptyData"; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | import request from '@/utils/request'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 100 |
| | | width: 200 |
| | | }, |
| | | '& .MuiTableCell-root': { |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'visible', |
| | | textOverflow: 'unset' |
| | | } |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <DateInput label='common.time.after' source="timeStart" />, |
| | | <DateInput label='common.time.before' source="timeEnd" />, |
| | | <NumberInput source="locId" label="table.field.locItem.locId" />, |
| | | <TextInput source="locCode" label="table.field.locItem.locCode" />, |
| | | <NumberInput source="orderId" label="table.field.locItem.orderId" />, |
| | | <TextInput source="type" label="table.field.locItem.type" />, |
| | | <NumberInput source="orderItemId" label="table.field.locItem.orderItemId" />, |
| | | <NumberInput source="wkType" label="table.field.locItem.wkType" />, |
| | | <NumberInput source="matnrId" label="table.field.locItem.matnrId" />, |
| | | <TextInput source="maktx" label="table.field.locItem.maktx" />, |
| | | <TextInput source="matnrCode" label="table.field.locItem.matnrCode" />, |
| | | <TextInput source="trackCode" label="table.field.locItem.trackCode" />, |
| | | <TextInput source="unit" label="table.field.locItem.unit" />, |
| | | <NumberInput source="anfme" label="table.field.locItem.anfme" />, |
| | | <NumberInput source="qty" label="table.field.locItem.qty" />, |
| | | <NumberInput source="workQty" label="table.field.locItem.workQty" />, |
| | | <TextInput source="batch" label="table.field.locItem.batch" />, |
| | | <TextInput source="splrBatch" label="table.field.locItem.splrBatch" />, |
| | | <TextInput source="spec" label="table.field.locItem.spec" />, |
| | | <TextInput source="model" label="table.field.locItem.model" />, |
| | | <TextInput source="fieldsIndex" label="table.field.locItem.fieldsIndex" />, |
| | |
| | | ] |
| | | |
| | | const LocItemList = () => { |
| | | const translate = useTranslate(); |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | const translate = useTranslate(); |
| | | const locId = useGetRecordId(); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | |
| | | }), |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.locPreview"} |
| | | empty={false} |
| | | filter={{ locId: locId }} |
| | | title={"menu.locItem"} |
| | | empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <SelectColumnsButton preferenceKey='locPreview' /> |
| | | <SelectColumnsButton preferenceKey='locItem' /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <DynamicFields /> |
| | | </List> |
| | | <LocItemCreate |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> |
| | | <PageDrawer |
| | | title='LocItem Detail' |
| | | drawerVal={drawerVal} |
| | |
| | | |
| | | |
| | | const DynamicFields = (props) => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const [columns, setColumns] = useState([]); |
| | | const { isLoading } = useListContext(); |
| | | const translate = useTranslate(); |
| | | const refresh = useRefresh(); |
| | | const notify = useNotify(); |
| | | |
| | | useEffect(() => { |
| | | getDynamicFields(); |
| | | }, []); |
| | |
| | | const arr = [ |
| | | <NumberField source="id" />, |
| | | <NumberField source="locId" label="table.field.locItem.locId" />, |
| | | <TextField source="wareArea" label="table.field.locItem.wareArea" />, |
| | | <TextField source="locCode" label="table.field.locItem.locCode" />, |
| | | <NumberField source="orderId" label="table.field.locItem.orderId" />, |
| | | <TextField source="type$" label="table.field.locItem.type" />, |
| | | <NumberField source="orderItemId" label="table.field.locItem.orderItemId" />, |
| | | <NumberField source="wkType$" label="table.field.locItem.wkType" />, |
| | | <NumberField source="matnrId" label="table.field.locItem.matnrId" />, |
| | | <TextField source="matnrCode" label="table.field.locItem.matnrCode" />, |
| | | <TextField source="maktx" label="table.field.locItem.maktx" />, |
| | | <TextField source="spec" label="table.field.locItem.spec" />, |
| | | <TextField source="model" label="table.field.locItem.model" />, |
| | | <TextField source="batch" label="table.field.locItem.batch" />, |
| | | <TextField source="trackCode" label="table.field.locItem.trackCode" />, |
| | | <TextField source="matnrCode" label="table.field.locItem.matnrCode" />, |
| | | <TextField source="unit" label="table.field.locItem.unit" />, |
| | | <NumberField source="anfme" label="table.field.locItem.anfme" />, |
| | | <NumberField source="workQty" label="table.field.locItem.workQty" />, |
| | | <NumberField source="qty" label="table.field.locItem.qty" />, |
| | | <TextField source="splrBatch" label="table.field.locItem.splrBatch" />, |
| | | <TextField source="fieldsIndex" label="table.field.locItem.fieldsIndex" />, |
| | | <TextField source="batch" label="table.field.locItem.batch" />, |
| | | <NumberField source="splrId" label="table.field.locItem.splrId" />, |
| | | <TextField source="spec" label="table.field.locItem.spec" />, |
| | | <TextField source="model" label="table.field.locItem.model" /> |
| | | ] |
| | | const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />) |
| | | const lastArr = [ |
| | | <TextField source="updateBy$" label="common.field.updateBy" />, |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime />, |
| | | <TextField source="createBy$" label="common.field.createBy" />, |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField>, |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField>, |
| | | <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} />, |
| | | ] |
| | | setColumns([...arr, ...fields, ...lastArr]); |
| | | |
| | | 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} alwaysOn/>) |
| | | }) |
| | | |
| | | } else { |
| | | notify(msg); |
| | | } |
| | |
| | | )} |
| | | {columns.length > 0 && |
| | | <StyledDatagrid |
| | | preferenceKey='locPreview' |
| | | preferenceKey='locItem' |
| | | bulkActionButtons={false} |
| | | rowClick={false} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={false} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'spec', 'model', 'locId', 'orderId', 'trackCode', 'orderItemId', 'matnrId', 'splrBatch', 'createBy$', 'memo', 'fieldsIndex', 'statusBool']} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'splrId', 'locId', 'matnrId']} |
| | | > |
| | | {columns.map((column) => column)} |
| | | </StyledDatagrid>} |