| | |
| | | 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': { |
| | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const { isLoading } = useListContext(); |
| | | const [dynamicFields, setDynamicFields] = useState([]); |
| | | |
| | | const [columns, setColumns] = useState([]); |
| | | const refresh = useRefresh(); |
| | | const { refetch } = useListContext(); |
| | | |
| | |
| | | data: { code, data, msg }, |
| | | } = await request.get("/fields/enable/list"); |
| | | if (code === 200) { |
| | | setDynamicFields(data); |
| | | refresh(); |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } catch (error) { |
| | | notify('请求出错'); |
| | | } |
| | | }; |
| | | |
| | | const columns = [ |
| | | 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" />, |
| | |
| | | <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} />, |
| | | <WrapperField key="opt" cellClassName="opt" label="common.field.opt"> |
| | | ] |
| | | const fields = data.map(el => <TextField key={el.fields} source={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: "60vh", }}> |
| | |
| | | /> |
| | | )} |
| | | |
| | | {columns.length > 0 && |
| | | <StyledDatagrid |
| | | preferenceKey='matnr' |
| | | bulkActionButtons={<> <BatchButton /><BulkDeleteButton mutationMode={OPERATE_MODE} /></>} |
| | | 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' |
| | |
| | | , 'createTime', 'createBy', 'memo', 'rglarId', 'groupId', 'stockLevel', 'isLabelMange']} |
| | | > |
| | | {columns.map((column) => column)} |
| | | </StyledDatagrid> |
| | | </StyledDatagrid>} |
| | | </Box> |
| | | ); |
| | | } |
| | |
| | | |
| | | ) |
| | | } |
| | | |
| | | 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} |
| | | /> |
| | | </> |
| | | |
| | | ) |
| | | } |