|  |  | 
 |  |  | 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'; | 
 |  |  | 
 |  |  |     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) => { | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     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) => { | 
 |  |  |         setFormData((prevData) => ({ | 
 |  |  | 
 |  |  |                                 variant="filled" | 
 |  |  |                                 onChange={(e) => handleChange(e.target.value, 'type')} | 
 |  |  |                                 dictTypeCode="sys_transfer_type" | 
 |  |  |                                 required | 
 |  |  |                             /> | 
 |  |  |                         </Grid> | 
 |  |  |                         <Grid item md={2}> | 
 |  |  | 
 |  |  |                                 value={formData.orgAreaId} | 
 |  |  |                                 variant="filled" | 
 |  |  |                                 dictTypeCode="warehouse" | 
 |  |  |                                 required | 
 |  |  |                                 onChange={(e) => handleChange(e.target.value, 'orgAreaId')} | 
 |  |  |                                 label={translate("table.field.transfer.orgAreaName")} /> | 
 |  |  |                         </Grid> | 
 |  |  | 
 |  |  |                                 value={formData.tarAreaId} | 
 |  |  |                                 dictTypeCode="warehouse" | 
 |  |  |                                 variant="filled" | 
 |  |  |                                 required | 
 |  |  |                                 onChange={(e) => handleChange(e.target.value, 'tarAreaId')} | 
 |  |  |                             /> | 
 |  |  |                         </Grid> | 
 |  |  | 
 |  |  |                 </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} /> | 
 |  |  | 
 |  |  |                     <TransferTableView | 
 |  |  |                         tabelData={tabelData} | 
 |  |  |                         setTableData={setTableData} | 
 |  |  |                         asnId={orderId} | 
 |  |  |                         orderId={orderId} | 
 |  |  |                         selectedRows={selectedRows} | 
 |  |  |                         setSelectedRows={setSelectedRows} | 
 |  |  |                         tableRef={tableRef}> | 
 |  |  | 
 |  |  |                     </Button> | 
 |  |  |                 </Toolbar> | 
 |  |  |                 <CreateBySelectMats | 
 |  |  |                     data={tabelData} | 
 |  |  |                     queryForm={formData} | 
 |  |  |                     open={createDialog} | 
 |  |  |                     setOpen={setCreateDialog} | 
 |  |  |                     data={tabelData} | 
 |  |  |                     selectedRows={selectedRows} | 
 |  |  |                     setSelectedRows={setSelectedRows} | 
 |  |  |                     setData={setTableData} | 
 |  |  |                 /> | 
 |  |  |             </Box> | 
 |  |  | 
 |  |  |  | 
 |  |  |     tableRef.current = useGridApiRef(); | 
 |  |  |  | 
 |  |  |     const tableIds = tabelData.map(map => map.id); | 
 |  |  |     // setSelectedRows(tableIds); | 
 |  |  |     // // console.log(selectedRows); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     return ( | 
 |  |  |         <Box> | 
 |  |  |             <DataGrid | 
 |  |  | 
 |  |  |                 rows={tabelData} | 
 |  |  |                 columns={columns} | 
 |  |  |                 disableRowSelectionOnClick | 
 |  |  |                 getRowId={(row) => row.matnrId ? row.matnrId : row.id} | 
 |  |  |                 disableColumnFilter | 
 |  |  |                 disableColumnSelector | 
 |  |  |                 disableColumnSorting | 
 |  |  |                 disableMultipleColumnsSorting | 
 |  |  |                 processRowUpdate={processRowUpdate} | 
 |  |  |                 initialState={{ | 
 |  |  |                     pagination: { | 
 |  |  |                         paginationModel: { | 
 |  |  | 
 |  |  |                 pageSizeOptions={[15, 25, 50, 100]} | 
 |  |  |                 editMode="row" | 
 |  |  |                 checkboxSelection | 
 |  |  |                 rowSelectionModel={tableIds} | 
 |  |  |                 onRowSelectionModelChange={handleSelectionChange} | 
 |  |  |                 selectionModel={selectedRows} | 
 |  |  |                 sx={{ | 
 |  |  |                     height: 580, | 
 |  |  |                     '& .MuiDataGrid-cell input': { | 
 |  |  | 
 |  |  |                     }, | 
 |  |  |                 }} | 
 |  |  |             /> | 
 |  |  |             {/* <Box sx={{ | 
 |  |  |                 padding: 2, | 
 |  |  |                 position: 'absolute', | 
 |  |  |                 right: 1 | 
 |  |  |             }}> | 
 |  |  |                 <Button variant="contained" onClick={() => handleSubmit()} startIcon={<SaveIcon/>} > | 
 |  |  |                     {translate('toolbar.confirm')} | 
 |  |  |                 </Button> | 
 |  |  |             </Box> */} | 
 |  |  |         </Box> | 
 |  |  |     ); | 
 |  |  | }; |