|  |  |  | 
|---|
|  |  |  | import ConfirmModal from "@/page/components/ConfirmModal"; | 
|---|
|  |  |  | import { DataGrid } from '@mui/x-data-grid'; | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | import { haveChildren } from '@/utils/common'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const LocAreaMatPanel = () => { | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | 
|---|
|  |  |  | const columns = [ | 
|---|
|  |  |  | { field: 'id', headerName: 'ID', width: 100 }, | 
|---|
|  |  |  | { field: 'areaId$', headerName: translate('table.field.locAreaMatRela.areaId'), width: 100 }, | 
|---|
|  |  |  | { field: 'locId$', headerName: translate('table.field.locAreaMatRela.locId'), width: 100 }, | 
|---|
|  |  |  | { field: 'locTypeId$', headerName: translate('table.field.locAreaMatRela.locTypeId'), width: 100 }, | 
|---|
|  |  |  | { field: 'matnrId$', headerName: translate('table.field.locAreaMatRela.matnrId'), width: 100 }, | 
|---|
|  |  |  | { field: 'groupId$', headerName: translate('table.field.locAreaMatRela.groupId'), width: 100 }, | 
|---|
|  |  |  | { field: 'locTypeId$', headerName: translate('table.field.locAreaMatRela.locTypeId'), width: 100 }, | 
|---|
|  |  |  | { field: 'locId$', headerName: translate('table.field.locAreaMatRela.locId'), width: 100 }, | 
|---|
|  |  |  | { | 
|---|
|  |  |  | field: 'action', | 
|---|
|  |  |  | headerName: '操作', | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [parmas, setParmas] = useState({ | 
|---|
|  |  |  | current: 1, | 
|---|
|  |  |  | pageSize: 99, | 
|---|
|  |  |  | areaMatId: record.id, | 
|---|
|  |  |  | locTypeId: '', | 
|---|
|  |  |  | groupId: '', | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [tableData, setTableData] = useState([]); | 
|---|
|  |  |  | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.get(`/locAreaMatRela/groups/${record.id}`); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | setMatnrTree(data || []) | 
|---|
|  |  |  | setMatnrTree(haveChildren(data) || []) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | const { data: { code, data, msg } } = await request.get(`/locAreaMatRela/locType/${record.id}`); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (code === 200) { | 
|---|
|  |  |  | setLocTree(data || []) | 
|---|
|  |  |  | setLocTree(haveChildren(data) || []) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | <Grid container spacing={2}> | 
|---|
|  |  |  | {/* 物料分组 */} | 
|---|
|  |  |  | <Grid item xs={2}> | 
|---|
|  |  |  | <MatnrTree matnrTree={matnrTree} setParmas={setParmas} reload={reload} /> | 
|---|
|  |  |  | <MatnrTree matnrTree={matnrTree} parmas={parmas} setParmas={setParmas} reload={reload} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | {/* 库位类型 */} | 
|---|
|  |  |  | <Grid item xs={2}> | 
|---|
|  |  |  | <LocTree locTree={locTree} setParmas={setParmas} reload={reload} /> | 
|---|
|  |  |  | <LocTree locTree={locTree} parmas={parmas} setParmas={setParmas} reload={reload} /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | {/* 其他内容 */} | 
|---|
|  |  |  | 
|---|
|  |  |  | disableColumnMenu={true} | 
|---|
|  |  |  | disableColumnSorting | 
|---|
|  |  |  | disableMultipleColumnsSorting | 
|---|
|  |  |  | columnBufferPx={100} | 
|---|
|  |  |  | initialState={{ | 
|---|
|  |  |  | pagination: { | 
|---|
|  |  |  | paginationModel: { | 
|---|
|  |  |  | pageSize: 10, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | pageSizeOptions={[10]} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | </Grid> | 
|---|
|  |  |  | 
|---|
|  |  |  | export default LocAreaMatPanel; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const MatnrTree = ({ matnrTree, setParmas, reload }) => { | 
|---|
|  |  |  | const MatnrTree = ({ matnrTree, parmas, setParmas, reload }) => { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | 
|---|
|  |  |  | groupId: selectedItems | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const res = await request.post(`/locAreaMatRela/group/remove/`, parmas); | 
|---|
|  |  |  | const res = await request.post(`/locAreaMatRela/group/remove`, parmas); | 
|---|
|  |  |  | if (res?.data?.code === 200) { | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleNodeSelect = (event, nodeId) => { | 
|---|
|  |  |  | event.stopPropagation() | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | parmas.groupId = nodeId; | 
|---|
|  |  |  | parmas.locTypeId = ''; | 
|---|
|  |  |  | setParmas(parmas) | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Card sx={{ p: 1 }}> | 
|---|
|  |  |  | <div style={{ display: 'flex', justifyContent: 'space-between', paddingBottom: '3px', marginBottom: '3px', borderBottom: '1px dashed #d4d4d4' }}> | 
|---|
|  |  |  | <div style={{ fontSize: '17px' }}>物料分组</div> | 
|---|
|  |  |  | <div style={{ display: 'flex', alignItems: 'center', gap: '3px' }}> | 
|---|
|  |  |  | {/* <div style={{ display: 'flex', alignItems: 'center', gap: '3px' }}> | 
|---|
|  |  |  | <AddIcon color={'info'} sx={{ cursor: 'pointer' }} onClick={() => handleAdd()} /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <DeleteIcon color={'warning'} sx={{ cursor: 'pointer' }} onClick={() => handleDelete()} /> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> */} | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <RichTreeView | 
|---|
|  |  |  | expansionTrigger="iconContainer" | 
|---|
|  |  |  | checkboxSelection | 
|---|
|  |  |  | multiSelect | 
|---|
|  |  |  | // checkboxSelection | 
|---|
|  |  |  | // multiSelect | 
|---|
|  |  |  | items={matnrTree} | 
|---|
|  |  |  | apiRef={apiRef} | 
|---|
|  |  |  | selectedItems={selectedItems} | 
|---|
|  |  |  | getItemId={(item) => item.id} | 
|---|
|  |  |  | getItemLabel={(item) => item.name} | 
|---|
|  |  |  | defaultExpandedItems={['grid']} | 
|---|
|  |  |  | selectedItems={selectedItems} | 
|---|
|  |  |  | onSelectedItemsChange={handleSelectedItemsChange} | 
|---|
|  |  |  | onItemSelectionToggle={handleItemSelectionToggle} | 
|---|
|  |  |  | onItemClick={handleNodeSelect} | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const LocTree = ({ locTree, setParmas, reload }) => { | 
|---|
|  |  |  | const LocTree = ({ locTree, setParmas, parmas, reload }) => { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  | const notify = useNotify(); | 
|---|
|  |  |  | 
|---|
|  |  |  | typeId: selectedItems | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const res = await request.post(`/locAreaMatRela/locType/remove/`, parmas); | 
|---|
|  |  |  | const res = await request.post(`/locAreaMatRela/locType/remove`, parmas); | 
|---|
|  |  |  | if (res?.data?.code === 200) { | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  | notify(res.data.msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleNodeSelect = (event, nodeId) => { | 
|---|
|  |  |  | // event.preventDefault(); | 
|---|
|  |  |  | console.log(nodeId) | 
|---|
|  |  |  | event.stopPropagation(); | 
|---|
|  |  |  | parmas.locTypeId = nodeId; | 
|---|
|  |  |  | parmas.groupId = ''; | 
|---|
|  |  |  | setParmas(parmas) | 
|---|
|  |  |  | reload() | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Card sx={{ p: 1 }}> | 
|---|
|  |  |  | <div style={{ display: 'flex', justifyContent: 'space-between', paddingBottom: '3px', marginBottom: '3px', borderBottom: '1px dashed #d4d4d4' }}> | 
|---|
|  |  |  | <div style={{ fontSize: '17px' }}>库位类型</div> | 
|---|
|  |  |  | <div style={{ display: 'flex', alignItems: 'center', gap: '3px' }}> | 
|---|
|  |  |  | {/* <div style={{ display: 'flex', alignItems: 'center', gap: '3px' }}> | 
|---|
|  |  |  | <AddIcon color={'info'} sx={{ cursor: 'pointer' }} onClick={() => handleAdd()} /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <DeleteIcon color={'warning'} sx={{ cursor: 'pointer' }} onClick={() => handleDelete()} /> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> */} | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <RichTreeView | 
|---|
|  |  |  | expansionTrigger="iconContainer" | 
|---|
|  |  |  | checkboxSelection | 
|---|
|  |  |  | multiSelect | 
|---|
|  |  |  | items={locTree} | 
|---|
|  |  |  | apiRef={apiRef} | 
|---|
|  |  |  | selectedItems={selectedItems} | 
|---|
|  |  |  | getItemId={(item) => item.id} | 
|---|
|  |  |  | getItemLabel={(item) => item.name} | 
|---|
|  |  |  | defaultExpandedItems={['grid']} | 
|---|
|  |  |  | onSelectedItemsChange={handleSelectedItemsChange} | 
|---|
|  |  |  | onItemSelectionToggle={handleItemSelectionToggle} | 
|---|
|  |  |  | onItemClick={handleNodeSelect} | 
|---|
|  |  |  | onItemSelectionToggle={handleItemSelectionToggle} | 
|---|
|  |  |  | // checkboxSelection | 
|---|
|  |  |  | // multiSelect | 
|---|
|  |  |  | selectedItems={selectedItems} | 
|---|
|  |  |  | onSelectedItemsChange={handleSelectedItemsChange} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <BindLocModal | 
|---|