提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['table','ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var func = layui.func; |
|
6 |
|
|
7 |
/** |
|
8 |
* 管理 |
|
9 |
*/ |
|
10 |
var Procdef = { |
|
11 |
tableId: "procdefTable" |
|
12 |
}; |
|
13 |
|
|
14 |
/** |
|
15 |
* 初始化表格的列 |
|
16 |
*/ |
|
17 |
Procdef.initColumn = function () { |
|
18 |
return [[ |
|
19 |
{type: 'checkbox'}, |
|
20 |
{type: "numbers", align: "center", title: '序号'}, |
|
21 |
{field: 'id', hide: true}, |
|
22 |
{field: 'deploymentId', hide: true}, |
|
23 |
{field: 'name', sort: true, align: "center", title: '名称'}, |
|
24 |
{field: 'key', sort: true, align: "center", title: '流程定义KEY'}, |
|
25 |
{ |
|
26 |
field: 'version', sort: true, align: "center", title: '版本', templet: function (d) { |
|
27 |
return 'v.' + d.version; |
|
28 |
} |
|
29 |
}, |
|
30 |
{field: 'deployTime', sort: true, align: "center", title: '部署时间'}, |
|
31 |
{field: 'resourceName', sort: true, align: "center", title: '流程bpmn文件名称'}, |
|
32 |
{field: 'dgrmResourceName', sort: true, align: "center", title: '流程图片名称'}, |
|
33 |
{ |
|
34 |
field: 'suspensionState', sort: true, align: "center", title: '状态', templet: function (d) { |
|
35 |
if (d.suspensionState === 1) { |
|
36 |
return "<span style='color: #5FB878;'>已激活</span>"; |
|
37 |
} else { |
|
38 |
return "<span style='color: #fe7300;'>已挂起</span>"; |
|
39 |
} |
|
40 |
} |
|
41 |
}, |
|
42 |
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 380} |
|
43 |
]]; |
|
44 |
}; |
|
45 |
|
|
46 |
/** |
|
47 |
* 点击查询按钮 |
|
48 |
*/ |
|
49 |
Procdef.search = function () { |
|
50 |
var queryData = {}; |
|
51 |
queryData['keywords'] = $("#keywords").val(); |
|
52 |
table.reload(Procdef.tableId, { |
|
53 |
where: queryData, page: {curr: 1} |
|
54 |
}); |
|
55 |
}; |
|
56 |
|
|
57 |
/** |
|
58 |
* 导入流程 |
|
59 |
*/ |
|
60 |
Procdef.openAddDlg = function () { |
|
61 |
func.open({ |
|
62 |
title: '导入流程', |
|
63 |
content: Feng.ctxPath + '/process/add', |
|
64 |
tableId: Procdef.tableId, |
|
65 |
height: 250 |
|
66 |
}); |
|
67 |
}; |
|
68 |
|
|
69 |
/** |
|
70 |
* 映射模型 |
|
71 |
*/ |
|
72 |
Procdef.map = function (data) { |
|
73 |
var ajax = new $ax(Feng.ctxPath + "/model/saveModelFromPro", function (data) { |
|
74 |
Feng.success("映射成功!"); |
|
75 |
}, function (data) { |
|
76 |
Feng.error("映射失败!" + data.responseJSON.message) |
|
77 |
}); |
|
78 |
ajax.set("processDefinitionId", data.id); |
|
79 |
ajax.start(); |
|
80 |
}; |
|
81 |
|
|
82 |
/** |
|
83 |
* 下载模型 |
|
84 |
*/ |
|
85 |
Procdef.download = function (data) { |
|
86 |
window.location.href = Feng.ctxPath + '/process/download?deploymentId=' + data.deploymentId; |
|
87 |
}; |
|
88 |
|
|
89 |
/** |
|
90 |
* 挂起或者激活 |
|
91 |
*/ |
|
92 |
Procdef.hangActive = function (data, status) { |
|
93 |
var ajax = new $ax(Feng.ctxPath + "/process/onoffPro", function (data) { |
|
94 |
if (status === 1) { |
|
95 |
Feng.success("激活成功!"); |
|
96 |
} else { |
|
97 |
Feng.success("挂起成功!"); |
|
98 |
} |
|
99 |
table.reload(Procdef.tableId); |
|
100 |
}, function (data) { |
|
101 |
if (status === 1) { |
|
102 |
Feng.error("激活失败!" + data.responseJSON.message) |
|
103 |
} else { |
|
104 |
Feng.error("挂起失败!" + data.responseJSON.message) |
|
105 |
} |
|
106 |
}); |
|
107 |
ajax.set("id", data.id); |
|
108 |
ajax.set("status", status); |
|
109 |
ajax.start(); |
|
110 |
}; |
|
111 |
|
|
112 |
/** |
|
113 |
* 点击删除 |
|
114 |
* |
|
115 |
* @param data 点击按钮时候的行数据 |
|
116 |
*/ |
|
117 |
Procdef.delete = function (data) { |
|
118 |
var operation = function () { |
|
119 |
var ajax = new $ax(Feng.ctxPath + "/process/delete", function (data) { |
|
120 |
Feng.success("删除成功!"); |
|
121 |
table.reload(Procdef.tableId); |
|
122 |
}, function (data) { |
|
123 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
124 |
}); |
|
125 |
ajax.set("deploymentId", data.deploymentId); |
|
126 |
ajax.start(); |
|
127 |
}; |
|
128 |
Feng.confirm("是否删除?", operation); |
|
129 |
}; |
|
130 |
|
|
131 |
// 渲染表格 |
|
132 |
table.render({ |
|
133 |
elem: '#' + Procdef.tableId, |
|
134 |
url: Feng.ctxPath + '/process/list', |
|
135 |
page: true, |
|
136 |
height: "full-158", |
|
137 |
cellMinWidth: 100, |
|
138 |
cols: Procdef.initColumn() |
|
139 |
}); |
|
140 |
|
|
141 |
// 搜索按钮点击事件 |
|
142 |
$('#btnSearch').click(function () { |
|
143 |
Procdef.search(); |
|
144 |
}); |
|
145 |
|
|
146 |
// 添加按钮点击事件 |
|
147 |
$('#btnAdd').click(function () { |
|
148 |
Procdef.openAddDlg(); |
|
149 |
}); |
|
150 |
|
|
151 |
// 工具条点击事件 |
|
152 |
table.on('tool(' + Procdef.tableId + ')', function (obj) { |
|
153 |
var data = obj.data; |
|
154 |
var layEvent = obj.event; |
|
155 |
|
|
156 |
if (layEvent === 'map') { |
|
157 |
Procdef.map(data); |
|
158 |
} else if (layEvent === 'download') { |
|
159 |
Procdef.download(data); |
|
160 |
} else if (layEvent === 'hangup') { |
|
161 |
Procdef.hangActive(data, 2); |
|
162 |
} else if (layEvent === 'active') { |
|
163 |
Procdef.hangActive(data, 1); |
|
164 |
} else if (layEvent === 'delete') { |
|
165 |
Procdef.delete(data); |
|
166 |
} |
|
167 |
}); |
|
168 |
}); |