提交 fefc8890 authored 作者: 钟是志's avatar 钟是志

28471 批量审核加一个进度条

上级 11c7ec36
...@@ -6,33 +6,46 @@ ...@@ -6,33 +6,46 @@
* callback 提交完成后执行回调函数 * callback 提交完成后执行回调函数
* form form表单控件 * form form表单控件
*/ */
import React, { useState } from "react"; import React, { useState } from 'react';
import { Modal, message } from "antd"; import { Modal, message } from 'antd';
import { preHandle } from "@/webPublic/one_stop_public/utils/myutils"; import { preHandle } from '@/webPublic/one_stop_public/utils/myutils';
import { connect } from "dva"; import { connect } from 'dva';
import Btn from "./pagesBtn"; import Btn from './pagesBtn';
import styles from "./styles.less"; import styles from './styles.less';
import ModalDiy from "@/baseComponent/ModalDiy"; import ModalDiy from '@/baseComponent/ModalDiy';
import { callbackSubmitData } from "@/webPublic/one_stop_public/models/callbackExamineProcess"; import { callbackSubmitData } from '@/webPublic/one_stop_public/models/callbackExamineProcess';
import { getToken } from "@/utils/authority"; import { getToken } from '@/utils/authority';
import { isJSON } from "@/webPublic/zyd_public/utils/utils"; import { isJSON } from '@/webPublic/zyd_public/utils/utils';
import { uaaRequest } from "@/webPublic/one_stop_public/utils/request"; import { uaaRequest } from '@/webPublic/one_stop_public/utils/request';
import AuditProcessOneByOne
from '@/webPublic/FormInsertDiy/AuditButton/pagesBtn/AuditProcessOneByOne';
function AuditButton(props) { function AuditButton(props) {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [modalContent, setModalContent] = useState(""); const [modalContent, setModalContent] = useState('');
const [isSubmitLoading, setSubmitLoading] = useState(false); const [isSubmitLoading, setSubmitLoading] = useState(false);
const [affairOkParams, setAffairParams] = useState({}); const [affairOkParams, setAffairParams] = useState({});
const [showProcessModal, setShowProcessModal] = useState(false); // 增加进度条 1条数据1条数据的调用接口
const { callback } = props;
function affairOk() { function affairOk() {
// 有taskIds属性时,是批量审核, // 有taskIds属性时,是批量审核,
const { dispatch, callback, data, form, taskIds, selectRows } = props; const {
const { oldKey, btnValue } = affairOkParams; dispatch,
if (window.stuSigningAuditXueShengChu && btnValue === "0") { data,
form,
taskIds,
selectRows
} = props;
const {
oldKey,
btnValue
} = affairOkParams;
if (window.stuSigningAuditXueShengChu && btnValue === '0') {
// 黔南就业学生处批量审批签章 特殊处理 专门为黔南签章批量审核搞的函数 // 黔南就业学生处批量审批签章 特殊处理 专门为黔南签章批量审核搞的函数
// 应该是点击同意才执行这个全局函数. // 应该是点击同意才执行这个全局函数.
window.stuSigningAuditXueShengChu({ window.stuSigningAuditXueShengChu({
userNowInfo: (isJSON(localStorage.getItem("user")) && JSON.parse(localStorage.getItem("user"))) || {}, userNowInfo: (isJSON(localStorage.getItem('user')) && JSON.parse(localStorage.getItem('user'))) || {},
buttonInfo: data?.btns && data?.btns.length ? data?.btns.find((x) => x.value === btnValue) : {}, buttonInfo: data?.btns && data?.btns.length ? data?.btns.find((x) => x.value === btnValue) : {},
token: getToken(), token: getToken(),
selectRows, selectRows,
...@@ -51,14 +64,14 @@ function AuditButton(props) { ...@@ -51,14 +64,14 @@ function AuditButton(props) {
setVisible, setVisible,
setSubmitLoading, setSubmitLoading,
remark: { remark: {
setVisible: "关闭弹窗的方法", setVisible: '关闭弹窗的方法',
setSubmitLoading: "显示为加载中", setSubmitLoading: '显示为加载中',
path: " 代码在学工的这里面 src/webPublic/FormInsertDiy/AuditButton/index.js", path: ' 代码在学工的这里面 src/webPublic/FormInsertDiy/AuditButton/index.js',
message: "蚂蚁金服的message 用来展示进度条. 不懂问我", message: '蚂蚁金服的message 用来展示进度条. 不懂问我',
Modal: "蚂蚁金服的Modal 用来提示审核已完成", Modal: '蚂蚁金服的Modal 用来提示审核已完成',
callback: "执行完了的回调函数", callback: '执行完了的回调函数',
else: "其他参数打印出来自己看看", else: '其他参数打印出来自己看看',
uaaRequest: "调一站式的接口的方法" uaaRequest: '调一站式的接口的方法'
} }
}); });
return true; return true;
...@@ -69,6 +82,7 @@ function AuditButton(props) { ...@@ -69,6 +82,7 @@ function AuditButton(props) {
setSubmitLoading(true); setSubmitLoading(true);
preHandle(values); preHandle(values);
let payload = { let payload = {
// 批量 和 单个审批 都用这段代码
taskIds: taskIds || [data.taskId], // 接口里面的taskId 任务Id taskIds: taskIds || [data.taskId], // 接口里面的taskId 任务Id
code: taskIds ? undefined : data.code, code: taskIds ? undefined : data.code,
// 审核相关内容 // 审核相关内容
...@@ -81,13 +95,19 @@ function AuditButton(props) { ...@@ -81,13 +95,19 @@ function AuditButton(props) {
apiData: data, apiData: data,
taskFormKey: data?.taskFormKey, taskFormKey: data?.taskFormKey,
userNowInfo: userNowInfo:
(isJSON(localStorage.getItem("user")) && JSON.parse(localStorage.getItem("user"))) || {}, (isJSON(localStorage.getItem('user')) && JSON.parse(localStorage.getItem('user'))) || {},
buttonInfo, buttonInfo,
token: getToken() token: getToken()
}; };
payload = callbackSubmitData(payload); payload = callbackSubmitData(payload);
console.log(payload);
setVisible(false);
setShowProcessModal(payload);
return false;
dispatch({ dispatch({
type: "affair/getExamineProcess", type: 'affair/getExamineProcess',
payload, payload,
callback: (val) => { callback: (val) => {
setSubmitLoading(false); setSubmitLoading(false);
...@@ -118,46 +138,55 @@ function AuditButton(props) { ...@@ -118,46 +138,55 @@ function AuditButton(props) {
* 根据不同值,返回对应样式 * 根据不同值,返回对应样式
*/ */
function getStyle(key, value) { function getStyle(key, value) {
if (key === "examine") { if (key === 'examine') {
switch (value) { switch (value) {
case 1: case 1:
return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_reject}`].join(" "); return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_reject}`].join(' ');
case 2: case 2:
return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_no}`].join(" "); return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_no}`].join(' ');
case 0: case 0:
return "deafalut"; return 'deafalut';
case "1": case '1':
return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_reject}`].join(" "); return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_reject}`].join(' ');
case "2": case '2':
return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_no}`].join(" "); return [`${styles.btn_margin}`, `${styles.btn}`, `${styles.btn_no}`].join(' ');
case "0": case '0':
return "deafalut"; return 'deafalut';
default: default:
return "deafalut"; return 'deafalut';
} }
} else { } else {
return "deafalut"; return 'deafalut';
} }
} }
function showModal(str, key, value) { function showModal(str, key, value) {
const { data, form } = props; const {
data,
form
} = props;
const buttonInfo = data?.btns && data?.btns.length ? data?.btns.find((x) => x.value === value) : {}; const buttonInfo = data?.btns && data?.btns.length ? data?.btns.find((x) => x.value === value) : {};
const values = form.getFieldsValue(); const values = form.getFieldsValue();
if(buttonInfo?.documentation){ if (buttonInfo?.documentation) {
let needAuditInfo = isJSON(buttonInfo.documentation) && JSON.parse(buttonInfo.documentation)?.needAuditInfo; let needAuditInfo = isJSON(buttonInfo.documentation) && JSON.parse(buttonInfo.documentation)?.needAuditInfo;
if(needAuditInfo && !values.reason){ if (needAuditInfo && !values.reason) {
message.warning('请输入审批理由'); message.warning('请输入审批理由');
return ; return;
} }
} }
setModalContent(`确定${str}吗?`); setModalContent(`确定${str}吗?`);
setAffairParams({ oldKey: key, btnValue: value }); setAffairParams({
oldKey: key,
btnValue: value
});
setVisible(true); setVisible(true);
} }
const { const {
data: { isHandle, btns } data: {
isHandle,
btns
}
} = props; } = props;
if (!isHandle || !Array.isArray(btns) || btns.length < 1) return null; if (!isHandle || !Array.isArray(btns) || btns.length < 1) return null;
return ( return (
...@@ -181,10 +210,23 @@ function AuditButton(props) { ...@@ -181,10 +210,23 @@ function AuditButton(props) {
handleCancel={hideModal} handleCancel={hideModal}
handleOk={affairOk} handleOk={affairOk}
confirmLoading={isSubmitLoading}> confirmLoading={isSubmitLoading}>
<div style={{ fontSize: 16, textAlign: "center", height: 150, lineHeight: "150px" }}> <div style={{
fontSize: 16,
textAlign: 'center',
height: 150,
lineHeight: '150px'
}}>
{modalContent} {modalContent}
</div> </div>
</ModalDiy> </ModalDiy>
{
showProcessModal &&
<AuditProcessOneByOne payloadData={showProcessModal}
callBack={callback}
setShowProcessModal={setShowProcessModal}
/>
}
</> </>
); );
} }
......
import React, { useState, useEffect, useRef } from 'react';
import { Modal, Progress,message } from 'antd';
import { uaaRequest } from '@/webPublic/one_stop_public/utils/request';
import styles from './styles.less';
export default function AuditProcessOneByOne({
payloadData = {},
callBack = () => {
},
setShowProcessModal,
}) {
if (!Array.isArray(payloadData?.taskIds) || !payloadData.taskIds.length) {
return null;
}
const [success, setS] = useState(0);
const [error, setE] = useState(0);
const resInfo = useRef();
const taskIds = payloadData.taskIds;
const total = taskIds.length;
async function getData(){
for (let g = 0; g < taskIds.length; g++) {
const res = await returnPromise({
...payloadData,
taskIds: [taskIds[g]],
});
if (res) {
setS((v) => v + 1);
} else {
setE((v) => v + 1);
}
resInfo.current = res;
}
}
useEffect(() => {
getData();
}, []);
useEffect(() => {
if (success + error === total) {
callBack(resInfo.current);
}
}, [success, error]);
const percent = Math.floor(((success + error) / total) * 100);
return (
<Modal title={'批量审核'}
visible={true}
width={1200}
footer={null}
onCancel={() => {
if(success + error !== total){
message.warning('审核正在进行中,请勿关闭');
}else{
setShowProcessModal(false);
}
}}
>
<div className={styles.juzhong}>
<Progress percent={percent}
type='circle'
status={error === total ? 'exception' : success + error === total ? 'success ' : ''}
strokeColor={{
'0%': '#108ee9',
'100%': '#87d068',
}}
/>
<div >
{
success + error === total ? `审核完成, 成功${success}条, 失败${error}条` : `正在进行审核 共${total}条数据, 成功${success}条, 失败${error}条`
}
</div>
</div>
</Modal>
);
}
let i = 0;
function returnPromise(data) {
// return new Promise((resolve, reject) => {
// i++;
// if (i % 2 > 0) {
// resolve(true);
// } else {
// resolve(false);
// }
// });
return uaaRequest('/UnifiedAppFormApi/examineProcess', data);
}
...@@ -21,3 +21,7 @@ ...@@ -21,3 +21,7 @@
border:1px solid #FF9B00; border:1px solid #FF9B00;
} }
} }
.juzhong{
display: grid;
justify-items: center;
}
...@@ -14,13 +14,6 @@ function AuditModal({ form, selectRows, children, getPage, noNeedForm }) { ...@@ -14,13 +14,6 @@ function AuditModal({ form, selectRows, children, getPage, noNeedForm }) {
message.info(`提交${res ? '成功' : '失败'}!`); message.info(`提交${res ? '成功' : '失败'}!`);
setVisible(false); setVisible(false);
getPage(); getPage();
// 19684 优秀学生奖学金---班主任审核页面--弹框提醒优化处理 禅道bug
// ModalInfo(`提交${res ? '成功' : '失败'}!`, {
// onOk: () => {
// setVisible(false);
// getPage();
// },
// });
} }
const [data, setData] = useState(null); const [data, setData] = useState(null);
...@@ -82,6 +75,7 @@ function AuditModal({ form, selectRows, children, getPage, noNeedForm }) { ...@@ -82,6 +75,7 @@ function AuditModal({ form, selectRows, children, getPage, noNeedForm }) {
width={900} width={900}
visible={visible} visible={visible}
title="批量审核" title="批量审核"
maskClosable={false}
footer={footer} footer={footer}
onCancel={() => setVisible(false)}> onCancel={() => setVisible(false)}>
<Spin spinning={loading}> <Spin spinning={loading}>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论