| | |
| | | import { useNavigate, useLocation } from 'react-router-dom'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | DataTable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | ColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | |
| | | Button, |
| | | useRefresh, |
| | | Pagination, |
| | | useSidebarState, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack, Dialog, DialogActions, DialogTitle, LinearProgress } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import PageDrawer from "../../components/PageDrawer"; |
| | | import StickyDataTable from "../../components/StickyDataTable"; |
| | | import useTableLayout from '@/utils/useTableLayout'; |
| | | |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import { fetchInOrderItemColumns } from '../config/orderItemColumns'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | | height: '.9em', |
| | | |
| | | }, |
| | | '& .RaDatagrid-row': { |
| | | cursor: 'auto' |
| | | }, |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | }, |
| | | })); |
| | | import { fetchInOrderItemFullColumns } from '../config/orderItemColumns'; |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | |
| | | <> |
| | | <Box display="flex"> |
| | | <List |
| | | resource="asnOrderItem/in" |
| | | resource="asnOrderItemFull/in" |
| | | sx={{ |
| | | flexGrow: 1, |
| | | transition: (theme) => |
| | |
| | | title={"menu.asnOrderItem"} |
| | | empty={false} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | // sort={{ field: "mo.create_time", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <SelectColumnsButton preferenceKey='asnOrderItem' /> |
| | | <ColumnsButton storeKey='asnOrderItem' /> |
| | | <ExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | pagination={<Pagination rowsPerPageOptions={[5, 10, 20, 25, 50, 100]} />} |
| | | > |
| | | <DynamicFields /> |
| | | <DynamicFields drawerVal={drawerVal} /> |
| | | </List> |
| | | <PageDrawer |
| | | title='AsnOrderItem Detail' |
| | |
| | | |
| | | export default AsnOrderItemList; |
| | | |
| | | const DynamicFields = (props) => { |
| | | const DynamicFields = ({ drawerVal }) => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const [columns, setColumns] = useState([]); |
| | | const { isLoading } = useListContext(); |
| | | const refresh = useRefresh(); |
| | | const omittedFields = [ |
| | | 'id' |
| | | ]; |
| | | |
| | | useEffect(() => { |
| | | getDynamicFields(); |
| | | }, []); |
| | | |
| | | const getDynamicFields = async () => { |
| | | const result = await fetchInOrderItemColumns(); |
| | | const result = await fetchInOrderItemFullColumns(); |
| | | if (result.success) { |
| | | const hiddenSources = [ |
| | | 'splrName', |
| | | 'businessTime', 'extendFields.[businessTime]', |
| | | 'wkType', 'extendFields.[wkType]', |
| | | 'type', 'extendFields.[type]' |
| | | 'type', 'extendFields.[type]', |
| | | ]; |
| | | const columns = result.columns.filter(col => !hiddenSources.includes(col.props.source)); |
| | | setColumns(columns); |
| | |
| | | } |
| | | } |
| | | |
| | | const { boxMaxWidth, boxMaxHeight } = useTableLayout(drawerVal); |
| | | |
| | | |
| | | |
| | | return ( |
| | | <Box sx={{ position: 'relative', minHeight: "60vh", }}> |
| | | <Box sx={{ |
| | | position: 'relative', |
| | | maxHeight: boxMaxHeight, |
| | | maxWidth: boxMaxWidth, |
| | | overflowX: 'auto', |
| | | overflowY: 'auto', |
| | | '& .MuiTableCell-root': { |
| | | whiteSpace: 'nowrap', |
| | | } |
| | | }}> |
| | | {isLoading && ( |
| | | <LinearProgress |
| | | sx={{ |
| | |
| | | /> |
| | | )} |
| | | {columns.length > 0 && |
| | | <StyledDatagrid |
| | | preferenceKey='asnOrderItem' |
| | | <StickyDataTable |
| | | footerConfig={[ |
| | | { field: 'anfme', type: 'sum', label: 'table.field.asnOrderItem.anfme' }, |
| | | { field: 'qty', type: 'max', label: 'table.field.asnOrderItem.qty' }, |
| | | ]} |
| | | // stickyRight={['createTime']} |
| | | storeKey='asnOrderItem' |
| | | bulkActionButtons={false} |
| | | rowClick={(id, resource, record) => false} |
| | | omit={['id', 'orderId', 'orderCode', 'poCode', 'poId', 'wkType', 'type', 'checkType', 'spec', 'model', 'purQty', 'purUnit', 'qrcode', 'trackCode', 'splrCode', 'splrName', 'projectCode', 'supplierId', 'supplierName', 'priceUnitId', 'shipperId', 'businessTime', 'extendFields.[businessTime]', 'extendFields.[wkType]', 'extendFields.[type]']} |
| | | // omit={['id', 'orderId', 'poDetlId', 'matnrId', 'spec', 'model', 'purQty', 'purUnit', 'qrcode', 'trackCode', 'splrCode', 'platWorkCode', 'projectCode', 'createBy', 'createTime']} |
| | | rowClick={false} |
| | | hiddenColumns={omittedFields} |
| | | > |
| | | {columns.map((column) => column)} |
| | | </StyledDatagrid>} |
| | | {columns} |
| | | </StickyDataTable>} |
| | | </Box> |
| | | ) |
| | | } |