|
|
1
|
+layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols', 'echarts', 'sessions',"commonDetail",'tableTree','soulTable'], function (exports) {
|
|
|
2
|
+ var $ = layui.$;
|
|
|
3
|
+ var laytpl = layui.laytpl;
|
|
|
4
|
+ var tree = layui.tree;
|
|
|
5
|
+ var form = layui.form;
|
|
|
6
|
+ var view = layui.view;
|
|
|
7
|
+ var table = layui.table;
|
|
|
8
|
+ var admin = layui.admin;
|
|
|
9
|
+ var commonCols = layui.commonCols;
|
|
|
10
|
+ var soulTable = layui.soulTable;
|
|
|
11
|
+ var tableTree = layui.tableTree;
|
|
|
12
|
+ var common = layui.common;
|
|
|
13
|
+ var commonDetail = layui.commonDetail;
|
|
|
14
|
+ var busId = '';//当前业务Id
|
|
|
15
|
+ var appId = '';
|
|
|
16
|
+ var curTreeNode = '';
|
|
|
17
|
+ var curBizResType = '';//当前业务所在的资源类型
|
|
|
18
|
+
|
|
|
19
|
+ var sortKey = '';
|
|
|
20
|
+
|
|
|
21
|
+
|
|
|
22
|
+ function autoHeight(el) {
|
|
|
23
|
+ // var height = el.parents('.layui-card').height();
|
|
|
24
|
+ // el.css('min-height', height - 75);
|
|
|
25
|
+ }
|
|
|
26
|
+
|
|
|
27
|
+ // 隐藏左侧菜单
|
|
|
28
|
+ $('#LAY_app_flexible').click();
|
|
|
29
|
+
|
|
|
30
|
+ //对外暴露的接口
|
|
|
31
|
+ exports('bizindex', function () {
|
|
|
32
|
+ var sessions = layui.sessions;
|
|
|
33
|
+ var accessToken = sessions.getToken()['access_token'];
|
|
|
34
|
+ var router = layui.router();
|
|
|
35
|
+ // 资源视图父级表格
|
|
|
36
|
+ var bizParentList;
|
|
|
37
|
+ // 资源视图表格
|
|
|
38
|
+ var bizListTable;
|
|
|
39
|
+ //点击卡片
|
|
|
40
|
+ $('#bizindexTable').unbind('click').on('click', '[data-biz-card]', function () {
|
|
|
41
|
+ var resType = $(this).data("biz-card");
|
|
|
42
|
+ var isLeaf = $(this).data("biz-leaf");
|
|
|
43
|
+ //过滤业务卡片
|
|
|
44
|
+ if (isLeaf =='1') {
|
|
|
45
|
+ //回选树节点
|
|
|
46
|
+ selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
|
|
|
47
|
+ renderBizResTypeCard(resType);
|
|
|
48
|
+ } else if(isLeaf == '0'){
|
|
|
49
|
+ selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
|
|
|
50
|
+ renderSecondIndex(resType);
|
|
|
51
|
+ }else{
|
|
|
52
|
+ //curBizResType = resType;
|
|
|
53
|
+ $("div[data-id='"+busId+"']").find("div[data-id='"+resType+"'] .layui-tree-entry:first span.layui-tree-txt").trigger("click")
|
|
|
54
|
+ }
|
|
|
55
|
+ });
|
|
|
56
|
+ // 查看拓扑
|
|
|
57
|
+ $('#bizindexTable').on('click', '.bizcard-view-topo', function () {
|
|
|
58
|
+ common.viewBizTopo($(this).data('busid'));
|
|
|
59
|
+ return false;
|
|
|
60
|
+ });
|
|
|
61
|
+ //回车搜索
|
|
|
62
|
+ $('#bizindex_keyword').keydown(function (e) {
|
|
|
63
|
+ if (e.keyCode === 13) {
|
|
|
64
|
+ // renderList(busId, curBizResType);
|
|
|
65
|
+ reloadTable();
|
|
|
66
|
+ return false;
|
|
|
67
|
+ }
|
|
|
68
|
+ });
|
|
|
69
|
+
|
|
|
70
|
+ var loading = layer.load(2);
|
|
|
71
|
+
|
|
|
72
|
+ // 树收缩事件
|
|
|
73
|
+ $('#bizindex-leftree-shrink').on('click', function () {
|
|
|
74
|
+ $(".bizIndexLeft").animate({width:0,minWidth:0,marginLeft:0},300,function () {
|
|
|
75
|
+ $("#bizindex-leftree_btn").show();
|
|
|
76
|
+ $("#bizindex-leftree-shrink").hide();
|
|
|
77
|
+ });
|
|
|
78
|
+ });
|
|
|
79
|
+
|
|
|
80
|
+ //树展开事件
|
|
|
81
|
+ $("#bizindex-leftree_btn").on("click",function () {
|
|
|
82
|
+ $("#bizindex-leftree_btn").hide();
|
|
|
83
|
+ $("#bizindex-leftree-shrink").show();
|
|
|
84
|
+ $(".bizIndexLeft").animate({minWidth:250,marginLeft:10},300);
|
|
|
85
|
+ });
|
|
|
86
|
+
|
|
|
87
|
+ //this
|
|
|
88
|
+ loadBizTree();
|
|
|
89
|
+
|
|
|
90
|
+ function renderIndex(busId, resType) {
|
|
|
91
|
+ $('#bizIndexContent').show();
|
|
|
92
|
+ $('#bizListContent').hide();
|
|
|
93
|
+ $('#biztreeTableContent').hide();
|
|
|
94
|
+ $('#bizDetailContent').empty();
|
|
|
95
|
+ $('#bizDetailContent').hide();
|
|
|
96
|
+ var bizindexTable = $('#bizindexTable');
|
|
|
97
|
+ autoHeight(bizindexTable);
|
|
|
98
|
+ window.setResizeEvents('autoHeight', autoHeight);
|
|
|
99
|
+
|
|
|
100
|
+ bizindexTable.html('<div class="loading"></div>');
|
|
|
101
|
+ admin.req({
|
|
|
102
|
+ url: common.domainName + '/api-web/home/resource/healthByResType?pResType=' + resType + '&busId=' + busId,
|
|
|
103
|
+ }).done(function (res) {
|
|
|
104
|
+ laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
|
|
|
105
|
+ bizindexTable.html(html);
|
|
|
106
|
+ });
|
|
|
107
|
+ });
|
|
|
108
|
+ }
|
|
|
109
|
+
|
|
|
110
|
+ function renderDefaultIndex() {
|
|
|
111
|
+ $('#bizIndexContent').show();
|
|
|
112
|
+ $('#bizListContent').hide();
|
|
|
113
|
+ $('#biztreeTableContent').hide();
|
|
|
114
|
+ $('#bizDetailContent').empty();
|
|
|
115
|
+ $('#bizDetailContent').hide();
|
|
|
116
|
+ var bizindexTable = $('#bizindexTable');
|
|
|
117
|
+ autoHeight(bizindexTable);
|
|
|
118
|
+ window.setResizeEvents('autoHeight', autoHeight);
|
|
|
119
|
+ admin.req({
|
|
|
120
|
+ url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType',
|
|
|
121
|
+ }).done(function (res) {
|
|
|
122
|
+ layer.close(loading);
|
|
|
123
|
+ laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
|
|
|
124
|
+ bizindexTable.html(html);
|
|
|
125
|
+ });
|
|
|
126
|
+ });
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ function renderSecondIndex(parentId) {
|
|
|
130
|
+ $('#bizIndexContent').show();
|
|
|
131
|
+ $('#bizListContent').hide();
|
|
|
132
|
+ $('#biztreeTableContent').hide();
|
|
|
133
|
+ $('#bizDetailContent').empty();
|
|
|
134
|
+ $('#bizDetailContent').hide();
|
|
|
135
|
+ var bizindexTable = $('#bizindexTable');
|
|
|
136
|
+ autoHeight(bizindexTable);
|
|
|
137
|
+ window.setResizeEvents('autoHeight', autoHeight);
|
|
|
138
|
+ admin.req({
|
|
|
139
|
+ url: common.domainName + '/api-web/home/resource/countSecondNum?parentId='+parentId,
|
|
|
140
|
+ }).done(function (res) {
|
|
|
141
|
+ layer.close(loading);
|
|
|
142
|
+ laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
|
|
|
143
|
+ bizindexTable.html(html);
|
|
|
144
|
+ });
|
|
|
145
|
+ });
|
|
|
146
|
+ }
|
|
|
147
|
+
|
|
|
148
|
+ //详细页面
|
|
|
149
|
+ function renderDetail(resId, resType) {
|
|
|
150
|
+ $('#bizIndexContent').hide();
|
|
|
151
|
+ $('#bizListContent').hide();
|
|
|
152
|
+ $('#biztreeTableContent').hide();
|
|
|
153
|
+ $('#bizDetailContent').show();
|
|
|
154
|
+ var url = common.detailPath(resType);
|
|
|
155
|
+ view('commonViewModel').render(url).then(function (res) {
|
|
|
156
|
+ var params = {
|
|
|
157
|
+ "resId": resId,
|
|
|
158
|
+ "resType": resType
|
|
|
159
|
+ };
|
|
|
160
|
+ laytpl(res.body).render(JSON.stringify(params), function (html) {
|
|
|
161
|
+ $("#bizDetailContent").html(html);
|
|
|
162
|
+ });
|
|
|
163
|
+ });
|
|
|
164
|
+
|
|
|
165
|
+ }
|
|
|
166
|
+
|
|
|
167
|
+ //加载树节点
|
|
|
168
|
+ function loadBizTree(val) {
|
|
|
169
|
+ //获取树节点数据
|
|
|
170
|
+ $("#bizindextree").empty();
|
|
|
171
|
+ if (val == '' || val == null || val == undefined) {
|
|
|
172
|
+ val = '';
|
|
|
173
|
+ }
|
|
|
174
|
+ admin.req({
|
|
|
175
|
+ url: common.domainName + '/api-web/home/business/getBusTree?keyword=' + val + '¬Exist=machineroom',
|
|
|
176
|
+ sync: true,
|
|
|
177
|
+ done: function (res) {
|
|
|
178
|
+ $('.layui-form layui-card-header')
|
|
|
179
|
+ if (res.success) {
|
|
|
180
|
+ var data = res.data;
|
|
|
181
|
+ tree.render({
|
|
|
182
|
+ elem: '#bizindextree',
|
|
|
183
|
+ showLine: false,
|
|
|
184
|
+ data: data,
|
|
|
185
|
+ click: function (node) {
|
|
|
186
|
+ if (node && node.data && node.data.children && node.data.children.length == 1) {
|
|
|
187
|
+ $('[data-id="' + node.data.children[0].id + '"]').find('.layui-tree-iconClick:first').click()
|
|
|
188
|
+ }
|
|
|
189
|
+ curTreeNode = node;
|
|
|
190
|
+ curBizResType = node.data.id;
|
|
|
191
|
+ if (node.data.code) {
|
|
|
192
|
+ busId = JSON.parse(node.data.code)["busId"];
|
|
|
193
|
+ appId = JSON.parse(node.data.code)["appId"];
|
|
|
194
|
+ }
|
|
|
195
|
+ var el = null;
|
|
|
196
|
+ if (node.data.children) {
|
|
|
197
|
+ el = $(node.elem[0]).find('>.layui-tree-entry .layui-tree-txt');
|
|
|
198
|
+ } else {
|
|
|
199
|
+ el = $(node.elem[0]).find('.layui-tree-txt');
|
|
|
200
|
+ }
|
|
|
201
|
+
|
|
|
202
|
+ var action = 'removeClass';
|
|
|
203
|
+ if (!el.hasClass('tree-node-select') && node.state === 'open') {
|
|
|
204
|
+ action = 'addClass';
|
|
|
205
|
+ el.parents('.layui-tree').find('.tree-node-select').removeClass('tree-node-select');
|
|
|
206
|
+ }
|
|
|
207
|
+
|
|
|
208
|
+ el[action]('tree-node-select');
|
|
|
209
|
+ // 决定显示那个视图
|
|
|
210
|
+ var optionsStr = '';
|
|
|
211
|
+ if (node.data.code) {
|
|
|
212
|
+ optionsStr = JSON.parse(node.data.code)['options'];
|
|
|
213
|
+ }
|
|
|
214
|
+ if (optionsStr && optionsStr != "") {
|
|
|
215
|
+ options = JSON.parse(optionsStr);
|
|
|
216
|
+ var callback = options.bizCallBack;
|
|
|
217
|
+ var fun = eval(callback);
|
|
|
218
|
+ // 获取回调方法
|
|
|
219
|
+ if ($.isFunction(fun)) {
|
|
|
220
|
+ fun.call(this, data, node.data, options);
|
|
|
221
|
+ }
|
|
|
222
|
+ } else if (node.data.code && JSON.parse(node.data.code).isLeaf == '0') {
|
|
|
223
|
+ renderSecondIndex(node.data.id);
|
|
|
224
|
+ } else {
|
|
|
225
|
+ if (node.data && node.data.system) {
|
|
|
226
|
+ //操作系统
|
|
|
227
|
+ if (node.data.system.length > 0) {
|
|
|
228
|
+ renderSystem(node.data.system);
|
|
|
229
|
+ }
|
|
|
230
|
+ } else {
|
|
|
231
|
+ renderBizResTypeCard(node.data.id);
|
|
|
232
|
+ }
|
|
|
233
|
+
|
|
|
234
|
+ }
|
|
|
235
|
+ }
|
|
|
236
|
+ });
|
|
|
237
|
+ $("#bizTotal").html(res.count);
|
|
|
238
|
+ loadParamSelect();
|
|
|
239
|
+ resTopo();
|
|
|
240
|
+ }
|
|
|
241
|
+ }
|
|
|
242
|
+ }).error(function () {
|
|
|
243
|
+ layer.close(loading);
|
|
|
244
|
+ var data = new Array();
|
|
|
245
|
+ tree.render({
|
|
|
246
|
+ elem: '#bizindextree',
|
|
|
247
|
+ showLine: false,
|
|
|
248
|
+ data: data
|
|
|
249
|
+ });
|
|
|
250
|
+ $("#bizTotal").html('0')
|
|
|
251
|
+ laytpl($('#bizindexTpl').html()).render({list: new Array()}, function (html) {
|
|
|
252
|
+ $('#bizindexTable').html(html);
|
|
|
253
|
+ });
|
|
|
254
|
+ });
|
|
|
255
|
+ renderDefaultIndex();
|
|
|
256
|
+ }
|
|
|
257
|
+
|
|
|
258
|
+ $("#bizTotal").parent().on("click",function () {
|
|
|
259
|
+ renderDefaultIndex();
|
|
|
260
|
+ })
|
|
|
261
|
+
|
|
|
262
|
+ $(".layui-input-search").keyup(function (e) {
|
|
|
263
|
+ if (e.keyCode === 13) {
|
|
|
264
|
+ loadBizTree($(this).val())
|
|
|
265
|
+ }
|
|
|
266
|
+ });
|
|
|
267
|
+
|
|
|
268
|
+ //资源详细页面
|
|
|
269
|
+ function loadResDetailInfo(parentNode, data, node, options) {
|
|
|
270
|
+ var resId = data.id;
|
|
|
271
|
+ var resType = data.pid;
|
|
|
272
|
+ renderDetail(resId, resType);
|
|
|
273
|
+ }
|
|
|
274
|
+
|
|
|
275
|
+ function loadChildResTypeCount(parentNode, data, node, options) {
|
|
|
276
|
+ var resId = data.id;
|
|
|
277
|
+ for (var i = 0; i < parentNode.length; i++) {
|
|
|
278
|
+ if (parentNode.id == data.id) {
|
|
|
279
|
+ resId = '';
|
|
|
280
|
+ break;
|
|
|
281
|
+ }
|
|
|
282
|
+ }
|
|
|
283
|
+ var code = JSON.parse(data.code);
|
|
|
284
|
+ renderIndex(code.busId, resId);
|
|
|
285
|
+ }
|
|
|
286
|
+
|
|
|
287
|
+ function loadChildBusCount(parentNode, data, node, options) {
|
|
|
288
|
+ var resId = data.id;
|
|
|
289
|
+ for (var i = 0; i < parentNode.length; i++) {
|
|
|
290
|
+ if (parentNode.id == data.id) {
|
|
|
291
|
+ resId = '';
|
|
|
292
|
+ break;
|
|
|
293
|
+ }
|
|
|
294
|
+ }
|
|
|
295
|
+ var code = JSON.parse(data.code);
|
|
|
296
|
+ renderSecondIndex(code.busId);
|
|
|
297
|
+ }
|
|
|
298
|
+
|
|
|
299
|
+ function openResourceView(parentNode, data, node, options) {
|
|
|
300
|
+ var code = JSON.parse(data.code);
|
|
|
301
|
+ renderList(code.busId, data.id);
|
|
|
302
|
+ }
|
|
|
303
|
+ //资源视图父级列表
|
|
|
304
|
+ function openParentResourceView(parentNode, data, node, options) {
|
|
|
305
|
+ var code = JSON.parse(data.code);
|
|
|
306
|
+ renderParentList(code.busId, data.id);
|
|
|
307
|
+ }
|
|
|
308
|
+
|
|
|
309
|
+ //加载虚拟化数据(平台、资源池、物理机、虚拟机)
|
|
|
310
|
+ function loadVirtualizationView(parentNode, data, node, options) {
|
|
|
311
|
+ renderTreeTable(busId, data.id);
|
|
|
312
|
+ }
|
|
|
313
|
+ //加载weblogic
|
|
|
314
|
+ function loadWeblogicView(parentNode, data, node, options) {
|
|
|
315
|
+ renderParentList(busId, data.id);
|
|
|
316
|
+ }
|
|
|
317
|
+
|
|
|
318
|
+ //资源状态
|
|
|
319
|
+ form.on('select(biz_resStatus)', function (data) {
|
|
|
320
|
+ // renderList(busId, curBizResType)
|
|
|
321
|
+ reloadTable();
|
|
|
322
|
+ });
|
|
|
323
|
+ //集群选择事件
|
|
|
324
|
+ form.on('select(biz_res_cluster)', function (data) {
|
|
|
325
|
+ // renderList(busId, curBizResType);
|
|
|
326
|
+ reloadTable();
|
|
|
327
|
+ });
|
|
|
328
|
+ //资源池选择事件
|
|
|
329
|
+ form.on('select(biz_res_colony)', function (data) {
|
|
|
330
|
+ // renderList(busId, curBizResType);
|
|
|
331
|
+ reloadTable();
|
|
|
332
|
+ });
|
|
|
333
|
+ //资源连接状态选择事件
|
|
|
334
|
+ form.on('select(biz_state)', function (data) {
|
|
|
335
|
+ // renderList(busId, curBizResType);
|
|
|
336
|
+ reloadTable();
|
|
|
337
|
+ });
|
|
|
338
|
+
|
|
|
339
|
+ //资源连接状态选择事件
|
|
|
340
|
+ form.on('select(biz_platform)', function (data) {
|
|
|
341
|
+ // renderList(busId, curBizResType);
|
|
|
342
|
+ reloadTable();
|
|
|
343
|
+ });
|
|
|
344
|
+ //连接状态
|
|
|
345
|
+ form.on('select(bizlink_state)', function (data) {
|
|
|
346
|
+ // renderList(currentResType);
|
|
|
347
|
+ reloadTable();
|
|
|
348
|
+ });
|
|
|
349
|
+ //连接状态
|
|
|
350
|
+ form.on('select(bizlink_state)', function (data) {
|
|
|
351
|
+ // renderList(currentResType);
|
|
|
352
|
+ reloadTable();
|
|
|
353
|
+ });
|
|
|
354
|
+ //资源池选择事件
|
|
|
355
|
+ form.on('select(biz_sub_restype)', function (data) {
|
|
|
356
|
+ // renderList(currentResType);
|
|
|
357
|
+ if (data.value) {
|
|
|
358
|
+ bizLoadRightResTypeSelectEvent(busId, data.value, 'normal')
|
|
|
359
|
+ } else {
|
|
|
360
|
+ bizLoadRightResTypeSelectEvent(busId, curTreeNode.data.id, 'normal')
|
|
|
361
|
+ }
|
|
|
362
|
+ reloadTable();
|
|
|
363
|
+ });
|
|
|
364
|
+
|
|
|
365
|
+ //操作系统
|
|
|
366
|
+ function renderSystem(system) {
|
|
|
367
|
+ $('#bizIndexContent').hide();
|
|
|
368
|
+ $('#bizListContent').show();
|
|
|
369
|
+ $('#bizDetailContent').empty();
|
|
|
370
|
+ $('#bizDetailContent').hide();
|
|
|
371
|
+ $('#biztreeTableContent').hide();
|
|
|
372
|
+
|
|
|
373
|
+ //清除查询条件
|
|
|
374
|
+ $("#bizindex_keyword").val("");
|
|
|
375
|
+ $("#biz_resStatus").val("");
|
|
|
376
|
+ $("#biz_res_colony").val("");
|
|
|
377
|
+ $("#biz_res_cluster").val("");
|
|
|
378
|
+ $("#bizlink_state").val("");
|
|
|
379
|
+ $("#biz_state").val("");
|
|
|
380
|
+ busId="";
|
|
|
381
|
+ //隐藏资源类型
|
|
|
382
|
+ $("#biz_sub_restype").parent().parent().addClass("hide");
|
|
|
383
|
+ form.render('select');
|
|
|
384
|
+
|
|
|
385
|
+ form.render(null, 'biz-list-form');
|
|
|
386
|
+ var cols = commonCols.resTypeCls["OperatingSystem"];
|
|
|
387
|
+ var resTypeList=[];
|
|
|
388
|
+ $.each(system, function (i, v) {
|
|
|
389
|
+ resTypeList.push(v.value);
|
|
|
390
|
+ busId=v.pid;
|
|
|
391
|
+ });
|
|
|
392
|
+ //获取配置的列
|
|
|
393
|
+ common.getTableCols({
|
|
|
394
|
+ domId: 'bizListTable',
|
|
|
395
|
+ moduleId: 'bizIndex',
|
|
|
396
|
+ resType: 'OperatingSystem'
|
|
|
397
|
+ },function (retCols) {
|
|
|
398
|
+ if (retCols) {
|
|
|
399
|
+ cols = retCols;
|
|
|
400
|
+ }
|
|
|
401
|
+ bizListTable = table.render({
|
|
|
402
|
+ elem: '#bizListTable'
|
|
|
403
|
+ // //, toolbar: '<div><button id="bizIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' //开启头部工具栏,并为其绑定左侧模板
|
|
|
404
|
+ , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
|
|
|
405
|
+ , defaultToolbar: ['filter']
|
|
|
406
|
+ , drag: {toolbar: false}
|
|
|
407
|
+ , url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString()
|
|
|
408
|
+ , where: {
|
|
|
409
|
+ access_token: accessToken,
|
|
|
410
|
+ resName: $("#bizindex_keyword").val(),
|
|
|
411
|
+ resHealth: $("#biz_resStatus").val(),
|
|
|
412
|
+ busId: busId,
|
|
|
413
|
+ colonlyId: $("#biz_res_colony").val(),
|
|
|
414
|
+ parentId: $("#biz_res_cluster").val(),
|
|
|
415
|
+ linkState: $("#bizlink_state").val(),
|
|
|
416
|
+ state: $("#biz_state").val(),
|
|
|
417
|
+ resCategory: 'resources',
|
|
|
418
|
+ }
|
|
|
419
|
+ , height: 'full-165'
|
|
|
420
|
+ , cellMinWidth: 80
|
|
|
421
|
+ , page: {
|
|
|
422
|
+ layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
|
|
|
423
|
+ , theme: '#1E9FFF'
|
|
|
424
|
+ }
|
|
|
425
|
+ , autoSort: false
|
|
|
426
|
+ , cols: [cols]
|
|
|
427
|
+ , done: function (res) {
|
|
|
428
|
+ soulTable.render(this);
|
|
|
429
|
+ getResCount(busId, resTypeList.toString());
|
|
|
430
|
+ commonCols.colsClickEvent();
|
|
|
431
|
+
|
|
|
432
|
+ bizLoadRightResTypeSelectEvent(busId, 'OperatingSystem', 'normal', res.obj);
|
|
|
433
|
+ //表格排序监听 joke add 20200408
|
|
|
434
|
+ table.on('sort(bizListTable)', function (obj) {
|
|
|
435
|
+ //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
|
|
|
436
|
+ if (obj.type != null) {
|
|
|
437
|
+ sortKey = obj.field + ' ' + obj.type;
|
|
|
438
|
+ } else {
|
|
|
439
|
+ sortKey = '';
|
|
|
440
|
+ }
|
|
|
441
|
+ reloadTable();
|
|
|
442
|
+ })
|
|
|
443
|
+ //触发拖动列事件,参数为保存按钮的id
|
|
|
444
|
+ common.dragCols("bizIndex_cols_save");
|
|
|
445
|
+ //保存列顺序
|
|
|
446
|
+ $("#bizIndex_cols_save").unbind("click").on("click", function () {
|
|
|
447
|
+ var params = {
|
|
|
448
|
+ domId: 'bizListTable',
|
|
|
449
|
+ moduleId: 'bizIndex',
|
|
|
450
|
+ resType: 'OperatingSystem',
|
|
|
451
|
+ cols: bizListTable.config.cols
|
|
|
452
|
+ }
|
|
|
453
|
+ common.saveTableCols(params);
|
|
|
454
|
+ });
|
|
|
455
|
+ resTopo();
|
|
|
456
|
+ }
|
|
|
457
|
+ });
|
|
|
458
|
+ });
|
|
|
459
|
+
|
|
|
460
|
+ }
|
|
|
461
|
+ //获取业务下的资源类型健康统计
|
|
|
462
|
+ function renderBizResTypeCard(bizId) {
|
|
|
463
|
+ busId = bizId;
|
|
|
464
|
+ $('#bizIndexContent').show();
|
|
|
465
|
+ $('#bizListContent').hide();
|
|
|
466
|
+ $('#biztreeTableContent').hide();
|
|
|
467
|
+ $('#bizDetailContent').empty();
|
|
|
468
|
+ $('#bizDetailContent').hide();
|
|
|
469
|
+ var bizindexTable = $('#bizindexTable');
|
|
|
470
|
+ autoHeight(bizindexTable);
|
|
|
471
|
+ window.setResizeEvents('autoHeight', autoHeight);
|
|
|
472
|
+ admin.req({
|
|
|
473
|
+ url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId
|
|
|
474
|
+ , done: function (res) {
|
|
|
475
|
+ laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
|
|
|
476
|
+ bizindexTable.html(html);
|
|
|
477
|
+ });
|
|
|
478
|
+ }
|
|
|
479
|
+ });
|
|
|
480
|
+ }
|
|
|
481
|
+
|
|
|
482
|
+
|
|
|
483
|
+ function renderParentList(busId, resType) {
|
|
|
484
|
+ $('#bizIndexContent').hide();
|
|
|
485
|
+ $('#bizListContent').show();
|
|
|
486
|
+ $('#bizDetailContent').empty();
|
|
|
487
|
+ $('#bizDetailContent').hide();
|
|
|
488
|
+ $('#biztreeTableContent').hide();
|
|
|
489
|
+ renderBizSerach(resType, busId, true);
|
|
|
490
|
+ form.render(null, 'biz-list-form');
|
|
|
491
|
+ var cols = commonCols.resTypeCls[resType];
|
|
|
492
|
+ //获取配置的列
|
|
|
493
|
+ common.getTableCols({
|
|
|
494
|
+ domId: 'bizParentList',
|
|
|
495
|
+ moduleId: 'bizIndex',
|
|
|
496
|
+ resType: resType
|
|
|
497
|
+ },function (retCols) {
|
|
|
498
|
+ if (retCols) {
|
|
|
499
|
+ cols = retCols;
|
|
|
500
|
+ }
|
|
|
501
|
+ bizParentList = table.render({
|
|
|
502
|
+ elem: '#bizListTable'
|
|
|
503
|
+ , url: common.domainName + '/api-web/home/res-list/' + resType
|
|
|
504
|
+ , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
|
|
|
505
|
+ , defaultToolbar: ['filter']
|
|
|
506
|
+ , drag: {toolbar: false}
|
|
|
507
|
+ , where: {
|
|
|
508
|
+ access_token: accessToken,
|
|
|
509
|
+ resName: $("#bizindex_keyword").val(),
|
|
|
510
|
+ resHealth: $("#biz_resStatus").val(),
|
|
|
511
|
+ busId: busId,
|
|
|
512
|
+ colonlyId: $("#biz_res_colony").val(),
|
|
|
513
|
+ parentId: $("#biz_res_cluster").val(),
|
|
|
514
|
+ linkState: $("#bizlink_state").val(),
|
|
|
515
|
+ state: $("#biz_state").val(),
|
|
|
516
|
+ resCategory: 'resources'
|
|
|
517
|
+ }
|
|
|
518
|
+ , height: 'full-165'
|
|
|
519
|
+ , cellMinWidth: 80
|
|
|
520
|
+ , page: {
|
|
|
521
|
+ layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
|
|
|
522
|
+ , theme: '#1E9FFF'
|
|
|
523
|
+ }
|
|
|
524
|
+ , autoSort: false
|
|
|
525
|
+ , cols: [cols]
|
|
|
526
|
+ , done: function (res) {
|
|
|
527
|
+ soulTable.render(this)
|
|
|
528
|
+ getResCount(busId, resType)
|
|
|
529
|
+
|
|
|
530
|
+ commonCols.colsClickEvent();
|
|
|
531
|
+
|
|
|
532
|
+ //表格排序监听 joke add 20200408
|
|
|
533
|
+ table.on('sort(bizListTable)', function (obj) {
|
|
|
534
|
+ //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
|
|
|
535
|
+ if (obj.type != null) {
|
|
|
536
|
+ sortKey = obj.field + ' ' + obj.type;
|
|
|
537
|
+ } else {
|
|
|
538
|
+ sortKey = '';
|
|
|
539
|
+ }
|
|
|
540
|
+ reloadTable();
|
|
|
541
|
+ })
|
|
|
542
|
+
|
|
|
543
|
+ //触发拖动列事件,参数为保存按钮的id
|
|
|
544
|
+ common.dragCols("bizIndex_cols_save");
|
|
|
545
|
+
|
|
|
546
|
+ bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
|
|
|
547
|
+ //保存列顺序
|
|
|
548
|
+ $("#bizIndex_cols_save").unbind("click").on("click", function () {
|
|
|
549
|
+ var params = {
|
|
|
550
|
+ domId: 'bizParentList',
|
|
|
551
|
+ moduleId: 'bizIndex',
|
|
|
552
|
+ resType: resType,
|
|
|
553
|
+ cols: bizParentList.config.cols
|
|
|
554
|
+ }
|
|
|
555
|
+ common.saveTableCols(params);
|
|
|
556
|
+ });
|
|
|
557
|
+ resTopo();
|
|
|
558
|
+ }
|
|
|
559
|
+ });
|
|
|
560
|
+ });
|
|
|
561
|
+ }
|
|
|
562
|
+ //资源列表
|
|
|
563
|
+ function renderList(busId, resType) {
|
|
|
564
|
+ $('#bizIndexContent').hide();
|
|
|
565
|
+ $('#bizListContent').show();
|
|
|
566
|
+ $('#bizDetailContent').empty();
|
|
|
567
|
+ $('#bizDetailContent').hide();
|
|
|
568
|
+ $('#biztreeTableContent').hide();
|
|
|
569
|
+
|
|
|
570
|
+ renderBizSerach(resType, busId);
|
|
|
571
|
+
|
|
|
572
|
+ form.render(null, 'biz-list-form');
|
|
|
573
|
+ var cols = commonCols.resTypeCls[resType];
|
|
|
574
|
+ //获取配置的列
|
|
|
575
|
+ common.getTableCols({
|
|
|
576
|
+ domId: 'bizListTable',
|
|
|
577
|
+ moduleId: 'bizIndex',
|
|
|
578
|
+ resType: resType
|
|
|
579
|
+ },function (retCols) {
|
|
|
580
|
+ if (retCols) {
|
|
|
581
|
+ cols = retCols;
|
|
|
582
|
+ }
|
|
|
583
|
+ bizListTable = table.render({
|
|
|
584
|
+ elem: '#bizListTable'
|
|
|
585
|
+ //, toolbar: '<div><button id="bizIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' //开启头部工具栏,并为其绑定左侧模板
|
|
|
586
|
+ , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
|
|
|
587
|
+ , defaultToolbar: ['filter']
|
|
|
588
|
+ , drag: {toolbar: false}
|
|
|
589
|
+ , url: common.domainName + '/api-web/home/res-list/' + resType
|
|
|
590
|
+ , where: {
|
|
|
591
|
+ access_token: accessToken,
|
|
|
592
|
+ resName: $("#bizindex_keyword").val(),
|
|
|
593
|
+ resHealth: $("#biz_resStatus").val(),
|
|
|
594
|
+ busId: busId,
|
|
|
595
|
+ colonlyId: $("#biz_res_colony").val(),
|
|
|
596
|
+ parentId: $("#biz_res_cluster").val(),
|
|
|
597
|
+ linkState: $("#bizlink_state").val(),
|
|
|
598
|
+ state: $("#biz_state").val(),
|
|
|
599
|
+ resCategory: 'resources'
|
|
|
600
|
+ }
|
|
|
601
|
+ , height: 'full-165'
|
|
|
602
|
+ , cellMinWidth: 80
|
|
|
603
|
+ , page: {
|
|
|
604
|
+ layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
|
|
|
605
|
+ , theme: '#1E9FFF'
|
|
|
606
|
+ }
|
|
|
607
|
+ , autoSort: false
|
|
|
608
|
+ , cols: [cols]
|
|
|
609
|
+ , done: function (res) {
|
|
|
610
|
+ soulTable.render(this)
|
|
|
611
|
+ getResCount(busId, resType)
|
|
|
612
|
+
|
|
|
613
|
+ commonCols.colsClickEvent();
|
|
|
614
|
+
|
|
|
615
|
+ //表格排序监听 joke add 20200408
|
|
|
616
|
+ table.on('sort(bizListTable)', function (obj) {
|
|
|
617
|
+ //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
|
|
|
618
|
+ if (obj.type != null) {
|
|
|
619
|
+ sortKey = obj.field + ' ' + obj.type;
|
|
|
620
|
+ } else {
|
|
|
621
|
+ sortKey = '';
|
|
|
622
|
+ }
|
|
|
623
|
+ reloadTable();
|
|
|
624
|
+ })
|
|
|
625
|
+
|
|
|
626
|
+ //触发拖动列事件,参数为保存按钮的id
|
|
|
627
|
+ common.dragCols("bizIndex_cols_save");
|
|
|
628
|
+ bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
|
|
|
629
|
+
|
|
|
630
|
+ //保存列顺序
|
|
|
631
|
+ $("#bizIndex_cols_save").unbind("click").on("click", function () {
|
|
|
632
|
+ var params = {
|
|
|
633
|
+ domId: 'bizListTable',
|
|
|
634
|
+ moduleId: 'bizIndex',
|
|
|
635
|
+ resType: resType,
|
|
|
636
|
+ cols: bizListTable.config.cols
|
|
|
637
|
+ }
|
|
|
638
|
+ common.saveTableCols(params);
|
|
|
639
|
+ });
|
|
|
640
|
+ resTopo();
|
|
|
641
|
+ }
|
|
|
642
|
+ });
|
|
|
643
|
+ });
|
|
|
644
|
+ }
|
|
|
645
|
+
|
|
|
646
|
+ //树表格
|
|
|
647
|
+ function renderTreeTable(busId, resType) {
|
|
|
648
|
+ $('#bizIndexContent').hide();
|
|
|
649
|
+ $('#bizListContent').hide();
|
|
|
650
|
+ $('#bizDetailContent').empty();
|
|
|
651
|
+ $('#bizDetailContent').hide();
|
|
|
652
|
+ $('#biztreeTableContent').show();
|
|
|
653
|
+ $(".top-head-info").removeClass("hide");
|
|
|
654
|
+ layer.load(2); //加载层。
|
|
|
655
|
+
|
|
|
656
|
+ //非平台才有以下三个指标信息
|
|
|
657
|
+ if (resType != 'VIRTUALIZATION_VMWARE') {
|
|
|
658
|
+ //绑定虚拟化平台
|
|
|
659
|
+ common.virtualPlatFormSelect("biz_virtual_platForm_select", busId, function () {
|
|
|
660
|
+ form.render("select");
|
|
|
661
|
+ });
|
|
|
662
|
+ if(resType == 'MIDDLEWARE_WEBLOGIC'){
|
|
|
663
|
+ $("#biz_virtual_platform_div_id").hide();
|
|
|
664
|
+ }
|
|
|
665
|
+ } else {
|
|
|
666
|
+ $("#biz_virtual_platform_div_id").hide();
|
|
|
667
|
+ }
|
|
|
668
|
+
|
|
|
669
|
+ var cols = commonCols.resTypeCls[resType];
|
|
|
670
|
+
|
|
|
671
|
+ admin.req({
|
|
|
672
|
+ url: common.domainName + "/api-web/home/virtual-res-list/" + resType
|
|
|
673
|
+ , data: {
|
|
|
674
|
+ ptId: $("#biz_virtual_platForm_select").val(),
|
|
|
675
|
+ health: $("#biz_treetable_resStatus").val(),
|
|
|
676
|
+ busId: busId,
|
|
|
677
|
+ keyWords: $("#biz_treetable_keyword").val(),
|
|
|
678
|
+ state: $("#biz_treetable_res_state").val()
|
|
|
679
|
+ }
|
|
|
680
|
+ , done: function (res) {
|
|
|
681
|
+ if (res.code == 0) {
|
|
|
682
|
+ var bizTableTreeVirtual;
|
|
|
683
|
+ //获取配置的列
|
|
|
684
|
+ common.getTableCols({
|
|
|
685
|
+ domId: 'bizTableTreeVirtual',
|
|
|
686
|
+ moduleId: 'bizIndex',
|
|
|
687
|
+ resType: resType
|
|
|
688
|
+ },function (retCols) {
|
|
|
689
|
+ if (retCols) {
|
|
|
690
|
+ cols = retCols;
|
|
|
691
|
+ }
|
|
|
692
|
+ bizTableTreeVirtual = table.render({
|
|
|
693
|
+ elem: '#biz_virtual_platform_treeTable',
|
|
|
694
|
+ data: res.data,
|
|
|
695
|
+ treeConfig: { //表格树所需配置
|
|
|
696
|
+ showField: 'resName' //表格树显示的字段
|
|
|
697
|
+ , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。
|
|
|
698
|
+ , treepid: ''//父级id字段名称
|
|
|
699
|
+ , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer
|
|
|
700
|
+ },
|
|
|
701
|
+ tree: {
|
|
|
702
|
+ iconIndex: 1
|
|
|
703
|
+ },
|
|
|
704
|
+ page: false,
|
|
|
705
|
+ limit: 9999,
|
|
|
706
|
+ autoColumnWidth: false,
|
|
|
707
|
+ cols: [cols]
|
|
|
708
|
+ , height: 'full-220',
|
|
|
709
|
+ done: function (res){
|
|
|
710
|
+ soulTable.render(this);
|
|
|
711
|
+ common.treeTableDragCols('#biz_virtual_platform_treeTable', '#bizTreeList-top-head-info-tpl');
|
|
|
712
|
+ bizLoadRightResTypeSelectEvent(busId, resType, 'tree', res.obj);
|
|
|
713
|
+ // 保存列顺序
|
|
|
714
|
+ $('#biz_virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){
|
|
|
715
|
+ common.saveTableCols({
|
|
|
716
|
+ domId: 'bizTableTreeVirtual',
|
|
|
717
|
+ moduleId: 'bizIndex',
|
|
|
718
|
+ resType: resType,
|
|
|
719
|
+ cols: bizTableTreeVirtual.config.cols
|
|
|
720
|
+ });
|
|
|
721
|
+ });
|
|
|
722
|
+ commonCols.colsClickEvent();
|
|
|
723
|
+ resTopo();
|
|
|
724
|
+ }
|
|
|
725
|
+ });
|
|
|
726
|
+ /*bizTableTreeVirtual.on('tool(tableEvent)',function (obj) {
|
|
|
727
|
+ if(!obj.data.treeList){
|
|
|
728
|
+ var field = obj.field; //单元格字段
|
|
|
729
|
+ var value = obj.value; //修改后的值
|
|
|
730
|
+ var data = obj.data; //当前行数据
|
|
|
731
|
+ var event = obj.event; //当前单元格事件属性值
|
|
|
732
|
+ var subResType = '';
|
|
|
733
|
+ if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){
|
|
|
734
|
+ subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER';
|
|
|
735
|
+ }else if(data.resType.indexOf('CLUSTER')>-1){
|
|
|
736
|
+ subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST';
|
|
|
737
|
+ }else if(data.resType.indexOf('PHYSICSHOST')>-1){
|
|
|
738
|
+ subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST';
|
|
|
739
|
+ }else{
|
|
|
740
|
+ subResType = data.resType
|
|
|
741
|
+ }
|
|
|
742
|
+ if(event === 'loadChildren'){
|
|
|
743
|
+ $.ajax({
|
|
|
744
|
+ url: common.domainName + "/api-web/home/virtual-res-list/" + subResType
|
|
|
745
|
+ , type: "get"
|
|
|
746
|
+ , data: {
|
|
|
747
|
+ ptId: $("#biz_virtual_platForm_select").val(),
|
|
|
748
|
+ health: $("#treetable_resStatus").val(),
|
|
|
749
|
+ busId: busId,
|
|
|
750
|
+ keyWords: $("#biz_treetable_keyword").val(),
|
|
|
751
|
+ state: $("#biz_treetable_state").val(),
|
|
|
752
|
+ access_token:accessToken,
|
|
|
753
|
+ parentId:data.resId
|
|
|
754
|
+ }
|
|
|
755
|
+ , success: function (res) {
|
|
|
756
|
+ if (res.data.length > 0) {
|
|
|
757
|
+ obj.loadChildren(res.data);
|
|
|
758
|
+ commonCols.colsClickEvent();
|
|
|
759
|
+ }
|
|
|
760
|
+ }
|
|
|
761
|
+ })
|
|
|
762
|
+ }
|
|
|
763
|
+ }
|
|
|
764
|
+ });*/
|
|
|
765
|
+ //统计总数
|
|
|
766
|
+ // $('#biz_virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#biz-treetable-countTpl').html()).render(res.data.length));
|
|
|
767
|
+ });
|
|
|
768
|
+ } else {
|
|
|
769
|
+ console.log(data.msg);
|
|
|
770
|
+ }
|
|
|
771
|
+ layer.closeAll();
|
|
|
772
|
+ //关键字回车事件
|
|
|
773
|
+ $('#biz_treetable_keyword').keydown(function (e) {
|
|
|
774
|
+ if (e.keyCode === 13) {
|
|
|
775
|
+ renderTreeTable(busId, curTreeNode.data.id)
|
|
|
776
|
+ return false;
|
|
|
777
|
+ }
|
|
|
778
|
+ });
|
|
|
779
|
+ //选择资源状态
|
|
|
780
|
+ form.on('select(biz_treetable_resStatus)', function (data) {
|
|
|
781
|
+ renderTreeTable(busId, curTreeNode.data.id);
|
|
|
782
|
+ });
|
|
|
783
|
+ //选择业务
|
|
|
784
|
+ form.on('select(treetableBizTypes)', function (data) {
|
|
|
785
|
+ renderTreeTable(busId, curTreeNode.data.id);
|
|
|
786
|
+ });
|
|
|
787
|
+ //选择业务
|
|
|
788
|
+ form.on('select(biz_treetable_res_state)', function (data) {
|
|
|
789
|
+ renderTreeTable(busId, curTreeNode.data.id);
|
|
|
790
|
+ });
|
|
|
791
|
+
|
|
|
792
|
+ //选择平台
|
|
|
793
|
+ form.on('select(biz_virtual_platForm_select)', function (data) {
|
|
|
794
|
+ renderTreeTable(busId, curTreeNode.data.id);
|
|
|
795
|
+ });
|
|
|
796
|
+ //资源连接状态选择时间
|
|
|
797
|
+ form.on('select(biz_treetable_state)', function (data) {
|
|
|
798
|
+ renderTreeTable(busId, curTreeNode.data.id);
|
|
|
799
|
+ });
|
|
|
800
|
+ }
|
|
|
801
|
+ }).error(function () {
|
|
|
802
|
+ layer.closeAll();
|
|
|
803
|
+ });
|
|
|
804
|
+ }
|
|
|
805
|
+
|
|
|
806
|
+ //获取资源统计
|
|
|
807
|
+ function getResCount(busId, resType) {
|
|
|
808
|
+ admin.req({
|
|
|
809
|
+ url: common.domainName + "/api-web/home/res-list/count/" + resType + "?busId=" + busId
|
|
|
810
|
+ , done: function (data) {
|
|
|
811
|
+ var rest = data.map;
|
|
|
812
|
+ if (data.code === 0) {
|
|
|
813
|
+ $("#resGoodCount").text("优:" + rest.good);
|
|
|
814
|
+ $("#resWorseCount").text("良:" + rest.worse);
|
|
|
815
|
+ $("#resWorstCount").text("中:" + rest.worst);
|
|
|
816
|
+ } else {
|
|
|
817
|
+ console.log(data.msg);
|
|
|
818
|
+ }
|
|
|
819
|
+ }
|
|
|
820
|
+ });
|
|
|
821
|
+ }
|
|
|
822
|
+
|
|
|
823
|
+ //回选树节点
|
|
|
824
|
+ function selectedBizTreeNode(target, type) {
|
|
|
825
|
+ $(".layui-tree-txt").removeClass("tree-node-select")
|
|
|
826
|
+ if (type == 'biz') { //如果是业务,默认展开第一节点
|
|
|
827
|
+ $(target).addClass("layui-tree-spread");
|
|
|
828
|
+ $(target).find(".layui-tree-entry").find('.layui-tree-txt').eq(0).addClass("tree-node-select");
|
|
|
829
|
+ $(target).parent().show();
|
|
|
830
|
+ $(target).find(".layui-tree-pack").eq(0).show();
|
|
|
831
|
+ } else if (type == 'select') {
|
|
|
832
|
+ $(target).parent().show();
|
|
|
833
|
+ $(target).find(".layui-tree-txt:first").addClass("tree-node-select");
|
|
|
834
|
+ } else {
|
|
|
835
|
+ var el = $('[data-id="' + busId + '"]').find(target);
|
|
|
836
|
+ $(target).parent().show();
|
|
|
837
|
+ el.find(".layui-tree-txt").addClass("tree-node-select")
|
|
|
838
|
+ }
|
|
|
839
|
+ }
|
|
|
840
|
+
|
|
|
841
|
+ //加载资源池、集群等查询条件
|
|
|
842
|
+ function renderBizSerach(resType, busId, subflag) {
|
|
|
843
|
+ //清空查询条件 joke add 20200409 开始
|
|
|
844
|
+ $('#bizindex_keyword').val('');
|
|
|
845
|
+ $('#biz_resStatus').val('');
|
|
|
846
|
+ $('#biz_res_colony').val('');
|
|
|
847
|
+ $('#biz_res_cluster').val('');
|
|
|
848
|
+ form.render('select');
|
|
|
849
|
+ //清空查询条件 joke add 20200409 开始
|
|
|
850
|
+
|
|
|
851
|
+
|
|
|
852
|
+ var targetId = '';
|
|
|
853
|
+ var searchType = "";
|
|
|
854
|
+ var optons = "";
|
|
|
855
|
+ //华为云物理机,加载华为云集群查询条件
|
|
|
856
|
+ if (resType == 'HUAWEI_CLOUD_PHYSICSHOST') {
|
|
|
857
|
+ optons = "<option value=''>=所属集群=</option>"
|
|
|
858
|
+ searchType = "HUAWEI_CLOUD_CLUSTER";
|
|
|
859
|
+ targetId = "biz_res_cluster";
|
|
|
860
|
+ $("#biz_res_cluster_id").show();
|
|
|
861
|
+ } else if ("MIDDLEWARE_WEBLOGIC" == resType) {
|
|
|
862
|
+ optons = "<option value=''>=所属控制台=</option>"
|
|
|
863
|
+ searchType = "MIDDLEWARE_WEBLOGIC";
|
|
|
864
|
+ targetId = 'biz_res_cluster'
|
|
|
865
|
+ $("#biz_res_cluster_id").show();
|
|
|
866
|
+ } else {
|
|
|
867
|
+ $("#biz_res_cluster_id").hide();
|
|
|
868
|
+ }
|
|
|
869
|
+ //华为云的集群、虚拟化物理机,查询条件绑定资源池
|
|
|
870
|
+ if (resType == 'HUAWEI_CLOUD_CLUSTER' || resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
|
|
|
871
|
+ optons = "<option value=''>=所属资源池=</option>"
|
|
|
872
|
+ if (resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
|
|
|
873
|
+ searchType = "VIRTUALIZATION_VMWARE_CLUSTER";
|
|
|
874
|
+ }
|
|
|
875
|
+ if (resType == 'HUAWEI_CLOUD_CLUSTER') {
|
|
|
876
|
+ searchType = "HUAWEI_CLOUD_COLONY";
|
|
|
877
|
+ }
|
|
|
878
|
+ targetId = "biz_res_colony";
|
|
|
879
|
+ $("#biz_res_colony_id").show();
|
|
|
880
|
+ } else {
|
|
|
881
|
+ $("#biz_res_colony_id").hide();
|
|
|
882
|
+ }
|
|
|
883
|
+ if ("MIDDLEWARE_WEBLOGIC" == resType) {
|
|
|
884
|
+ $("#biz_platform_id").hide()
|
|
|
885
|
+ }
|
|
|
886
|
+
|
|
|
887
|
+ if (resType == 'VIRTUALIZATION_VMWARE' || resType == 'VIRTUALIZATION_HUAWEI' || resType == 'MIDDLEWARE_WEBLOGIC') {
|
|
|
888
|
+ $("#biz_virtual_platform_div_id").hide();
|
|
|
889
|
+ }
|
|
|
890
|
+ if (targetId && searchType) {
|
|
|
891
|
+ var url = "/api-web/home/res-list/" + searchType + "?page=1&limit=50&busId=" + busId;
|
|
|
892
|
+ if(searchType == 'MIDDLEWARE_WEBLOGIC'){
|
|
|
893
|
+ url += '&parentId=null'
|
|
|
894
|
+ }
|
|
|
895
|
+ admin.req({
|
|
|
896
|
+ url: common.domainName + url
|
|
|
897
|
+ }).done(function (res) {
|
|
|
898
|
+ if (res.data) {
|
|
|
899
|
+ $.each(res.data, function (i, v) {
|
|
|
900
|
+ optons += '<option value="' + v.resId + '">' + v.resName + '</option>';
|
|
|
901
|
+ });
|
|
|
902
|
+ }
|
|
|
903
|
+ $('#' + targetId).html(optons);
|
|
|
904
|
+ form.render("select");
|
|
|
905
|
+ })
|
|
|
906
|
+ }
|
|
|
907
|
+
|
|
|
908
|
+ //vmware虚拟机 joke add 20200528
|
|
|
909
|
+ if (resType == 'VIRTUALIZATION_VMWARE_VHOST') {
|
|
|
910
|
+ $("#biz_platform_id").show();
|
|
|
911
|
+ //绑定虚拟化平台
|
|
|
912
|
+ common.virtualPlatFormSelect("biz_platform", "", function () {
|
|
|
913
|
+ form.render("select");
|
|
|
914
|
+ });
|
|
|
915
|
+ } else {
|
|
|
916
|
+ $("#biz_platform_id").hide();
|
|
|
917
|
+ }
|
|
|
918
|
+ if(subflag){
|
|
|
919
|
+ $("#biz_sub_restype").parent().parent().removeClass("hide");
|
|
|
920
|
+ $("#bizListContent").find(".top-head-info").removeClass("hide");
|
|
|
921
|
+ var url = `${common.domainName}/api-web/bResource/finsResTypeListByParentId?resType=${resType}`
|
|
|
922
|
+ admin.req({
|
|
|
923
|
+ url: url
|
|
|
924
|
+ }).done(function (res) {
|
|
|
925
|
+ var subhtml = '<option value="">=资源类型=</option>';
|
|
|
926
|
+ if (res.data) {
|
|
|
927
|
+ $.each(res.data, function (i, v) {
|
|
|
928
|
+ subhtml += '<option value="' + v.name + '">' + v.val + '</option>';
|
|
|
929
|
+ });
|
|
|
930
|
+ }
|
|
|
931
|
+ $('#biz_sub_restype').html(subhtml);
|
|
|
932
|
+ form.render("select");
|
|
|
933
|
+ })
|
|
|
934
|
+ } else {
|
|
|
935
|
+ if (!$("#bizListContent").find(".top-head-info").hasClass("hide")) {
|
|
|
936
|
+ $("#bizListContent").find(".top-head-info").addClass("hide")
|
|
|
937
|
+ }
|
|
|
938
|
+ if (!$("#biz_sub_restype").parent().parent().hasClass("hide")) {
|
|
|
939
|
+ $("#biz_sub_restype").parent().parent().addClass("hide");
|
|
|
940
|
+ }
|
|
|
941
|
+ }
|
|
|
942
|
+ }
|
|
|
943
|
+
|
|
|
944
|
+ function bizLoadRightResTypeSelectEvent(busId, resType, type, obj) {
|
|
|
945
|
+ var str = '';
|
|
|
946
|
+ var domStr = 'bizListContent'
|
|
|
947
|
+ var fun = reloadTable;
|
|
|
948
|
+ if (type == 'tree') {
|
|
|
949
|
+ str = 'tree_'
|
|
|
950
|
+ domStr = 'biztreeTableContent'
|
|
|
951
|
+ fun = renderTreeTable
|
|
|
952
|
+ }
|
|
|
953
|
+ var map = obj;
|
|
|
954
|
+ $.each(map, function (key, values) {
|
|
|
955
|
+ $("#" + str + key + "_biz").html(map[key])
|
|
|
956
|
+ });
|
|
|
957
|
+ //清除筛选条件
|
|
|
958
|
+ $("#" + domStr).find(".info-box-count .num span").unbind().on("click", function () {
|
|
|
959
|
+ var val = $(this).data("value"), target = $(this).data("target");
|
|
|
960
|
+ if (val && target) {
|
|
|
961
|
+ $("#" + target).val(val);
|
|
|
962
|
+ form.render("select")
|
|
|
963
|
+ fun(busId, resType);
|
|
|
964
|
+ } else {
|
|
|
965
|
+ //清除查询条件
|
|
|
966
|
+ $('#bizindex_keyword').val('');
|
|
|
967
|
+ $('#biz_res_colony').val('');
|
|
|
968
|
+ $('#biz_res_cluster').val('');
|
|
|
969
|
+ $('#biz_resStatus').val('');
|
|
|
970
|
+ $('#bizlink_state').val('');
|
|
|
971
|
+ $('#biz_state').val('');
|
|
|
972
|
+ $('#biz_sub_restype').val('');
|
|
|
973
|
+ $("#biz_virtual_platForm_select").val('');
|
|
|
974
|
+ $("#biz_treetable_resStatus").val('');
|
|
|
975
|
+ $("#biz_treetable_keyword").val('');
|
|
|
976
|
+ $("#biz_treetable_res_state").val('');
|
|
|
977
|
+ $('#biz_platform').val('');
|
|
|
978
|
+ form.render("select")
|
|
|
979
|
+ fun(busId, resType);
|
|
|
980
|
+ }
|
|
|
981
|
+ })
|
|
|
982
|
+ }
|
|
|
983
|
+
|
|
|
984
|
+ //重新load表格
|
|
|
985
|
+ function reloadTable() {
|
|
|
986
|
+ var platform = $("#biz_platform").find("option:selected").text();
|
|
|
987
|
+ if (platform == '=所属平台=') {
|
|
|
988
|
+ platform = '';
|
|
|
989
|
+ }
|
|
|
990
|
+ bizListTable = bizParentList = table.reload('bizListTable', {
|
|
|
991
|
+ page: {
|
|
|
992
|
+ curr: 1
|
|
|
993
|
+ }
|
|
|
994
|
+ ,where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
|
|
|
995
|
+ access_token: accessToken,
|
|
|
996
|
+ resName: $("#bizindex_keyword").val(),
|
|
|
997
|
+ resHealth: $("#biz_resStatus").val(),
|
|
|
998
|
+ busId: busId,
|
|
|
999
|
+ colonlyId: $("#biz_res_colony").val(),
|
|
|
1000
|
+ parentId: $("#biz_res_cluster").val(),
|
|
|
1001
|
+ sortKey: sortKey,
|
|
|
1002
|
+ state: $("#biz_state").val(),
|
|
|
1003
|
+ linkState: $("#bizlink_state").val(),
|
|
|
1004
|
+ platform: platform,
|
|
|
1005
|
+ subResType:$("#biz_sub_restype").val()
|
|
|
1006
|
+ }
|
|
|
1007
|
+ })
|
|
|
1008
|
+ }
|
|
|
1009
|
+
|
|
|
1010
|
+ function loadParamSelect() {
|
|
|
1011
|
+ if (router.search.busId) {
|
|
|
1012
|
+ busId = router.search.busId;
|
|
|
1013
|
+ var type = router.search.type ? router.search.type : 'select';
|
|
|
1014
|
+ //回选树节点
|
|
|
1015
|
+ selectedBizTreeNode('[data-id="' + busId + '"]', type);
|
|
|
1016
|
+ renderBizResTypeCard(busId);
|
|
|
1017
|
+ }
|
|
|
1018
|
+ }
|
|
|
1019
|
+
|
|
|
1020
|
+ function resTopo() {
|
|
|
1021
|
+
|
|
|
1022
|
+ //绑定鼠标移入移出事件
|
|
|
1023
|
+ $('table tr').hover(function (obj) {
|
|
|
1024
|
+ $(obj.currentTarget).find('.reslist-view-topo').removeClass('hide');
|
|
|
1025
|
+ }, function (obj) {
|
|
|
1026
|
+ $(obj.currentTarget).find('.reslist-view-topo').addClass('hide');
|
|
|
1027
|
+ })
|
|
|
1028
|
+
|
|
|
1029
|
+ // 加入/移出收藏夹
|
|
|
1030
|
+ $('a.reslist-view-topo').unbind('click').on('click', function () {
|
|
|
1031
|
+ common.viewResTopo($(this).data('resid'));
|
|
|
1032
|
+ });
|
|
|
1033
|
+
|
|
|
1034
|
+ }
|
|
|
1035
|
+ });
|
|
|
1036
|
+}); |