flowlayout.js
17.7 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
layui.define(["jquery", "layer", "bootstrap"],
function (exports) {
var $ = layui.jquery;
var layer = layui.layer;
//初始化设计流程器
$.fn.flowdesign = function (options) {
var $frmpreview = $(this);
if (!$frmpreview.attr('id')) {
return false;
}
$frmpreview.html("");
var defaultcnf = {
width: 500,
height: 400,
haveHead: false,
haveTool: true,
headLabel: true,
toolBtns: ["start round mix", "end round", "node", "join", "fork"],
haveGroup: true,
useOperStack: true
};
if (options != undefined) {
$.extend(defaultcnf, options);
}
var flowPanel = $.createGooFlow($(this), defaultcnf);
flowPanel.setNodeRemarks({
cursor: "选择指针",
direct: "转换连线",
dashed: "关联虚线",
start: "开始结点",
end: "结束结点",
task: "任务结点",
node: "任务结点",
chat: "决策结点",
state: "状态结点",
plug: "附加插件",
fork: "分支结点",
join: "联合结点",
complex: "复合结点",
group: "组织划分框编辑开"
});
if (options != undefined
&& options.flowcontent != undefined
&& options.flowcontent != null) { //加载内容
flowPanel.loadData(options.flowcontent);
}
//导出数据扩展方法
//所有节点必须有进出线段
//必须有开始结束节点(且只能为一个)
//分流合流节点必须成对出现
//分流合流节点必须一一对应且中间必须有且只能有一个普通节点
//分流节点与合流节点之前的审核节点必须有且只能有一条出去和进来节点
flowPanel.exportDataEx = function () {
var data = flowPanel.exportData();
var fromlines = {},
tolines = {},
nodes = {},
fnodes = [], //会签分流节点
hnodes = [], //会签合流节点
startroundFlag = 0, //开始节点标识
endroundFlag = 0; //结束节点标识
for (var i in data.lines) {
if (fromlines[data.lines[i].from] == undefined) {
fromlines[data.lines[i].from] = [];
}
fromlines[data.lines[i].from].push(data.lines[i].to);
if (tolines[data.lines[i].to] == undefined) {
tolines[data.lines[i].to] = [];
}
tolines[data.lines[i].to].push(data.lines[i].from);
}
for (var j in data.nodes) {
var _node = data.nodes[j];
var _flag = false;
switch (_node.type) {
case "start round mix":
startroundFlag++;
if (fromlines[_node.id] == undefined) {
layer.msg("开始节点无法流转到下一个节点");
return -1;
}
break;
case "end round":
endroundFlag++;
if (tolines[_node.id] == undefined) {
layer.msg("无法流转到结束节点");
return -1;
}
break;
case "node":
_flag = true;
break;
case "fork":
_flag = true;
fnodes.push(_node.id);
break;
case "join":
hnodes.push(_node.id);
_flag = true;
break;
default:
layer.msg("节点数据异常!");
return -1;
break;
}
nodes[_node.id] = _node;
}
if (startroundFlag == 0) {
layer.msg("必须有开始节点");
return -1;
}
if (endroundFlag == 0) {
layer.msg("必须有结束节点");
return -1;
}
if (fnodes.length != hnodes.length) {
layer.msg("分流节点必须等于合流节点");
return -1;
}
return data;
}
flowPanel.SetNodeEx = function (id, data) {
flowPanel.setName(id, data.NodeName, "node", data);
}
flowPanel.SetLineEx = function (id, data) {
flowPanel.setName(id, data.LineName, "line", data);
}
flowPanel.onItemDbClick = function (id, type) {
var obj = flowPanel.getItemInfo(id, type);
switch (type) {
case "node":
options.OpenNode(obj);
break;
case "line":
options.OpenLine(obj);
break;
}
return false;
}
if (options.isprocessing) //如果是显示进程状态
{
var tipHtml =
'<div style="position:absolute;left:10px;margin-top: 10px;padding:10px;border-radius:5px;background:rgba(0,0,0,0.05);z-index:1000;display:inline-block;">';
tipHtml +=
'<div style="display: inline-block;"><i style="padding-right:5px;color:#5cb85c;" class="layui-icon"></i><span>已处理</span></div>';
tipHtml +=
'<div style="display: inline-block;margin-left: 10px;"><i style="padding-right:5px;color:#5bc0de;" class="layui-icon"></i><span>正在处理</span></div>';
tipHtml +=
'<div style="display: inline-block;margin-left: 10px;"><i style="padding-right:5px;color:#d9534f;" class="layui-icon"></i><span>不通过</span></div>';
tipHtml +=
'<div style="display: inline-block;margin-left: 10px;"><i style="padding-right:5px;color:#f0ad4e;" class="layui-icon"></i><span>驳回</span></div>';
tipHtml +=
'<div style="display: inline-block;margin-left: 10px;"><i style="padding-right:5px;color:#999;" class="layui-icon"></i><span>未处理</span></div></div>';
$('.GooFlow_work .GooFlow_work_inner').css('background-image', 'none');
$('td').css('color', '#fff');
$frmpreview.css('background', '#fff');
$('.ico').remove();
$('.GooFlow_item').css('border', '0px');
$frmpreview.append(tipHtml);
$.each(options.nodeData,
function (i, item) {
$("#" + item.id).css("background", "#999");
if (item.type == "start round mix") {
$("#" + item.id).css("background", "#5cb85c");
} else {
if (item.id == options.activityId) {
$("#" + item.id).css("background", "#5bc0de"); //正在处理
}
if (item.setInfo != undefined && item.setInfo.Taged != undefined) {
if (item.setInfo.Taged == -1) {
$("#" + item.id).css("background", "#d9534f"); //不通过
} else if (item.setInfo.Taged == 1) {
$("#" + item.id).css("background", "#5cb85c"); //通过
} else {
$("#" + item.id).css("background", "#f0ad4e"); //驳回
}
}
}
if (item.setInfo != undefined && item.setInfo.Taged != undefined) {
var tips = '<div style="text-align:left">';
var tagname = { "-1": "不通过", "1": "通过", "0": "驳回" };
tips += "<p>处理人:" + item.setInfo.UserName + "</p>";
tips += "<p>结果:" + tagname[item.setInfo.Taged] + "</p>";
tips += "<p>处理时间:" + item.setInfo.TagedTime + "</p>";
tips += "<p>备注:" + item.setInfo.Description + "</p></div>";
$('#' + item.id).click(function () {
layer.tips(tips, '#' + item.id);
});
} else {
$('#' + item.id).click(function () {
layer.tips('暂无处理信息', '#' + item.id);
});
}
});
}
if (options.preview == 1) {
preview();
}
//预览
function preview() {
var _frmitems = {};
for (var i in options.frmData) {
var _frmitem = options.frmData[i];
_frmitems[_frmitem.control_field] = _frmitem.control_label;
}
var DataBaseLinkData = {};
var _NodeRejectType = { "0": "前一步", "1": "第一步", "2": "某一步", "3": "用户指定", "4": "不处理" };
var _NodeIsOver = { "0": "不允许", "1": "允许" };
var _NodeDesignate = {
"NodeDesignateType1": "所有成员",
"NodeDesignateType2": "指定成员",
"NodeDesignateType3": "发起者领导",
"NodeDesignateType4": "前一步骤领导",
"NodeDesignateType5": "发起者部门领导",
"NodeDesignateType6": "发起者公司领导"
};
var _NodeConfluenceType = { "0": "所有步骤通过", "1": "一个步骤通过即可", "2": "按百分比计算" };
if (options.flowcontent == undefined) return;
$.each(options.flowcontent.nodes,
function (i, item) {
if (item.setInfo != undefined) {
var _popoverhtml = "";
_popoverhtml +=
'<div class="flow-portal-panel-title"><i class="fa fa-navicon"></i> 基本信息</div>';
_popoverhtml += '<ul>';
_popoverhtml += '<li>节点标识:' + item.setInfo.NodeCode + '</li>';
_popoverhtml += '<li>驳回类型:' + _NodeRejectType[item.setInfo.NodeRejectType] + '</li>';
_popoverhtml += '<li>终止流程:' + _NodeIsOver[item.setInfo.NodeIsOver] + '</li>';
if (item.setInfo.Description != "") {
_popoverhtml += '<li>备注:' + item.setInfo.Description + '</li>';
}
if (item.setInfo.NodeConfluenceType != "") {
_popoverhtml += '<li>会签策略:' +
_NodeConfluenceType[item.setInfo.NodeConfluenceType] +
'</li>';
if (item.setInfo.NodeConfluenceType == 2) {
_popoverhtml += '<li>会签比例:' + item.setInfo.NodeConfluenceRate + '</li>';
}
}
if (item.setInfo.NodeDataBase != "") {
_popoverhtml += '<li>绑定数据库:' + DataBaseLinkData[item.setInfo.NodeDataBase] + '</li>';
}
if (item.setInfo.NodeTable != "") {
_popoverhtml += '<li>绑定表名:' + item.setInfo.NodeTable + '</li>';
}
if (item.setInfo.NodePram != "") {
_popoverhtml += '<li>绑定字段:' + item.setInfo.NodePram + '</li>';
}
_popoverhtml += '</ul>';
_popoverhtml +=
'<div class="flow-portal-panel-title"><i class="fa fa-navicon"></i> 审核者</div>';
_popoverhtml += '<ul>';
_popoverhtml += '<li>类型:' + _NodeDesignate[item.setInfo.NodeDesignate] + '</li>';
if (item.setInfo.NodeDesignateData != undefined) {
var _rowstr = "";
for (var i in item.setInfo.NodeDesignateData.roles) {
var _postitem = item.setInfo.NodeDesignateData.roles[i];
var _one = top.clientroleData[_postitem];
_rowstr += ' <span class="label label-success">' +
(_one == undefined ? _postitem : _one.FullName) +
'</span>';
if (i == item.setInfo.NodeDesignateData.roles.length - 1) {
_popoverhtml += '<li>角色:' + _rowstr + '</li>';
}
}
_rowstr = "";
for (var i in item.setInfo.NodeDesignateData.users) {
var _postitem = item.setInfo.NodeDesignateData.users[i];
var _one = clientuserData[_postitem];
_rowstr += ' <span class="label label-danger">' +
(_one == undefined ? _postitem : _one.RealName) +
'</span>';
if (i == item.setInfo.NodeDesignateData.users.length - 1) {
_popoverhtml += '<li>用户:' + _rowstr + '</li>';
}
}
}
_popoverhtml += '</ul>';
var _row = "";
for (var i in item.setInfo.frmPermissionInfo) {
var _item = item.setInfo.frmPermissionInfo[i];
var _downtext = "";
if (_item.down) {
_downtext = ' | 可下载';
} else if (_item.down != undefined) {
_downtext = ' | 不可下载';
}
_row += '<li>' +
_frmitems[_item.fieldid] +
': ' +
(_item.look ? '可查看' : '不可查看') +
_downtext +
'</li>';
if (i == item.setInfo.frmPermissionInfo.length - 1) {
_popoverhtml +=
'<div class="flow-portal-panel-title"><i class="fa fa-navicon"></i> 权限分配</div>';
_popoverhtml += '<ul>';
_popoverhtml += _row;
_popoverhtml += '</ul>';
}
}
if (item.setInfo.NodeDataBaseToSQL != "" || item.setInfo.NodeSQL != "") {
_popoverhtml +=
'<div class="flow-portal-panel-title"><i class="fa fa-navicon"></i> 执行SQL</div>';
_popoverhtml += '<ul>';
_popoverhtml += '<li>数据库:' + DataBaseLinkData[item.setInfo.NodeDataBaseToSQL] + '</li>';
_popoverhtml += '<li>SQL语句:' + item.setInfo.NodeSQL + '</li>';
_popoverhtml += '</ul>';
}
$('#' + item.id).attr('title', item.name);
$('#' + item.id).attr('data-toggle', 'popover');
$('#' + item.id).attr('data-placement', 'bottom');
$('#' + item.id).attr('data-content', _popoverhtml);
} else {
$('#' + item.id).attr('title', item.name);
$('#' + item.id).attr('data-toggle', 'popover');
$('#' + item.id).attr('data-placement', 'bottom');
$('#' + item.id).attr('data-content', "该节点未被设置");
}
});
//$('.GooFlow_item').popover({ html: true });
}
return flowPanel;
}
exports('flowlayout');
});