From 02a262e542e970efe0ffb78e4d9d1e0cbbb1845e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 26 九月 2024 13:36:18 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/page/jam/JamList.jsx | 84 ++++++++++++++++++++++++++++++++++-------
1 files changed, 69 insertions(+), 15 deletions(-)
diff --git a/zy-acs-flow/src/page/jam/JamList.jsx b/zy-acs-flow/src/page/jam/JamList.jsx
index b8b77ec..0ab7c11 100644
--- a/zy-acs-flow/src/page/jam/JamList.jsx
+++ b/zy-acs-flow/src/page/jam/JamList.jsx
@@ -30,6 +30,9 @@
ReferenceArrayInput,
AutocompleteInput,
DeleteButton,
+ FunctionField,
+ useNotify,
+ useRefresh,
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { styled } from '@mui/material/styles';
@@ -42,6 +45,9 @@
import MyField from "../components/MyField";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
+import ConfirmButton from "../components/ConfirmButton";
+import CloseIcon from '@mui/icons-material/Close';
+import request from '@/utils/request';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
'& .css-1vooibu-MuiSvgIcon-root': {
@@ -109,11 +115,33 @@
/>,
]
+const states = [
+ { id: 'RUNNING', name: 'page.jam.enums.state.running' },
+ { id: 'FINISH', name: 'page.jam.enums.state.finish' },
+ { id: 'FAIL', name: 'page.jam.enums.state.fail' },
+ { id: 'DEPRECATED', name: 'page.jam.enums.state.deprecated' },
+];
+
const JamList = () => {
const translate = useTranslate();
-
+ const notify = useNotify();
+ const refresh = useRefresh();
const [createDialog, setCreateDialog] = useState(false);
const [drawerVal, setDrawerVal] = useState(false);
+
+ const onDeprecated = (jamId) => {
+ request.get("/jam/deprecated/" + jamId).then(res => {
+ const { code, msg, data } = res.data;
+ if (code === 200) {
+ notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } });
+ refresh();
+ } else {
+ notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } });
+ }
+ }).catch(error => {
+ notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
+ })
+ }
return (
<Box display="flex">
@@ -144,21 +172,28 @@
preferenceKey='jam'
bulkActionButtons={false}
rowClick={(id, resource, record) => false}
- expand={() => <JamPanel />}
- expandSingle={true}
+ // expand={() => <JamPanel />}
+ // expandSingle={true}
omit={['id', 'uuid', 'cycleCode', 'updateBy', 'updateTime', 'createTime', 'createBy', 'statusBool', 'memo']}
>
<NumberField source="id" />
<TextField source="uuid" label="table.field.jam.uuid" />
{/* <TextField source="name" label="table.field.jam.name" /> */}
+ <ReferenceField source="jamSeg" label="table.field.jam.jamSeg" reference="segment" link={false} sortable={false}>
+ <FunctionField render={(record) => {
+ return <>{record.groupId} - ({record.serial})</>
+ }} />
+ </ReferenceField>
<ReferenceField source="jamAgv" label="table.field.jam.jamAgv" reference="agv" link={false} sortable={false} >
<TextField source="uuid" sx={{ fontWeight: 'bold' }} />
</ReferenceField>
<ReferenceField source="jamCode" label="table.field.jam.jamCode" reference="code" link={false} sortable={false}>
<TextField source="data" />
</ReferenceField>
- <ReferenceField source="jamSeg" label="table.field.jam.jamSeg" reference="segment" link={false} sortable={false}>
- <TextField source="id" />
+ <ReferenceField source="avoSeg" label="table.field.jam.avoSeg" reference="segment" link={false} sortable={false}>
+ <FunctionField render={(record) => {
+ return <>{record.groupId} - ({record.serial})</>
+ }} />
</ReferenceField>
<ReferenceField source="avoAgv" label="table.field.jam.avoAgv" reference="agv" link={false} sortable={false}>
<TextField source="uuid" sx={{ fontWeight: 'bold' }} />
@@ -166,10 +201,7 @@
<ReferenceField source="avoCode" label="table.field.jam.avoCode" reference="code" link={false} sortable={false}>
<TextField source="data" />
</ReferenceField>
- <ReferenceField source="avoSeg" label="table.field.jam.avoSeg" reference="segment" link={false} sortable={false}>
- <TextField source="id" />
- </ReferenceField>
- <BooleanField source="cycleAvoBool" label="table.field.jam.cycleAvo" />
+ <BooleanField source="cycleAvoBool" label="table.field.jam.cycleAvo" sortable={false} />
<ReferenceField source="cycleCode" label="table.field.jam.cycleCode" reference="code" link={false} sortable={false}>
<TextField source="data" />
</ReferenceField>
@@ -177,8 +209,11 @@
<DateField source="notifyTime" label="table.field.jam.notifyTime" showTime />
<DateField source="endTime" label="table.field.jam.endTime" showTime />
<NumberField source="duration" label="table.field.jam.duration" />
- <TextField source="state" label="table.field.jam.state" />
-
+ <FunctionField label="table.field.segment.state" cellClassName="state" render={record => (
+ <>
+ {translate(states.find(item => item.id === record.state)?.name)}
+ </>
+ )} />
<ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
<TextField source="nickname" />
</ReferenceField>
@@ -189,10 +224,29 @@
<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>
+ <FunctionField label="common.field.opt" cellClassName="opt" render={record => (
+ (record.state === "RUNNING" || record.state === "FINISH") && (
+ <>
+ <ConfirmButton
+ label="common.action.deprecated"
+ size="small"
+ color="primary"
+ startIcon={<CloseIcon />}
+ sx={{
+ padding: '1px',
+ fontSize: '.75rem',
+ '& .MuiButton-startIcon': {
+ marginRight: '2px'
+ },
+ }}
+ data={record.uuid}
+ onConfirm={() => {
+ onDeprecated(record.id);
+ }}
+ />
+ </>
+ )
+ )} />
</StyledDatagrid>
</List>
<JamCreate
--
Gitblit v1.9.1