Authored by xwx

Merge branch 'master' of http://113.200.75.45:82/monitor_v3/hg-monitor-web into master-v32-xwx

... ... @@ -762,7 +762,7 @@ layui.define(['table', 'form', 'laydate', 'admin', 'layer', 'laytpl', 'common',
});
reloadTable();
} else {
layer.msg(response.msg, {
layer.msg("删除失败", {
offset: '15px'
, icon: 2
, timeout: 5000
... ...
layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols', 'echarts', 'sessions',"commonDetail",'tableTree','soulTable'], function (exports) {
var $ = layui.$;
var laytpl = layui.laytpl;
var tree = layui.tree;
var form = layui.form;
var view = layui.view;
var table = layui.table;
var admin = layui.admin;
var commonCols = layui.commonCols;
var soulTable = layui.soulTable;
var tableTree = layui.tableTree;
var common = layui.common;
var commonDetail = layui.commonDetail;
var busId = '';//当前业务Id
var appId = '';
var curTreeNode = '';
var curBizResType = '';//当前业务所在的资源类型
var sortKey = '';
function autoHeight(el) {
// var height = el.parents('.layui-card').height();
// el.css('min-height', height - 75);
}
// 隐藏左侧菜单
$('#LAY_app_flexible').click();
//对外暴露的接口
exports('bizindex', function () {
var sessions = layui.sessions;
var accessToken = sessions.getToken()['access_token'];
var router = layui.router();
// 资源视图父级表格
var bizParentList;
// 资源视图表格
var bizListTable;
//点击卡片
$('#bizindexTable').unbind('click').on('click', '[data-biz-card]', function () {
var resType = $(this).data("biz-card");
var isLeaf = $(this).data("biz-leaf");
//过滤业务卡片
if (isLeaf =='1') {
//回选树节点
selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
renderBizResTypeCard(resType);
} else if(isLeaf == '0'){
selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
renderSecondIndex(resType);
}else{
//curBizResType = resType;
$("div[data-id='"+busId+"']").find("div[data-id='"+resType+"'] .layui-tree-entry:first span.layui-tree-txt").trigger("click")
}
});
// 查看拓扑
$('#bizindexTable').on('click', '.bizcard-view-topo', function () {
common.viewBizTopo($(this).data('busid'));
return false;
});
//回车搜索
$('#bizindex_keyword').keydown(function (e) {
if (e.keyCode === 13) {
// renderList(busId, curBizResType);
reloadTable();
return false;
}
});
var loading = layer.load(2);
// 树收缩事件
$('#bizindex-leftree-shrink').on('click', function () {
$(".bizIndexLeft").animate({width:0,minWidth:0,marginLeft:0},300,function () {
$("#bizindex-leftree_btn").show();
$("#bizindex-leftree-shrink").hide();
});
});
//树展开事件
$("#bizindex-leftree_btn").on("click",function () {
$("#bizindex-leftree_btn").hide();
$("#bizindex-leftree-shrink").show();
$(".bizIndexLeft").animate({minWidth:250,marginLeft:10},300);
});
//this
loadBizTree();
function renderIndex(busId, resType) {
$('#bizIndexContent').show();
$('#bizListContent').hide();
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
bizindexTable.html('<div class="loading"></div>');
admin.req({
url: common.domainName + '/api-web/home/resource/healthByResType?pResType=' + resType + '&busId=' + busId,
}).done(function (res) {
laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
bizindexTable.html(html);
});
});
}
function renderDefaultIndex() {
$('#bizIndexContent').show();
$('#bizListContent').hide();
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType',
}).done(function (res) {
layer.close(loading);
laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
bizindexTable.html(html);
});
});
}
function renderSecondIndex(parentId) {
$('#bizIndexContent').show();
$('#bizListContent').hide();
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/countSecondNum?parentId='+parentId,
}).done(function (res) {
layer.close(loading);
laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
bizindexTable.html(html);
});
});
}
//详细页面
function renderDetail(resId, resType) {
$('#bizIndexContent').hide();
$('#bizListContent').hide();
$('#biztreeTableContent').hide();
$('#bizDetailContent').show();
var url = common.detailPath(resType);
view('commonViewModel').render(url).then(function (res) {
var params = {
"resId": resId,
"resType": resType
};
laytpl(res.body).render(JSON.stringify(params), function (html) {
$("#bizDetailContent").html(html);
});
});
}
//加载树节点
function loadBizTree(val) {
//获取树节点数据
$("#bizindextree").empty();
if (val == '' || val == null || val == undefined) {
val = '';
}
admin.req({
url: common.domainName + '/api-web/home/business/getBusTree?keyword=' + val + '&notExist=machineroom',
sync: true,
done: function (res) {
$('.layui-form layui-card-header')
if (res.success) {
var data = res.data;
tree.render({
elem: '#bizindextree',
showLine: false,
data: data,
click: function (node) {
if (node && node.data && node.data.children && node.data.children.length == 1) {
$('[data-id="' + node.data.children[0].id + '"]').find('.layui-tree-iconClick:first').click()
}
curTreeNode = node;
curBizResType = node.data.id;
if (node.data.code) {
busId = JSON.parse(node.data.code)["busId"];
appId = JSON.parse(node.data.code)["appId"];
}
var el = null;
if (node.data.children) {
el = $(node.elem[0]).find('>.layui-tree-entry .layui-tree-txt');
} else {
el = $(node.elem[0]).find('.layui-tree-txt');
}
var action = 'removeClass';
if (!el.hasClass('tree-node-select') && node.state === 'open') {
action = 'addClass';
el.parents('.layui-tree').find('.tree-node-select').removeClass('tree-node-select');
}
el[action]('tree-node-select');
// 决定显示那个视图
var optionsStr = '';
if (node.data.code) {
optionsStr = JSON.parse(node.data.code)['options'];
}
if (optionsStr && optionsStr != "") {
options = JSON.parse(optionsStr);
var callback = options.bizCallBack;
var fun = eval(callback);
// 获取回调方法
if ($.isFunction(fun)) {
fun.call(this, data, node.data, options);
}
} else if (node.data.code && JSON.parse(node.data.code).isLeaf == '0') {
renderSecondIndex(node.data.id);
} else {
if (node.data && node.data.system) {
//操作系统
if (node.data.system.length > 0) {
renderSystem(node.data.system);
}
} else {
renderBizResTypeCard(node.data.id);
}
}
}
});
$("#bizTotal").html(res.count);
loadParamSelect();
resTopo();
}
}
}).error(function () {
layer.close(loading);
var data = new Array();
tree.render({
elem: '#bizindextree',
showLine: false,
data: data
});
$("#bizTotal").html('0')
laytpl($('#bizindexTpl').html()).render({list: new Array()}, function (html) {
$('#bizindexTable').html(html);
});
});
renderDefaultIndex();
}
$("#bizTotal").parent().on("click",function () {
renderDefaultIndex();
})
$(".layui-input-search").keyup(function (e) {
if (e.keyCode === 13) {
loadBizTree($(this).val())
}
});
//资源详细页面
function loadResDetailInfo(parentNode, data, node, options) {
var resId = data.id;
var resType = data.pid;
renderDetail(resId, resType);
}
function loadChildResTypeCount(parentNode, data, node, options) {
var resId = data.id;
for (var i = 0; i < parentNode.length; i++) {
if (parentNode.id == data.id) {
resId = '';
break;
}
}
var code = JSON.parse(data.code);
renderIndex(code.busId, resId);
}
function loadChildBusCount(parentNode, data, node, options) {
var resId = data.id;
for (var i = 0; i < parentNode.length; i++) {
if (parentNode.id == data.id) {
resId = '';
break;
}
}
var code = JSON.parse(data.code);
renderSecondIndex(code.busId);
}
function openResourceView(parentNode, data, node, options) {
var code = JSON.parse(data.code);
renderList(code.busId, data.id);
}
//资源视图父级列表
function openParentResourceView(parentNode, data, node, options) {
var code = JSON.parse(data.code);
renderParentList(code.busId, data.id);
}
//加载虚拟化数据(平台、资源池、物理机、虚拟机)
function loadVirtualizationView(parentNode, data, node, options) {
renderTreeTable(busId, data.id);
}
//加载weblogic
function loadWeblogicView(parentNode, data, node, options) {
renderParentList(busId, data.id);
}
//资源状态
form.on('select(biz_resStatus)', function (data) {
// renderList(busId, curBizResType)
reloadTable();
});
//集群选择事件
form.on('select(biz_res_cluster)', function (data) {
// renderList(busId, curBizResType);
reloadTable();
});
//资源池选择事件
form.on('select(biz_res_colony)', function (data) {
// renderList(busId, curBizResType);
reloadTable();
});
//资源连接状态选择事件
form.on('select(biz_state)', function (data) {
// renderList(busId, curBizResType);
reloadTable();
});
//资源连接状态选择事件
form.on('select(biz_platform)', function (data) {
// renderList(busId, curBizResType);
reloadTable();
});
//连接状态
form.on('select(bizlink_state)', function (data) {
// renderList(currentResType);
reloadTable();
});
//连接状态
form.on('select(bizlink_state)', function (data) {
// renderList(currentResType);
reloadTable();
});
//资源池选择事件
form.on('select(biz_sub_restype)', function (data) {
// renderList(currentResType);
if (data.value) {
bizLoadRightResTypeSelectEvent(busId, data.value, 'normal')
} else {
bizLoadRightResTypeSelectEvent(busId, curTreeNode.data.id, 'normal')
}
reloadTable();
});
//操作系统
function renderSystem(system) {
$('#bizIndexContent').hide();
$('#bizListContent').show();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
$('#biztreeTableContent').hide();
//清除查询条件
$("#bizindex_keyword").val("");
$("#biz_resStatus").val("");
$("#biz_res_colony").val("");
$("#biz_res_cluster").val("");
$("#bizlink_state").val("");
$("#biz_state").val("");
busId="";
//隐藏资源类型
$("#biz_sub_restype").parent().parent().addClass("hide");
form.render('select');
form.render(null, 'biz-list-form');
var cols = commonCols.resTypeCls["OperatingSystem"];
var resTypeList=[];
$.each(system, function (i, v) {
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">&#xe633;</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: $("#bizindex_keyword").val(),
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();
bizLoadRightResTypeSelectEvent(busId, 'OperatingSystem', 'normal', res.obj);
//表格排序监听 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();
}
});
});
}
//获取业务下的资源类型健康统计
function renderBizResTypeCard(bizId) {
busId = bizId;
$('#bizIndexContent').show();
$('#bizListContent').hide();
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId
, done: function (res) {
laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
bizindexTable.html(html);
});
}
});
}
function renderParentList(busId, resType) {
$('#bizIndexContent').hide();
$('#bizListContent').show();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
$('#biztreeTableContent').hide();
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: $("#bizindex_keyword").val(),
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();
//表格排序监听 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");
bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
//保存列顺序
$("#bizIndex_cols_save").unbind("click").on("click", function () {
var params = {
domId: 'bizParentList',
moduleId: 'bizIndex',
resType: resType,
cols: bizParentList.config.cols
}
common.saveTableCols(params);
});
resTopo();
}
});
});
}
//资源列表
function renderList(busId, resType) {
$('#bizIndexContent').hide();
$('#bizListContent').show();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
$('#biztreeTableContent').hide();
renderBizSerach(resType, busId);
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">&#xe634;</i></button></div>' //开启头部工具栏,并为其绑定左侧模板
, toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
, defaultToolbar: ['filter']
, drag: {toolbar: false}
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
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();
//表格排序监听 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");
bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
//保存列顺序
$("#bizIndex_cols_save").unbind("click").on("click", function () {
var params = {
domId: 'bizListTable',
moduleId: 'bizIndex',
resType: resType,
cols: bizListTable.config.cols
}
common.saveTableCols(params);
});
resTopo();
}
});
});
}
//树表格
function renderTreeTable(busId, resType) {
$('#bizIndexContent').hide();
$('#bizListContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
$('#biztreeTableContent').show();
$(".top-head-info").removeClass("hide");
layer.load(2); //加载层。
//非平台才有以下三个指标信息
if (resType != 'VIRTUALIZATION_VMWARE') {
//绑定虚拟化平台
common.virtualPlatFormSelect("biz_virtual_platForm_select", busId, function () {
form.render("select");
});
if(resType == 'MIDDLEWARE_WEBLOGIC'){
$("#biz_virtual_platform_div_id").hide();
}
} else {
$("#biz_virtual_platform_div_id").hide();
}
var cols = commonCols.resTypeCls[resType];
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 = 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', res.obj);
// 保存列顺序
$('#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();
}
});
/*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));
});
} 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);
});
}
}).error(function () {
layer.closeAll();
});
}
//获取资源统计
function getResCount(busId, resType) {
admin.req({
url: common.domainName + "/api-web/home/res-list/count/" + resType + "?busId=" + busId
, done: function (data) {
var rest = data.map;
if (data.code === 0) {
$("#resGoodCount").text("优:" + rest.good);
$("#resWorseCount").text("良:" + rest.worse);
$("#resWorstCount").text("中:" + rest.worst);
} else {
console.log(data.msg);
}
}
});
}
//回选树节点
function selectedBizTreeNode(target, type) {
$(".layui-tree-txt").removeClass("tree-node-select")
if (type == 'biz') { //如果是业务,默认展开第一节点
$(target).addClass("layui-tree-spread");
$(target).find(".layui-tree-entry").find('.layui-tree-txt').eq(0).addClass("tree-node-select");
$(target).parent().show();
$(target).find(".layui-tree-pack").eq(0).show();
} else if (type == 'select') {
$(target).parent().show();
$(target).find(".layui-tree-txt:first").addClass("tree-node-select");
} else {
var el = $('[data-id="' + busId + '"]').find(target);
$(target).parent().show();
el.find(".layui-tree-txt").addClass("tree-node-select")
}
}
//加载资源池、集群等查询条件
function renderBizSerach(resType, busId, subflag) {
//清空查询条件 joke add 20200409 开始
$('#bizindex_keyword').val('');
$('#biz_resStatus').val('');
$('#biz_res_colony').val('');
$('#biz_res_cluster').val('');
form.render('select');
//清空查询条件 joke add 20200409 开始
var targetId = '';
var searchType = "";
var optons = "";
//华为云物理机,加载华为云集群查询条件
if (resType == 'HUAWEI_CLOUD_PHYSICSHOST') {
optons = "<option value=''>=所属集群=</option>"
searchType = "HUAWEI_CLOUD_CLUSTER";
targetId = "biz_res_cluster";
$("#biz_res_cluster_id").show();
} else if ("MIDDLEWARE_WEBLOGIC" == resType) {
optons = "<option value=''>=所属控制台=</option>"
searchType = "MIDDLEWARE_WEBLOGIC";
targetId = 'biz_res_cluster'
$("#biz_res_cluster_id").show();
} else {
$("#biz_res_cluster_id").hide();
}
//华为云的集群、虚拟化物理机,查询条件绑定资源池
if (resType == 'HUAWEI_CLOUD_CLUSTER' || resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
optons = "<option value=''>=所属资源池=</option>"
if (resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
searchType = "VIRTUALIZATION_VMWARE_CLUSTER";
}
if (resType == 'HUAWEI_CLOUD_CLUSTER') {
searchType = "HUAWEI_CLOUD_COLONY";
}
targetId = "biz_res_colony";
$("#biz_res_colony_id").show();
} else {
$("#biz_res_colony_id").hide();
}
if ("MIDDLEWARE_WEBLOGIC" == resType) {
$("#biz_platform_id").hide()
}
if (resType == 'VIRTUALIZATION_VMWARE' || resType == 'VIRTUALIZATION_HUAWEI' || resType == 'MIDDLEWARE_WEBLOGIC') {
$("#biz_virtual_platform_div_id").hide();
}
if (targetId && searchType) {
var url = "/api-web/home/res-list/" + searchType + "?page=1&limit=50&busId=" + busId;
if(searchType == 'MIDDLEWARE_WEBLOGIC'){
url += '&parentId=null'
}
admin.req({
url: common.domainName + url
}).done(function (res) {
if (res.data) {
$.each(res.data, function (i, v) {
optons += '<option value="' + v.resId + '">' + v.resName + '</option>';
});
}
$('#' + targetId).html(optons);
form.render("select");
})
}
//vmware虚拟机 joke add 20200528
if (resType == 'VIRTUALIZATION_VMWARE_VHOST') {
$("#biz_platform_id").show();
//绑定虚拟化平台
common.virtualPlatFormSelect("biz_platform", "", function () {
form.render("select");
});
} else {
$("#biz_platform_id").hide();
}
if(subflag){
$("#biz_sub_restype").parent().parent().removeClass("hide");
$("#bizListContent").find(".top-head-info").removeClass("hide");
var url = `${common.domainName}/api-web/bResource/finsResTypeListByParentId?resType=${resType}`
admin.req({
url: url
}).done(function (res) {
var subhtml = '<option value="">=资源类型=</option>';
if (res.data) {
$.each(res.data, function (i, v) {
subhtml += '<option value="' + v.name + '">' + v.val + '</option>';
});
}
$('#biz_sub_restype').html(subhtml);
form.render("select");
})
} else {
if (!$("#bizListContent").find(".top-head-info").hasClass("hide")) {
$("#bizListContent").find(".top-head-info").addClass("hide")
}
if (!$("#biz_sub_restype").parent().parent().hasClass("hide")) {
$("#biz_sub_restype").parent().parent().addClass("hide");
}
}
}
function bizLoadRightResTypeSelectEvent(busId, resType, type, obj) {
var str = '';
var domStr = 'bizListContent'
var fun = reloadTable;
if (type == 'tree') {
str = 'tree_'
domStr = 'biztreeTableContent'
fun = renderTreeTable
}
var map = obj;
$.each(map, function (key, values) {
$("#" + str + key + "_biz").html(map[key])
});
//清除筛选条件
$("#" + domStr).find(".info-box-count .num span").unbind().on("click", function () {
var val = $(this).data("value"), target = $(this).data("target");
if (val && target) {
$("#" + target).val(val);
form.render("select")
fun(busId, resType);
} else {
//清除查询条件
$('#bizindex_keyword').val('');
$('#biz_res_colony').val('');
$('#biz_res_cluster').val('');
$('#biz_resStatus').val('');
$('#bizlink_state').val('');
$('#biz_state').val('');
$('#biz_sub_restype').val('');
$("#biz_virtual_platForm_select").val('');
$("#biz_treetable_resStatus").val('');
$("#biz_treetable_keyword").val('');
$("#biz_treetable_res_state").val('');
$('#biz_platform').val('');
form.render("select")
fun(busId, resType);
}
})
}
//重新load表格
function reloadTable() {
var platform = $("#biz_platform").find("option:selected").text();
if (platform == '=所属平台=') {
platform = '';
}
bizListTable = bizParentList = table.reload('bizListTable', {
page: {
curr: 1
}
,where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
parentId: $("#biz_res_cluster").val(),
sortKey: sortKey,
state: $("#biz_state").val(),
linkState: $("#bizlink_state").val(),
platform: platform,
subResType:$("#biz_sub_restype").val()
}
})
}
function loadParamSelect() {
if (router.search.busId) {
busId = router.search.busId;
var type = router.search.type ? router.search.type : 'select';
//回选树节点
selectedBizTreeNode('[data-id="' + busId + '"]', type);
renderBizResTypeCard(busId);
}
}
function resTopo() {
//绑定鼠标移入移出事件
$('table tr').hover(function (obj) {
$(obj.currentTarget).find('.reslist-view-topo').removeClass('hide');
}, function (obj) {
$(obj.currentTarget).find('.reslist-view-topo').addClass('hide');
})
// 加入/移出收藏夹
$('a.reslist-view-topo').unbind('click').on('click', function () {
common.viewResTopo($(this).data('resid'));
});
}
});
});
\ No newline at end of file
... ...