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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import React, {useState, useEffect} from 'react';
import Document from 'react-document-title'
import {WingBlank, WhiteSpace, ActionSheet, Toast} from 'antd-mobile'
import axiosRequest from '../../utils/request';
import downloadFile from '../../utils/downloadFile'
import TopTabs from '../../components/Tabs/BlankTabs'
import Skeleton from '../../components/Skeleton'
import Basic from './commponents/Basic'
import Adjunct from './commponents/Adjunct'
import Flow from './commponents/Flow';
import Option from './commponents/Option';
import './index.less'
const Process = (props) => {
const {uuid, FLOWTBID} = props.match.params;
const [templateId, setTemplateId] = useState();
const [tableId, setTableId] = useState();
const [nodeId, setNodeId] = useState();
// const [operateId, setOperateId] = useState();
const [flowTbId, setFlowTbId] = useState();
//回到顶部
useEffect(() => {
window.scrollTo(0, 0)
}, []);
const [deal, setDeal] = useState()
useEffect(() => {
const {id} = props.match.params;
setFlowTbId(FLOWTBID);
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/dispatcher`,
body: {
operateId: id,
formType: 'form',
uuid,
mobileSign: 1
}
}).then(res => {
// console.log(res.elementList && res.elementList.length > 0)
// const keys = res.elementList ? Object.keys(res.elementList) : [];
// console.log(keys);
setBasic(res.elementList && res.elementList.length > 0 ? res.elementList.map(item => ({title: item.showName})) : []);
setTableId(res.table && res.table.tableId);
setTemplateId(res.property && res.property.templateId);
setNodeId(res.property && res.property.curNodeId);
setDeal(res.deal)
// setOperateId(res.property && res.property.operateId);
});
}, []);
//获取basic数据
const [basic, setBasic] = useState([]);
const [basicLoading, setBasicLoading] = useState(false)
const getBasic = uuid => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/getData`,
body: {uuid, tableId, templateId}
}).then(res => {
setBasicLoading(true)
const result = [...basic];
result.map(item => {
item.content = res[item.title]
return null;
});
setBasic(result)
});
}
//获取Flow数据
const [flowData, setFlowData] = useState([]);
const [flowLoading, setFlowLoading] = useState(false)
const getFlow = uuid => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/getFlowList`,
body: {uuid, tableId}
}).then(res => {
setFlowLoading(true)
setFlowData(res)
});
};
const [adjunctData, setAdjunctData] = useState([]);
const [adjunctLoading, setAdjunctLoading] = useState(false)
const getAdjunct= uuid => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/getFiles`,
body: {uuid, fieldName: 'fj', tableId}
}).then(res => {
setAdjunctLoading(true)
setAdjunctData(res)
});
};
const [button, setButton] = useState([])
const getButton= uuid => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/nextNodeList`,
body: {curNodeId: nodeId}
}).then(res => {
const result = res ? res.map(item => ({button: item.name, target: item.special, nodetype: item.nodetype})) : []
setButton(result)
});
};
useEffect(() => {
const {uuid} = props.match.params;
templateId && tableId && getBasic(uuid)
templateId && tableId && getFlow(uuid);
templateId && tableId && getAdjunct(uuid)
getButton()
}, [nodeId]);
//提交按钮状态
const [disabled, setDisabled] = useState(true);
//提交按钮文字
const [footButton, setFootButton] = useState('处理');
//聚焦
const optionBlur = () => {
setFootButton('确认发送');
setFootStatus(true)
};
useEffect(() => {
const option = document.getElementsByClassName("option-text")[0];
if (option) {
option.addEventListener('focus', optionBlur, true);
return () => option.removeEventListener('focus', optionBlur, true);
}
}, [basic]);
const [blyj, setBlyj] = useState();
const optionChange = val => {
setBlyj(val);
optionBlur()
setDisabled(!(val != null && val !== ''))
};
const [current, setCurrent] = useState('basic');
const [footStatus, setFootStatus] = useState(false);
//点击输入框, 聚焦移动
const textClick = () => {
document.getElementsByClassName("option-text")[0].focus();
window.scrollTo(0, document.body.scrollHeight);
optionBlur()
};
const download = (uuid, callback) => {
const developer = localStorage.getItem('developer');
downloadFile({
method: 'post',
url: `/idtAppServiceV6/oApp/downloadLargeFileForword`,
body: {uuid, tableId, developer},
}).then(res => {
var downloadElement = document.createElement('a');
downloadElement.href = res.request.responseURL;
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
})
}
//tab切换
const tabClick = (name) => {
setCurrent(name)
name === 'option' && document.getElementsByClassName("option-text")[0].focus();
name === 'option' && optionBlur()
const top = document.getElementById(`event-${name}`).offsetTop - document.getElementById(`event-basic`).offsetTop;
window.scrollTo(0,top);
};
//antd-mobile 提交选项
const isIPhone = new RegExp('\\biPhone\\b|\\biPod\\b', 'i').test(window.navigator.userAgent);
let wrapProps;
if (isIPhone) {
wrapProps = {
onTouchStart: e => e.preventDefault(),
};
};
const blyjSubmit = () => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/oApp/save`,
body: {
tableId,
dealInfo: JSON.stringify({BLYJ: blyj, flowTbId}),
params: JSON.stringify({UUID: uuid})}
}).then(res => {
console.log(res)
});
}
const showActionSheet = () => {
blyjSubmit()
const BUTTON = [];
button.map(item => BUTTON.push(item.button));
const BUTTONS = BUTTON.concat(['取消']);
ActionSheet.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: BUTTONS.length - 1,
maskClosable: true,
wrapProps,
},
(buttonIndex) => {
buttonIndex > -1 && (buttonIndex < BUTTONS.length - 1) && subUrl(buttonIndex)
});
};
const subUrl = key => {
button[key].nodetype === 'bakup' ? end() :
props.history.push(`/blank/submit/${nodeId}/${uuid}/${flowTbId ? flowTbId : 'null'}`)
};
const end = () => {
axiosRequest({
method: 'post',
url: `/idtAppServiceV6/application/interfaces/flow/saveWorkFlowModel.jsp`,
body: {
flowNodeId: nodeId,
attachId: uuid,
flowTbId: flowTbId === 'null' ? '' : flowTbId,
userListMap: JSON.stringify([{}])
}
}).then(res => {
if (res.success === 'success') {
Toast.success("操作成功", 1, () => {
props.history.push('/bord/backlog')
});
}
});
};
const resultLoading = basicLoading && adjunctLoading && flowLoading;
return (
<Document title="待办详情">
<div>
<TopTabs page={current} onClick={tabClick}/>
<div id="event">
<WingBlank>
<div id="event-basic"/>
<WhiteSpace/>
{resultLoading ? <Basic data={basic} attachId={uuid} {...props}/> : <Skeleton/>}
<div id="event-adjunct"/>
<WhiteSpace/>
{resultLoading ? <Adjunct download={download} data={adjunctData} tableId={tableId}/> : <Skeleton/>}
<div id="event-flow"/>
<WhiteSpace/>
{resultLoading ? <Flow data={flowData}/> : <Skeleton/>}
<div id="event-option"/>
<WhiteSpace/>
{resultLoading ? <Option deal={deal} onChange={optionChange}/> : <Skeleton/>}
</WingBlank>
</div>
<div className="event-footer">
{ resultLoading && (
<div className={`event-footer-button ${(footStatus && disabled) ? 'button-disabled' : '' }`} onClick={footStatus && !disabled ? showActionSheet: textClick}>
{!footStatus && (
<img alt="" src="/img/process-edit.png" className="process-edit"/>
)}
{footButton}
</div>
)}
</div>
</div>
</Document>
);
};
export default Process;