diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/bizindex.js b/hg-monitor-web-base/src/main/resources/static/src/controller/bizindex.js index c76d9ac..97977cc 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/bizindex.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/bizindex.js @@ -17,6 +17,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols var curBizResType = '';//当前业务所在的资源类型 var sortKey = ''; + var fieldExpandArr=[];//获取扩展的表格字段 function autoHeight(el) { @@ -402,72 +403,102 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols resTypeList.push(v.value); busId=v.pid; }); - //获取配置的列 - common.getTableCols({ - domId: 'bizListTable', - moduleId: 'bizIndex', - resType: 'OperatingSystem' - },function (retCols) { - if (retCols) { - cols = retCols; - } - bizListTable = table.render({ - elem: '#bizListTable' - , 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>' //开启头部工具栏,并为其绑定左侧模板 - //, toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: {toolbar: false} - , url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString() - , where: { - access_token: accessToken, - resName: busIndexKeyWord, - resHealth: $("#biz_resStatus").val(), - busId: busId, - colonlyId: $("#biz_res_colony").val(), - parentId: $("#biz_res_cluster").val(), - linkState: $("#bizlink_state").val(), - state: $("#biz_state").val(), - resCategory: 'resources', - } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' - } - , autoSort: false - , cols: [cols] - , done: function (res) { - soulTable.render(this); - getResCount(busId, resTypeList.toString()); - commonCols.colsClickEvent(); - //表格排序监听 joke add 20200408 - table.on('sort(bizListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; - } - reloadTable(); - }) - //触发拖动列事件,参数为保存按钮的id - common.dragCols("bizIndex_cols_save"); - //保存列顺序 - $("#bizIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'bizListTable', - moduleId: 'bizIndex', - resType: 'OperatingSystem', - cols: bizListTable.config.cols + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) } - common.saveTableCols(params); - }); - resTopo(); + } + } else { + console.log(res.msg); } - }); + } }); - + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'bizListTable', + moduleId: 'bizIndex', + resType: 'OperatingSystem' + },function (retCols) { + if (retCols) { + cols = retCols; + } + bizListTable = table.render({ + elem: '#bizListTable' + , 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>' //开启头部工具栏,并为其绑定左侧模板 + //, toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: {toolbar: false} + , url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString() + , where: { + access_token: accessToken, + resName: busIndexKeyWord, + resHealth: $("#biz_resStatus").val(), + busId: busId, + colonlyId: $("#biz_res_colony").val(), + parentId: $("#biz_res_cluster").val(), + linkState: $("#bizlink_state").val(), + state: $("#biz_state").val(), + resCategory: 'resources', + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , autoSort: false + , cols: [cols] + , done: function (res) { + soulTable.render(this); + getResCount(busId, resTypeList.toString()); + commonCols.colsClickEvent(); + //表格排序监听 joke add 20200408 + table.on('sort(bizListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) + //触发拖动列事件,参数为保存按钮的id + common.dragCols("bizIndex_cols_save"); + //保存列顺序 + $("#bizIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'bizListTable', + moduleId: 'bizIndex', + resType: 'OperatingSystem', + cols: bizListTable.config.cols + } + common.saveTableCols(params); + }); + resTopo(); + } + }); + }); + },300) } //获取业务下的资源类型健康统计 function renderBizResTypeCard(bizId) { @@ -500,75 +531,106 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols renderBizSerach(resType, busId, true); form.render(null, 'biz-list-form'); var cols = commonCols.resTypeCls[resType]; - //获取配置的列 - common.getTableCols({ - domId: 'bizParentList', - moduleId: 'bizIndex', - resType: resType - },function (retCols) { - if (retCols) { - cols = retCols; - } - bizParentList = table.render({ - elem: '#bizListTable' - , url: common.domainName + '/api-web/home/res-list/' + resType - , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: {toolbar: false} - , where: { - access_token: accessToken, - resName: busIndexKeyWord, - resHealth: $("#biz_resStatus").val(), - busId: busId, - colonlyId: $("#biz_res_colony").val(), - parentId: $("#biz_res_cluster").val(), - linkState: $("#bizlink_state").val(), - state: $("#biz_state").val(), - resCategory: 'resources' + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } + } + } else { + console.log(res.msg); } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' + } + }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'bizParentList', + moduleId: 'bizIndex', + resType: resType + },function (retCols) { + if (retCols) { + cols = retCols; } - , autoSort: false - , cols: [cols] - , done: function (res) { - soulTable.render(this) - getResCount(busId, resType) + bizParentList = table.render({ + elem: '#bizListTable' + , url: common.domainName + '/api-web/home/res-list/' + resType + , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: {toolbar: false} + , where: { + access_token: accessToken, + resName: busIndexKeyWord, + resHealth: $("#biz_resStatus").val(), + busId: busId, + colonlyId: $("#biz_res_colony").val(), + parentId: $("#biz_res_cluster").val(), + linkState: $("#bizlink_state").val(), + state: $("#biz_state").val(), + resCategory: 'resources' + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , autoSort: false + , cols: [cols] + , done: function (res) { + soulTable.render(this) + getResCount(busId, resType) - commonCols.colsClickEvent(); + commonCols.colsClickEvent(); - //表格排序监听 joke add 20200408 - table.on('sort(bizListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; - } - reloadTable(); - }) + //表格排序监听 joke add 20200408 + table.on('sort(bizListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) - //触发拖动列事件,参数为保存按钮的id - common.dragCols("bizIndex_cols_save"); + //触发拖动列事件,参数为保存按钮的id + common.dragCols("bizIndex_cols_save"); - bizLoadRightResTypeSelectEvent(busId,resType,'normal'); - //保存列顺序 - $("#bizIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'bizParentList', - moduleId: 'bizIndex', - resType: resType, - cols: bizParentList.config.cols - } - common.saveTableCols(params); - }); - resTopo(); - } + bizLoadRightResTypeSelectEvent(busId,resType,'normal'); + //保存列顺序 + $("#bizIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'bizParentList', + moduleId: 'bizIndex', + resType: resType, + cols: bizParentList.config.cols + } + common.saveTableCols(params); + }); + resTopo(); + } + }); }); - }); + },300) } //资源列表 function renderList(busId, resType) { @@ -582,74 +644,105 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols form.render(null, 'biz-list-form'); var cols = commonCols.resTypeCls[resType]; - //获取配置的列 - common.getTableCols({ - domId: 'bizListTable', - moduleId: 'bizIndex', - resType: resType - },function (retCols) { - if (retCols) { - cols = retCols; - } - bizListTable = table.render({ - elem: '#bizListTable' - , 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>' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: {toolbar: false} - , url: common.domainName + '/api-web/home/res-list/' + resType - , where: { - access_token: accessToken, - resName: busIndexKeyWord, - resHealth: $("#biz_resStatus").val(), - busId: busId, - colonlyId: $("#biz_res_colony").val(), - parentId: $("#biz_res_cluster").val(), - linkState: $("#bizlink_state").val(), - state: $("#biz_state").val(), - resCategory: 'resources' + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } + } + } else { + console.log(res.msg); } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' + } + }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'bizListTable', + moduleId: 'bizIndex', + resType: resType + },function (retCols) { + if (retCols) { + cols = retCols; } - , autoSort: false - , cols: [cols] - , done: function (res) { - soulTable.render(this) - getResCount(busId, resType) + bizListTable = table.render({ + elem: '#bizListTable' + , 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>' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: {toolbar: false} + , url: common.domainName + '/api-web/home/res-list/' + resType + , where: { + access_token: accessToken, + resName: busIndexKeyWord, + resHealth: $("#biz_resStatus").val(), + busId: busId, + colonlyId: $("#biz_res_colony").val(), + parentId: $("#biz_res_cluster").val(), + linkState: $("#bizlink_state").val(), + state: $("#biz_state").val(), + resCategory: 'resources' + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , autoSort: false + , cols: [cols] + , done: function (res) { + soulTable.render(this) + getResCount(busId, resType) - commonCols.colsClickEvent(); + commonCols.colsClickEvent(); - //表格排序监听 joke add 20200408 - table.on('sort(bizListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; - } - reloadTable(); - }) + //表格排序监听 joke add 20200408 + table.on('sort(bizListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) - //触发拖动列事件,参数为保存按钮的id - common.dragCols("bizIndex_cols_save"); + //触发拖动列事件,参数为保存按钮的id + common.dragCols("bizIndex_cols_save"); - //保存列顺序 - $("#bizIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'bizListTable', - moduleId: 'bizIndex', - resType: resType, - cols: bizListTable.config.cols - } - common.saveTableCols(params); - }); - resTopo(); - } + //保存列顺序 + $("#bizIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'bizListTable', + moduleId: 'bizIndex', + resType: resType, + cols: bizListTable.config.cols + } + common.saveTableCols(params); + }); + resTopo(); + } + }); }); - }); + },300) } //树表格 @@ -676,140 +769,170 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols } var cols = commonCols.resTypeCls[resType]; - + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 admin.req({ - url: common.domainName + "/api-web/home/virtual-res-list/" + resType - , data: { - ptId: $("#biz_virtual_platForm_select").val(), - health: $("#biz_treetable_resStatus").val(), - busId: busId, - keyWords: $("#biz_treetable_keyword").val(), - state: $("#biz_treetable_res_state").val() - } + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType , done: function (res) { - if (res.code == 0) { - var bizTableTreeVirtual; - //获取配置的列 - common.getTableCols({ - domId: 'bizTableTreeVirtual', - moduleId: 'bizIndex', - resType: resType - },function (retCols) { - if (retCols) { - cols = retCols; + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) } - bizTableTreeVirtual = table.render({ - elem: '#biz_virtual_platform_treeTable', - data: res.data, - treeConfig: { //表格树所需配置 - showField: 'resName' //表格树显示的字段 - , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。 - , treepid: ''//父级id字段名称 - , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer - }, - tree: { - iconIndex: 1 - }, - page: false, - limit: 9999, - autoColumnWidth: false, - cols: [cols] - , height: 'full-220', - done: function (res){ - soulTable.render(this); - common.treeTableDragCols('#biz_virtual_platform_treeTable', '#bizTreeList-top-head-info-tpl'); - bizLoadRightResTypeSelectEvent(busId,resType,'tree'); - // 保存列顺序 - $('#biz_virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){ - common.saveTableCols({ - domId: 'bizTableTreeVirtual', - moduleId: 'bizIndex', - resType: resType, - cols: bizTableTreeVirtual.config.cols - }); - }); - commonCols.colsClickEvent(); - resTopo(); + } + } else { + console.log(res.msg); + } + } + }); + setTimeout(function (){ + admin.req({ + url: common.domainName + "/api-web/home/virtual-res-list/" + resType + , data: { + ptId: $("#biz_virtual_platForm_select").val(), + health: $("#biz_treetable_resStatus").val(), + busId: busId, + keyWords: $("#biz_treetable_keyword").val(), + state: $("#biz_treetable_res_state").val() + } + , done: function (res) { + if (res.code == 0) { + var bizTableTreeVirtual; + //获取配置的列 + common.getTableCols({ + domId: 'bizTableTreeVirtual', + moduleId: 'bizIndex', + resType: resType + },function (retCols) { + if (retCols) { + cols = retCols; } - }); - /*bizTableTreeVirtual.on('tool(tableEvent)',function (obj) { - if(!obj.data.treeList){ - var field = obj.field; //单元格字段 - var value = obj.value; //修改后的值 - var data = obj.data; //当前行数据 - var event = obj.event; //当前单元格事件属性值 - var subResType = ''; - if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){ - subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER'; - }else if(data.resType.indexOf('CLUSTER')>-1){ - subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; - }else if(data.resType.indexOf('PHYSICSHOST')>-1){ - subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; - }else{ - subResType = data.resType + bizTableTreeVirtual = table.render({ + elem: '#biz_virtual_platform_treeTable', + data: res.data, + treeConfig: { //表格树所需配置 + showField: 'resName' //表格树显示的字段 + , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。 + , treepid: ''//父级id字段名称 + , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer + }, + tree: { + iconIndex: 1 + }, + page: false, + limit: 9999, + autoColumnWidth: false, + cols: [cols] + , height: 'full-220', + done: function (res){ + soulTable.render(this); + common.treeTableDragCols('#biz_virtual_platform_treeTable', '#bizTreeList-top-head-info-tpl'); + bizLoadRightResTypeSelectEvent(busId,resType,'tree'); + // 保存列顺序 + $('#biz_virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){ + common.saveTableCols({ + domId: 'bizTableTreeVirtual', + moduleId: 'bizIndex', + resType: resType, + cols: bizTableTreeVirtual.config.cols + }); + }); + commonCols.colsClickEvent(); + resTopo(); } - if(event === 'loadChildren'){ - $.ajax({ - url: common.domainName + "/api-web/home/virtual-res-list/" + subResType - , type: "get" - , data: { - ptId: $("#biz_virtual_platForm_select").val(), - health: $("#treetable_resStatus").val(), - busId: busId, - keyWords: $("#biz_treetable_keyword").val(), - state: $("#biz_treetable_state").val(), - access_token:accessToken, - parentId:data.resId - } - , success: function (res) { - if (res.data.length > 0) { - obj.loadChildren(res.data); - commonCols.colsClickEvent(); + }); + /*bizTableTreeVirtual.on('tool(tableEvent)',function (obj) { + if(!obj.data.treeList){ + var field = obj.field; //单元格字段 + var value = obj.value; //修改后的值 + var data = obj.data; //当前行数据 + var event = obj.event; //当前单元格事件属性值 + var subResType = ''; + if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){ + subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER'; + }else if(data.resType.indexOf('CLUSTER')>-1){ + subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; + }else if(data.resType.indexOf('PHYSICSHOST')>-1){ + subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; + }else{ + subResType = data.resType + } + if(event === 'loadChildren'){ + $.ajax({ + url: common.domainName + "/api-web/home/virtual-res-list/" + subResType + , type: "get" + , data: { + ptId: $("#biz_virtual_platForm_select").val(), + health: $("#treetable_resStatus").val(), + busId: busId, + keyWords: $("#biz_treetable_keyword").val(), + state: $("#biz_treetable_state").val(), + access_token:accessToken, + parentId:data.resId } - } - }) + , success: function (res) { + if (res.data.length > 0) { + obj.loadChildren(res.data); + commonCols.colsClickEvent(); + } + } + }) + } } - } - });*/ - //统计总数 - // $('#biz_virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#biz-treetable-countTpl').html()).render(res.data.length)); + });*/ + //统计总数 + // $('#biz_virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#biz-treetable-countTpl').html()).render(res.data.length)); + }); + } else { + console.log(data.msg); + } + layer.closeAll(); + //关键字回车事件 + $('#biz_treetable_keyword').keydown(function (e) { + if (e.keyCode === 13) { + renderTreeTable(busId, curTreeNode.data.id) + return false; + } + }); + //选择资源状态 + form.on('select(biz_treetable_resStatus)', function (data) { + renderTreeTable(busId, curTreeNode.data.id); + }); + //选择业务 + form.on('select(treetableBizTypes)', function (data) { + renderTreeTable(busId, curTreeNode.data.id); + }); + //选择业务 + form.on('select(biz_treetable_res_state)', function (data) { + renderTreeTable(busId, curTreeNode.data.id); + }); + + //选择平台 + form.on('select(biz_virtual_platForm_select)', function (data) { + renderTreeTable(busId, curTreeNode.data.id); + }); + //资源连接状态选择时间 + form.on('select(biz_treetable_state)', function (data) { + renderTreeTable(busId, curTreeNode.data.id); }); - } else { - console.log(data.msg); } + }).error(function () { layer.closeAll(); - //关键字回车事件 - $('#biz_treetable_keyword').keydown(function (e) { - if (e.keyCode === 13) { - renderTreeTable(busId, curTreeNode.data.id) - return false; - } - }); - //选择资源状态 - form.on('select(biz_treetable_resStatus)', function (data) { - renderTreeTable(busId, curTreeNode.data.id); - }); - //选择业务 - form.on('select(treetableBizTypes)', function (data) { - renderTreeTable(busId, curTreeNode.data.id); - }); - //选择业务 - form.on('select(biz_treetable_res_state)', function (data) { - renderTreeTable(busId, curTreeNode.data.id); - }); - - //选择平台 - form.on('select(biz_virtual_platForm_select)', function (data) { - renderTreeTable(busId, curTreeNode.data.id); - }); - //资源连接状态选择时间 - form.on('select(biz_treetable_state)', function (data) { - renderTreeTable(busId, curTreeNode.data.id); - }); - } - }).error(function () { - layer.closeAll(); - }); + }); + },300) } //获取资源统计 diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/bizreslist.js b/hg-monitor-web-base/src/main/resources/static/src/controller/bizreslist.js index adb22b0..df0a99a 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/bizreslist.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/bizreslist.js @@ -9,7 +9,7 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm var common = layui.common; var commonCols = layui.commonCols; var sortKey = ''; - + var fieldExpandArr=[];//获取扩展的表格字段 //用树表格展示的资源类型 var treeTableResTypes = [ @@ -102,71 +102,101 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm renderSearchCondition(resType, bizId); var cols = commonCols.resTypeCls[resType]; - //获取配置的列 - common.getTableCols({ - domId: 'bizResListTable', - moduleId: 'bizreslist', - resType: activeResType - }, function (retCols) { - if (retCols) { - cols = retCols; - } - listTable = table.render({ - elem: '#bizResListTable' - , url: common.domainName + '/api-web/home/res-list/' + newResType - , where: { - access_token: accessToken, - resName: $("#biz_reslist_keyword").val(), - resHealth: $("#biz_reslist_resStatus").val(), - busId: bizId, - colonlyId: $("#biz_reslist_res_colony").val(), - parentId: $("#biz_reslist_res_cluster").val(), - linkState: $("#biz_reslist_link_state").val(), - state: $("#biz_reslist_state").val(), - // hostState: $("#biz_reslist_host_state").val(), - powerState: $("#biz_reslist_power_state").val(), - collProtocols: collProtocols - - } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' - } - , toolbar: '#bizreslist_cols_save_btn' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: 'simple' - , autoSort: false - , cols: [cols] - , done: function (res) { - soulTable.render(this); - getResCount(bizId, newResType) - commonCols.colsClickEvent(); - - table.on('sort(bizResListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) } - reloadTable(); - }) - - //触发拖动列事件,参数为保存按钮的id - common.dragCols("bizreslist_cols_save"); - loadRightResTypeSelectEvent(newResType, 'normal'); - - initSaveColsEvent();//保存列事件 - // 导出到excel - initExportDataEvent(); - resFavorites(); - resTopo(); + } + } else { + console.log(res.msg); } - }); - }) + } + }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'bizResListTable', + moduleId: 'bizreslist', + resType: activeResType + }, function (retCols) { + if (retCols) { + cols = retCols; + } + listTable = table.render({ + elem: '#bizResListTable' + , url: common.domainName + '/api-web/home/res-list/' + newResType + , where: { + access_token: accessToken, + resName: $("#biz_reslist_keyword").val(), + resHealth: $("#biz_reslist_resStatus").val(), + busId: bizId, + colonlyId: $("#biz_reslist_res_colony").val(), + parentId: $("#biz_reslist_res_cluster").val(), + linkState: $("#biz_reslist_link_state").val(), + state: $("#biz_reslist_state").val(), + // hostState: $("#biz_reslist_host_state").val(), + powerState: $("#biz_reslist_power_state").val(), + collProtocols: collProtocols + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , toolbar: '#bizreslist_cols_save_btn' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: 'simple' + , autoSort: false + , cols: [cols] + , done: function (res) { + soulTable.render(this); + getResCount(bizId, newResType) + commonCols.colsClickEvent(); + + table.on('sort(bizResListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) + + //触发拖动列事件,参数为保存按钮的id + common.dragCols("bizreslist_cols_save"); + loadRightResTypeSelectEvent(newResType, 'normal'); + + initSaveColsEvent();//保存列事件 + // 导出到excel + initExportDataEvent(); + resFavorites(); + resTopo(); + } + }); + }) + },300) } @@ -206,145 +236,175 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm layer.load(2); //加载层。 var cols = commonCols.resTypeCls[resType]; - - //获取配置的列 - common.getTableCols({ - domId: 'bizResTreeTable', - moduleId: 'bizreslist', - resType: activeResType - }, function (ressult) { - if (ressult) { - cols = ressult; + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } + } + } else { + console.log(res.msg); + } } - admin.req({ - url: common.domainName + "/api-web/home/virtual-res-list/" + resType - , data: { - parentId: $("#biz_virtual_platForm_select").val(), - health: $("#biz_reslist_treetable_resStatus").val(), - busId: bizId, - keyWords: $("#biz_reslist_treetable_keyword").val(), - state: $("#biz_reslist_treetable_state").val(), - linkState: $('#biz_reslist_treetable_link_state').val(), - powerState: $("#biz_reslist_treetable_power_state").val(), - serverState: $("#biz_reslist_server_state").val(), - collProtocols: collProtocols + }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'bizResTreeTable', + moduleId: 'bizreslist', + resType: activeResType + }, function (ressult) { + if (ressult) { + cols = ressult; } - , done: function (res) { - if (res.code == 0) { - treeListTable = table.render({ - elem: '#bizResTreeTable', - data: res.data, - tree: { - iconIndex: 1 - }, - height: 'full-270', - treeConfig: { //表格树所需配置 - showField: 'resName' //表格树显示的字段 - , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。 - , treepid: ''//父级id字段名称 - , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer - }, - cols: [cols], - drag: 'simple', - page: false, - limit: 9999, - autoColumnWidth: false, - done: function (a, b, c) { - soulTable.render(this); - //触发拖动列事件,参数为保存按钮的id - common.treeTableDragCols("#bizResTreeTable", "#bizTreeReslist_cols_save_btn"); - - commonCols.colsClickEvent(); - // 加载统计信息 - loadRightResTypeSelectEvent(resType, 'tree'); - initTreeSaveColsEvent();//保存列事件 - initExportTreeDataEvent(); - resFavorites(); - resTopo(); - } - }); - } else { - console.log(data.msg); + admin.req({ + url: common.domainName + "/api-web/home/virtual-res-list/" + resType + , data: { + parentId: $("#biz_virtual_platForm_select").val(), + health: $("#biz_reslist_treetable_resStatus").val(), + busId: bizId, + keyWords: $("#biz_reslist_treetable_keyword").val(), + state: $("#biz_reslist_treetable_state").val(), + linkState: $('#biz_reslist_treetable_link_state').val(), + powerState: $("#biz_reslist_treetable_power_state").val(), + serverState: $("#biz_reslist_server_state").val(), + collProtocols: collProtocols } - layer.closeAll(); - //关键字回车事件 - $('#biz_reslist_treetable_keyword').unbind('keydown').keydown(function (e) { - if (e.keyCode === 13) { - renderTreeTable(bizId, resType, true) + , done: function (res) { + if (res.code == 0) { + treeListTable = table.render({ + elem: '#bizResTreeTable', + data: res.data, + tree: { + iconIndex: 1 + }, + height: 'full-270', + treeConfig: { //表格树所需配置 + showField: 'resName' //表格树显示的字段 + , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。 + , treepid: ''//父级id字段名称 + , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer + }, + cols: [cols], + drag: 'simple', + page: false, + limit: 9999, + autoColumnWidth: false, + done: function (a, b, c) { + soulTable.render(this); + //触发拖动列事件,参数为保存按钮的id + common.treeTableDragCols("#bizResTreeTable", "#bizTreeReslist_cols_save_btn"); + + commonCols.colsClickEvent(); + // 加载统计信息 + loadRightResTypeSelectEvent(resType, 'tree'); + initTreeSaveColsEvent();//保存列事件 + initExportTreeDataEvent(); + resFavorites(); + resTopo(); + } + }); + } else { + console.log(data.msg); } - }); - //选择资源状态 - form.on('select(biz_reslist_treetable_resStatus)', function (data) { - renderTreeTable(bizId, resType, true); - }); - //选择业务 - form.on('select(treetableBizTypes)', function (data) { - renderTreeTable(bizId, resType, true); - }); - - //选择平台 - form.on('select(biz_reslist_virtual_platForm_select)', function (data) { - renderTreeTable(bizId, resType, true); - }); - //资源状态选择事件 - form.on('select(biz_reslist_treetable_state)', function (data) { - renderTreeTable(bizId, resType, true); - }); - //资源连接状态选择事件 - form.on('select(biz_reslist_treetable_link_state)', function (data) { - renderTreeTable(bizId, resType, true); - }); - // 电源状态 - form.on('select(biz_reslist_treetable_power_state)', function (data) { - renderTreeTable(bizId, resType, true); - }); - /** - /**表格的增删改都会回调此方法 - * 与table.on(tool(lay-filter))用法一致。 - **/ - /*treeListTable.on('tool(tableEvent)', function (obj) { - if (!obj.data.treeList) { - var field = obj.field; //单元格字段 - var value = obj.value; //修改后的值 - var data = obj.data; //当前行数据 - var event = obj.event; //当前单元格事件属性值 - var subResType = ''; - if (data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI') { - subResType = data.resType == 'VIRTUALIZATION_VMWARE' ? 'VIRTUALIZATION_VMWARE_CLUSTER' : 'VIRTUALIZATION_HUAWEI_CLUSTER'; - } else if (data.resType.indexOf('CLUSTER') > -1) { - subResType = data.resType == 'VIRTUALIZATION_VMWARE_CLUSTER' ? 'VIRTUALIZATION_VMWARE_PHYSICSHOST' : 'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; - } else if (data.resType.indexOf('PHYSICSHOST') > -1) { - subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; - }else{ - subResType = data.resType + layer.closeAll(); + //关键字回车事件 + $('#biz_reslist_treetable_keyword').unbind('keydown').keydown(function (e) { + if (e.keyCode === 13) { + renderTreeTable(bizId, resType, true) } - if(event === 'loadChildren'){ - $.ajax({ - url: common.domainName + "/api-web/home/virtual-res-list/" + subResType - , type: "get" - , data: { - health: $("#biz_reslist_treetable_resStatus").val(), - busId: bizId, - keyWords: $("#biz_treetable_keyword").val(), - state: $("#biz_reslist_treetable_state").val(), - access_token:accessToken, - parentId:data.resId - } - ,success:function (res) { - if(res.data.length>0){ - obj.loadChildren(res.data); - commonCols.colsClickEvent(); + }); + //选择资源状态 + form.on('select(biz_reslist_treetable_resStatus)', function (data) { + renderTreeTable(bizId, resType, true); + }); + //选择业务 + form.on('select(treetableBizTypes)', function (data) { + renderTreeTable(bizId, resType, true); + }); + + //选择平台 + form.on('select(biz_reslist_virtual_platForm_select)', function (data) { + renderTreeTable(bizId, resType, true); + }); + //资源状态选择事件 + form.on('select(biz_reslist_treetable_state)', function (data) { + renderTreeTable(bizId, resType, true); + }); + //资源连接状态选择事件 + form.on('select(biz_reslist_treetable_link_state)', function (data) { + renderTreeTable(bizId, resType, true); + }); + // 电源状态 + form.on('select(biz_reslist_treetable_power_state)', function (data) { + renderTreeTable(bizId, resType, true); + }); + /** + /**表格的增删改都会回调此方法 + * 与table.on(tool(lay-filter))用法一致。 + **/ + /*treeListTable.on('tool(tableEvent)', function (obj) { + if (!obj.data.treeList) { + var field = obj.field; //单元格字段 + var value = obj.value; //修改后的值 + var data = obj.data; //当前行数据 + var event = obj.event; //当前单元格事件属性值 + var subResType = ''; + if (data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI') { + subResType = data.resType == 'VIRTUALIZATION_VMWARE' ? 'VIRTUALIZATION_VMWARE_CLUSTER' : 'VIRTUALIZATION_HUAWEI_CLUSTER'; + } else if (data.resType.indexOf('CLUSTER') > -1) { + subResType = data.resType == 'VIRTUALIZATION_VMWARE_CLUSTER' ? 'VIRTUALIZATION_VMWARE_PHYSICSHOST' : 'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; + } else if (data.resType.indexOf('PHYSICSHOST') > -1) { + subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; + }else{ + subResType = data.resType + } + if(event === 'loadChildren'){ + $.ajax({ + url: common.domainName + "/api-web/home/virtual-res-list/" + subResType + , type: "get" + , data: { + health: $("#biz_reslist_treetable_resStatus").val(), + busId: bizId, + keyWords: $("#biz_treetable_keyword").val(), + state: $("#biz_reslist_treetable_state").val(), + access_token:accessToken, + parentId:data.resId } - } - }) + ,success:function (res) { + if(res.data.length>0){ + obj.loadChildren(res.data); + commonCols.colsClickEvent(); + } + } + }) + } } - } - });*/ - } - }).error(function () { - layer.closeAll(); - }); - }) + });*/ + } + }).error(function () { + layer.closeAll(); + }); + }) + },300) } //获取资源统计 diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/commonCols.js b/hg-monitor-web-base/src/main/resources/static/src/controller/commonCols.js index 496c108..a304a6b 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/commonCols.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/commonCols.js @@ -2978,7 +2978,113 @@ layui.define(['soulTable', 'commonDetail', 'common', 'laytpl', 'view', 'admin', }, function () { layer.close(subtips); }); + //lsq T3和IOP点击修改删除 2022-08-04 + $('.edit-delete-tpl').unbind('click').on('click',function (){ + var $T3Dom = $(this); + //判断是字段类型T3/IOP + let tplType=$T3Dom.data('tpltype'); + //获取资源id + var resId = $T3Dom.data('resid'); + //获取旧数据 + let old_T3Dom=$T3Dom.text(); + //获取扩展字段id + let expandId=$T3Dom.data('expandid'); + //获取字段为输入框或者下拉选择 0 输入框 1下拉选择 + let fieldSourceType=$T3Dom.data('fieldsourcetype'); + //获取下拉选择值 + let fieldList=$T3Dom.data('list'); + let url='/api-web/resource/expand/saveOrUpdate'; + //判断类型是输入框还是下拉列表 + let titleName=''; + let promptHtml=''; + if(fieldSourceType == '0'){ + titleName='请输入'; + promptHtml=`<input type="text" id="promptInput" name="promptInput" autocomplete="off" class="layui-input">` + }else if(fieldSourceType== '1'){ + titleName='请选择'; + promptHtml=`<select id="promptInput" style="width:80%;cursor:pointer;" class="layui-select" lay-filter="promptInput">` + if(fieldList){ + let fieldListArr=fieldList.split(",") + fieldListArr.map(item=>{ + promptHtml+=`<option value="`+item+`">`+item+`</option>`; + }) + } + promptHtml+=`</select>`; + }else{ + promptHtml=`` + } + let html_tpl=`<div class="T3-IOP-prompt">`+promptHtml+`</div>`; + layer.open({ + title: [titleName+tplType, 'font-size:14px;'], + type: 1, + area: ['280px','170px'], + content: html_tpl, + success: function () { + $('#promptInput').val(old_T3Dom) + } + , id: 'lay_T3_IOP' //设定一个id,防止重复弹出 + , btn: ['清空', '保存'] + , yes: function (index, layero) { + layer.confirm('确认要删除吗?', {icon: 3, title: '提示'}, function (index1) { + layer.load(2); + admin.req({ + //删除T3值 + url: common.domainName + url, + data: { + resId:resId, + fieldValue:'', + expandId:expandId,//扩展字段id + + }, + }).done(function (response) { + layer.closeAll('loading'); + if (response.success) { + layer.msg('删除成功!', {icon: 1, time: 3000}); + $T3Dom.text(''); + } else { + layer.msg('删除失败!', {icon: 2, time: 3000}); + } + layer.close(index); + }); + }) + } + , btn2:function(index, layero){ + var value = $('#promptInput').val(); + if (value !== old_T3Dom) { + layer.load(2); + admin.req({ + //修改扩展字段T3/IOp值 + url: common.domainName + url, + data: { + resId:resId, + fieldValue:value, + expandId:expandId,//扩展字段id + + }, + success: function (response) { + layer.closeAll('loading'); + if (response && response.success) { + layer.msg('修改成功', {icon: 1}); + $T3Dom.text(value); + } else { + layer.msg('修改失败', {icon: 2}); + } + layer.close(index); + + }, + error: function (err) { + layer.closeAll('loading'); + layer.msg('修改失败', {icon: 2}); + } + }); + } else { + layer.close(index); + } + }, + }); + }) + //end lsq T3和IOP点击修改/删除 2022-08-04 function showTips(id, message, state) { subtips = layer.tips(state + "失败原因:" + message, '#' + id, {tips: 1}); diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/resManageIndex.js b/hg-monitor-web-base/src/main/resources/static/src/controller/resManageIndex.js index 1886941..f4065bd 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/resManageIndex.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/resManageIndex.js @@ -1,5 +1,5 @@ //资源视图 -layui.define(['common', 'tree', 'laypage', 'laytpl', 'upload', 'admin', 'form', 'table', 'treeTable', 'sessions', "commonDetail", 'tasklist', 'view', 'reslist'], function (exports) { +layui.define(['common', 'tree', 'laypage', 'laytpl', 'upload', 'admin', 'form', 'table', 'treeTable', 'sessions', "common", 'tasklist', 'view', 'reslist'], function (exports) { var $ = layui.$; var common = layui.common; var table = layui.table; @@ -809,300 +809,439 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'upload', 'admin', 'form', return htm; } }); - //渲染表格 - table.render({ - elem: '#resManageTable' - , id: 'resManageTable' - , url: common.domainName + '/api-web/home/res-list/' + resType - , where: { - access_token: accessToken, - editMode: 'true', - resName: $("#resManageIndexForm").find("input[name='resName']").val() ? $("#resManageIndexForm").find("input[name='resName']").val() : searchId, - ipOrManageIp: $("#resManageIndexForm").find("input[name='ipOrManageIp']").val(), - // admin: $("#resManageIndexForm").find("input[name='admin']").val(), - adminName: $("#resManageIndexForm").find("input[name='admin']").val(), - busId: $("#resManageIndexForm").find("input[name='busId']").val(), - state: $("#resManageIndexForm").find("select[name='state']").val(), - parentId: $("#resManageIndexForm").find("select[name='parentId']").val(), - collectionState: $("#resManageIndexForm").find("select[name='collectionState']").val() - } - , height: 'full-200' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: this.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + //lsq 资源管理增加扩展字段 待验证 2022-08-12 + // if(this.fieldExpandArr.indexOf(resType)!=-1){ + // }else{ + // this.fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } + // } + } else { + console.log(res.msg); + } } - , limit: common.limit - , limits: common.limits - , cols: [cols] - , done: function (res, curr, count) { - - //XuHaoJie 2021/10/18 阿里云无详情页 华为云无详情页 - $('button[data-restype="ALI_CLOUD_PLAT"][lay-tips="查看详情"]').remove() - $('button[data-restype="HUAWEI_CLOUD_PLAT"][lay-tips="查看详情"]').remove() - // 共享设备,厂商是H3C、HDS的设备不让查看详情页,没有数据 - $('button[data-restype="STORAGE_SHARE"][data-provider="H3C"]').remove() - $('button[data-restype="STORAGE_SHARE"][data-provider="HDS"]').remove() - - lastQueryCondition = this.where; - lastQueryCondition.resType = this.url.substring(this.url.lastIndexOf("/") + 1); - (lastQueryCondition.resType === 'all') && (lastQueryCondition.resType = '') - $('table tr').hover(function (obj) { - $(obj.currentTarget).find('.layui-icon-rate').removeClass('hide'); - }, function (obj) { - $(obj.currentTarget).find('.layui-icon-rate').addClass('hide'); - }) - tableScrollPatch($(this)); - //表格排序监听 joke add 20200408 - table.on('sort(resManageTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; - } - reloadTable(); - }) + }); + setTimeout(function (){ + //渲染表格 + table.render({ + elem: '#resManageTable' + , id: 'resManageTable' + , url: common.domainName + '/api-web/home/res-list/' + resType + , where: { + access_token: accessToken, + editMode: 'true', + resName: $("#resManageIndexForm").find("input[name='resName']").val() ? $("#resManageIndexForm").find("input[name='resName']").val() : searchId, + ipOrManageIp: $("#resManageIndexForm").find("input[name='ipOrManageIp']").val(), + // admin: $("#resManageIndexForm").find("input[name='admin']").val(), + adminName: $("#resManageIndexForm").find("input[name='admin']").val(), + busId: $("#resManageIndexForm").find("input[name='busId']").val(), + state: $("#resManageIndexForm").find("select[name='state']").val(), + parentId: $("#resManageIndexForm").find("select[name='parentId']").val(), + collectionState: $("#resManageIndexForm").find("select[name='collectionState']").val() + } + , height: 'full-200' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , limit: common.limit + , limits: common.limits + , cols: [cols] + , done: function (res, curr, count) { + + //XuHaoJie 2021/10/18 阿里云无详情页 华为云无详情页 + $('button[data-restype="ALI_CLOUD_PLAT"][lay-tips="查看详情"]').remove() + $('button[data-restype="HUAWEI_CLOUD_PLAT"][lay-tips="查看详情"]').remove() + // 共享设备,厂商是H3C、HDS的设备不让查看详情页,没有数据 + $('button[data-restype="STORAGE_SHARE"][data-provider="H3C"]').remove() + $('button[data-restype="STORAGE_SHARE"][data-provider="HDS"]').remove() + + lastQueryCondition = this.where; + lastQueryCondition.resType = this.url.substring(this.url.lastIndexOf("/") + 1); + (lastQueryCondition.resType === 'all') && (lastQueryCondition.resType = '') + $('table tr').hover(function (obj) { + $(obj.currentTarget).find('.layui-icon-rate').removeClass('hide'); + }, function (obj) { + $(obj.currentTarget).find('.layui-icon-rate').addClass('hide'); + }) + tableScrollPatch($(this)); + //表格排序监听 joke add 20200408 + table.on('sort(resManageTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) - //点击协议名称 进行编辑 - $('[resmanage-data-edit]').unbind("click").on('click', function () { - if ($.inArray('back:resource:update', checkList) == -1) { - layer.msg('暂无权限!', {icon: 7, time: 3000}); - return; - } - openEditHtml($(this).attr("resmanage-data-edit"),$(this).data("restype"),false); - }); - $('[resmanage-data-delete]').unbind("click").on('click', function () { - deleteByIds($(this).attr("resmanage-data-delete")); - }); - $('[resmanage-data-delete-plus]').unbind("click").on('click', function () { - compulsoryDeleteById($(this).attr("resmanage-data-delete-plus")); - }); - $('[resmanage-data-console]').unbind("click").on('click', function () { - var resId = $(this).attr("resmanage-data-console"); - window.open('/src/lib/extend/ssh/page/webssh.html?resId='+resId,"_blank"); - }); - $('[resmanage-data-stopcoll]').unbind("click").on('click', function () { - var $that = $(this) - //确认提示框 - layer.confirm('确认要恢复/暂停当前资源的采集吗?', { - btn: ['确定', '取消'] //按钮 - }, function () { - var loding = layer.load(2) - var opj = { - resId:$that.attr("resmanage-data-stopcoll"), - state:$that.data("param") + //点击协议名称 进行编辑 + $('[resmanage-data-edit]').unbind("click").on('click', function () { + if ($.inArray('back:resource:update', checkList) == -1) { + layer.msg('暂无权限!', {icon: 7, time: 3000}); + return; } - $.ajax({ - url: common.domainName + '/api-web/manage/resource/stopOrStartColl?access_token='+accessToken - ,data:JSON.stringify(opj) - ,type:'post' - ,contentType: "application/json; charset=utf-8" - ,success:function (res) { - if (res.success){ - layer.close(loding); - layer.msg('操作成功', { - offset: '15px' - , icon: 1 - , time: 1500 - },function () { - layer.closeAll(); - reloadTable(); - }); - } else{ - layer.msg('操作异常:'+res.msg, {icon: 7, time: 3000}); - } - }, - error:function (res) { - layer.closeAll(); - console.error(res); - } - }) + openEditHtml($(this).attr("resmanage-data-edit"),$(this).data("restype"),false); }); - }); - // 加入/移出收藏夹 - $('a.layui-icon-rate').unbind('click').on('click',rate ); - - function rate() { - var $aDom = $(this); - var resId = $aDom.data('id'); - var favIdList = $aDom.data('favid') && $aDom.data('favid') != 'null' ? $aDom.data('favid').split(',') : []; - admin.req({ - url: common.domainName + '/api-web/favorites/treeSelectData' - }).done(function (response) { - var data = response.data; - if (data.length == 0) { - var selectValue = ''; - saveFavs($aDom,selectValue,resId,'true'); - } else if (data.length == 1) { - var selectValue = data[0].value; - saveFavs($aDom,selectValue,resId,'false'); - } else { - layer.open({ - type: '1', - title: '选择收藏夹', - id: 'layer-select-favorites', - content: '<div class="div-select-favorites"><div id="slt-favorites-tree"></div></div>', - offset: '150px', - area: ['20%', '15%'], - btn: ['选择', '取消'], - resize: false, - success: function () { - admin.req({ - url: common.domainName + '/api-web/favorites/treeSelectData' - }).done(function (response) { - xmSelect.render({ - el: '#slt-favorites-tree', - radio: true, - clickClose: true, - autoRow: true, - filterable: true, - height: 'auto', - toolbar: { - show: true, - }, - model: { - label: { - type: 'text' - } - }, - tree: { - show: true, - showFolderIcon: true, - showLine: true, - indent: 20, - expandedKeys: true, - strict: false - }, - data: data + $('[resmanage-data-delete]').unbind("click").on('click', function () { + deleteByIds($(this).attr("resmanage-data-delete")); + }); + $('[resmanage-data-delete-plus]').unbind("click").on('click', function () { + compulsoryDeleteById($(this).attr("resmanage-data-delete-plus")); + }); + $('[resmanage-data-console]').unbind("click").on('click', function () { + var resId = $(this).attr("resmanage-data-console"); + window.open('/src/lib/extend/ssh/page/webssh.html?resId='+resId,"_blank"); + }); + $('[resmanage-data-stopcoll]').unbind("click").on('click', function () { + var $that = $(this) + //确认提示框 + layer.confirm('确认要恢复/暂停当前资源的采集吗?', { + btn: ['确定', '取消'] //按钮 + }, function () { + var loding = layer.load(2) + var opj = { + resId:$that.attr("resmanage-data-stopcoll"), + state:$that.data("param") + } + $.ajax({ + url: common.domainName + '/api-web/manage/resource/stopOrStartColl?access_token='+accessToken + ,data:JSON.stringify(opj) + ,type:'post' + ,contentType: "application/json; charset=utf-8" + ,success:function (res) { + if (res.success){ + layer.close(loding); + layer.msg('操作成功', { + offset: '15px' + , icon: 1 + , time: 1500 + },function () { + layer.closeAll(); + reloadTable(); }); - }); - }, - yes: function (layerIndex) { - var selectValue = xmSelect.get('#slt-favorites-tree', true).getValue('value'); - if (favIdList.length === 0 && selectValue.length === 0) { - layer.msg('请选择一个收藏夹!', {icon: 0, time: 3000}); - return false; + } else{ + layer.msg('操作异常:'+res.msg, {icon: 7, time: 3000}); } - var favIds = selectValue.join(','); - layer.load(2); - saveFavs($aDom,favIds,resId,'false',layerIndex); + }, + error:function (res) { + layer.closeAll(); + console.error(res); } - }); - } - }) - } + }) + }); + }); + // 加入/移出收藏夹 + $('a.layui-icon-rate').unbind('click').on('click',rate ); + + function rate() { + var $aDom = $(this); + var resId = $aDom.data('id'); + var favIdList = $aDom.data('favid') && $aDom.data('favid') != 'null' ? $aDom.data('favid').split(',') : []; + admin.req({ + url: common.domainName + '/api-web/favorites/treeSelectData' + }).done(function (response) { + var data = response.data; + if (data.length == 0) { + var selectValue = ''; + saveFavs($aDom,selectValue,resId,'true'); + } else if (data.length == 1) { + var selectValue = data[0].value; + saveFavs($aDom,selectValue,resId,'false'); + } else { + layer.open({ + type: '1', + title: '选择收藏夹', + id: 'layer-select-favorites', + content: '<div class="div-select-favorites"><div id="slt-favorites-tree"></div></div>', + offset: '150px', + area: ['20%', '15%'], + btn: ['选择', '取消'], + resize: false, + success: function () { + admin.req({ + url: common.domainName + '/api-web/favorites/treeSelectData' + }).done(function (response) { + xmSelect.render({ + el: '#slt-favorites-tree', + radio: true, + clickClose: true, + autoRow: true, + filterable: true, + height: 'auto', + toolbar: { + show: true, + }, + model: { + label: { + type: 'text' + } + }, + tree: { + show: true, + showFolderIcon: true, + showLine: true, + indent: 20, + expandedKeys: true, + strict: false + }, + data: data + }); + }); + }, + yes: function (layerIndex) { + var selectValue = xmSelect.get('#slt-favorites-tree', true).getValue('value'); + if (favIdList.length === 0 && selectValue.length === 0) { + layer.msg('请选择一个收藏夹!', {icon: 0, time: 3000}); + return false; + } + var favIds = selectValue.join(','); + layer.load(2); + saveFavs($aDom,favIds,resId,'false',layerIndex); + } + }); + } + }) + } - //移出收藏夹 - $('a.layui-icon-rate-solid').unbind('click').on('click',rateSolidClick ); + //移出收藏夹 + $('a.layui-icon-rate-solid').unbind('click').on('click',rateSolidClick ); - function rateSolidClick() { - var $aDom = $(this); - var resId = $aDom.data('id'); - var favId = ''; - saveFavs($aDom,favId,resId,'false'); - } + function rateSolidClick() { + var $aDom = $(this); + var resId = $aDom.data('id'); + var favId = ''; + saveFavs($aDom,favId,resId,'false'); + } - //添加收藏夹/移出收藏夹 - function saveFavs($aDom,favIds,resId,flag,layerIndex) { - admin.req({ - url: common.domainName + '/api-web/favorites/save/fav', - type: 'POST', - data: { - favIds: favIds, - resId: resId, - flag: flag - }, - error: function () { + //添加收藏夹/移出收藏夹 + function saveFavs($aDom,favIds,resId,flag,layerIndex) { + admin.req({ + url: common.domainName + '/api-web/favorites/save/fav', + type: 'POST', + data: { + favIds: favIds, + resId: resId, + flag: flag + }, + error: function () { + layer.closeAll('loading'); + } + }).done(function (response) { layer.closeAll('loading'); - } - }).done(function (response) { - layer.closeAll('loading'); - if (response.success) { - if (favIds != '' || (flag == 'true' && favIds == '')) { - $aDom.removeClass('layui-icon-rate'); - $aDom.removeClass('hide'); - $aDom.addClass('layui-icon-rate-solid'); - $aDom.unbind('click').on('click', rateSolidClick); - $aDom.attr('lay-tips', '移出收藏夹'); - $aDom.css('color','#FEB61E').css('font-size','14px'); - $aDom.data('favid', favIds); + if (response.success) { + if (favIds != '' || (flag == 'true' && favIds == '')) { + $aDom.removeClass('layui-icon-rate'); + $aDom.removeClass('hide'); + $aDom.addClass('layui-icon-rate-solid'); + $aDom.unbind('click').on('click', rateSolidClick); + $aDom.attr('lay-tips', '移出收藏夹'); + $aDom.css('color','#FEB61E').css('font-size','14px'); + $aDom.data('favid', favIds); + } else { + $aDom.removeClass('layui-icon-rate-solid'); + $aDom.addClass('layui-icon-rate'); + $aDom.unbind('click').on('click', rate); + $aDom.addClass('hide'); + $aDom.attr('lay-tips', '加入收藏夹'); + $aDom.css('font-size','14px'); + $aDom.data('favid', ''); + } + layer.close(layerIndex); } else { - $aDom.removeClass('layui-icon-rate-solid'); - $aDom.addClass('layui-icon-rate'); - $aDom.unbind('click').on('click', rate); - $aDom.addClass('hide'); - $aDom.attr('lay-tips', '加入收藏夹'); - $aDom.css('font-size','14px'); - $aDom.data('favid', ''); + layer.msg('保存失败!', {icon: 2, time: 3000}); } - layer.close(layerIndex); - } else { - layer.msg('保存失败!', {icon: 2, time: 3000}); - } - }); - } + }); + } - // 打开详情页面 - $('[resmanage-data-openDetail]').unbind("click").on('click', function () { - // if ($.inArray('back:resource:update', checkList) == -1) { - // layer.msg('暂无权限!', {icon: 7, time: 3000}); - // return; - // } - //背景色改变 - $.each($(this).parents('tbody').eq(0).find('tr'),function (i,v) { - $(this).css('background-color',''); - if($(this).hasClass('tbody-tr-background-color')){ - $(this).removeClass('tbody-tr-background-color'); + // 打开详情页面 + $('[resmanage-data-openDetail]').unbind("click").on('click', function () { + // if ($.inArray('back:resource:update', checkList) == -1) { + // layer.msg('暂无权限!', {icon: 7, time: 3000}); + // return; + // } + //背景色改变 + $.each($(this).parents('tbody').eq(0).find('tr'),function (i,v) { + $(this).css('background-color',''); + if($(this).hasClass('tbody-tr-background-color')){ + $(this).removeClass('tbody-tr-background-color'); + } + }); + $(this).parents('tr').eq(0).addClass("tbody-tr-background-color"); + var resId = $(this).attr("resmanage-data-openDetail"); + var resType = $(this).data("restype"); + var name = $(this).data("name"); + var ip = $(this).data("ip"); + var resTypeName = $(this).data("restypename"); + var admin = $(this).data("admin"); + var adminName = $(this).data("adminname"); + var manageIp = $(this).data("manageip"); + var collProtocol = $(this).data("collprotocol"); + var provider= $(this).data("provider"); + if (name && name != ''){ + name += ' | '; } - }); - $(this).parents('tr').eq(0).addClass("tbody-tr-background-color"); - var resId = $(this).attr("resmanage-data-openDetail"); - var resType = $(this).data("restype"); - var name = $(this).data("name"); - var ip = $(this).data("ip"); - var resTypeName = $(this).data("restypename"); - var admin = $(this).data("admin"); - var adminName = $(this).data("adminname"); - var manageIp = $(this).data("manageip"); - var collProtocol = $(this).data("collprotocol"); - var provider= $(this).data("provider"); - if (name && name != ''){ - name += ' | '; - } - if (resTypeName && resType !== 'HOST_X86SERVER') { - name += resTypeName + '|'; - } - if (ip) { - if (resType === 'HOST_X86SERVER') { - if (collProtocol && (collProtocol.split(",").length > 1 || collProtocol === 'SSH')) { - name += '应用IP-' + ip + '|'; + if (resTypeName && resType !== 'HOST_X86SERVER') { + name += resTypeName + '|'; + } + if (ip) { + if (resType === 'HOST_X86SERVER') { + if (collProtocol && (collProtocol.split(",").length > 1 || collProtocol === 'SSH')) { + name += '应用IP-' + ip + '|'; + } + } else { + name += ip + '|'; } - } else { - name += ip + '|'; } - } - if (resType === 'HOST_X86SERVER' && collProtocol && collProtocol.indexOf('SNMP') !== -1 ) { - if (manageIp) { - name += '管理IP-' + manageIp + '|'; + if (resType === 'HOST_X86SERVER' && collProtocol && collProtocol.indexOf('SNMP') !== -1 ) { + if (manageIp) { + name += '管理IP-' + manageIp + '|'; + } } - } - if (adminName){ - name += adminName + ' | '; - } - if (name.length>0){ - name = name.substr(0,name.length-1); - } - if(resType=='STORAGE_SHARE' && provider!='HUAWEI' && provider!='Inspur'){ - return false; - } - commonDetail.openDetail(resId,resType,name) - }); - resTopo(); - } - }); + if (adminName){ + name += adminName + ' | '; + } + if (name.length>0){ + name = name.substr(0,name.length-1); + } + if(resType=='STORAGE_SHARE' && provider!='HUAWEI' && provider!='Inspur'){ + return false; + } + commonDetail.openDetail(resId,resType,name) + }); + resTopo(); + + //lsq T3和IOP点击修改删除 2022-08-04 + $('.edit-delete-tpl').unbind('click').on('click',function (){ + var $T3Dom = $(this); + //判断是字段类型T3/IOP + let tplType=$T3Dom.data('tpltype'); + //获取资源id + var resId = $T3Dom.data('resid'); + //获取旧数据 + let old_T3Dom=$T3Dom.text(); + //获取扩展字段id + let expandId=$T3Dom.data('expandid'); + //获取字段为输入框或者下拉选择 0 输入框 1下拉选择 + let fieldSourceType=$T3Dom.data('fieldsourcetype'); + //获取下拉选择值 + let fieldList=$T3Dom.data('list'); + let url='/api-web/resource/expand/saveOrUpdate'; + //判断类型是输入框还是下拉列表 + let titleName=''; + let promptHtml=''; + if(fieldSourceType == '0'){ + titleName='请输入'; + promptHtml=`<input type="text" id="promptInput" name="promptInput" autocomplete="off" class="layui-input">` + }else if(fieldSourceType== '1'){ + titleName='请选择'; + promptHtml=`<select id="promptInput" style="width:80%;cursor:pointer;" class="layui-select" lay-filter="promptInput">` + if(fieldList){ + let fieldListArr=fieldList.split(",") + fieldListArr.map(item=>{ + promptHtml+=`<option value="`+item+`">`+item+`</option>`; + }) + } + promptHtml+=`</select>`; + }else{ + promptHtml=`` + } + let html_tpl=`<div class="T3-IOP-prompt">`+promptHtml+`</div>`; + layer.open({ + title: [titleName+tplType, 'font-size:14px;'], + type: 1, + area: ['280px','170px'], + content: html_tpl, + success: function () { + $('#promptInput').val(old_T3Dom) + } + , id: 'lay_T3_IOP' //设定一个id,防止重复弹出 + , btn: ['清空', '保存'] + , yes: function (index, layero) { + layer.confirm('确认要删除吗?', {icon: 3, title: '提示'}, function (index1) { + layer.load(2); + admin.req({ + //删除T3值 + url: common.domainName + url, + data: { + resId:resId, + fieldValue:'', + expandId:expandId,//扩展字段id + + }, + }).done(function (response) { + layer.closeAll('loading'); + if (response.success) { + layer.msg('删除成功!', {icon: 1, time: 3000}); + $T3Dom.text(''); + } else { + layer.msg('删除失败!', {icon: 2, time: 3000}); + } + layer.close(index); + }); + }) + } + , btn2:function(index, layero){ + var value = $('#promptInput').val(); + if (value !== old_T3Dom) { + layer.load(2); + admin.req({ + //修改扩展字段T3/IOp值 + url: common.domainName + url, + data: { + resId:resId, + fieldValue:value, + expandId:expandId,//扩展字段id + + }, + success: function (response) { + layer.closeAll('loading'); + if (response && response.success) { + layer.msg('修改成功', {icon: 1}); + $T3Dom.text(value); + } else { + layer.msg('修改失败', {icon: 2}); + } + layer.close(index); + + }, + error: function (err) { + layer.closeAll('loading'); + layer.msg('修改失败', {icon: 2}); + } + }); + } else { + layer.close(index); + } + }, + }); + }) + //end lsq T3和IOP点击修改/删除 2022-08-04 + } + }); + },300) } //处理表头和内容不能对齐的问题 diff --git a/hg-monitor-web-base/src/main/resources/static/src/controller/resindex.js b/hg-monitor-web-base/src/main/resources/static/src/controller/resindex.js index 258409d..fa2c2ab 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/controller/resindex.js +++ b/hg-monitor-web-base/src/main/resources/static/src/controller/resindex.js @@ -4,6 +4,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', ' var $ = layui.$; var common = layui.common; var table = layui.table; + var fieldExpandArr=[];//获取扩展的表格字段 //对外暴露的接口 exports('resindex', function (data) { @@ -169,46 +170,77 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', ' } else { cols = commonCols.resTypeCls[resType]; } - resTableList = table.render({ - elem: '#resindexList' - , id: 'resindexList' - , url: common.domainName + '/api-web/home/res-list/' + resType - , toolbar: '<div><button id="resTableIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' - , where: { - access_token: accessToken, - resCategory: 'resources' - } - , height: '100' - , cellMinWidth: 80 - , page: false - , cols: [cols] - , done: function (res, curr, count) { - //2021/10/18 徐毫杰 阿里云服务器更改样式 - if(resType=='ALI_CLOUD_PLAT'){ - $('.layui-table-view').height(170); - $('.layui-table-main').height(70); - } - //调用收藏方法 - resFavorites(); - resTopo(); - - commonCols.colsClickEvent(editFlag); - - //触发拖动列事件,参数为保存按钮的id - common.dragCols("resTableIndex_cols_save"); - - //保存列顺序 - $("#resTableIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'resTableList', - moduleId: 'resIndex', - resType: resType, - cols: resTableList.config.cols + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } } - common.saveTableCols(params); - }); + } else { + console.log(res.msg); + } } }); + setTimeout(function (){ + resTableList = table.render({ + elem: '#resindexList' + , id: 'resindexList' + , url: common.domainName + '/api-web/home/res-list/' + resType + , toolbar: '<div><button id="resTableIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' + , where: { + access_token: accessToken, + resCategory: 'resources' + } + , height: '100' + , cellMinWidth: 80 + , page: false + , cols: [cols] + , done: function (res, curr, count) { + //2021/10/18 徐毫杰 阿里云服务器更改样式 + if(resType=='ALI_CLOUD_PLAT'){ + $('.layui-table-view').height(170); + $('.layui-table-main').height(70); + } + //调用收藏方法 + resFavorites(); + resTopo(); + + commonCols.colsClickEvent(editFlag); + + //触发拖动列事件,参数为保存按钮的id + common.dragCols("resTableIndex_cols_save"); + + //保存列顺序 + $("#resTableIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'resTableList', + moduleId: 'resIndex', + resType: resType, + cols: resTableList.config.cols + } + common.saveTableCols(params); + }); + } + }); + },300) }); } //左侧树 @@ -752,148 +784,179 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', ' var index = layer.load(2); //加载层 var cols = commonCols.resTypeCls[resType]; + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 admin.req({ - url: common.domainName + "/api-web/home/virtual-res-list/" + resType - , type: "get" - , data: { - ptId: $("#virtual_platForm_select").val(), - busId: bizId, - keyWords: $("#treetable_keyword").val(), - health: $("#treetable_resStatus").val(), - state: $("#treetable_res_state").val(), - resCategory: 'resources', - collProtocols : collProtocols - - } + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType , done: function (res) { - layer.close(index); - if (res.code == 0) { - //渲染表格 - var tableTreeVirtual; - //获取配置的列 - common.getTableCols({ - domId: 'tableTreeVirtual', - moduleId: 'resIndex', - resType: resType - },function (retCols) { - if (retCols) { - cols = retCols; + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) } - tableTreeVirtual = table.render({ - elem: '#virtual_platform_treeTable', - autoColumnWidth: false, - page: false, - limit: 9999, - data: res.data, - tree: { - iconIndex: 1 - }, - cols: [cols] - , height: 'full-220', - done: function (res) { - soulTable.render(this); - - //调用收藏方法 - resFavorites(); - resTopo(); - - common.treeTableDragCols('#virtual_platform_treeTable', '#resTreeList-top-head-info-tpl'); - loadRightResTypeSelectEvent(curTreeNode.data.id,"tree") - // 保存列顺序 - $('#virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){ - common.saveTableCols({ - domId: 'tableTreeVirtual', - moduleId: 'resIndex', - resType: resType, - cols: tableTreeVirtual.config.cols - }); - }); + } + } else { + console.log(res.msg); + } + } + }); + setTimeout(function (){ + admin.req({ + url: common.domainName + "/api-web/home/virtual-res-list/" + resType + , type: "get" + , data: { + ptId: $("#virtual_platForm_select").val(), + busId: bizId, + keyWords: $("#treetable_keyword").val(), + health: $("#treetable_resStatus").val(), + state: $("#treetable_res_state").val(), + resCategory: 'resources', + collProtocols : collProtocols - commonCols.colsClickEvent(editFlag); + } + , done: function (res) { + layer.close(index); + if (res.code == 0) { + //渲染表格 + var tableTreeVirtual; + //获取配置的列 + common.getTableCols({ + domId: 'tableTreeVirtual', + moduleId: 'resIndex', + resType: resType + },function (retCols) { + if (retCols) { + cols = retCols; } - }); - /** - /**表格的增删改都会回调此方法 - * 与table.on(tool(lay-filter))用法一致。 - **/ - /*tableTreeVirtual.on('tool(tableEvent)',function (obj) { - if(!obj.data.treeList){ - var field = obj.field; //单元格字段 - var value = obj.value; //修改后的值 - var data = obj.data; //当前行数据 - var event = obj.event; //当前单元格事件属性值 - var subResType = ''; - if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){ - subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER'; - }else if(data.resType.indexOf('CLUSTER')>-1){ - subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; - }else if(data.resType.indexOf('PHYSICSHOST')>-1){ - subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; - }else{ - subResType = data.resType + tableTreeVirtual = table.render({ + elem: '#virtual_platform_treeTable', + autoColumnWidth: false, + page: false, + limit: 9999, + data: res.data, + tree: { + iconIndex: 1 + }, + cols: [cols] + , height: 'full-220', + done: function (res) { + soulTable.render(this); + + //调用收藏方法 + resFavorites(); + resTopo(); + + common.treeTableDragCols('#virtual_platform_treeTable', '#resTreeList-top-head-info-tpl'); + loadRightResTypeSelectEvent(curTreeNode.data.id,"tree") + // 保存列顺序 + $('#virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){ + common.saveTableCols({ + domId: 'tableTreeVirtual', + moduleId: 'resIndex', + resType: resType, + cols: tableTreeVirtual.config.cols + }); + }); + + commonCols.colsClickEvent(editFlag); } - if(event === 'loadChildren'){ - $.ajax({ - url: common.domainName + "/api-web/home/virtual-res-list/" + subResType - , type: "get" - , data: { - ptId: $("#virtual_platForm_select").val(), - health: $("#treetable_resStatus").val(), - busId: $("#treetableBizTypes").val(), - keyWords: $("#treetable_keyword").val(), - state: $("#treetable_state").val(), - access_token:accessToken, - parentId:data.resId - } - ,success:function (res) { - if(res.data.length>0){ - obj.loadChildren(res.data); - commonCols.colsClickEvent(); + }); + /** + /**表格的增删改都会回调此方法 + * 与table.on(tool(lay-filter))用法一致。 + **/ + /*tableTreeVirtual.on('tool(tableEvent)',function (obj) { + if(!obj.data.treeList){ + var field = obj.field; //单元格字段 + var value = obj.value; //修改后的值 + var data = obj.data; //当前行数据 + var event = obj.event; //当前单元格事件属性值 + var subResType = ''; + if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){ + subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER'; + }else if(data.resType.indexOf('CLUSTER')>-1){ + subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST'; + }else if(data.resType.indexOf('PHYSICSHOST')>-1){ + subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST'; + }else{ + subResType = data.resType + } + if(event === 'loadChildren'){ + $.ajax({ + url: common.domainName + "/api-web/home/virtual-res-list/" + subResType + , type: "get" + , data: { + ptId: $("#virtual_platForm_select").val(), + health: $("#treetable_resStatus").val(), + busId: $("#treetableBizTypes").val(), + keyWords: $("#treetable_keyword").val(), + state: $("#treetable_state").val(), + access_token:accessToken, + parentId:data.resId } - } - }) + ,success:function (res) { + if(res.data.length>0){ + obj.loadChildren(res.data); + commonCols.colsClickEvent(); + } + } + }) + } } - } - });*/ - //统计总数 - // $('#virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#treetable-countTpl').html()).render(res.data.length)); - }); - } else { - console.log(data.msg); - } - //关键字回车事件 - $('#treetable_keyword').keydown(function (e) { - if (e.keyCode === 13) { - renderTreeTable(curTreeNode.data.id) - return false; + });*/ + //统计总数 + // $('#virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#treetable-countTpl').html()).render(res.data.length)); + }); + } else { + console.log(data.msg); } - }); - //选择资源状态 - form.on('select(treetable_resStatus)', function (data) { - renderTreeTable(curTreeNode.data.id); - }); - // //选择业务 - // form.on('select(treetableBizTypes)', function (data) { - // renderTreeTable(curTreeNode.data.id); - // }); - //选择平台 - form.on('select(virtual_platForm_select)', function (data) { - renderTreeTable(curTreeNode.data.id); - }); - //选择资源连接状态 - form.on('select(treetable_state)', function (data) { - renderTreeTable(curTreeNode.data.id); - }); - form.on('select(treetable_res_state)', function (data) { - renderTreeTable(curTreeNode.data.id); - }); + //关键字回车事件 + $('#treetable_keyword').keydown(function (e) { + if (e.keyCode === 13) { + renderTreeTable(curTreeNode.data.id) + return false; + } + }); + //选择资源状态 + form.on('select(treetable_resStatus)', function (data) { + renderTreeTable(curTreeNode.data.id); + }); + // //选择业务 + // form.on('select(treetableBizTypes)', function (data) { + // renderTreeTable(curTreeNode.data.id); + // }); + //选择平台 + form.on('select(virtual_platForm_select)', function (data) { + renderTreeTable(curTreeNode.data.id); + }); + //选择资源连接状态 + form.on('select(treetable_state)', function (data) { + renderTreeTable(curTreeNode.data.id); + }); + form.on('select(treetable_res_state)', function (data) { + renderTreeTable(curTreeNode.data.id); + }); - commonCols.colsClickEvent(editFlag); + commonCols.colsClickEvent(editFlag); - } - }).error(function () { - layer.close(index); - }); + } + }).error(function () { + layer.close(index); + }); + },300) } @@ -995,116 +1058,148 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', ' } //渲染表格 var cols = commonCols.resTypeCls[resType]; - //获取配置的列 - common.getTableCols({ - domId: 'parentResListTable', - moduleId: 'resIndex', - resType: resType - },function (retCols) { - if(retCols){ - cols = retCols; - } - - parentResListTable = table.render({ - elem: '#resListTable' - , id: 'resListTable' - , toolbar: '#resList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: {toolbar: false} - , url: common.domainName + '/api-web/home/res-list/' + resType - , where: { - access_token: accessToken, - resName: resindexKeyword, - busId: bizId, - resHealth: $("#resStatus").val(), - colonlyId: $("#res_colony").val(), - parentId: $("#res_cluster").val(), - sortKey: sortKey, - state: $("#state").val(), - linkState: $("#link_state").val(), - hostState: $("#host_state").val(), - powerState: $("#power_state").val(), - resCategory: 'resources' + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) + } + } + } else { + console.log(res.msg); } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' + } + }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'parentResListTable', + moduleId: 'resIndex', + resType: resType + },function (retCols) { + if(retCols){ + cols = retCols; } - , autoSort: false - , limit: 150 - , limits: [150, 200, 300] - , cols: [cols] - , done: function (res, curr, count) { - //更改样式 - function noClick($that) { - $that.css("color", "#666"); - $that.css("text-decoration", "none"); - $that.attr("lay-tips", "未监控到数据"); - } - // 共享设备,厂商是H3C、HDS的设备不让点击并且提示暂无监控信息 - var $hsc_ = $('span[data-restype="STORAGE_SHARE"][data-provider="H3C"]'); - $.each($hsc_, function (i, v) { - noClick($(this)); - }); - var $hds = $('span[data-restype="STORAGE_SHARE"][data-provider="HDS"]'); - $.each($hds, function (i, v) { - noClick($(this)); - }); - //华为云,阿里云不让点击,并且提示暂无监控信息 - // var $hds = $('span[data-restype="HUAWEI_CLOUD_PLAT"]'); - // $.each($hds, function (i, v) { - // noClick($(this)); - // }); - // var $hds = $('span[data-restype="ALI_CLOUD_PLAT"]'); - // $.each($hds, function (i, v) { - // noClick($(this)); - // }); - - soulTable.render(this) - - //调用收藏方法 - resFavorites(); - resTopo(); - - commonCols.colsClickEvent(editFlag); + parentResListTable = table.render({ + elem: '#resListTable' + , id: 'resListTable' + , toolbar: '#resList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: {toolbar: false} + , url: common.domainName + '/api-web/home/res-list/' + resType + , where: { + access_token: accessToken, + resName: resindexKeyword, + busId: bizId, + resHealth: $("#resStatus").val(), + colonlyId: $("#res_colony").val(), + parentId: $("#res_cluster").val(), + sortKey: sortKey, + state: $("#state").val(), + linkState: $("#link_state").val(), + hostState: $("#host_state").val(), + powerState: $("#power_state").val(), + resCategory: 'resources' + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , autoSort: false + , limit: 150 + , limits: [150, 200, 300] + , cols: [cols] + , done: function (res, curr, count) { + //更改样式 + function noClick($that) { + $that.css("color", "#666"); + $that.css("text-decoration", "none"); + $that.attr("lay-tips", "未监控到数据"); + } - //表格排序监听 joke add 20200408 - table.on('sort(resListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - if (obj.field == 'ip') { - sortKey = 'INET_ATON(' + obj.field + ') ' + obj.type; + // 共享设备,厂商是H3C、HDS的设备不让点击并且提示暂无监控信息 + var $hsc_ = $('span[data-restype="STORAGE_SHARE"][data-provider="H3C"]'); + $.each($hsc_, function (i, v) { + noClick($(this)); + }); + var $hds = $('span[data-restype="STORAGE_SHARE"][data-provider="HDS"]'); + $.each($hds, function (i, v) { + noClick($(this)); + }); + //华为云,阿里云不让点击,并且提示暂无监控信息 + // var $hds = $('span[data-restype="HUAWEI_CLOUD_PLAT"]'); + // $.each($hds, function (i, v) { + // noClick($(this)); + // }); + // var $hds = $('span[data-restype="ALI_CLOUD_PLAT"]'); + // $.each($hds, function (i, v) { + // noClick($(this)); + // }); + + soulTable.render(this) + + //调用收藏方法 + resFavorites(); + resTopo(); + + commonCols.colsClickEvent(editFlag); + + //表格排序监听 joke add 20200408 + table.on('sort(resListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + if (obj.field == 'ip') { + sortKey = 'INET_ATON(' + obj.field + ') ' + obj.type; + } else { + sortKey = obj.field + ' ' + obj.type; + } } else { - sortKey = obj.field + ' ' + obj.type; + sortKey = ''; } - } else { - sortKey = ''; - } - reloadTable(); - }) + reloadTable(); + }) - //触发拖动列事件,参数为保存按钮的id - common.dragCols("parentResIndex_cols_save"); + //触发拖动列事件,参数为保存按钮的id + common.dragCols("parentResIndex_cols_save"); - //保存列顺序 - $("#parentResIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'parentResListTable', - moduleId: 'resIndex', - resType: resType, - cols: parentResListTable.config.cols - } - common.saveTableCols(params); - }); - // 渲染统计数据 - loadRightResTypeSelectEvent(resType,"normal"); - } + //保存列顺序 + $("#parentResIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'parentResListTable', + moduleId: 'resIndex', + resType: resType, + cols: parentResListTable.config.cols + } + common.saveTableCols(params); + }); + // 渲染统计数据 + loadRightResTypeSelectEvent(resType,"normal"); + } + }); }); - }); + },300) + } //资源列表 @@ -1132,85 +1227,116 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', ' $('#power_state_div').show(); } var cols = commonCols.resTypeCls[resType]; - //获取配置的列 - common.getTableCols({ - domId: 'resListTable', - moduleId: 'resIndex', - resType: resType - },function (retCols) { - if (retCols) { - cols = retCols; - } - resListTable = table.render({ - elem: '#resListTable' - , id: 'resListTable' - , toolbar: '<div><button id="resIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' //开启头部工具栏,并为其绑定左侧模板 - , defaultToolbar: ['filter'] - , drag: {toolbar: false} - , url: common.domainName + '/api-web/home/res-list/' + resType - , where: { - access_token: accessToken, - resName: resindexKeyword !== '' ? resindexKeyword : id, - busId: bizId, - resHealth: $("#resStatus").val(), - colonlyId: $("#res_colony").val(), - parentId: $("#res_cluster").val(), - sortKey: sortKey, - state: $("#state").val(), - linkState: $("#link_state").val(), - hostState: $("#host_state").val(), - powerState: $("#power_state").val(), - provider: $("#res_vendor").val(), - resCategory: 'resources' - } - , height: 'full-165' - , cellMinWidth: 80 - , page: { - layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] - , theme: '#1E9FFF' - } - , autoSort: false - , limit: 150 - , limits: [150, 200, 300] - , cols: [cols] - , done: function (res, curr, count) { - soulTable.render(this) - - //调用收藏方法 - resFavorites(); - resTopo(); - - commonCols.colsClickEvent(editFlag); - loadRightResTypeSelectEvent(curTreeNode.id ? curTreeNode.id : curTreeNode.data.id, "normal", res.obj); - - //表格排序监听 joke add 20200408 - table.on('sort(resListTable)', function (obj) { - //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: - if (obj.type != null) { - sortKey = obj.field + ' ' + obj.type; - } else { - sortKey = ''; - } - reloadTable(); - }) - - //触发拖动列事件,参数为保存按钮的id - common.dragCols("resIndex_cols_save"); - - //保存列顺序 - $("#resIndex_cols_save").unbind("click").on("click", function () { - var params = { - domId: 'resListTable', - moduleId: 'resIndex', - resType: resType, - cols: resListTable.config.cols + //start lsq 根据资源类型resType获取动态添加的列表字段 2022-08-05 + admin.req({ + url: common.domainName + "/api-web/resource/expand/list?resType=" + resType + , done: function (res) { + if (res && res.data ) { + let arr=res.data; + if(fieldExpandArr.indexOf(resType)!=-1){ + }else{ + fieldExpandArr.push(resType); + if(arr.length>0){ + arr.map(item=>{ + let listStr=''; + if(item.list && item.list.length>0){ + listStr=item.list.join(',') + } + cols.splice(item.fieldSort,0,{field: item.field, title: item.fieldName, align: 'center', width: 100, sort: true, + templet:` <div> + <div class="edit-delete-tpl T-edit-delete-tpl" lay-tips="点击修改/删除" data-fieldsourcetype="`+item.fieldSourceType+`" + data-expandid="`+item.id+`" data-list="`+listStr+`" data-tpltype="`+item.field+`" data-resid="{{d.resId}}"> + {{d.`+item.field+` ? d.`+item.field+` : ''}} + </div></div>`}) + }) } - common.saveTableCols(params); - $(this).addClass("hide"); - }); + } + } else { + console.log(res.msg); } - }); + } }); + setTimeout(function (){ + //获取配置的列 + common.getTableCols({ + domId: 'resListTable', + moduleId: 'resIndex', + resType: resType + },function (retCols) { + if (retCols) { + cols = retCols; + } + resListTable = table.render({ + elem: '#resListTable' + , id: 'resListTable' + , toolbar: '<div><button id="resIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont"></i></button></div>' //开启头部工具栏,并为其绑定左侧模板 + , defaultToolbar: ['filter'] + , drag: {toolbar: false} + , url: common.domainName + '/api-web/home/res-list/' + resType + , where: { + access_token: accessToken, + resName: resindexKeyword !== '' ? resindexKeyword : id, + busId: bizId, + resHealth: $("#resStatus").val(), + colonlyId: $("#res_colony").val(), + parentId: $("#res_cluster").val(), + sortKey: sortKey, + state: $("#state").val(), + linkState: $("#link_state").val(), + hostState: $("#host_state").val(), + powerState: $("#power_state").val(), + provider: $("#res_vendor").val(), + resCategory: 'resources' + } + , height: 'full-165' + , cellMinWidth: 80 + , page: { + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] + , theme: '#1E9FFF' + } + , autoSort: false + , limit: 150 + , limits: [150, 200, 300] + , cols: [cols] + , done: function (res, curr, count) { + soulTable.render(this) + + //调用收藏方法 + resFavorites(); + resTopo(); + + commonCols.colsClickEvent(editFlag); + loadRightResTypeSelectEvent(curTreeNode.id ? curTreeNode.id : curTreeNode.data.id, "normal", res.obj); + + //表格排序监听 joke add 20200408 + table.on('sort(resListTable)', function (obj) { + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如: + if (obj.type != null) { + sortKey = obj.field + ' ' + obj.type; + } else { + sortKey = ''; + } + reloadTable(); + }) + + //触发拖动列事件,参数为保存按钮的id + common.dragCols("resIndex_cols_save"); + + //保存列顺序 + $("#resIndex_cols_save").unbind("click").on("click", function () { + var params = { + domId: 'resListTable', + moduleId: 'resIndex', + resType: resType, + cols: resListTable.config.cols + } + common.saveTableCols(params); + $(this).addClass("hide"); + }); + } + }); + }); + },300) } diff --git a/hg-monitor-web-base/src/main/resources/static/src/style/css/main.css b/hg-monitor-web-base/src/main/resources/static/src/style/css/main.css index 286d539..9a039f2 100644 --- a/hg-monitor-web-base/src/main/resources/static/src/style/css/main.css +++ b/hg-monitor-web-base/src/main/resources/static/src/style/css/main.css @@ -8126,4 +8126,17 @@ form[lay-filter="activewarning-form"] .layui-inline { padding: 5px; color: #fff; cursor: pointer; -} \ No newline at end of file +} +/*lsq T3和IOP 2022-08-04*/ +.edit-delete-tpl{ + width: 100%; + height: 100%; + cursor: pointer; +} +.T3-IOP-prompt{ + display: flex; + align-items: center; + justify-content: center; + height: 100%; + padding: 0 20px; +}