| | |
| | | import { Box, Card, Grid, LinearProgress, Select, MenuItem, ListItemText, Tooltip } from "@mui/material"; |
| | | import { Box, Card, Grid, LinearProgress, Select, MenuItem, ListItemText, Tooltip, IconButton } from "@mui/material"; |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | List, |
| | |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | | Toolbar, |
| | | useRecordContext, |
| | | useTranslate, |
| | | useNotify, |
| | |
| | | SimpleForm, |
| | | required, |
| | | Form, |
| | | useRefresh, |
| | | useRedirect, |
| | | } from 'react-admin'; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, DEFAULT_ITEM_PAGE_SIZE } from '@/config/setting'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import { DataGrid, useGridApiContext } from '@mui/x-data-grid'; |
| | | import { DataGrid, useGridApiContext, GridActionsCellItem, useGridApiRef } from '@mui/x-data-grid'; |
| | | import request from '@/utils/request'; |
| | | import ConfirmationNumberOutlinedIcon from '@mui/icons-material/ConfirmationNumberOutlined'; |
| | | import CloseSharpIcon from '@mui/icons-material/CloseSharp'; |
| | | import ConfirmButton from '../../components/ConfirmButton'; |
| | | import { Delete, Edit, Add } from '@mui/icons-material'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | |
| | | const OutStockPublic = (props) => { |
| | | const { record, open, setOpen } = props; |
| | | const dataGridRef = useRef(null); |
| | | const notify = useNotify(); |
| | | const gridRef = useGridApiRef(); |
| | | const [rows, setRows] = useState({}); |
| | | const translate = useTranslate(); |
| | | const [selectedIds, setSelectedIds] = React.useState([]); |
| | |
| | | [name]: value |
| | | })); |
| | | }; |
| | | |
| | | gridRef.current = useGridApiRef(); |
| | | |
| | | return ( |
| | | <> |
| | | <Box> |
| | | <Grid sx={{ display: "flex" }} container rowSpacing={2} columnSpacing={2}> |
| | | <Grid item xl={6} gap={2} > |
| | | <Grid item xl={5.7} gap={2} > |
| | | <Card> |
| | | <Form> |
| | | <ReferenceInput |
| | |
| | | empty={false} |
| | | filter={{ asnId: record?.id, deleted: 0 }} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | | <SelectColumnsButton preferenceKey='outStock' /> |
| | | )} |
| | | actions={false} |
| | | perPage={DEFAULT_ITEM_PAGE_SIZE} |
| | | > |
| | | <LinearProgress |
| | |
| | | </List> |
| | | </Card> |
| | | </Grid> |
| | | <Grid item xl={6} gap={2}> |
| | | <Grid item xl={6.3} gap={2}> |
| | | <Card> |
| | | <Box> |
| | | <Box sx={{ height: 500, width: '100%' }}> |
| | | <DataGrid |
| | | rows={rows} |
| | | columns={columns} |
| | | apiRef={gridRef} |
| | | initialState={{ |
| | | pagination: { |
| | | paginationModel: { |
| | |
| | | }, |
| | | }, |
| | | }} |
| | | ref={dataGridRef} |
| | | checkboxSelection |
| | | pageSizeOptions={[15, 25, 35, 45]} |
| | | onRowSelectionModelChange={(ids) => { |
| | | setSelectedIds(ids) |
| | | }} |
| | | pageSizeOptions={[15, 25, 35, 45]} |
| | | /> |
| | | </Box> |
| | | <Box sx={{ textAlign: 'center' }}> |
| | | <CloseButton setOpen={setOpen} /> |
| | | <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} /> |
| | | <SubmitButton selectedIds={selectedIds} setSelectedIds={setSelectedIds} gridRef={gridRef} /> |
| | | </Box> |
| | | </Card> |
| | | </Grid> |
| | |
| | | |
| | | |
| | | //提交按钮 |
| | | const SubmitButton = ({ selectedIds, setSelectedIds }) => { |
| | | const submit = () => { |
| | | if (selectedIds.length < 1) { return } |
| | | console.log(selectedIds); |
| | | const SubmitButton = ({ selectedIds, setSelectedIds, gridRef }) => { |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const redirect = useRedirect(); |
| | | const submit = async () => { |
| | | const items = gridRef.current?.getSortedRows(); |
| | | const { data: { code, data, msg } } = await request.post('/outStock/generate/tasks', { items }); |
| | | if (code == 200) { |
| | | refresh(); |
| | | redirect("/task") |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <ConfirmButton |
| | | label="toolbar.confirm" |
| | |
| | | ) |
| | | } |
| | | |
| | | |
| | | const columns = [ |
| | | { field: 'id', headerName: 'ID', width: 40 }, |
| | | { field: 'locCode', headerName: '库位', width: 110 }, |
| | | { field: 'barcode', headerName: '容器', width: 120 }, |
| | | { field: 'batch', headerName: '批次', width: 90 }, |
| | | { field: 'unit', headerName: '单位', width: 90 }, |
| | | { field: 'workQty', headerName: '本次出库数量', width: 110 }, |
| | | { field: 'outQty', headerName: '本次出库数量', width: 110 }, |
| | | { |
| | | field: 'siteNo', |
| | | headerName: '出库口', |
| | |
| | | <OutStockSite {...params} /> |
| | | ), |
| | | }, |
| | | { |
| | | field: 'actions', |
| | | type: 'actions', |
| | | headerName: '操作', |
| | | with: 120, |
| | | getActions: (params) => [ |
| | | <GridActionsCellItem |
| | | icon={<Delete />} |
| | | label="Delete" |
| | | onClick={() => handleDelete(params.row.id)} |
| | | />, |
| | | ] |
| | | }, |
| | | ] |
| | | |
| | | /** |
| | | * 删除事件 |
| | | * @param {*} params |
| | | */ |
| | | const handleDelete = (params) => { |
| | | console.log(params); |
| | | |
| | | } |
| | | |
| | | |
| | | const OutStockSiteNo = React.memo(function OutStockSiteNo(props) { |
| | | const { value } = props; |
| | | if (!value) { |