Commit 50d46dfe34adfba168c2a47239c75c6ca2761043

Authored by Min
1 parent 58c0232c

1.同步审批流单据展示逻辑,同意,驳回等按钮点击后增加loading

src/components/Common/CommonExamInfo/index.js
1 1 /* eslint-disable */
2 2 import React, { Component } from 'react';
3 3 import moment from 'moment';
4   -import { Input, Layout, Steps, Select, Button, Modal,message, Spin } from 'antd-v4';
  4 +import { Input, Layout, Steps, Select, Button, Modal,message, Spin } from 'antd';
5 5 import { UserOutlined } from '@ant-design/icons';
6 6 import * as commonUtils from '@/utils/utils';/* 通用方法 */
7 7 import * as commonServices from '@/services/services';/* 服务类 */
8   -import commonConfig from '../../../utils/config';
  8 +import * as commonConfig from '../../../utils/config';
9 9 import flowPicture2 from '@/assets/flow/flowpic.png';
10 10 import styles from './index.less';
11 11 import AntdDraggableModal from "../AntdDraggableModal";
... ... @@ -47,6 +47,23 @@ class CommonExamInfo extends Component {
47 47 message.warn("请输入驳回理由!")
48 48 return;
49 49 }
  50 + // 如果是同意按钮,设置loading状态并开始进度计
  51 + this.setState({
  52 + flowLoading: true,
  53 + progressCount: 0
  54 + });
  55 +
  56 + // 模拟进度计数直到101
  57 + const progressInterval = setInterval(() => {
  58 + this.setState(prevState => {
  59 + const newCount = prevState.progressCount + 1;
  60 + if (newCount > 101) {
  61 + clearInterval(progressInterval);
  62 + return { progressCount: 101 };
  63 + }
  64 + return { progressCount: newCount };
  65 + });
  66 + }, 50); // 每50ms增加1,大约5秒到101
50 67 const bizFlowVo = sFlowObj.bizFlowVo;
51 68 const sTableParamsValue= sFlowObj.bizFlowVo?.sTableParamsValue;
52 69 const sFormData= commonUtils.isNotEmptyObject(sTableParamsValue) ? JSON.parse(sTableParamsValue) : {};
... ... @@ -63,6 +80,8 @@ class CommonExamInfo extends Component {
63 80 const sValue = this.state[name];
64 81 if (btnName === 'agree' && commonUtils.isEmptyObject(sValue)) {
65 82 message.warn(`${child.title} 为必填项!`);
  83 + // 如果是同意按钮,清除loading状态
  84 + this.setState({ flowLoading: false });
66 85 return;
67 86 }
68 87 sFormData[name]= sValue;
... ... @@ -94,7 +113,10 @@ class CommonExamInfo extends Component {
94 113 data.selectMap = {};
95 114 data.comment = textareaValue;
96 115 const { token }= this.props;
97   - console.log('data传参', data);
  116 +
  117 + // console.log('接口开始执行,等待1分钟...');
  118 + // await new Promise(resolve => setTimeout(resolve, 10000));
  119 + // console.log('1分钟等待结束,开始处理请求');
98 120 const sReturn = (await commonServices.postValueService(token, data, url)).data;
99 121 if(commonUtils.isNotEmptyObject(sReturn)) {
100 122 if (sReturn.code > 0 || sReturn.code === 0) {
... ... @@ -126,14 +148,24 @@ class CommonExamInfo extends Component {
126 148 // if (iframeDoc.document) iframeDoc = iframeDoc.document; // 处理IE兼容性
127 149 iframeWindow.location.reload(); // 刷新iframe中的页面
128 150 }
129   - this.setState({ historyNewList: historyList, bHandleShow: false, flowLoading: false}) ;
  151 + // 确保进度计数到101后清除loading状态
  152 + this.setState({
  153 + historyNewList: historyList,
  154 + bHandleShow: false,
  155 + flowLoading: false,
  156 + progressCount: 101
  157 + });
130 158 }
131 159  
132 160 } else {
133 161 this.props.getServiceError(sReturn);
  162 + // 操作失败时清除loading状态
  163 + this.setState({ flowLoading: false });
134 164 }
135 165 }else {
136 166 message.warn('操作异常!')
  167 + // 操作异常时清除loading状态
  168 + this.setState({ flowLoading: false });
137 169 }
138 170  
139 171 }
... ... @@ -338,12 +370,23 @@ class CommonExamInfo extends Component {
338 370 dataDynamicList && dataDynamicList.map((child) => {
339 371 const name = child.name;
340 372 const title = child.title;
341   - const value = child.value;
  373 + let value = child.value;
342 374 let bEdit = !child.bEdit; /* 是否编辑 */
  375 + const sRealValue = child.sRealValue;
343 376 /* 如果 isHandle 为 true,代表只能查看, 就不允许编辑 */
344 377 if(bEdit) {
345 378 bEdit = !isHandle;
346 379 }
  380 + let bHtml =false;
  381 + if(commonUtils.isNotEmptyObject(value)) {
  382 + if(value.includes('br')) {
  383 + value = String(value).replace(/<br\s*\/?>/gi, '\n');
  384 + }
  385 + if(value.includes('&lt')) {
  386 + value= String(value).replace(/&lt;br\s*\/?&gt;/gi, '\n')
  387 + }
  388 + bHtml = true;
  389 + }
347 390 const type= child.type; /* 文本类型 */
348 391 const bSelect = child.bSelect; /* 是否下拉 */
349 392 const selectList = child.selectList;
... ... @@ -366,6 +409,8 @@ class CommonExamInfo extends Component {
366 409 options={selectList}
367 410 onChange={(value, option) => this.handleOptionChange(value, option, name)}
368 411 /></div> :
  412 + !bEdit && type === 's' && bSelect ?
  413 + <div className={styles.cardValue}> {sRealValue}</div> :
369 414 bEdit && type === 'm' && !bSelect ?
370 415 <TextArea
371 416 className={styles.memo}
... ... @@ -377,7 +422,7 @@ class CommonExamInfo extends Component {
377 422 <div className={styles.cardValue}>
378 423 {
379 424 type === 's' && (name?.includes('sProcessName') || name?.toLowerCase().indexOf('memo') > -1) ?
380   - <pre className={styles.preStyle}> {value} </pre> : value
  425 + <pre className={styles.preStyle}> {value} </pre> : bHtml ? <pre className={styles.pre}>{value} </pre> : value
381 426 }
382 427  
383 428 </div>
... ...