提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['table', 'admin', 'ax', 'func', 'layer', 'form'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var admin = layui.admin; |
|
6 |
var func = layui.func; |
|
7 |
var layer = layui.layer; |
|
8 |
var form = layui.form; |
|
9 |
|
|
10 |
/** |
|
11 |
* 管理 |
|
12 |
*/ |
|
13 |
var Model = { |
|
14 |
tableId: "modelTable" |
|
15 |
}; |
|
16 |
|
|
17 |
/** |
|
18 |
* 初始化表格的列 |
|
19 |
*/ |
|
20 |
Model.initColumn = function () { |
|
21 |
return [[ |
|
22 |
{type: 'checkbox'}, |
|
23 |
{field: 'id', hide: true, sort: true, title: 'id'}, |
|
24 |
{type: "numbers", align: "center", title: '序号'}, |
|
25 |
{field: 'name', align: "center", title: '模型名称'}, |
|
26 |
{field: 'cateName', align: "center", title: '分类'}, |
|
27 |
{field: 'createTime', align: "center", title: '创建时间'}, |
|
28 |
{field: 'lastUpdateTime', align: "center", title: '更新时间'}, |
|
29 |
{ |
|
30 |
field: 'version', align: "center", title: '版本', templet: function (d) { |
|
31 |
return 'v.' + d.version; |
|
32 |
} |
|
33 |
}, |
|
34 |
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 380} |
|
35 |
]]; |
|
36 |
}; |
|
37 |
|
|
38 |
/** |
|
39 |
* 点击查询按钮 |
|
40 |
*/ |
|
41 |
Model.search = function () { |
|
42 |
var queryData = {}; |
|
43 |
queryData['name'] = $("#name").val(); |
|
44 |
queryData['category'] = $("#category").val(); |
|
45 |
table.reload(Model.tableId, { |
|
46 |
where: queryData, page: {curr: 1} |
|
47 |
}); |
|
48 |
}; |
|
49 |
|
|
50 |
/** |
|
51 |
* 弹出添加对话框 |
|
52 |
*/ |
|
53 |
Model.openAddDlg = function () { |
|
54 |
func.open({ |
|
55 |
title: '添加', |
|
56 |
content: Feng.ctxPath + '/model/add', |
|
57 |
tableId: Model.tableId |
|
58 |
}); |
|
59 |
}; |
|
60 |
|
|
61 |
/** |
|
62 |
* 点击编辑 |
|
63 |
* |
|
64 |
* @param data 点击按钮时候的行数据 |
|
65 |
*/ |
|
66 |
Model.openEditDlg = function (data) { |
|
67 |
func.open({ |
|
68 |
title: '修改', |
|
69 |
content: Feng.ctxPath + '/model/edit?id=' + data.id, |
|
70 |
tableId: Model.tableId |
|
71 |
}); |
|
72 |
}; |
|
73 |
|
|
74 |
/** |
|
75 |
* 点击删除 |
|
76 |
* |
|
77 |
* @param data 点击按钮时候的行数据 |
|
78 |
*/ |
|
79 |
Model.onDeleteItem = function (data) { |
|
80 |
var operation = function () { |
|
81 |
var ajax = new $ax(Feng.ctxPath + "/model/delete", function (data) { |
|
82 |
Feng.success("删除成功!"); |
|
83 |
table.reload(Model.tableId); |
|
84 |
}, function (data) { |
|
85 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
86 |
}); |
|
87 |
ajax.set("modelId", data.id); |
|
88 |
ajax.start(); |
|
89 |
}; |
|
90 |
Feng.confirm("是否删除?", operation); |
|
91 |
}; |
|
92 |
|
|
93 |
/** |
|
94 |
* 设计流程图 |
|
95 |
*/ |
|
96 |
Model.onDesignItem = function (data) { |
|
97 |
func.open({ |
|
98 |
title: '流程设计器', |
|
99 |
content: Feng.ctxPath + '/activiti-editor/editor.html?modelId=' + data.id, |
|
100 |
resize: true, |
|
101 |
maxmin: true, |
|
102 |
width: '1200px' |
|
103 |
}); |
|
104 |
}; |
|
105 |
|
|
106 |
/** |
|
107 |
* 发布部署流程 |
|
108 |
*/ |
|
109 |
Model.onDeployItem = function (data) { |
|
110 |
var ajax = new $ax(Feng.ctxPath + "/model/deployment", function (data) { |
|
111 |
Feng.success("部署成功!"); |
|
112 |
}, function (data) { |
|
113 |
Feng.error("部署失败!" + data.responseJSON.message) |
|
114 |
}); |
|
115 |
ajax.set("modelId", data.id); |
|
116 |
ajax.start(); |
|
117 |
}; |
|
118 |
|
|
119 |
/** |
|
120 |
* 预览流程图 |
|
121 |
*/ |
|
122 |
Model.onPreviewItem = function (data) { |
|
123 |
var ajax = new $ax(Feng.ctxPath + "/model/isCanExportXml", function (result) { |
|
124 |
func.open({ |
|
125 |
title: '预览流程xml', |
|
126 |
content: Feng.ctxPath + '/model/modelView?modelId=' + data.id, |
|
127 |
resize: true, |
|
128 |
maxmin: true, |
|
129 |
width: '1200px' |
|
130 |
}); |
|
131 |
}, function (data) { |
|
132 |
Feng.error("预览失败!" + data.responseJSON.message); |
|
133 |
}); |
|
134 |
ajax.set("modelId", data.id); |
|
135 |
ajax.start(); |
|
136 |
}; |
|
137 |
|
|
138 |
/** |
|
139 |
* 导出item |
|
140 |
*/ |
|
141 |
Model.onExportItem = function (data) { |
|
142 |
var ajax = new $ax(Feng.ctxPath + "/model/isCanExportXml", function (result) { |
|
143 |
window.location.href = Feng.ctxPath + '/model/exportXml?modelId=' + data.id; |
|
144 |
}, function (data) { |
|
145 |
Feng.error("导出失败!" + data.responseJSON.message); |
|
146 |
}); |
|
147 |
ajax.set("modelId", data.id); |
|
148 |
ajax.start(); |
|
149 |
}; |
|
150 |
|
|
151 |
// 渲染表格 |
|
152 |
var tableResult = table.render({ |
|
153 |
elem: '#' + Model.tableId, |
|
154 |
url: Feng.ctxPath + '/model/list', |
|
155 |
page: true, |
|
156 |
height: "full-158", |
|
157 |
cellMinWidth: 100, |
|
158 |
cols: Model.initColumn() |
|
159 |
}); |
|
160 |
|
|
161 |
// 搜索按钮点击事件 |
|
162 |
$('#btnSearch').click(function () { |
|
163 |
Model.search(); |
|
164 |
}); |
|
165 |
|
|
166 |
// 添加按钮点击事件 |
|
167 |
$('#btnAdd').click(function () { |
|
168 |
Model.openAddDlg(); |
|
169 |
}); |
|
170 |
|
|
171 |
// 导出excel |
|
172 |
$('#btnExp').click(function () { |
|
173 |
Model.exportExcel(); |
|
174 |
}); |
|
175 |
|
|
176 |
// 工具条点击事件 |
|
177 |
table.on('tool(' + Model.tableId + ')', function (obj) { |
|
178 |
var data = obj.data; |
|
179 |
var layEvent = obj.event; |
|
180 |
|
|
181 |
if (layEvent === 'edit') { |
|
182 |
Model.openEditDlg(data); |
|
183 |
} else if (layEvent === 'delete') { |
|
184 |
Model.onDeleteItem(data); |
|
185 |
} else if (layEvent === 'design') { |
|
186 |
Model.onDesignItem(data); |
|
187 |
} else if (layEvent === 'deploy') { |
|
188 |
Model.onDeployItem(data); |
|
189 |
} else if (layEvent === 'preview') { |
|
190 |
Model.onPreviewItem(data); |
|
191 |
} else if (layEvent === 'export') { |
|
192 |
Model.onExportItem(data); |
|
193 |
} |
|
194 |
}); |
|
195 |
|
|
196 |
//初始化搜索框 |
|
197 |
var ajax = new $ax(Feng.ctxPath + "/dict/listDictsByCode", function (data) { |
|
198 |
for (var i = 0; i < data.data.length; i++) { |
|
199 |
var name = data.data[i].name; |
|
200 |
var code = data.data[i].code; |
|
201 |
$("#category").append('<option value="' + code + '">' + name + '</option>'); |
|
202 |
} |
|
203 |
form.render(); |
|
204 |
}, function (data) { |
|
205 |
}); |
|
206 |
ajax.set("dictTypeCode", "FLOW_CATEGARY"); |
|
207 |
ajax.start(); |
|
208 |
}); |