From 93d8a38f9fd0746b9ce6ac7541bf2b8b48f7c63c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 18 十二月 2024 13:11:24 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/page/mission/MissionResend.jsx | 49 ++++++++++++++++++++++++++++++++++---------------
1 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/zy-acs-flow/src/page/mission/MissionResend.jsx b/zy-acs-flow/src/page/mission/MissionResend.jsx
index 10b1a43..85823b3 100644
--- a/zy-acs-flow/src/page/mission/MissionResend.jsx
+++ b/zy-acs-flow/src/page/mission/MissionResend.jsx
@@ -36,6 +36,7 @@
import DialogCloseButton from "../components/DialogCloseButton";
import { format } from 'date-fns';
import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew';
+import request from '@/utils/request';
const MissionResend = ({ open, id }) => {
const redirect = useRedirect();
@@ -136,8 +137,7 @@
</Box>
)}
- <ActionTable actionIds={record?.actionIds} />
-
+ <ActionTable actionIds={record?.actionIds} currCode={record.currCode} handleClose={handleClose} />
</Box>
</Box>
</Stack>
@@ -178,9 +178,10 @@
},
];
-const ActionTable = ({ actionIds }) => {
+const ActionTable = ({ actionIds, currCode, handleClose }) => {
const dataProvider = useDataProvider();
const translate = useTranslate();
+ const notify = useNotify();
const [actions, setActions] = useState([]);
const [selected, setSelected] = React.useState([]);
@@ -189,6 +190,13 @@
dataProvider.getMany('action', { ids: actionIds }).then(res => {
if (res.data?.length > 0) {
setActions(res.data);
+
+ // init selected
+ const indexOfCurrCode = res.data.findIndex(item => item.code === currCode);
+ if (indexOfCurrCode !== -1) {
+ const selectedIds = res.data.slice(indexOfCurrCode).map(item => item.id);
+ setSelected(selectedIds);
+ }
}
})
}
@@ -222,6 +230,21 @@
setSelected(newSelected);
};
+ const resendSubmit = () => {
+ if (!!selected?.length) {
+ request.post("/mission/resend", selected.map(id => ({ id }))).then(res => {
+ const { code, msg, data } = res.data;
+ if (code === 200) {
+ notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } });
+ handleClose();
+ } else {
+ notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } });
+ }
+ }).catch(error => {
+ notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
+ })
+ }
+ }
return (
<>
@@ -250,7 +273,7 @@
variant="subtitle1"
component="div"
>
- {selected.length} selected
+ {selected.length} {translate('common.action.selected')}
</Typography>
) : (
<Typography
@@ -259,20 +282,16 @@
id="tableTitle"
component="div"
>
- Actions
+ {translate('table.field.mission.actions')}
</Typography>
)}
{selected.length > 0 && (
- <Tooltip title="Delete">
- <IconButton>
- <Button
- onClick={() => {
- alert('clicked');
- }}
- >
- ss
- </Button>
- </IconButton>
+ <Tooltip title="Resend">
+ <Button
+ onClick={resendSubmit}
+ >
+ {translate('ra.action.confirm')}
+ </Button>
</Tooltip>
)}
</Toolbar>
--
Gitblit v1.9.1