Authored by xwx

资源视图、业务视图左侧树添加搜索栏

... ... @@ -36,6 +36,8 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
var bizParentList;
// 资源视图表格
var bizListTable;
var busHealthKeyWord = '';
var busIndexKeyWord = '';
//点击卡片
$('#bizindexTable').unbind('click').on('click', '[data-biz-card]', function () {
var resType = $(this).data("biz-card");
... ... @@ -58,9 +60,17 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
common.viewBizTopo($(this).data('busid'));
return false;
});
//搜索按钮
$('#bizSearch').unbind('click').on('click',function (){
layer.load(2);
busIndexKeyWord = $('#bizInputSearch').val();
loadBizTree(busIndexKeyWord)
})
//回车搜索
$('#bizindex_keyword').keydown(function (e) {
if (e.keyCode === 13) {
busIndexKeyWord = $(this).val();
layer.load(2);
// renderList(busId, curBizResType);
reloadTable();
return false;
... ... @@ -117,9 +127,10 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType',
}).done(function (res) {
layer.close(loading);
url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType?keyword='+busHealthKeyWord,
sync: true
}).always(function (res) {
layer.closeAll('loading');
laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
bizindexTable.html(html);
});
... ... @@ -136,7 +147,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/countSecondNum?parentId='+parentId,
url: common.domainName + '/api-web/home/resource/countSecondNum?parentId='+parentId+'&keyword='+busIndexKeyWord,
}).done(function (res) {
layer.close(loading);
laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
... ... @@ -171,6 +182,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
if (val == '' || val == null || val == undefined) {
val = '';
}
busHealthKeyWord = val;
admin.req({
url: common.domainName + '/api-web/home/business/getBusTree?keyword=' + val + '&notExist=machineroom',
sync: true,
... ... @@ -262,6 +274,8 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$(".layui-input-search").keyup(function (e) {
if (e.keyCode === 13) {
loadBizTree($(this).val())
busIndexKeyWord = $(this).val();
busHealthKeyWord = $(this).val();
}
});
... ... @@ -371,7 +385,6 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$('#biztreeTableContent').hide();
//清除查询条件
$("#bizindex_keyword").val("");
$("#biz_resStatus").val("");
$("#biz_res_colony").val("");
$("#biz_res_cluster").val("");
... ... @@ -407,7 +420,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString()
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -468,7 +481,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId
url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId +"&keyWord="+busHealthKeyWord
, done: function (res) {
laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
bizindexTable.html(html);
... ... @@ -504,7 +517,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, drag: {toolbar: false}
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -586,7 +599,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -837,7 +850,6 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
//加载资源池、集群等查询条件
function renderBizSerach(resType, busId, subflag) {
//清空查询条件 joke add 20200409 开始
$('#bizindex_keyword').val('');
$('#biz_resStatus').val('');
$('#biz_res_colony').val('');
$('#biz_res_cluster').val('');
... ... @@ -996,7 +1008,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
}
,where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ...
... ... @@ -19,7 +19,8 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
var admin = layui.admin;
var commonDetail = layui.commonDetail;
var domainName = common.domainName;
var resHealthKeyWord = '';
var resindexKeyword = '';
var resTypeSelectExclude = ['HOST_MINICOMPUTER', 'HOST_MINICOMPUTER_SERVER', 'HOST_BMC', 'HOST_X86SERVER']
var curTreeNode = '';
... ... @@ -141,48 +142,16 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/healthByResType?pResType=' + resType,
url: common.domainName + '/api-web/home/resource/healthByResType?pResType=' + resType +'&keyword=' + resHealthKeyWord,
}).done(function (res) {
laytpl($('#resindexTpl').html()).render({list: res.data}, function (html) {
resindexTable.html(html);
layer.closeAll('loading');
});
});
}
admin.req({
url: common.domainName + '/api-web/home/resType/getTree?notExist=machineroom&table=resources&exist=HOST_MINICOMPUTER_SERVER',
type: 'get',
sync: true,
done: function (res) {
layer.close(loading);
loadResTree(res.data);
//joke add 20200407,如果没有资源树,则默认资源页给提示无数据 开始
if (res.data.length === 0) {
var resindexTable = $('#resindexTable');
autoHeight(resindexTable);
laytpl($('#resindexTpl').html()).render({list: res.data}, function (html) {
resindexTable.html(html);
});
}
loadParamSelect();
//joke add 20200407,如果没有资源树,则默认资源页给提示无数据 开始
}
}).error(function () {
layer.close(loading);
//joke add 20200407
//树无数据提示
tree.render({
elem: '#resindextree',
showLine: false,
data: new Array()
});
//右侧无数据提示
var resindexTable = $('#resindexTable');
autoHeight(resindexTable);
laytpl($('#resindexTpl').html()).render({list: new Array()}, function (html) {
resindexTable.html(html);
});
});
//不带分页的列表
function renderTableList(resType) {
... ... @@ -243,7 +212,44 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
});
}
//左侧树
function loadResTree(data) {
function loadResTree(val) {
admin.req({
url: common.domainName + '/api-web/home/resType/getTree?notExist=machineroom&table=resources&exist=HOST_MINICOMPUTER_SERVER&keyword='+val,
type: 'get',
sync: true,
done: function (res) {
layer.close(loading);
treeList(res.data);
//joke add 20200407,如果没有资源树,则默认资源页给提示无数据 开始
if (res.data.length === 0) {
var resindexTable = $('#resindexTable');
autoHeight(resindexTable);
laytpl($('#resindexTpl').html()).render({list: res.data}, function (html) {
resindexTable.html(html);
});
renderIndex('')
}
loadParamSelect();
//joke add 20200407,如果没有资源树,则默认资源页给提示无数据 开始
}
}).error(function () {
layer.close(loading);
//joke add 20200407
//树无数据提示
tree.render({
elem: '#resindextree',
showLine: false,
data: new Array()
});
//右侧无数据提示
var resindexTable = $('#resindexTable');
autoHeight(resindexTable);
laytpl($('#resindexTpl').html()).render({list: new Array()}, function (html) {
resindexTable.html(html);
});
});
}
function treeList(data){
//默认展开全部一级节点
$.each(data,function (i,v) {
v.spread = true;
... ... @@ -681,11 +687,28 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
//回车搜索
$('#resindex_keyword').keydown(function (e) {
if (e.keyCode === 13) {
resindexKeyword = $(this).val();
// renderList(currentResType);
reloadTable();
return false;
}
});
$(".layui-input-search").keydown(function (e) {
if (e.keyCode === 13) {
layer.load(2)
loadResTree($(this).val());
resHealthKeyWord = $(this).val();
resindexKeyword = $(this).val();
}
});
//搜索按钮
$('#resSearch').unbind('click').on('click',function (){
resindexKeyword = $('#inputSearch').val();
resHealthKeyWord = $('#inputSearch').val();
layer.load(2)
loadResTree(resindexKeyword)
})
loadResTree('');
//资源详细信息
function renderDetail(resId, resType) {
... ... @@ -991,7 +1014,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#resindex_keyword").val(),
resName: resindexKeyword,
busId: bizId,
resHealth: $("#resStatus").val(),
colonlyId: $("#res_colony").val(),
... ... @@ -1127,7 +1150,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#resindex_keyword").val() !== '' ? $("#resindex_keyword").val() : id,
resName: resindexKeyword !== '' ? resindexKeyword : id,
busId: bizId,
resHealth: $("#resStatus").val(),
colonlyId: $("#res_colony").val(),
... ... @@ -1158,6 +1181,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
resTopo();
commonCols.colsClickEvent(editFlag);
loadRightResTypeSelectEvent(curTreeNode.id ? curTreeNode.id : curTreeNode.data.id, "normal", res.obj);
//表格排序监听 joke add 20200408
table.on('sort(resListTable)', function (obj) {
... ... @@ -1212,7 +1236,6 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
//加载资源池、集群等查询条件
function renderSerach(resType,subflag) {
//清空查询条件 joke add 20200409 开始
$('#resindex_keyword').val('');
$('#resStatus').val('');
// $('#resListBizTypes').val('');
if(xmSelect.get("#resListBizTypes") && xmSelect.get("#resListBizTypes")[0]){
... ... @@ -1522,7 +1545,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
}
, where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
access_token: accessToken,
resName: $("#resindex_keyword").val(),
resName: resindexKeyword,
busId: bizId,
resHealth: $("#resStatus").val(),
colonlyId: $("#res_colony").val(),
... ...