From 48b45b5e63f9925c63c951093c4cf596d89683a2 Mon Sep 17 00:00:00 2001 From: vincentlu <t1341870251@gmail.com> Date: 星期一, 11 八月 2025 10:34:22 +0800 Subject: [PATCH] # --- rsf-admin/src/page/orders/transfer/ManualCreate.jsx | 84 ++++++++++++++++++----------------------- 1 files changed, 37 insertions(+), 47 deletions(-) diff --git a/rsf-admin/src/page/orders/transfer/ManualCreate.jsx b/rsf-admin/src/page/orders/transfer/ManualCreate.jsx index 3d6f07e..2990e16 100644 --- a/rsf-admin/src/page/orders/transfer/ManualCreate.jsx +++ b/rsf-admin/src/page/orders/transfer/ManualCreate.jsx @@ -18,6 +18,7 @@ Form, useCreateController, SimpleForm, + useRefresh, } from 'react-admin'; import { Dialog, @@ -39,24 +40,26 @@ import WarehouseSelect from "../../components/WarehouseSelect.jsx"; import { DataGrid, useGridApiRef } from '@mui/x-data-grid'; import ConfirmButton from "../../components/ConfirmButton"; +import { useFormContext, useWatch } from "react-hook-form"; import CreateBySelectMats from "./CreateBySelectMats.jsx"; import { Add, Edit, Delete } from '@mui/icons-material'; import DictSelect from "../../components/DictSelect"; -import { useFormContext, useWatch } from "react-hook-form"; import { minHeight, padding } from "@mui/system"; import SaveIcon from '@mui/icons-material/Save'; import request from '@/utils/request'; +import _, { set } from 'lodash'; const ManualCreate = (props) => { const { open, setOpen, orderId } = props; const tableRef = useRef(); const notify = useNotify(); + const refresh = useRefresh(); const translate = useTranslate(); const [tabelData, setTableData] = useState([]); const [disabled, setDisabled] = useState(false); const [selectedRows, setSelectedRows] = useState([]); const [createDialog, setCreateDialog] = useState(false); - const [formData, setFormData] = useState({}); + const [formData, setFormData] = useState({ type: '1', orgAreaId: null, tarAreaId: null }); const [list, setList] = useState([]); const handleClose = (event, reason) => { @@ -84,12 +87,10 @@ "transfer": formData, "items": tabelData, } - + const res = await request.post(`/transfer/items/save`, parmas); if (res?.data?.code === 200) { setOpen(false); - refresh(); - resetData() } else { notify(res.data.msg); } @@ -101,13 +102,13 @@ const res = await request.post(`/transfer/items/update`, parmas); if (res?.data?.code === 200) { setOpen(false); - refresh(); - resetData() } else { notify(res.data.msg); } } setDisabled(false) + refresh(); + }; const handleSuccess = async (data) => { @@ -138,17 +139,26 @@ } } + const newAddClick = () => { + if (formData.orgAreaId == null || formData.orgAreaId == undefined) { + notify("鍘熷簱鍖轰笉鑳戒负绌猴紒锛�", { type: 'error' }) + return + } + if (formData.tarAreaId == null || formData.tarAreaId == undefined) { + notify("鐩爣搴撳尯涓嶈兘涓虹┖锛侊紒", { type: 'error' }) + return + } + console.log(formData); + + setCreateDialog(true) + } + const handleChange = (value, name) => { - console.log(name); - console.log(value); setFormData((prevData) => ({ ...prevData, [name]: value })); - - console.log(formData); - }; return ( @@ -163,7 +173,6 @@ variant="filled" onChange={(e) => handleChange(e.target.value, 'type')} dictTypeCode="sys_transfer_type" - required /> </Grid> <Grid item md={2}> @@ -171,7 +180,6 @@ value={formData.orgAreaId} variant="filled" dictTypeCode="warehouse" - required onChange={(e) => handleChange(e.target.value, 'orgAreaId')} label={translate("table.field.transfer.orgAreaName")} /> </Grid> @@ -181,7 +189,6 @@ value={formData.tarAreaId} dictTypeCode="warehouse" variant="filled" - required onChange={(e) => handleChange(e.target.value, 'tarAreaId')} /> </Grid> @@ -189,7 +196,7 @@ </SimpleForm> <Box sx={{ mt: 2 }}> <Stack direction="row" spacing={2} sx={{ justifyContent: "flex-end" }}> - <Button variant="contained" onClick={() => setCreateDialog(true)} > + <Button variant="contained" onClick={newAddClick} > {translate('common.action.newAddMats')} </Button> <ConfirmButton label={"toolbar.delete"} variant="outlined" color="error" onConfirm={handleDeleteItem} /> @@ -199,7 +206,7 @@ <TransferTableView tabelData={tabelData} setTableData={setTableData} - asnId={orderId} + orderId={orderId} selectedRows={selectedRows} setSelectedRows={setSelectedRows} tableRef={tableRef}> @@ -211,9 +218,12 @@ </Button> </Toolbar> <CreateBySelectMats + data={tabelData} + queryForm={formData} open={createDialog} setOpen={setCreateDialog} - data={tabelData} + selectedRows={selectedRows} + setSelectedRows={setSelectedRows} setData={setTableData} /> </Box> @@ -348,24 +358,22 @@ }, { field: 'anfme', - headerName: translate('table.field.outStockItem.anfme') + "*", + headerName: translate('table.field.outStockItem.anfme'), type: 'number', minWidth: 100, flex: 1, editable: true, valueFormatter: (val) => val < 0 ? 0 : val, - headerClassName: "custom", }, { field: 'splrCode', - headerName: translate('table.field.outStockItem.splrCode') + "*", + headerName: translate('table.field.outStockItem.splrCode'), minWidth: 100, flex: 1, editable: true, renderEditCell: (params) => ( <SelectInputSplrCodeEditCell {...params} /> ), - headerClassName: "custom", }, { field: 'splrName', @@ -376,18 +384,10 @@ renderEditCell: (params) => ( <SelectInputSplrNameEditCell {...params} /> ), - headerClassName: "custom", }, { - field: 'splrBatch', + field: 'batch', headerName: translate('table.field.outStockItem.splrBatch'), - minWidth: 100, - flex: 1, - editable: true, - }, - { - field: 'poCode', - headerName: translate('table.field.outStockItem.poDetlCode'), minWidth: 100, flex: 1, editable: true, @@ -468,6 +468,11 @@ tableRef.current = useGridApiRef(); + const tableIds = tabelData.map(map => map.id); + // setSelectedRows(tableIds); + // // console.log(selectedRows); + + return ( <Box> <DataGrid @@ -475,12 +480,6 @@ rows={tabelData} columns={columns} disableRowSelectionOnClick - getRowId={(row) => row.matnrId ? row.matnrId : row.id} - disableColumnFilter - disableColumnSelector - disableColumnSorting - disableMultipleColumnsSorting - processRowUpdate={processRowUpdate} initialState={{ pagination: { paginationModel: { @@ -491,8 +490,8 @@ pageSizeOptions={[15, 25, 50, 100]} editMode="row" checkboxSelection + rowSelectionModel={tableIds} onRowSelectionModelChange={handleSelectionChange} - selectionModel={selectedRows} sx={{ height: 580, '& .MuiDataGrid-cell input': { @@ -500,15 +499,6 @@ }, }} /> - {/* <Box sx={{ - padding: 2, - position: 'absolute', - right: 1 - }}> - <Button variant="contained" onClick={() => handleSubmit()} startIcon={<SaveIcon/>} > - {translate('toolbar.confirm')} - </Button> - </Box> */} </Box> ); }; -- Gitblit v1.9.1