AuditInformation.js
7.27 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* eslint-disable no-const-assign,prefer-destructuring */
/**
* Created by mar105 on 2019-01-04.
*/
// , Switch, Icon
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Layout, Spin, Tabs, Avatar, message, Select, Input, Button } from 'antd';
import * as commonFunc from './../Common/commonFunc';/* 通用单据方法 */ /* 通用单据方法 */
import StaticEditTable from '../Common/CommonTable';/* 可编辑表格 */
import styles from './../../index.less';
import CommonView from './../Common/CommonView';
import CommonBase from './../Common/CommonBase';/* 获取配置及数据 */
import * as commonUtils from './../../utils/utils';/* 通用方法 */
import * as commonBusiness from './../Common/commonBusiness';/* 单据业务功能 */
import * as commonConfig from './../../utils/config';
import * as commonServices from './../../services/services';/* 服务类 */
const { TabPane } = Tabs;
const { Option } = Select;
const { Content } = Layout;
class AuditInformation extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentWillReceiveProps(nextProps) {
const {
formData, currentId, checkData, app,
} = nextProps;
let { masterConfig, canSendMsg } = nextProps;
const { userinfo } = app;
if (commonUtils.isEmptyArr(masterConfig) && formData.length > 0) {
const sId = currentId !== undefined ? currentId : '';
/* 数据Id */
masterConfig = formData.filter(item => !item.bGrd)[0];
const checkConfig = formData.filter(item => item.bGrd && item.sTbName === 'sysbillcheckresult')[0];
const checkColumn = commonFunc.getHeaderConfig(checkConfig);
this.handleGetData(masterConfig, checkConfig);
this.props.onSaveState({
masterConfig, sId, pageLoading: false, checkConfig, checkColumn, checked: true, canSendMsg: false,
});
} else if (commonUtils.isNotEmptyArr(checkData) && (JSON.stringify(this.props.checkData) !== JSON.stringify(checkData))) {
const iIndex = checkData.findIndex(item => item.sResult !== '1' && item.sResult !== '2' && item.sCheckPersonId === userinfo.sId);
if (iIndex > -1) {
canSendMsg = true;
}
this.props.onSaveState({ canSendMsg });
}
}
shouldComponentUpdate(nextProps) {
const { checkColumn, masterConfig } = nextProps;
return commonUtils.isNotEmptyArr(checkColumn) || commonUtils.isNotEmptyObject(masterConfig);
}
/** 获取主表数据 */
handleGetData = async (masterConfig, checkConfig) => {
const { currentId } = this.props; /* 当前页签数据 */
const sId = currentId !== undefined ? currentId : '';
await this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' } });
const { masterData } = this.props;
if (!commonUtils.isEmptyObject(checkConfig) && !commonUtils.isEmptyObject(masterData)) {
this.props.handleGetDataSet({
name: 'check', configData: checkConfig, condition: { sSqlCondition: { sBillId: masterData.sBillId } },
});
}
};
handleForm = (form) => {
this.form = form;
};
handleSelectChange = (value) => {
let iReply = 1;
if (value === 'approve') {
iReply = 1;
} else if (value === 'refuse') {
iReply = 0;
}
this.props.onSaveState({ iReply });
};
handleSwitchChange = (value) => {
this.props.onSaveState({ checked: value });
};
handleSubmit = async () => {
const {
sModelsId, masterData, masterConfig, checkConfig,
} = this.props;
let { iReply } = this.props;
const sReply = document.getElementById('sReply').value;
iReply = commonUtils.isEmptyNumber(iReply) ? 1 : iReply;
const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const value = {
sProName: 'Sp_System_ReplyCheckMsg',
paramsMap: {
sMsgGuid: masterData.sId,
sBillGuid: masterData.sBillId,
iReply,
sReply,
},
};
const returnData = (await commonServices.postValueService(this.props.app.token, value, url)).data;
if (returnData.code === 1) {
if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
this.handleGetData(masterConfig, checkConfig);
message.success(returnData.msg);
} else {
message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
}
} else { /* 失败 */
this.props.getServiceError(returnData);
}
};
render() {
const { pageLoading, masterData } = this.props;
const imgSrc = commonBusiness.handleAddIcon(masterData);
return (
<Spin spinning={pageLoading}>
<WorkOrderComponent
{...this.props}
{...this.state}
onReturnForm={this.handleForm}
onSelectChange={this.handleSelectChange}
onSwitchChange={this.handleSwitchChange}
onSubmit={this.handleSubmit}
imgSrc={imgSrc}
/>
</Spin>
);
}
}
const WorkOrderComponent = Form.create({
mapPropsToFields(props) {
const { masterData } = props;
const obj = commonFunc.mapPropsToFields(masterData, Form);
return obj;
},
})((props) => {
const {
form, onReturnForm, onSelectChange, onSubmit, checked,
} = props;
/* 回带表单 */
onReturnForm(form);
const propsType = {
...props,
onChange: props.onMasterChange,
};
const style = checked ? 'block' : 'none';
/*
<div style={{ padding: '10px 12px' }}>显示审核记录:
<Switch
checkedChildren={<Icon type="check" />}
unCheckedChildren={<Icon type="close" />}
onChange={onSwitchChange}
/>
</div>
*/
return (
<Form>
<Layout>
<Layout id="AudiInfomation" className={styles.clayout} style={{ padding: '90px 0 0 0' }}>
<Content className={styles.content} >
<div className="bill-search-group" >
<CommonView {...propsType} />
</div>
<div id="slaveTabs" className={styles.bShow} style={{ overflow: 'auto', display: style }}>
<div>
<Avatar src={props.imgSrc} />
</div>
<Tabs tabBarStyle={{ paddingLeft: '10px' }} >
<TabPane tab="审批信息" key={3} >
<StaticEditTable {...commonBusiness.getTableTypes('check', props)} footer="hidden" />
</TabPane>
</Tabs>
</div>
{ props.canSendMsg ? (
<div style={{ paddingLeft: '13px', width: '30%' }}>
<span style={{ height: '40px', lineHeight: '40px' }}>回答内容:</span>
<Select defaultValue="approve" onChange={onSelectChange}>
<Option value="approve">批准</Option>
<Option value="refuse">拒绝</Option>
</Select>
</div>) : ''
}
{ props.canSendMsg ? (<Input id="sReply" addonBefore="备注:" style={{ paddingLeft: '13px', width: '30%' }} />) : ''}
{ props.canSendMsg ? (
<div style={{ marginTop: '8px', paddingLeft: '13px' }}>
<Button type="primary" htmlType="submit" onClick={onSubmit}>发送</Button>
</div>) : ''}
</Content>
</Layout>
</Layout>
</Form>
);
});
export default CommonBase(AuditInformation);