From d25c8fa670a8fea0977c85f67b13917b3bdefa89 Mon Sep 17 00:00:00 2001 From: verou <857149855@qq.com> Date: 星期五, 14 三月 2025 17:01:24 +0800 Subject: [PATCH] fix:增加datagrid --- rsf-admin/src/page/qlyInspect/QlyInspectPanel.jsx | 40 - rsf-admin/src/page/asnOrder/AsnWareModal.jsx | 306 +++----------- rsf-admin/src/page/qlyInspect/QlyInspectList.jsx | 18 rsf-admin/src/page/qlyIsptItem/QlyIsptItemList.jsx | 174 ++++++++ rsf-admin/src/page/qlyIsptItem/QlyIsptItemCreate.jsx | 190 +++++++++ rsf-admin/src/page/qlyIsptItem/index.jsx | 18 rsf-admin/src/page/qlyIsptItem/QlyIsptItemPanel.jsx | 123 ++++++ rsf-admin/src/page/qlyInspect/index.jsx | 2 rsf-admin/src/page/qlyInspect/QlyInspectCreate.jsx | 39 - rsf-admin/src/i18n/zh.js | 23 rsf-admin/src/i18n/en.js | 21 rsf-admin/src/page/ResourceContent.js | 3 rsf-admin/src/page/qlyInspect/QlyInspectEdit.jsx | 39 - rsf-admin/src/page/qlyIsptItem/QlyIsptItemEdit.jsx | 162 ++++++++ rsf-admin/src/page/asnOrder/AsnOrderModal.jsx | 16 15 files changed, 856 insertions(+), 318 deletions(-) diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js index c0a1107..4739948 100644 --- a/rsf-admin/src/i18n/en.js +++ b/rsf-admin/src/i18n/en.js @@ -367,12 +367,25 @@ }, qlyInspect: { code: "code", - name: "name", - barcode: "barcode", - asnItemId: "asnItemId", - poItemId: "poItemId", + wkType: "wkType", safeQty: "safeQty", + dlyQty: "dlyQty", + rcptQty: "rcptQty", + isptQty: "isptQty", + }, + qlyIsptItem: { + ispectId: "ispectId", + matnrCode: "matnrCode", + maktx: "maktx", + label: "label", + splrName: "splrName", + splrBatch: "splrBatch", + stockBatch: "stockBatch", + rcptQty: "rcptQty", + dlyQty: "dlyQty", disQty: "disQty", + safeQty: "safeQty", + picPath: "picPath", }, dictType: { code: "Code", diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js index 4b899fa..ab555e4 100644 --- a/rsf-admin/src/i18n/zh.js +++ b/rsf-admin/src/i18n/zh.js @@ -367,12 +367,25 @@ }, qlyInspect: { code: "缂栫爜", - name: "鍚嶇О", - barcode: "鏍囩鐮�", - asnItemId: "閫氱煡鍗曟槑缁嗘爣璇�", - poItemId: "PO鍗曟槑缁嗘爣璇�", + wkType: "wkType", safeQty: "鍚堟牸鏁伴噺", - disQty: "涓嶅悎鏍兼暟閲�", + dlyQty: "dlyQty", + rcptQty: "rcptQty", + isptQty: "isptQty", + }, + qlyIsptItem: { + ispectId: "ispectId", + matnrCode: "matnrCode", + maktx: "maktx", + label: "label", + splrName: "splrName", + splrBatch: "splrBatch", + stockBatch: "stockBatch", + rcptQty: "rcptQty", + dlyQty: "dlyQty", + disQty: "disQty", + safeQty: "safeQty", + picPath: "picPath", }, dictType: { code: "瀛楀吀缂栫爜", diff --git a/rsf-admin/src/page/ResourceContent.js b/rsf-admin/src/page/ResourceContent.js index 1c808a1..3a8765b 100644 --- a/rsf-admin/src/page/ResourceContent.js +++ b/rsf-admin/src/page/ResourceContent.js @@ -21,6 +21,7 @@ import container from './container'; import contract from './contract'; import qlyInspect from './qlyInspect'; +import qlyIsptItem from './qlyIsptItem'; import dictType from './system/dicts/dictType'; import dictData from './system/dicts/dictData'; import companys from './basicInfo/companys'; @@ -73,6 +74,8 @@ return contract; case 'qlyInspect': return qlyInspect; + case 'qlyIsptItem': + return qlyIsptItem; case 'dictType': return dictType; case 'dictData': diff --git a/rsf-admin/src/page/asnOrder/AsnOrderModal.jsx b/rsf-admin/src/page/asnOrder/AsnOrderModal.jsx index 87d0b1f..f5428f0 100644 --- a/rsf-admin/src/page/asnOrder/AsnOrderModal.jsx +++ b/rsf-admin/src/page/asnOrder/AsnOrderModal.jsx @@ -167,6 +167,8 @@ <AsnWareModal open={createDialog} setOpen={setCreateDialog} + data={tabelData} + setData={setTableData} /> </> ) @@ -287,8 +289,20 @@ <StyledTableRow key={row.id || Math.random()}> {columns.map((column) => ( <StyledTableCell key={column.id} > - {row[column.id]} + <TextField + key={row.id} + value={row[column.id]} + variant="outlined" + size="small" + sx={{ + padding: '2px', '& .MuiOutlinedInput-input': { + padding: '2px 5px', + minWidth: '50px', + } + }} + /> </StyledTableCell> + ))} </StyledTableRow> ))} diff --git a/rsf-admin/src/page/asnOrder/AsnWareModal.jsx b/rsf-admin/src/page/asnOrder/AsnWareModal.jsx index 8bd3975..d3dd744 100644 --- a/rsf-admin/src/page/asnOrder/AsnWareModal.jsx +++ b/rsf-admin/src/page/asnOrder/AsnWareModal.jsx @@ -1,24 +1,4 @@ -import React, { useState, useRef, useEffect, useMemo } from "react"; -import { - CreateBase, - useTranslate, - TextInput, - NumberInput, - BooleanInput, - DateInput, - SaveButton, - SelectInput, - ReferenceInput, - ReferenceArrayInput, - AutocompleteInput, - Toolbar, - required, - useDataProvider, - useNotify, - Form, - useCreateController, - useRefresh, -} from 'react-admin'; +import React, { useState, useEffect } from "react"; import { Dialog, DialogActions, @@ -30,32 +10,22 @@ Box, Button, Paper, - TableContainer, - Table, - TableHead, - TableBody, - TableRow, - TableCell, - Checkbox, styled - - } from '@mui/material'; import DialogCloseButton from "../components/DialogCloseButton"; -import StatusSelectInput from "../components/StatusSelectInput"; import ConfirmButton from "../components/ConfirmButton"; -import MemoInput from "../components/MemoInput"; -import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form"; -import SaveIcon from '@mui/icons-material/Save'; +import { useTranslate, useNotify, useRefresh } from 'react-admin'; import request from '@/utils/request'; +import { DataGrid } from '@mui/x-data-grid'; +import SaveIcon from '@mui/icons-material/Save'; const AsnWareModal = (props) => { - const { open, setOpen } = props; + const { open, setOpen, data, setData } = props; const translate = useTranslate(); const notify = useNotify(); const refresh = useRefresh(); - const asnId = '' + const asnId = ''; const handleClose = (event, reason) => { if (reason !== "backdropClick") { @@ -64,11 +34,11 @@ }; const [formData, setFormData] = useState({ - type: '', - wkType: '' + name: '', + code: '' }); - const [tabelData, setTableData] = useState([{ id: 1 }, { id: 2 }]); + const [tableData, setTableData] = useState([]); const [selectedRows, setSelectedRows] = useState([]); const handleChange = (e) => { @@ -80,12 +50,29 @@ }; const handleSubmit = () => { - console.log(formData); + setOpen(false); + refresh(); + const selectedData = selectedRows.map(id => tableData.find(row => row.id === id)); + setData(selectedData); }; + const getData = async () => { + const res = await request.post(`/matnr/page`, { + pageSize: 99 + }); + if (res?.data?.code === 200) { + setTableData(res.data.data.records); + } else { + notify(res.data.msg); + } + }; + useEffect(() => { + getData(); + }, []); const handleSearch = () => { + // 杩欓噷鍙互娣诲姞鎼滅储閫昏緫 }; return ( @@ -95,7 +82,7 @@ aria-labelledby="form-dialog-title" fullWidth disableRestoreFocus - maxWidth="lg" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' + maxWidth="lg" > <DialogTitle id="form-dialog-title" sx={{ position: 'sticky', @@ -113,20 +100,19 @@ <Grid container spacing={2}> <Grid item xs={4}> <TextField - label={translate('table.field.asnOrder.type')} - name="type" - value={formData.type} + label={translate('table.field.matnr.name')} + name="name" + value={formData.name} onChange={handleChange} variant="outlined" size="small" /> </Grid> - <Grid item xs={4}> <TextField - label={translate('table.field.asnOrder.wkType')} - name="wkType" - value={formData.wkType} + label={translate('table.field.matnr.code')} + name="code" + value={formData.code} onChange={handleChange} variant="outlined" size="small" @@ -134,207 +120,71 @@ </Grid> </Grid> </Box> - <Box sx={{ mt: 2 }}> <Stack direction="row" spacing={2}> <Button variant="contained" onClick={handleSearch}>鎼滅储</Button> </Stack> - </Box> - - <Box sx={{ mt: 2 }}> - <AsnWareModalTable tabelData={tabelData} setTableData={setTableData} selectedRows={selectedRows} - setSelectedRows={setSelectedRows}></AsnWareModalTable> + <Box sx={{ mt: 2, height: 400, width: '100%' }}> + <AsnWareModalTable tableData={tableData} setTableData={setTableData} + selectedRows={selectedRows} + setSelectedRows={setSelectedRows} /> </Box> </DialogContent> <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> - <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > + <Box sx={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}> <Button onClick={handleSubmit} variant="contained" startIcon={<SaveIcon />}> 纭 </Button> - </Toolbar> + </Box> </DialogActions> - - </Dialog> - ) -} + ); +}; export default AsnWareModal; -const AsnWareModalTable = ({ tabelData, setTableData }) => { +const AsnWareModalTable = ({ tableData, setTableData, selectedRows, setSelectedRows }) => { const translate = useTranslate(); - const notify = useNotify(); - const refresh = useRefresh(); - - const [selected, setSelected] = React.useState([]); const columns = [ - { - id: 'id', - label: 'ID', - minWidth: 100 - }, - { - id: 'name', - label: 'table.field.matnr.name', - minWidth: 100 - }, - { - id: 'code', - label: 'table.field.matnr.code', - minWidth: 100 - }, - { - id: 'spec', - label: 'table.field.matnr.spec', - minWidth: 100 - }, - { - id: 'model', - label: 'table.field.matnr.model', - minWidth: 100 - }, - { - id: 'weight', - label: 'table.field.matnr.weight', - minWidth: 100 - }, - { - id: 'color', - label: 'table.field.matnr.color', - minWidth: 100 - }, - { - id: 'size', - label: 'table.field.matnr.size', - minWidth: 100 - }, - { - id: 'describle', - label: 'table.field.matnr.describle', - minWidth: 100 - }, - { - id: 'nromNum', - label: 'table.field.matnr.nromNum', - minWidth: 100 - }, - { - id: 'unit', - label: 'table.field.matnr.unit', - minWidth: 100 - }, - { - id: 'purchaseUnit', - label: 'table.field.matnr.purUnit', - minWidth: 100 - }, - { - id: 'stockUnit', - label: 'table.field.matnr.stockUnit', - minWidth: 100 - }, - { - id: 'stockLeval$', - label: 'table.field.matnr.stockLevel', - minWidth: 100, - sortable: false - }, - - + { field: 'id', headerName: 'ID', width: 100 }, + { field: 'name', headerName: translate('table.field.matnr.name'), width: 100 }, + { field: 'code', headerName: translate('table.field.matnr.code'), width: 100 }, + { field: 'spec', headerName: translate('table.field.matnr.spec'), width: 100 }, + { field: 'model', headerName: translate('table.field.matnr.model'), width: 100 }, + { field: 'weight', headerName: translate('table.field.matnr.weight'), width: 100 }, + { field: 'color', headerName: translate('table.field.matnr.color'), width: 100 }, + { field: 'size', headerName: translate('table.field.matnr.size'), width: 100 }, + { field: 'describle', headerName: translate('table.field.matnr.describle'), width: 100 }, + { field: 'nromNum', headerName: translate('table.field.matnr.nromNum'), width: 100 }, + { field: 'unit', headerName: translate('table.field.matnr.unit'), width: 100 }, + { field: 'purchaseUnit', headerName: translate('table.field.matnr.purUnit'), width: 100 }, + { field: 'stockUnit', headerName: translate('table.field.matnr.stockUnit'), width: 100 }, + { field: 'stockLeval$', headerName: translate('table.field.matnr.stockLevel'), width: 100, sortable: false }, ]; - const StyledTableRow = styled(TableRow)(({ theme }) => ({ - "& .MuiButtonBase-root.": { - padding: "0px 0px", - }, - })); - - const StyledTableCell = styled(TableCell)(({ theme }) => ({ - "& .MuiButtonBase-root": { - padding: "0px 0px", - }, - overflow: "hidden", - textOverflow: "ellipsis", - whiteSpace: "nowrap", - maxWidth: 600, - })); - - const handleClick = (event, id) => { - const selectedIndex = selected.indexOf(id); - let newSelected = []; - - if (selectedIndex === -1) { - newSelected = newSelected.concat(selected, id); - } else if (selectedIndex === 0) { - newSelected = newSelected.concat(selected.slice(1)); - } else if (selectedIndex === selected.length - 1) { - newSelected = newSelected.concat(selected.slice(0, -1)); - } else if (selectedIndex > 0) { - newSelected = newSelected.concat( - selected.slice(0, selectedIndex), - selected.slice(selectedIndex + 1), - ); - } - setSelected(newSelected); + const handleSelectionChange = (ids) => { + const selectedData = ids.map((id) => tableData.find((row) => row.id === id)); + // setSelectedRows(selectedData); + // setSelectedRows(ids); + console.log(selectedData) }; - // const handleSelectAllClick = (event) => { - // if (event.target.checked) { - // const newSelected = tabelData.map((n) => n.id); - // setSelected(newSelected); - // return; - // } - // setSelected([]); - // }; - return ( - <TableContainer component={Paper} > - <Table size="small" > - <TableHead> - <StyledTableRow key={'head'}> - <TableCell padding="checkbox"> - <Checkbox - color="primary" - /> - </TableCell> - {columns.map((column) => { - const value = column.label; - return ( - <StyledTableCell - key={column.id} - align={column.align || "left"} - > - {column.format ? column.format(value) : translate(value)} - </StyledTableCell> - ); - - })} - </StyledTableRow> - </TableHead> - - <TableBody> - - {tabelData.map((row) => { - const isItemSelected = selected.includes(row.id); - return (<StyledTableRow key={row.id || Math.random()} aria-checked={isItemSelected} selected={isItemSelected} onClick={(event) => handleClick(event, row.id)}> - <TableCell padding="checkbox"> - <Checkbox - color="primary" - checked={isItemSelected} - /> - </TableCell> - {columns.map((column) => ( - <StyledTableCell key={column.id} > - {row[column.id]} - </StyledTableCell> - ))} - </StyledTableRow>) - })} - - </TableBody> - </Table> - </TableContainer> - ) -} + <div style={{ height: 400, width: '100%' }}> + <DataGrid + size="small" + rows={tableData} + columns={columns} + checkboxSelection + onRowSelectionModelChange={handleSelectionChange} + selectionModel={selectedRows} + disableColumnMenu={true} + disableColumnSorting + disableMultipleColumnsSorting + autoPageSize + /> + </div> + ); +}; \ No newline at end of file diff --git a/rsf-admin/src/page/qlyInspect/QlyInspectCreate.jsx b/rsf-admin/src/page/qlyInspect/QlyInspectCreate.jsx index 4aa684f..dca01a0 100644 --- a/rsf-admin/src/page/qlyInspect/QlyInspectCreate.jsx +++ b/rsf-admin/src/page/qlyInspect/QlyInspectCreate.jsx @@ -95,28 +95,9 @@ </Grid> <Grid item xs={6} display="flex" gap={1}> <TextInput - label="table.field.qlyInspect.name" - source="name" + label="table.field.qlyInspect.wkType" + source="wkType" parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <TextInput - label="table.field.qlyInspect.barcode" - source="barcode" - parse={v => v} - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.qlyInspect.asnItemId" - source="asnItemId" - /> - </Grid> - <Grid item xs={6} display="flex" gap={1}> - <NumberInput - label="table.field.qlyInspect.poItemId" - source="poItemId" /> </Grid> <Grid item xs={6} display="flex" gap={1}> @@ -127,8 +108,20 @@ </Grid> <Grid item xs={6} display="flex" gap={1}> <NumberInput - label="table.field.qlyInspect.disQty" - source="disQty" + label="table.field.qlyInspect.dlyQty" + source="dlyQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyInspect.rcptQty" + source="rcptQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyInspect.isptQty" + source="isptQty" /> </Grid> diff --git a/rsf-admin/src/page/qlyInspect/QlyInspectEdit.jsx b/rsf-admin/src/page/qlyInspect/QlyInspectEdit.jsx index 985c367..2b4e951 100644 --- a/rsf-admin/src/page/qlyInspect/QlyInspectEdit.jsx +++ b/rsf-admin/src/page/qlyInspect/QlyInspectEdit.jsx @@ -74,28 +74,9 @@ </Stack> <Stack direction='row' gap={2}> <TextInput - label="table.field.qlyInspect.name" - source="name" + label="table.field.qlyInspect.wkType" + source="wkType" parse={v => v} - /> - </Stack> - <Stack direction='row' gap={2}> - <TextInput - label="table.field.qlyInspect.barcode" - source="barcode" - parse={v => v} - /> - </Stack> - <Stack direction='row' gap={2}> - <NumberInput - label="table.field.qlyInspect.asnItemId" - source="asnItemId" - /> - </Stack> - <Stack direction='row' gap={2}> - <NumberInput - label="table.field.qlyInspect.poItemId" - source="poItemId" /> </Stack> <Stack direction='row' gap={2}> @@ -106,8 +87,20 @@ </Stack> <Stack direction='row' gap={2}> <NumberInput - label="table.field.qlyInspect.disQty" - source="disQty" + label="table.field.qlyInspect.dlyQty" + source="dlyQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyInspect.rcptQty" + source="rcptQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyInspect.isptQty" + source="isptQty" /> </Stack> diff --git a/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx b/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx index 10bda0b..d1fa634 100644 --- a/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx +++ b/rsf-admin/src/page/qlyInspect/QlyInspectList.jsx @@ -64,12 +64,11 @@ <DateInput label='common.time.before' source="timeEnd" alwaysOn />, <TextInput source="code" label="table.field.qlyInspect.code" />, - <TextInput source="name" label="table.field.qlyInspect.name" />, - <TextInput source="barcode" label="table.field.qlyInspect.barcode" />, - <NumberInput source="asnItemId" label="table.field.qlyInspect.asnItemId" />, - <NumberInput source="poItemId" label="table.field.qlyInspect.poItemId" />, + <TextInput source="wkType" label="table.field.qlyInspect.wkType" />, <NumberInput source="safeQty" label="table.field.qlyInspect.safeQty" />, - <NumberInput source="disQty" label="table.field.qlyInspect.disQty" />, + <NumberInput source="dlyQty" label="table.field.qlyInspect.dlyQty" />, + <NumberInput source="rcptQty" label="table.field.qlyInspect.rcptQty" />, + <NumberInput source="isptQty" label="table.field.qlyInspect.isptQty" />, <TextInput label="common.field.memo" source="memo" />, <SelectInput @@ -124,12 +123,11 @@ > <NumberField source="id" /> <TextField source="code" label="table.field.qlyInspect.code" /> - <TextField source="name" label="table.field.qlyInspect.name" /> - <TextField source="barcode" label="table.field.qlyInspect.barcode" /> - <NumberField source="asnItemId" label="table.field.qlyInspect.asnItemId" /> - <NumberField source="poItemId" label="table.field.qlyInspect.poItemId" /> + <TextField source="wkType" label="table.field.qlyInspect.wkType" /> <NumberField source="safeQty" label="table.field.qlyInspect.safeQty" /> - <NumberField source="disQty" label="table.field.qlyInspect.disQty" /> + <NumberField source="dlyQty" label="table.field.qlyInspect.dlyQty" /> + <NumberField source="rcptQty" label="table.field.qlyInspect.rcptQty" /> + <NumberField source="isptQty" label="table.field.qlyInspect.isptQty" /> <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> <TextField source="nickname" /> diff --git a/rsf-admin/src/page/qlyInspect/QlyInspectPanel.jsx b/rsf-admin/src/page/qlyInspect/QlyInspectPanel.jsx index 785ba88..a66c697 100644 --- a/rsf-admin/src/page/qlyInspect/QlyInspectPanel.jsx +++ b/rsf-admin/src/page/qlyInspect/QlyInspectPanel.jsx @@ -23,7 +23,7 @@ overflow: 'hidden', textOverflow: 'ellipsis', }}> - {Common.camelToPascalWithSpaces(translate('table.field.qlyInspect.name'))}: {record.name} + {Common.camelToPascalWithSpaces(translate('table.field.qlyInspect.id'))}: {record.id} </Typography> {/* inherit, primary, secondary, textPrimary, textSecondary, error */} <Typography variant="h6" gutterBottom align="right" > @@ -48,26 +48,8 @@ </Grid> <Grid item xs={6}> <PanelTypography - title="table.field.qlyInspect.name" - property={record.name} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.qlyInspect.barcode" - property={record.barcode} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.qlyInspect.asnItemId" - property={record.asnItemId} - /> - </Grid> - <Grid item xs={6}> - <PanelTypography - title="table.field.qlyInspect.poItemId" - property={record.poItemId} + title="table.field.qlyInspect.wkType" + property={record.wkType} /> </Grid> <Grid item xs={6}> @@ -78,8 +60,20 @@ </Grid> <Grid item xs={6}> <PanelTypography - title="table.field.qlyInspect.disQty" - property={record.disQty} + title="table.field.qlyInspect.dlyQty" + property={record.dlyQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyInspect.rcptQty" + property={record.rcptQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyInspect.isptQty" + property={record.isptQty} /> </Grid> diff --git a/rsf-admin/src/page/qlyInspect/index.jsx b/rsf-admin/src/page/qlyInspect/index.jsx index a4add54..7973dcf 100644 --- a/rsf-admin/src/page/qlyInspect/index.jsx +++ b/rsf-admin/src/page/qlyInspect/index.jsx @@ -13,6 +13,6 @@ edit: QlyInspectEdit, show: ShowGuesser, recordRepresentation: (record) => { - return `${record.name}` + return `${record.id}` } }; diff --git a/rsf-admin/src/page/qlyIsptItem/QlyIsptItemCreate.jsx b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemCreate.jsx new file mode 100644 index 0000000..8517b34 --- /dev/null +++ b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemCreate.jsx @@ -0,0 +1,190 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + CreateBase, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SaveButton, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + Toolbar, + required, + useDataProvider, + useNotify, + Form, + useCreateController, +} from 'react-admin'; +import { + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Stack, + Grid, + Box, +} from '@mui/material'; +import DialogCloseButton from "../components/DialogCloseButton"; +import StatusSelectInput from "../components/StatusSelectInput"; +import MemoInput from "../components/MemoInput"; + +const QlyIsptItemCreate = (props) => { + const { open, setOpen } = props; + + const translate = useTranslate(); + const notify = useNotify(); + + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + + const handleSuccess = async (data) => { + setOpen(false); + notify('common.response.success'); + }; + + const handleError = async (error) => { + notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); + }; + + return ( + <> + <CreateBase + record={{}} + transform={(data) => { + return data; + }} + mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} + > + <Dialog + open={open} + onClose={handleClose} + aria-labelledby="form-dialog-title" + fullWidth + disableRestoreFocus + maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' + > + <Form> + <DialogTitle id="form-dialog-title" sx={{ + position: 'sticky', + top: 0, + backgroundColor: 'background.paper', + zIndex: 1000 + }} + > + {translate('create.title')} + <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> + <DialogCloseButton onClose={handleClose} /> + </Box> + </DialogTitle> + <DialogContent sx={{ mt: 2 }}> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyIsptItem.ispectId" + source="ispectId" + autoFocus + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.matnrCode" + source="matnrCode" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.maktx" + source="maktx" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.label" + source="label" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.splrName" + source="splrName" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.splrBatch" + source="splrBatch" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.stockBatch" + source="stockBatch" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyIsptItem.rcptQty" + source="rcptQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyIsptItem.dlyQty" + source="dlyQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyIsptItem.disQty" + source="disQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.qlyIsptItem.safeQty" + source="safeQty" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.qlyIsptItem.picPath" + source="picPath" + parse={v => v} + /> + </Grid> + + <Grid item xs={6} display="flex" gap={1}> + <StatusSelectInput /> + </Grid> + <Grid item xs={12} display="flex" gap={1}> + <Stack direction="column" spacing={1} width={'100%'}> + <MemoInput /> + </Stack> + </Grid> + </Grid> + </DialogContent> + <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> + <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > + <SaveButton /> + </Toolbar> + </DialogActions> + </Form> + </Dialog> + </CreateBase> + </> + ) +} + +export default QlyIsptItemCreate; diff --git a/rsf-admin/src/page/qlyIsptItem/QlyIsptItemEdit.jsx b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemEdit.jsx new file mode 100644 index 0000000..43944ab --- /dev/null +++ b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemEdit.jsx @@ -0,0 +1,162 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + Edit, + SimpleForm, + FormDataConsumer, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + SaveButton, + Toolbar, + Labeled, + NumberField, + required, + useRecordContext, + DeleteButton, +} from 'react-admin'; +import { useWatch, useFormContext } from "react-hook-form"; +import { Stack, Grid, Box, Typography } from '@mui/material'; +import * as Common from '@/utils/common'; +import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; +import EditBaseAside from "../components/EditBaseAside"; +import CustomerTopToolBar from "../components/EditTopToolBar"; +import MemoInput from "../components/MemoInput"; +import StatusSelectInput from "../components/StatusSelectInput"; + +const FormToolbar = () => { + const { getValues } = useFormContext(); + + return ( + <Toolbar sx={{ justifyContent: 'space-between' }}> + <SaveButton /> + <DeleteButton mutationMode="optimistic" /> + </Toolbar> + ) +} + +const QlyIsptItemEdit = () => { + const translate = useTranslate(); + + return ( + <Edit + redirect="list" + mutationMode={EDIT_MODE} + actions={<CustomerTopToolBar />} + aside={<EditBaseAside />} + > + <SimpleForm + shouldUnregister + warnWhenUnsavedChanges + toolbar={<FormToolbar />} + mode="onTouched" + defaultValues={{}} + // validate={(values) => { }} + > + <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> + <Grid item xs={12} md={8}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.main')} + </Typography> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyIsptItem.ispectId" + source="ispectId" + autoFocus + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.matnrCode" + source="matnrCode" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.maktx" + source="maktx" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.label" + source="label" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.splrName" + source="splrName" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.splrBatch" + source="splrBatch" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.stockBatch" + source="stockBatch" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyIsptItem.rcptQty" + source="rcptQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyIsptItem.dlyQty" + source="dlyQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyIsptItem.disQty" + source="disQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.qlyIsptItem.safeQty" + source="safeQty" + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.qlyIsptItem.picPath" + source="picPath" + parse={v => v} + /> + </Stack> + + </Grid> + <Grid item xs={12} md={4}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.common')} + </Typography> + <StatusSelectInput /> + <Box mt="2em" /> + <MemoInput /> + </Grid> + </Grid> + </SimpleForm> + </Edit > + ) +} + +export default QlyIsptItemEdit; diff --git a/rsf-admin/src/page/qlyIsptItem/QlyIsptItemList.jsx b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemList.jsx new file mode 100644 index 0000000..ae7a557 --- /dev/null +++ b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemList.jsx @@ -0,0 +1,174 @@ +import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; +import { useNavigate } from 'react-router-dom'; +import { + List, + DatagridConfigurable, + SearchInput, + TopToolbar, + SelectColumnsButton, + EditButton, + FilterButton, + CreateButton, + ExportButton, + BulkDeleteButton, + WrapperField, + useRecordContext, + useTranslate, + useNotify, + useListContext, + FunctionField, + TextField, + NumberField, + DateField, + BooleanField, + ReferenceField, + TextInput, + DateTimeInput, + DateInput, + SelectInput, + NumberInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + DeleteButton, +} from 'react-admin'; +import { Box, Typography, Card, Stack } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import QlyIsptItemCreate from "./QlyIsptItemCreate"; +import QlyIsptItemPanel from "./QlyIsptItemPanel"; +import EmptyData from "../components/EmptyData"; +import MyCreateButton from "../components/MyCreateButton"; +import MyExportButton from '../components/MyExportButton'; +import PageDrawer from "../components/PageDrawer"; +import MyField from "../components/MyField"; +import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; +import * as Common from '@/utils/common'; + +const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ + '& .css-1vooibu-MuiSvgIcon-root': { + height: '.9em' + }, + '& .RaDatagrid-row': { + cursor: 'auto' + }, + '& .column-name': { + }, + '& .opt': { + width: 200 + }, +})); + +const filters = [ + <SearchInput source="condition" alwaysOn />, + <DateInput label='common.time.after' source="timeStart" alwaysOn />, + <DateInput label='common.time.before' source="timeEnd" alwaysOn />, + + <NumberInput source="ispectId" label="table.field.qlyIsptItem.ispectId" />, + <TextInput source="matnrCode" label="table.field.qlyIsptItem.matnrCode" />, + <TextInput source="maktx" label="table.field.qlyIsptItem.maktx" />, + <TextInput source="label" label="table.field.qlyIsptItem.label" />, + <TextInput source="splrName" label="table.field.qlyIsptItem.splrName" />, + <TextInput source="splrBatch" label="table.field.qlyIsptItem.splrBatch" />, + <TextInput source="stockBatch" label="table.field.qlyIsptItem.stockBatch" />, + <NumberInput source="rcptQty" label="table.field.qlyIsptItem.rcptQty" />, + <NumberInput source="dlyQty" label="table.field.qlyIsptItem.dlyQty" />, + <NumberInput source="disQty" label="table.field.qlyIsptItem.disQty" />, + <NumberInput source="safeQty" label="table.field.qlyIsptItem.safeQty" />, + <TextInput source="picPath" label="table.field.qlyIsptItem.picPath" />, + + <TextInput label="common.field.memo" source="memo" />, + <SelectInput + label="common.field.status" + source="status" + choices={[ + { id: '1', name: 'common.enums.statusTrue' }, + { id: '0', name: 'common.enums.statusFalse' }, + ]} + resettable + />, +] + +const QlyIsptItemList = () => { + const translate = useTranslate(); + + const [createDialog, setCreateDialog] = useState(false); + const [drawerVal, setDrawerVal] = useState(false); + + return ( + <Box display="flex"> + <List + sx={{ + flexGrow: 1, + transition: (theme) => + theme.transitions.create(['all'], { + duration: theme.transitions.duration.enteringScreen, + }), + marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + }} + title={"menu.qlyIsptItem"} + empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} + filters={filters} + sort={{ field: "create_time", order: "desc" }} + actions={( + <TopToolbar> + <FilterButton /> + <MyCreateButton onClick={() => { setCreateDialog(true) }} /> + <SelectColumnsButton preferenceKey='qlyIsptItem' /> + <MyExportButton /> + </TopToolbar> + )} + perPage={DEFAULT_PAGE_SIZE} + > + <StyledDatagrid + preferenceKey='qlyIsptItem' + bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} + rowClick={(id, resource, record) => false} + expand={() => <QlyIsptItemPanel />} + expandSingle={true} + omit={['id', 'createTime', 'createBy', 'memo']} + > + <NumberField source="id" /> + <NumberField source="ispectId" label="table.field.qlyIsptItem.ispectId" /> + <TextField source="matnrCode" label="table.field.qlyIsptItem.matnrCode" /> + <TextField source="maktx" label="table.field.qlyIsptItem.maktx" /> + <TextField source="label" label="table.field.qlyIsptItem.label" /> + <TextField source="splrName" label="table.field.qlyIsptItem.splrName" /> + <TextField source="splrBatch" label="table.field.qlyIsptItem.splrBatch" /> + <TextField source="stockBatch" label="table.field.qlyIsptItem.stockBatch" /> + <NumberField source="rcptQty" label="table.field.qlyIsptItem.rcptQty" /> + <NumberField source="dlyQty" label="table.field.qlyIsptItem.dlyQty" /> + <NumberField source="disQty" label="table.field.qlyIsptItem.disQty" /> + <NumberField source="safeQty" label="table.field.qlyIsptItem.safeQty" /> + <TextField source="picPath" label="table.field.qlyIsptItem.picPath" /> + + <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> + <TextField source="nickname" /> + </ReferenceField> + <DateField source="updateTime" label="common.field.updateTime" showTime /> + <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> + <TextField source="nickname" /> + </ReferenceField> + <DateField source="createTime" label="common.field.createTime" showTime /> + <BooleanField source="statusBool" label="common.field.status" sortable={false} /> + <TextField source="memo" label="common.field.memo" sortable={false} /> + <WrapperField cellClassName="opt" label="common.field.opt"> + <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> + <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> + </WrapperField> + </StyledDatagrid> + </List> + <QlyIsptItemCreate + open={createDialog} + setOpen={setCreateDialog} + /> + <PageDrawer + title='QlyIsptItem Detail' + drawerVal={drawerVal} + setDrawerVal={setDrawerVal} + > + </PageDrawer> + </Box> + ) +} + +export default QlyIsptItemList; diff --git a/rsf-admin/src/page/qlyIsptItem/QlyIsptItemPanel.jsx b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemPanel.jsx new file mode 100644 index 0000000..b769c14 --- /dev/null +++ b/rsf-admin/src/page/qlyIsptItem/QlyIsptItemPanel.jsx @@ -0,0 +1,123 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; +import { + useTranslate, + useRecordContext, +} from 'react-admin'; +import PanelTypography from "../components/PanelTypography"; +import * as Common from '@/utils/common' + +const QlyIsptItemPanel = () => { + 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.qlyIsptItem.id'))}: {record.id} + </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.qlyIsptItem.ispectId" + property={record.ispectId} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.matnrCode" + property={record.matnrCode} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.maktx" + property={record.maktx} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.label" + property={record.label} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.splrName" + property={record.splrName} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.splrBatch" + property={record.splrBatch} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.stockBatch" + property={record.stockBatch} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.rcptQty" + property={record.rcptQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.dlyQty" + property={record.dlyQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.disQty" + property={record.disQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.safeQty" + property={record.safeQty} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.qlyIsptItem.picPath" + property={record.picPath} + /> + </Grid> + + </Grid> + </CardContent> + </Card > + </> + ); +}; + +export default QlyIsptItemPanel; diff --git a/rsf-admin/src/page/qlyIsptItem/index.jsx b/rsf-admin/src/page/qlyIsptItem/index.jsx new file mode 100644 index 0000000..64dff1e --- /dev/null +++ b/rsf-admin/src/page/qlyIsptItem/index.jsx @@ -0,0 +1,18 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + ListGuesser, + EditGuesser, + ShowGuesser, +} from "react-admin"; + +import QlyIsptItemList from "./QlyIsptItemList"; +import QlyIsptItemEdit from "./QlyIsptItemEdit"; + +export default { + list: QlyIsptItemList, + edit: QlyIsptItemEdit, + show: ShowGuesser, + recordRepresentation: (record) => { + return `${record.id}` + } +}; -- Gitblit v1.9.1