|  |  |  | 
|---|
|  |  |  | import * as Common from '@/utils/common'; | 
|---|
|  |  |  | import ImportButton from "../../components/ImportButton"; | 
|---|
|  |  |  | import MatListAside from './MatnrListAside'; | 
|---|
|  |  |  | import { display, height } from "@mui/system"; | 
|---|
|  |  |  | import { display, height, width } from "@mui/system"; | 
|---|
|  |  |  | import DashboardIcon from '@mui/icons-material/Dashboard'; | 
|---|
|  |  |  | import EditIcon from '@mui/icons-material/Edit'; | 
|---|
|  |  |  | import PrintIcon from '@mui/icons-material/Print'; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | import BatchModal from './BatchModal'; | 
|---|
|  |  |  | import PrintModal from './PrintModal'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | 
|---|
|  |  |  | width: '200px' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .RaList-main': { | 
|---|
|  |  |  | minHeight: '80vh' | 
|---|
|  |  |  | minHeight: '90vh' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .column-name': { | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | textOverflow: 'ellipsis', | 
|---|
|  |  |  | display: 'block', | 
|---|
|  |  |  | width: '100px', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | '& .RaDatagrid-table': { | 
|---|
|  |  |  | width: '100%' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | })); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MatnrListContent = (props) => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const { isLoading } = useListContext(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [columns, setColumns] = useState([]); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  | const { refetch } = useListContext(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useEffect(() => { | 
|---|
|  |  |  | getDynamicFields(); | 
|---|
|  |  |  | }, []); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const getDynamicFields = async () => { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | data: { code, data, msg }, | 
|---|
|  |  |  | } = await request.get("/fields/enable/list"); | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | const arr = [ | 
|---|
|  |  |  | <NumberField key="id" source="id" />, | 
|---|
|  |  |  | <TooltipField key="name" source="name" label="table.field.matnr.name" cellClassName="name" />, | 
|---|
|  |  |  | <TextField key="code" source="code" label="table.field.matnr.code" />, | 
|---|
|  |  |  | <TextField key="shipperId$" source="shipperId$" label="table.field.matnr.shipperId" />, | 
|---|
|  |  |  | <ReferenceField key="groupId" source="groupId" label="table.field.matnr.groupId" reference="matnrGroup" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="name" /> | 
|---|
|  |  |  | </ReferenceField>, | 
|---|
|  |  |  | <TextField key="platCode" source="platCode" label="table.field.matnr.platCode" />, | 
|---|
|  |  |  | <TextField key="spec" source="spec" label="table.field.matnr.spec" />, | 
|---|
|  |  |  | <TextField key="model" source="model" label="table.field.matnr.model" />, | 
|---|
|  |  |  | <NumberField key="weight" source="weight" label="table.field.matnr.weight" />, | 
|---|
|  |  |  | <TextField key="describle" source="describle" label="table.field.matnr.describle" />, | 
|---|
|  |  |  | <NumberField key="nromNum" source="nromNum" label="table.field.matnr.nromNum" />, | 
|---|
|  |  |  | <TextField key="unit" source="unit" label="table.field.matnr.unit" />, | 
|---|
|  |  |  | <TextField key="purchaseUnit" source="purchaseUnit" label="table.field.matnr.purUnit" />, | 
|---|
|  |  |  | <TextField key="stockUnit" source="stockUnit" label="table.field.matnr.stockUnit" />, | 
|---|
|  |  |  | <TextField key="stockLeval$" source="stockLeval$" label="table.field.matnr.stockLevel" sortable={false} />, | 
|---|
|  |  |  | <TextField key="flagLabelMange$" source="flagLabelMange$" label="table.field.matnr.isLabelMange" sortable={false} />, | 
|---|
|  |  |  | <NumberField key="safeQty" source="safeQty" label="table.field.matnr.safeQty" />, | 
|---|
|  |  |  | <NumberField key="minQty" source="minQty" label="table.field.matnr.minQty" />, | 
|---|
|  |  |  | <NumberField key="maxQty" source="maxQty" label="table.field.matnr.maxQty" />, | 
|---|
|  |  |  | <NumberField key="stagn" source="stagn" label="table.field.matnr.stagn" />, | 
|---|
|  |  |  | <NumberField key="valid" source="valid" label="table.field.matnr.valid" />, | 
|---|
|  |  |  | <NumberField key="validWarn" source="validWarn" label="table.field.matnr.validWarn" />, | 
|---|
|  |  |  | <NumberField key="flagCheck" source="flagCheck" label="table.field.matnr.flagCheck" />, | 
|---|
|  |  |  | <ReferenceField key="updateBy" source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField>, | 
|---|
|  |  |  | <DateField key="updateTime" source="updateTime" label="common.field.updateTime" showTime />, | 
|---|
|  |  |  | <ReferenceField key="createBy" source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField>, | 
|---|
|  |  |  | <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} />, | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | const fields = data.map(el => <TextField key={el.fields} source={`extendFields.[${el.fields}]`} label={el.fieldsAlise} />) | 
|---|
|  |  |  | const opt = <WrapperField key="opt" cellClassName="opt" label="common.field.opt"> | 
|---|
|  |  |  | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|---|
|  |  |  | <EnableButton /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | setColumns([...arr, ...fields, opt]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (error) { | 
|---|
|  |  |  | notify('请求出错'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box sx={{ position: 'relative', minHeight: "40vh", }}> | 
|---|
|  |  |  | <Box sx={{ position: 'relative', minHeight: "60vh", }}> | 
|---|
|  |  |  | {isLoading && ( | 
|---|
|  |  |  | <LinearProgress | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey='matnr' | 
|---|
|  |  |  | bulkActionButtons={<> <BatchButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | expand={() => <MatnrPanel />} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'shipperId', 'platCode', 'spec', 'model', 'weight', 'color', 'size', 'describle' | 
|---|
|  |  |  | , 'nromNum', 'unit', 'purchaseUnit', 'stockUnit', 'stockLeval', 'isLabelMange', 'safeQty' | 
|---|
|  |  |  | , 'minQty', 'maxQty', 'stagn', 'valid', 'validWarn', 'flagCheck', 'updateTime', 'updateBy' | 
|---|
|  |  |  | , 'createTime', 'createBy', 'memo', 'rglarId', 'groupId', 'stockLevel', 'isLabelMange']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <TooltipField source="name" label="table.field.matnr.name" cellClassName="name" /> | 
|---|
|  |  |  | <TextField source="code" label="table.field.matnr.code" /> | 
|---|
|  |  |  | <ReferenceField source="shipperId" label="table.field.matnr.shipperId" reference="shipper" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="name" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <ReferenceField source="groupId" label="table.field.matnr.groupId" reference="matnrGroup" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="name" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <ReferenceField source="rglarId" label="table.field.matnr.rglarId" reference="batchRegular" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="code" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <TextField source="platCode" label="table.field.matnr.platCode" /> | 
|---|
|  |  |  | <TextField source="spec" label="table.field.matnr.spec" /> | 
|---|
|  |  |  | <TextField source="model" label="table.field.matnr.model" /> | 
|---|
|  |  |  | <NumberField source="weight" label="table.field.matnr.weight" /> | 
|---|
|  |  |  | <TextField source="color" label="table.field.matnr.color" /> | 
|---|
|  |  |  | <TextField source="size" label="table.field.matnr.size" /> | 
|---|
|  |  |  | <TextField source="describle" label="table.field.matnr.describle" /> | 
|---|
|  |  |  | <NumberField source="nromNum" label="table.field.matnr.nromNum" /> | 
|---|
|  |  |  | <TextField source="unit" label="table.field.matnr.unit" /> | 
|---|
|  |  |  | <TextField source="purchaseUnit" label="table.field.matnr.purUnit" /> | 
|---|
|  |  |  | <TextField source="stockUnit" label="table.field.matnr.stockUnit" /> | 
|---|
|  |  |  | <TextField source="stockLeval$" label="table.field.matnr.stockLevel" sortable={false} /> | 
|---|
|  |  |  | <TextField source="isLabelMange$" label="table.field.matnr.isLabelMange" sortable={false} /> | 
|---|
|  |  |  | <NumberField source="safeQty" label="table.field.matnr.safeQty" /> | 
|---|
|  |  |  | <NumberField source="minQty" label="table.field.matnr.minQty" /> | 
|---|
|  |  |  | <NumberField source="maxQty" label="table.field.matnr.maxQty" /> | 
|---|
|  |  |  | <NumberField source="stagn" label="table.field.matnr.stagn" /> | 
|---|
|  |  |  | <NumberField source="valid" label="table.field.matnr.valid" /> | 
|---|
|  |  |  | <NumberField source="validWarn" label="table.field.matnr.validWarn" /> | 
|---|
|  |  |  | <NumberField source="flagCheck" label="table.field.matnr.flagCheck" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|---|
|  |  |  | <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} /> | 
|---|
|  |  |  | <WrapperField cellClassName="opt" label="common.field.opt"> | 
|---|
|  |  |  | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|---|
|  |  |  | {/* <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> */} | 
|---|
|  |  |  | <EnableButton /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | {columns.length > 0 && | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey='matnr' | 
|---|
|  |  |  | bulkActionButtons={<> | 
|---|
|  |  |  | <BatchButton /> | 
|---|
|  |  |  | <PrintButton /> | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | omit={['id', 'shipperId', 'platCode', 'spec', 'model', 'weight', 'color', 'describle' | 
|---|
|  |  |  | , 'nromNum', 'unit', 'purchaseUnit', 'stockUnit', 'stockLeval', 'isLabelMange', 'safeQty' | 
|---|
|  |  |  | , 'minQty', 'maxQty', 'stagn', 'valid', 'validWarn', 'flagCheck', 'updateTime', 'updateBy' | 
|---|
|  |  |  | , 'createTime', 'createBy', 'memo', 'rglarId', 'groupId', 'stockLevel']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {columns.map((column) => column)} | 
|---|
|  |  |  | </StyledDatagrid>} | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MatnrList = () => { | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const PrintButton = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | const refresh = useRefresh(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Button color="secondary" onClick={() => setCreateDialog(true)} label={"toolbar.print"}> | 
|---|
|  |  |  | <PrintIcon /> | 
|---|
|  |  |  | </Button> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <PrintModal | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|