From 03faa035cda5bdc060095b9a2a2b9e8fae5aed09 Mon Sep 17 00:00:00 2001 From: verou <857149855@qq.com> Date: 星期三, 09 四月 2025 15:34:46 +0800 Subject: [PATCH] fix:收货单增加字段 --- rsf-admin/src/page/asnOrder/AsnOrderPanel.jsx | 326 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 224 insertions(+), 102 deletions(-) diff --git a/rsf-admin/src/page/asnOrder/AsnOrderPanel.jsx b/rsf-admin/src/page/asnOrder/AsnOrderPanel.jsx index b9814df..3a6c137 100644 --- a/rsf-admin/src/page/asnOrder/AsnOrderPanel.jsx +++ b/rsf-admin/src/page/asnOrder/AsnOrderPanel.jsx @@ -1,117 +1,239 @@ import React, { useState, useRef, useEffect, useMemo } from "react"; -import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; +import { Box, Card, CardContent, Grid, Typography, Button, TextField, Tooltip, Paper, TableContainer, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material'; import { useTranslate, useRecordContext, + useNotify, + useRefresh, + useListContext, } from 'react-admin'; import PanelTypography from "../components/PanelTypography"; import * as Common from '@/utils/common' - -const AsnOrderPanel = () => { +import { styled } from "@mui/material/styles"; +import request from '@/utils/request'; +import debounce from 'lodash/debounce'; +import { DataGrid } from '@mui/x-data-grid'; +import PrintModal from './PrintModal'; +import PrintIcon from '@mui/icons-material/Print'; +const AsnOrderPanel = ({ billReload }) => { const record = useRecordContext(); if (!record) return null; const translate = useTranslate(); - return ( - <> - <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> - <CardContent> - <Grid container spacing={2}> - <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> - <Typography variant="h6" gutterBottom align="left" sx={{ - maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, - whiteSpace: 'nowrap', - overflow: 'hidden', - textOverflow: 'ellipsis', - }}> - {Common.camelToPascalWithSpaces(translate('table.field.asnOrder.name'))}: {record.name} - </Typography> - {/* inherit, primary, secondary, textPrimary, textSecondary, error */} - <Typography variant="h6" gutterBottom align="right" > - ID: {record.id} - </Typography> - </Grid> - </Grid> - <Grid container spacing={2}> - <Grid item xs={12} container alignContent="flex-end"> - <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> - {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} - </Typography> - </Grid> - </Grid> - <Box height={20}> </Box> - <Grid container spacing={2}> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.code" - property={record.code} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.poCode" - property={record.poCode} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.poId" - property={record.poId} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.type" - property={record.type} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.wkType" - property={record.wkType} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.anfme" - property={record.anfme} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.qty" - property={record.qty} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.logisNo" - property={record.logisNo} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.arrTime" - property={record.arrTime$} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.rleStatus" - property={record.rleStatus$} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.asnOrder.name" - property={record.name} - /> - </Grid> + const notify = useNotify(); + const [rows, setRows] = useState([]); + const [maktx, setMaktx] = useState(''); + const asnId = record.id; - </Grid> - </CardContent> - </Card > - </> + useEffect(() => { + debouncedHttp({ maktx }); + }, [asnId, maktx]); + + const http = async (parmas) => { + const res = await request.post('/asnOrderItem/page', { ...parmas, asnId }); + if (res?.data?.code === 200) { + setRows(res.data.data.records) + } else { + notify(res.data.msg); + } + } + + + useEffect(() => { + billReload.current = http + }, []); + + + const debouncedHttp = useMemo(() => debounce(http, 300), []); + + const columns = [ + { + field: 'asnId', + headerName: translate('table.field.asnOrderItem.asnId') + }, + { + field: 'asnCode', + headerName: translate('table.field.asnOrderItem.asnCode'), + width: 150, + }, + { + field: 'poDetlId', + headerName: translate('table.field.asnOrderItem.poDetlId') + }, + { + field: 'poDetlCode', + headerName: translate('table.field.asnOrderItem.poDetlCode') + }, + { + field: 'matnrCode', + headerName: translate('table.field.asnOrderItem.matnrCode'), + width: 150, + }, + { + field: 'maktx', + headerName: translate('table.field.asnOrderItem.maktx'), + width: 200, + }, + { + field: 'anfme', + headerName: translate('table.field.asnOrderItem.purQty') + }, + { + field: 'stockUnit', + headerName: translate('table.field.asnOrderItem.stockUnit') + }, + // { + // field: 'purQty', + // headerName: translate('table.field.asnOrderItem.purQty') + // }, + { + field: 'purUnit', + headerName: translate('table.field.asnOrderItem.purUnit') + }, + { + field: 'qty', + headerName: translate('table.field.asnOrderItem.qty') + }, + { + field: 'splrBatch', + headerName: translate('table.field.asnOrderItem.splrBatch') + }, + { + field: 'splrCode', + headerName: translate('table.field.asnOrderItem.splrCode') + }, + { + field: 'splrName', + headerName: translate('table.field.asnOrderItem.splrName') + }, + { + field: 'trackCode', + headerName: translate('table.field.asnOrderItem.barcode'), + width: 150 + }, + { + field: 'prodTime', + headerName: translate('table.field.asnOrderItem.prodTime') + }, + { + field: 'packName', + headerName: translate('table.field.asnOrderItem.packName') + }, + { + field: 'action', + headerName: '鎿嶄綔', + width: 70, + lockPosition: 'left', + renderCell: (params) => ( + <PrintButton rows={[params.row.id]} /> + ), + + },] + + const [selectedRows, setSelectedRows] = useState([]); + + const handleSelectionChange = (ids) => { + setSelectedRows(ids) + + }; + const maktxChange = (value) => { + setMaktx(value) + } + + + return ( + <Box sx={{ + position: 'relative', + padding: '5px 10px' + }}> + <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '4px', alignItems: 'center' }}> + <TextField value={maktx} onChange={(e) => maktxChange(e.target.value)} label="鎼滅储鐗╂枡" sx={{ width: '300px' }} size="small" /> + + <div style={{ display: 'flex', gap: '10px' }}> + <PrintsButton rows={selectedRows} /> + </div> + </div> + + + <DataGrid + sx={{ width: 'calc(100vw - 280px)' }} + size="small" + rows={rows} + columns={columns} + disableRowSelectionOnClick + checkboxSelection + onRowSelectionModelChange={handleSelectionChange} + selectionModel={selectedRows} + disableColumnMenu={true} + disableColumnSorting + disableMultipleColumnsSorting + columnHeaderHeight={40} + rowHeight={42} + initialState={{ + pagination: { + paginationModel: { + pageSize: 10, + }, + }, + }} + pageSizeOptions={[10, 25, 50]} + /> + </Box > + ); }; export default AsnOrderPanel; + +const PrintsButton = ({ rows }) => { + const record = useRecordContext(); + const { resource, selectedIds } = useListContext(); + const notify = useNotify(); + const refresh = useRefresh(); + const translate = useTranslate(); + + const [createDialog, setCreateDialog] = useState(false); + + const modalChange = () => { + if (rows?.length === 0) { + notify('璇烽�夋嫨鐗╂枡'); + return; + } else { + setCreateDialog(true) + } + + } + + return ( + <> + <Button size="small" color="secondary" onClick={modalChange} startIcon={<PrintIcon />}>{translate("toolbar.batchPrint")}</Button> + + <PrintModal + open={createDialog} + setOpen={setCreateDialog} + rows={rows} + /> + </> + ) +} + +const PrintButton = ({ rows }) => { + const record = useRecordContext(); + + const notify = useNotify(); + const refresh = useRefresh(); + + const [createDialog, setCreateDialog] = useState(false); + const translate = useTranslate(); + + return ( + <> + <Button size="small" color="secondary" onClick={() => setCreateDialog(true)} startIcon={<PrintIcon />}>{translate("toolbar.print")}</Button> + + <PrintModal + open={createDialog} + setOpen={setCreateDialog} + rows={rows} + /> + </> + ) +} -- Gitblit v1.9.1