xfrontend/web/srczip/logic/dashboard.js
2021-07-23 14:37:55 +08:00

265 lines
10 KiB
JavaScript

//cc
(function(){
X.pageLogic['dashboard'] = {
init :function(){
var me = this;
var popid='';
layui.element.init();
// 项目列表
// http://10.0.0.7:6789/
X.api("project/","get",{},function(d){
X.laytpldata('#layui-project-dot',d,'.layui-project-box');
X.DATA['projectarr'] = d;
X.DATA['projectid'] = d[0]["_id"];
X.DATA["game"] = d[0]["game"];
me.freshMenu(d[0]["_id"]);
// X.template("toptab","analysis-zhanwei",d);
});
// $(".username").html(X.DATA.userinfo.name);
// 选择项目
$(document).off('click','.selectproject').on('click','.selectproject',function(){
var id = $(this).attr("data-id");
var game = $(this).attr("data-game");
$(".projecttit").html($(this).html());
X.DATA['projectid'] = id;
X.DATA["game"] = game;
//侧边栏数据渲染
me.freshMenu(id);
// X.pageLogic.dashboard.freshMenu(id);
});
//a标签点击跳转事件
$(document).on('click','.layui-nav-child a',function(){
var url = $(this).attr("data-url");
X.gourl(url);
});
// 修改面板名
$(document).on('click','.layui-left-dd',function(){
$(".tab-tit-box .tab-tit").html($(this).find("span").html());
X.DATA['dashboard_id'] = $(this).attr('data-id'); //看板id
// 获取报表数据
gettabledata();
});
// 获取表格数据
function gettabledata(){
X.api('dashboard','post',{id:X.DATA['dashboard_id']},function(d){
// console.log(d);
for(let i in d){
X.api("ck/"+d[i]['model']+"_model","post",{report_id:d[i]['report_id']},function(val){
// console.log(val);
if(d[i]['model'] == "event"){
if(d[i]['graph_type'] == 'table'){
X.eventtable(val,function(data){
console.log(data);
X.template("modeltable","chart-box",data);
})
}else if(d[i]['graph_type'] == 'echarts'){
}
}
})
}
})
};
// 渲染添加按钮侧边栏下拉框
X.laydropdown("#chuangjian",X.DATA.createsidebar,function(d){
if(d.url){
X.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
url: d.url
})
}
this.elem.val(d.title);
});
// 时间控件渲染
X.daterender(".tab-right-box .time");
// X.echartsdata("#charts");
//更新时间按钮
$(".updatetime").click(function(){
X.updatatime(".updatetime");
});
//管理我创建的看板
$(".sousuo-box .kbglkanbanbtn").click(function(){
X.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
offset: 'lt',
anim: 5,
skin: 'yourclass',
url: 'adminkanban'
})
});
//渲染时区下拉框
layui.dropdown.render({
elem: ".tab-tit-box .tab-shiqvshezhi"
,data: X.DATA.timezone
,click: function(obj){
console.log(obj)
$(".tab-tit-box .tab-shiqvshezhi").html(obj.title);
//数据更新
// this.elem.val(obj.title);
}
});
//筛选
$(".tab-right-box .tjsx").click(function(){
X.open({
type: 1,
title: false,
closeBtn: 0,
shade:0,
shadeClose: false,
offset: [120,270],
url: "screen",
extData : {}
})
});
// 侧边栏搜索
$('.sousuo-txt').bind('input propertychange', function() {
var tit = $(this).val()
var KanBanData = X.DATA['KanBanData'];
var ProjectData = X.DATA['ProjectData'];
if(tit != ''){
var ssKanBanData = [],
ssProjectData = []
for(let i in KanBanData){
if(KanBanData[i]['title'].indexOf(tit) != -1){
ssKanBanData.push(KanBanData[i]);
}else {
for(let j in KanBanData[i]['children']){
if(KanBanData[i]['children'][j]['title'].indexOf(tit) != -1 ){
var arr = KanBanData[i];
arr['children'].push(KanBanData[i]['children'][j]);
ssKanBanData.push(arr);
}
}
}
}
for(let i in ProjectData){
for(let i in ProjectData){
if(ProjectData[i]['children'].length > 0){
if(ProjectData[i]['title'].indexOf(tit) != -1){
ssProjectData.push(ProjectData[i]);
}else {
var towProjectData = ProjectData[i]['children'];
for(let j in towProjectData){
if(towProjectData[j]['children'].length > 0){
if(towProjectData[j]['children'].length > 0){
var threProjectData = ProjectData[i]['children'][j]['children'];
for(let z in threProjectData){
if(threProjectData[z]['title'].indexOf(tit) != -1){
var arr = ProjectData[i];
arr['children'] = towProjectData[j];
arr['children']['children'] = threProjectData[z];
// arr['children'].push( threProjectData[z] )
ssProjectData.push(arr);
}
}
}
}else {
if(towProjectData[j]['title'].indexOf(tit) != -1 ){
var arr = ProjectData[i];
arr['children'].push(towProjectData[j]);
ssProjectData.push(arr);
}
}
}
}
}else {
if(ProjectData[i]['title'].indexOf(tit) != -1){
ssProjectData.push(ProjectData[i]);
}
}
}
}
X.laytpldata('#mykanban-dot',ssKanBanData,'#mykanban');
X.laytpldata('#kongjian-dot',ssProjectData,'#kongjian');
}else {
me.freshMenu(X.DATA['projectid']);
}
});
// 用户搜索
$("#search").click(function(){
X.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
skin: 'yourclass',
url: 'search'
})
});
$(document).off('click','.tab-right-box .shezhi').on("click",".tab-right-box .shezhi",function(){
X.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
offset: 'rt',
anim: 5,
skin: 'yourclass',
url: 'kanbanshezhi'
})
});
// 保存报表列表
$(document).off('click','.baobiao').on('click','.baobiao',function(){
X.parametersopen({},'kanbanadmin','rt',function(){
console.log(111);
gettabledata();
})
});
//侧边栏更多控制按钮
// taboperation = function(e,type,id,name){
// console.log(X.DATA.taboperationdata[type])
// X.laydropdown('.kanbanwenjianimg',X.DATA.taboperationdata[type]);
// }
},
// X.pageLogic.dashboard.freshMenu();
freshMenu : function(id){
//获取对应侧边栏
X.api('project/kanban',"post",{"_id":id},function (d){
console.log(d);
X.DATA['KanBanData'] = d.kanban;
X.DATA['ProjectData'] = d.spaces;
X.laytpldata('#mykanban-dot',d.kanban,'#mykanban');
X.laytpldata('#kongjian-dot',d.spaces,'#kongjian');
});
}
};
})();