From 3f54021c96ed84ce42181b3709788610e2ab57ca Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期一, 04 八月 2025 17:14:18 +0800
Subject: [PATCH] 库存调整功能优化
---
rsf-admin/src/page/stockManage/locRevise/LocReviseList.jsx | 6
rsf-admin/src/page/stockManage/locRevise/LocReviseCreate.jsx | 176 +++++++++--------
rsf-admin/src/page/stockManage/locRevise/LocReviseEdit.jsx | 63 ++----
rsf-admin/src/page/orders/outStock/SelectMatnrModal.jsx | 16
rsf-admin/src/page/stockManage/locRevise/SelectLocsRevise.jsx | 327 ++++++++++++++++++++++++++++++++
5 files changed, 454 insertions(+), 134 deletions(-)
diff --git a/rsf-admin/src/page/orders/outStock/SelectMatnrModal.jsx b/rsf-admin/src/page/orders/outStock/SelectMatnrModal.jsx
index bc1906e..9e5071d 100644
--- a/rsf-admin/src/page/orders/outStock/SelectMatnrModal.jsx
+++ b/rsf-admin/src/page/orders/outStock/SelectMatnrModal.jsx
@@ -43,18 +43,18 @@
Select,
MenuItem
} from '@mui/material';
+import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form";
import DialogCloseButton from "../../components/DialogCloseButton";
import StatusSelectInput from "../../components/StatusSelectInput";
-import ConfirmButton from "../../components/ConfirmButton";
-import MatnrInfoModal from "./MatnrInfoModal";
-import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form";
-import SaveIcon from '@mui/icons-material/Save';
-import request from '@/utils/request';
-import { Add, Edit, Delete } from '@mui/icons-material';
-import _, { set } from 'lodash';
-import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
import DictionarySelect from "../../components/DictionarySelect";
+import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
+import ConfirmButton from "../../components/ConfirmButton";
+import { Add, Edit, Delete } from '@mui/icons-material';
import DictSelect from "../../components/DictSelect";
+import SaveIcon from '@mui/icons-material/Save';
+import MatnrInfoModal from "./MatnrInfoModal";
+import request from '@/utils/request';
+import _, { set } from 'lodash';
import "./asnOrder.css";
const SelectMatnrModal = (props) => {
diff --git a/rsf-admin/src/page/stockManage/locRevise/LocReviseCreate.jsx b/rsf-admin/src/page/stockManage/locRevise/LocReviseCreate.jsx
index 36f977a..d8b8919 100644
--- a/rsf-admin/src/page/stockManage/locRevise/LocReviseCreate.jsx
+++ b/rsf-admin/src/page/stockManage/locRevise/LocReviseCreate.jsx
@@ -5,21 +5,33 @@
DateInput,
ReferenceInput,
AutocompleteInput,
+ SelectColumnsButton,
+ DatagridConfigurable,
Toolbar,
required,
useNotify,
DeleteButton,
+ BooleanField,
+ EditButton,
+ WrapperField,
SaveButton,
SimpleForm,
+ NumberField,
useRefresh,
+ TextField,
+ DateField,
CreateBase,
+ TopToolbar,
+ FilterButton,
+ SearchInput,
+ List,
+ Create,
} from 'react-admin';
import {
Dialog,
DialogActions,
DialogContent,
DialogTitle,
- TextField,
IconButton,
MenuItem,
Tooltip,
@@ -27,8 +39,11 @@
Button,
Stack,
Grid,
+ Card,
Box,
+ CardContent,
} from '@mui/material';
+import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import ConfirmationNumberIcon from '@mui/icons-material/ConfirmationNumber';
import DialogCloseButton from "../../components/DialogCloseButton.jsx";
import WarehouseSelect from "../../components/WarehouseSelect.jsx";
@@ -36,21 +51,13 @@
import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
import ConfirmButton from "../../components/ConfirmButton";
import { Add, Edit, Delete } from '@mui/icons-material';
+import SelectLocsRevise from "./SelectLocsRevise.jsx";
import DictSelect from "../../components/DictSelect";
import SaveIcon from '@mui/icons-material/Save';
import { styled } from '@mui/material/styles';
+import { redirect } from "react-router";
import request from '@/utils/request';
import _, { set } from 'lodash';
-
-const StyledSimpleForm = styled(SimpleForm)(({ theme }) => ({
- '& .MuiToolbar-root-RaToolbar-root': {
- '& .RaToolbar-defaultToolbar': {
- justifyContent: 'flex-end',
- }
- }
-
-}));
-
const LocReviseCreate = (props) => {
const { open, setOpen, orderId } = props;
@@ -60,6 +67,7 @@
const translate = useTranslate();
const [tabelData, setTableData] = useState([]);
const [disabled, setDisabled] = useState(false);
+ const [isVisible, setIsVisible] = useState("block");
const [selectedRows, setSelectedRows] = useState([]);
const [createDialog, setCreateDialog] = useState(false);
const [formData, setFormData] = useState({ type: '0', orgAreaId: null, tarAreaId: null, exceTime: null, code: null });
@@ -74,38 +82,46 @@
setTableData([...tabelData]);
}
- const handleSubmit = async () => {
- setFinally()
- setDisabled(true)
+ const FormToolbar = () => {
+ return (
+ <Toolbar sx={{ justifyContent: 'flex-end' }}>
+ <SaveButton disabled={disabled} />
+ <DeleteButton mutationMode="optimistic" />
+ </Toolbar>
+ )
+ }
+ // const handleSubmit = async () => {
+ // setFinally()
+ // setDisabled(true)
- if (orderId == null || orderId == undefined) {
- const parmas = {
- "revise": formData,
- "items": tabelData,
- }
+ // if (orderId == null || orderId == undefined) {
+ // const parmas = {
+ // "revise": formData,
+ // "items": tabelData,
+ // }
- const res = await request.post(`/transfer/items/save`, parmas);
- if (res?.data?.code === 200) {
- setOpen(false);
- } else {
- notify(res.data.msg);
- }
- } else {
- const parmas = {
- "transfer": formData,
- "items": tabelData,
- }
- const res = await request.post(`/transfer/items/update`, parmas);
- if (res?.data?.code === 200) {
- setOpen(false);
- } else {
- notify(res.data.msg);
- }
- }
- setDisabled(false)
- refresh();
+ // const res = await request.post(`/transfer/items/save`, parmas);
+ // if (res?.data?.code === 200) {
+ // setOpen(false);
+ // } else {
+ // notify(res.data.msg);
+ // }
+ // } else {
+ // const parmas = {
+ // "transfer": formData,
+ // "items": tabelData,
+ // }
+ // const res = await request.post(`/transfer/items/update`, parmas);
+ // if (res?.data?.code === 200) {
+ // setOpen(false);
+ // } else {
+ // notify(res.data.msg);
+ // }
+ // }
+ // setDisabled(false)
+ // refresh();
- };
+ // };
const handleDeleteItem = () => {
const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId));
@@ -113,20 +129,15 @@
}
const newAddClick = () => {
- if (formData.areaId == null || formData.areaId == undefined) {
- notify("搴撳尯涓嶈兘涓虹┖锛侊紒", { type: 'error' })
- return
- }
setCreateDialog(true)
}
const mutationOptions = {
onSuccess: (data) => {
- notify(`鏂囩珷 "${data.title}" 鍒涘缓鎴愬姛`, { type: 'success' });
+ setIsVisible("block")
+ setDisabled(true)
+ refresh()
},
- onError: (error) => {
- notify(`鍒涘缓澶辫触: ${error.message}`, { type: 'error' });
- }
};
const handleChange = (value, name) => {
@@ -139,20 +150,15 @@
return (
<>
<Box sx={{ padding: 1 }}>
- <CreateBase resource="locRevise" mutationOptions={mutationOptions} >
- <SimpleForm >
+ <Create resource="locRevise"
+ title={false}
+ mutationOptions={mutationOptions} >
+ <SimpleForm toolbar={<FormToolbar />}>
<Grid container spacing={2} sx={{
'& .MuiToolbar-root-RaToolbar-root.RaToolbar-defaultToolbar': {
justifyContent: 'flex-end',
}
}}>
- <Grid item md={2}>
- <TextInput
- source="code"
- label={translate("table.field.locRevise.code")}
- readOnly
- />
- </Grid>
<Grid item md={2}>
<AutocompleteInput
choices={dicts}
@@ -160,6 +166,7 @@
optionValue="value"
defaultValue="1"
source="type"
+ parse={v => v}
label={translate("table.field.transfer.type")}
/>
</Grid>
@@ -168,6 +175,7 @@
<AutocompleteInput
optionText='name'
optionValue="id"
+ parse={v => v}
label={translate("table.field.locRevise.areaName")}
/>
</ReferenceInput>
@@ -175,36 +183,38 @@
<Grid item md={2}>
<DateInput
source="exceTime"
+ parse={v => v}
label="table.field.locRevise.exceTime"
/>
</Grid>
</Grid>
</SimpleForm>
- </CreateBase>
- <Box sx={{ mt: 2 }}>
- <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-end" }}>
- <Button variant="contained" onClick={newAddClick} >
- {translate('common.action.newAddMats')}
- </Button>
- <ConfirmButton label={"toolbar.delete"} variant="outlined" color="error" onConfirm={handleDeleteItem} />
- </Stack>
+ </Create>
+ <Box sx={{ display: isVisible }}>
+ <Card sx={{ height: 630 }}>
+ <Box>
+ <Box sx={{ mt: 2 }}>
+ <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-start" }}>
+ <Button variant="contained" onClick={newAddClick} >
+ {translate('common.action.newAddMats')}
+ </Button>
+ <ConfirmButton label={"toolbar.delete"} variant="outlined" color="error" onConfirm={handleDeleteItem} />
+ </Stack>
+ </Box>
+ <Box sx={{ mt: 2 }}>
+ <TransferTableView
+ tabelData={tabelData}
+ setTableData={setTableData}
+ orderId={orderId}
+ selectedRows={selectedRows}
+ setSelectedRows={setSelectedRows}
+ tableRef={tableRef}>
+ </TransferTableView>
+ </Box>
+ </Box>
+ </Card>
</Box>
- <Box sx={{ mt: 2 }}>
- <TransferTableView
- tabelData={tabelData}
- setTableData={setTableData}
- orderId={orderId}
- selectedRows={selectedRows}
- setSelectedRows={setSelectedRows}
- tableRef={tableRef}>
- </TransferTableView>
- </Box>
- <Toolbar sx={{ width: '100%', justifyContent: 'flex-start', bgcolor: 'white' }} >
- <Button disabled={disabled} onClick={handleSubmit} variant="contained" startIcon={<SaveIcon />}>
- {translate('toolbar.confirm')}
- </Button>
- </Toolbar>
- {/* <CreateBySelectMats
+ <SelectLocsRevise
data={tabelData}
queryForm={formData}
open={createDialog}
@@ -212,7 +222,7 @@
selectedRows={selectedRows}
setSelectedRows={setSelectedRows}
setData={setTableData}
- /> */}
+ />
</Box>
</>
)
@@ -480,7 +490,7 @@
rowSelectionModel={tableIds}
onRowSelectionModelChange={handleSelectionChange}
sx={{
- height: 580,
+ height: 500,
'& .MuiDataGrid-cell input': {
border: '1px solid #ccc'
},
diff --git a/rsf-admin/src/page/stockManage/locRevise/LocReviseEdit.jsx b/rsf-admin/src/page/stockManage/locRevise/LocReviseEdit.jsx
index ae94a21..80db4ee 100644
--- a/rsf-admin/src/page/stockManage/locRevise/LocReviseEdit.jsx
+++ b/rsf-admin/src/page/stockManage/locRevise/LocReviseEdit.jsx
@@ -29,16 +29,6 @@
import MemoInput from "@/page/components/MemoInput";
import StatusSelectInput from "@/page/components/StatusSelectInput";
-const FormToolbar = () => {
- const { getValues } = useFormContext();
-
- return (
- <Toolbar sx={{ justifyContent: 'space-between' }}>
- <SaveButton />
- <DeleteButton mutationMode="optimistic" />
- </Toolbar>
- )
-}
const LocReviseEdit = () => {
const translate = useTranslate();
@@ -53,13 +43,24 @@
<SimpleForm
shouldUnregister
warnWhenUnsavedChanges
- toolbar={<FormToolbar />}
+ toolbar={false}
mode="onTouched"
defaultValues={{}}
+ sx={{
+ "& .MuiFormLabel-root.MuiInputLabel-root.Mui-disabled": {
+ bgcolor: 'white',
+ WebkitTextFillColor: "rgba(0, 0, 0)"
+ },
+
+ "& .MuiInputBase-input.MuiFilledInput-input.Mui-disabled": {
+ bgcolor: 'white',
+ WebkitTextFillColor: "rgba(0, 0, 0)"
+ }
+ }}
// validate={(values) => { }}
>
<Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}>
- <Grid item xs={12} md={8}>
+ <Grid item xs={24} md={12}>
<Typography variant="h6" gutterBottom>
{translate('common.edit.title.main')}
</Typography>
@@ -68,64 +69,46 @@
label="table.field.locRevise.code"
source="code"
parse={v => v}
- autoFocus
+ readOnly
/>
- </Stack>
- <Stack direction='row' gap={2}>
<SelectInput
label="table.field.locRevise.type"
source="type"
choices={[
{ id: 0, name: ' 搴撳瓨璋冩暣' },
- { id: 2, name: ' 鐩樼偣璋冩暣' },
+ { id: 2, name: ' 鐩樼偣璋冩暣' },
]}
+ readOnly
/>
- </Stack>
- <Stack direction='row' gap={2}>
<NumberInput
label="table.field.locRevise.anfme"
source="anfme"
+ readOnly
/>
</Stack>
<Stack direction='row' gap={2}>
<NumberInput
label="table.field.locRevise.reviseQty"
source="reviseQty"
+ readOnly
/>
- </Stack>
- <Stack direction='row' gap={2}>
<SelectInput
label="table.field.locRevise.exceStatus"
source="exceStatus"
choices={[
{ id: 0, name: '鏈墽琛�' },
- { id: 1, name: '鎵ц涓�' },
- { id: 2, name: '鎵ц瀹屾垚' },
+ { id: 1, name: '鎵ц涓�' },
+ { id: 2, name: '鎵ц瀹屾垚' },
]}
+ readOnly
/>
- </Stack>
- <Stack direction='row' gap={2}>
- <NumberInput
- label="table.field.locRevise.orgAreaId"
- source="orgAreaId"
- />
- </Stack>
- <Stack direction='row' gap={2}>
<TextInput
- label="table.field.locRevise.orgAreaName"
+ label="table.field.locRevise.areaName"
source="orgAreaName"
parse={v => v}
+ readOnly
/>
</Stack>
-
- </Grid>
- <Grid item xs={12} md={4}>
- <Typography variant="h6" gutterBottom>
- {translate('common.edit.title.common')}
- </Typography>
- <StatusSelectInput />
- <Box mt="2em" />
- <MemoInput />
</Grid>
</Grid>
</SimpleForm>
diff --git a/rsf-admin/src/page/stockManage/locRevise/LocReviseList.jsx b/rsf-admin/src/page/stockManage/locRevise/LocReviseList.jsx
index 30a792c..efdc6fc 100644
--- a/rsf-admin/src/page/stockManage/locRevise/LocReviseList.jsx
+++ b/rsf-admin/src/page/stockManage/locRevise/LocReviseList.jsx
@@ -128,7 +128,7 @@
rowClick={(id, resource, record) => false}
expand={false}
expandSingle={true}
- omit={['id', 'createTime', 'createBy', 'memo']}
+ omit={['id', 'createTime', 'createBy', 'orgAreaId', 'memo']}
>
<NumberField source="id" />
<TextField source="code" label="table.field.locRevise.code" />
@@ -136,8 +136,8 @@
<NumberField source="anfme" label="table.field.locRevise.anfme" />
<NumberField source="reviseQty" label="table.field.locRevise.reviseQty" />
<TextField source="exceStatus$" label="table.field.locRevise.exceStatus" sortable={false} />
- <NumberField source="orgAreaId" label="table.field.locRevise.orgAreaId" />
- <TextField source="orgAreaName" label="table.field.locRevise.orgAreaName" />
+ <NumberField source="orgAreaId" label="table.field.locRevise.areaId" />
+ <TextField source="orgAreaName" label="table.field.locRevise.areaName" />
<TextField source="updateBy$" label="common.field.updateBy" />
<DateField source="updateTime" label="common.field.updateTime" showTime />
<DateField source="createBy$" label="common.field.createBy" />
diff --git a/rsf-admin/src/page/stockManage/locRevise/SelectLocsRevise.jsx b/rsf-admin/src/page/stockManage/locRevise/SelectLocsRevise.jsx
new file mode 100644
index 0000000..1d66d19
--- /dev/null
+++ b/rsf-admin/src/page/stockManage/locRevise/SelectLocsRevise.jsx
@@ -0,0 +1,327 @@
+import React, { useState, useEffect } from "react";
+import {
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogTitle,
+ Stack,
+ Grid,
+ Box,
+ Button,
+ Paper,
+ styled,
+ Tooltip,
+ IconButton,
+ TextField,
+} from '@mui/material';
+
+import { EDIT_MODE, DEFAULT_START_PAGE, DEFAULT_ITEM_PAGE_SIZE, DEFAULT_PAGE_SIZE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting';
+import DialogCloseButton from "../../components/DialogCloseButton";
+import {
+ useTranslate, useNotify, useRefresh, List, FilterButton, NumberField,
+ DateField, ReferenceInput, AutocompleteInput, TextInput, DatagridConfigurable,
+ BooleanField, SearchInput,
+} from 'react-admin';
+import TreeSelectInput from "@/page/components/TreeSelectInput";
+import { Add, Edit, Delete, Save } from '@mui/icons-material';
+import SaveIcon from '@mui/icons-material/Save';
+import { DataGrid } from '@mui/x-data-grid';
+import request from '@/utils/request';
+
+
+
+const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
+ '& .css-1vooibu-MuiSvgIcon-root': {
+ height: '.9em'
+ },
+ '& .RaDatagrid-row': {
+ cursor: 'auto'
+ },
+ '& .column-name': {
+ },
+ '& .opt': {
+ width: 180
+ },
+}));
+
+
+
+const SelectLocsRevise = (props) => {
+ const { open, setOpen, data, setData } = props;
+ const translate = useTranslate();
+ const refresh = useRefresh();
+ const notify = useNotify();
+
+ const handleClose = (event, reason) => {
+ if (reason !== "backdropClick") {
+ setOpen(false);
+ }
+ };
+
+ const dicts = JSON.parse(localStorage.getItem('sys_dicts'))?.filter(dict => (dict.dictTypeCode == 'sys_stock_revise_type')) || [];
+ const [formData, setFormData] = useState({});
+ const [tableData, setTableData] = useState([]);
+ const [dyFields, setDyFields] = useState([]);
+ const [selectedRows, setSelectedRows] = useState([]);
+ const [page, setPage] = useState({ page: DEFAULT_START_PAGE, pageSize: DEFAULT_PAGE_SIZE });
+ const [rowCount, setRowCount] = useState(0);
+ const [isLoading, setIsLoading] = useState(false);
+ const handleChange = (e) => {
+ const { name, value } = e.target;
+ setFormData(() => ({
+ [name]: value
+ }));
+ };
+
+ const reset = () => {
+ setFormData({
+ name: '',
+ code: '',
+ groupId: 0
+ })
+ }
+
+ const handleSubmit = () => {
+ const hasarr = data.map(el => +el.matnrId)
+ const selectedData = selectedRows.filter(item => !hasarr.includes(item)).map(id => (tableData.find(row => row.id === id)));
+ const value = selectedData.map((el => {
+ const dynamicFields = dyFields.reduce((acc, item) => {
+ acc[item.fields] = el['extendFields']?.[item.fields] || '';
+ return acc;
+ }, {});
+ return {
+ matnrId: el.id,
+ maktx: el.name,
+ matnrCode: el.code,
+ stockUnit: el.stockUnit || '',
+ purUnit: el.purchaseUnit || '',
+ ...dynamicFields
+ }
+ }))
+ setData([...data, ...value]);
+ setOpen(false);
+ reset();
+ };
+
+ const filters = [
+ <SearchInput source="condition" alwaysOn />,
+ ]
+
+ const getData = async () => {
+ setIsLoading(true)
+ const res = await request.post(`/locItem/page`, {
+ ...formData,
+ current: page?.page,
+ pageSize: page?.pageSize,
+ orderBy: "create_time desc"
+ });
+ if (res?.data?.code === 200) {
+ setTableData(res.data.data.records);
+ setRowCount(res.data?.data?.total);
+
+ } else {
+ notify(res.data.msg);
+ }
+ setIsLoading(false)
+
+ };
+
+ useEffect(() => {
+ getData();
+ }, [open, page]);
+
+ const handleSearch = () => {
+ getData()
+ };
+
+ return (
+ <Dialog
+ open={open}
+ onClose={handleClose}
+ aria-labelledby="form-dialog-title"
+ fullWidth
+ disableRestoreFocus
+ maxWidth="xl"
+ >
+ <DialogTitle id="form-dialog-title" sx={{
+ position: 'sticky',
+ top: 0,
+ backgroundColor: 'background.paper',
+ zIndex: 1000
+ }}>
+ {translate("common.action.newAddMats")}
+ <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}>
+ <DialogCloseButton onClose={handleClose} />
+ </Box>
+ </DialogTitle>
+ <DialogContent sx={{ mt: 2 }}>
+ {/* <Box>
+ <List
+ sx={{
+ flexGrow: 1,
+ marginRight: 1,
+ transition: (theme) =>
+ theme.transitions.create(['all'], {
+ duration: theme.transitions.duration.enteringScreen,
+ }),
+ }}
+ resource="loc"
+ title={"menu.loc"}
+ empty={false}
+ filter={{ useStatus: 'F' }}
+ filters={filters}
+ sort={{ field: "'row'" }}
+ actions={false}
+ perPage={DEFAULT_PAGE_SIZE}
+ aside={false}
+ >
+ <StyledDatagrid
+ preferenceKey='loc'
+ align="left"
+ bulkActionButtons={false}
+ rowClick={() => false}
+ omit={['id', 'areaId', 'type', 'barcode']}
+ >
+ <NumberField source="id" />
+ <TextField source="code" label="table.field.locItem.locCode" />
+ </StyledDatagrid>
+ </List>
+ </Box> */}
+ <Box>
+ <Box component="form" onSubmit={handleSubmit} sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
+ <Grid container spacing={2} md={6}>
+ <Grid item md={4}>
+ <TextField
+ label={translate('table.field.locItem.locCode')}
+ name="locCode"
+ value={formData.name}
+ onChange={handleChange}
+ size="small"
+ />
+ </Grid>
+ <Grid item md={2} sx={{ margin: 'auto' }}>
+ <Button variant="contained" onClick={handleSearch}>鎼滅储</Button>
+ </Grid>
+ </Grid>
+ </Box>
+ <Box sx={{ mt: 2, height: 600, width: '100%' }}>
+ <AsnWareModalTable
+ tableData={tableData}
+ setTableData={setTableData}
+ dyFields={dyFields}
+ page={page}
+ rowCount={rowCount}
+ setPage={setPage}
+ isLoading={isLoading}
+ setDyFields={setDyFields}
+ selectedRows={selectedRows}
+ setSelectedRows={setSelectedRows}
+ />
+ </Box>
+ </Box>
+ </DialogContent>
+ <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}>
+ <Box sx={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
+ <Button onClick={handleSubmit} variant="contained" startIcon={<SaveIcon />}>
+ {translate('toolbar.confirm')}
+ </Button>
+ </Box>
+ </DialogActions>
+ </Dialog>
+ );
+};
+
+export default SelectLocsRevise;
+
+const AsnWareModalTable = ({ tableData, setTableData, page, isLoading, pageSize, setPage, rowCount, selectedRows, setSelectedRows, dyFields, setDyFields }) => {
+ const translate = useTranslate();
+ const notify = useNotify();
+
+ const [columns, setColumns] = useState([
+ // { field: 'id', headerName: 'ID', width: 100 },
+ { field: 'locCode', headerName: translate('table.field.locItem.locCode'), width: 150 },
+ { field: 'matnrCode', headerName: translate('table.field.locItem.matnrCode'), width: 200 },
+ { field: 'maktx', headerName: translate('table.field.locItem.maktx'), width: 300 },
+ { field: 'batch', headerName: translate('table.field.locItem.batch'), width: 100 },
+ { field: 'anfme', headerName: translate('table.field.locItem.anfme'), width: 100 },
+ { field: 'unit', headerName: translate('table.field.matnr.unit'), width: 100 },
+ ])
+
+ const action = {
+ field: 'action',
+ headerName: '鎿嶄綔',
+ width: 140,
+ lockPosition: 'left',
+ renderCell: (params) => (
+ <Tooltip title="Delete">
+ <IconButton onClick={() => handleDelete(params.row)}>
+ <Delete />
+ </IconButton>
+ <IconButton onClick={() => handleDelete(params.row)}>
+ <Save />
+ </IconButton>
+ </Tooltip>
+ ),
+ }
+
+
+ const handleSelectionChange = (ids) => {
+ setSelectedRows(ids)
+ };
+
+ useEffect(() => {
+ if (dyFields.length < 1) {
+ getDynamicFields();
+ }
+ }, []);
+
+ const getDynamicFields = async () => {
+ const {
+ data: { code, data, msg },
+ } = await request.get("/fields/enable/list");
+ if (code === 200) {
+ const cols = data.map(el => ({
+ field: el.fields,
+ headerName: el.fieldsAlise,
+ minWidth: 100,
+ flex: 1,
+ editable: el.unique,
+ valueGetter: (value, row) => {
+ return row.extendFields?.[el.fields] || '';
+ },
+ }))
+ setDyFields(data)
+ setColumns([...columns, ...cols, action])
+ } else {
+ notify(msg);
+ }
+ }
+
+ return (
+ <div style={{ width: '100%' }}>
+ <DataGrid
+ sx={{ height: 600 }}
+ size="small"
+ rows={tableData}
+ columns={columns}
+ checkboxSelection
+ onRowSelectionModelChange={handleSelectionChange}
+ selectionModel={selectedRows}
+ disableColumnMenu={true}
+ disableColumnSorting
+ disableMultipleColumnsSorting
+ rowCount={rowCount}
+ paginationMode="server"
+ paginationModel={page}
+ onPaginationModelChange={setPage}
+ loading={isLoading}
+ slotProps={{
+ loadingOverlay: {
+ variant: 'linear-progress',
+ noRowsVariant: 'linear-progress',
+ },
+ }}
+ />
+ </div>
+ );
+};
\ No newline at end of file
--
Gitblit v1.9.1