fastflowbase.js
20.3 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
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
277
278
279
280
281
282
define(['fastflow-fixed-columns'], function (undefined) {
var fastflowBase = {
api: {
renderbadge: function () {
$.ajax({
type: "POST",
url: "fastflow/flow/bill/getBadge",
data: {},
dataType: "json",
success: function (data) {
if (data['code'] == 1) {
let parentWindow = window.parent.document;
$('.fastflow-badge', parentWindow).remove();
data['data'].forEach(function (item) {
if (item['count'] > 0) {
$('a[addtabs=' + item['id'] + ']', parentWindow).append('<span class="pull-right-container fastflow-badge" style="margin-right: 20px"> <small class="' + item['shape'] + ' pull-right ' + item['color'] + '">' + item['show'] + '</small></span>');
}
});
if($('#bill-page',parentWindow).length === 1){
let topWindow = top.window.document;
$('.fastflow-badge', topWindow).remove();
data['data'].forEach(function (item) {
if (item['count'] > 0) {
$('a[addtabs=' + item['id'] + ']', topWindow).append('<span class="pull-right-container fastflow-badge" style="margin-right: 20px"> <small class="' + item['shape'] + ' pull-right ' + item['color'] + '">' + item['show'] + '</small></span>');
}
});
}
}
}
});
},
formatter: {
id: function (value, row, index) {
return '<span class="label label-success" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-check-circle" style="margin-right: 4px;"></i>' + value + '</span>';
},
progress: function (value, row, index) {
return '<div class="progress active" style="background: #d0d0d0;">'
+ '<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" style="width: '
+ Math.round(value * 100)
+ '%"> '
+ '<b>'
+ Math.round(value * 100)
+ '%</b> '
+ '</div></div>';
},
flowinfo: function (value, row, index) {
let html = '';
console.log('config',Config.initiator_id)
let backin = '';
if(row.initiator_id == Config.initiator_id && row.flow_auth.code!=4){
backin = '<a href="#" class="btn btn-xs btn-success btn-cx" data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa fa-reply" style="margin-right: 4px;"></i>撤销</a>';
}
if (row['flow_auth']['code'] == -3 || row['flow_auth']['code'] == -1 || row['flow_auth']['code'] == 3) {
let labelcolor = {
'-3': 'label-danger',
'-1': 'label-warning',
'3': 'label-warning',
};
html = '<span class="label ' + labelcolor[row['flow_auth']['code']] + '" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</span>'
+backin
+ '<a href="fastflow/flow/flow/detail?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog btn-detail" title="查看" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-list" style="margin-right: 4px;"></i>查看</a>'
+ '<a href="fastflow/flow/flow/flowdiagram?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog" title="流程图" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-sitemap" style="margin-right: 4px;"></i>流程图</a>';
} else if (row['flow_auth']['code'] == 2) {
if (row['fastflow_signature_status'] == -1) {
html = '<a href="fastflow/signature/initiate?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-info btn-dialog btn-signature" title="发起签章" data-area=["60%","80%"] style="margin-right: 4px;font-size: 90%;"><i class="fa fa-file-text-o" style="margin-right: 4px;"></i>发起签章</a>'
} else if (row['fastflow_signature_status'] == 0) {
html = '<a href="javascript:;" class="btn btn-xs btn-warning" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-file-text-o" style="margin-right: 4px;"></i>待签章</a>'
} else if (row['fastflow_signature_status'] == 1) {
html = '<a href="javascript:;" class="btn btn-xs btn-info-light" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-file-text-o" style="margin-right: 4px;"></i>已签章</a>'
} else {
html = '<span class="label label-success" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</span>'
}
html +=
backin +
'<a href="fastflow/flow/flow/detail?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog btn-detail" title="查看" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-list" style="margin-right: 4px;"></i>查看</a>'
+ '<a href="fastflow/flow/flow/flowdiagram?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog" title="流程图" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-sitemap" style="margin-right: 4px;"></i>流程图</a>';
} else if (row['flow_auth']['code'] == -2) {
html = '<span class="label label-warning" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</span>';
} else if (row['flow_auth']['code'] == 0) {
html = '<a href="fastflow/flow/run/start?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-info btn-dialog btn-start" title="' + row['flow_auth']['msg'] + '" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-calendar-plus-o" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</a>';
} else if (row['flow_auth']['code'] == 1) {
needCheckCount = 0;
row['runthread_info'] = Array.from(row['runthread_info']);
row['runthread_info'].forEach(function (item) {
if (item['auth_info'] !== false) {
needCheckCount += 1;
}
});
html = '<a href="javascript:;" class="btn btn-xs btn-success btn-cancheck" style="position:relative;font-size: 90%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i><span class="label label-danger" style="position:absolute;text-align:center;font-size:12px;padding:3px 3px;right: -2px;top:-6px;border-radius:1em;width: 18px;height: 18px">'
+ needCheckCount + '</span>'
+ row['flow_auth']['msg'] + '</a>'
+backin
+ '<a href="fastflow/flow/flow/detail?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog btn-detail" title="查看" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-list" style="margin-right: 4px;"></i>查看</a>'
+ '<a href="fastflow/flow/flow/flowdiagram?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog" title="流程图" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-sitemap" style="margin-right: 4px;"></i>流程图</a>';
} else if (row['flow_auth']['code'] == 4) {
html = '<a href="fastflow/flow/run/start?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-info btn-dialog btn-start" title="' + row['flow_auth']['msg'] + '" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-calendar-plus-o" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</a>'
+backin
+ '<a href="fastflow/flow/flow/detail?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog btn-detail" title="查看" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-list" style="margin-right: 4px;"></i>查看</a>';
}else if (row['flow_auth']['code'] == 5) {
html = '<span class="label label-warning" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i>' + row['flow_auth']['msg'] + '</span>'
+backin
+ '<a href="fastflow/flow/flow/detail?bill=' + row['bill'] + '&bill_id=' + row['id'] + '" class="btn btn-xs btn-success btn-dialog btn-detail" title="查看" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-list" style="margin-right: 4px;"></i>查看</a>';
}
return html;
},
detail: function (index, row, e) {
if (row['runthread_info'] == -1 || row['runthread_info'] == 2) {
$(e).parent().prev().find('.detail-icon').trigger('click').addClass('hidden');
return '';
}
detailtable = '<table style="width: 100%;margin-left: 15px" class="table table-hover detailtable"><tbody data-listidx="1"><tr style="background-color: #e9f4fd;"><th style="width: 60px;text-align: center">步骤编号</th><th style="text-align: center;">步骤名称</th><th style="text-align: center;">审批人</th><th style="text-align: center;">会签</th><th style="text-align: center;">回退</th><th style="text-align: center;">上一步骤</th><th style="text-align: center;">下一步骤</th><th style="text-align: center;">被代理人(组)</th><th style="text-align: center;">代理人(组)</th><th style="text-align: center;width:250px;">审批</th></tr>';
row['runthread_info'] = Array.from(row['runthread_info']);
row['runthread_info'].forEach(function (item) {
var zrin = '<a href="fastflow/flow/run/change?thread_id='+item["id"]+ '" class="btn btn-xs btn-warning-light btn-dialog" title="转审" data-area=["25%","45%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa fa-reply-all" style="margin-right: 4px;"></i>转审</a>';
checkButton = '';
if (item['auth_info'] !== false) {
checkButton = (item['auth_info']['agency'] == true ? '<span class="label label-info" style="font-size: 94%;width:42px;margin-right: 9px;">代理</span>' : '')
+ '<a href="fastflow/flow/run/agree?thread_id=' + item["id"] + '" class="btn btn-xs btn-success-light btn-dialog" title="同意" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-check-square" style="margin-right: 4px;"></i>同意</a>'
+zrin
+ (item['can_back'] == 1 ? '<a href="fastflow/flow/run/back?thread_id=' + item["id"] + '" class="btn btn-xs btn-danger-light btn-dialog" title="驳回" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-reply" style="margin-right: 4px;"></i>驳回</a>' : '')
+ (item['can_sign'] == 1 ? '<a href="fastflow/flow/run/sign?thread_id=' + item["id"] + '" class="btn btn-xs btn-info-light btn-dialog" title="会签" data-area=["95%","95%"] data-table-id="table" style="margin-right: 4px;font-size: 90%;"><i class="fa fa-pencil" style="margin-right: 4px;"></i>会签</a>' : '');
} else {
checkButton = '<a href="javascript:;" class="btn btn-xs btn-warning-light" style="font-size: 94%;margin-right: 4px;"><i class="fa fa-info-circle" style="margin-right: 4px;"></i>无审批权限</a>';
}
checkButton = '<div style="width: 220px;">' + checkButton + '</div>';
checkUser = '';
item['check_worker_list'].forEach(function (worker) {
checked = false;
for (i = 0; i < item['checked_worker_list'].length; i++) {
if (worker == item['checked_worker_list'][i]) {
checked = true;
break;
}
}
if (checked) {
checkUser += '<span class="text-success">' + worker + '</span>,';
} else {
checkUser += worker + ',';
}
});
detailtable += '<tr style="text-align: center;"><td>' + item['id'] + '</td><td>' + item['name'] + '</td><td>'
+ (checkUser == '' ? '<a class="btn btn-xs btn-danger">【错误】未设置审批人</a>' : (item['checkmode'] == 1 ? '<span class="text-info">联合审批:</span>' : '<span class="text-info">任一审批:</span>') + checkUser.slice(0, checkUser.length - 1))
+ '</td><td>'
+ (item['is_sign'] == 1 ? '<span class="text-warning">是</span>' : '否')
+ '</td><td>'
+ (item['is_back'] == 1 ? '<span class="text-warning">是</span>' : '否')
+ '</td><td>'
+ item['pre_step']
+ '</td><td>'
+ (item['next_step'] == '' ? '<a class="btn btn-xs btn-danger">【错误】请完善流程设计,条件转出步骤必须设置</a>' : item['next_step'])
+ '</td><td>'
+ (item['agency_info'] !== null ? item['agency_info']['principal_name'] : '')
+ '</td><td>'
+ (item['agency_info'] !== null ? item['agency_info']['agent_name'] : '')
+ '</td><td>'
+ checkButton
+ '</td></tr>';
});
detailtable += '</tbody></table>';
return detailtable;
},
},
events: {
flowinfo: {
'click .btn-cancheck': function (e, value, row, index) {
e.stopPropagation();
$('tr[data-index="' + index + '"]').find('.detail-icon').trigger('click');
},
'click .btn-cx': function (e, value, row, index) {
e.stopPropagation();
console.log('rowrow',row.runthread_info[0].id)
// row['bill'] row['id']
Layer.confirm("是否确定撤销?", {icon: 3}, function (index) {
if(row.runthread_info[0].id==''){
Toastr.success("撤销失败1");
return false;
}
Fast.api.ajax({
url:'fastflow/flow/flow/revoke',
data:{bill:row['bill'],bill_id:row['id'],tid:row.runthread_info[0].id}
}, function(data, ret){
//成功的回调
layer.close(index);
$('#table').bootstrapTable('refresh');
Toastr.success("提交撤销成功");
return false;
}, function(data, ret){
//失败的回调
layer.close(index);
Toastr.success("提交撤销失败");
return false;
});
Toastr.success("提交成功");
});
}
}
},
bindevent: function (table) {
$('.btn-expandall').click(function (e) {
$('#table').bootstrapTable('expandAllRows');
});
$('.btn-collapseall').click(function (e) {
$('#table').bootstrapTable('collapseAllRows');
});
let indexUrl = $.fn.bootstrapTable.defaults.extend.index_url.replace(location.search,'');
$(document).on("click", ".btn-mine", function () {
table.bootstrapTable('refresh', {url: indexUrl + '?show=mine'});
$(this).addClass('disabled');
$(".btn-showcancheck").removeClass('disabled');
$(".btn-showall").removeClass('disabled');
return false;
});
$(document).on("click", ".btn-showcancheck", function () {
table.bootstrapTable('refresh', {url: indexUrl + '?show=cancheck'});
$(this).addClass('disabled');
$(".btn-mine").removeClass('disabled');
$(".btn-showall").removeClass('disabled');
return false;
});
$(document).on("click", ".btn-showall", function () {
table.bootstrapTable('refresh', {url: indexUrl});
$(this).addClass('disabled');
$(".btn-mine").removeClass('disabled');
$(".btn-showcancheck").removeClass('disabled');
return false;
});
$('th.detail').css({
"text-align": "center",
"vertical-align": "middle",
"width": "36px",
"color": "#4397fd"
});
$('th.detail').html('<div class="th-inner"><a href="javascript:;" class="detail-toggle" data-expand="false"><i class="glyphicon glyphicon-plus icon-plus"></i></a></div><div class="fht-cell"></div>');
$('th.detail .detail-toggle').click(function (e) {
if ($(this).data('expand') == false) {
$('#table').bootstrapTable('expandAllRows');
$(this).data('expand', true);
$('i', this).removeClass('glyphicon-plus icon-plus').addClass('glyphicon-minus icon-minus');
} else {
$('#table').bootstrapTable('collapseAllRows');
$(this).data('expand', false);
$('i', this).removeClass('glyphicon-minus icon-minus').addClass('glyphicon-plus icon-plus');
}
});
}
}
}
return fastflowBase;
})