1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* 审核按钮封装
* 徐立
* 2020-3-28
* data 为 'affair/getIdFormDetail' 接口请求到的数据
* callback 提交完成后执行回调函数
* form form表单控件
*/
import React, { Component } from 'react';
import BtnOk from './userTable';
import { preHandle } from '../../utils/myutils';
import { connect } from 'dva';
@connect()
export default class index extends Component {
constructor(props) {
super(props);
this.state = {
isSumbitLoading: false,
isHandle: false,
};
}
affairOk = (oldkey, btnValue, value) => {
const { dispatch, callback, data } = this.props;
this.setState(
{
isSumbitLoading: true,
},
() => {
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
preHandle(values);
dispatch({
type: 'affair/getExamineProcess',
payload: {
taskIds: [data.taskId], // 接口里面的taskId 任务Id
code: data.code,
// 审核相关内容
examineMap: JSON.stringify({
[oldkey]: btnValue, // 每个配置按钮对应的对象内容 oldkey = 接口中 key btnValue = 接口中 value
reason: value, // 审批理由
code: data.code,
}),
taskForm: JSON.stringify(values), // 审批表单的参数值
},
callback: (val) => {
this.setState({
isSumbitLoading: false,
isHandle: false,
});
if (callback) {
callback(val);
}
},
});
}
});
},
);
};
componentDidMount() {
const { data } = this.props;
this.setState({
isHandle: data.isHandle,
});
}
componentWillReceiveProps(nextProps) {
const { data } = nextProps;
this.setState({
isHandle: data.isHandle,
});
}
render() {
const { isSumbitLoading, isHandle } = this.state;
const { data } = this.props;
return (
<>
{isHandle ? (
<BtnOk
isSecond={data.isSecond}
affairOk={this.affairOk}
isSumbitLoading={isSumbitLoading}
btns={data.btns}
/>
) : null}
</>
);
}
}