skyouc
13 小时以前 1504150a9e26ef221fc6ac4e0ad494446968d06d
rsf-admin/src/page/orders/transfer/CreateBySelectMats.jsx
@@ -23,8 +23,8 @@
    DeleteButton,
} from 'react-admin';
import { Stack, Grid, Box, Typography, Dialog, DialogTitle, DialogContent, TextField, Button, DialogActions } from '@mui/material';
import { EDIT_MODE, DEFAULT_START_PAGE, DEFAULT_PAGE_SIZE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting';
import DialogCloseButton from "../../components/DialogCloseButton.jsx";
import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting';
import StatusSelectInput from "../../components/StatusSelectInput";
import CustomerTopToolBar from "../../components/EditTopToolBar";
import TreeSelectInput from "@/page/components/TreeSelectInput";
@@ -37,28 +37,24 @@
const CreateBySelectMats = (props) => {
    const { open, setOpen, data, setData } = props;
    const [page, setPage] = useState(0);
    const { open, setOpen, data, setData, queryForm } = props;
    const [page, setPage] = useState({ page: DEFAULT_START_PAGE, pageSize: DEFAULT_PAGE_SIZE });
    const [rowCount, setRowCount] = useState(0);
    const [isLoading, setIsLoading] = useState(false);
    const [formData, setFormData] = useState({});
    const [tableData, setTableData] = useState([]);
    const [dyFields, setDyFields] = useState([]);
    const [pageSize, setPageSize] = useState(25);
    const [selectedRows, setSelectedRows] = useState([]);
    const translate = useTranslate();
    const notify = useNotify();
    const refresh = useRefresh();
    const handleClose = (event, reason) => {
        if (reason !== "backdropClick") {
            setOpen(false);
        }
    };
    const handleChange = (e) => {
        const { name, value } = e.target;
@@ -69,9 +65,8 @@
    const reset = () => {
        setFormData({
            name: '',
            code: '',
            groupId: 0
            maktx: '',
            matnrCode: '',
        })
    }
@@ -84,33 +79,42 @@
                return acc;
            }, {});
            return {
                matnrId: el.id,
                maktx: el.name,
                matnrCode: el.code,
                stockUnit: el.stockUnit || '',
                purUnit: el.purchaseUnit || '',
                id: el.id,
                matnrId: el.matnrId,
                maktx: el.maktx,
                matnrCode: el.matnrCode,
                anfme: el.anfme,
                batch: el.batch,
                spec: el.spec,
                model: el.model,
                fieldsIndex: el.fieldsIndex,
                stockUnit: el.unit || '',
                ...dynamicFields
            }
        }))
        }));
        setData([...data, ...value]);
        setOpen(false);
        reset();
    };
    const getData = async () => {
        const res = await request.post(`/matnr/page`, {
        let params = {
            ...formData,
            current: page,
            pageSize: pageSize,
            orgAreaId: queryForm?.orgAreaId,
            current: page?.page,
            pageSize: page?.pageSize,
            orderBy: "create_time desc"
        });
        };
        setIsLoading(true)
        const res = await request.post(`/transfer/locs/items`, params);
        if (res?.data?.code === 200) {
            const {data} = res.data;
            const { data } = res.data;
            setTableData(data?.records);
            setRowCount(data?.total);
        } else {
            notify(res.data.msg);
        }
        setIsLoading(false)
    };
    useEffect(() => {
@@ -128,7 +132,7 @@
            aria-labelledby="form-dialog-title"
            fullWidth
            disableRestoreFocus
            maxWidth="lg"
            maxWidth="xl"
        >
            <DialogTitle id="form-dialog-title" sx={{
                position: 'sticky',
@@ -147,8 +151,8 @@
                        <Grid item md={3}>
                            <TextField
                                label={translate('table.field.matnr.name')}
                                name="name"
                                value={formData.name}
                                name="maktx"
                                value={formData.maktx}
                                onChange={handleChange}
                                size="small"
                            />
@@ -156,20 +160,10 @@
                        <Grid item md={3}>
                            <TextField
                                label={translate('table.field.matnr.code')}
                                name="code"
                                value={formData.code}
                                name="matnrCode"
                                value={formData.matnrCode}
                                onChange={handleChange}
                                size="small"
                            />
                        </Grid>
                        <Grid item md={3}>
                            <TreeSelectInput
                                label="table.field.matnr.groupId"
                                value={formData.groupId}
                                resource={'matnrGroup'}
                                source="groupId"
                                name="groupId"
                                onChange={handleChange}
                            />
                        </Grid>
                        <Grid item md={2} sx={{ margin: 'auto' }}>
@@ -178,7 +172,7 @@
                    </Grid>
                </Box>
                <Box sx={{ mt: 2, height: 400, width: '100%' }}>
                <Box sx={{ mt: 2, height: 600, width: '100%' }}>
                    <SelectMatsTableView
                        tableData={tableData}
                        setTableData={setTableData}
@@ -186,6 +180,7 @@
                        rowCount={rowCount}
                        pageSize={pageSize}
                        setPage={setPage}
                        isLoading={isLoading}
                        setPageSize={setPageSize}
                        dyFields={dyFields}
                        setDyFields={setDyFields}
@@ -208,34 +203,26 @@
export default CreateBySelectMats;
const SelectMatsTableView = ({ tableData, page, pageSize,setPage, setPageSize, rowCount, setTableData, selectedRows, setSelectedRows, dyFields, setDyFields }) => {
const SelectMatsTableView = ({ tableData, page, isLoading, pageSize, setPage, setPageSize, rowCount, setTableData, selectedRows, setSelectedRows, dyFields, setDyFields }) => {
    const translate = useTranslate();
    const notify = useNotify();
    const [extendColumns, setExtendColumns] = useState([]);
    const [columns, setColumns] = useState([
        { field: 'name', headerName: translate('table.field.matnr.name'), width: 300 },
        { field: 'code', headerName: translate('table.field.matnr.code'), width: 200 },
        { field: 'groupId$', headerName: translate('table.field.matnr.groupId'), width: 100 },
        { field: 'maktx', headerName: translate('table.field.matnr.name'), width: 300 },
        { field: 'matnrCode', headerName: translate('table.field.matnr.code'), width: 200 },
        { field: 'locCode', headerName: translate('table.field.locItem.locCode'), width: 100 },
        { field: 'spec', headerName: translate('table.field.matnr.spec'), width: 100 },
        { field: 'batch', headerName: translate('table.field.locItem.batch'), width: 100 },
        { field: 'model', headerName: translate('table.field.matnr.model'), width: 100 },
        { field: 'weight', headerName: translate('table.field.matnr.weight'), width: 100 },
        { field: 'describle', headerName: translate('table.field.matnr.describle'), width: 100 },
        { field: 'nromNum', headerName: translate('table.field.matnr.nromNum'), width: 100 },
        { field: 'anfme', headerName: translate('table.field.locItem.anfme'), width: 100 },
        { field: 'unit', headerName: translate('table.field.matnr.unit'), width: 100 },
        { field: 'purchaseUnit', headerName: translate('table.field.matnr.purUnit'), width: 100 },
        { field: 'stockUnit', headerName: translate('table.field.matnr.stockUnit'), width: 100 },
        { field: 'stockLeval$', headerName: translate('table.field.matnr.stockLevel'), width: 100, sortable: false },
        { field: 'wareArea', headerName: translate('table.field.locItem.wareArea'), width: 100, sortable: false },
    ])
    const handleSelectionChange = (ids) => {
        setSelectedRows(ids)
    };
    useEffect(() => {
        console.log('------->');
        console.log(page);
    }, [page])
    useEffect(() => {
        if (extendColumns == undefined || extendColumns.length < 1) {
@@ -267,32 +254,27 @@
    }
    return (
        <div style={{ height: 400, width: '100%' }}>
        <div style={{ height: 590, width: '100%' }}>
            <DataGrid
                size="small"
                rows={tableData}
                page={page}
                pageSize={pageSize}
                columns={columns}
                pagination
                checkboxSelection
                rowCount={rowCount}
                onRowSelectionModelChange={handleSelectionChange}
                onPageChange={(newPage) => setPage(newPage)}
                onPageSizeChange={(newPageSize) => setPageSize(newPageSize)}
                selectionModel={selectedRows}
                columns={columns}
                paginationMode="server"
                paginationModel={page}
                checkboxSelection
                onPaginationModelChange={setPage}
                onRowSelectionModelChange={handleSelectionChange}
                selectionModel={selectedRows}
                disableColumnMenu={true}
                initialState={{
                    pagination: {
                        paginationModel: {
                            pageSize: 25,
                        },
                    },
                }}
                pageSizeOptions={[15, 25, 50, 100]}
                disableColumnSorting
                disableMultipleColumnsSorting
                loading={isLoading}
                slotProps={{
                    loadingOverlay: {
                        variant: 'linear-progress',
                        noRowsVariant: 'linear-progress',
                    },
                }}
            />
        </div>
    );