From c1f03711c7db7b5780a31fd277dfea2e4210005a Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 26 九月 2024 13:25:06 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/page/jam/JamList.jsx | 64 ++++++++++++++++++++++++++++---
1 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/zy-acs-flow/src/page/jam/JamList.jsx b/zy-acs-flow/src/page/jam/JamList.jsx
index b8b77ec..0d285a4 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">
@@ -177,8 +205,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 +220,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