| | |
| | | import basContainer from './basicInfo/basContainer'; |
| | | import outBound from "./work/outBound"; |
| | | import checkOutBound from "./work/checkOutBound"; |
| | | import stockTransfer from "./work/stockTransfer"; |
| | | |
| | | const ResourceContent = (node) => { |
| | | switch (node.component) { |
| | |
| | | return outBound; |
| | | case 'checkOutBound': |
| | | return checkOutBound; |
| | | case 'stockTransfer': |
| | | return stockTransfer; |
| | | default: |
| | | return { |
| | | list: ListGuesser, |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | ListGuesser, |
| | | EditGuesser, |
| | | ShowGuesser, |
| | | } from "react-admin"; |
| | | |
| | | |
| | | import StockTransferList from "./stockTransferList"; |
| | | |
| | | export default { |
| | | list: StockTransferList, |
| | | edit: EditGuesser, |
| | | show: ShowGuesser, |
| | | recordRepresentation: (record) => { |
| | | return `${record.id}` |
| | | } |
| | | }; |
New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { useWatch, useFormContext } from "react-hook-form"; |
| | | import { |
| | | CreateBase, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SaveButton, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | Toolbar, |
| | | required, |
| | | useDataProvider, |
| | | useNotify, |
| | | Form, |
| | | useCreateController, |
| | | useListContext, |
| | | useRefresh, |
| | | Edit, |
| | | useRedirect, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | | DialogActions, |
| | | DialogContent, |
| | | DialogTitle, |
| | | Stack, |
| | | Grid, |
| | | TextField, |
| | | Box, |
| | | Button, |
| | | Paper, |
| | | TableContainer, |
| | | Table, |
| | | TableHead, |
| | | TableBody, |
| | | TableRow, |
| | | TableCell, |
| | | Tooltip, |
| | | IconButton, |
| | | styled, |
| | | Select, |
| | | MenuItem, |
| | | Typography, |
| | | Card, |
| | | Autocomplete, |
| | | } from '@mui/material'; |
| | | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; |
| | | import ConfirmButton from "../../components/ConfirmButton"; |
| | | import TreeSelectInput from "@/page/components/TreeSelectInput"; |
| | | import { DataGrid, useGridApiRef } from '@mui/x-data-grid'; |
| | | import DictSelect from "../../components/DictSelect"; |
| | | import AddIcon from '@mui/icons-material/Add'; |
| | | import DeleteIcon from '@mui/icons-material/Delete'; |
| | | import request from '@/utils/request'; |
| | | import LocItemInfoModal from "../components/locItemInfoModal"; |
| | | import { Delete } from '@mui/icons-material'; |
| | | import _, { set } from 'lodash'; |
| | | import StaSelect from "../components/StaSelect"; |
| | | import { redirect } from "react-router"; |
| | | import { number } from "prop-types"; |
| | | |
| | | const StockTransferList = () => { |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [tabelData, setTableData] = useState([]); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [sta, setSta] = useState(""); |
| | | const notify = useNotify(); |
| | | const tableRef = useRef(); |
| | | tableRef.current = useGridApiRef(); |
| | | const translate = useTranslate(); |
| | | |
| | | const [orgLoc, setOrgLoc] = useState([]); |
| | | const [tarLoc, setTarLoc] = useState([]); |
| | | const [tarLocList, setTarLocList] = useState([]); |
| | | |
| | | useEffect(() => { |
| | | selectAreaNoUse(); |
| | | },[orgLoc]) |
| | | |
| | | const selectAreaNoUse = async() =>{ |
| | | const { |
| | | data: { code, data, msg }, |
| | | } = await request.post("/loc/areaNoUse/list",{ |
| | | |
| | | }); |
| | | if (code === 200) { |
| | | const newData = data.map((item) => { |
| | | return { |
| | | label: item, |
| | | id: item |
| | | } |
| | | |
| | | }) |
| | | console.log(newData); |
| | | setTarLocList(newData); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | const handleDeleteItem = () => { |
| | | const newTableData = _.filter(tabelData, (item) => !selectedRows.includes(item.matnrId)); |
| | | setTableData(newTableData); |
| | | } |
| | | |
| | | // 添加一个处理新数据的函数,设置outQty默认值 |
| | | const handleSetData = (newData) => { |
| | | // 为新添加的数据设置outQty默认值为anfme的值 |
| | | const dataWithDefaultQty = newData.map(item => ({ |
| | | ...item, |
| | | outQty: item.outQty || item.anfme // 如果outQty已存在则保留,否则使用anfme的值 |
| | | })); |
| | | setTableData([...tabelData, ...dataWithDefaultQty]); |
| | | }; |
| | | |
| | | |
| | | |
| | | return ( |
| | | <> |
| | | <Card sx={{ p: 2, mb: 2, mt: 2 }}> |
| | | <Form> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12}> |
| | | <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 1 }}> |
| | | <Typography variant="h6" > |
| | | {translate('table.field.stockTransfer.inputLoc')} |
| | | </Typography> |
| | | <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 1 }}> |
| | | <Stack direction='row' spacing={2} minWidth={200}> |
| | | <TextField |
| | | label={translate("table.field.stockTransfer.orgLoc")} |
| | | onChange={(event) => setOrgLoc(event.target.value)} |
| | | /> |
| | | </Stack> |
| | | <>{"——"}</> |
| | | <Stack direction='row' spacing={2} minWidth={200}> |
| | | <Autocomplete |
| | | disablePortal |
| | | options={tarLocList} |
| | | renderInput={(params) => ( |
| | | <TextField {...params} label={translate("table.field.stockTransfer.tarLoc")} /> |
| | | )} |
| | | onChange={(event, value) => setTarLoc(value)} |
| | | /> |
| | | </Stack> |
| | | </Box> |
| | | |
| | | <Stack direction='row' spacing={2} minWidth={200}> |
| | | <SubmitButton |
| | | orgLoc={orgLoc} |
| | | tarLoc={tarLoc} |
| | | /> |
| | | </Stack> |
| | | </Box> |
| | | </Grid> |
| | | </Grid> |
| | | </Form> |
| | | </Card> |
| | | <Card sx={{ mb: 2 }}> |
| | | <Box sx={{}}> |
| | | <ModalTable tabelData={tabelData} setTableData={setTableData} selectedRows={selectedRows} setSelectedRows={setSelectedRows} tableRef={tableRef}></ModalTable> |
| | | </Box> |
| | | </Card> |
| | | <LocItemInfoModal |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | data={tabelData} |
| | | setData={handleSetData} |
| | | /> |
| | | |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default StockTransferList; |
| | | |
| | | const SubmitButton = (props) => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const redirect = useRedirect(); |
| | | const refresh = useRefresh(); |
| | | const { orgLoc, tarLoc } = props; |
| | | const check = () => { |
| | | console.log(orgLoc, tarLoc); |
| | | if (orgLoc === "" || orgLoc === undefined || orgLoc === null) { |
| | | notify("请选择站点"); |
| | | return; |
| | | } |
| | | if (tarLoc === "" || tarLoc === undefined || tarLoc === null) { |
| | | notify("请选择站点"); |
| | | return; |
| | | } |
| | | |
| | | } |
| | | const http = async (sta, items) => { |
| | | console.log(items); |
| | | |
| | | const filter = items.filter(item => (item.outQty + item.workQty) > item.anfme); |
| | | if (filter.length > 0) { |
| | | notify(translate('toolbar.request.error.out_stock_qty')) |
| | | return |
| | | } |
| | | const { data: { code, data, msg } } = await request.post(`/locItem/generate/task`, { siteNo: sta, items: items }); |
| | | if (code === 200) { |
| | | notify(msg); |
| | | refresh() |
| | | setTableData([]) |
| | | redirect("/task") |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | return ( |
| | | <ConfirmButton |
| | | variant="contained" |
| | | color="primary" |
| | | onConfirm={check} |
| | | label={"table.field.outBound.createTask"} |
| | | > |
| | | </ConfirmButton> |
| | | ) |
| | | |
| | | } |
| | | |
| | | const ModalTable = ({ tabelData, setTableData, selectedRows, setSelectedRows, tableRef }) => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | |
| | | const [columns, setColumns] = useState([ |
| | | { |
| | | field: 'locCode', |
| | | headerName: translate('table.field.locItem.locCode'), |
| | | width: 100, |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'anfme', |
| | | headerName: translate('table.field.locItem.anfme'), |
| | | type: 'number', |
| | | width: 100, |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'workQty', |
| | | headerName: translate('table.field.locItem.workQty'), |
| | | width: 100, |
| | | type: 'number', |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'locCode', |
| | | headerName: translate('table.field.locItem.locCode'), |
| | | width: 100, |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'matnrCode', |
| | | headerName: translate('table.field.locItem.matnrCode'), |
| | | width: 130, |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'maktx', |
| | | headerName: translate('table.field.locItem.maktx'), |
| | | width: 250, |
| | | editable: false, |
| | | }, |
| | | { |
| | | field: 'batch', |
| | | headerName: translate('table.field.locItem.batch'), |
| | | width: 250, |
| | | editable: false, |
| | | }, |
| | | ]) |
| | | |
| | | const action = { |
| | | field: 'action', |
| | | headerName: '操作', |
| | | width: 70, |
| | | lockPosition: 'left', |
| | | renderCell: (params) => ( |
| | | <Tooltip title="Delete"> |
| | | <IconButton onClick={() => handleDelete(params.row)}> |
| | | <Delete /> |
| | | </IconButton> |
| | | </Tooltip> |
| | | ), |
| | | |
| | | } |
| | | |
| | | let cdata = useRef([]); |
| | | |
| | | useEffect(() => { |
| | | getDynamicFields(); |
| | | }, []); |
| | | |
| | | useEffect(() => { |
| | | cdata.current = tabelData |
| | | }, [tabelData]); |
| | | |
| | | 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: false |
| | | })) |
| | | setColumns([...columns, ...cols, action]) |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | |
| | | |
| | | const handleDelete = (row) => { |
| | | const newData = _.filter(cdata.current, (item) => item.id !== row.id); |
| | | setTableData(newData); |
| | | }; |
| | | |
| | | |
| | | const processRowUpdate = (newRow, oldRow) => { |
| | | const rows = tabelData.map((r) => |
| | | r.id === newRow.id ? { ...newRow } : r |
| | | ) |
| | | setTableData(rows) |
| | | return newRow; |
| | | }; |
| | | |
| | | const handleSelectionChange = (ids) => { |
| | | setSelectedRows(ids) |
| | | }; |
| | | |
| | | tableRef.current = useGridApiRef(); |
| | | |
| | | return ( |
| | | <div style={{ height: 500, width: '100%' }}> |
| | | <DataGrid |
| | | apiRef={tableRef} |
| | | rows={tabelData} |
| | | columns={columns} |
| | | disableRowSelectionOnClick |
| | | getRowId={(row) => row.matnrId ? row.matnrId : row.id} |
| | | disableColumnFilter |
| | | disableColumnSelector |
| | | disableColumnSorting |
| | | disableMultipleColumnsSorting |
| | | processRowUpdate={processRowUpdate} |
| | | initialState={{ |
| | | pagination: { |
| | | paginationModel: { |
| | | pageSize: 25, |
| | | }, |
| | | }, |
| | | }} |
| | | pageSizeOptions={[10, 25, 50, 100]} |
| | | editMode="row" |
| | | checkboxSelection |
| | | onRowSelectionModelChange={handleSelectionChange} |
| | | selectionModel={selectedRows} |
| | | sx={{ |
| | | '& .MuiDataGrid-cell input': { |
| | | border: '1px solid #ccc' |
| | | }, |
| | | }} |
| | | /> |
| | | </div> |
| | | ); |
| | | }; |
| | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Api(tags = "库位信息") |
| | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping("/loc/areaNoUse/list") |
| | | public R areaNoUselist(@RequestBody Map<String, Object> map) { |
| | | List<Loc> list = locService.list(); |
| | | List<String> list1 = list.stream().map(obj -> obj.getCode()).collect(Collectors.toList()); |
| | | return R.ok(list1); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping({"/loc/many/{ids}", "/locs/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(locService.listByIds(Arrays.asList(ids))); |
| | |
| | | } |
| | | String join = StringUtils.join(param.getTypeIds(), ","); |
| | | |
| | | String[] split = warehouseAreas.getCode().split("\\."); |
| | | if (split.length == 0){ |
| | | throw new CoolException("库区编码错误!!"); |
| | | } |
| | | StringBuilder locStar = new StringBuilder(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | locStar.append(split[i]).append("-"); |
| | | } |
| | | |
| | | List<Loc> list = new ArrayList<>(); |
| | | for (int r = param.getStartRow(); r <= param.getEndRow(); r++) { |
| | | for (int b = param.getStartBay(); b <= param.getEndBay(); b++) { |
| | | for (int l = param.getStartLev(); l <= param.getEndLev(); l++) { |
| | | // 获取库位号 |
| | | String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l); |
| | | String locNo = locStar + String.format("%d", r) + String.format("-%d", b) + String.format("-%d", l); |
| | | Loc loc = new Loc(); |
| | | loc.setCode(locNo) |
| | | .setUseStatus("O") |