15480 lines
639 KiB
JavaScript
15480 lines
639 KiB
JavaScript
// srczip/common.js
|
||
//基础通用方法
|
||
var X = window.X || {
|
||
event : new EventEmitter(),
|
||
pageLogic : {},
|
||
DATA : {
|
||
'echartscolor': [ '#3ea7fd', '#cdddfd', '#5ad8a6', '#cdf3e4', '#5d7092', '#ced4de', '#f6bd16','#fcebb9','#e86452','#f8d0cb','#6dc8ec', '#d3eef9', '#9270ca', '#d3c6ea', '#ff9d4d', '#ffd8b8', '#269a99','#aad8d8','#ff99c3','#ffd6e7' ],
|
||
'createsidebar':[
|
||
{ title: '新建看板',id: 0,url:'newkanban'},
|
||
// {title: '新建文件夹',id: 1,url:'newwenjian'},
|
||
{title: '创建空间',id: 2,url:'kongjianshezhi'}
|
||
],
|
||
'taboperationdata':{
|
||
kanban:[
|
||
{'title':'重命名','img':'xiugai.png','click':'modifyname'},
|
||
{'title':'移动至','img':'yidong.png','click':'yidong-pop'},
|
||
// {'title':'复制看板','img':'fuzhi.png','click':'copykanban'},
|
||
{'title':'删除看板','img':'del.png','click':'del'},
|
||
],
|
||
wenjian:[
|
||
{'title':'重新命名','img':'xiugai.png','click':'modifyname'},
|
||
{'title':'删除文件夹','img':'del.png','click':'del'},
|
||
],
|
||
baobiao:[
|
||
{'title':'复制看板','img':'fuzhi.png','click':'copy'}
|
||
]
|
||
},
|
||
'gengduolist':[
|
||
{'title':'报表设置','id':'shezhi'},
|
||
{'title':'数据导出','id':'export'},
|
||
{'title':'报表移除','id':'del'},
|
||
],
|
||
'gengduolist2':[
|
||
{'title':'数据导出','id':'export'},
|
||
],
|
||
//用户搜索条件
|
||
'search':{
|
||
category:[
|
||
|
||
],
|
||
condition:[
|
||
{'title':'等于','id':'0','default':false},
|
||
{'title':'不等于','id':'1','default':false},
|
||
{'title':'包括','id':'2','default':true},
|
||
{'title':'不包括','id':'3','default':false},
|
||
{'title':'有值','id':'4','default':false},
|
||
{'title':'无值','id':'5','default':false},
|
||
{'title':'正则匹配','id':'6','default':false},
|
||
{'title':'正则不匹配','id':'7','default':false},
|
||
],
|
||
condition2:[
|
||
{'title':'等于','id':'0','default':false},
|
||
{'title':'不等于','id':'1','default':false},
|
||
{'title':'小于','id':'2','default':true},
|
||
{'title':'大于','id':'3','default':false},
|
||
{'title':'有值','id':'4','default':false},
|
||
{'title':'无值','id':'5','default':false},
|
||
{'title':'区间','id':'6','default':false}
|
||
],
|
||
condition2:[
|
||
{'title':'等于','id':'=='},
|
||
{'title':'不等于','id':'!='},
|
||
{'title':'小于','id':'<'},
|
||
{'title':'大于','id':'>'},
|
||
{'title':'小于等于','id':'<='},
|
||
{'title':'大于等于','id':'>='},
|
||
{'title':'区间','id':'range'}
|
||
],
|
||
},
|
||
//日期控件参数
|
||
'locale': {
|
||
"format": 'YYYY-MM-DD',
|
||
"separator": " - ",
|
||
"applyLabel": "应用",
|
||
"cancelLabel": "取消",
|
||
"fromLabel": "起始时间",
|
||
"toLabel": "结束时间'",
|
||
"customRangeLabel": "自定义",
|
||
"weekLabel": "W",
|
||
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
|
||
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||
"firstDay": 1
|
||
},
|
||
'timezone':[
|
||
{'title': "UTC+08:00 默认",id:8},
|
||
{'title': "当前时区",id:8},
|
||
{'title': "UTC-12:00",id:12},
|
||
{'title': "UTC-11:00",id:11},
|
||
{'title': "UTC-10:00",id:10},
|
||
{'title': "UTC-09:00",id:9},
|
||
{'title': "UTC-08:00",id:8},
|
||
{'title': "UTC-07:00",id:7},
|
||
{'title': "UTC±00:00",id:0}
|
||
],
|
||
'analysis':{},
|
||
'companylist':{
|
||
'event':[
|
||
{'title':'按天','id':'P1D'},
|
||
{'title':'按分钟','id':'PT1M'},
|
||
{'title':'每五分钟','id':'PT5M'},
|
||
{'title':'每十分钟','id':'PT10M'},
|
||
{'title':'每十五分钟','id':'PT15M'},
|
||
{'title':'按小时','id':'PT1H'},
|
||
// {'title':'按小时段','id':'HOUR'},
|
||
{'title':'按周','id':'P1W'},
|
||
{'title':'按月','id':'P1M'},
|
||
{'title':'合计','id':'total'},
|
||
],
|
||
'retention':[
|
||
{'title':'当日','id':1},
|
||
{'title':'次日','id':2},
|
||
{'title':'7日','id':7},
|
||
{'title':'14日','id':14},
|
||
{'title':'30日','id':30}
|
||
],
|
||
'distribution':[
|
||
{'title':'按天','id':'P1D'},
|
||
{'title':'按周','id':'P1W'},
|
||
{'title':'按月','id':'P1M'},
|
||
{'title':'合计','id':'total'}
|
||
]
|
||
},
|
||
'retentionlist' : [
|
||
{'title':'留存','id':0},
|
||
{'title':'流失','id':1},
|
||
],
|
||
'screenlist':[]
|
||
},
|
||
};
|
||
|
||
|
||
(function(){
|
||
//本地
|
||
// var ipurl = "http://10.0.0.240:7899/api/v1/";
|
||
// 线上
|
||
var ipurl = "http://139.159.159.3:9865/api/v1/";
|
||
//线上测试
|
||
// var ipurl = "http://139.159.159.3:7889/api/v1/";
|
||
|
||
//设置或读取登录缓存,需要保存到localStorage,防止刷新时候登录数据丢失
|
||
X.loginCache = function(data){
|
||
if(data == null){
|
||
var _cache = localStorage.loginData;
|
||
if(_cache){
|
||
return JSON.parse(_cache);
|
||
}else{
|
||
return null;
|
||
}
|
||
}else{
|
||
localStorage.loginData = JSON.stringify(data);
|
||
}
|
||
};
|
||
|
||
//统一API接口调用
|
||
X.api = function(url,type,parms,callback){
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
var contentType;
|
||
if(url.indexOf("login") != -1){
|
||
var data = parms;
|
||
var url = ipurl+url;
|
||
}else {
|
||
var data = {};
|
||
contentType = 'application/json';
|
||
if(parms != 1){
|
||
var data = JSON.stringify(parms);
|
||
}
|
||
if(url == 'data_mana/list'){
|
||
var url = ipurl+url+"?game="+ X.DATA.game+"&"+parms || "";
|
||
}else {
|
||
var url = ipurl+url+"?game="+ X.DATA.game || "";
|
||
}
|
||
}
|
||
var index;
|
||
$.ajax({
|
||
headers: {
|
||
Authorization:token//此处放置请求到的用户token
|
||
},
|
||
url: url,
|
||
type:type,
|
||
data:data,
|
||
async:true,
|
||
contentType: contentType,
|
||
beforeSend: function () {
|
||
// loading 显示
|
||
index = layer.load(1);
|
||
},
|
||
success:function(d){
|
||
layer.close(index);
|
||
|
||
if(d.code == 0){
|
||
if( JSON.stringify(d.data) != "{}" && JSON.stringify(d.data) != "[]"){
|
||
callback && callback(d.data);
|
||
}else {
|
||
layer.msg('查无数据');
|
||
callback && callback(d.data);
|
||
}
|
||
}else {
|
||
if(d.code == -5){
|
||
layer.msg("登录过期请重新登录!!!");
|
||
window.localStorage.removeItem('loginData');
|
||
X.gourl("login");
|
||
location.reload();
|
||
}else if(d.code == -9){
|
||
callback && callback("查无数据");
|
||
}else {
|
||
layer.msg(d.msg);
|
||
}
|
||
}
|
||
|
||
},
|
||
error:function(error){
|
||
layer.msg('数据正在加载中...');
|
||
layer.close(index);
|
||
}
|
||
});
|
||
};
|
||
// 看板单独调用api方法,去除loading效果
|
||
X.modelapi = function(url,type,parms,callback){
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
var contentType;
|
||
if(url.indexOf("login") != -1){
|
||
var data = parms;
|
||
var url = ipurl+url;
|
||
}else {
|
||
var data = {};
|
||
contentType = 'application/json';
|
||
if(parms != 1){
|
||
var data = JSON.stringify(parms);
|
||
}
|
||
if(url == 'data_mana/list'){
|
||
var url = ipurl+url+"?game="+ X.DATA.game+"&"+parms || "";
|
||
}else {
|
||
var url = ipurl+url+"?game="+ X.DATA.game || "";
|
||
}
|
||
}
|
||
$.ajax({
|
||
headers: {
|
||
Authorization:token//此处放置请求到的用户token
|
||
},
|
||
url: url,
|
||
type:type,
|
||
data:data,
|
||
async:true,
|
||
contentType: contentType,
|
||
beforeSend: function () {
|
||
|
||
},
|
||
success:function(d){
|
||
if(d.code == 0){
|
||
if( JSON.stringify(d.data) != "{}" && JSON.stringify(d.data) != "[]"){
|
||
callback && callback(d.data);
|
||
}else {
|
||
// layer.msg('查无数据');
|
||
callback && callback(d.data);
|
||
}
|
||
}else {
|
||
if(d.code == -5){
|
||
layer.msg("登录过期请重新登录!!!");
|
||
window.localStorage.removeItem('loginData');
|
||
X.gourl("login");
|
||
location.reload();
|
||
}else if(d.code == -9){
|
||
|
||
callback && callback("查无数据");
|
||
}else {
|
||
layer.msg(d.msg);
|
||
}
|
||
}
|
||
|
||
},
|
||
error:function(error){
|
||
layer.msg('数据正在加载中...');
|
||
}
|
||
});
|
||
};
|
||
|
||
//提交修改记录
|
||
X.submitrecord = function(content){
|
||
var game = X.game;//项目名
|
||
var name = X.userinfo.name;//账号名
|
||
var date = new Date();
|
||
var y = date.getFullYear();
|
||
var m = date.getMonth()+1;
|
||
var d = date.getDate();
|
||
var h = date.getHours();
|
||
var min = date.getMinutes();
|
||
var s = date.getSeconds();
|
||
var time = y+'年'+(m<10?('0'+m):m)+'月'+(d<10?('0'+d):d)+'日 '+(h<10?('0'+h):h)+':'+(min<10?('0'+min):min)+':'+(s<10?('0'+s):s);//操作时间
|
||
|
||
console.log(name+'在'+time+'修改'+content);
|
||
// X.api(function(){
|
||
|
||
// })
|
||
};
|
||
|
||
X.uploadfile=function(url,id,callback){
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
layui.upload.render({
|
||
elem: id
|
||
, url: ipurl+url+"?game="+ X.DATA.game || ""
|
||
,headers: {
|
||
Authorization:token//此处放置请求到的用户token
|
||
}
|
||
, auto: false
|
||
,accept: 'file' //普通文件
|
||
,exts: 'xls|xlsx' //只允许上传excel文件
|
||
,bindAction: '#test9'
|
||
, choose: function (obj) {
|
||
// console.log(obj);
|
||
}
|
||
, done: function (res) {
|
||
if(res.code == 0 ){
|
||
layer.msg("提交成功");
|
||
callback && callback(res);
|
||
}else {
|
||
layer.msg(res.msg);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
//下载报表
|
||
X.download=function(url, params,name){
|
||
// console.log(url);
|
||
postDownload(url, params,name);
|
||
};
|
||
|
||
async function postDownload(url, params,name) {
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
|
||
var url = ipurl+url+"?game="+ X.DATA.game;
|
||
const request = {
|
||
async: true,
|
||
body: JSON.stringify(params),
|
||
method: 'POST',
|
||
headers: {
|
||
Authorization:token,//此处放置请求到的用户token
|
||
'Content-Type':'application/json',
|
||
},
|
||
}
|
||
|
||
const response = await fetch(url, request);
|
||
|
||
// const filename = response.headers.get('content-disposition').split('=')[1];
|
||
const filename = name+'.xlsx';
|
||
const blob = await response.blob();
|
||
|
||
const link = document.createElement('a')
|
||
link.download = decodeURIComponent(filename)
|
||
link.style.display = 'none'
|
||
link.href = URL.createObjectURL(blob)
|
||
document.body.appendChild(link)
|
||
link.click()
|
||
URL.revokeObjectURL(link.href)
|
||
document.body.removeChild(link)
|
||
};
|
||
|
||
X.template = function(url,id,data,callback){
|
||
$.get('pages/'+ url + '.html',function(content){
|
||
$('#'+id).html(content);
|
||
X.pageLogic[url] && X.pageLogic[url].init && X.pageLogic[url].init(data);
|
||
callback && callback();
|
||
// X.pageLogic[parms.url] && X.pageLogic[parms.url].init && X.pageLogic[parms.url].init( parms );
|
||
});
|
||
};
|
||
|
||
//弹窗
|
||
X.open = function(parms){
|
||
if(parms.url){
|
||
var url = 'pages/'+ parms.url + '.html';
|
||
$.get(url,function(html){
|
||
parms.content = html;
|
||
// openindes是弹出层的标记,方便后面多个弹框对应关闭
|
||
parms.success = function(layero, index){
|
||
parms.layIndex = index;
|
||
X.pageLogic[parms.url] && X.pageLogic[parms.url].init && X.pageLogic[parms.url].init( parms );
|
||
};
|
||
layer.open(parms);
|
||
})
|
||
}else{
|
||
layer.open(parms);
|
||
}
|
||
};
|
||
|
||
//渲染表格无分页无操作
|
||
X.tabledata = function(id,url,data){
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
layui.table.render({
|
||
headers: {
|
||
Authorization: token
|
||
}
|
||
,elem: id
|
||
,url: ipurl+url+"?game="+X.DATA.game
|
||
,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
||
,cols: data
|
||
});
|
||
};
|
||
|
||
//渲染表格有分页有操作
|
||
X.laytabledata = function(id,url,data,arr,height,callback,method){
|
||
var loginCache = X.loginCache();
|
||
var token = (loginCache? loginCache.token:"");
|
||
token = "Bearer "+token;
|
||
var url
|
||
if(arr){
|
||
url = ipurl+url+"?game="+X.DATA.game+arr;
|
||
}else {
|
||
url = ipurl+url+"?game="+X.DATA.game;
|
||
}
|
||
if(!height){
|
||
var height = 'full-20'
|
||
}
|
||
method = method ? method : "get";
|
||
// if(method){
|
||
// method = method;
|
||
// }else{
|
||
// method = 'get';
|
||
// }
|
||
layui.table.render({
|
||
method: method,
|
||
headers: {
|
||
Authorization: token
|
||
}
|
||
,elem: id
|
||
,url: url
|
||
,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
||
,cols: data
|
||
,height: height
|
||
,done: function (res, curr, count) {
|
||
callback && callback(res, curr, count);
|
||
}
|
||
});
|
||
};
|
||
|
||
//渲染模板,模板id,数据,位置id
|
||
X.laytpldata = function (mbid ,data,wzid,callback){
|
||
var getTpl = $(mbid).html()
|
||
layui.laytpl(getTpl).render(data, function(html){
|
||
wzid && $(wzid).html(html);
|
||
layui.element.init(); //重新渲染
|
||
callback && callback(html);
|
||
});
|
||
};
|
||
|
||
//渲染下拉框
|
||
X.laydropdown = function(id,data,callback){
|
||
layui.dropdown.render({
|
||
elem: id
|
||
,data: data
|
||
,click: callback
|
||
});
|
||
};
|
||
|
||
//查询条件弹框 id:位置,data:数据,deviationleft:左偏移量,deviationtop:上偏移量
|
||
X.querycriteriapop = function(data,url,deviationleft, deviationtop, callback){
|
||
var innerHeight = window.innerHeight;
|
||
if(innerHeight - deviationtop < 420){
|
||
deviationtop = deviationtop - 450
|
||
}
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
// shade:,
|
||
shadeClose: true,
|
||
offset: [deviationtop,deviationleft],
|
||
url: url,
|
||
extData : data,
|
||
callback : callback
|
||
});
|
||
};
|
||
|
||
X.parametersopen = function(data,url,offset,callback){
|
||
// var innerHeight = window.innerHeight;
|
||
// if( innerHeight - offset[0] < height){
|
||
// offset[0] = offset[0] - (height + 30);
|
||
// }
|
||
// console.log(offset);
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
offset:offset,
|
||
url: url,
|
||
extData : data,
|
||
callback : callback
|
||
});
|
||
};
|
||
|
||
// 渲染树形菜单
|
||
X.treemenu = function(elem,data,id){
|
||
layui.tree.render({
|
||
elem: elem
|
||
,data: data
|
||
,showCheckbox: true //是否显示复选框
|
||
,id: id
|
||
,isJump: false //是否允许点击节点时弹出新窗口跳转
|
||
|
||
});
|
||
};
|
||
|
||
//渲染穿梭框
|
||
X.laytransfer = function(elem,data,title,id){
|
||
layui.transfer.render({
|
||
elem: elem
|
||
,data: data
|
||
,title: title
|
||
,showSearch: true
|
||
,id: id
|
||
})
|
||
};
|
||
|
||
//获取时间粒度中文名
|
||
X.granularity=function(timeParticleSize,callback){
|
||
if(timeParticleSize == 'P1D'){
|
||
granularity = '按天'
|
||
}else if(timeParticleSize == 'PT1M'){
|
||
granularity = '按分钟'
|
||
}else if(timeParticleSize == 'PT5M'){
|
||
granularity = '每五分钟'
|
||
}else if(timeParticleSize == 'PT10M'){
|
||
granularity = '每十分钟'
|
||
}else if(timeParticleSize == 'PT15M'){
|
||
granularity = '每十五分钟'
|
||
}else if(timeParticleSize == 'PT1H'){
|
||
granularity = '按小时'
|
||
}else if(timeParticleSize == 'P1W'){
|
||
granularity = '按周'
|
||
}else if(timeParticleSize == 'P1M'){
|
||
granularity = '按月'
|
||
}else if(timeParticleSize == 'total'){
|
||
granularity = '合计'
|
||
}else if(timeParticleSize == '1'){
|
||
granularity = '当日'
|
||
}else if(timeParticleSize == '2'){
|
||
granularity = '次日'
|
||
}else if(timeParticleSize == '7'){
|
||
granularity = '7日'
|
||
}else if(timeParticleSize == '14'){
|
||
granularity = '14日'
|
||
}else if(timeParticleSize == '30'){
|
||
granularity = '30日'
|
||
}
|
||
callback && callback(granularity);
|
||
};
|
||
|
||
//根据中文名获取时间粒度id
|
||
X.granularityid=function(timeParticleSize,callback){
|
||
if(timeParticleSize == '按天'){
|
||
granularity = 'P1D'
|
||
}else if(timeParticleSize == '按分钟'){
|
||
granularity = 'PT1M'
|
||
}else if(timeParticleSize == '每五分钟'){
|
||
granularity = 'PT5M'
|
||
}else if(timeParticleSize == '每十分钟'){
|
||
granularity = 'PT10M'
|
||
}else if(timeParticleSize == '每十五分钟'){
|
||
granularity = 'PT15M'
|
||
}else if(timeParticleSize == '按小时'){
|
||
granularity = 'PT1H'
|
||
}else if(timeParticleSize == '按周'){
|
||
granularity = 'P1W'
|
||
}else if(timeParticleSize == '按月'){
|
||
granularity = 'P1M'
|
||
}else if(timeParticleSize == '合计'){
|
||
granularity = 'total'
|
||
}else if(timeParticleSize == '当日'){
|
||
granularity = '1'
|
||
}else if(timeParticleSize == '次日'){
|
||
granularity = '2'
|
||
}else if(timeParticleSize == '7日'){
|
||
granularity = '7'
|
||
}else if(timeParticleSize == '14日'){
|
||
granularity = '14'
|
||
}else if(timeParticleSize == '30日'){
|
||
granularity = '30'
|
||
}
|
||
callback && callback(granularity);
|
||
};
|
||
|
||
|
||
// 分组项取交集
|
||
X.groupintersection=function(c , a , callback){
|
||
var dataArr=[];
|
||
var arr=[];
|
||
for(let i in c){
|
||
|
||
for(let j in a){
|
||
|
||
if(c[i]['id'] == a[j]['id']){
|
||
|
||
for(let z in c[i]['category']){
|
||
|
||
for(let q in a[j]['category']){
|
||
|
||
if(c[i]['category'][z]['title'] == a[j]['category'][q]['title']){
|
||
arr.push(c[i]['category'][z]);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
if(arr.length > 0){
|
||
var data = {
|
||
title: c[i]['title'],
|
||
id:c[i]['id'],
|
||
category:arr
|
||
};
|
||
dataArr.push(data);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
//分页
|
||
X.layuipages = function(id,count,callback){//绑定id,数据总数
|
||
layui.laypage.render({
|
||
elem: id
|
||
,count: count //数据总数
|
||
,limit: 18 //每页显示数
|
||
,jump:callback
|
||
});
|
||
};
|
||
|
||
// 日期选择器
|
||
X.daterender = function(id,callback){
|
||
// console.log(moment().subtract(1, 'week').startOf('week'))
|
||
$(id).daterangepicker({
|
||
'locale': X.DATA.locale,
|
||
ranges: {
|
||
'今日': [moment(), moment()],
|
||
'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||
'最近7日': [moment().subtract(7, 'days'), moment().subtract(0, 'days')],
|
||
'最近30日': [moment().subtract(30, 'days'), moment().subtract(0, 'days')],
|
||
'上周': [moment().subtract(1, 'week').startOf('week')+86400000, moment().subtract(1, 'week').endOf('week')+86400000],
|
||
'本周': [moment().startOf('week')+86400000, moment()+86400000],
|
||
'本月': [moment().startOf('month'), moment()],
|
||
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
|
||
'全部时间': [moment().subtract( parseInt((new Date).getTime()/86400000) , 'days'), moment()]
|
||
},
|
||
"alwaysShowCalendars": true,
|
||
"startDate": moment().subtract(6, 'days'),
|
||
"endDate": new Date(),
|
||
"opens": "right",
|
||
|
||
}, function (start, end, label) {
|
||
callback && callback(start,end,label);
|
||
// console.log(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')) ;
|
||
});
|
||
};
|
||
|
||
X.updatatime = function(id){
|
||
var myDate = new Date;
|
||
var year = myDate.getFullYear(); //获取当前年
|
||
var mon = myDate.getMonth() + 1; //获取当前月
|
||
var date = myDate.getDate(); //获取当前日
|
||
var h = myDate.getHours();//获取当前小时数(0-23)
|
||
var m = myDate.getMinutes();//获取当前分钟数(0-59)
|
||
var s = myDate.getSeconds();//获取当前秒
|
||
var week = myDate.getDay();
|
||
var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
||
var time = year + "-" + mon + "-" + date + " " + h+":"+m+":"+s
|
||
// console.log(year + "-" + mon + "-" + date + " " + h+":"+m+":"+s);
|
||
$(id).attr('title',"最新更新时间:"+time);
|
||
};
|
||
|
||
//多选下拉框
|
||
// X.select = function(){
|
||
|
||
// };
|
||
|
||
//多选标签-基本配置
|
||
X.selectM = function(id,data,width,callback){
|
||
layui.selectM({
|
||
//元素容器【必填】
|
||
elem: id
|
||
//候选数据【必填】
|
||
,data: data
|
||
,width: width
|
||
,max: 100
|
||
//添加验证
|
||
,verify:'required',
|
||
callback:callback
|
||
});
|
||
};
|
||
|
||
X.layuidate=function(id){
|
||
layui.laydate.render({
|
||
elem: id
|
||
,type: 'datetime'
|
||
,range: true
|
||
});
|
||
};
|
||
|
||
//定义一个比较器--升序排列
|
||
X.compare=function(propertyName) {
|
||
return function(object1, object2) {
|
||
var value1 = object1[propertyName];
|
||
var value2 = object2[propertyName];
|
||
if(value2 < value1) {
|
||
return 1;
|
||
} else if(value2 > value1) {
|
||
return -1;
|
||
} else {
|
||
return 0;
|
||
}
|
||
}
|
||
};
|
||
|
||
// table
|
||
X.fixedTable=function(id,type,classname,headdata,dataarr,cat){
|
||
var fixedTable = new FixedTable({
|
||
wrap: document.getElementById(id),//生成的表格需要放到哪里
|
||
type: type,//表格类型,有:head-fixed、col-fixed、row-col-fixed
|
||
extraClass: classname,//需要添加到表格中的额外class
|
||
maxHeight: true,
|
||
fields: headdata,
|
||
// [//表格的列
|
||
// {
|
||
// width: "150px",
|
||
// field: "日期",
|
||
// fixed: true
|
||
// },
|
||
// {
|
||
// width: "120px",
|
||
// field: "姓名",
|
||
// fixed: true
|
||
// },
|
||
// {
|
||
// width: "120px",
|
||
// field: "省份",
|
||
// //fixed: true,
|
||
|
||
// },
|
||
// {
|
||
// width: "120px",
|
||
// field: "市区"
|
||
// },
|
||
// {
|
||
// width: "300px",
|
||
// field: "地址",
|
||
// // fixed: true,
|
||
|
||
// },
|
||
// {
|
||
// width: "120px",
|
||
// field: "邮编",
|
||
|
||
// },
|
||
// {
|
||
// width: "100px",
|
||
// field: "操作",
|
||
// fixed: true,
|
||
// fixedDirection: "right"
|
||
// }
|
||
// ],
|
||
tableDefaultContent: "<div>我是一个默认的div</div>"
|
||
});
|
||
|
||
fixedTable.addRow(function (){
|
||
var html = '';
|
||
if(cat == 'event' || cat == "ltv"){
|
||
for(let i in dataarr){
|
||
html += '<tr>';
|
||
for(let j in dataarr[i]){
|
||
html += '<td class="ws-150"><div class="table-cell">'+ dataarr[i][j] +'</div></td>';
|
||
}
|
||
html += '</tr>';
|
||
}
|
||
}else if(cat == "retention" || cat == "scatter"){
|
||
|
||
for(let i in dataarr){
|
||
html += '<tr>';
|
||
html += '<td class="ws-150"><div class="table-cell">'+ dataarr[i]['date'] +'</div></td>';
|
||
html += '<td class="ws-150"><div class="table-cell">'+ dataarr[i]['d0'] +'</div></td>';
|
||
for(let j in dataarr[i]['data']){
|
||
// for(let z in dataarr[i]['data'][j]){
|
||
html += '<td class="ws-150"><div class="table-cell">'+ dataarr[i]['data'][j]['n'] +'</div><div class="table-cell">'+ dataarr[i]['data'][j]['p'] +'</div></td>';
|
||
// }
|
||
}
|
||
html += '</tr>';
|
||
}
|
||
|
||
}else if(cat == "user_property"){
|
||
for(let i in dataarr){
|
||
html += '<tr>';
|
||
html += '<td class="ws-150"><div class="table-cell">'+ i +'</div></td>';
|
||
html += '<td class="ws-150"><div class="table-cell">'+ dataarr[i] +'</div></td>';
|
||
html += '</tr>';
|
||
}
|
||
}
|
||
|
||
return html;
|
||
});
|
||
};
|
||
|
||
X.eventtable=function(data,callback){
|
||
var titledata,date,condata = [];
|
||
for(let i in data){
|
||
if(data[i]['values'].length > 0 ){
|
||
titledata= $.extend(true,[],data[0]['date_range']);
|
||
|
||
// ,'阶段总和'
|
||
if(data[i]['groups']['length'] != 0){
|
||
titledata.unshift('指标','分组');
|
||
for(let j in data[i]['values']){
|
||
var arr;
|
||
arr = $.extend(true,[],data[i].values[j])
|
||
arr.unshift(data[i]['event_name'],data[i]['groups'][j]);
|
||
// ,data[i]['sum'][j]
|
||
condata.push(arr);
|
||
}
|
||
// for(let j in condata){
|
||
// condata[j].splice(1,0,data[i]['groups'][j]);
|
||
// }
|
||
|
||
}else {
|
||
titledata.unshift('指标');
|
||
var arr;
|
||
arr = $.extend(true,[],data[i].values[0])
|
||
arr.unshift(data[i]['event_name']);
|
||
// ,data[i]['sum'][0]
|
||
condata.push(arr)
|
||
}
|
||
}else {
|
||
layer.msg('查询数据为空');
|
||
}
|
||
}
|
||
date = data[0]['start_date'] + " - " + data[0]['end_date'];
|
||
|
||
var dataArr = {
|
||
titledata:titledata,
|
||
condata:condata,
|
||
date:date
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.eventchart = function(data,callback){
|
||
var legenddata=[];
|
||
var legendnamearr = [];
|
||
for(let i in data){
|
||
legendnamearr.push(data[i]['event_name'])
|
||
if(data[i]['groups'].length > 0){
|
||
for(let z in data[i]['groups']){
|
||
var pj = data[i]['event_name']+data[i]['groups'][z];
|
||
legenddata.push(pj);
|
||
}
|
||
}else {
|
||
var pj = data[i]['event_name'];
|
||
legenddata.push(pj);
|
||
}
|
||
}
|
||
var seriesData=[];
|
||
var sum = -1;
|
||
var mean = -1;
|
||
var sameday = 0;
|
||
var date;
|
||
var wowtype='',chain_ratiotype='';//判断较环比和较同比的正负
|
||
var selected = {};//线多的话默认显示5条
|
||
|
||
date = data[0]['start_date'] + " - " + data[0]['end_date'];
|
||
// console.log(date);
|
||
for(let i in data){
|
||
for(let z in data[i]['values']){
|
||
var arr = {
|
||
name: '',
|
||
type: 'line',
|
||
data: data[i]['values'][z]
|
||
}
|
||
seriesData.push(arr);
|
||
sameday = data[0]['last_value'];
|
||
|
||
}
|
||
}
|
||
|
||
//只在单个指标分析中显示总价和均值
|
||
if(data.length == 1){
|
||
sum = data[0]['sum'][0];
|
||
mean = data[0]['avg'][0];
|
||
}
|
||
|
||
if(legenddata.length > 0){
|
||
for(let i in seriesData){
|
||
seriesData[i]['name'] = legenddata[i];
|
||
}
|
||
}
|
||
|
||
if(legenddata.length > 5){
|
||
for(let i in legenddata){
|
||
if(i < 5){
|
||
selected[legenddata[i]] = true;
|
||
}else {
|
||
selected[legenddata[i]] = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
if(data[0]['wow']){
|
||
if(data[0]['wow'] >= 0){
|
||
wowtype = '+'
|
||
}else{
|
||
wowtype = '-'
|
||
}
|
||
}
|
||
|
||
if(data[0]['chain_ratio']){
|
||
if(data[0]['chain_ratio'] >= 0){
|
||
chain_ratiotype = '+'
|
||
}else{
|
||
chain_ratiotype = '-'
|
||
}
|
||
}
|
||
|
||
var dataArr = {
|
||
xAxisData:data[0]['date_range'],
|
||
legenddata:legenddata,
|
||
seriesData:seriesData,
|
||
legendnamearr:legendnamearr,
|
||
selected:selected,
|
||
date:date,
|
||
sum:sum,
|
||
mean:mean,
|
||
sameday: sameday,
|
||
wowtype:wowtype,
|
||
wow: Math.abs(data[0]['wow']),//同比
|
||
chain_ratio: Math.abs(data[0]['chain_ratio']),//环比
|
||
chain_ratiotype:chain_ratiotype,
|
||
proid_money: data[0]['proid_money'],
|
||
proid_name: data[0]['proid_name']
|
||
}
|
||
console.log(dataArr);
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.eventsmall = function(data,callback){
|
||
var date,num,wowtype="",chain_ratiotype=""; //时间,当天数量
|
||
// console.log(data);
|
||
// for(let i in data){
|
||
// if(data[i]['groups']['length'] == 0){
|
||
|
||
|
||
// }
|
||
// }
|
||
var length = data[0]['date_range'].length - 1;
|
||
date = data[0]['date_range'][length];
|
||
num = data[0]['values'][0][length];
|
||
if(data[0]['wow']){
|
||
if(data[0]['wow'] >= 0){
|
||
wowtype = '+'
|
||
}else{
|
||
wowtype = '-'
|
||
}
|
||
}
|
||
|
||
if(data[0]['chain_ratio']){
|
||
if(data[0]['chain_ratio'] >= 0){
|
||
chain_ratiotype = '+'
|
||
}else{
|
||
chain_ratiotype = '-'
|
||
}
|
||
}
|
||
|
||
var dataArr = {
|
||
date: date,
|
||
num: num,
|
||
wowtype: wowtype,
|
||
chain_ratiotype: chain_ratiotype
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.retentiontable=function(data,callback){
|
||
var nname,pname
|
||
if(data.retentiontype == 0) {
|
||
nname = 'n';
|
||
pname = 'p';
|
||
}else {
|
||
nname = 'n_outflow';
|
||
pname = 'p_outflow';
|
||
}
|
||
|
||
// if(data['filter_item_type'] != "all" && data['filter_item_type'] != "" && data['filter_item_type']){
|
||
// var filteritem = data['filter_item'];
|
||
// if(data['days'].length >= 0){
|
||
// var filterarr = [];
|
||
// for(let i in data['days']){
|
||
// for(let j in filteritem){
|
||
// if(data['days'][i] == filteritem[j]){
|
||
// filterarr.push(i);
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
var tabledata=[];
|
||
for(let i in data['summary_values']){
|
||
var arr = {
|
||
date: i,
|
||
d0:data['summary_values'][i]['d0'],
|
||
data:[]
|
||
}
|
||
for(let j in data['summary_values'][i][nname]){
|
||
var nrr = {
|
||
n:0,
|
||
p:0
|
||
}
|
||
// if(data['filter_item_type'] != "all" && data['filter_item_type'] != "" && data['filter_item_type']){
|
||
// for(let a in filterarr){
|
||
// var index = Number(filterarr[a]);
|
||
// if(j == index){
|
||
// nrr["n"] = data['summary_values'][i][nname][j];
|
||
// nrr["p"] = data['summary_values'][i][pname][j]
|
||
// arr['data'].push(nrr);
|
||
// }
|
||
// }
|
||
// }else {
|
||
nrr["n"] = data['summary_values'][i][nname][j];
|
||
nrr["p"] = data['summary_values'][i][pname][j]
|
||
arr['data'].push(nrr);
|
||
// }
|
||
// nrr["n"] = data['summary_values'][i][nname][j];
|
||
// nrr["p"] = data['summary_values'][i][pname][j]
|
||
// arr['data'].push(nrr);
|
||
}
|
||
tabledata.push(arr);
|
||
}
|
||
|
||
// var titdata = [];
|
||
// for(let i in data['days']){
|
||
// var tit = "第" + i + "日";
|
||
// titdata.push(tit);
|
||
// }
|
||
// if(data['filter_item_type'] != "all" && data['filter_item_type'] != "" && data['filter_item_type']){
|
||
// var titarr = [];
|
||
// for(let j in filterarr){
|
||
// var index = Number(filterarr[j]);
|
||
// titarr.push(data['days'][index]);
|
||
// }
|
||
// for(let i in titarr){
|
||
// var tit = "第" + titarr[i] + "日";
|
||
// titdata.push(tit);
|
||
// }
|
||
// }else {
|
||
// for(let i in data['days']){
|
||
// var tit = "第" + data['days'][i] + "日";
|
||
// titdata.push(tit);
|
||
// }
|
||
// }
|
||
// titdata.unshift("日期",data.title);
|
||
var date = data['start_date'] + " - " + data['end_date'];
|
||
var dataArr = {
|
||
titledata: data.title,
|
||
condata:tabledata,
|
||
retentiontype:data.retentiontype,
|
||
date:date
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.retentionchart = function(d,callback){
|
||
var nname,pname,wowtype="",chain_ratiotype="";
|
||
if(d.retentiontype == 0) {
|
||
nname = 'n';
|
||
pname = 'p';
|
||
}else {
|
||
nname = 'n_outflow';
|
||
pname = 'p_outflow';
|
||
}
|
||
var arr = {};
|
||
var legenddata = [];
|
||
var seriesData = [];
|
||
var xAxisData = [];
|
||
var date,sum=0,mean=0,sameday=0;
|
||
date = d['start_date'] + " - " + d['end_date'];
|
||
if(jQuery.isEmptyObject(d.values)){
|
||
var arr = []
|
||
for(let i in d['summary_values']){
|
||
var index = d['summary_values'][i][pname].length - 1;
|
||
legenddata.push(i);
|
||
arr.push(d['summary_values'][i][pname]);
|
||
}
|
||
d.title.splice(0,1);
|
||
xAxisData = d.title;
|
||
for(let i in arr){
|
||
var drr = {
|
||
name: d.date_range[i],
|
||
type: 'line',
|
||
data: arr[i]
|
||
}
|
||
seriesData.push(drr);
|
||
}
|
||
// for(let i in arr){
|
||
// if(arr[i] != "-"){
|
||
// sum = sum + 0;
|
||
// }
|
||
// sameday = arr[i];
|
||
// }
|
||
// mean = (sum / arr.length).toFixed(2);
|
||
|
||
}else {
|
||
var timearr = [];
|
||
for(let i in d.values){
|
||
timearr.push(i);
|
||
for(let j in d.values[i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d.values[i][j][pname];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d.values[i][j][pname];
|
||
}
|
||
}
|
||
}
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in timearr ){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(timearr[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for(let i in ydata){
|
||
legenddata.push(i);
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr)
|
||
}
|
||
|
||
}
|
||
|
||
if(d['wow']){
|
||
if(d['wow'] >= 0){
|
||
wowtype = '+'
|
||
}else{
|
||
wowtype = '-'
|
||
}
|
||
}
|
||
|
||
if(d['chain_ratio']){
|
||
if(d['chain_ratio'] >= 0){
|
||
chain_ratiotype = '+'
|
||
}else{
|
||
chain_ratiotype = '-'
|
||
}
|
||
}
|
||
|
||
var selected = {};//线多的话默认显示5条
|
||
if(legenddata.length > 5){
|
||
for(let i in legenddata){
|
||
if(i < 5){
|
||
selected[legenddata[i]] = true;
|
||
}else {
|
||
selected[legenddata[i]] = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
var dataArr = {
|
||
xAxisData:xAxisData,
|
||
legenddata:legenddata,
|
||
seriesData:seriesData,
|
||
selected:selected,
|
||
date:date,
|
||
sum:sum.toFixed(2),
|
||
mean:mean,
|
||
sameday: 0,
|
||
wowtype:wowtype,
|
||
chain_ratiotype:chain_ratiotype,
|
||
retentiontype:d.retentiontype
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.ltvtable=function(data,callback){
|
||
var date = data['start_date'] + " - " + data['end_date'];
|
||
var dataArr = {
|
||
titledata:data.title,
|
||
condata:data.rows,
|
||
date:date
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.userpropertytable=function(data,callback){
|
||
var dataArr = {
|
||
titledata:data.title,
|
||
condata:data.value
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.userpropertychart=function(data,callback){
|
||
var xAxisData = [];
|
||
var seriesdata =[];
|
||
var legenddata = [];
|
||
var date,sum,mean,sameday;
|
||
for(let i in data.value){
|
||
xAxisData.push(i);
|
||
seriesdata.push(data.value[i]);
|
||
}
|
||
var dataArr = {
|
||
xAxisData:xAxisData,
|
||
legenddata:legenddata,
|
||
seriesData:seriesdata,
|
||
date:0,
|
||
sum:0,
|
||
mean:0,
|
||
sameday: 0
|
||
}
|
||
// console.log(xAxisData);
|
||
// console.log(seriesdata);
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.scattertable=function(data,callback){
|
||
var tabledata = [];
|
||
for(let i in data.list){
|
||
var arr = {
|
||
date: i,
|
||
d0: data['list'][i]['总体']["total"],
|
||
data:[]
|
||
}
|
||
for(let j in data['list'][i]['总体']["n"]){
|
||
var nrr = {
|
||
n:0,
|
||
p:0
|
||
}
|
||
nrr["n"] = data['list'][i]['总体']["n"][j];
|
||
nrr["p"] = data['list'][i]['总体']["p"][j]
|
||
arr['data'].push(nrr);
|
||
}
|
||
tabledata.push(arr)
|
||
}
|
||
data['tabletitle'] = $.extend(true,[],data['label']);
|
||
data['tabletitle'].unshift('事件发生时间','总人数');
|
||
var date = data['start_date'] + " - " + data['end_date'];
|
||
var dataArr = {
|
||
titledata: data.tabletitle,
|
||
condata:tabledata,
|
||
date:date
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
X.scatterchart=function(data,callback){
|
||
|
||
var legendData = data.label;
|
||
var xAxisData = [];
|
||
var seriesData = [];
|
||
var arr =[];
|
||
for(let i in data['list']){
|
||
xAxisData.push(i);
|
||
for(let j in data['list'][i]){
|
||
if(arr[j]){
|
||
arr[j][i] = data['list'][i][j]['n'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = data['list'][i][j]['n'];
|
||
}
|
||
}
|
||
}
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in xAxisData){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(xAxisData[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for(let i in ydata){
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
var date = data['start_date'] + " - " + data['end_date'];
|
||
var dataArr = {
|
||
xAxisData:xAxisData,
|
||
legenddata:legendData,
|
||
seriesData:seriesData,
|
||
date:date,
|
||
}
|
||
callback && callback(dataArr);
|
||
};
|
||
|
||
|
||
// 分组项
|
||
// X.grouped=function(data,id){
|
||
// console.log(data)
|
||
// var html
|
||
// for(let i in data){
|
||
// html = html + `
|
||
// <div class="analysis-action-row">
|
||
// <div class="analysis-action-left">
|
||
// <div class="analysis-num bgcolor">` + i+1 + `</div>
|
||
// <div class="analysis-ant-dropdown-trigger">
|
||
// <img src="./static/img/shaix2.png"/>
|
||
// <span>` + data[i]['column_name'] + `</span>
|
||
// </div>
|
||
// </div>
|
||
|
||
// <div class="analysis-ta-property-range analysis-granularity"> <img src="./static/img/shezhi2.png"> </div>
|
||
|
||
// <div class="analysis-ta-property-range analysis-section"> <img src="./static/img/shezhi2.png"> </div>
|
||
// <div class="analysis-action-right"> <img src="./static/img/cha1.png"/> </div>
|
||
// </div>
|
||
// `
|
||
// }
|
||
// $(id).html(html);
|
||
// }
|
||
|
||
// function ScreenClick(id){
|
||
// $("#zhuanghu_xila").hide();
|
||
// $("#zhuanghu_xila").empty();
|
||
// var judge_boxtxt = $('#judge_box').val();
|
||
// var data ={};
|
||
// for(let i in ScreenArr){
|
||
// for(let j in ScreenArr[i]['Category']){
|
||
// if(ScreenArr[i]['Category'][j]['id'] == id){
|
||
// data = ScreenArr[i]['Category'][j];
|
||
// break;
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
// if(data['type'] == 'time'){
|
||
// $(".judge_box").hide();
|
||
// $(".search_txt").hide();
|
||
// $(".time-box").show();
|
||
// }else {
|
||
// $(".judge_box").show();
|
||
// if(judge_boxtxt == 4 || judge_boxtxt == 5){
|
||
// $("#judge_input").val('');
|
||
// $("#judge_input").hide();
|
||
// }else {
|
||
// $(".search_txt").show();
|
||
// }
|
||
// $(".time-box").hide();
|
||
// }
|
||
// $("#zhanghu_box span").html(data['title']);
|
||
// $("#zhanghu_box").attr('title',data['title']);
|
||
// $(".Screen").hide();
|
||
// $(".Screen").empty();
|
||
// }
|
||
|
||
|
||
|
||
})();
|
||
|
||
// srczip/base/ajaxpage.js
|
||
//(function(){
|
||
function getHashParms(){
|
||
//获取hash数据,处理为字典,方便拼接多个hash值
|
||
var hash = location.hash.replace('#','');
|
||
var res = {};
|
||
if(hash){
|
||
var hashArr = hash.split('&');
|
||
for(var i=0;i<hashArr.length;i++){
|
||
var kv = hashArr[i].split('=');
|
||
res[kv[0]] = kv[1];
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
|
||
function setHashParms(k,v,type){
|
||
//设置一个hash值
|
||
var hash = [];
|
||
var kv = getHashParms();
|
||
kv[k] = v;
|
||
for(var k in kv){
|
||
hash.push( k+'='+kv[k] );
|
||
}
|
||
location.hash = hash.join('&');
|
||
}
|
||
|
||
function setContentByUrl(url,id,fillTo){
|
||
//通过url设置内容页,本质上就是一个ajax请求+填充
|
||
if(!id){
|
||
if(!fillTo)fillTo=$('#main-content');
|
||
}else {
|
||
if(!fillTo)fillTo=$('#'+id);
|
||
}
|
||
X.DATA['page'] = url;
|
||
// console.log(url);
|
||
$.get('pages/'+ url + '.html',function(content){
|
||
// fillTo.empty();
|
||
fillTo.html(content);
|
||
X.event.emit('pageOnLoad',url);
|
||
X.pageLogic[url] && X.pageLogic[url].init && X.pageLogic[url].init();
|
||
});
|
||
}
|
||
|
||
X.gourl = function(url,id){
|
||
if(url || id){
|
||
setHashParms('page',url);
|
||
setContentByUrl(url,id);
|
||
}
|
||
X.DATA['eventid'] = "";
|
||
X.DATA['ltvid'] = "";
|
||
X.DATA['retentionid'] = "";
|
||
};
|
||
|
||
|
||
$(function(){
|
||
//拦截所有class里有ajax-content的链接,由直接跳转修改为ajax跳转
|
||
$('body').on("click",".ajax-content",function(){
|
||
var href = $(this).attr('href');
|
||
var id = $(this).attr('data-id');
|
||
X.gourl(href,id);
|
||
return false;
|
||
});
|
||
//设置主页,如果hash里有值的话,设置为hash的值,方便复制url传播
|
||
var hash = getHashParms();
|
||
setContentByUrl(hash.page || 'login');
|
||
|
||
var n = window.event.screenX - window.screenLeft;
|
||
var b = n > document.documentElement.scrollWidth-20;
|
||
if(b && window.event.clientY < 0 || window.event.altKey){
|
||
//页面关闭
|
||
// console.log('页面关闭');
|
||
}else{
|
||
//页面刷新
|
||
// console.log('页面刷新111');
|
||
var query = window.location.href;
|
||
var querys = query.split("=");
|
||
if(querys[1] != undefined && querys[1] != 'login'){
|
||
$("#conetnt").html("");
|
||
X.gourl('dashboard');
|
||
}
|
||
}
|
||
|
||
// $(document).keydown(function (event) {
|
||
// if (event.keyCode == 116) {
|
||
// event.preventDefault(); //阻止默认刷新
|
||
// console.log('刷新');
|
||
// var query = window.location.href;
|
||
// var querys = query.split("=");
|
||
// if(querys[1]){
|
||
// $("#conetnt").html("");
|
||
// var gourl = querys[1];
|
||
// X.gourl(gourl,'conetnt');
|
||
// }
|
||
// return false;
|
||
// }
|
||
// });
|
||
|
||
});
|
||
|
||
window.onhashchange = function(){
|
||
// console.log( getHashParms() );
|
||
var page = X.DATA['page'];
|
||
var urlinfo = getHashParms();
|
||
if(urlinfo.page == 'dashboard'){
|
||
for(let i in X.DATA['ProjectData']){
|
||
for(let j in X.DATA['ProjectData'][i]['children']){
|
||
if(X.DATA['ProjectData'][i]['children'][j]['_id'] == urlinfo.menu){
|
||
$(".tab-tit-box .tab-tit").html(X.DATA['ProjectData'][i]['children'][j]['name']);
|
||
X.DATA['ProjectData'][i]['children'][j]['onclick'] = 1;
|
||
}else{
|
||
X.DATA['ProjectData'][i]['children'][j]['onclick'] = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
X.laytpldata('#kongjian-dot',X.DATA['ProjectData'],'#kongjian',function(){
|
||
// X.pageLogic.dashboard.sidebarslide();
|
||
var sidebar = document.getElementById('sidebar-boxhuadong');
|
||
new Sortable(sidebar, {
|
||
handle: '.tuodong', // handle class
|
||
animation: 150,
|
||
onUpdate:function(evt){
|
||
// console.log(evt);
|
||
var newIndex = evt.newIndex;
|
||
var oldIndex = evt.oldIndex;
|
||
var kbid = evt.item.attributes[3]['nodeValue'];
|
||
var index = 0;
|
||
for(let i in X.DATA['ProjectData']){
|
||
if(kbid == X.DATA['ProjectData'][i]['_id']){
|
||
index = i;
|
||
for(let j in X.DATA['ProjectData'][i]['children']){
|
||
if(j > newIndex){
|
||
X.DATA['ProjectData'][i]['children'][j]['sort'] = Number(X.DATA['ProjectData'][i]['children'][j]['sort']) + Number(1);
|
||
}else if(j == newIndex){
|
||
X.DATA['ProjectData'][i]['children'][j]['sort'] = Number(X.DATA['ProjectData'][i]['children'][j]['sort']) - Number(1);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
X.DATA['ProjectData'][index]['children'][oldIndex]['sort'] = newIndex;
|
||
var sortarr = [];
|
||
for(let q in X.DATA['ProjectData'][index]['children']){
|
||
var arr = {
|
||
name: X.DATA['ProjectData'][index]['children'][q]['name'],
|
||
dashboard_id: X.DATA['ProjectData'][index]['children'][q]['_id'],
|
||
sort: X.DATA['ProjectData'][index]['children'][q]['sort']
|
||
}
|
||
sortarr.push(arr);
|
||
}
|
||
X.api('dashboard/sort','post',{sort:sortarr},function(d){
|
||
if(d == 1){
|
||
X.pageLogic.dashboard.freshMenu(X.DATA['projectid']);
|
||
}
|
||
})
|
||
}
|
||
});
|
||
|
||
});
|
||
X.DATA['page'] = urlinfo.page;
|
||
// console.log(urlinfo.page);
|
||
// console.log(urlinfo.menu);
|
||
if(page != urlinfo.page){
|
||
X.gourl(urlinfo.page,'conetnt');
|
||
}
|
||
X.DATA['dashboard_id'] = urlinfo.menu;
|
||
X.pageLogic['dashboard'].gettabledata();
|
||
}
|
||
};
|
||
|
||
//})();
|
||
// srczip/base/visibleChange.js
|
||
(function(){
|
||
X.pageLogic['visibleChange'] = {
|
||
init : function(parms){
|
||
var observer = new IntersectionObserver(function(changes){
|
||
changes.forEach(function(item,index){
|
||
var callback = $(item.target).data('_visibleChangeCall');
|
||
if(item.intersectionRatio > 0){
|
||
//target:被观察的目标元素,是一个 DOM 节点对象
|
||
callback && callback.call( item.target,1);
|
||
}else{
|
||
callback && callback.call( item.target,0);
|
||
}
|
||
});
|
||
});
|
||
|
||
$.fn.visibleChange = function(callback) {
|
||
this.each(function(){
|
||
$(this).data('_visibleChangeCall',callback);
|
||
observer.observe( this );
|
||
});
|
||
return this;
|
||
};
|
||
|
||
$('.layui-col').visibleChange(function(isShow){
|
||
if(isShow==1){
|
||
//被看见了
|
||
}else{
|
||
//看不见了
|
||
}
|
||
});
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/3rmodel.js
|
||
(function(){
|
||
X.pageLogic['3rmodel'] = {
|
||
init : function(){
|
||
var me = this;
|
||
// 渲染form样式
|
||
layui.form.render();
|
||
|
||
var dataArr; //分析指标
|
||
var groupeddata;//分组项
|
||
var type2data;
|
||
//var filtersymbols=[];//筛选符号
|
||
// filtersymbols.push(drr);
|
||
var defaultgroupdata; //默认添加分组项里的事件
|
||
var filter_map,quotas_map;
|
||
var data = {
|
||
"events":[],
|
||
"eventView":{
|
||
"cksql":"event",
|
||
"startTime":"",
|
||
"timeParticleSize":"P1D",
|
||
"endTime":"",
|
||
"graphShape":"L0",
|
||
"e_days":0,
|
||
"s_days":7,
|
||
"groupBy":[],
|
||
"uiCommonConfig":{
|
||
"tableSorts":[],
|
||
"chartSort":"num-desc"
|
||
},
|
||
"filts":[],//全局筛选
|
||
"relation":'and',
|
||
"zone_time":'8',//时区
|
||
'min_r': 1,
|
||
'middle_r':1
|
||
}
|
||
}
|
||
|
||
var retdata,props;
|
||
|
||
// 日期渲染
|
||
X.daterender("#analtsis-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
// calculationdata();
|
||
})
|
||
|
||
var time = $("#analtsis-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
// X.template("toptab","analysis-zhanwei",X.DATA['projectarr'],function(){
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
|
||
dataArr = d;
|
||
X.api("data_auth/load_prop_quotas","post",{event_name:dataArr[0]['category'][0]['event_name']},function(d){
|
||
retdata = d.staid_quots.concat(d.props);
|
||
props = d.props;
|
||
var defaultindicator = {
|
||
"event_desc":dataArr[0]['category'][0]['event_desc'],
|
||
"event_name":dataArr[0]['category'][0]['event_name'],
|
||
"event_attr":"总次数",
|
||
"event_attr_id":"*",
|
||
"event_attr_type":"",
|
||
"analysisname":'',
|
||
"analysis":'total_count',
|
||
"filts":[],//过滤项
|
||
"relation":'and',
|
||
"customEvent":'',
|
||
"eventNameDisplay":'',//重命名指标
|
||
"format":'float',
|
||
"formatname":'两位小数'
|
||
}
|
||
data.events.push(defaultindicator);
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
type2data= retdata
|
||
X.api("data_auth/load_filter_props","post",{event_name:dataArr[0]['category'][0]['event_name']},function(val){
|
||
defaultgroupdata = val;
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.eventid && X.DATA.eventid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.eventid);
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
})
|
||
})
|
||
// groupeddata = d.group_by;
|
||
})
|
||
// });
|
||
|
||
|
||
// 渲染选择时间下拉框
|
||
layui.dropdown.render({
|
||
elem: ".analysis-navigation-bar-datetime"
|
||
,data: X.DATA.timezone
|
||
,click: function(obj){
|
||
$(".analysis-navigation-bar-datetime").html(obj.title);
|
||
data['eventView']['zone_time'] = obj.id;
|
||
}
|
||
});
|
||
|
||
// 伸缩左侧选项
|
||
$(".analysis-con-left-shrink").click(function(){
|
||
if($(".analysis-con-left").css('left') == "auto" || $(".analysis-con-left").css('left') == "0px"){
|
||
$(".analysis-con-left").css("position","absolute");
|
||
$(".analysis-con-left").css("left","-535px");
|
||
$(".analysis-con-left-shrink").css("transform","rotate(180deg)");
|
||
$(".analysis-con-right").css("width","calc(100% - 15px)");
|
||
$(".analysis-con-right").css("margin-left","16px");
|
||
}else {
|
||
$(".analysis-con-left").css("position","relative");
|
||
$(".analysis-con-left").css("left","auto");
|
||
$(".analysis-con-left-shrink").css("transform","rotate(3600deg)");
|
||
$(".analysis-con-right").css("width","calc(100% - 550px)");
|
||
$(".analysis-con-right").css("margin-left","0px");
|
||
}
|
||
});
|
||
|
||
//已存报表
|
||
var baobiaodata;
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
if(d){
|
||
backfilldata(d)
|
||
}
|
||
})
|
||
});
|
||
|
||
// 反向填充数据
|
||
function backfilldata(d){
|
||
|
||
data = d.query;
|
||
// filtersymbols = data.cachedata.filtersymbols;
|
||
var time = $("#analtsis-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
baobiaodata = d;
|
||
|
||
if(d.query.eventView.filts.length > 0){
|
||
$(".analysis-overall").show();
|
||
}else {
|
||
$(".analysis-overall").hide();
|
||
}
|
||
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",d.query.events,".analysis-con-left-screen-list-box");
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",d.query.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",d.query['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
calculationdata();
|
||
}
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 切换为指标公式或组合
|
||
$(document).off('click','.analysis-gongshi').on('click','.analysis-gongshi',function(){
|
||
var index = $(this).attr("data-index");
|
||
var type = $(this).attr("data-type");
|
||
data['events'][index]['customType'] = type;
|
||
$("#analysis-con-left-screen-list-left-box-"+index).hide();
|
||
$("#analysis-custom-box-"+index).show();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-zhibiao").show();
|
||
});
|
||
|
||
// 切换为指标选择
|
||
$(document).off('click','.analysis-zhibiao').on('click','.analysis-zhibiao',function(){
|
||
var index = $(this).attr("data-index");
|
||
$("#analysis-con-left-screen-list-left-box-"+index).show();
|
||
$("#analysis-custom-box-"+index).hide();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-gongshi").show();
|
||
});
|
||
|
||
//复制指标
|
||
$(document).off('click','.analysis-fuzhi').on('click','.analysis-fuzhi',function(){
|
||
var index = $(this).attr("data-index");
|
||
var arr = data.events[index];
|
||
data.events.push(arr);
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
var num = data.events.length;
|
||
|
||
// filtersymbols[num] = filtersymbols[index];
|
||
});
|
||
|
||
//重命名指标
|
||
$(document).off('click','.analysis-chongmingming').on('click','.analysis-chongmingming',function() {
|
||
var index = $(this).attr('data-index');
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index).show();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-chongmingming-del").show();
|
||
});
|
||
|
||
//删除重命名
|
||
$(document).off('click','.analysis-chongmingming-del').on('click','.analysis-chongmingming-del',function() {
|
||
var index = $(this).attr("data-index");
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index).hide();
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index+" "+"input").val('');
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-chongmingming").show();
|
||
});
|
||
|
||
// 设置一级事件
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function() {
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index')
|
||
X.querycriteriapop(dataArr,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.id;
|
||
obj.html(htmlstring);
|
||
data['events'][index]['event_desc'] = val.id;
|
||
data['events'][index]['event_name'] = val.name;
|
||
|
||
|
||
|
||
})
|
||
});
|
||
//设置一级事件中第二个参数
|
||
$(document).off('click','.analysis-zhibiao-list-type2').on('click','.analysis-zhibiao-list-type2',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
if(type2data.length >0){
|
||
X.parametersopen(type2data,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
$("#analysis-zhibiao-list-type2-"+index).html(val.title);
|
||
|
||
data['events'][index]['event_attr'] = val.title;
|
||
data['events'][index]['event_attr_id'] = val.id;
|
||
data['events'][index]['event_attr_type'] = val.data_type;
|
||
|
||
if(val.data_type && val.data_type != null){
|
||
$("#analysis-zhibiao-list-type3-"+index).show();
|
||
$("#analysis-zhibiao-list-type3-"+index).html(quotas_map[val.data_type][0]['title']);
|
||
data['events'][index]['analysisname'] = quotas_map[val.data_type][0]['title'];
|
||
data['events'][index]['analysis'] = quotas_map[val.data_type][0]['id'];
|
||
}else {
|
||
$("#analysis-zhibiao-list-type3-"+index).hide();
|
||
data['events'][index]['analysis'] = val.analysis;
|
||
}
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
}
|
||
})
|
||
}
|
||
});
|
||
//设置一级事件中第三个参数
|
||
$(document).off('click','.analysis-zhibiao-condition').on('click','.analysis-zhibiao-condition',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['events'][index]['event_attr_type'];
|
||
|
||
X.parametersopen(quotas_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$("#analysis-zhibiao-list-type3-"+index).html(val.title);
|
||
data['events'][index]['analysisname'] = val.title;
|
||
data['events'][index]['analysis'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.ta-property-select').on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
// filtersymbols[index][indexs] = val.category;
|
||
data['events'][index]['filts'][indexs]['columnDesc'] = htmlstring;
|
||
data['events'][index]['filts'][indexs]['columnName'] = val.id;
|
||
data['events'][index]['filts'][indexs]['data_type'] = val.type;
|
||
data['events'][index]['filts'][indexs]['tableType'] = val.table_type;
|
||
})
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = data['events'][index]['filts'][indexs]['data_type'];
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['filts'][indexs]['comparator_name'] = val.title;
|
||
data['events'][index]['filts'][indexs]['comparator'] = val.id;
|
||
}
|
||
})
|
||
});
|
||
|
||
// 添加筛选项
|
||
$(document).off('click','.analysis-shaix-jinting').on('click','.analysis-shaix-jinting',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 添加筛选项
|
||
function addscreen(index){
|
||
X.api('data_auth/load_filter_props',"post",{event_name:data['events'][index]["event_name"]},function(d){
|
||
|
||
var arr = {
|
||
"columnDesc":d[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":d[0]['category'][0]['id'],//事件id
|
||
"comparator_name":filter_map[d[0]['category'][0]['data_type']][0]['title'],//选择符号中文显示
|
||
"comparator":filter_map[d[0]['category'][0]['data_type']][0]['id'],//符号id
|
||
"data_type":d[0]['category'][0]['data_type'],
|
||
"ftv":[],//条件
|
||
"strftv":'',//字符串显示条件
|
||
"tableType": d[0]['id']
|
||
} //筛选数据
|
||
data['events'][index]['filts'].push(arr);
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
})
|
||
};
|
||
|
||
//监听重命名指标
|
||
$(document).off('change','.analysis-con-left-screen-list-left-zhibiaoname input').on('change','.analysis-con-left-screen-list-left-zhibiaoname input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var txt = $(this).val();
|
||
|
||
data['events'][index]['eventNameDisplay'] = txt;
|
||
});
|
||
|
||
// 监听文本框
|
||
$(document).off('change','.analysis-zhibiao-list-type4 input').on('change','.analysis-zhibiao-list-type4 input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
if(data['events'][index]['filts'][indexs]){
|
||
data['events'][index]['filts'][indexs]['ftv']=valarr;
|
||
data['events'][index]['filts'][indexs]['strftv']=val;
|
||
}else {
|
||
|
||
}
|
||
|
||
});
|
||
|
||
// 且和或切换
|
||
$(document).off('click','.analysis-con-left-screen-list-right-screen-qh-tit').on("click",".analysis-con-left-screen-list-right-screen-qh-tit",function(){
|
||
var html = $(this).html(); //relation筛选条件的关系
|
||
var index = $(this).attr("data-index");
|
||
if(html == "且"){
|
||
$(this).html('或');
|
||
data['events'][index]['relation'] = 'or'
|
||
}else {
|
||
$(this).html('且');
|
||
data['events'][index]['relation'] = 'and'
|
||
}
|
||
});
|
||
|
||
// 添加条件按钮
|
||
$(document).off('click','.analysis-zhibiao-updata').on('click',".analysis-zhibiao-updata",function(){
|
||
// addindex();
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 删除二级筛选项
|
||
$(document).off('click','.analysis-zhibiao-list-del').on('click','.analysis-zhibiao-list-del',function(){
|
||
// var id = "analysis-zhibiao-list-mar-"+$(this).attr("data-twonum");
|
||
// $("#"+id).remove();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
// filtersymbols[index].splice(indexs,1);
|
||
data.events[index]['filts'].splice(indexs,1);
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
});
|
||
|
||
// 添加指标
|
||
function addindex(){
|
||
var defaultindicator = {
|
||
"event_desc":dataArr[0]['category'][0]['event_desc'],
|
||
"event_name":dataArr[0]['category'][0]['event_name'],
|
||
"event_attr":"总次数",
|
||
"event_attr_id":"*",
|
||
"event_attr_type":"",
|
||
"analysisname":'',
|
||
"analysis":'total_count',
|
||
"filts":[],//过滤项
|
||
"relation":'and',
|
||
"customEvent":'',
|
||
"eventNameDisplay":'',//重命名指标
|
||
"format":'float',
|
||
"formatname":'两位小数'
|
||
}
|
||
data['events'].push(defaultindicator);
|
||
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
var index = data.events.length - 1;
|
||
|
||
$(".analysis-del").show() //显示删除按钮
|
||
var drr = [];
|
||
if(data.events.length > 1){
|
||
$(".analysis-overall").show();
|
||
}else {
|
||
$(".analysis-overall").hide();
|
||
}
|
||
};
|
||
|
||
//添加按钮
|
||
$(document).on('click','.analysis-jia1',function(){
|
||
|
||
addindex();
|
||
|
||
});
|
||
//添加指标按钮
|
||
$(document).on('click','.analysis-bottom-jia1',function(){
|
||
|
||
addindex();
|
||
|
||
});
|
||
|
||
//删除指标
|
||
$(document).off('click','.analysis-del').on('click',".analysis-del",function(){
|
||
if(data['events'].length != 1){
|
||
var index = $(this).attr("data-index");
|
||
data['events'].splice(index,1);
|
||
if(data['events'].length == 1){
|
||
$(".analysis-del").hide(); //隐藏删除按钮
|
||
$(".analysis-overall").hide();
|
||
}
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data.events,".analysis-con-left-screen-list-box");
|
||
}
|
||
});
|
||
|
||
|
||
$(".analysis-custom-event-box .analysis-custom-event-txt").blur(function(){
|
||
$(this).css("border-bottom","0px");
|
||
});
|
||
|
||
$(document).off('click','.analysis-custom-event-box .analysis-custom-event-txt').on('blur','.analysis-custom-event-box .analysis-custom-event-txt',function(){
|
||
// $(this).css("border-bottom","1px solid #3d90ff");
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
data['events'][index]['customEvent'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.analysis-con-left-screen-list-left-zhibiaoname2 input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname2 input',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['events'][index]['eventNameDisplay'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.ant-select-selector').on('click','.ant-select-selector',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var downlist = [
|
||
{title:'两位小数',id:'float'},
|
||
{title:'百分比',id:'percent'},
|
||
{title:'取整',id:'integer'},
|
||
];
|
||
X.parametersopen(downlist,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['format'] = val.id;
|
||
data['events'][index]['formatname'] = val.title;
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
//分组项
|
||
var cat = "event";
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function(){
|
||
var index = data['eventView']['groupBy'].length;
|
||
for(let i in defaultgroupdata){
|
||
if(defaultgroupdata[i]['category'].length > 0){
|
||
var drr = {
|
||
"columnDesc":defaultgroupdata[i]['category'][index]['title'],//事件中文显示
|
||
"columnName":defaultgroupdata[i]['category'][index]['id'],//事件id
|
||
'data_type':defaultgroupdata[i]['category'][index]['data_type'],//类型
|
||
'tableType': defaultgroupdata[i]['id'],
|
||
"ftv":[],//条件
|
||
"section":''//区间
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
data.eventView.groupBy.push(drr);
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data.eventView.groupBy[index]['columnDesc'] = val.title;
|
||
data.eventView.groupBy[index]['columnName'] = val.id;
|
||
data.eventView.groupBy[index]['data_type'] = val.type;
|
||
data.eventView.groupBy[index]['tableType'] = val.table_type;
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-granularity').on("click",".analysis-granularity",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var type = obj.attr("data_type");
|
||
var index = obj.attr("data-index");
|
||
var arr;
|
||
if(type == 'date'){
|
||
arr = {
|
||
data:[
|
||
{'name':"按天",'id':'day','checked':true},
|
||
{'name':"按分钟",'id':'min','checked':false},
|
||
{'name':"按小时",'id':'hour','checked':false},
|
||
{'name':"按周",'id':'week','checked':false},
|
||
{'name':"按月",'id':'month','checked':false}
|
||
],
|
||
default: data.eventView.groupBy[index]['ftv']
|
||
|
||
}
|
||
}else {
|
||
arr ={
|
||
data:[
|
||
{'name':"按元素",'id':'0','checked':true},
|
||
{'name':"按列表整体",'id':'1','checked':false},
|
||
{'name':"按元素集合",'id':'2','checked':false}
|
||
],
|
||
default: data.eventView.groupBy[index]['ftv']
|
||
}
|
||
}
|
||
|
||
X.querycriteriapop(arr,'groupitem',offset.left,offset.top+obj.height(),function(val){
|
||
data.eventView.groupBy[index]['ftv'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).on("click",".analysis-section",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var sectionid = obj.attr("data-sectionid");
|
||
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'groupeditemspop',
|
||
extData : sectionid,
|
||
callback : function(val){
|
||
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
$(document).on('click','.analysis-action-right',function(){
|
||
var index = $(this).attr('data-index');
|
||
data.eventView.groupBy.splice(index,1);
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
});
|
||
|
||
$(document).on('click','.analysis-event-splitting',function(){
|
||
|
||
});
|
||
|
||
// 全局筛选
|
||
var filtsftvdata=[];
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var drr={
|
||
"columnDesc":defaultgroupdata[0]['category'][0]['title'],//事件中文显示 columnDesc
|
||
"columnName":defaultgroupdata[0]['category'][0]['id'],//事件id
|
||
'data_type':defaultgroupdata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"tableType":defaultgroupdata[0]['id']
|
||
};
|
||
data['eventView']['filts'].push(drr);//上传全局数据
|
||
filtsftvdata.push(defaultgroupdata[0]['category'][0]['category'])
|
||
|
||
$(".analysis-overall-situation-left-box").show();
|
||
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['eventView']['filts'][index]['data_type'];
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$(this).html(val.title);
|
||
data['eventView']['filts'][index]['comparator_name'] = val.title;
|
||
data['eventView']['filts'][index]['comparator'] = val.id;
|
||
if(val.id == "range"){
|
||
data['eventView']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-del').on('click',".analysis-overall-situation-del",function(){
|
||
var index = $(this).attr("data-index");
|
||
data['eventView']['filts'].splice(index,1);
|
||
filtsftvdata.splice(index,1);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
// $(".analysis-overall-situation-left-box").hide();
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['eventView']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['eventView']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
|
||
$(document).off('click','.analysis-overall-situation-left-guanxi').on('click','.analysis-overall-situation-left-guanxi',function(){
|
||
var html = $(this).html(); //relation筛选条件的关系
|
||
if(html == "且"){
|
||
$(this).html('或');
|
||
data['eventView']['relation'] = 'or'
|
||
}else {
|
||
$(this).html('且');
|
||
data['eventView']['relation'] = 'and'
|
||
}
|
||
});
|
||
|
||
// 全局属性选择
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click',".analysis-overall-situation-attr",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['columnDesc'] = val.title;
|
||
data['eventView']['filts'][index]['columnName'] = val.id;
|
||
data['eventView']['filts'][index]['data_type'] = val.type;
|
||
data['eventView']['filts'][index]['comparator_name'] = '等于';
|
||
data['eventView']['filts'][index]['comparator'] = '==';
|
||
data['eventView']['filts'][index]['tableType'] = val.table_type;
|
||
filtsftvdata[index]=val.category;
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
})
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input3 input').on('blur','.analysis-overall-situation-input3 input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var text = $(this).val();
|
||
if(index == 0){
|
||
data['eventView']['min_r'] = text;
|
||
}else{
|
||
data['eventView']['middle_r'] = text;
|
||
}
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['eventView']['filts'][index]['ftv']=valarr;
|
||
data['eventView']['filts'][index]['strftv']=val;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['eventView']['filts'][index]['ftv'][0] = val;
|
||
data['eventView']['filts'][index]['section'][0] = val;
|
||
}else {
|
||
data['eventView']['filts'][index]['ftv'][1] = val;
|
||
data['eventView']['filts'][index]['section'][1] = val;
|
||
}
|
||
});
|
||
|
||
// 时间粒度
|
||
X.laydropdown('.analtsis-timeParticleSize',X['DATA']['companylist']['event'],function(d){
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['timeParticleSize'] = d.id;
|
||
calculationdata();
|
||
});
|
||
|
||
X.layuidate('#analysis-overall-situation-time1');
|
||
|
||
// 计算
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
calculationdata();
|
||
|
||
});
|
||
|
||
var querydata;//查询数据
|
||
$(document).on('click','.analtsis-chart-switch-box .analtsis-chart-switch',function(){
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '趋势图'){trendchart(querydata)}
|
||
else if($(this).attr('title') == '堆积图'){stackingdiagram(querydata);}
|
||
else if($(this).attr('title') == '累计图'){}
|
||
else if($(this).attr('title') == '分布图'){distributionmap(querydata)}
|
||
else if($(this).attr('title') == '饼状分布'){}
|
||
}else{
|
||
// layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
|
||
});
|
||
|
||
//堆积图
|
||
function stackingdiagram(d){
|
||
var xAxisData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['groups']){
|
||
var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
xAxisData.push(pj);
|
||
}
|
||
}
|
||
var seriesData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['values']){
|
||
var arr = {
|
||
name: '',
|
||
type: 'line',
|
||
stack: '总量',
|
||
areaStyle: {},
|
||
emphasis: {
|
||
focus: 'series'
|
||
},
|
||
data: d[i]['values'][z]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
if(xAxisData.length > 0){
|
||
for(let i in seriesData){
|
||
seriesData[i]['name'] = xAxisData[i];
|
||
}
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: xAxisData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: d[0]['date_range']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//趋势图
|
||
function trendchart(d){
|
||
var xAxisData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['groups']){
|
||
var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
xAxisData.push(pj);
|
||
}
|
||
}
|
||
var seriesData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['values']){
|
||
var arr = {
|
||
name: '',
|
||
type: 'line',
|
||
data: d[i]['values'][z]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
if(xAxisData.length > 0){
|
||
for(let i in seriesData){
|
||
seriesData[i]['name'] = xAxisData[i];
|
||
}
|
||
}
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: xAxisData
|
||
},
|
||
// toolbox: {
|
||
// feature: {
|
||
// saveAsImage: {}
|
||
// }
|
||
// },
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: d[0]['date_range']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//分布图
|
||
function distributionmap(d){
|
||
var legendData =[];
|
||
var xAxisData=[];
|
||
var seriesData=[];
|
||
if(jQuery.isEmptyObject(d[0]["groups"])){
|
||
for(let i in d){
|
||
xAxisData.push(d[i]['event_name']);
|
||
legendData.push(d[i]['event_name']);
|
||
var num =0;
|
||
for(let j in d[i]['values'][i]){
|
||
num = num + d[i]['values'][i][j]
|
||
}
|
||
var arr = {
|
||
name: d[i]['event_name'],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
}else {
|
||
for(let i in d){
|
||
xAxisData.push(d[i]['event_name']);
|
||
for(let j in d[i]['groups']){
|
||
var num =0;
|
||
for(let z in d[i]['values'][j]){
|
||
num = parseFloat(num) + parseFloat(d[i]['values'][j][z])
|
||
}
|
||
if(i > 0){
|
||
for(let q in seriesData){
|
||
if(d[i]['groups'][j] == seriesData[q]['name']){
|
||
seriesData[q]['data'].push(num);
|
||
}else {
|
||
var arr = {
|
||
name: d[i]['groups'][j],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
}else {
|
||
var arr = {
|
||
name: d[i]['groups'][j],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
}
|
||
// for(let i in d){
|
||
// for(let z in d[i]['groups']){
|
||
// var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
// xAxisData.push(pj);
|
||
// }
|
||
// }
|
||
// var seriesData=[];
|
||
// for(let i in d){
|
||
// for(let z in d[i]['values']){
|
||
// var arr = {
|
||
// name: '',
|
||
// type: 'bar',
|
||
// data: d[i]['values'][z]
|
||
// }
|
||
// seriesData.push(arr);
|
||
// }
|
||
// }
|
||
// if(xAxisData.length > 0){
|
||
// for(let i in seriesData){
|
||
// seriesData[i]['name'] = xAxisData[i];
|
||
// }
|
||
// }
|
||
// return;
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
}
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
legend: {
|
||
data: legendData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
axisTick: {show: false},
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//表格
|
||
function tabledata(d){
|
||
var titledata,condata=[];
|
||
for(let i in d){
|
||
titledata= $.extend(true,[],d[0]['date_range']) ;
|
||
if(d[i]['groups']['length'] != 0){
|
||
titledata.unshift('指标','分组','阶段总和');
|
||
for(let j in d[i]['values']){
|
||
var arr;
|
||
arr = $.extend(true,[],d[i].values[j]);
|
||
arr.unshift(d[i]['event_name'],d[i]['sum'][j]);
|
||
condata.push(arr);
|
||
}
|
||
for(let j in condata){
|
||
condata[j].splice(1,0,d[i]['groups'][j]);
|
||
}
|
||
|
||
}else {
|
||
titledata.unshift('指标','阶段总和');
|
||
var arr;
|
||
arr = $.extend(true,[],d[i].values[0])
|
||
arr.unshift(d[i]['event_name'],d[i]['sum'][0]);
|
||
condata.push(arr);
|
||
}
|
||
}
|
||
X.laytpldata("#table-fenxi-th-dot",titledata,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",condata ,".table-fenxi-td");
|
||
};
|
||
|
||
function calculationdata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/event_model","post",dataArr,function(d){
|
||
querydata = d;
|
||
if(d.length > 0){
|
||
if(d[0].values.length > 0 ){
|
||
updata();
|
||
tabledata(d);
|
||
}else {
|
||
$("#analysis-echarts").empty();
|
||
layer.msg("无数据");
|
||
}
|
||
}else {
|
||
$("#analysis-echarts").empty();
|
||
layer.msg("无数据");
|
||
}
|
||
|
||
})
|
||
};
|
||
|
||
function updata(){
|
||
var tit = $(".select-chart").attr("title");
|
||
if(tit == '趋势图'){trendchart(querydata)}
|
||
else if(tit == '堆积图'){stackingdiagram(querydata);}
|
||
else if(tit == '累计图'){}
|
||
else if(tit == '分布图'){distributionmap(querydata)}
|
||
else if(tit == '饼状分布'){}
|
||
};
|
||
|
||
// 保存报表
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
// 下载
|
||
$(document).off('click','.download-table').on('click','.download-table',function(){
|
||
X.download('ck/event_model_export',data,'事件分析');
|
||
});
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
},
|
||
|
||
// 保存报表
|
||
// savereport:function(d){
|
||
|
||
// }
|
||
|
||
};
|
||
})();
|
||
|
||
|
||
|
||
// srczip/logic/addeventattradmin.js
|
||
(function(){
|
||
X.pageLogic['addeventattradmin'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
layui.form.render();
|
||
|
||
$(".eventattradminedit-but-box .eventattradminedit-qx").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.eventattradminedit-but-box .eventattradminedit-qd').on('click','.eventattradminedit-but-box .eventattradminedit-qd',function(){
|
||
var fromdata = layui.form.val("eventattradmineditexample");
|
||
|
||
X.api('data_mana/add_attr',"post",{new_attribute: fromdata['eventname'], data_type:fromdata.addevent ,cat:data,state:'add'},function(d){
|
||
me.callback && me.callback(d);
|
||
layer.closeAll();
|
||
layer.msg('添加成功');
|
||
})
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/addexistuser.js
|
||
(function(){
|
||
X.pageLogic['addexistuser'] = {
|
||
init : function(){
|
||
|
||
var data = {
|
||
"authDataPowers":[
|
||
|
||
],
|
||
"authRoles":[
|
||
|
||
],
|
||
"userlist":[
|
||
|
||
]
|
||
}
|
||
|
||
X.api("user/all_account","get",{},function(d){
|
||
data['userlist'] = d
|
||
X.laytpldata("#addexistuser-con-user-box-dot",d,".addexistuser-con-user-box");
|
||
});
|
||
|
||
X.api("project/members","get",{},function(d){
|
||
// console.log(d)
|
||
// X.laytpldata("#addexistuser-con-user-box-dot",d,".addexistuser-con-user-box");
|
||
});
|
||
|
||
X.api("authz/roles","get",{},function(d){
|
||
var projectrolearrlist = [];
|
||
for(let i in d){
|
||
var arr={
|
||
id:d[i]['_id'],
|
||
title:d[i]['name'],
|
||
game:d[i]['game']
|
||
}
|
||
projectrolearrlist.push(arr);
|
||
};
|
||
data['authRoles'] = projectrolearrlist;
|
||
})
|
||
|
||
$('.addexistuser-con-ss-box input').bind('input propertychange', function() {
|
||
var txt = $(this).val();
|
||
var userdata = data["userlist"];
|
||
var arr = [];
|
||
for(let i in userdata){
|
||
if(userdata[i]["nickname"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}else {
|
||
if(userdata[i]["name"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}
|
||
}
|
||
}
|
||
if(txt != ""){
|
||
X.laytpldata("#addexistuser-con-user-box-dot",arr,".addexistuser-con-user-box");
|
||
$(".addexistuser-con-ss-cha").show();
|
||
}else {
|
||
X.laytpldata("#addexistuser-con-user-box-dot",data.userlist,".addexistuser-con-user-box");
|
||
$(".addexistuser-con-ss-cha").hide();
|
||
}
|
||
});
|
||
|
||
$(".addexistuser-con-ss-cha").click(function(){
|
||
$(".addexistuser-con-ss-box input").val("");
|
||
$(".addexistuser-con-ss-cha").hide();
|
||
X.laytpldata("#addexistuser-con-user-box-dot",data.userlist,".addexistuser-con-user-box");
|
||
});
|
||
|
||
var Addeddate = []; //以选中人员
|
||
$("body").on("click",".addexistuser-con-user-list-box img",function(){
|
||
var index = $(this).attr("data-index");
|
||
var arr = data.userlist[index];//获取选中用户数据
|
||
Addeddate.push(arr);
|
||
var txt = $(".addexistuser-con-ss-box input").val();
|
||
if(txt != ""){
|
||
var userdata = data["userlist"];
|
||
var arr = [];
|
||
for(let i in userdata){
|
||
if(userdata[i]["nickname"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}else {
|
||
if(userdata[i]["name"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}
|
||
}
|
||
}
|
||
arr.splice(index,1);
|
||
X.laytpldata("#addexistuser-con-user-box-dot",arr,".addexistuser-con-user-box");
|
||
}else {
|
||
data.userlist.splice(index,1);
|
||
X.laytpldata("#addexistuser-con-user-box-dot",data.userlist,".addexistuser-con-user-box");
|
||
}
|
||
|
||
for(let i in Addeddate){
|
||
if(Addeddate[i] == undefined){
|
||
Addeddate.splice(i,1);
|
||
}
|
||
}
|
||
|
||
X.laytpldata("#addexistuser-table-con-list-dot",Addeddate,".addexistuser-table-con-list");
|
||
|
||
addlaydropdown();
|
||
|
||
});
|
||
|
||
$("body").on("click",".addexistuser-table-tit-cz img",function(){
|
||
var index = $(this).attr("data-index");
|
||
data.userlist.push(Addeddate[index]);
|
||
Addeddate.splice(index,1);
|
||
var txt = $(".addexistuser-con-ss-box input").val();
|
||
if(txt != ""){
|
||
usertxtdate();
|
||
}else {
|
||
X.laytpldata("#addexistuser-con-user-box-dot",data.userlist,".addexistuser-con-user-box");
|
||
}
|
||
X.laytpldata("#addexistuser-table-con-list-dot",Addeddate,".addexistuser-table-con-list");
|
||
addlaydropdown();
|
||
});
|
||
|
||
var cprojectindex = '';//获取点击的项目角色的index
|
||
var cprojectdiv = '';//获取点击的项目角色的div
|
||
$("body").on("click",".addexistuser-role span",function(){
|
||
cprojectindex = $(this).attr("data-index");
|
||
cprojectdiv = $(this);
|
||
});
|
||
|
||
var cdatarightsindex = "";//获取点击的数据权限index
|
||
var cdatarightsdiv = "";//获取点击的数据权限div
|
||
$("body").on("click",".addexistuser-attr span",function(){
|
||
cdatarightsindex = $(this).attr("data-index");
|
||
cdatarightsdiv = $(this);
|
||
});
|
||
|
||
function usertxtdate(){
|
||
var userdata = data["userlist"];
|
||
var arr = [];
|
||
for(let i in userdata){
|
||
if(userdata[i]["nickname"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}else {
|
||
if(userdata[i]["name"].indexOf(txt) >= 0 ){
|
||
arr.push(userdata[i]);
|
||
}
|
||
}
|
||
}
|
||
arr.splice(index,1);
|
||
X.laytpldata("#addexistuser-con-user-box-dot",arr,".addexistuser-con-user-box");
|
||
};
|
||
|
||
//给项目角色,数据权限添加下拉框
|
||
function addlaydropdown(){
|
||
X.laydropdown(".addexistuser-role",data["authRoles"],function(d){
|
||
cprojectdiv.html(d.title);
|
||
Addeddate[cprojectindex]['role_id'] = d.id;
|
||
Addeddate[cprojectindex]['role_tit'] = d.title;
|
||
})
|
||
|
||
X.laydropdown(".addexistuser-attr",data["authDataPowers"],function(d){
|
||
cdatarightsdiv.html(d.title);
|
||
Addeddate[cdatarightsindex]['datarightsid'] = d.id;
|
||
Addeddate[cdatarightsindex]['datarightstit'] = d.title;
|
||
})
|
||
};
|
||
|
||
//叉图标
|
||
$(".addexistuser-top-box img").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
// 取消按钮
|
||
$(".addexistuser-btn-qx").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
//确定按钮
|
||
$(".addexistuser-btn-qd").click(function(){
|
||
|
||
var ylist = [];
|
||
for(let i in Addeddate){
|
||
var arr = {
|
||
username:Addeddate[i]['name'],
|
||
role_id:Addeddate[i]['role_id'],
|
||
game:X.DATA.game
|
||
}
|
||
ylist.push(arr)
|
||
}
|
||
|
||
if(ylist.length == 0){
|
||
layer.msg('暂未选择用户');
|
||
return;
|
||
}
|
||
X.api("authz/add_role_domain","post",{data:ylist},function(d){
|
||
layer.closeAll();
|
||
});
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/addproduct.js
|
||
(function(){
|
||
X.pageLogic['addproduct'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
|
||
$(document).off('click','.newwenjian-qd').on('click','.newwenjian-qd',function(){
|
||
if($("#game").val() == "" && $("#name").val() == ""){
|
||
layer.msg('标题,路径为必填项');
|
||
return;
|
||
}
|
||
var arr = {
|
||
"name": $("#name").val(),
|
||
"game": $("#game").val(),
|
||
}
|
||
X.api('project/create','post',arr,function(d){
|
||
layer.closeAll();
|
||
me.callback && me.callback();
|
||
});
|
||
|
||
|
||
});
|
||
|
||
$(document).off('click','.newwenjian-qx').on('click','.newwenjian-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.newwenjian-cha').on('click','.newwenjian-cha',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/addproject_owner_name.js
|
||
(function(){
|
||
X.pageLogic['addproject_owner_name'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
// console.log(data);
|
||
|
||
if(data){
|
||
// for(let i in data.ditch){
|
||
// $(".datarightsedit-txt-input").html(data.main_channel);
|
||
// $(".datarightsedit-txt-input3").html(data.ditch);
|
||
// }
|
||
X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
|
||
};
|
||
|
||
$(document).off("click",'.datarightsedit-tj').on('click','.datarightsedit-tj',function(){
|
||
var arr = {
|
||
'main_channel':'',
|
||
'ditch':''
|
||
}
|
||
data.ditch.push(arr);
|
||
X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
|
||
});
|
||
|
||
$(document).off('click','.daxinqudao').on('blur','.daxinqudao',function(){
|
||
var index = $(this).attr("data-index");
|
||
data.ditch[index]['main_channel'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.qudaocanshu').on('blur','.qudaocanshu',function(){
|
||
var index = $(this).attr("data-index");
|
||
data.ditch[index]['ditch'] = $(this).val();
|
||
});
|
||
|
||
$(document).off("click",'.datarightsedit-txt-box-del').on('click','.datarightsedit-txt-box-del',function(){
|
||
var index = $(this).attr("data-index");
|
||
data.ditch.splice(index,1);
|
||
X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
|
||
});
|
||
|
||
$(".datarightsedit-qx").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(".datarightsedit-top-box img").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(".datarightsedit-qd").click(function(){
|
||
|
||
X.api("project/add_project_name","post",{game:data.game,ditch:data.ditch,name: data.name},function(d){
|
||
if(d){
|
||
layer.msg("编辑成功");
|
||
me.callback && me.callback();
|
||
layer.closeAll();
|
||
}
|
||
})
|
||
});
|
||
|
||
},
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/addproject_owner_name_list.js
|
||
(function(){
|
||
X.pageLogic['addproject_owner_name_list'] = {
|
||
init : function(){
|
||
var me = this;
|
||
me.addprojectownernamelist();
|
||
layui.table.on('tool(eventattradmintest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'edit'){
|
||
data['cat'] = 'event'
|
||
X.parametersopen(data,"addproject_owner_name",'auto',function(){
|
||
me.addprojectownernamelist();
|
||
})
|
||
}
|
||
})
|
||
|
||
|
||
},
|
||
addprojectownernamelist : function(){
|
||
X.laytabledata("#eventattradmin-table","project/project_name",[[
|
||
{field:'game', title: '项目名', sort: true}
|
||
,{field:'name', title: '显示名'}
|
||
,{field:'main_channel', title: '发行渠道 : 渠道参数',templet:function(d){
|
||
var txt = '';
|
||
for(let i in d.ditch){
|
||
if(d.ditch[i]['main_channel'] != undefined && d.ditch[i]['ditch'] != undefined) {
|
||
|
||
}
|
||
txt += d.ditch[i]['main_channel']+ " : " + d.ditch[i]['ditch'] +'<br>'
|
||
}
|
||
return txt
|
||
}}
|
||
,{fixed: 'right', title:'操作', toolbar: '#addprojectownernameDemo', width:80}
|
||
]]);
|
||
}
|
||
|
||
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/addrole.js
|
||
(function(){
|
||
X.pageLogic['addrole'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
|
||
var data;
|
||
X.api("authz/api_list","get",{},function(d){
|
||
data = d;
|
||
X.laytpldata("#addrole-info-table-con-dot",d,".addrole-info-table-con");
|
||
layui.form.render();
|
||
});
|
||
|
||
if(parms){
|
||
this.parms = parms;
|
||
var passdata = parms;
|
||
|
||
X.api("authz/get_permissions_for_user_in_domain","post",{role_id:passdata.id,game:X['DATA']['game']},function(d){
|
||
|
||
$('.addrole-tit').val(passdata.title);
|
||
var selinput = {}
|
||
for(let i in d){
|
||
selinput[d[i]['_id']] = true
|
||
}
|
||
layui.form.val('addroleexample', selinput)
|
||
});
|
||
};
|
||
|
||
// layui.form.on('checkbox(addrolelist)', function(data){
|
||
// console.log(data.othis[0]['innerText']);
|
||
// var title = data.othis[0]['innerText'];
|
||
// var selinput = {}
|
||
// if(title == "全选"){
|
||
// for(let i in data){
|
||
// selinput[data[i]['path']] = true
|
||
// }
|
||
// layui.form.val('addroleexample', selinput)
|
||
// }
|
||
// });
|
||
|
||
$(document).off('click','.addrole-list-qx').on('click','.addrole-list-qx',function(){
|
||
var selinput = {}
|
||
for(let i in data){
|
||
selinput[data[i]['path']] = true
|
||
}
|
||
layui.form.val('addroleexample', selinput)
|
||
});
|
||
|
||
$(document).off('click','.addrole-qd').on('click','.addrole-qd',function(){
|
||
var tit = $(".addrole-tit").val();
|
||
var addroledata = layui.form.val("addroleexample");
|
||
|
||
var dataArr =[];
|
||
for(let i in addroledata){
|
||
dataArr.push(i);
|
||
}
|
||
if(passdata){
|
||
// X.api("authz/add_roles","post",{name:tit,game:X['DATA']['game'],desc:'111'},function(d){
|
||
|
||
// X.api("authz/add_policy","post",{role_id:d,game:X['DATA']['game'],act:"*",path_list:dataArr},function(d){
|
||
// layer.msg("创建成功");
|
||
// $(".addrole-qx a").click();
|
||
// })
|
||
// })
|
||
}else{
|
||
X.api("authz/add_roles","post",{name:tit,game:X['DATA']['game'],desc:'111'},function(d){
|
||
|
||
X.api("authz/add_policy","post",{role_id:d,game:X['DATA']['game'],act:"*",path_list:dataArr},function(d){
|
||
layer.msg("创建成功");
|
||
$(".addrole-qx a").click();
|
||
})
|
||
|
||
})
|
||
}
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/adduser.js
|
||
(function(){
|
||
X.pageLogic['adduser'] = {
|
||
init : function(){
|
||
|
||
$(document).off('click','.adduser-top-box img').on('click','.adduser-top-box img',function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
var projectrolearr,projectrolearrlist=[];
|
||
X.api("authz/roles","get",{},function(d){
|
||
projectrolearr = d;
|
||
for(let i in projectrolearr){
|
||
var arr={
|
||
id:projectrolearr[i]['_id'],
|
||
title:projectrolearr[i]['name'],
|
||
game:projectrolearr[i]['game']
|
||
}
|
||
projectrolearrlist.push(arr);
|
||
}
|
||
})
|
||
// var datarightsarr;
|
||
// X.api("data_auth/list","get",{},function(d){
|
||
// datarightsarr = d;
|
||
// })
|
||
|
||
var adduserData =[]; //以创建账号
|
||
$(document).off('click','.adduser-subject-add-box div').on('click','.adduser-subject-add-box div',function(){
|
||
var txt = $(".adduser-subject-add-box input").val();
|
||
var titarr = txt.split(",");
|
||
for(let i in titarr){
|
||
var arr = {
|
||
"game": X.DATA.game,
|
||
"username": titarr[i],
|
||
"role_name": projectrolearr[0]["name"],
|
||
"role_id": projectrolearr[0]["_id"]
|
||
// "data_authority":datarightsarr[0]["title"],
|
||
// "data_auth_id":datarightsarr[0]["id"]
|
||
}
|
||
adduserData.push(arr);
|
||
}
|
||
update();
|
||
$(".adduser-subject-add-box input").val("");
|
||
})
|
||
|
||
$(document).off('click','.adduser-table-title-cz img').on('click','.adduser-table-title-cz img',function(){
|
||
var index = $(this).attr("data-index");
|
||
adduserData.splice(index,1);
|
||
update();
|
||
})
|
||
|
||
var cprojectindex = '';//获取点击的项目角色的index
|
||
var cprojectdiv = '';//获取点击的项目角色的div
|
||
$(document).off('click','.adduser-role span').on('click','.adduser-role span',function(){
|
||
cprojectindex = $(this).attr("data-index");
|
||
cprojectdiv = $(this);
|
||
})
|
||
|
||
var cdatarightsindex = "";//获取点击的数据权限index
|
||
var cdatarightsdiv = "";//获取点击的数据权限div
|
||
|
||
$(document).off('click','.adduser-attr span').on('click','.adduser-attr span',function(){
|
||
cdatarightsindex = $(this).attr("data-index");
|
||
cdatarightsdiv = $(this);
|
||
})
|
||
|
||
function update(){
|
||
X.laytpldata("#adduser-table-con-box-dot",adduserData,".adduser-table-con-box");
|
||
// 项目角色修改
|
||
// console.log(projectrolearrlist);
|
||
|
||
X.laydropdown(".adduser-role",projectrolearrlist,function(d){
|
||
cprojectdiv.html(d.title);
|
||
|
||
adduserData[cprojectindex]['role_name'] = d.title;
|
||
adduserData[cprojectindex]['role_id'] = d.id;
|
||
|
||
})
|
||
// 数据权限修改
|
||
// X.laydropdown(".adduser-attr",datarightsarr,function(d){
|
||
// cdatarightsdiv.html(d.title);
|
||
// console.log(d)
|
||
// adduserData[cdatarightsindex]['data_authority'] = d.title;
|
||
// adduserData[cdatarightsindex]['data_auth_id'] = d.id;
|
||
// })
|
||
}
|
||
|
||
$(document).off('click','.adduser-but-box .adduser-btn').on('click','.adduser-but-box .adduser-btn',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.adduser-but-box .adduser-btn2').on('click','.adduser-but-box .adduser-btn2',function(){
|
||
var namearr = [];
|
||
|
||
for(let i in adduserData){
|
||
namearr.push(adduserData[i]['username']);
|
||
}
|
||
if(namearr.length > 0){
|
||
//创建账号
|
||
X.api("user/add_account","post",{account_list:namearr},function(d){
|
||
//给账号添加项目角色
|
||
X.api("authz/add_role_domain","post",{data:adduserData},function(d){
|
||
X.pageLogic.useradmin.useradmin();
|
||
layer.closeAll();
|
||
layer.msg("创建成功");
|
||
});
|
||
})
|
||
}else {
|
||
layer.msg("请先添加账号");
|
||
}
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/addusergroup.js
|
||
(function(){
|
||
X.pageLogic['addusergroup'] = {
|
||
init : function(){
|
||
layui.form.render();
|
||
var data = [
|
||
{"value": "1", "title": "李白"}
|
||
,{"value": "2", "title": "杜甫"}
|
||
,{"value": "3", "title": "苏轼"}
|
||
,{"value": "4", "title": "李清照"}
|
||
,{"value": "5", "title": "鲁迅"}
|
||
,{"value": "6", "title": "巴金"}
|
||
,{"value": "7", "title": "冰心"}
|
||
,{"value": "8", "title": "矛盾"}
|
||
,{"value": "9", "title": "贤心"}
|
||
]
|
||
//渲染穿梭框
|
||
X.laytransfer("#addusergroup-user-box",data,['选择用户识别属性', '已添加属性'],"addusergroupuserinfo");
|
||
|
||
$(".addusergroup-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".addusergroup-top-box img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".addusergroup-qd").click(function(){
|
||
var getData = layui.transfer.getData('addusergroupuserinfo');
|
||
var txt = $(".addusergroup-txt").val();
|
||
layer.closeAll();
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/adminkanban.js
|
||
(function(){
|
||
X.pageLogic['adminkanban'] = {
|
||
init : function(){
|
||
var me = this;
|
||
// 弹窗占满整平
|
||
$(".adminmykanban-box").css('height',window.innerHeight+'px');
|
||
me.updata(X.DATA['projectid']);
|
||
|
||
$(".adminmykanban-top-fh").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.adminmykanban-sousuo-box .cha').on('click','.adminmykanban-sousuo-box .cha',function(){
|
||
$(".adminmykanban-sousuo-box .adminmykanban-txt").val("");
|
||
$(".adminmykanban-sousuo-box .cha").hide();
|
||
me.updata(X.DATA['projectid']);
|
||
});
|
||
|
||
// 全选按钮
|
||
$(document).off('click','#adminmykanban-quanxuan').on('click','#adminmykanban-quanxuan',function(){
|
||
var KanBanData = X.DATA['sxKanBanData'];
|
||
var ProjectData = X.DATA['sxProjectData'];
|
||
if($(this).prop('checked')){
|
||
for(let i in KanBanData){
|
||
KanBanData[i]['checked'] = true;
|
||
}
|
||
for(let i in ProjectData){
|
||
ProjectData[i]['checked'] = true;
|
||
}
|
||
}else {
|
||
for(let i in KanBanData){
|
||
KanBanData[i]['checked'] = false;
|
||
}
|
||
for(let i in ProjectData){
|
||
ProjectData[i]['checked'] = false;
|
||
}
|
||
}
|
||
|
||
X.treemenu("#adminmykanban-con-mykanban",KanBanData,'mykanban');
|
||
X.treemenu("#adminmykanban-con-kongjian",ProjectData,'kongjian');
|
||
});
|
||
|
||
// 搜索
|
||
$('.adminmykanban-sousuo-box .adminmykanban-txt').bind('input propertychange', function() {
|
||
var txt = $(this).val();
|
||
var KanBanData = X.DATA['sxKanBanData'];
|
||
var ProjectData = X.DATA['sxProjectData'];
|
||
if(txt != ""){
|
||
var ssKanBanData = [];
|
||
var ssProjectData = [];
|
||
for(let i in KanBanData){
|
||
if(KanBanData[i]['title'].indexOf(txt) != -1){
|
||
ssKanBanData.push(KanBanData[i]);
|
||
}else {
|
||
var arr = []
|
||
for(let j in KanBanData[i]['children']){
|
||
|
||
if(KanBanData[i]['children'][j]['title'].indexOf(txt) != -1 ){
|
||
// KanBanData[i]["children"].push(KanBanData[i]['children'][j]);
|
||
arr.push(KanBanData[i]['children'][j]);
|
||
}
|
||
}
|
||
if(arr.length != 0){
|
||
var data = KanBanData[i];
|
||
data['children'] = arr
|
||
ssKanBanData.push(data);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
for(let i in ProjectData){
|
||
if(ProjectData[i]['title'].indexOf(txt) != -1){
|
||
ssProjectData.push(ProjectData[i])
|
||
}else {
|
||
if(ProjectData[i]['children'] != undefined){
|
||
var twoarr = [];
|
||
var trenarr = [];
|
||
for(let j in ProjectData[i]['children']){
|
||
if(ProjectData[i]['children'][j]['title'].indexOf(txt) != -1){
|
||
twoarr.push(ProjectData[i]['children'][j]);
|
||
|
||
if(ssProjectData.length == 0){
|
||
var data = ProjectData[i];
|
||
data['children'] = twoarr;
|
||
ssProjectData.push(data);
|
||
}else {
|
||
var data = twoarr;
|
||
ssProjectData[i]['children'].push(data);
|
||
}
|
||
}else {
|
||
if(ProjectData[i]['children'][j]['children'] != undefined){
|
||
for(let z in ProjectData[i]['children'][j]['children']){
|
||
if(ProjectData[i]['children'][j]['children'][z]['title'].indexOf(txt) != -1){
|
||
trenarr.push(ProjectData[i]['children'][j]['children'][z]);
|
||
// var dataarr = ProjectData[i]['children'][j];
|
||
// if(ssProjectData.length == 0){
|
||
|
||
// var arr = JSON.parse(JSON.stringify(ProjectData[i]));
|
||
// var towarr = JSON.parse(JSON.stringify(ProjectData[i]['children'][j]));
|
||
// var dataarr = [];
|
||
// dataarr.push(towarr);
|
||
// arr['children'] = [];
|
||
// arr['children']=dataarr[0]
|
||
// towarr['children'] = trenarr;
|
||
// ssProjectData.push(arr);
|
||
// console.log(ssProjectData)
|
||
// }else {
|
||
// var towarr = arr['children'][j];
|
||
// towarr['children'].push(trenarr);
|
||
// ssProjectData[i]['children'].push(towarr);
|
||
// }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
X.treemenu("#adminmykanban-con-mykanban",ssKanBanData,'mykanban');
|
||
X.treemenu("#adminmykanban-con-kongjian",ssProjectData,'kongjian');
|
||
$(".adminmykanban-sousuo-box .cha").show();
|
||
}else {
|
||
$(".adminmykanban-sousuo-box .cha").hide();
|
||
me.updata(X.DATA['projectid']);
|
||
}
|
||
});
|
||
|
||
function cloneObjectFn(obj){ // 对象复制
|
||
return JSON.parse(JSON.stringify(obj))
|
||
};
|
||
|
||
//移动至
|
||
$(document).off('click','.adminmykanban-operation-but-yidong').on('click','.adminmykanban-operation-but-yidong',function(){
|
||
var mykanban = layui.tree.getChecked('mykanban');
|
||
var kongjian = layui.tree.getChecked('kongjian');
|
||
if(mykanban.length < 1 && kongjian.length < 1){
|
||
alert('请先选择需要移动的看板!!!');
|
||
return;
|
||
}
|
||
var data = {
|
||
'mykanban':selectkanbanidarr(mykanban),
|
||
'kongjian':selectkongjianidarr(kongjian)
|
||
}
|
||
var source_id = data['mykanban'].concat(data['kongjian']);
|
||
X.parametersopen(source_id,'yidong-pop','auto',function(){
|
||
me.updata(X.DATA['projectid']);
|
||
})
|
||
});
|
||
|
||
//删除
|
||
$(document).off('click','.adminmykanban-operation-but-del').on('click','.adminmykanban-operation-but-del',function(){
|
||
var mykanban = layui.tree.getChecked('mykanban');
|
||
var kongjian = layui.tree.getChecked('kongjian');
|
||
var kanbanid = selectkanbanidarr(mykanban);
|
||
var kongjianid = selectkongjianidarr(kongjian);
|
||
var data= kanbanid.concat(kongjianid);
|
||
if(data.length == 0 ){
|
||
alert('请先选择要删除的看板!!!');
|
||
return;
|
||
}
|
||
|
||
$(".layui-layer").css('background-color','#fff !important');
|
||
layer.confirm('确认删除选中的看板吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("dashboard/delete",'post',{ids:data},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
me.updata(X.DATA.projectid);//刷新数据
|
||
})
|
||
});
|
||
|
||
});
|
||
|
||
// 复制至空间
|
||
$(document).off('click','.adminmykanban-operation-but-copykongjian').on('click','.adminmykanban-operation-but-copykongjian',function(){
|
||
var mykanban = layui.tree.getChecked('mykanban');
|
||
var kongjian = layui.tree.getChecked('kongjian');
|
||
if(mykanban.length < 1 && kongjian.length < 1){
|
||
alert('请先选择需要移动的看板!!!');
|
||
return;
|
||
}
|
||
var data = {
|
||
'mykanban':selectkanbanidarr(mykanban),
|
||
'kongjian':selectkongjianidarr(kongjian)
|
||
}
|
||
var source_id = data['mykanban'].concat(data['kongjian']);
|
||
X.parametersopen(source_id,'copykanban_kongjian','auto',function(){
|
||
me.updata(X.DATA['projectid']);
|
||
})
|
||
})
|
||
|
||
// 复制至项目
|
||
$(document).off('click','.adminmykanban-operation-but-copy').on('click','.adminmykanban-operation-but-copy',function(){
|
||
var mykanban = layui.tree.getChecked('mykanban');
|
||
var kongjian = layui.tree.getChecked('kongjian');
|
||
var kanbanid = selectkanbanidarr(mykanban);
|
||
var kongjianid = selectkongjianidarr(kongjian);
|
||
var data= kanbanid.concat(kongjianid);
|
||
if(data.length < 1){
|
||
alert('请先选择需要复制的看板!!!');
|
||
return;
|
||
}
|
||
X.parametersopen(data,'copykanban','auto',function(){
|
||
// me.updata(X.DATA['projectid']);
|
||
})
|
||
})
|
||
|
||
function selectkanbanidarr(mykanban){
|
||
var kanbanid =[];
|
||
for(let i in mykanban){
|
||
if(mykanban[i]['children'].length > 0){
|
||
for(let j in mykanban[i]['children']){
|
||
kanbanid.push(mykanban[i]['children'][j]['id']);
|
||
}
|
||
}else {
|
||
kanbanid.push(mykanban[i]['id']);
|
||
}
|
||
|
||
}
|
||
return kanbanid
|
||
};
|
||
|
||
function selectkongjianidarr(kongjian){
|
||
var kongjianid = [];
|
||
for(let i in kongjian){
|
||
if(kongjian[i]['children'].length > 0){
|
||
for(let j in kongjian[i]['children']){
|
||
|
||
// if(kongjian[i]['children'][j]['children'].length > 0){
|
||
// for(let z in kongjian[i]['children'][j]['children']){
|
||
// kongjianid.push(kongjian[i]['children'][j]['children'][z]['id'])
|
||
// }
|
||
// }else {
|
||
kongjianid.push(kongjian[i]['children'][j]['id']);
|
||
// }
|
||
}
|
||
}else {
|
||
kongjianid.push(kongjian[i]['id']);
|
||
}
|
||
}
|
||
return kongjianid
|
||
}
|
||
|
||
},
|
||
|
||
updata:function(id){
|
||
X.api("project/kanban","post",{"_id":id},function(d){
|
||
var kanban = [];
|
||
for(let i in d.kanban){
|
||
var arr = {};
|
||
arr['title'] = d.kanban[i]['name'];
|
||
arr['id'] = d.kanban[i]['_id'];
|
||
if(d.kanban[i]['children'].length > 0){
|
||
var kanbanchidren = [];
|
||
for(let j in d.kanban[i]['children']){
|
||
var drr ={};
|
||
drr['title'] = d.kanban[i]['children'][j]['name'];
|
||
drr['id'] = d.kanban[i]['children'][j]['_id'];
|
||
kanbanchidren.push(drr);
|
||
}
|
||
arr['children'] = kanbanchidren;
|
||
}else {
|
||
arr['children'] = d.kanban[i]['children'];
|
||
}
|
||
kanban.push(arr);
|
||
}
|
||
var spaces = [];
|
||
for(let i in d.spaces){
|
||
var arr = {};
|
||
arr['title'] = d.spaces[i]['name'];
|
||
arr['id'] = d.spaces[i]['_id'];
|
||
if(d.spaces[i]['children'].length > 0){
|
||
var spaceschidren = [];
|
||
for(let j in d.spaces[i]['children']){
|
||
var drr ={};
|
||
drr['title'] = d.spaces[i]['children'][j]['name'];
|
||
drr['id'] = d.spaces[i]['children'][j]['_id'];
|
||
if(d.spaces[i]['children'][j]['isFolder']){
|
||
if(d.spaces[i]['children'][j]['children'].length > 0){
|
||
var spacestwochidren = [];
|
||
for(let z in d.spaces[i]['children'][j]['children']){
|
||
var crr ={};
|
||
crr['title'] = d.spaces[i]['children'][j]['children'][z]['name'];
|
||
crr['id'] = d.spaces[i]['children'][j]['children'][z]['_id'];
|
||
spacestwochidren.push(crr);
|
||
}
|
||
drr['children'] = spacestwochidren;
|
||
}else {
|
||
drr['children'] = d.spaces[i]['children'][j]['children'];
|
||
}
|
||
}
|
||
spaceschidren.push(drr);
|
||
}
|
||
arr['children'] = spaceschidren;
|
||
}else {
|
||
arr['children'] = d.spaces[i]['children'];
|
||
}
|
||
spaces.push(arr);
|
||
}
|
||
|
||
// 渲染数据
|
||
//树形看板
|
||
X.DATA['sxKanBanData'] = kanban;
|
||
X.DATA['sxProjectData'] = spaces;
|
||
|
||
X.treemenu("#adminmykanban-con-mykanban",kanban,'mykanban');
|
||
X.treemenu("#adminmykanban-con-kongjian",spaces,'kongjian');
|
||
});
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/analysis.js
|
||
(function(){
|
||
X.pageLogic['analysis'] = {
|
||
init : function(){
|
||
var me = this;
|
||
// 渲染form样式
|
||
layui.form.render();
|
||
|
||
var dataArr; //分析指标
|
||
var groupeddata;//分组项
|
||
var type2data;
|
||
//var filtersymbols=[];//筛选符号
|
||
// filtersymbols.push(drr);
|
||
var defaultgroupdata; //默认添加分组项里的事件
|
||
var filter_map,quotas_map;
|
||
var data = {
|
||
"events":[],
|
||
"eventView":{
|
||
"cksql":"event",
|
||
"startTime":"",
|
||
"timeParticleSize":"P1D",
|
||
"endTime":"",
|
||
"graphShape":"L0",
|
||
"e_days":0,
|
||
"s_days":7,
|
||
"groupBy":[],
|
||
"uiCommonConfig":{
|
||
"tableSorts":[],
|
||
"chartSort":"num-desc"
|
||
},
|
||
"filts":[],//全局筛选
|
||
"relation":'and',
|
||
"zone_time":'8'//时区
|
||
}
|
||
}
|
||
|
||
var retdata,props;
|
||
|
||
// 日期渲染
|
||
X.daterender("#analtsis-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
// calculationdata();
|
||
})
|
||
|
||
var time = $("#analtsis-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
// X.template("toptab","analysis-zhanwei",X.DATA['projectarr'],function(){
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
|
||
dataArr = d;
|
||
X.api("data_auth/load_prop_quotas","post",{event_name:dataArr[0]['category'][0]['event_name']},function(d){
|
||
retdata = d.staid_quots.concat(d.props);
|
||
props = d.props;
|
||
var defaultindicator = {
|
||
"event_desc":dataArr[0]['category'][0]['event_desc'],
|
||
"event_name":dataArr[0]['category'][0]['event_name'],
|
||
"event_attr":"总次数",
|
||
"event_attr_id":"*",
|
||
"event_attr_type":"",
|
||
"analysisname":'',
|
||
"analysis":'total_count',
|
||
"filts":[],//过滤项
|
||
"relation":'and',
|
||
"customEvent":'',
|
||
"eventNameDisplay":'',//重命名指标
|
||
"format":'float',
|
||
"formatname":'两位小数',
|
||
"is_show" : true
|
||
}
|
||
data.events.push(defaultindicator);
|
||
updataindex(data.events);
|
||
type2data= retdata
|
||
X.api("data_auth/load_filter_props","post",{event_name:dataArr[0]['category'][0]['event_name']},function(val){
|
||
defaultgroupdata = val;
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.eventid && X.DATA.eventid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.eventid);
|
||
if(X.DATA.authority != 'rw'){
|
||
$('.analysis-savereport').hide();
|
||
}else {
|
||
$('.analysis-saveas').show();
|
||
}
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
})
|
||
})
|
||
// groupeddata = d.group_by;
|
||
})
|
||
// });
|
||
|
||
|
||
// 渲染选择时间下拉框
|
||
layui.dropdown.render({
|
||
elem: ".analysis-navigation-bar-datetime"
|
||
,data: X.DATA.timezone
|
||
,click: function(obj){
|
||
$(".analysis-navigation-bar-datetime").html(obj.title);
|
||
data['eventView']['zone_time'] = obj.id;
|
||
}
|
||
});
|
||
|
||
// 伸缩左侧选项
|
||
$(".analysis-con-left-shrink").click(function(){
|
||
if($(".analysis-con-left").css('left') == "auto" || $(".analysis-con-left").css('left') == "0px"){
|
||
$(".analysis-con-left").css("position","absolute");
|
||
$(".analysis-con-left").css("left","-535px");
|
||
$(".analysis-con-left-shrink").css("transform","rotate(180deg)");
|
||
$(".analysis-con-right").css("width","calc(100% - 15px)");
|
||
$(".analysis-con-right").css("margin-left","16px");
|
||
}else {
|
||
$(".analysis-con-left").css("position","relative");
|
||
$(".analysis-con-left").css("left","auto");
|
||
$(".analysis-con-left-shrink").css("transform","rotate(3600deg)");
|
||
$(".analysis-con-right").css("width","calc(100% - 550px)");
|
||
$(".analysis-con-right").css("margin-left","0px");
|
||
}
|
||
});
|
||
|
||
//已存报表
|
||
var baobiaodata;
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
if(d){
|
||
backfilldata(d)
|
||
}
|
||
})
|
||
});
|
||
|
||
// 反向填充数据
|
||
function backfilldata(d){
|
||
|
||
data = d.query;
|
||
// filtersymbols = data.cachedata.filtersymbols;
|
||
var time = $("#analtsis-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
baobiaodata = d;
|
||
|
||
if(d.query.events.length > 0){
|
||
$(".analysis-overall").show();
|
||
}else {
|
||
$(".analysis-overall").hide();
|
||
}
|
||
updataindex(d.query.events);
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",d.query.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",d.query['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
calculationdata();
|
||
};
|
||
|
||
// 更新指标
|
||
function updataindex(indexdata){
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",indexdata,".analysis-con-left-screen-list-box",function(){
|
||
var sidebar = document.getElementById('analysis-con-left-screen-list-box');
|
||
new Sortable(sidebar, {
|
||
handle: '.analysis-num', // handle class
|
||
animation: 150,
|
||
onUpdate:function(evt){
|
||
var newIndex = evt.newIndex;
|
||
var oldIndex = evt.oldIndex;
|
||
let item = data.events.splice(oldIndex, 1); // arr删除2,把2给item
|
||
data.events.splice(newIndex, 0, item[0]);
|
||
updataindex(data.events);
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 显示隐藏
|
||
$(document).off("click",".analysis-isshow-click").on("click",".analysis-isshow-click",function(){
|
||
var index = $(this).attr("data-index");
|
||
var type = $(this).attr("data-type");
|
||
var isshow = (type == "true") ? false : true;
|
||
data['events'][index]['is_show'] = isshow;
|
||
updataindex(data.events);
|
||
});
|
||
|
||
// 切换为指标公式或组合
|
||
$(document).off('click','.analysis-gongshi').on('click','.analysis-gongshi',function(){
|
||
var index = $(this).attr("data-index");
|
||
var type = $(this).attr("data-type");
|
||
data['events'][index]['customType'] = type;
|
||
$("#analysis-con-left-screen-list-left-box-"+index).hide();
|
||
$("#analysis-custom-box-"+index).show();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-zhibiao").show();
|
||
});
|
||
|
||
// 切换为指标选择
|
||
$(document).off('click','.analysis-zhibiao').on('click','.analysis-zhibiao',function(){
|
||
var index = $(this).attr("data-index");
|
||
$("#analysis-con-left-screen-list-left-box-"+index).show();
|
||
$("#analysis-custom-box-"+index).hide();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-gongshi").show();
|
||
});
|
||
|
||
//复制指标
|
||
$(document).off('click','.analysis-fuzhi').on('click','.analysis-fuzhi',function(){
|
||
var index = $(this).attr("data-index");
|
||
var arr = data.events[index];
|
||
data.events.push(arr);
|
||
updataindex(data.events);
|
||
var num = data.events.length;
|
||
|
||
// filtersymbols[num] = filtersymbols[index];
|
||
});
|
||
|
||
//重命名指标
|
||
$(document).off('click','.analysis-chongmingming').on('click','.analysis-chongmingming',function() {
|
||
var index = $(this).attr('data-index');
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index).show();
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-chongmingming-del").show();
|
||
});
|
||
|
||
//删除重命名
|
||
$(document).off('click','.analysis-chongmingming-del').on('click','.analysis-chongmingming-del',function() {
|
||
var index = $(this).attr("data-index");
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index).hide();
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-"+index+" "+"input").val('');
|
||
$(this).hide();
|
||
$("#analysis-con-left-screen-list-right-"+index+" "+".analysis-chongmingming").show();
|
||
});
|
||
|
||
// 设置一级事件
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function() {
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index')
|
||
X.querycriteriapop(dataArr,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.id;
|
||
obj.html(htmlstring);
|
||
data['events'][index]['event_desc'] = val.id;
|
||
data['events'][index]['event_name'] = val.name;
|
||
})
|
||
});
|
||
//设置一级事件中第二个参数
|
||
$(document).off('click','.analysis-zhibiao-list-type2').on('click','.analysis-zhibiao-list-type2',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
if(type2data.length >0){
|
||
X.parametersopen(type2data,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
$("#analysis-zhibiao-list-type2-"+index).html(val.title);
|
||
|
||
data['events'][index]['event_attr'] = val.title;
|
||
data['events'][index]['event_attr_id'] = val.id;
|
||
data['events'][index]['event_attr_type'] = val.data_type;
|
||
|
||
if(val.data_type && val.data_type != null){
|
||
$("#analysis-zhibiao-list-type3-"+index).show();
|
||
$("#analysis-zhibiao-list-type3-"+index).html(quotas_map[val.data_type][0]['title']);
|
||
data['events'][index]['analysisname'] = quotas_map[val.data_type][0]['title'];
|
||
data['events'][index]['analysis'] = quotas_map[val.data_type][0]['id'];
|
||
}else {
|
||
$("#analysis-zhibiao-list-type3-"+index).hide();
|
||
data['events'][index]['analysis'] = val.analysis;
|
||
}
|
||
updataindex(data.events);
|
||
}
|
||
})
|
||
}
|
||
});
|
||
//设置一级事件中第三个参数
|
||
$(document).off('click','.analysis-zhibiao-condition').on('click','.analysis-zhibiao-condition',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['events'][index]['event_attr_type'];
|
||
|
||
X.parametersopen(quotas_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$("#analysis-zhibiao-list-type3-"+index).html(val.title);
|
||
data['events'][index]['analysisname'] = val.title;
|
||
data['events'][index]['analysis'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.ta-property-select').on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
// console.log(val);
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
// filtersymbols[index][indexs] = val.category;
|
||
data['events'][index]['filts'][indexs]['columnDesc'] = htmlstring;
|
||
data['events'][index]['filts'][indexs]['columnName'] = val.id;
|
||
data['events'][index]['filts'][indexs]['data_type'] = val.type;
|
||
data['events'][index]['filts'][indexs]['tableType'] = val.table_type;
|
||
if(val.type == 'user_label'){
|
||
data['events'][index]['filts'][indexs]['comparator_name'] = "是";
|
||
data['events'][index]['filts'][indexs]['comparator'] = 'in';
|
||
}
|
||
updataindex(data.events);
|
||
})
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = data['events'][index]['filts'][indexs]['data_type'];
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['filts'][indexs]['comparator_name'] = val.title;
|
||
data['events'][index]['filts'][indexs]['comparator'] = val.id;
|
||
}
|
||
})
|
||
});
|
||
|
||
// 添加筛选项
|
||
$(document).off('click','.analysis-shaix-jinting').on('click','.analysis-shaix-jinting',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 添加筛选项
|
||
function addscreen(index){
|
||
X.api('data_auth/load_filter_props',"post",{event_name:data['events'][index]["event_name"]},function(d){
|
||
|
||
var arr = {
|
||
"columnDesc":d[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":d[0]['category'][0]['id'],//事件id
|
||
"comparator_name":filter_map[d[0]['category'][0]['data_type']][0]['title'],//选择符号中文显示
|
||
"comparator":filter_map[d[0]['category'][0]['data_type']][0]['id'],//符号id
|
||
"data_type":d[0]['category'][0]['data_type'],
|
||
"ftv":[],//条件
|
||
"strftv":'',//字符串显示条件
|
||
"tableType": d[0]['id']
|
||
} //筛选数据
|
||
data['events'][index]['filts'].push(arr);
|
||
updataindex(data.events);
|
||
})
|
||
};
|
||
|
||
//监听重命名指标
|
||
$(document).off('change','.analysis-con-left-screen-list-left-zhibiaoname input').on('change','.analysis-con-left-screen-list-left-zhibiaoname input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var txt = $(this).val();
|
||
|
||
data['events'][index]['eventNameDisplay'] = txt;
|
||
});
|
||
|
||
$(document).off("click",".analysis-zhibiao-list-type4").on("click",".analysis-zhibiao-list-type4",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var comparator = obj.attr("data-comparator");
|
||
var columnName;
|
||
if(indexs != undefined){
|
||
columnName = data['events'][index]['filts'][indexs]['columnName'];
|
||
}else {
|
||
columnName = data['eventView']['filts'][index]['columnName']
|
||
}
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(indexs != undefined){
|
||
data['events'][index]['filts'][indexs]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['events'][index]['filts'][indexs]['ftv'] = arr;
|
||
updataindex(data.events)
|
||
}else {
|
||
data['eventView']['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['eventView']['filts'][index]['ftv'] = arr;
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
}
|
||
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
// 监听文本框
|
||
$(document).off('change','.analysis-zhibiao-list-type4 input').on('change','.analysis-zhibiao-list-type4 input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
if(data['events'][index]['filts'][indexs]){
|
||
data['events'][index]['filts'][indexs]['ftv']=valarr;
|
||
data['events'][index]['filts'][indexs]['strftv']=val;
|
||
}else {
|
||
|
||
}
|
||
|
||
});
|
||
|
||
// 且和或切换
|
||
$(document).off('click','.analysis-con-left-screen-list-right-screen-qh-tit').on("click",".analysis-con-left-screen-list-right-screen-qh-tit",function(){
|
||
var html = $(this).html(); //relation筛选条件的关系
|
||
var index = $(this).attr("data-index");
|
||
if(html == "且"){
|
||
$(this).html('或');
|
||
data['events'][index]['relation'] = 'or'
|
||
}else {
|
||
$(this).html('且');
|
||
data['events'][index]['relation'] = 'and'
|
||
}
|
||
});
|
||
|
||
// 添加条件按钮
|
||
$(document).off('click','.analysis-zhibiao-updata').on('click',".analysis-zhibiao-updata",function(){
|
||
// addindex();
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 删除二级筛选项
|
||
$(document).off('click','.analysis-zhibiao-list-del').on('click','.analysis-zhibiao-list-del',function(){
|
||
// var id = "analysis-zhibiao-list-mar-"+$(this).attr("data-twonum");
|
||
// $("#"+id).remove();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-twonum");
|
||
// filtersymbols[index].splice(indexs,1);
|
||
data.events[index]['filts'].splice(indexs,1);
|
||
updataindex(data.events);
|
||
});
|
||
|
||
// 添加指标
|
||
function addindex(){
|
||
var defaultindicator = {
|
||
"event_desc":dataArr[0]['category'][0]['event_desc'],
|
||
"event_name":dataArr[0]['category'][0]['event_name'],
|
||
"event_attr":"总次数",
|
||
"event_attr_id":"*",
|
||
"event_attr_type":"",
|
||
"analysisname":'',
|
||
"analysis":'total_count',
|
||
"filts":[],//过滤项
|
||
"relation":'and',
|
||
"customEvent":'',
|
||
"eventNameDisplay":'',//重命名指标
|
||
"format":'float',
|
||
"formatname":'两位小数',
|
||
"is_show": true
|
||
}
|
||
data['events'].push(defaultindicator);
|
||
|
||
updataindex(data.events);
|
||
var index = data.events.length - 1;
|
||
|
||
$(".analysis-del").show() //显示删除按钮
|
||
var drr = [];
|
||
if(data.events.length > 1){
|
||
$(".analysis-overall").show();
|
||
}else {
|
||
$(".analysis-overall").hide();
|
||
}
|
||
};
|
||
|
||
//添加按钮
|
||
$(document).on('click','.analysis-jia1',function(){
|
||
|
||
addindex();
|
||
|
||
});
|
||
//添加指标按钮
|
||
$(document).on('click','.analysis-bottom-jia1',function(){
|
||
|
||
addindex();
|
||
|
||
});
|
||
|
||
//删除指标
|
||
$(document).off('click','.analysis-del').on('click',".analysis-del",function(){
|
||
if(data['events'].length != 1){
|
||
var index = $(this).attr("data-index");
|
||
data['events'].splice(index,1);
|
||
if(data['events'].length == 1){
|
||
$(".analysis-del").hide(); //隐藏删除按钮
|
||
$(".analysis-overall").hide();
|
||
}
|
||
updataindex(data.events);
|
||
}
|
||
});
|
||
|
||
|
||
$(".analysis-custom-event-box .analysis-custom-event-txt").blur(function(){
|
||
$(this).css("border-bottom","0px");
|
||
});
|
||
|
||
$(document).off('click','.analysis-custom-event-box .analysis-custom-event-txt').on('blur','.analysis-custom-event-box .analysis-custom-event-txt',function(){
|
||
// $(this).css("border-bottom","1px solid #3d90ff");
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
data['events'][index]['customEvent'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.analysis-con-left-screen-list-left-zhibiaoname2 input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname2 input',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['events'][index]['eventNameDisplay'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.ant-select-selector').on('click','.ant-select-selector',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var downlist = [
|
||
{title:'两位小数',id:'float'},
|
||
{title:'百分比',id:'percent'},
|
||
{title:'取整',id:'integer'},
|
||
];
|
||
X.parametersopen(downlist,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['format'] = val.id;
|
||
data['events'][index]['formatname'] = val.title;
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
//分组项
|
||
var cat = "event";
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function(){
|
||
var index = data['eventView']['groupBy'].length;
|
||
for(let i in defaultgroupdata){
|
||
if(defaultgroupdata[i]['category'].length > 0){
|
||
var drr = {
|
||
"columnDesc":defaultgroupdata[i]['category'][index]['title'],//事件中文显示
|
||
"columnName":defaultgroupdata[i]['category'][index]['id'],//事件id
|
||
'data_type':defaultgroupdata[i]['category'][index]['data_type'],//类型
|
||
'tableType': defaultgroupdata[i]['id'],
|
||
"ftv":[],//条件
|
||
"section":''//区间
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
data.eventView.groupBy.push(drr);
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data.eventView.groupBy[index]['columnDesc'] = val.title;
|
||
data.eventView.groupBy[index]['columnName'] = val.id;
|
||
data.eventView.groupBy[index]['data_type'] = val.type;
|
||
data.eventView.groupBy[index]['tableType'] = val.table_type;
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-granularity').on("click",".analysis-granularity",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var type = obj.attr("data_type");
|
||
var index = obj.attr("data-index");
|
||
var arr;
|
||
if(type == 'date'){
|
||
arr = {
|
||
data:[
|
||
{'name':"按天",'id':'day','checked':true},
|
||
{'name':"按分钟",'id':'min','checked':false},
|
||
{'name':"按小时",'id':'hour','checked':false},
|
||
{'name':"按周",'id':'week','checked':false},
|
||
{'name':"按月",'id':'month','checked':false}
|
||
],
|
||
default: data.eventView.groupBy[index]['ftv']
|
||
|
||
}
|
||
}else {
|
||
arr ={
|
||
data:[
|
||
{'name':"按元素",'id':'0','checked':true},
|
||
{'name':"按列表整体",'id':'1','checked':false},
|
||
{'name':"按元素集合",'id':'2','checked':false}
|
||
],
|
||
default: data.eventView.groupBy[index]['ftv']
|
||
}
|
||
}
|
||
|
||
X.querycriteriapop(arr,'groupitem',offset.left,offset.top+obj.height(),function(val){
|
||
data.eventView.groupBy[index]['ftv'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).on("click",".analysis-section",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var sectionid = obj.attr("data-sectionid");
|
||
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'groupeditemspop',
|
||
extData : sectionid,
|
||
callback : function(val){
|
||
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
$(document).on('click','.analysis-action-right',function(){
|
||
var index = $(this).attr('data-index');
|
||
data.eventView.groupBy.splice(index,1);
|
||
X.laytpldata("#analysis-gpmain___3YGfw-dot",data.eventView.groupBy,".analysis-gpmain___3YGfw");
|
||
});
|
||
|
||
$(document).on('click','.analysis-event-splitting',function(){
|
||
|
||
});
|
||
|
||
// 全局筛选
|
||
var filtsftvdata=[];
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
|
||
var drr={
|
||
"columnDesc":defaultgroupdata[0]['category'][0]['title'],//事件中文显示 columnDesc
|
||
"columnName":defaultgroupdata[0]['category'][0]['id'],//事件id
|
||
'data_type':defaultgroupdata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"tableType":defaultgroupdata[0]['id']
|
||
};
|
||
data['eventView']['filts'].push(drr);//上传全局数据
|
||
filtsftvdata.push(defaultgroupdata[0]['category'][0]['category'])
|
||
|
||
$(".analysis-overall-situation-left-box").show();
|
||
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['eventView']['filts'][index]['data_type'];
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$(this).html(val.title);
|
||
data['eventView']['filts'][index]['comparator_name'] = val.title;
|
||
data['eventView']['filts'][index]['comparator'] = val.id;
|
||
if(val.id == "range"){
|
||
data['eventView']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-del').on('click',".analysis-overall-situation-del",function(){
|
||
var index = $(this).attr("data-index");
|
||
data['eventView']['filts'].splice(index,1);
|
||
filtsftvdata.splice(index,1);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
// $(".analysis-overall-situation-left-box").hide();
|
||
}
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['eventView']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['eventView']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
|
||
$(document).off('click','.analysis-overall-situation-left-guanxi').on('click','.analysis-overall-situation-left-guanxi',function(){
|
||
var html = $(this).html(); //relation筛选条件的关系
|
||
if(html == "且"){
|
||
$(this).html('或');
|
||
data['eventView']['relation'] = 'or'
|
||
}else {
|
||
$(this).html('且');
|
||
data['eventView']['relation'] = 'and'
|
||
}
|
||
});
|
||
|
||
// 全局属性选择
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click',".analysis-overall-situation-attr",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(defaultgroupdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['columnDesc'] = val.title;
|
||
data['eventView']['filts'][index]['columnName'] = val.id;
|
||
data['eventView']['filts'][index]['data_type'] = val.type;
|
||
data['eventView']['filts'][index]['comparator_name'] = '等于';
|
||
data['eventView']['filts'][index]['comparator'] = '==';
|
||
data['eventView']['filts'][index]['tableType'] = val.table_type;
|
||
filtsftvdata[index]=val.category;
|
||
|
||
if(val.type == 'user_label'){
|
||
data['eventView']['filts'][index]['comparator_name'] = "是";
|
||
data['eventView']['filts'][index]['comparator'] = 'in';
|
||
}
|
||
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
// analysisdown();
|
||
})
|
||
});
|
||
|
||
|
||
$(document).off("click",".analysis-overall-situation-input").on("click",".analysis-overall-situation-input",function(event){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var comparator = obj.attr("data-comparator");
|
||
var columnName = data['eventView']['filts'][index]['columnName'];
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
|
||
if(comparator == "in"){
|
||
if(data['eventView']['filts'][index]['strftv'] == "" ){
|
||
var strftv = val.title;
|
||
data['eventView']['filts'][index]['ftv'].push(val.id);
|
||
}else {
|
||
var strftv = data['eventView']['filts'][index]['strftv'] + "," + val.title;
|
||
data['eventView']['filts'][index]['ftv'].push(val.id);
|
||
}
|
||
data['eventView']['filts'][index]['strftv'] = strftv;
|
||
}else {
|
||
data['eventView']['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['eventView']['filts'][index]['ftv'] = arr;
|
||
}
|
||
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data['eventView']['filts'],".analysis-overall-situation-list-box",function(){
|
||
renderdate();
|
||
});
|
||
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(event){
|
||
var index = $(this).attr("data-index");
|
||
var comparator = $(this).attr("data-comparator");
|
||
if(comparator != 'in'){
|
||
var val = $(this).val();
|
||
if(val != ""){
|
||
var valarr = val.split(",");
|
||
data['eventView']['filts'][index]['ftv']=valarr;
|
||
data['eventView']['filts'][index]['strftv']=val;
|
||
}
|
||
}
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['eventView']['filts'][index]['ftv'][0] = val;
|
||
data['eventView']['filts'][index]['section'][0] = val;
|
||
}else {
|
||
data['eventView']['filts'][index]['ftv'][1] = val;
|
||
data['eventView']['filts'][index]['section'][1] = val;
|
||
}
|
||
});
|
||
|
||
// 时间粒度
|
||
X.laydropdown('.analtsis-timeParticleSize',X['DATA']['screenlist']['event'],function(d){
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['timeParticleSize'] = d.id;
|
||
calculationdata();
|
||
});
|
||
|
||
X.layuidate('#analysis-overall-situation-time1');
|
||
|
||
// 计算
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
calculationdata();
|
||
});
|
||
|
||
var querydata;//查询数据
|
||
$(document).on('click','.analtsis-chart-switch-box .analtsis-chart-switch',function(){
|
||
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '趋势图'){trendchart(querydata)}
|
||
else if($(this).attr('title') == '堆积图'){stackingdiagram(querydata);}
|
||
else if($(this).attr('title') == '累计图'){}
|
||
else if($(this).attr('title') == '分布图'){distributionmap(querydata)}
|
||
else if($(this).attr('title') == '饼状分布'){}
|
||
}else{
|
||
// layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
|
||
});
|
||
|
||
//堆积图
|
||
function stackingdiagram(d){
|
||
var xAxisData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['groups']){
|
||
var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
xAxisData.push(pj);
|
||
}
|
||
}
|
||
var seriesData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['values']){
|
||
var arr = {
|
||
name: '',
|
||
type: 'line',
|
||
stack: '总量',
|
||
areaStyle: {},
|
||
emphasis: {
|
||
focus: 'series'
|
||
},
|
||
data: d[i]['values'][z]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
if(xAxisData.length > 0){
|
||
for(let i in seriesData){
|
||
seriesData[i]['name'] = xAxisData[i];
|
||
}
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
},
|
||
formatter:function(params){
|
||
var axisIndex = params[0]['axisIndex'];
|
||
if(d[axisIndex]['proid_name'] && d[axisIndex]['proid_name'].length > 0){
|
||
var index = params[0]['dataIndex'];
|
||
var money = d[axisIndex]['proid_money'][index];
|
||
var name = d[axisIndex]['proid_name'][index];
|
||
var html = name+'<br/>'+'次数:'+ params[axisIndex]['data']+"<br/>"+'总金额:'+money;
|
||
}else {
|
||
var html = params[0]['axisValue']+'<br/>';
|
||
for(let i in params){
|
||
html+= params[i]['seriesName']+':'+ params[i]['value']+"<br/>"
|
||
}
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: xAxisData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: d[0]['date_range']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//趋势图
|
||
function trendchart(d){
|
||
var xAxisData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['groups']){
|
||
var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
xAxisData.push(pj);
|
||
}
|
||
}
|
||
var seriesData=[];
|
||
for(let i in d){
|
||
for(let z in d[i]['values']){
|
||
var arr = {
|
||
name: '',
|
||
type: 'line',
|
||
data: d[i]['values'][z]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
if(xAxisData.length > 0){
|
||
for(let i in seriesData){
|
||
seriesData[i]['name'] = xAxisData[i];
|
||
}
|
||
}
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: xAxisData
|
||
},
|
||
// toolbox: {
|
||
// feature: {
|
||
// saveAsImage: {}
|
||
// }
|
||
// },
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: d[0]['date_range']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//分布图
|
||
function distributionmap(d){
|
||
var legendData =[];
|
||
var xAxisData=[];
|
||
var seriesData=[];
|
||
if(jQuery.isEmptyObject(d[0]["groups"])){
|
||
for(let i in d){
|
||
xAxisData.push(d[i]['event_name']);
|
||
legendData.push(d[i]['event_name']);
|
||
var num =0;
|
||
for(let j in d[i]['values'][i]){
|
||
num = num + d[i]['values'][i][j]
|
||
}
|
||
var arr = {
|
||
name: d[i]['event_name'],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
}else {
|
||
for(let i in d){
|
||
xAxisData.push(d[i]['event_name']);
|
||
for(let j in d[i]['groups']){
|
||
var num =0;
|
||
for(let z in d[i]['values'][j]){
|
||
num = parseFloat(num) + parseFloat(d[i]['values'][j][z])
|
||
}
|
||
if(i > 0){
|
||
for(let q in seriesData){
|
||
if(d[i]['groups'][j] == seriesData[q]['name']){
|
||
seriesData[q]['data'].push(num);
|
||
}else {
|
||
var arr = {
|
||
name: d[i]['groups'][j],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
}
|
||
}else {
|
||
var arr = {
|
||
name: d[i]['groups'][j],
|
||
type: 'bar',
|
||
barWidth : 30,
|
||
data: [],
|
||
}
|
||
arr['data'].push(num);
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
}
|
||
// for(let i in d){
|
||
// for(let z in d[i]['groups']){
|
||
// var pj = d[i]['event_name']+d[i]['groups'][z];
|
||
// xAxisData.push(pj);
|
||
// }
|
||
// }
|
||
// var seriesData=[];
|
||
// for(let i in d){
|
||
// for(let z in d[i]['values']){
|
||
// var arr = {
|
||
// name: '',
|
||
// type: 'bar',
|
||
// data: d[i]['values'][z]
|
||
// }
|
||
// seriesData.push(arr);
|
||
// }
|
||
// }
|
||
// if(xAxisData.length > 0){
|
||
// for(let i in seriesData){
|
||
// seriesData[i]['name'] = xAxisData[i];
|
||
// }
|
||
// }
|
||
// return;
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
}
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
legend: {
|
||
data: legendData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
axisTick: {show: false},
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//表格
|
||
function tabledata(d){
|
||
var titledata,condata=[];
|
||
for(let i in d){
|
||
titledata= $.extend(true,[],d[0]['date_range']) ;
|
||
if(d[i]['groups']['length'] != 0){
|
||
titledata.unshift('指标','分组','阶段总和');
|
||
for(let j in d[i]['values']){
|
||
var arr;
|
||
arr = $.extend(true,[],d[i].values[j]);
|
||
arr.unshift(d[i]['event_name'],d[i]['groups'][j],d[i]['sum'][j]);
|
||
condata.push(arr);
|
||
}
|
||
// for(let j in condata){
|
||
// condata[j].splice(1,0,d[i]['groups'][j]);
|
||
// }
|
||
|
||
}else {
|
||
titledata.unshift('指标','阶段总和');
|
||
var arr;
|
||
arr = $.extend(true,[],d[i].values[0])
|
||
arr.unshift(d[i]['event_name'],d[i]['sum'][0]);
|
||
condata.push(arr);
|
||
}
|
||
}
|
||
X.laytpldata("#table-fenxi-th-dot",titledata,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",condata ,".table-fenxi-td");
|
||
};
|
||
|
||
function calculationdata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/event_model","post",dataArr,function(d){
|
||
querydata = d;
|
||
if(d != "查无数据"){
|
||
if(d[0].values.length > 0 ){
|
||
updata();
|
||
tabledata(d);
|
||
$(".chawushuj").hide();
|
||
}else {
|
||
$("#analysis-echarts").empty();
|
||
layer.msg("无数据");
|
||
}
|
||
}else {
|
||
$("#analysis-echarts").empty();
|
||
|
||
$(".table-fenxi-td").html("");
|
||
$(".chawushuj").show();
|
||
// layer.msg("无数据");
|
||
|
||
}
|
||
|
||
})
|
||
};
|
||
|
||
function updata(){
|
||
var tit = $(".select-chart").attr("title");
|
||
if(tit == '趋势图'){trendchart(querydata)}
|
||
else if(tit == '堆积图'){stackingdiagram(querydata);}
|
||
else if(tit == '累计图'){}
|
||
else if(tit == '分布图'){distributionmap(querydata)}
|
||
else if(tit == '饼状分布'){}
|
||
};
|
||
|
||
// 保存报表
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
baobiaodata['saveas']= 0;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
//另存为
|
||
$(document).off('click','.analysis-saveas').on('click','.analysis-saveas',function(){
|
||
baobiaodata['saveas']= 1;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
|
||
});
|
||
|
||
// 下载
|
||
$(document).off('click','.download-table').on('click','.download-table',function(){
|
||
// console.log(11111);
|
||
X.download('ck/event_model_export',data,'事件分析');
|
||
});
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
},
|
||
|
||
// 保存报表
|
||
// savereport:function(d){
|
||
|
||
// }
|
||
|
||
};
|
||
})();
|
||
|
||
|
||
|
||
// srczip/logic/apiadmin.js
|
||
(function(){
|
||
X.pageLogic['apiadmin'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
me.updataapilist();
|
||
$(document).off('click','.eventattradmin-actions___141YT').on('click','.eventattradmin-actions___141YT',function(){
|
||
X.parametersopen('','apiadmin_add','auto',function(){
|
||
me.updataapilist();
|
||
})
|
||
});
|
||
|
||
layui.table.on('tool(apiadminntest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'edit'){
|
||
X.parametersopen(data,"apiadmin_add",'auto',function(){
|
||
me.updataapilist();
|
||
})
|
||
}else if(obj.event === 'del'){
|
||
layer.confirm('确认删除当前api吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
var arr = [];
|
||
arr.push(data._id);
|
||
X.api("authz/del_api",'post',{ids:arr},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
me.updataapilist();
|
||
})
|
||
});
|
||
}
|
||
})
|
||
|
||
},
|
||
updataapilist:function(){
|
||
X.laytabledata("#apiadmin-table","authz/api_list",[[
|
||
{field:'name', title: '标题', width: '10%', sort: true}
|
||
,{field:'path', title: '路径'}
|
||
,{field:'desc', title: '简介',width: '60%'}
|
||
,{fixed: 'right', title:'操作', toolbar: '#apiadminbarDemo', width:117}
|
||
]],null,'685');
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/apiadmin_add.js
|
||
(function(){
|
||
X.pageLogic['apiadmin_add'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
// console.log(data);
|
||
if(data){
|
||
$("#path").val(data.path);
|
||
$("#name").val(data.name);
|
||
$("#desc").val(data.desc);
|
||
}
|
||
$(document).off('click','.newwenjian-qd').on('click','.newwenjian-qd',function(){
|
||
if($("#path").val() == "" && $("#name").val() == ""){
|
||
layer.msg('标题,路径为必填项');
|
||
return;
|
||
}
|
||
var arr = {
|
||
"path": $("#path").val(),
|
||
"name": $("#name").val(),
|
||
"desc": $("#desc").val()
|
||
}
|
||
if(!data){
|
||
X.api('authz/add_api','post',arr,function(d){
|
||
layer.closeAll();
|
||
X.pageLogic.apiadmin.updataapilist();
|
||
});
|
||
}else {
|
||
arr['id'] = data['_id'];
|
||
X.api('authz/edit_api','post',arr,function(d){
|
||
layer.closeAll();
|
||
X.pageLogic.apiadmin.updataapilist();
|
||
});
|
||
}
|
||
|
||
});
|
||
|
||
$(document).off('click','.newwenjian-qx').on('click','.newwenjian-qx',function(){
|
||
layer.closeAll();
|
||
|
||
});
|
||
|
||
$(document).off('click','.newwenjian-cha').on('click','.newwenjian-cha',function(){
|
||
layer.closeAll();
|
||
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/attribute.js
|
||
(function(){
|
||
X.pageLogic['attribute'] = {
|
||
init : function(){
|
||
|
||
var data ={
|
||
"eventView":{
|
||
"cksql":'user_property',
|
||
"groupBy":[
|
||
|
||
],
|
||
"userCrowds":[
|
||
|
||
]
|
||
},
|
||
"events":{
|
||
"analysis":"",
|
||
"analysisName":"",
|
||
"eventNameDisplay":"",
|
||
"filts":[
|
||
|
||
],
|
||
"quota":"",
|
||
"quotaDesc":"",
|
||
"quotatype":"",
|
||
"relation":"and",
|
||
"tableType":"user"
|
||
}
|
||
};
|
||
|
||
// 分析属性控制重命名
|
||
$(document).off('click','.analysis-chongmingming').on('click','.analysis-chongmingming',function(){
|
||
$('.analysis-con-left-screen-list-left-zhibiaoname').show();
|
||
$(this).hide();
|
||
$('.analysis-chongmingming-del').show();
|
||
});
|
||
|
||
$(document).off('click','.analysis-chongmingming-del').on('click','.analysis-chongmingming-del',function(){
|
||
$('.analysis-con-left-screen-list-left-zhibiaoname').hide();
|
||
$(this).hide();
|
||
$('.analysis-chongmingming').show();
|
||
});
|
||
|
||
//用户属性数据请求
|
||
var user_attr = [];
|
||
var quotas_map = [];
|
||
var filter_map = [];
|
||
var user_data = []; //分组项,用户符合,人群对比数据格式
|
||
X.api("data_auth/user_property","get",{},function(val){
|
||
for(let i in val){
|
||
var arr = {
|
||
id : val[i]['name'],
|
||
data_type : val[i]['data_type'],
|
||
title : val[i]['name']
|
||
};
|
||
user_attr.push(arr);
|
||
}
|
||
data['events']['quota'] = user_attr[0]['id'];
|
||
data['events']['quotaDesc'] = user_attr[0]['title'];
|
||
data['events']['quotatype'] = user_attr[0]['data_type'];
|
||
$('.ant-dropdown-trigger').html(user_attr[0]['title']);
|
||
|
||
var arr = {
|
||
category: user_attr,
|
||
id:'',
|
||
title:'用户属性'
|
||
}
|
||
user_data.push(arr);
|
||
|
||
X.api("data_auth/quotas_map","get",{},function(val){
|
||
quotas_map = val;
|
||
if(user_attr[0]['data_type'] == ""){
|
||
$('.analysis-choicetypename').hide();
|
||
}else {
|
||
$('.analysis-choicetypename').html(quotas_map[user_attr[0]['data_type']][0]['title']);
|
||
data['events']['analysis'] = quotas_map[user_attr[0]['data_type']][0]['id'];
|
||
data['events']['analysisName'] = quotas_map[user_attr[0]['data_type']][0]['title'];
|
||
}
|
||
})
|
||
|
||
X.api("data_auth/filter_map","get",{},function(val){
|
||
filter_map = val;
|
||
})
|
||
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.user_propertyid && X.DATA.user_propertyid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.user_propertyid);
|
||
if(X.DATA.authority != 'rw'){
|
||
$('.analysis-savereport').hide();
|
||
}else{
|
||
$('.analysis-saveas').hide();
|
||
}
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
|
||
});
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 分析属性
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.parametersopen(user_attr,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
obj.html(val.title);
|
||
data['events']['quota'] = val.id;
|
||
data['events']['quotaDesc'] = val.title;
|
||
data['events']['quotatype'] = val.data_type;
|
||
if(val.data_type == ""){
|
||
$('.analysis-choicetypename').hide();
|
||
}else {
|
||
$('.analysis-choicetypename').show();
|
||
data['events']['analysis'] = quotas_map[val.data_type][0].id;
|
||
data['events']['analysisDesc'] = quotas_map[val.data_type][0].title;
|
||
$('.analysis-choicetypename').html(quotas_map[val.data_type][0]['title']);
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.parametersopen(quotas_map[data['events']['quotatype']],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
obj.html(val.title);
|
||
data['events']['analysis'] = val.id;
|
||
data['events']['analysisDesc'] = val.title;
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-list-left-zhibiaoname input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname input',function(){
|
||
data['events']['eventNameDisplay'] = $(this).val();
|
||
});
|
||
|
||
// 分组项
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function(){
|
||
var arr = {
|
||
"columnDesc": user_data[0]['category'][0]['title'],//事件中文显示
|
||
"columnName": user_data[0]['category'][0]['id'],//事件id
|
||
'data_type': user_data[0]['category'][0]['data_type'],//类型
|
||
'table_type': "",
|
||
"ftv":'',//条件
|
||
"intervalType":'def',
|
||
"quotaIntervalArr":[]
|
||
};
|
||
data['eventView']['groupBy'].push(arr);
|
||
if(data['eventView']['groupBy'].length >= 2){
|
||
$(this).hide();
|
||
}
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
});
|
||
|
||
$(document).off('click','.analysis-action-right').on('click','.analysis-action-right',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['eventView']['groupBy'].splice(index,1);
|
||
if(data['eventView']['groupBy'].length < 2){
|
||
$(".analysis-footadd___2D4YB").show();
|
||
}
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr('data-index');
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(user_data,'category',offset.left,offset.top+obj.height(),function(val){
|
||
// console.log(val);
|
||
obj.html(val.title);
|
||
data['eventView']['groupBy'][index]['columnName'] = val.id;
|
||
data['eventView']['groupBy'][index]['columnDesc'] = val.title;
|
||
data['eventView']['groupBy'][index]['data_type'] = val.type;
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-ta-property-range').on('click','.analysis-ta-property-range',function(){
|
||
var index = $(this).attr('data-index');
|
||
var sectionid = data['eventView']['groupBy'][index];
|
||
X.parametersopen(sectionid,'groupeditemspop',"auto",function(val){
|
||
data['eventView']['groupBy'][index]['intervalType'] = val.type;
|
||
if(val.type == "user_defined"){
|
||
data['eventView']['groupBy'][index]['quotaIntervalArr'] = val.quotaIntervalArr;
|
||
}
|
||
})
|
||
});
|
||
|
||
//且用户符合
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var drr={
|
||
"columnDesc":user_data[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":user_data[0]['category'][0]['id'],//事件id
|
||
'data_type':user_data[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"table_type":user_data[0]['id']
|
||
};
|
||
|
||
data['events']['filts'].push(drr);
|
||
|
||
if(data['events']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-left-guanxi').on('click',".analysis-overall-situation-left-guanxi",function(){
|
||
var tit = $(this).html();
|
||
if(tit == "且"){
|
||
$(this).html('或');
|
||
data['events']['relation'] = 'or';
|
||
}else {
|
||
$(this).html('且');
|
||
data['events']['relation'] = 'and';
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click','.analysis-overall-situation-attr',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr('data-index');
|
||
var offset = obj.offset();
|
||
|
||
X.querycriteriapop(user_data,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['events']['filts'][index]['columnName'] = val.id;
|
||
data['events']['filts'][index]['columnDesc'] = val.title;
|
||
data['events']['filts'][index]['data_type'] = val.type;
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr('data-index');
|
||
var offset = obj.offset();
|
||
// console.log(filter_map);
|
||
var filter_type = data['events']['filts'][index]['data_type'];
|
||
X.parametersopen( filter_map[filter_type] ,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
obj.html(val.title);
|
||
data['events']['filts'][index]['comparator'] = val.id;
|
||
data['events']['filts'][index]['comparator_name'] = val.title;
|
||
if(val.id == "range"){
|
||
data['events']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
|
||
$(document).off("click",".analysis-overall-situation-input").on("click",".analysis-overall-situation-input",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var columnName = data['events']['filts'][index]['columnName'];
|
||
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
data['events']['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['events']['filts'][index]['ftv'] = arr;
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['events']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['events']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
||
var val = $(this).val();
|
||
var titarr = val.split(",");
|
||
var index = $(this).attr("data-index");
|
||
data['events']['filts'][index]['strftv'] = val;
|
||
data['events']['filts'][index]['ftv'] = titarr;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['events']['filts'][index][index]['ftv'][0] = val;
|
||
}else {
|
||
data['events']['filts'][index]['ftv'][1] = val;
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-del').on('click','.analysis-overall-situation-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['events']['filts'].splice(index,1);
|
||
if(data['events']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
// 计算按钮
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
calculationdata();
|
||
});
|
||
|
||
function calculationdata(){
|
||
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/user_property_model","post",dataArr,function(val){
|
||
if(val != "查无数据"){
|
||
attributetable(val);
|
||
querydata = val;
|
||
updata(val);
|
||
$(".chawushuj").hide();
|
||
}else {
|
||
$("#attribute-echarts").empty();
|
||
$(".table-fenxi-th").html("");
|
||
$(".table-fenxi-td").html("");
|
||
$(".chawushuj").show();
|
||
}
|
||
})
|
||
};
|
||
|
||
function updata(d){
|
||
var title = $(".select-chart").attr("title");
|
||
if(title == '柱状分布图'){ attributebar(d);}
|
||
else if(title == '饼状图'){ attributepie(d); }
|
||
};
|
||
|
||
var querydata;
|
||
$(document).off('click','.analtsis-chart-switch').on('click','.analtsis-chart-switch',function(){
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '柱状分布图'){ attributebar(querydata);}
|
||
else if($(this).attr('title') == '饼状图'){
|
||
attributepie(querydata);
|
||
}
|
||
}else{
|
||
layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
});
|
||
|
||
function attributetable(val){
|
||
X.laytpldata("#table-attrbute-th-dot",val.title,".table-attrbute-th");
|
||
X.laytpldata("#table-attrbute-td-dot",val.value,".table-attrbute-td");
|
||
};
|
||
|
||
function attributebar(val){
|
||
|
||
var xAxisData = [];
|
||
var seriesdata =[];
|
||
for(let i in val.value){
|
||
xAxisData.push(i);
|
||
seriesdata.push(val.value[i]);
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('attribute-echarts'));
|
||
var option = {
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
}
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
// legend: {
|
||
// data: legendData
|
||
// },
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
axisTick: {show: false},
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: [{
|
||
data: seriesdata,
|
||
type: 'bar',
|
||
|
||
}]
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
function attributepie(val){
|
||
// console.log(val);
|
||
var seriesdata = [];
|
||
for(let i in val.value){
|
||
var arr = {
|
||
value: val['value'][i],
|
||
name: i
|
||
};
|
||
seriesdata.push(arr);
|
||
}
|
||
// console.log(seriesdata);
|
||
var myChart = echarts.init(document.getElementById('attribute-echarts'));
|
||
var option = {
|
||
// color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'item'
|
||
},
|
||
legend: {
|
||
orient: 'vertical',
|
||
left: 'left',
|
||
},
|
||
series: [
|
||
{
|
||
name: '访问来源',
|
||
type: 'pie',
|
||
radius: ['40%', '70%'],
|
||
data: seriesdata,
|
||
emphasis: {
|
||
itemStyle: {
|
||
shadowBlur: 10,
|
||
shadowOffsetX: 0,
|
||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||
}
|
||
}
|
||
}
|
||
]
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
//已存报表
|
||
var baobiaodata;
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
if(d){
|
||
backfilldata(d)
|
||
}
|
||
})
|
||
});
|
||
|
||
// 保存报表
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
baobiaodata['saveas'] = 0;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
//另存为
|
||
$(document).off('click','.analysis-saveas').on('click','.analysis-saveas',function(){
|
||
baobiaodata['saveas'] = 1;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
});
|
||
|
||
// 反向填充数据
|
||
function backfilldata(d){
|
||
data = d.query;
|
||
baobiaodata = d;
|
||
$('.ant-dropdown-trigger').html(data['events']['quotaDesc']);
|
||
$('.analysis-choicetypename').html(data['events']['analysisDesc']);
|
||
X.template("globalfilter","xinwei-whole",data['events']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
calculationdata();
|
||
}
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/category.js
|
||
(function(){
|
||
|
||
X.pageLogic['category'] = {
|
||
init : function( parms ){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
|
||
// 给条件框赋值
|
||
X.laytpldata("#zhuang-tab-dot",data,'.zhuang_tab ');
|
||
|
||
X.laytpldata("#zhuang-conetnt-dot",data,'.zhuang_conetnt ');
|
||
|
||
// 搜索框改变事件
|
||
$('.zhuanghu_ss #zhuanghu_txt').bind('input propertychange', function() {
|
||
var arrData = [];
|
||
var tit = $(this).val();
|
||
if(tit != ""){
|
||
$('.zhuanghu_ss .qingkomg').show();
|
||
for(let i in data){
|
||
var Categoryarr =[];
|
||
for(let j in data[i]['category']){
|
||
if(data[i]['category'][j]['title'].indexOf(tit) != -1){
|
||
Categoryarr.push(data[i]['category'][j]);
|
||
}
|
||
}
|
||
if(Categoryarr.length > 0){
|
||
var arr = {
|
||
'title':data[i]['title'],
|
||
'id':data[i]['id'],
|
||
'category':Categoryarr
|
||
}
|
||
arrData.push(arr);
|
||
}
|
||
}
|
||
// $("#zhuang-conetnt-dot").html("");
|
||
X.laytpldata("#zhuang-conetnt-dot",arrData,'.zhuang_conetnt ');
|
||
}else {
|
||
$('.zhuanghu_ss .qingkomg').hide();
|
||
X.laytpldata("#zhuang-conetnt-dot",data,'.zhuang_conetnt ');
|
||
}
|
||
});
|
||
|
||
//清空搜索框
|
||
$('.zhuanghu_ss .qingkomg').click(function(){
|
||
$('.zhuanghu_ss #zhuanghu_txt').val('');
|
||
X.laytpldata("#zhuang-conetnt-dot",data,'.zhuang_conetnt ');
|
||
})
|
||
var index = 0;
|
||
$(".zhuang_tab_box .zhuang_tab span").click(function(){
|
||
$(".zhuang_tab_box .zhuang_tab span div").removeClass('zhuanghu_xila_xian');
|
||
$(this).find('div').addClass('zhuanghu_xila_xian');
|
||
index = $(this).attr("data-index");
|
||
if(index != 0){
|
||
var dataArr = [];
|
||
dataArr.push(data[index])
|
||
X.laytpldata("#zhuang-conetnt-dot",dataArr,'.zhuang_conetnt ');
|
||
}else {
|
||
X.laytpldata("#zhuang-conetnt-dot",data,'.zhuang_conetnt ');
|
||
}
|
||
})
|
||
|
||
//单击属性
|
||
$(document).off('click','.zhuang_conetnt .ta-pso-line').on('click','.zhuang_conetnt .ta-pso-line',function(){
|
||
var indexs = $(this).attr("data-indexs");
|
||
var number = 0;
|
||
if(index == 0){
|
||
number = $(this).attr("data-index");
|
||
}else {
|
||
number = index
|
||
}
|
||
var valdata = {
|
||
'title':$(this).attr('data-title'),
|
||
'id':$(this).attr('data-id'),
|
||
'type':$(this).attr('data-type'),
|
||
'category': data[number]['category'][indexs]['category'],
|
||
'table_type':data[number]['id']
|
||
}
|
||
me.callback && me.callback(valdata);
|
||
|
||
layer.close( me.parms.layIndex );//获取最新的弹窗关闭
|
||
})
|
||
}
|
||
};
|
||
|
||
})();
|
||
|
||
// srczip/logic/conditionquery.js
|
||
(function(){
|
||
X.pageLogic['conditionquery'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
var dataArr = {
|
||
eventView:data.eventView,
|
||
events:data.events
|
||
}
|
||
X.api('ck/'+ dataArr['eventView']['cksql'] +'_model_sql','post',dataArr,function(d){
|
||
$(".conditionquery-sqldata").html(d[0]['sql']);
|
||
$(".conditionquery-apidata").html(JSON.stringify(dataArr));
|
||
})
|
||
var tab = 0
|
||
layui.element.on('tab(conditionquery)', function(data){
|
||
tab = data['index']
|
||
});
|
||
|
||
$(document).on("click",'.conditionquery-copy',function(){
|
||
|
||
if(tab == 0){
|
||
selectText('conditionquery-sqldata');
|
||
}else {
|
||
selectText('conditionquery-apidata');
|
||
}
|
||
document.execCommand('copy');
|
||
layer.msg('复制成功');
|
||
|
||
})
|
||
|
||
function selectText(element) {
|
||
var text = document.getElementById(element);
|
||
//做下兼容
|
||
if (document.body.createTextRange) { //如果支持
|
||
var range = document.body.createTextRange(); //获取range
|
||
range.moveToElementText(text); //光标移上去
|
||
range.select(); //选择
|
||
} else if (window.getSelection) {
|
||
var selection = window.getSelection(); //获取selection
|
||
var range = document.createRange(); //创建range
|
||
range.selectNodeContents(text); //选择节点内容
|
||
selection.removeAllRanges(); //移除所有range
|
||
selection.addRange(range); //添加range
|
||
/*if(selection.setBaseAndExtent){
|
||
selection.setBaseAndExtent(text, 0, text, 1);
|
||
}*/
|
||
} else {
|
||
alert("复制失败");
|
||
}
|
||
}
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/copykanban.js
|
||
(function(){
|
||
X.pageLogic['copykanban'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
var comboTree1,comboTree2;
|
||
|
||
// X.api("project/","get",{},function(d){
|
||
X.laytpldata("#project-list-box-dot",X.DATA.projectarr,".project-list-box");
|
||
// });
|
||
|
||
// 项目监听下拉框
|
||
// layui.form.on('select(projectlist)', function(data){
|
||
// if(data){
|
||
// X.api('project/kanban','post',{_id:data.value},function(d){
|
||
// comboTree1 = $('.copy-txt-box .justAnotherInputBox1').comboTree({
|
||
// source : d.kanban,
|
||
// isMultiple: false
|
||
// });
|
||
// comboTree2 = $('.copy-txt-box .justAnotherInputBox2').comboTree({
|
||
// source : d.spaces,
|
||
// isMultiple: false
|
||
// });
|
||
// })
|
||
// }
|
||
// });
|
||
|
||
layui.form.render();
|
||
//叉图标关闭弹窗
|
||
// $(document).off('click','.copy-top .copy-cha').on('click','.copy-top .copy-cha',function(){
|
||
// console.log(layer.index)
|
||
// parent.layer.closeAll(layer.index);
|
||
// });
|
||
// //取消按钮
|
||
// $(".copy-but-box .copy-qx").click(function(){
|
||
// layer.closeAll(layer.index);
|
||
// });
|
||
//我的看板,空间切换实践copy-tab
|
||
$(".copy-tab-box .copy-tab div").click(function(){
|
||
$(".copy-tab-box .copy-tab div").removeClass('tabdata');
|
||
$(this).addClass('tabdata');
|
||
if($(this).html() == "我的看板"){
|
||
$(".copy-txt-box .justAnotherInputBox1").show();
|
||
$(".copy-txt-box .justAnotherInputBox2").hide();
|
||
}else {
|
||
$(".copy-txt-box .justAnotherInputBox1").hide();
|
||
$(".copy-txt-box .justAnotherInputBox2").show();
|
||
}
|
||
$(".copy-txt-box .justAnotherInputBox1").val("");
|
||
$(".copy-txt-box .justAnotherInputBox2").val("");
|
||
})
|
||
|
||
//确定按钮
|
||
$(".copy-but-box .copy-qd").click(function(){
|
||
var seldata = layui.form.val('projectlistexample');
|
||
var dataArr = {
|
||
'source_ids':data, //复制的看板id
|
||
'dest_project_id':seldata['project'] //复制到的项目id
|
||
};
|
||
X.api('dashboard/copy','post',dataArr,function(d){
|
||
layer.msg('复制成功');
|
||
layer.closeAll(0);
|
||
})
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/copykanban_kongjian.js
|
||
(function(){
|
||
X.pageLogic['copykanban_kongjian'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
var comboTree1,comboTree2
|
||
comboTree1 = $('.yidong-txt-box .justAnotherInputBox1').comboTree({
|
||
source : X.DATA.KanBanData,
|
||
isMultiple: false
|
||
});
|
||
comboTree2 = $('.yidong-txt-box .justAnotherInputBox2').comboTree({
|
||
source : X.DATA.ProjectData,
|
||
isMultiple: false
|
||
});
|
||
|
||
//叉图标关闭弹窗
|
||
$(".yidong-top .yidong-cha").click(function(){
|
||
parent.layer.closeAll(layer.index);
|
||
});
|
||
//取消按钮
|
||
$(".yidong-but-box .yidong-qx").click(function(){
|
||
layer.closeAll(layer.index);
|
||
});
|
||
//我的看板,空间切换实践
|
||
$(".yidong-tab-box .yidong-tab div").click(function(){
|
||
$(".yidong-tab-box .yidong-tab div").removeClass('tabdata');
|
||
$(this).addClass('tabdata');
|
||
if($(this).html() == "我的看板"){
|
||
$(".yidong-txt-box .justAnotherInputBox1").show();
|
||
$(".yidong-txt-box .justAnotherInputBox2").hide();
|
||
}else {
|
||
$(".yidong-txt-box .justAnotherInputBox1").hide();
|
||
$(".yidong-txt-box .justAnotherInputBox2").show();
|
||
}
|
||
$(".yidong-txt-box .justAnotherInputBox1").val("");
|
||
$(".yidong-txt-box .justAnotherInputBox2").val("");
|
||
})
|
||
|
||
//确定按钮
|
||
$(".yidong-but-box .yidong-qd").click(function(){
|
||
var type ='kanban';
|
||
var id = '';//没有默认传看板
|
||
if($('#yidongjustAnotherInputBox2').val() != ""){
|
||
var Addlocation = $('#yidongjustAnotherInputBox2').val();
|
||
type = "space"
|
||
}else {
|
||
var Addlocation = $('#yidongjustAnotherInputBox1').val();
|
||
}
|
||
// console.log(Addlocation);
|
||
if(Addlocation){
|
||
id = X.pageLogic.newkanban.matchingid(Addlocation,type);
|
||
}else {
|
||
alert('请选择添加的位置');
|
||
return;
|
||
}
|
||
// var source_id = data['mykanban'].concat(data['kongjian']);
|
||
var dataArr = {
|
||
'source_ids':data,
|
||
'project_id': X.DATA.projectid,
|
||
'dest_space_id': id
|
||
};
|
||
X.api('dashboard/copy_to_my_space','post',dataArr,function(d){
|
||
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
X.pageLogic.adminkanban.updata(X.DATA.projectid);//刷新数据
|
||
layer.closeAll(0);
|
||
|
||
})
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/copyreport.js
|
||
(function(){
|
||
X.pageLogic['copyreport'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
// console.log(data);
|
||
|
||
X.api("project/","get",{},function(d){
|
||
X.laytpldata("#project-list-box-dot",d,".project-list-box");
|
||
layui.form.render();
|
||
});
|
||
var dest_project_id;//項目id
|
||
layui.form.on('select(projectlist)', function(data){
|
||
dest_project_id = data.value;
|
||
});
|
||
|
||
//确定按钮
|
||
$(document).off('click','.yidong-but-box .yidong-qd').on('click','.yidong-but-box .yidong-qd',function(){
|
||
var report_ids = [];
|
||
report_ids.push(data);
|
||
var dataArr = {
|
||
'dest_project_id': dest_project_id,
|
||
'report_ids': report_ids
|
||
};
|
||
X.api('report/copy','post',dataArr,function(d){
|
||
|
||
layer.closeAll(0);
|
||
})
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/customname.js
|
||
(function(){
|
||
X.pageLogic['customname'] = {
|
||
init : function(){
|
||
|
||
updataselect_list();
|
||
|
||
// X.uploadfile("data_mana/add_select_map","#fileupload",function(res){
|
||
// updataselect_list();
|
||
// });
|
||
|
||
function updataselect_list(){
|
||
X.api("data_mana/select_list","get",{},function(res){
|
||
X.laytpldata('#customname-content-box-dot',res,'.layui-tab-title');
|
||
X.laytpldata('#layui-tab-content-dot',res,'.layui-tab-content');
|
||
console.log($(".customname-content-box").height())
|
||
$(".layui-tab-content").css('height',$(".customname-content-box").height());
|
||
|
||
})
|
||
};
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/dashboard.js
|
||
//cc
|
||
(function(){
|
||
X.pageLogic['dashboard'] = {
|
||
init :function(){
|
||
|
||
var me = this;
|
||
|
||
var popid='';
|
||
|
||
layui.element.init();
|
||
|
||
var userinfo = localStorage.getItem('loginData');
|
||
if(userinfo){
|
||
X.DATA["userinfo"] = JSON.parse(userinfo);
|
||
if(X.DATA["userinfo"]['name'] != 'root' ){
|
||
$(".projectinfo").hide();
|
||
$(".addproduct").hide();
|
||
}
|
||
}else {
|
||
layer.msg('登录过期请重新登录!!!');
|
||
X.gourl("login");
|
||
return;
|
||
}
|
||
|
||
// 退出登录
|
||
$(document).off('click','.sifnoutlogin').on('click','.sifnoutlogin',function(){
|
||
window.localStorage.removeItem('loginData');
|
||
X.gourl("login");
|
||
location.reload();
|
||
});
|
||
|
||
// 项目列表
|
||
// 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'] = X.DATA['projectid'] || d[0]["_id"];
|
||
X.DATA["game"] = X.DATA["game"] || d[0]["game"];
|
||
for(let i in d){
|
||
if(d[i]['game'] == X.DATA["game"]){
|
||
$(".projecttit").html(d[i]['name']);
|
||
}
|
||
}
|
||
$("#model-box").html("");
|
||
me.freshMenu(X.DATA['projectid']);
|
||
|
||
// 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['dashboard_id'] = "";
|
||
X.DATA['projectid'] = id;
|
||
X.DATA["game"] = game;
|
||
//侧边栏数据渲染
|
||
me.freshMenu(id);
|
||
// X.pageLogic.dashboard.freshMenu(id);
|
||
});
|
||
|
||
//a标签点击跳转事件
|
||
$(document).off('click','.layui-nav-child a').on('click','.layui-nav-child a',function(){
|
||
var url = $(this).attr("data-url");
|
||
X.gourl(url);
|
||
});
|
||
|
||
//空间单击事件
|
||
$(document).off("click",'.xiangmukongjian').on('click','.xiangmukongjian',function(){
|
||
var authority = $(this).attr("data-authority");
|
||
X.DATA.authority = authority;
|
||
if(authority == "rw"){
|
||
$(".baobiao").show();
|
||
}else{
|
||
$(".baobiao").hide();
|
||
}
|
||
// console.log(authority);
|
||
});
|
||
|
||
// 修改面板名
|
||
$(document).off('click','.layui-left-dd').on('click','.layui-left-dd',function(){
|
||
var authority = $(this).attr("data-authority");
|
||
X.DATA.authority = authority;
|
||
if(authority == "rw" && X.DATA['userinfo']['userid'] == $(this).attr("data-userid")){
|
||
$(".baobiao").show();
|
||
}else{
|
||
$(".baobiao").hide();
|
||
}
|
||
$(".tab-tit-box .tab-tit").html($(this).find("span").html());
|
||
setHashParms("menu",$(this).attr('data-id'));
|
||
// $("#model-box").html("");
|
||
// X.DATA['dashboard_id'] = $(this).attr('data-id'); //看板id
|
||
// 获取报表数据
|
||
// me.gettabledata();
|
||
});
|
||
|
||
// 渲染添加按钮侧边栏下拉框
|
||
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",function(start, end, label) {
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
// console.log(startTime);
|
||
// console.log(endTime);
|
||
});
|
||
|
||
// X.echartsdata("#charts");
|
||
|
||
//更新时间按钮
|
||
$(".updatetime").click(function(){
|
||
X['DATA']['screenlist'] = [];
|
||
X.updatatime(".updatetime");
|
||
me.gettabledata();
|
||
});
|
||
|
||
//添加项目
|
||
$(document).off('click','.addproduct').on("click",".addproduct",function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'addproduct',
|
||
callback :function(d){
|
||
X.api("project/","get",{},function(d){
|
||
X.laytpldata('#layui-project-dot',d,'.layui-project-box');
|
||
X.DATA['projectarr'] = d;
|
||
X.DATA['projectid'] = X.DATA['projectid'] || d[0]["_id"];
|
||
X.DATA["game"] = X.DATA["game"] || d[0]["game"];
|
||
for(let i in d){
|
||
if(d[i]['game'] == X.DATA["game"]){
|
||
$(".projecttit").html(d[i]['name']);
|
||
}
|
||
}
|
||
$("#model-box").html("");
|
||
me.freshMenu(X.DATA['projectid']);
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
//管理我创建的看板
|
||
$(document).off('click','.sousuo-box .kbglkanbanbtn').on("click",".sousuo-box .kbglkanbanbtn",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){
|
||
$(".tab-tit-box .tab-shiqvshezhi").html(obj.title);
|
||
|
||
//数据更新
|
||
// this.elem.val(obj.title);
|
||
}
|
||
});
|
||
|
||
//筛选
|
||
$(document).off('click','.tab-right-box .tjsx').on("click",".tab-right-box .tjsx",function(){
|
||
layer.msg('该功能暂未开放');
|
||
return;
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shade:0,
|
||
shadeClose: false,
|
||
offset: [120,270],
|
||
url: "screen",
|
||
extData : {}
|
||
})
|
||
})
|
||
|
||
// 单个表格筛选
|
||
$(document).off('click','.tishi-tjsx').on('click','.tishi-tjsx',function(){
|
||
var obj = $(this);
|
||
var id = obj.attr('data-id');
|
||
var screenlist;
|
||
var cat = obj.attr('data-cat');
|
||
var modelsize = obj.attr('data-modelsize');
|
||
var modeltype = obj.attr('data-modeltype');
|
||
var name = obj.attr('data-name');
|
||
|
||
var timetxtid = 'times'+id;
|
||
var timetxt = $("#"+timetxtid).html();
|
||
var timetxtarr = timetxt.split(" - ");
|
||
var startTime = timetxtarr[0] + " "+ "00:00:00";
|
||
var endTime = timetxtarr[1]+ " "+ "23:59:59";
|
||
|
||
for(let i in X.DATA['screenlist']){
|
||
if(id == X.DATA['screenlist'][i]['id']){
|
||
screenlist = X.DATA['screenlist'][i];
|
||
}
|
||
}
|
||
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
// shade:0,
|
||
shadeClose: true,
|
||
offset: [120,270],
|
||
url: "screen",
|
||
extData : screenlist,
|
||
callback : function(d){
|
||
d['startTime'] = startTime;
|
||
d['endTime']=endTime;
|
||
d['id'] = id;
|
||
var dataArr = {
|
||
report_id : id,
|
||
ext_filter : d
|
||
}
|
||
X.DATA['screenlist'].push(d);
|
||
|
||
for(let i in X.DATA['screenlist']){
|
||
var cardid = "model"+X.DATA['screenlist'][i]['id'];
|
||
$("#"+cardid+" .shaixjeiguo").show();
|
||
}
|
||
|
||
X.api("ck/"+ cat +"_model","post",dataArr,function(vals){
|
||
if(vals == '查无数据'){
|
||
layer.msg('筛选条件无数据');
|
||
return;
|
||
}
|
||
var report_id = [];
|
||
report_id.push(id);
|
||
|
||
X.api('report/read_report','post',{project_id:X.DATA['projectid'],report_id:report_id,dashboard_id:X.DATA.dashboard_id},function(q){
|
||
var bbsetdata = {
|
||
graph_size:modelsize,
|
||
graph_type:modeltype,
|
||
model:cat,
|
||
name:name,
|
||
report_id:id,
|
||
modelswitch:q[0].show_config.modelswitch,
|
||
ascending:q[0].show_config.ascending
|
||
}
|
||
var modeldata = X.pageLogic['dashboard'].modeldata(bbsetdata,vals);
|
||
//渲染模板和数据
|
||
X.template("modeltable",'conent-box'+modeldata[0]['id'],modeldata[0],function(){
|
||
X.pageLogic['dashboard'].morefeatures(modeldata[0]);
|
||
});
|
||
})
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.shaixjeiguo').on('click','.shaixjeiguo',function(){
|
||
var id = $(this).attr('data-id');
|
||
var filts
|
||
for(let i in X.DATA.screenlist){
|
||
if(X.DATA.screenlist[i]['id'] == id){
|
||
filts = X.DATA.screenlist[i]['filts'];
|
||
}
|
||
}
|
||
var filtshtml = ''
|
||
if(filts.length > 0){
|
||
for(let i in filts){
|
||
filtshtml+= filts[i]['columnDesc'] + filts[i]['comparator_name'] + filts[i]['strftv'] + '<br>'
|
||
}
|
||
}
|
||
|
||
layui.layer.tips(filtshtml, '#sxjg'+id, {
|
||
tips: [4, '#475285']
|
||
});
|
||
})
|
||
|
||
|
||
|
||
// 侧边栏搜索
|
||
$('.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']);
|
||
}
|
||
|
||
});
|
||
|
||
// 用户搜索
|
||
$(document).off('click','#search').on("click","#search",function(){
|
||
// layer.msg('该功能暂未开放');
|
||
// return;
|
||
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(){
|
||
layer.msg('该功能暂未开放');
|
||
return;
|
||
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(){
|
||
me.gettabledata();
|
||
})
|
||
});
|
||
|
||
//更新报表
|
||
$(document).off('click','.model-gengx').on('click','.model-gengx',function(){
|
||
var id = $(this).attr('data-id');
|
||
for(let i in X['DATA']['screenlist']){
|
||
if(X['DATA']['screenlist'][i]['id'] == id){
|
||
X['DATA']['screenlist'].splice(i,1);
|
||
}
|
||
}
|
||
X.api('dashboard/','post',{id:X.DATA['dashboard_id']},function(d){
|
||
// return;
|
||
X.pageLogic['dashboard'].fillmodeldata(d[id]);
|
||
|
||
})
|
||
|
||
});
|
||
|
||
//报表跳转到详情s
|
||
$(document).off('click','.gobaobiaoinfo').on('click','.gobaobiaoinfo',function(){
|
||
var cat = $(this).attr('data-cat');
|
||
var id = $(this).attr('data-id');
|
||
var gourl='';
|
||
if(cat == 'event'){
|
||
gourl = 'analysis';
|
||
}else if(cat == 'retention'){
|
||
gourl = 'retained';
|
||
// layer.msg('暂未处理当前逻辑');
|
||
// return;
|
||
}else if(cat == 'ltv'){
|
||
gourl = 'ltvmodel';
|
||
// layer.msg('暂未处理当前逻辑');
|
||
// return;
|
||
}else if(cat == 'user_property'){
|
||
gourl = 'attribute';
|
||
}else if(cat == 'scatter'){
|
||
gourl = 'distribution';
|
||
}
|
||
X.gourl(gourl,'conetnt');//跳到对应的分析页面
|
||
X.DATA[cat+'id'] = id;
|
||
});
|
||
|
||
//复制单个报表
|
||
$(document).off('click','.model-fuzhi').on('click','.model-fuzhi',function(e) {
|
||
e.stopPropagation();
|
||
var id = $(this).attr('data-id')
|
||
X.parametersopen(id,'copyreport',"auto",function(d) {
|
||
|
||
})
|
||
});
|
||
|
||
//删除空间
|
||
$(document).off('click','.nav-space-bar').on('click','.nav-space-bar',function(e){
|
||
e.stopPropagation();
|
||
var id = $(this).attr('data-id');
|
||
X.parametersopen(id,"kongjianshezhi",'auto',function(d){
|
||
|
||
})
|
||
})
|
||
|
||
//删除看板
|
||
$(document).off('click','.nav-action-bar').on('click','.nav-action-bar',function(e){
|
||
e.stopPropagation();
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var innerHeight = window.innerHeight;
|
||
var offsets = [ offset.top + 10,offset.left];
|
||
|
||
if( innerHeight - offset.top < 150){
|
||
offsets = [ offset.top - 100,offset.left];
|
||
}
|
||
var id = $(this).attr('data-id');
|
||
X.parametersopen(X.DATA.taboperationdata['kanban'],"dropdownlist2",offsets,function(d){
|
||
var arr = [];
|
||
arr.push(id);
|
||
if(d.click != 'del'){
|
||
X.parametersopen(arr,d.click,'auto',function(){
|
||
// me.updata(X.DATA['projectid']);
|
||
me.freshMenu(X.DATA['projectid']);
|
||
})
|
||
}else {
|
||
layer.confirm('确认删除选中的看板吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("dashboard/delete",'post',{ids:arr},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
me.updata(X.DATA.projectid);//刷新数据
|
||
})
|
||
});
|
||
}
|
||
|
||
});
|
||
});
|
||
|
||
//留存分析模板特定留存流失按钮
|
||
$(document).off('click',".kanben-retained-type").on('click',".kanben-retained-type",function(d){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var id = obj.attr('data-id');
|
||
var cat = obj.attr('data-cat');
|
||
var modelsize = obj.attr('data-modelsize');
|
||
var modeltype = obj.attr('data-modeltype');
|
||
var name = obj.attr('data-name');
|
||
X.parametersopen(X['DATA']['retentionlist'],'dropdownlist',[offset.top+obj.height(),offset.left],function(d){
|
||
obj.html(d.title);
|
||
var retentiontype = d.id;
|
||
var modelid = "retention"+id;
|
||
var reportid = [];
|
||
reportid.push(id);
|
||
// X.api('dashboard/','post',{id:X.DATA['dashboard_id']},function(val){
|
||
// for(let i in val){
|
||
// if(val[i]['report_id'] == id){
|
||
// X.pageLogic['dashboard'].fillmodeldata(val[i],modelid,retentiontype);
|
||
// }
|
||
// }
|
||
// })
|
||
X.api("report/read_report",'post',{project_id:X.DATA['projectid'],report_id:reportid,dashboard_id:X.DATA.dashboard_id},function(q){
|
||
var query = {
|
||
eventView:q[0]['query']['eventView'],
|
||
events:q[0]['query']['events'],
|
||
};
|
||
//获取修改的时间
|
||
var dateid = "times"+id;
|
||
var time = $("#"+dateid).html();
|
||
var timearr = time.split(" ");
|
||
query['eventView']['startTime'] = timearr[0] + ' 00:00:00';
|
||
query['eventView']['endTime'] = timearr[2] + ' 23:59:59';
|
||
//获取修改的时间粒度
|
||
var timeParticleSizeid = "screenlist"+id;
|
||
var timeParticleSizename = $("#"+timeParticleSizeid).html();
|
||
var timeParticleSize;
|
||
X.granularityid(timeParticleSizename,function(d){
|
||
timeParticleSize = d;
|
||
if(cat == "retention"){
|
||
query['eventView']['unitNum'] = parseInt(timeParticleSize);
|
||
}else {
|
||
query['eventView']['timeParticleSize'] = timeParticleSize;
|
||
}
|
||
X.modelapi("ck/"+ cat +"_model","post",query,function(val){
|
||
if(JSON.stringify(val) != "{}"){
|
||
var bbsetdata = {
|
||
graph_size:modelsize,
|
||
graph_type:modeltype,
|
||
model:cat,
|
||
name:name,
|
||
report_id:id,
|
||
query:query,
|
||
modelswitch:q[0].show_config.modelswitch,
|
||
ascending:q[0].show_config.ascending
|
||
}
|
||
|
||
var modeldata = X.pageLogic['dashboard'].modeldata(bbsetdata,val,retentiontype);
|
||
//渲染模板和数据
|
||
X.template("modeltable",'conent-box'+modeldata[0]['id'],modeldata[0],function(){
|
||
X.pageLogic['dashboard'].morefeatures(modeldata[0]);
|
||
});
|
||
|
||
}else {
|
||
layer.msg('无数据!!!');
|
||
}
|
||
|
||
})
|
||
})
|
||
})
|
||
})
|
||
});
|
||
|
||
//报表时间粒度修改
|
||
$(document).off('click','.model-screenlist').on('click','.model-screenlist',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
|
||
var id = obj.attr('data-id');
|
||
var cat = obj.attr('data-cat');
|
||
var modelsize = obj.attr('data-modelsize');
|
||
var modeltype = obj.attr('data-modeltype');
|
||
var name = obj.attr('data-name');
|
||
$("#sxjg"+id).hide();
|
||
|
||
X.parametersopen(X['DATA']['companylist'][cat],'dropdownlist',[offset.top+obj.height(),offset.left],function(d){
|
||
// console.log(d);
|
||
obj.html(d.title);
|
||
var reportid = [];
|
||
reportid.push(id);
|
||
X.api('report/read_report','post',{project_id:X.DATA['projectid'],report_id:reportid,dashboard_id:X.DATA.dashboard_id},function(q){
|
||
var query = {
|
||
eventView:q[0]['query']['eventView'],
|
||
events:q[0]['query']['events'],
|
||
};
|
||
if(cat == "retention"){
|
||
query['eventView']['unitNum'] = parseInt(d.id);
|
||
}else {
|
||
query['eventView']['timeParticleSize'] = d.id;;
|
||
}
|
||
//时间获取修改后的时间
|
||
// 报表时间id
|
||
var dateid = "times"+id;
|
||
var time = $("#"+dateid).html();
|
||
var timearr = time.split(" ");
|
||
query['eventView']['startTime'] = timearr[0] + ' 00:00:00';
|
||
query['eventView']['endTime'] = timearr[2] + ' 23:59:59';
|
||
for(let i in X.DATA['screenlist']){
|
||
if(X.DATA['screenlist'][i]['id'] == id){
|
||
query['eventView']['filts'] = X.DATA['screenlist'][i]['filts']
|
||
}
|
||
}
|
||
// console.log(query);
|
||
X.modelapi("ck/"+ cat +"_model","post",query,function(vals){
|
||
var bbsetdata = {
|
||
graph_size:modelsize,
|
||
graph_type:modeltype,
|
||
model:cat,
|
||
name:name,
|
||
report_id:id,
|
||
query:q[0]['query'],
|
||
modelswitch:q[0].show_config.modelswitch,
|
||
ascending:q[0].show_config.ascending
|
||
}
|
||
// debugger;
|
||
var modeldata = X.pageLogic['dashboard'].modeldata(bbsetdata,vals);
|
||
//渲染模板和数据
|
||
X.template("modeltable",'conent-box'+modeldata[0]['id'],modeldata[0],function(){
|
||
X.pageLogic['dashboard'].morefeatures(modeldata[0]);
|
||
});
|
||
})
|
||
})
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.chart').on('click','.chart',function(){
|
||
var dropdownlist = [
|
||
{title:'报表',id:'table'},
|
||
{title:'图形',id:'echarts'}
|
||
];
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var id = obj.attr('data-id');
|
||
var modelid = id;
|
||
var modelsize = obj.attr('data-modelsize');
|
||
var modeltype = obj.attr('data-modeltype');
|
||
var cat = obj.attr('data-cat');
|
||
var name = obj.attr('data-name');
|
||
X.parametersopen(dropdownlist,'dropdownlist',[offset.top+obj.height()+5,offset.left-150],function(d){
|
||
|
||
var data = {
|
||
report_id:id,
|
||
graph_size:modelsize,
|
||
graph_type:d.id,
|
||
model:cat,
|
||
name:name
|
||
}
|
||
X.api('dashboard/edit_show_report','post',{dashboard_id:X.DATA.dashboard_id,config:data},function(d){
|
||
X.api('dashboard/','post',{id:X.DATA['dashboard_id']},function(val){
|
||
for(let i in val){
|
||
if(val[i]['report_id'] == id){
|
||
X.pageLogic['dashboard'].fillmodeldata(val[i],modelid);
|
||
}
|
||
}
|
||
})
|
||
})
|
||
|
||
})
|
||
});
|
||
|
||
//点击时间获取到单击的报表id
|
||
$(document).off('click','.model-times').on('click','.model-times',function(){
|
||
var arr = {
|
||
id:$(this).attr('data-id'),
|
||
cat:$(this).attr('data-cat'),
|
||
modeltype:$(this).attr('data-modeltype'),
|
||
modelsize:$(this).attr('data-modelsize'),
|
||
name:$(this).attr('data-name'),
|
||
}
|
||
X.DATA.oclickarr =arr;
|
||
// $("#sxjg"+$(this).attr('data-id')).hide();
|
||
});
|
||
|
||
//更多按钮配置下拉框
|
||
$(document).off('click','.model-gengduo').on('click','.model-gengduo',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var id = obj.attr('data-id');
|
||
// var modelid = 'model'+id;
|
||
var modelsize = obj.attr('data-modelsize');
|
||
var modeltype = obj.attr('data-modeltype');
|
||
var cat = obj.attr('data-cat');
|
||
var name = obj.attr('data-name');
|
||
var modelswitch = obj.attr("data-modelswitch");
|
||
var ascending = obj.attr("data-ascending");
|
||
var avesumdata = obj.attr("data-avesumdata");
|
||
var daydata = obj.attr("data-daydata");
|
||
var reverseorder = obj.attr("data-reverseorder")
|
||
|
||
var gengduolist
|
||
if(X.DATA.authority == "rw"){
|
||
gengduolist = X['DATA']['gengduolist'];
|
||
}else {
|
||
gengduolist = X['DATA']['gengduolist2'];
|
||
}
|
||
X.parametersopen(gengduolist,'dropdownlist',[offset.top+obj.height(),offset.left-170],function(d){
|
||
if(d.id == 'shezhi'){
|
||
var data = {
|
||
id : id,
|
||
modelsize : modelsize,
|
||
modeltype : modeltype,
|
||
modelswitch: modelswitch,
|
||
ascending:ascending,
|
||
daydata:daydata,
|
||
avesumdata:avesumdata,
|
||
cat: cat,
|
||
reverseorder:reverseorder
|
||
}
|
||
X.parametersopen(data,'setupbaobiao',"auto",function(d){
|
||
X.pageLogic['dashboard'].gettabledata();
|
||
})
|
||
}else if(d.id == 'export'){
|
||
var arr = [];
|
||
arr.push(id);
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:arr},function(d){
|
||
var arr = {
|
||
"eventView": d[0]['query']['eventView'],
|
||
"events": d[0]['query']['events'],
|
||
}
|
||
var dateid = "times"+id;
|
||
var time = $("#"+dateid).html();
|
||
var timearr = time.split(" ");
|
||
arr['eventView']['startTime'] = timearr[0] + ' 00:00:00';
|
||
arr['eventView']['endTime'] = timearr[2] + ' 23:59:59';
|
||
|
||
X.download('ck/'+ cat +'_model_export',arr,name);
|
||
})
|
||
|
||
|
||
}else {
|
||
layer.confirm('确认移除['+ name + ']', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api('dashboard/del_report','post',{_id:X['DATA']['dashboard_id'],report_id:id},function(){
|
||
X.pageLogic['dashboard'].gettabledata();
|
||
});
|
||
});
|
||
}
|
||
})
|
||
});
|
||
|
||
},
|
||
|
||
// X.pageLogic.dashboard.freshMenu();
|
||
freshMenu : function(id){
|
||
//获取对应侧边栏
|
||
X.api('project/kanban',"post",{"_id":id},function (d){
|
||
X.DATA['KanBanData'] = d.kanban;
|
||
X.DATA['ProjectData'] = d.spaces;
|
||
for(let i in d.spaces){
|
||
if(d.spaces[i]['children'].length > 0){
|
||
if(d.spaces[i]['authority'] == "rw" && d.spaces[i]['children'][i]['user_id'] == X.DATA['userinfo']['userid']){
|
||
$(".baobiao").show();
|
||
continue;
|
||
}else{
|
||
$(".baobiao").hide();
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
|
||
for(let i in d.spaces){
|
||
if(d.spaces[i]['children'].length > 0){
|
||
if(X.DATA['dashboard_id'] == undefined || X.DATA['dashboard_id'] == ""){
|
||
for(let q in d.spaces){
|
||
for(let j in d.spaces[q]['children']){
|
||
d.spaces[q]['children'][j]['onclick'] = 0;
|
||
d.spaces[q]['children'][j]['sort'] = j
|
||
if(j == 0){
|
||
d.spaces[q]['children'][j]['onclick'] = 1;
|
||
}
|
||
}
|
||
}
|
||
// console.log(d.spaces[i]['children'][0]['_id']);
|
||
var query = window.location.href;
|
||
var querys = query.split("=");
|
||
// debugger;
|
||
if(querys[2] == d.spaces[i]['children'][0]['_id']){
|
||
X.DATA['dashboard_id'] = querys[2];
|
||
}else {
|
||
setHashParms("menu",d.spaces[i]['children'][0]['_id']);
|
||
}
|
||
// $(".tab-tit-box .tab-tit").html(d.spaces[i]['children'][0]['name']);
|
||
// X.DATA['dashboard_id'] = d.spaces[i]['children'][0]['_id']; //看板id
|
||
}else {
|
||
for(let q in d.spaces){
|
||
for(let j in d.spaces[q]['children']){
|
||
d.spaces[q]['children'][j]['onclick'] = 0;
|
||
d.spaces[q]['children'][j]['sort'] = j
|
||
if(d.spaces[q]['children'][j]['_id'] == X.DATA['dashboard_id']){
|
||
d.spaces[q]['children'][j]['onclick'] = 1;
|
||
$(".tab-tit-box .tab-tit").html(d.spaces[q]['children'][j]['name']);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
$("#model-box").html("");
|
||
// 获取报表数据
|
||
X.pageLogic['dashboard'].gettabledata();
|
||
X.laytpldata('#mykanban-dot',d.kanban,'#mykanban');
|
||
X.laytpldata('#kongjian-dot',d.spaces,'#kongjian',function(){
|
||
// X.pageLogic.dashboard.sidebarslide();
|
||
// var sidebar = document.getElementById('sidebar-box'+d.spaces[0]['_id']);
|
||
var sidebar = document.getElementById('sidebar-boxhuadong');
|
||
new Sortable(sidebar, {
|
||
handle: '.tuodong', // handle class
|
||
animation: 150,
|
||
onUpdate:function(evt){
|
||
var newIndex = evt.newIndex;
|
||
var oldIndex = evt.oldIndex;
|
||
// console.log(d.spaces);
|
||
for(let j in d.spaces[i]['children']){
|
||
if(j >= newIndex){
|
||
d.spaces[i]['children'][j]['sort'] = Number(d.spaces[i]['children'][j]['sort']) + Number(1);
|
||
}
|
||
}
|
||
d.spaces[i]['children'][oldIndex]['sort'] = newIndex;
|
||
var sortarr = [];
|
||
for(let q in d.spaces[i]['children']){
|
||
var arr = {
|
||
dashboard_id: d.spaces[i]['children'][q]['_id'],
|
||
sort: d.spaces[i]['children'][q]['sort']
|
||
}
|
||
sortarr.push(arr);
|
||
}
|
||
X.api('dashboard/sort','post',{sort:sortarr},function(d){
|
||
if(d == 1){
|
||
X.pageLogic.dashboard.freshMenu(X.DATA['projectid']);
|
||
}
|
||
})
|
||
}
|
||
});
|
||
});
|
||
|
||
break;//终止循环
|
||
|
||
}else {
|
||
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// 侧边栏上下滑动 废弃
|
||
sidebarslide:function(){
|
||
$('.sidebarslide').sortable({
|
||
connectWith: [".sidebarslide"],
|
||
placeholder: "drop-area",
|
||
distance: 15,
|
||
tolerance:'pointer',
|
||
opacity:0.8,
|
||
revert:100,
|
||
helper:'clone',
|
||
appendTo:'body',
|
||
start : function(event, ui){
|
||
// console.log(111,event);
|
||
// console.log(111,ui);
|
||
},
|
||
stop: function(event, ui){
|
||
// console.log(222,event);
|
||
// console.log(222,ui);
|
||
},
|
||
|
||
})
|
||
},
|
||
|
||
//填充看板数据
|
||
//总体逻辑是:根据获取到的看板内容去先渲染放置的框,在根据不同分析模型处理对应的数据进行填充
|
||
fillmodeldata:function(d,id,type){
|
||
X.modelapi("ck/"+d['model']+"_model","post",{report_id:d['report_id']},function(val){
|
||
if(val == '查无数据'){
|
||
$('#model-two-'+d['report_id']).html('<span class="woshujv">查无数据</span>');
|
||
}else {
|
||
var eventdata = X.pageLogic['dashboard'].modeldata(d,val,type);
|
||
var data;
|
||
if(eventdata.length > 0){
|
||
for(var z in eventdata){
|
||
if(id){
|
||
//当有id时更新对应id看板内的内容
|
||
X.template("modeltype","model-two-"+id,eventdata[z],function(){
|
||
// X.pageLogic['dashboard'].morefeatures(eventdata[z]);
|
||
X.template("modeltable",'conent-box'+eventdata[z]['id'],eventdata[z],function(){
|
||
X.pageLogic['dashboard'].morefeatures(eventdata[z]);
|
||
});
|
||
});
|
||
}else {
|
||
//渲染模板和数据
|
||
X.template("modeltype",'model-two-'+eventdata[z]['id'],eventdata[z],function(){
|
||
//X.pageLogic['dashboard'].morefeatures(eventdata[z]);
|
||
X.template("modeltable",'conent-box'+eventdata[z]['id'],eventdata[z],function(){
|
||
X.pageLogic['dashboard'].morefeatures(eventdata[z]);
|
||
});
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
})
|
||
},
|
||
|
||
modeldata:function(d,val,type){
|
||
var eventdata = [];
|
||
if(d['query']){
|
||
if(d.cat == "retention"){
|
||
var timeParticleSize = d['query']['eventView']['unitNum'];
|
||
}else {
|
||
var timeParticleSize = d['query']['eventView']['timeParticleSize'];
|
||
}
|
||
|
||
var granularity = ''
|
||
if(timeParticleSize){
|
||
X.granularity(timeParticleSize,function(d){
|
||
granularity = d;
|
||
});
|
||
}
|
||
}
|
||
|
||
if(d['model'] == "event"){
|
||
// 事件分析
|
||
if(d['graph_size'] == 'small'){
|
||
X.eventsmall(val,function(data){//表格数据处理
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['wow'] = Math.abs(val[0]['wow']);
|
||
data['chain_ratio'] = Math.abs(val[0]['chain_ratio']);
|
||
data['desc'] = d['desc'];
|
||
eventdata.push(data);
|
||
})
|
||
}else {
|
||
if(d['graph_type'] == 'table'){
|
||
//表格样式
|
||
X.eventtable(val,function(data){//表格数据处理
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['modelswitch'] = d['modelswitch'];
|
||
data['ascending'] = d['ascending'];
|
||
data['desc'] = d['desc'];
|
||
data['reverseorder']=d['reverseorder'];
|
||
eventdata.push(data);
|
||
// return;
|
||
if(d['modelswitch']){
|
||
var originaldata;//原始数据
|
||
originaldata= $.extend(true,[],eventdata[0]['condata']);
|
||
originaldata.unshift(eventdata[0]['titledata']);
|
||
var dataarr = [];
|
||
for(let i in originaldata[0]){
|
||
var arr = [];
|
||
dataarr.push(arr);
|
||
}
|
||
for(let i in originaldata){
|
||
for(let j in originaldata[i]){
|
||
dataarr[j].push(originaldata[i][j]);
|
||
}
|
||
}
|
||
var titledata = dataarr[0];
|
||
var condata = dataarr.slice(1, dataarr.length);
|
||
|
||
eventdata[0]['titledata'] = titledata;
|
||
eventdata[0]['condata'] = condata;
|
||
}
|
||
//数据根据时间降序排列
|
||
if(d['ascending']){
|
||
// console.log()
|
||
// console.log(eventdata);
|
||
var condatalength = eventdata[0]['condata'].length;
|
||
var condataascend=[];
|
||
for(var i = condatalength - 1; i >= 0; i--){
|
||
condataascend.push(eventdata[0]['condata'][i]);
|
||
}
|
||
eventdata[0]['condata'] = condataascend;
|
||
}
|
||
|
||
})
|
||
|
||
}else if(d['graph_type'] == 'echarts'){
|
||
//图形
|
||
X.eventchart(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['avesumdata']=d['avesumdata'];
|
||
data['daydata'] = d['daydata'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['desc'] = d['desc'];
|
||
eventdata.push(data);
|
||
})
|
||
}
|
||
}
|
||
|
||
} else if(d['model'] == "retention"){
|
||
//留存分析
|
||
if(type){
|
||
val['retentiontype'] = type;
|
||
}else {
|
||
val['retentiontype'] = 0
|
||
}
|
||
if(d['graph_size'] == 'small'){
|
||
|
||
}else {
|
||
if(d['graph_type'] == 'table'){
|
||
X.retentiontable(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['desc'] = d['desc'];
|
||
data['reverseorder']=d['reverseorder'];
|
||
eventdata.push(data);
|
||
|
||
if(d['ascending']){
|
||
var condatalength = eventdata[0]['condata'].length;
|
||
var condataascend=[];
|
||
for(var i = condatalength - 1; i >= 0; i--){
|
||
condataascend.push(eventdata[0]['condata'][i]);
|
||
}
|
||
eventdata[0]['condata'] = condataascend;
|
||
}
|
||
})
|
||
|
||
}else {
|
||
X.retentionchart(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['desc'] = d['desc'];
|
||
data['avesumdata']=d['avesumdata'];
|
||
data['daydata'] = d['daydata'];
|
||
eventdata.push(data);
|
||
})
|
||
}
|
||
}
|
||
}else if(d['model'] == 'ltv'){
|
||
//ltv模型
|
||
if(d['graph_type'] == 'table'){
|
||
X.ltvtable(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['desc'] = d['desc'];
|
||
data['reverseorder']=d['reverseorder'];
|
||
eventdata.push(data);
|
||
|
||
if(d['ascending']){
|
||
var condatalength = eventdata[0]['condata'].length;
|
||
var condataascend=[];
|
||
for(var i = condatalength - 1; i >= 0; i--){
|
||
condataascend.push(eventdata[0]['condata'][i]);
|
||
}
|
||
eventdata[0]['condata'] = condataascend;
|
||
}
|
||
})
|
||
}else {
|
||
X.ltvtable(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
// data['date'] = startTimearr[0] + ' - ' + endTimearr[0];
|
||
data['timeParticleSize'] = granularity;
|
||
data['desc'] = d['desc'];
|
||
data['avesumdata']=d['avesumdata'];
|
||
data['daydata'] = d['daydata'];
|
||
eventdata.push(data);
|
||
})
|
||
}
|
||
}else if(d['model'] == 'user_property'){
|
||
// 属性分析
|
||
if(d['graph_type'] == 'table'){
|
||
X.userpropertytable(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['date'] = "";
|
||
data['desc'] = d['desc'];
|
||
data['reverseorder']=d['reverseorder'];
|
||
eventdata.push(data);
|
||
if(d['ascending']){
|
||
var condatalength = eventdata[0]['condata'].length;
|
||
var condataascend=[];
|
||
for(var i = condatalength - 1; i >= 0; i--){
|
||
condataascend.push(eventdata[0]['condata'][i]);
|
||
}
|
||
eventdata[0]['condata'] = condataascend;
|
||
}
|
||
})
|
||
}else {
|
||
X.userpropertychart(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['date'] = "";
|
||
data['desc'] = d['desc'];
|
||
data['avesumdata']=d['avesumdata'];
|
||
data['daydata'] = d['daydata'];
|
||
eventdata.push(data);
|
||
})
|
||
}
|
||
}else if(d['model'] == 'scatter'){
|
||
// 分布分析
|
||
if(d['graph_type'] == "table"){
|
||
X.scattertable(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['desc'] = d['desc'];
|
||
data['reverseorder']=d['reverseorder'];
|
||
eventdata.push(data);
|
||
if(d['ascending']){
|
||
var condatalength = eventdata[0]['condata'].length;
|
||
var condataascend=[];
|
||
for(var i = condatalength - 1; i >= 0; i--){
|
||
condataascend.push(eventdata[0]['condata'][i]);
|
||
}
|
||
eventdata[0]['condata'] = condataascend;
|
||
}
|
||
})
|
||
}else {
|
||
X.scatterchart(val,function(data){
|
||
data['name'] = d['name'];
|
||
data['modeltype'] = d['graph_type'];
|
||
data['id'] = d['report_id'];
|
||
data['modelsize'] = d['graph_size'];
|
||
data['cat'] = d['model'];
|
||
data['desc'] = d['desc'];
|
||
data['avesumdata']=d['avesumdata'];
|
||
data['daydata'] = d['daydata'];
|
||
eventdata.push(data);
|
||
})
|
||
}
|
||
|
||
|
||
}
|
||
eventdata[0]['authority'] = X.DATA.authority;
|
||
return eventdata;
|
||
},
|
||
|
||
//画统计图和添加移入移出事件
|
||
morefeatures:function(eventdata){
|
||
|
||
//更多按钮配置下拉框
|
||
// X.laydropdown(".model-gengduo",X['DATA']['gengduolist'],function(d){
|
||
// if(d.id == 'shezhi'){
|
||
// var data = {
|
||
// id : eventdata.id,
|
||
// modelsize : eventdata.modelsize,
|
||
// modeltype : eventdata.modeltype,
|
||
// modelswitch: eventdata.modelswitch
|
||
// }
|
||
// X.parametersopen(data,'setupbaobiao',"auto",function(d){
|
||
// X.pageLogic['dashboard'].gettabledata();
|
||
// })
|
||
// }else if(d.id == 'export'){
|
||
// X.download('ck/'+ eventdata.cat +'_model_export',{report_id:eventdata.id},eventdata.name);
|
||
// }else {
|
||
|
||
// layer.confirm('确认移除['+ eventdata.name + ']', {
|
||
// btn: ['取消','删除 '] //按钮
|
||
// }, function(){
|
||
// //取消
|
||
// layer.close(layer.index);
|
||
// }, function(){
|
||
// //删除
|
||
// X.api('dashboard/del_report','post',{_id:X['DATA']['dashboard_id'],report_id:eventdata.id},function(){
|
||
// X.pageLogic['dashboard'].gettabledata();
|
||
// });
|
||
// });
|
||
// }
|
||
// });
|
||
|
||
//设置时间
|
||
X.daterender(".model-times",function(start, end, label){
|
||
// var id = $(this).attr('data-id');
|
||
var oclickarr = X.DATA.oclickarr;
|
||
var id = 'times'+oclickarr.id;
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
$("#"+id).html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
|
||
var reportid = [];
|
||
reportid.push(oclickarr.id);
|
||
X.api('report/read_report','post',{project_id:X.DATA['projectid'],report_id:reportid,dashboard_id:X.DATA.dashboard_id},function(q){
|
||
if(q.length > 0){
|
||
var query = {
|
||
eventView:q[0]['query']['eventView'],
|
||
events:q[0]['query']['events'],
|
||
};
|
||
query['eventView']['startTime'] = startTime;
|
||
query['eventView']['endTime'] = endTime;
|
||
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
query['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
query['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
// 获取选择后的时间粒度
|
||
var timeParticleSizeid = "screenlist"+oclickarr.id;
|
||
var timeParticleSizename = $("#"+timeParticleSizeid).html();
|
||
var timeParticleSize;
|
||
X.granularityid(timeParticleSizename,function(d){
|
||
timeParticleSize = d;
|
||
if(oclickarr.cat == "retention" || oclickarr.cat == "scatter"){
|
||
query['eventView']['unitNum'] = parseInt(timeParticleSize);
|
||
}else {
|
||
query['eventView']['timeParticleSize'] = timeParticleSize;
|
||
}
|
||
// query['eventView']['timeParticleSize'] = timeParticleSize;
|
||
for(let i in X.DATA['screenlist']){
|
||
if(X.DATA['screenlist'][i]['id'] == oclickarr.id){
|
||
query['eventView']['filts'] = X.DATA['screenlist'][i]['filts']
|
||
}
|
||
}
|
||
X.api("ck/"+ oclickarr.cat +"_model","post",query,function(val){
|
||
if(JSON.stringify(val) != "{}" && JSON.stringify(val) != "[]"){
|
||
var bbsetdata = {
|
||
graph_size:oclickarr['modelsize'],
|
||
graph_type:oclickarr['modeltype'],
|
||
model:oclickarr['cat'],
|
||
name:oclickarr['name'],
|
||
report_id:oclickarr['id'],
|
||
query:query,
|
||
modelswitch:q[0].show_config.modelswitch,
|
||
ascending:q[0].show_config.ascending
|
||
}
|
||
|
||
var modeldata = X.pageLogic['dashboard'].modeldata(bbsetdata,val);
|
||
//渲染模板和数据
|
||
X.template("modeltable",'conent-box'+modeldata[0]['id'],modeldata[0],function(){
|
||
X.pageLogic['dashboard'].morefeatures(modeldata[0]);
|
||
});
|
||
|
||
}else {
|
||
layer.msg('无数据!!!');
|
||
}
|
||
|
||
})
|
||
});
|
||
}else {
|
||
layer.msg('无数据qqq');
|
||
}
|
||
})
|
||
});
|
||
|
||
|
||
if(eventdata['modeltype'] == 'echarts' && eventdata['modelsize'] != 'small' ){
|
||
var myChart = echarts.init(document.getElementById(eventdata['id']));
|
||
if(eventdata['cat'] == 'user_property'){
|
||
var option = {
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
legend: {
|
||
// data: eventdata['legendnamearr'],
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
axisTick: {show: false},
|
||
data: eventdata['xAxisData']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: [{
|
||
data: eventdata['seriesData'],
|
||
type: 'bar',
|
||
|
||
}]
|
||
};
|
||
}else{
|
||
var option = {
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
},
|
||
formatter:function(params){
|
||
//鼠标移入图表自定义显示内容
|
||
var axisIndex = params[0]['axisIndex'];
|
||
if(eventdata['proid_name'] && eventdata['proid_name'].length > 0){
|
||
var index = params[0]['dataIndex'];
|
||
var money = eventdata['proid_money'][index];
|
||
var name = eventdata['proid_name'][index];
|
||
var html = name+'<br/>'+'次数:'+ params[axisIndex]['data']+"<br/>"+'总金额:'+money;
|
||
|
||
}else {
|
||
var html = params[0]['axisValue']+'<br/>';
|
||
for(let i in params){
|
||
html+= params[i]['seriesName']+':'+ params[i]['value']+"<br/>"
|
||
}
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
bottom:0,
|
||
data: eventdata['legenddata'],
|
||
selected:eventdata['selected']
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '10%',
|
||
top: '5%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
axisTick: {show: false},
|
||
data: eventdata['xAxisData']
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: eventdata['seriesData']
|
||
};
|
||
}
|
||
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
},
|
||
|
||
//获取表格数据
|
||
//先渲染外框大小位置和标题
|
||
gettabledata:function(){
|
||
if(X.DATA['dashboard_id'] && X.DATA['dashboard_id'] != ""){
|
||
X.modelapi('dashboard/','post',{id:X.DATA['dashboard_id']},function(d){
|
||
X['DATA']['kanbanlist'] = d;
|
||
var modellist=[];
|
||
for(let i in d){
|
||
var arr = {
|
||
sort:d[i]['sort'],
|
||
report_id:d[i]['report_id']
|
||
}
|
||
modellist.push(arr);
|
||
}
|
||
modellist.sort( X.compare("sort") );
|
||
var num = 0;
|
||
$("#model-box").html("");//清空表格数据
|
||
for(let i in modellist){
|
||
for(let z in d){
|
||
if(modellist[i]['sort'] == d[z]['sort'] && modellist[i]['report_id'] == d[z]['report_id']){
|
||
//渲染模板和数据
|
||
X.laytpldata("#kanban-model-box-dot",d[z],null,function(html){
|
||
$('#model-box').append(html);
|
||
num ++;
|
||
// X.pageLogic['dashboard'].fillmodeldata(d[z]);
|
||
});
|
||
//当外框和标题渲染完在渲染数据
|
||
if(num == Object.getOwnPropertyNames(d).length){
|
||
for(let q in d){
|
||
// console.log(d[q]);
|
||
X.pageLogic['dashboard'].fillmodeldata(d[q]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
})
|
||
}
|
||
},
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/datacheck.js
|
||
(function(){
|
||
X.pageLogic['datacheck'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
|
||
X.api("project/","get",{},function(d){
|
||
X.laytpldata('#select-datacheck-list-box-dot',d,'.select-datacheck-list-box',function(){
|
||
layui.form.render();
|
||
});
|
||
})
|
||
|
||
// 事件属性添加
|
||
var eventarr = [];
|
||
$(document).off('click','.eventattr-add').on('click','.eventattr-add',function(){
|
||
var arr = {
|
||
'attrname':'',
|
||
'v':''
|
||
}
|
||
eventarr.push(arr);
|
||
X.laytpldata("#eventattr-box-dot",eventarr,"#datacheck-eventattr-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
// 事件属性删除
|
||
$(document).off('click','.attrname-del').on('click','.attrname-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
eventarr.splice(index,1);
|
||
X.laytpldata("#eventattr-box-dot",eventarr,"#datacheck-eventattr-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
$(document).off('click','.eventattr-input').on('blur','.eventattr-input',function(){
|
||
var index = $(this).attr('data-index');
|
||
if(eventarr[index] == undefined){
|
||
var arr = {
|
||
'attrname':'',
|
||
'v':''
|
||
}
|
||
eventarr.push(arr);
|
||
}
|
||
eventarr[index]['attrname'] = $(this).val();
|
||
});
|
||
|
||
layui.form.on('select(eventattr_filter)',function(data){
|
||
var value = data.value;
|
||
var valarr = value.split('_');
|
||
var index = valarr[1];
|
||
var val = valarr[0];
|
||
eventarr[index]['v'] = val;
|
||
});
|
||
|
||
$(document).off('click','.eventattr-copy').on('click','.eventattr-copy',function(){
|
||
var txt = $(".datacheck-copy-txt-box").val();
|
||
var valarr = txt.split(/[(\r\n)\r\n]+/);
|
||
// console.log(valarr);
|
||
var dataDarr = [];
|
||
for(let i in valarr){
|
||
var arr = valarr[i].split("\t");
|
||
// console.log(arr);
|
||
dataDarr.push(arr);
|
||
}
|
||
var eventdata = [];
|
||
for(let i in dataDarr){
|
||
if(dataDarr[i][1]){
|
||
var arr = {
|
||
'attrname': dataDarr[i][1],
|
||
'v': fieidmapping(dataDarr[i][2])
|
||
}
|
||
eventdata.push(arr);
|
||
}
|
||
}
|
||
eventarr = eventdata;
|
||
layui.form.val('datacheckexample',{
|
||
'eventname':dataDarr[0][0]
|
||
});
|
||
// console.log(eventarr);
|
||
// return;
|
||
X.laytpldata("#eventattr-box-dot",eventarr,"#datacheck-eventattr-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
// 字段映射
|
||
function fieidmapping(d){
|
||
if(d == 'int'){
|
||
return 'integer';
|
||
}else if(d == 'str'){
|
||
return 'string';
|
||
}else if(d == 'date'){
|
||
return 'date';
|
||
}else if(d == 'json'){
|
||
return 'json'
|
||
}else {
|
||
return 'array'
|
||
}
|
||
}
|
||
|
||
// 其他条件添加
|
||
var conditionarr = [];
|
||
$(document).off('click','.condition-add').on('click','.condition-add',function(){
|
||
var arr = {
|
||
'conditionname':'',
|
||
'v':''
|
||
}
|
||
conditionarr.push(arr);
|
||
X.laytpldata("#condition-box-dot",conditionarr,"#datacheck-condition-box");
|
||
layui.form.render();
|
||
});
|
||
// 其他条件删除
|
||
$(document).off('click','.condition-del').on("click",'.condition-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
conditionarr.splice(index,1);
|
||
X.laytpldata("#condition-box-dot",conditionarr,"#datacheck-condition-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
$(document).off('click','.condition-input').on('blur','.condition-input',function(){
|
||
var index = $(this).attr('data-index');
|
||
if(conditionarr[index] == undefined){
|
||
var arr = {
|
||
'conditionname':'',
|
||
'v':''
|
||
}
|
||
conditionarr.push(arr);
|
||
}
|
||
conditionarr[index]['conditionname'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.condition-v-input').on('blur','.condition-v-input',function(){
|
||
var index = $(this).attr('data-index');
|
||
if(conditionarr[index] == undefined){
|
||
var arr = {
|
||
'conditionname':'',
|
||
'v':''
|
||
}
|
||
conditionarr.push(arr);
|
||
}
|
||
conditionarr[index]['v'] = $(this).val();
|
||
});
|
||
|
||
// 默认属性
|
||
var baseeventdata = {};
|
||
$(document).off('click','.baseevent').on('click','.baseevent',function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
offset: 'auto',
|
||
anim: 5,
|
||
skin: 'yourclass',
|
||
url: 'datacheck_moren',
|
||
data:baseeventdata,
|
||
callback : function(d){
|
||
baseeventdata = d;
|
||
}
|
||
})
|
||
});
|
||
|
||
//默认全选默认属性
|
||
X.api('check_data/default_field','get',{},function(d){
|
||
baseeventdata = d;
|
||
});
|
||
|
||
$(document).off('click','.datacheck-but-bc').on('click','.datacheck-but-bc',function(){
|
||
var fromdata = layui.form.val('datacheckexample');
|
||
var is_unique;
|
||
// console.log(fromdata);
|
||
if(fromdata.only == "true"){
|
||
is_unique = true
|
||
}else {
|
||
is_unique = false
|
||
}
|
||
|
||
var props={},where={};
|
||
for(let i in eventarr){
|
||
props[eventarr[i]['attrname']] = eventarr[i]['v']
|
||
}
|
||
for(let i in conditionarr){
|
||
where[conditionarr[i]['conditionname']] = conditionarr[i]['v']
|
||
}
|
||
|
||
var data={
|
||
'game': fromdata.game,
|
||
'db_name':fromdata.db_name,
|
||
'event_name':fromdata.eventname,
|
||
'is_unique':is_unique,
|
||
'props':props,
|
||
'where':where,
|
||
'default_field':baseeventdata,
|
||
'modeltitle': modeltitle
|
||
};
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
offset: 'auto',
|
||
anim: 5,
|
||
skin: 'yourclass',
|
||
url: 'datacheck_preser',
|
||
data:data
|
||
})
|
||
});
|
||
|
||
var modeltitle
|
||
$(document).off('click','.datacheck-but-ck').on('click','.datacheck-but-ck',function(){
|
||
X.parametersopen({},'datacheck_list','rt',function(d){
|
||
var data = d;
|
||
var props = data.check.props;
|
||
var where = data.check.where;
|
||
baseeventdata = data.check.default_field;
|
||
var eventData=[];
|
||
var conditionData=[];
|
||
for(let i in props){
|
||
var arr = {
|
||
'attrname':i,
|
||
'v':props[i]
|
||
}
|
||
eventData.push(arr);
|
||
}
|
||
eventarr = eventData;
|
||
for(let i in where){
|
||
var arr = {
|
||
'conditionname':i,
|
||
'v':where[i]
|
||
}
|
||
conditionData.push(arr);
|
||
}
|
||
conditionarr = conditionData;
|
||
modeltitle = data.title;
|
||
layui.form.val('datacheckexample',{
|
||
'game':data['game'],
|
||
'db_name':data['check']['db_name'],
|
||
'eventname':data['check']['event_name'],
|
||
'only':data['check']['is_unique'],
|
||
});
|
||
|
||
X.laytpldata("#eventattr-box-dot",eventarr,"#datacheck-eventattr-box");
|
||
X.laytpldata("#condition-box-dot",conditionarr,"#datacheck-condition-box");
|
||
layui.form.render();
|
||
})
|
||
});
|
||
|
||
|
||
// 查询按钮
|
||
$(document).off('click','.datacheck-but-cx').on('click','.datacheck-but-cx',function(){
|
||
var fromdata = layui.form.val('datacheckexample');
|
||
var is_unique;
|
||
// console.log(fromdata);
|
||
if(fromdata.only == "true"){
|
||
is_unique = true
|
||
}else {
|
||
is_unique = false
|
||
}
|
||
|
||
var props={},where={};
|
||
for(let i in eventarr){
|
||
props[eventarr[i]['attrname']] = eventarr[i]['v']
|
||
}
|
||
for(let i in conditionarr){
|
||
where[conditionarr[i]['conditionname']] = conditionarr[i]['v']
|
||
}
|
||
|
||
var data={
|
||
'game': fromdata.game,
|
||
'db_name':fromdata.db_name,
|
||
'event_name':fromdata.eventname,
|
||
'is_unique':is_unique,
|
||
'props':props,
|
||
'where':where,
|
||
'default_field':baseeventdata
|
||
};
|
||
// console.log(data);
|
||
X.api('check_data/check','post',data,function(d){
|
||
$(".datacheck-result-info-tongguo").html("");
|
||
$(".datacheck-result-info-cuowu").html("");
|
||
|
||
// X.laytpldata("#datacheck-table-title-box",d.title,".table-fenxi-th");
|
||
// X.laytpldata("#datacheck-tbody-title-box",d.data,".table-fenxi-td");
|
||
|
||
var data=d;
|
||
var pass_list = data.pass_list;
|
||
var fail_list = data.fail_list;
|
||
for(let i in pass_list){
|
||
$(".datacheck-result-info-tongguo").append(pass_list[i]);
|
||
}
|
||
for(let i in fail_list){
|
||
$(".datacheck-result-info-cuowu").append(fail_list[i]);
|
||
}
|
||
|
||
var headdata=[];
|
||
for(let i in data.title){
|
||
var arr = {
|
||
width: "150px",
|
||
field: data.title[i],
|
||
fixed: false
|
||
};
|
||
if(i == 0){
|
||
arr['fixed'] = true;
|
||
}
|
||
headdata.push(arr);
|
||
}
|
||
// X.fixedTable("datacheck-table-box",'row-col-fixed','',headdata,data.data);
|
||
|
||
|
||
X.laytpldata("#datacheck-table-title-box",data.title,".table-fenxi-th");
|
||
X.laytpldata("#datacheck-tbody-title-box",data.data ,".table-fenxi-td");
|
||
|
||
})
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/datacheck_list.js
|
||
(function(){
|
||
X.pageLogic['datacheck_list'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
// var data = parms.extData;
|
||
$('.datacheck_list-box').css('height',window.innerHeight+'px');
|
||
|
||
posttemplate();
|
||
var savelist;
|
||
function posttemplate(){
|
||
X.api('check_data/template','get',{},function(d){
|
||
savelist = d;
|
||
X.laytpldata("#save-list-content-box-dot",d,".save-list-content-box");
|
||
})
|
||
};
|
||
|
||
$(document).off('click','.save-list').on('click','.save-list',function(){
|
||
var index = $(this).attr('data-index');
|
||
var data = savelist[index];
|
||
layer.closeAll();
|
||
me.callback && me.callback(data);
|
||
});
|
||
// 删除
|
||
$(document).off('click',".save-list-del").on('click','.save-list-del',function(e){
|
||
e.stopPropagation();
|
||
var title = $(this).attr("data-title");
|
||
var data = {
|
||
title: title
|
||
}
|
||
X.api('check_data/del_template','post',data,function(){
|
||
layer.msg('删除成功');
|
||
posttemplate();
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.save-list-qx').on('click','.save-list-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/datacheck_moren.js
|
||
(function(){
|
||
X.pageLogic['datacheck_moren'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var baseeventdata = parms.data;
|
||
|
||
var default_field
|
||
X.api('check_data/default_field','get',{},function(d){
|
||
default_field = d;
|
||
var listarr = [];
|
||
if(JSON.stringify(baseeventdata) != "{}"){
|
||
for(let i in default_field){
|
||
var arr= {
|
||
'title': i,
|
||
'on': 0
|
||
}
|
||
for(let j in baseeventdata){
|
||
if(i == j){
|
||
arr['on'] = 1;
|
||
break;
|
||
}
|
||
}
|
||
listarr.push(arr);
|
||
}
|
||
}else {
|
||
for(let i in default_field){
|
||
var arr = {
|
||
'title': i,
|
||
'on':1
|
||
}
|
||
listarr.push(arr);
|
||
}
|
||
}
|
||
// console.log(listarr);
|
||
// baseeventdata = default_field;
|
||
X.laytpldata("#baseevent-checkbox-box-dot",listarr,".baseevent-checkbox-box");
|
||
layui.form.render();
|
||
})
|
||
// $.ajax({
|
||
// url: 'http://10.0.0.77:7997/v1/check/default_field',
|
||
// type:'get',
|
||
// dataType: 'json',
|
||
// async:true,
|
||
// contentType:'application/json',
|
||
// beforeSend: function () {
|
||
// // loading 显示
|
||
// },
|
||
// success:function(d){
|
||
// default_field = d.data;
|
||
// var listarr = [];
|
||
// if(JSON.stringify(baseeventdata) != "{}"){
|
||
// for(let i in default_field){
|
||
// var arr= {
|
||
// 'title': i,
|
||
// 'on': 0
|
||
// }
|
||
// for(let j in baseeventdata){
|
||
// if(i == j){
|
||
// arr['on'] = 1;
|
||
// break;
|
||
// }
|
||
// }
|
||
// listarr.push(arr);
|
||
// }
|
||
// }else {
|
||
// for(let i in default_field){
|
||
// var arr = {
|
||
// 'title': i,
|
||
// 'on':1
|
||
// }
|
||
// listarr.push(arr);
|
||
// }
|
||
// }
|
||
// // console.log(listarr);
|
||
// // baseeventdata = default_field;
|
||
// X.laytpldata("#baseevent-checkbox-box-dot",listarr,".baseevent-checkbox-box");
|
||
// layui.form.render();
|
||
// },
|
||
// error:function(error){
|
||
// layer.msg('条件错误');
|
||
// }
|
||
// });
|
||
|
||
// 清除
|
||
$(document).off('click','.baseevent-but-qc').on('click','.baseevent-but-qc',function(){
|
||
// console.log(default_field);
|
||
var listarr = [];
|
||
for(let i in default_field){
|
||
var arr = {
|
||
'title': i,
|
||
'on':0
|
||
}
|
||
listarr.push(arr);
|
||
}
|
||
X.laytpldata("#baseevent-checkbox-box-dot",listarr,".baseevent-checkbox-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
// 全选
|
||
$(document).off('click','.baseevent-but-qb').on('click','.baseevent-but-qb',function(){
|
||
// console.log(default_field);
|
||
var listarr = [];
|
||
for(let i in default_field){
|
||
var arr = {
|
||
'title': i,
|
||
'on':1
|
||
}
|
||
listarr.push(arr);
|
||
}
|
||
X.laytpldata("#baseevent-checkbox-box-dot",listarr,".baseevent-checkbox-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
$(document).off('click','.baseevent-but-qx').on('click','.baseevent-but-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
|
||
$(document).off('click','.baseevent-but-ok').on('click','.baseevent-but-ok',function(){
|
||
var fromdata = layui.form.val('baseeventexample');
|
||
var defaultfield = {};
|
||
for(let i in fromdata){
|
||
defaultfield[i] = default_field[i]
|
||
}
|
||
// baseeventdata = defaultfield;
|
||
me.callback && me.callback(defaultfield);
|
||
layer.close( me.parms.layIndex );
|
||
});
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/datacheck_preser.js
|
||
(function(){
|
||
X.pageLogic['datacheck_preser'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var check = parms.data;
|
||
if(check.modeltitle){
|
||
$('.datacheck_preser-save-title').val(check.modeltitle);
|
||
}
|
||
$(document).off('click','.datacheck_preser-but-qd').on('click','.datacheck_preser-but-qd',function(){
|
||
if($('.datacheck_preser-save-title').val() == ""){
|
||
layer.msg('名称不能为空');
|
||
return;
|
||
}
|
||
var data = {
|
||
check:check,
|
||
title: $('.datacheck_preser-save-title').val()
|
||
}
|
||
|
||
X.api('check_data/save','post',data,function(d){
|
||
if(d == true){
|
||
layer.closeAll();
|
||
layer.msg('保存成功');
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.datacheck_preser-but-qx').on('click','.datacheck_preser-but-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/datarights.js
|
||
(function(){
|
||
X.pageLogic['datarights'] = {
|
||
init : function(){
|
||
var me = this;
|
||
|
||
$(".datarights-add-box").click(function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'datarightsedit'
|
||
})
|
||
})
|
||
|
||
me.dataauthlist();
|
||
|
||
layui.table.on('tool(datarightstest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === "edit"){
|
||
// 编辑
|
||
X.parametersopen(data,'datarightsedit','auto',function(d){
|
||
// console.log("1111",d);
|
||
me.dataauthlist();
|
||
})
|
||
|
||
}
|
||
})
|
||
|
||
},
|
||
dataauthlist:function(){
|
||
X.tabledata('#datarightsdata','authz/account_owner_list',[[
|
||
{field:'name', title: '用户名', sort: true}
|
||
,{field:'nickname', title: '显示名'}
|
||
,{field:'owner_list', title: '渠道', sort: true}
|
||
,{fixed: 'right', title:'操作', toolbar: '#datarights-barDemo', width:100}
|
||
]]);
|
||
}
|
||
};
|
||
})();
|
||
|
||
|
||
// srczip/logic/datarightsedit.js
|
||
(function(){
|
||
X.pageLogic['datarightsedit'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
// console.log(data);
|
||
|
||
if(data){
|
||
$(".datarightsedit-txt-input").html(data.owner_list);
|
||
}
|
||
|
||
|
||
$(".datarightsedit-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".datarightsedit-top-box img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".datarightsedit-qd").click(function(){
|
||
var tit = $(".datarightsedit-txt-input").val();
|
||
var owners = tit.split(",");
|
||
X.api("authz/update_account_owner","post",{owners:owners,account_name:data.name},function(d){
|
||
layer.msg("创建成功");
|
||
layer.closeAll();
|
||
X.pageLogic.datarights.dataauthlist();
|
||
})
|
||
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/defaultrole.js
|
||
(function(){
|
||
X.pageLogic['defaultrole'] = {
|
||
init : function(parms){
|
||
var role_id,datalist;
|
||
updataroles();
|
||
function updataroles(){
|
||
X.api("authz/roles","get",{},function(d){
|
||
datalist = d;
|
||
if(d[0]){
|
||
role_id = d[0]['_id'];
|
||
$(".projectadmin-list-name").html(d[0]["name"]);
|
||
X.laytpldata("#projectadmin-con-hz-left-list-tit-xiangmu-dot",d,".projectadmin-con-hz-left-list-tit-xiangmu");
|
||
updataapiinfo(d[0]['_id']);
|
||
}else {
|
||
layer.msg('查无数据');
|
||
}
|
||
|
||
// X.laytpldata("#projectadmin-info-box-dot",d.sys_role[0]['authority'],".projectadmin-info-box");
|
||
});
|
||
}
|
||
|
||
$(document).off('click',".menu_dapax .item_kuvn").on('click',".menu_dapax .item_kuvn",function(){
|
||
$(".menu_dapax .item_kuvn").removeClass("selected___3ctlt");
|
||
$(this).addClass("selected___3ctlt");
|
||
var url = $(this).attr("data-url");
|
||
});
|
||
|
||
$(document).off('click','.roleinproject-tit').on("click",".roleinproject-tit",function(){
|
||
var index = $(this).attr("data-index");
|
||
$(".projectadmin-con-hz-left-list-con").removeClass("selected___3ctlt");
|
||
$(this).addClass("selected___3ctlt");
|
||
$(".projectadmin-list-name").html(datalist[index]['name']);
|
||
var id = $(this).attr("data-id");
|
||
updataapiinfo(id);
|
||
// X.laytpldata("#projectadmin-info-box-dot",data.dom_role[index]['authority'],".projectadmin-info-box");
|
||
});
|
||
|
||
function updataapiinfo(id){
|
||
role_id = id;
|
||
X.api("authz/get_permissions_for_user_in_domain","post",{role_id:id,game:X['DATA']['game']},function(d){
|
||
X.laytpldata("#projectadmin-info-box-dot",d,".projectadmin-info-box");
|
||
});
|
||
};
|
||
|
||
$(document).off('click','.projectadmin-del').on('click','.projectadmin-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
var path = $(this).attr('data-path');
|
||
layer.confirm('确认删除当前api吗?', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("authz/del_policy",'post',{role_id:role_id,game:X['DATA']['game'],path:path,act:"*"},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
updataapiinfo(role_id);
|
||
})
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.projectadmin-edit').on('click','.projectadmin-edit',function(params){
|
||
var path = $(this).attr('data-path');
|
||
var arr = [];
|
||
arr.push(path);
|
||
X.api("authz/add_policy",'post',{role_id:role_id,game:X['DATA']['game'],path_list:arr,act:"*"},function(d){
|
||
layer.close(layer.index);
|
||
layer.msg('添加成功');
|
||
updataapiinfo(role_id);
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.projectadmin-gongduo').on('click','.projectadmin-gongduo',function(e){
|
||
e.stopPropagation();
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var id = obj.attr('data-id');
|
||
var name = obj.attr("data-name");
|
||
var arr = [
|
||
{
|
||
title:'重命名',
|
||
id:'edit'
|
||
},
|
||
{
|
||
title:'删除',
|
||
id:'del'
|
||
}
|
||
]
|
||
X.querycriteriapop(arr,'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val.id == 'del'){
|
||
layer.confirm('确认删除当前角色吗?', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("authz/del_role_user_domain",'post',{role_id:id,game:X['DATA']['game'],username:name},function(d){
|
||
layer.close(layer.index);
|
||
layer.msg('删除成功');
|
||
updataroles();
|
||
})
|
||
});
|
||
}else {
|
||
var arr = {
|
||
id:id,
|
||
title:$(".projectadmin-list-name").html()
|
||
}
|
||
X.parametersopen(arr,"roleeditname",'auto',function(d){
|
||
updataroles();
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/deluserinfo.js
|
||
(function(){
|
||
X.pageLogic['deluserinfo'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
$(".deluserinfo-bottom-left").click(function(e){
|
||
X.api("project/del_member","post",{username:data.name,project_id:X.DATA.projectid,role:data.role},function(d){
|
||
layer.msg('删除成功');
|
||
me.callback && me.callback(data);
|
||
layer.closeAll();
|
||
})
|
||
})
|
||
|
||
$(".deluserinfo-qx").click(function(e){
|
||
layer.closeAll();
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/distribution.js
|
||
(function(){
|
||
X.pageLogic['distribution'] = {
|
||
init : function(){
|
||
|
||
var data ={
|
||
"eventView":{
|
||
"cksql":"scatter",
|
||
"endTime":"",
|
||
"groupBy":[],
|
||
"startTime":"",
|
||
"timeParticleSize":"P1D",
|
||
"e_days":0,
|
||
"s_days":7
|
||
},
|
||
"events":[
|
||
|
||
]
|
||
};
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 日期渲染
|
||
X.daterender("#retained-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
distributiondata();
|
||
});
|
||
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
// console.log(d);
|
||
backfilldata(d);
|
||
|
||
})
|
||
});
|
||
var baobiaodata;
|
||
function backfilldata(d){
|
||
if(d){
|
||
baobiaodata = d;
|
||
data = d.query;
|
||
// 数据看板点进来时吧保存的时间初始化为当前时间
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
X.template("userpar","userpar-event",data['events']);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
distributiondata();
|
||
}
|
||
};
|
||
|
||
X.template("grouped","shushi");
|
||
|
||
var eventdata = [];
|
||
var type2data = [];
|
||
var groupitemeventsdata = [];
|
||
var screentypearr=[]; //筛选项数据
|
||
var drr = [];
|
||
screentypearr.push(drr); //每一个筛选事件按添加次数依次写入
|
||
var quotas_map,filter_map
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
eventdata = d;
|
||
var arr = [
|
||
{
|
||
"analysis":"times",
|
||
"analysisDesc":"次数",
|
||
"eventName":d[0]['category'][0]['event_name'],
|
||
"eventDesc":d[0]['category'][0]['event_desc'],
|
||
"filts":[],
|
||
"intervalType":"def",
|
||
"quota":"*",
|
||
"quotaname":"次数",
|
||
"relation":"and", //筛选关系
|
||
"type":"normal",
|
||
"renameindicator":'' //重命名指标
|
||
}
|
||
]
|
||
data['events'] = arr;
|
||
|
||
X.api("data_auth/load_prop_quotas","post",{event_name:d[0]['category'][0]['event_name'], 'model':'scatter' },function(d){
|
||
X.template("userpar","userpar-event",data['events']);
|
||
var retdata = d.staid_quots.concat(d.props);
|
||
type2data[0]=retdata;
|
||
screentypearr[0] = d.props;
|
||
})
|
||
X.api("data_auth/load_filter_props","post",{event_name:d[0]['category'][0]['event_name']},function(val){
|
||
groupitemeventsdata = val;
|
||
})
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
})
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.scatterid && X.DATA.scatterid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.scatterid);
|
||
if(X.DATA.authority != 'rw'){
|
||
$('.analysis-savereport').hide();
|
||
}else {
|
||
$('.analysis-saveas').hide();
|
||
}
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var dataevent= data['events'][index];
|
||
|
||
X.querycriteriapop(eventdata,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.id);
|
||
dataevent['eventName'] = val.name;
|
||
dataevent['eventDesc'] = val.id;
|
||
// X.api("data_auth/load_filter_props","post",{event_name:val.name},function(val){
|
||
// groupitemeventsdata= val;
|
||
// })
|
||
|
||
})
|
||
});
|
||
|
||
//设置一级事件中第二个参数
|
||
$(document).off('click','.analysis-zhibiao-list-type2').on('click','.analysis-zhibiao-list-type2',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
if(type2data.length >0){
|
||
X.querycriteriapop(type2data[0],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
// console.log(val);
|
||
$("#analysis-zhibiao-list-type2-"+index).html(val.title);
|
||
|
||
data['events'][index]['quotaname'] = val.title;
|
||
data['events'][index]['quota'] = val.id;
|
||
data['events'][index]['data_type'] = val.data_type;
|
||
if(val.category && val.category.length > 0){
|
||
$("#analysis-zhibiao-list-type3-"+index).show();
|
||
$("#analysis-zhibiao-list-type3-"+index).html(val.category[0].title);
|
||
data['events'][index]['analysisDesc'] = val.category[0].title;
|
||
data['events'][index]['analysis'] = val.category[0].id;
|
||
}else {
|
||
$("#analysis-zhibiao-list-type3-"+index).hide();
|
||
// data['events'][index]['analysis'] = val.analysis;
|
||
}
|
||
X.template("userpar","userpar-event",data['events']);
|
||
}
|
||
})
|
||
}
|
||
});
|
||
|
||
//设置一级事件中第三个参数
|
||
$(document).off('click','.analysis-zhibiao-condition').on('click','.analysis-zhibiao-condition',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
var type = obj.attr("data-type");
|
||
X.querycriteriapop(quotas_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
$("#analysis-zhibiao-list-type3-"+index).html(val.title);
|
||
data['events'][index]['analysisDesc'] = val.title;
|
||
data['events'][index]['analysis'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.userevent-granularity').on('click','.userevent-granularity',function(){
|
||
var sectionid = data['events'][0];
|
||
X.parametersopen(sectionid,'groupeditemspop',"auto",function(val){
|
||
data['events'][0]['intervalType'] = val.type;
|
||
if(val.type == "user_defined"){
|
||
data['events'][0]['quotaIntervalArr'] = val.quotaIntervalArr;
|
||
}
|
||
})
|
||
});
|
||
|
||
//重命名指标
|
||
$(document).off('click','.analysis-chongmingming').on('click','.analysis-chongmingming',function() {
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").show();
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-del").show();
|
||
});
|
||
|
||
//删除重命名
|
||
$(document).off('click','.analysis-chongmingming-del').on('click','.analysis-chongmingming-del',function() {
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").hide();
|
||
$(".analysis-con-left-screen-list-left-zhibiaoname-txt").val('');
|
||
$(this).hide();
|
||
$(".analysis-chongmingming ").show();
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input',function(){
|
||
var txt = $(this).val();
|
||
data['events'][0]['renameindicator'] = txt;
|
||
});
|
||
|
||
// 添加筛选项
|
||
$(document).off('click','.analysis-shaix').on('click','.analysis-shaix',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
$(document).off('click','.analysis-zhibiao-updata-initial-event').on("click",'.analysis-zhibiao-updata-initial-event',function(){
|
||
addscreen(0);
|
||
})
|
||
|
||
// 添加筛选项
|
||
function addscreen(index){
|
||
// X.api('data_auth/load_filter_props',"post",{event_name:data['events'][index]["eventName"]},function(d){
|
||
// console.log(d);
|
||
var arr = {
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],//事件id
|
||
"comparator_name":filter_map[groupitemeventsdata[0]['category'][0]['data_type']][0]['title'],//选择符号中文显示
|
||
"comparator":filter_map[groupitemeventsdata[0]['category'][0]['data_type']][0]['id'],//符号id
|
||
"data_type":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"ftv":[],//条件
|
||
"strftv":'',//字符串显示条件
|
||
"tableType": groupitemeventsdata[0]['id']
|
||
} //筛选数据
|
||
data['events'][index]['filts'].push(arr);
|
||
X.template("userpar","userpar-event",data['events']); //更新事件
|
||
|
||
// })
|
||
};
|
||
|
||
$(document).off("click",".ta-property-select").on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
// console.log(val);
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
|
||
data['events'][index]['filts'][indexs]['columnDesc'] = htmlstring;
|
||
data['events'][index]['filts'][indexs]['columnName'] = val.id;
|
||
data['events'][index]['filts'][indexs]['data_type'] = val.type;
|
||
data['events'][index]['filts'][indexs]['tableType'] = val.table_type;
|
||
if(val.type == 'user_label'){
|
||
data['events'][index]['filts'][indexs]['comparator_name'] = "是";
|
||
data['events'][index]['filts'][indexs]['comparator'] = 'in';
|
||
}
|
||
X.template("userpar","userpar-event",data['events']);
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = $(this).attr('data-type');
|
||
X.querycriteriapop(filter_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['filts'][indexs]['comparator_name'] = val.title;
|
||
data['events'][index]['filts'][indexs]['comparator'] = val.id;
|
||
X.template("userpar","userpar-event",data['events']);
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-con-left-screen-list-right-screen-qh-tit').on('click','.analysis-con-left-screen-list-right-screen-qh-tit',function(){
|
||
var tit = $(this).html();
|
||
if(tit == '且'){
|
||
$(this).html('或');
|
||
data['events'][0]['relation'] = 'or';
|
||
}else{
|
||
$(this).html('且');
|
||
data['events'][0]['relation'] = 'and';
|
||
}
|
||
});
|
||
|
||
$(document).off("click",".analysis-zhibiao-list-type4").on("click",".analysis-zhibiao-list-type4",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var columnName = data['events'][index]['filts'][indexs]['columnName'];
|
||
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
data['events'][index]['filts'][indexs]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['events'][index]['filts'][indexs]['ftv'] = arr;
|
||
X.template("userpar","userpar-event",data['events']);
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('change','.analysis-zhibiao-list-type4 input').on('change','.analysis-zhibiao-list-type4 input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['events'][index]['filts'][indexs]['ftv']=valarr;
|
||
data['events'][index]['filts'][indexs]['strftv']=val;
|
||
});
|
||
|
||
// 删除筛选
|
||
$(document).off('click','.analysis-zhibiao-list-del-initial-event').on('click','.analysis-zhibiao-list-del-initial-event',function(){
|
||
var index = $(this).attr("data-twonum");
|
||
data['events'][0]['filts'].splice(index,1);
|
||
X.template("userpar","userpar-event",data['events']);
|
||
});
|
||
|
||
// 分组项
|
||
$(document).off('click','.analysis-action-right').on('click','.analysis-action-right',function() {
|
||
var index = $(this).attr("data-index");
|
||
data.eventView.groupBy.splice(index,1);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
});
|
||
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function() {
|
||
|
||
var arr = {
|
||
"columnDesc": "#account_id",//事件中文显示
|
||
"columnName": "#account_id",//事件id
|
||
'data_type': "string",//类型
|
||
'table_type': "event",
|
||
"ftv":"",//条件
|
||
"section":''//区间
|
||
};
|
||
data['eventView']['groupBy'].push(arr);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data.eventView.groupBy[index]['columnDesc'] = val.title;
|
||
data.eventView.groupBy[index]['columnName'] = val.id;
|
||
data.eventView.groupBy[index]['data_type'] = val.type;
|
||
data.eventView.groupBy[index]['table_type'] = val.table_type;
|
||
});
|
||
});
|
||
|
||
// 时间粒度
|
||
X.laydropdown('.analtsis-timeParticleSize',X['DATA']['companylist']['distribution'],function(d){
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['timeParticleSize'] = d.id;
|
||
// retaineddata();
|
||
});
|
||
|
||
// 计算
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
|
||
distributiondata()
|
||
|
||
});
|
||
|
||
var querydata;
|
||
function distributiondata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/scatter_model","post",dataArr,function(d){
|
||
if(d != "查无数据"){
|
||
querydata = d;
|
||
d['tabletitle'] = $.extend(true,[],d['label']);
|
||
d['tabletitle'].unshift('事件发生时间','总人数');
|
||
updata(d);
|
||
$(".chawushuj").hide();
|
||
}else{
|
||
$("#distribution-echarts").empty();
|
||
$(".table-fenxi-th").html("");
|
||
$(".table-fenxi-td").html("");
|
||
$(".chawushuj").show();
|
||
}
|
||
|
||
})
|
||
};
|
||
|
||
function updata(d){
|
||
var title = $(".select-chart").attr("title");
|
||
if(title == '数据表'){ $(".table-div-box").show(); $(".analysis-echarts").hide(); retainedtable(d)}
|
||
else if(title == '数值分布'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retainednRetained(d) }
|
||
else if(title == '百分比分布'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retaineddayRetained(d) }
|
||
};
|
||
|
||
$(document).off('click','.analtsis-chart-switch').on('click','.analtsis-chart-switch',function(){
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '数据表'){ $(".table-div-box").show(); $(".analysis-echarts").hide(); retainedtable(querydata)}
|
||
else if($(this).attr('title') == '数值分布'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retainednRetained(querydata) }
|
||
else if($(this).attr('title') == '百分比分布'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retaineddayRetained(querydata) }
|
||
}else{
|
||
layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
});
|
||
|
||
function retainedtable(d){
|
||
var tabledata = [];
|
||
for(let i in d.list){
|
||
var arr = {
|
||
date: i,
|
||
total: d['list'][i]['总体']["total"],
|
||
data:[]
|
||
}
|
||
for(let j in d['list'][i]['总体']["n"]){
|
||
var nrr = {
|
||
n:0,
|
||
p:0
|
||
}
|
||
nrr["n"] = d['list'][i]['总体']["n"][j];
|
||
nrr["p"] = d['list'][i]['总体']["p"][j]
|
||
arr['data'].push(nrr);
|
||
}
|
||
tabledata.push(arr)
|
||
}
|
||
// console.log(tabledata);
|
||
X.laytpldata("#table-fenxi-th-dot",d.tabletitle,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",tabledata,".table-fenxi-td");
|
||
};
|
||
|
||
function retainednRetained(d){
|
||
var legendData = d.label;
|
||
var xAxisData = [];
|
||
var seriesData = [];
|
||
var arr =[];
|
||
for(let i in d['list']){
|
||
xAxisData.push(i);
|
||
for(let j in d['list'][i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d['list'][i][j]['n'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d['list'][i][j]['n'];
|
||
}
|
||
}
|
||
}
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in xAxisData){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(xAxisData[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for(let i in ydata){
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
areaStyle: {},
|
||
emphasis: {
|
||
focus: 'series'
|
||
},
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('distribution-echarts'));
|
||
var option = {
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: legendData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
function retaineddayRetained(d){
|
||
var legendData = d.label;
|
||
var xAxisData = [];
|
||
var seriesData = [];
|
||
var arr =[];
|
||
for(let i in d['list']){
|
||
xAxisData.push(i);
|
||
for(let j in d['list'][i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d['list'][i][j]['p'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d['list'][i][j]['p'];
|
||
}
|
||
}
|
||
}
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in xAxisData){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(xAxisData[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for(let i in ydata){
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
areaStyle: {},
|
||
emphasis: {
|
||
focus: 'series'
|
||
},
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('distribution-echarts'));
|
||
var option = {
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: legendData
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value',
|
||
axisLabel: {
|
||
formatter:'{value}%'
|
||
}
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
baobiaodata['saveas'] = 0;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
//另存为
|
||
$(document).off('click','.analysis-saveas').on('click','.analysis-saveas',function(){
|
||
baobiaodata['saveas'] = 1;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
});
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/dropdownlist.js
|
||
(function(){
|
||
X.pageLogic['dropdownlist'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var listdata = parms.extData;
|
||
// console.log('aaa',listdata);
|
||
|
||
X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
|
||
|
||
// $(document).off("bind",'.dropdownlist-input').on("bind",".dropdownlist-input",function(){
|
||
// var title = $(this).val();
|
||
// console.log(title);
|
||
// });
|
||
|
||
$('.dropdownlist-input').bind('input propertychange', function() {
|
||
var title = $(this).val();
|
||
if(title != ""){
|
||
var filteringdata = [];
|
||
for(let i in listdata){
|
||
if(listdata[i]['title'].indexOf(title) != -1 || listdata[i]['id'].indexOf(title) != -1){
|
||
filteringdata.push(listdata[i]);
|
||
}
|
||
}
|
||
// console.log(filteringdata);
|
||
X.laytpldata("#dropdownlist-con-box-dot",filteringdata,".dropdownlist-con-box");
|
||
}else{
|
||
X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
|
||
}
|
||
})
|
||
|
||
$(document).off('click','.dropdownlist-list').on('click','.dropdownlist-list',function(){
|
||
var index = $(this).attr("data-index");
|
||
var id = $(this).attr("data-id");
|
||
var title = $(this).attr("data-title");
|
||
for(let i in listdata){
|
||
if(listdata[i]['id'] == id && title == listdata[i]['title']){
|
||
var dataArr = listdata[i];
|
||
}
|
||
}
|
||
me.callback && me.callback(dataArr);
|
||
layer.close( me.parms.layIndex );
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/dropdownlist2.js
|
||
(function(){
|
||
X.pageLogic['dropdownlist2'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var listdata = parms.extData;
|
||
// console.log('aaa',listdata);
|
||
|
||
X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
|
||
|
||
$(document).off('click','.dropdownlist-list').on('click','.dropdownlist-list',function(){
|
||
var index = $(this).attr("data-index");
|
||
var dataArr = listdata[index];
|
||
layer.closeAll(0);
|
||
me.callback && me.callback(dataArr);
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/dropdownlist3.js
|
||
(function(){
|
||
X.pageLogic['dropdownlist3'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var listdata = parms.extData.data;
|
||
var comparator = parms.extData.comparator;
|
||
// console.log('aaa',listdata);
|
||
|
||
X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
|
||
|
||
// $(document).off("bind",'.dropdownlist-input').on("bind",".dropdownlist-input",function(){
|
||
// var title = $(this).val();
|
||
// console.log(title);
|
||
// });
|
||
|
||
$('.dropdownlist-input').bind('input propertychange', function() {
|
||
var title = $(this).val();
|
||
if(title != ""){
|
||
var filteringdata = [];
|
||
for(let i in listdata){
|
||
if(listdata[i]['title'].indexOf(title) != -1 || listdata[i]['id'].indexOf(title) != -1){
|
||
filteringdata.push(listdata[i]);
|
||
}
|
||
}
|
||
// console.log(filteringdata);
|
||
X.laytpldata("#dropdownlist-con-box-dot",filteringdata,".dropdownlist-con-box");
|
||
}else{
|
||
X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
|
||
}
|
||
})
|
||
|
||
var dataArr=[];
|
||
$(document).off('click','.dropdownlist-list').on('click','.dropdownlist-list',function(){
|
||
var index = $(this).attr("data-index");
|
||
var id = $(this).attr("data-id");
|
||
var title = $(this).attr("data-title");
|
||
var type = 0;
|
||
if(comparator == 'in'){
|
||
for(let i in dataArr){
|
||
if(dataArr[i]['id'] == id){
|
||
type = 1;
|
||
dataArr.splice(i,1)
|
||
break;
|
||
}else {
|
||
type = 0;
|
||
}
|
||
}
|
||
if(type == 0 ){
|
||
$(this).addClass("dropdownlist-list-on");
|
||
for(let i in listdata){
|
||
if(listdata[i]['id'] == id && title == listdata[i]['title']){
|
||
dataArr.push(listdata[i]);
|
||
}
|
||
};
|
||
}else {
|
||
$(this).removeClass("dropdownlist-list-on");
|
||
}
|
||
}else{
|
||
$(".dropdownlist-list").removeClass("dropdownlist-list-on");
|
||
$(this).addClass("dropdownlist-list-on");
|
||
for(let i in listdata){
|
||
if(listdata[i]['id'] == id && title == listdata[i]['title']){
|
||
dataArr[0]=listdata[i];
|
||
}
|
||
};
|
||
}
|
||
|
||
});
|
||
|
||
$(document).off('click','.dropdownlist-but-qd').on('click','.dropdownlist-but-qd',function(){
|
||
var strftv='',ftv='';
|
||
for(let i in dataArr){
|
||
strftv += (i==0) ? dataArr[i]['title']:','+dataArr[i]['title'];
|
||
ftv+= (i==0) ? dataArr[i]['id']:','+dataArr[i]['id'];
|
||
}
|
||
var arr ={
|
||
'title':strftv,
|
||
'id':ftv
|
||
}
|
||
me.callback && me.callback(arr);
|
||
layer.close( me.parms.layIndex );
|
||
});
|
||
|
||
$(document).off('click','.dropdownlist-but-qx').on('click','.dropdownlist-but-qx',function(){
|
||
layer.close( me.parms.layIndex );
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/event.js
|
||
(function(){
|
||
X.pageLogic['event'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
// console.log(data);
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data,"#initial-event");
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/eventattradmin.js
|
||
(function(){
|
||
X.pageLogic['eventattradmin'] = {
|
||
init : function(){
|
||
var me = this;
|
||
me.eventattradminlist();
|
||
layui.table.on('tool(eventattradmintest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'edit'){
|
||
data['cat'] = 'event'
|
||
X.parametersopen(data,"eventattradminedit",'auto',function(){
|
||
me.eventattradminlist();
|
||
})
|
||
}
|
||
});
|
||
|
||
$(document).off("click",'.addeventattradmin').on('click','.addeventattradmin',function(){
|
||
|
||
X.parametersopen('event',"addeventattradmin",'auto',function(){
|
||
me.eventattradminlist();
|
||
})
|
||
|
||
});
|
||
|
||
},
|
||
eventattradminlist : function(){
|
||
X.laytabledata("#eventattradmin-table","data_mana/attr_list",[[
|
||
{field:'name', title: '属性名', sort: true}
|
||
,{field:'show_name', title: '显示名'}
|
||
,{field:'data_type', title: '数据类型', sort: true,templet:function(d){
|
||
if(d.data_type == "string"){
|
||
return '文本'
|
||
}else if(d.data_type == "ip"){
|
||
return 'ip'
|
||
}else if(d.data_type == "int"){
|
||
return '数值'
|
||
}else if(d.data_type == "float"){
|
||
return '浮点型'
|
||
}else if(d.data_type == "datetime"){
|
||
return '时间'
|
||
}else if(d.data_type == "array"){
|
||
return '数组'
|
||
}
|
||
}}
|
||
,{field:'city', title: '单位'}
|
||
,{field:'is_show', title: '显示状态', minWidth: 100,templet:function(d){
|
||
if(d.is_show){
|
||
return '显示'
|
||
}else {
|
||
return '<span style="color: #acbad0">隐藏</span>'
|
||
}
|
||
}}
|
||
,{field:'attr_type', title: '属性类型', sort: true}
|
||
,{field:'score', title: '维度表', sort: true}
|
||
,{fixed: 'right', title:'操作', toolbar: '#eventattradminbarDemo', width:80}
|
||
]]
|
||
,"&cat=event");
|
||
}
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/eventattradminedit.js
|
||
(function(){
|
||
X.pageLogic['eventattradminedit'] = {
|
||
init : function(parms){
|
||
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
layui.form.render();
|
||
if(data){
|
||
var eventstate
|
||
if(data.is_show){
|
||
eventstate = 1
|
||
}else {
|
||
eventstate = 0
|
||
}
|
||
layui.form.val('eventattradmineditexample', {
|
||
"eventname": data.show_name // "name": "value"
|
||
,"eventunit": data.unit
|
||
,"eventstate": eventstate
|
||
});
|
||
}
|
||
|
||
|
||
$(".eventattradminedit-but-box .eventattradminedit-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(document).off('click','.eventattradminedit-but-box .eventattradminedit-qd').on('click','.eventattradminedit-but-box .eventattradminedit-qd',function(){
|
||
var fromdata = layui.form.val("eventattradmineditexample");
|
||
var is_show;
|
||
if(fromdata.eventstate == "1"){
|
||
is_show = true;
|
||
}else {
|
||
is_show = false;
|
||
}
|
||
X.api('data_mana/attr_edit',"post",{name:data.name,show_name: fromdata['eventname'],is_show:is_show,cat:data.cat},function(d){
|
||
layer.msg('修改成功');
|
||
me.callback && me.callback(d);
|
||
layer.closeAll();
|
||
})
|
||
})
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/eventmanagement.js
|
||
(function(){
|
||
X.pageLogic['eventmanagement'] = {
|
||
init : function(){
|
||
var me = this;
|
||
me.eventmanagementlist();
|
||
layui.table.on('tool(eventmanagementtest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'edit'){
|
||
X.parametersopen(data,"personalsettingsedit",'auto',function(){
|
||
|
||
me.eventmanagementlist();
|
||
})
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.eventattradmin-actions___141YT').on('click','.eventattradmin-actions___141YT',function(){
|
||
|
||
X.parametersopen(1,"personalsettingsedit",'auto',function(){
|
||
|
||
me.eventmanagementlist();
|
||
})
|
||
|
||
});
|
||
|
||
},
|
||
eventmanagementlist : function(){
|
||
X.laytabledata("#eventmanagement-table","data_mana/event_list",[[
|
||
{field:'name', title: '事件名', sort: true}
|
||
,{field:'show_name', title: '显示名'}
|
||
,{field:'desc', title: '备注'}
|
||
,{field:'is_show', title: '显示状态', minWidth: 100,templet:function(d){
|
||
if(d.is_show){
|
||
return '显示'
|
||
}else {
|
||
return '<span style="color: #acbad0">隐藏</span>'
|
||
}
|
||
}}
|
||
,{field:'event_count', title: '昨日事件量', sort: true}
|
||
,{fixed: 'right', title:'操作', toolbar: '#eventmanagementDemo', width:80}
|
||
]]);
|
||
}
|
||
|
||
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/funnel.js
|
||
(function(){
|
||
X.pageLogic['funnel'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
// console.log(data);
|
||
X.laytpldata("#analysis-con-left-screen-list-dot",data,"#funnel-event");
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/funnelanalysis.js
|
||
(function(){
|
||
X.pageLogic['funnelanalysis'] = {
|
||
init : function(parms){
|
||
// 分组项
|
||
X.template("grouped","shushi");
|
||
|
||
var data ={
|
||
"eventView":{
|
||
"cksql":"funnel",
|
||
"endTime":"",
|
||
"filts":[],
|
||
"groupBy":[],
|
||
"e_days":0,
|
||
"s_days":7,
|
||
"relation":"and",
|
||
"startTime":"",
|
||
"statType":"retention",
|
||
"timeParticleSize":"P1D",
|
||
"windows_gap":7
|
||
},
|
||
"events":[
|
||
|
||
]
|
||
};
|
||
|
||
// 日期渲染
|
||
X.daterender("#retained-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
retaineddata();
|
||
})
|
||
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
var eventdata;
|
||
var groupitemeventsdata//分组项里的事件
|
||
var filter_map,quotas_map;
|
||
// var screentypearr = [];
|
||
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
eventdata = d;
|
||
var arr = [{
|
||
"eventDesc":eventdata[0]['category'][0]['event_desc'],
|
||
"eventName":eventdata[0]['category'][0]['event_name'],
|
||
"filts":[],
|
||
"relation":"and",
|
||
"relationUser":"and",
|
||
"renameindicator":""
|
||
},{
|
||
"eventDesc":eventdata[0]['category'][0]['event_desc'],
|
||
"eventName":eventdata[0]['category'][0]['event_name'],
|
||
"filts":[],
|
||
"relation":"and",
|
||
"relationUser":"and",
|
||
"renameindicator":""
|
||
}
|
||
]
|
||
data['events'] = arr;
|
||
X.api("data_auth/load_filter_props","post",{event_name:d[0]['category'][0]['event_name']},function(val){
|
||
|
||
groupitemeventsdata= val;
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
//从数据看板点击进来触发事件
|
||
// if(X.DATA.retentionid && X.DATA.retentionid != ''){
|
||
// var report_idarr = [];
|
||
// report_idarr.push(X.DATA.retentionid);
|
||
// X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
// backfilldata(d[0]);
|
||
// })
|
||
// }
|
||
|
||
//初始事件
|
||
X.template("funnel","funnel-event",data['events']);
|
||
})
|
||
|
||
})
|
||
|
||
|
||
|
||
})
|
||
});
|
||
|
||
//开启重命名
|
||
$(document).off('click','.analysis-chongmingming-initial-event').on('click','.analysis-chongmingming-initial-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").show();
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-del-initial-event").show();
|
||
});
|
||
|
||
//取消重命名
|
||
$(document).off('click','.analysis-chongmingming-del-initial-event').on('click','.analysis-chongmingming-del-initial-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").hide();
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event input").val('');
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-initial-event").show();
|
||
});
|
||
|
||
// 添加指标
|
||
function addindex(){
|
||
var defaultindicator = {
|
||
"eventDesc":eventdata[0]['category'][0]['event_desc'],
|
||
"eventName":eventdata[0]['category'][0]['event_name'],
|
||
"filts":[],
|
||
"relation":"and",
|
||
"relationUser":"and",
|
||
"renameindicator":""
|
||
}
|
||
data['events'].push(defaultindicator);
|
||
X.template("funnel","funnel-event",data['events'],function(){
|
||
var drr = [];
|
||
if(data['events'].length > 2){
|
||
$(".analysis-del").show();
|
||
}else {
|
||
$(".analysis-del").hide();
|
||
}
|
||
});
|
||
|
||
};
|
||
|
||
//添加按钮
|
||
$(document).off('click','.analysis-jia1').on('click','.analysis-jia1',function(){
|
||
addindex();
|
||
});
|
||
$(document).off('click','.funnel-updataevent').on('click','.funnel-updataevent',function(){
|
||
addindex();
|
||
});
|
||
|
||
// 添加筛选项
|
||
$(document).off('click','.analysis-shaix').on('click','.analysis-shaix',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 添加筛选项
|
||
function addscreen(index){
|
||
var arr = {
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],
|
||
"comparator":"==",
|
||
"comparatorName":"等于",
|
||
"ftv":[],
|
||
"strftv":"",
|
||
"table_type":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"timeUnit":""
|
||
}
|
||
data['events'][index]['filts'].push(arr);
|
||
X.template("funnel","funnel-event",data['events']);
|
||
};
|
||
|
||
$(document).off('click','.analysis-zhibiao-updata').on('click','.analysis-zhibiao-updata',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
addscreen(index);
|
||
});
|
||
|
||
// 删除指定初始事件筛选
|
||
$(document).off('click','.analysis-del').on('click','.analysis-del',function(){
|
||
var index = $(this).attr("data-index");
|
||
data['events'].splice(index,1);
|
||
X.template("funnel","funnel-event",data['events']);
|
||
});
|
||
|
||
//删除指定筛选
|
||
$(document).off('click','.analysis-zhibiao-list-del').on('click','.analysis-zhibiao-list-del',function(){
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-twonum");
|
||
data['events'][index]['filts'].splice(indexs,1);
|
||
X.template("funnel","funnel-event",data['events']);
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input',function(){
|
||
var txt = $(this).val();
|
||
data['events'][0]['renameindicator'] = txt;
|
||
});
|
||
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var dataevent= data['events'][index];
|
||
// console.log(dataevent);
|
||
X.querycriteriapop(eventdata,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.id);
|
||
dataevent['eventName'] = val.name;
|
||
dataevent['eventDesc'] = val.id;
|
||
|
||
X.api("data_auth/load_filter_props","post",{event_name:val.name},function(val){
|
||
groupitemeventsdata = val;
|
||
})
|
||
// console.log(data['events']);
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.ta-property-select').on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data['events'][index]['filts'][indexs]['columnDesc'] = htmlstring;
|
||
data['events'][index]['filts'][indexs]['columnName'] = val.id;
|
||
data['events'][index]['filts'][indexs]['data_type'] = val.type;
|
||
data['events'][index]['filts'][indexs]['table_type'] = val.table_type;
|
||
})
|
||
});
|
||
|
||
// 过滤数据
|
||
// function filteringdata(){
|
||
// var screentypedata;
|
||
// if(groupitemeventsdata.length>1){
|
||
// for(var i =0; i < groupitemeventsdata.length - 1; i++){
|
||
// if(i == 0){
|
||
// X.groupintersection(groupitemeventsdata[i] , groupitemeventsdata[Number(i) + Number(1)],function(d){
|
||
// screentypedata = d;
|
||
// });
|
||
// }else {
|
||
// X.groupintersection(screentypedata , groupitemeventsdata[Number(i) + Number(1)],function(d){
|
||
// screentypedata = d;
|
||
// })
|
||
// }
|
||
// }
|
||
// }else {
|
||
// screentypedata = groupitemeventsdata[0];
|
||
// }
|
||
// return screentypedata;
|
||
// }
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = data['events'][index]['filts'][indexs]['data_type'];
|
||
X.querycriteriapop(filter_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['filts'][indexs]['comparatorName'] = val.title;
|
||
data['events'][index]['filts'][indexs]['comparator'] = val.id;
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('blur','.analysis-zhibiao-list-type4 input').on('blur','.analysis-zhibiao-list-type4 input',function(){
|
||
var index = $(this).attr('data-index');
|
||
var indexs = $(this).attr('data-indexs');
|
||
var txt = $(this).val();
|
||
var txtarr = txt.split(",");
|
||
data['events'][index]['filts'][indexs]['strftv'] = txt;
|
||
data['events'][index]['filts'][indexs]['ftv'] = txtarr;
|
||
});
|
||
|
||
//全局筛选
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var drr={
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],//事件id
|
||
'data_type':groupitemeventsdata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator_id":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"table_type":groupitemeventsdata[0]['id']
|
||
};
|
||
data['eventView']['filts'].push(drr);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
//删除指定全局数据
|
||
$(document).off('click','.analysis-overall-situation-del').on('click','.analysis-overall-situation-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['eventView']['filts'].splice(index,1);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click','.analysis-overall-situation-attr',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['columnDesc'] = val.title;
|
||
data['eventView']['filts'][index]['columnName'] = val.id;
|
||
data['eventView']['filts'][index]['data_type'] = val.type;
|
||
data['eventView']['filts'][index]['comparator_name'] = '等于';
|
||
data['eventView']['filts'][index]['comparator_id'] = '==';
|
||
data['eventView']['filts'][index]['table_type'] = val.table_type;
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['eventView']['filts'][index]['data_type'];
|
||
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$(this).html(val.title);
|
||
data['eventView']['filts'][index]['comparator_name'] = val.title;
|
||
data['eventView']['filts'][index]['comparator_id'] = val.id;
|
||
if(val.id == "range"){
|
||
data['eventView']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['eventView']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['eventView']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
var valarr = val.split(",");
|
||
data['eventView']['filts'][index]['strftv'] = val;
|
||
data['eventView']['filts'][index]['ftv']= valarr;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['eventView']['filts'][index]['ftv'][0] = val;
|
||
data['eventView']['filts'][index]['section'][0] = val;
|
||
data['eventView']['filts'][index]['ftv'].push(val);
|
||
}else {
|
||
data['eventView']['filts'][index]['ftv'][1] = val;
|
||
data['eventView']['filts'][index]['section'][1] = val;
|
||
data['eventView']['filts'][index]['ftv'].push(val);
|
||
}
|
||
});
|
||
|
||
// 分组项
|
||
$(document).off('click','.analysis-action-right').on('click','.analysis-action-right',function() {
|
||
var index = $(this).attr("data-index");
|
||
data.eventView.groupBy.splice(index,1);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
$(".group-updata").show();
|
||
});
|
||
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function() {
|
||
var arr = {
|
||
"columnDesc": "#account_id",//事件中文显示
|
||
"columnName": "#account_id",//事件id
|
||
'data_type': "string",//类型
|
||
'table_type': "event",
|
||
"ftv":"",//条件
|
||
"section":''//区间
|
||
};
|
||
data['eventView']['groupBy'].push(arr);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
$(this).hide();
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data.eventView.groupBy[index]['columnDesc'] = val.title;
|
||
data.eventView.groupBy[index]['columnName'] = val.id;
|
||
data.eventView.groupBy[index]['data_type'] = val.type;
|
||
data.eventView.groupBy[index]['table_type'] = val.table_type;
|
||
})
|
||
});
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 时间粒度
|
||
var timeParticleSizearr = [
|
||
{'title':'1天','id':'1'},
|
||
{'title':'7日','id':'7'},
|
||
{'title':'14日','id':'14'},
|
||
{'title':'30日','id':'30'},
|
||
];
|
||
X.laydropdown('.analtsis-timeParticleSize',timeParticleSizearr,function(d){
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['windows_gap'] = parseInt(d.id);
|
||
retaineddata();
|
||
});
|
||
|
||
// 计算按钮
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
retaineddata()
|
||
});
|
||
var querydata;
|
||
function retaineddata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/funnel_model","post",dataArr,function(d){
|
||
if(d != "查无数据"){
|
||
d['etitle'] = $.extend(true,[],d['title']);
|
||
if(d['title'].length == 2){
|
||
d['etitle'].unshift('总体');
|
||
}
|
||
querydata = d;
|
||
updata(d)
|
||
}else {
|
||
layer.msg('查无数据');
|
||
}
|
||
})
|
||
};
|
||
|
||
function updata(d){
|
||
var title = $(".select-chart").attr("title");
|
||
if(title == '转化图'){ retainedtable(d); retaineddayRetained(d);}
|
||
else if(title == '趋势图'){ retainednRetained(d);retainednRetainedtable(d); }
|
||
};
|
||
|
||
function retainedtable(d){
|
||
var tabledata=[];
|
||
for(let i in d['list']){
|
||
var arr = {
|
||
title: d['list'][i]["title"],
|
||
data:[]
|
||
}
|
||
for(let j in d['list'][i]["n"]){
|
||
var nrr = {
|
||
n:0,
|
||
p:0
|
||
}
|
||
nrr["n"] = d['list'][i]["n"][j];
|
||
nrr["p"] = d['list'][i]["p1"][j]
|
||
arr['data'].push(nrr);
|
||
}
|
||
tabledata.push(arr)
|
||
}
|
||
|
||
X.laytpldata("#table-fenxi-th-dot",d.etitle,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",tabledata,".table-fenxi-td");
|
||
};
|
||
|
||
//转化图
|
||
function retaineddayRetained(d){
|
||
var arr = {};
|
||
var xAxisData= d['level'];
|
||
var seriesData=[];
|
||
|
||
for(let i in d['list']){
|
||
var arr = {
|
||
name: d['list'][i]['title'],
|
||
type: 'bar',
|
||
barMaxWidth : 30,
|
||
data: d['list'][i]['p1']
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('funnel-echarts'));
|
||
var option = {
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '5%',
|
||
top: '10%',
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
// 趋势图
|
||
function retainednRetained(d){
|
||
var arr = {};
|
||
var legenddata = [];
|
||
var seriesData = [];
|
||
var xAxisdata = [];
|
||
if(jQuery.isEmptyObject(d.date_data)){
|
||
var arr = []
|
||
for(let i in d['summary_values']){
|
||
var index = d['summary_values'][i]['p'].length - 1;
|
||
arr.push(d['summary_values'][i]['p'][index]);
|
||
}
|
||
|
||
seriesData = {
|
||
type: 'line',
|
||
data: arr
|
||
}
|
||
}else {
|
||
var arr =[];
|
||
for(let i in d['date_data']){
|
||
xAxisdata.push(i);
|
||
for(let j in d['date_data'][i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d['date_data'][i][j]['p1'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d['date_data'][i][j]['p1'];
|
||
}
|
||
}
|
||
}
|
||
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in xAxisdata ){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(xAxisdata[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
for(let i in ydata){
|
||
legenddata.push(i);
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr)
|
||
}
|
||
|
||
}
|
||
var myChart = echarts.init(document.getElementById('funnel-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: [ '#3ea7fd', '#cdddfd', '#5ad8a6', '#cdf3e4', '#5d7092', '#ced4de', '#f6bd16','#fcebb9','#e86452','#f8d0cb','#6dc8ec', '#d3eef9', '#9270ca', '#d3c6ea', '#ff9d4d', '#ffd8b8', '#269a99','#aad8d8','#ff99c3','#ffd6e7' ],
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: legenddata
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: xAxisdata
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
|
||
};
|
||
//趋势图表格
|
||
function retainednRetainedtable(d){
|
||
var arr = {};
|
||
var seriesData = [];
|
||
var xAxisdata = [];
|
||
if(jQuery.isEmptyObject(d.date_data)){
|
||
var arr = []
|
||
for(let i in d['summary_values']){
|
||
var index = d['summary_values'][i]['p'].length - 1;
|
||
arr.push(d['summary_values'][i]['p'][index]);
|
||
}
|
||
|
||
seriesData = {
|
||
type: 'line',
|
||
data: arr
|
||
}
|
||
}else {
|
||
var arr =[];
|
||
for(let i in d['date_data']){
|
||
xAxisdata.push(i);
|
||
for(let j in d['date_data'][i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d['date_data'][i][j]['p1'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d['date_data'][i][j]['p1'];
|
||
}
|
||
}
|
||
}
|
||
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in xAxisdata ){
|
||
ydata[j].push(0);
|
||
for(let z in arr[j]){
|
||
if(xAxisdata[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
xAxisdata.unshift('总体');
|
||
|
||
var tabdata = [];
|
||
for(let i in ydata){
|
||
var arr = {
|
||
'title': i,
|
||
'data':[]
|
||
}
|
||
for(let j in ydata[i]){
|
||
var nrr = {
|
||
n:'',
|
||
p:ydata[i][j]
|
||
}
|
||
arr['data'].push(nrr);
|
||
}
|
||
tabdata.push(arr);
|
||
}
|
||
X.laytpldata("#table-fenxi-th-dot",xAxisdata,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",tabdata,".table-fenxi-td");
|
||
};
|
||
|
||
$(document).off('click','.analtsis-chart-switch').on('click','.analtsis-chart-switch',function(){
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '转化图'){ retainedtable(querydata); retaineddayRetained(querydata)}
|
||
else if($(this).attr('title') == '趋势图'){
|
||
retainednRetained(querydata);
|
||
retainednRetainedtable(querydata);
|
||
}
|
||
}else{
|
||
layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
X.parametersopen(data,'savereport','auto')
|
||
});
|
||
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
if(d){
|
||
data = d.query;
|
||
|
||
X.template("funnel","funnel-event",data['events']);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
|
||
retaineddata();
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/globalfilter.js
|
||
(function(){
|
||
X.pageLogic['globalfilter'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
|
||
// console.log(111,data);
|
||
X.laytpldata("#analysis-overall-situation-list-box-dot",data,"#xinwei-whole");
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/grouped.js
|
||
(function(){
|
||
X.pageLogic['grouped'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
|
||
X.laytpldata("#analysis-con-left-screen-box-dot",data,"#shushi");
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/groupeditemspop.js
|
||
(function(){
|
||
X.pageLogic['groupeditemspop'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
|
||
var arr = [
|
||
{title:'默认区间',id:'def',checked:true},
|
||
{title:'离散数字',id:'discrete',checked:false},
|
||
{title:'自定义区间',id:'user_defined',checked:false},
|
||
]
|
||
// console.log(data);
|
||
if(data!= ''){
|
||
for(let i in arr){
|
||
if(data['intervalType'] != ""){
|
||
if(arr[i]['id'] == data['intervalType']){
|
||
arr[i]['checked'] = true
|
||
}else {
|
||
arr[i]['checked'] = false
|
||
}
|
||
}
|
||
}
|
||
// 添加
|
||
var qvjian = [
|
||
{'rise':'-∞','tail':1},
|
||
{'rise':1,'tail':2},
|
||
{'rise':2,'tail':'+∞'},
|
||
];
|
||
if(data['intervalType'] == 'user_defined'){
|
||
$(".groupeditemspop-custom-box").show();
|
||
// console.log(data['quotaIntervalArr']);
|
||
if(data['quotaIntervalArr'].length >= qvjian.length){
|
||
var num = data['quotaIntervalArr'].length - qvjian.length;
|
||
for(var i = 0; i < num; i ++){
|
||
var qrr = {'rise': qvjian[qvjian.length - 2]['tail'] ,'tail': qvjian[qvjian.length - 2]['tail'] + 1 };
|
||
qvjian.splice( qvjian.length - 1 , 0, qrr);
|
||
}
|
||
}
|
||
for(let i in data['quotaIntervalArr']){
|
||
if(i == 0){
|
||
qvjian[i]['tail'] = data['quotaIntervalArr'][i];
|
||
}else {
|
||
qvjian[i]['tail'] = data['quotaIntervalArr'][i];
|
||
qvjian[i]['rise'] = data['quotaIntervalArr'][i - 1];
|
||
}
|
||
|
||
}
|
||
var drr = {'rise': data['quotaIntervalArr'][data['quotaIntervalArr'].length - 1] ,'tail':'+∞'}
|
||
qvjian[qvjian.length - 1 ] = drr;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
X.laytpldata("#groupeditemspop-list-box-dot",arr,".groupeditemspop-list-box");
|
||
layui.form.render();
|
||
|
||
layui.form.on('radio(groupeditemspopexample)',function(data){
|
||
if(data.value == "user_defined"){
|
||
$(".groupeditemspop-custom-box").show();
|
||
}else {
|
||
$(".groupeditemspop-custom-box").hide();
|
||
}
|
||
})
|
||
|
||
X.laytpldata("#qvjian-box-dot",qvjian,".qvjian-box");
|
||
$(document).off('click','.qvjian-but').on('click','.qvjian-but',function(){
|
||
var arr = {'rise': qvjian[qvjian.length - 2]['tail'] ,'tail': qvjian[qvjian.length - 2]['tail'] + 1 };
|
||
qvjian.splice( qvjian.length - 1 , 0, arr);
|
||
qvjian[qvjian.length - 1]['rise'] = Number(qvjian[qvjian.length - 2]['tail']) + 1;
|
||
X.laytpldata("#qvjian-box-dot",qvjian,".qvjian-box");
|
||
})
|
||
|
||
$(document).off('click','.qvjian input').on('blur','.qvjian input',function(){
|
||
var index = $(this).attr("data-index");
|
||
var tit = $(this).val();
|
||
for(let i in qvjian){
|
||
if(i > index){
|
||
qvjian[i]['tail'] = Number(tit) + 1;
|
||
qvjian[i]['rise'] = qvjian[ i - 1 ]['tail'];
|
||
}else if(i == index){
|
||
qvjian[i]['tail'] = Number(tit);
|
||
}
|
||
}
|
||
X.laytpldata("#qvjian-box-dot",qvjian,".qvjian-box");
|
||
})
|
||
|
||
$(document).off('click','.groupeditemspop-qd').on('click','.groupeditemspop-qd',function(){
|
||
var data = layui.form.val('groupeditemsexample');
|
||
if(data.type == "user_defined"){
|
||
var quotaIntervalArr=[];
|
||
for(let i in qvjian){
|
||
if(i < qvjian.length - 1){
|
||
quotaIntervalArr.push(qvjian[i]['tail']);
|
||
}
|
||
}
|
||
data['quotaIntervalArr'] = quotaIntervalArr;
|
||
}
|
||
layer.closeAll();
|
||
me.callback && me.callback(data);
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/groupitem.js
|
||
(function(){
|
||
X.pageLogic['groupitem'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
// console.log(data);
|
||
if(data.default !=''){
|
||
for(let i in data.data){
|
||
if(data.data[i]['id'] == data.default){
|
||
data.data[i]['checked'] = true
|
||
}else {
|
||
data.data[i]['checked'] = false
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
X.laytpldata("#groupitem-sele-box-dot",data.data,".groupitem-sele-box");
|
||
|
||
$(document).on('change','.groupitem-sele-box',function(){
|
||
// console.log($(this).val());
|
||
var valdata = {
|
||
'id':$(this).val(),
|
||
}
|
||
me.callback && me.callback(valdata);
|
||
|
||
layer.close( me.parms.layIndex );//获取最新的弹窗关闭
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/importuser.js
|
||
(function(){
|
||
X.pageLogic['importuser'] = {
|
||
init : function(){
|
||
|
||
X.api("project/","get",{},function(d){
|
||
for(let i in d){
|
||
if(d[i]["_id" == X.DATA.projectid]){
|
||
d.splice(i,1);
|
||
}
|
||
}
|
||
X.laytpldata("#importuser-con-sele-dot",d,".importuser-con-sele");
|
||
layui.form.render();
|
||
})
|
||
|
||
$(".importuser-top-box img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".importuser-qd").click(function(){
|
||
var xzprojectid = layui.form.val("example").interest;
|
||
|
||
// X.api("","post",{_id:xzprojectid},function(){
|
||
// layer.closeAll();
|
||
// })
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/jurisdiction.js
|
||
(function(){
|
||
X.pageLogic['jurisdiction'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
|
||
if(data == 'r'){
|
||
$("#Sjurisdiction-chakan").prop("checked", true);
|
||
}else{
|
||
$("#Sjurisdiction-bianji").prop("checked", true);
|
||
}
|
||
|
||
$(".Sjurisdiction-box .Sjurisdiction-but").click(function(){
|
||
var txt = $(this).attr('data-value');
|
||
if(txt == "仅查看"){
|
||
$("#Sjurisdiction-bianji").prop("checked", false);
|
||
$("#Sjurisdiction-chakan").prop("checked", true);
|
||
}else{
|
||
$("#Sjurisdiction-chakan").prop("checked", false);
|
||
$("#Sjurisdiction-bianji").prop("checked", true);
|
||
}
|
||
me.callback && me.callback(txt);
|
||
layer.close( me.parms.layIndex );//获取最新的弹窗关闭
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/kanbanadmin.js
|
||
(function(){
|
||
X.pageLogic['kanbanadmin'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
|
||
$('.kanbanadmin-box').css('height',window.innerHeight+'px');
|
||
|
||
var reportlistdata;
|
||
var toadddata = [];//已添加报表数据
|
||
var submitdata = [];//提交数据
|
||
|
||
// 更新看板
|
||
kanbanupdata();
|
||
function kanbanupdata(){
|
||
X.api("report/read_report","post",{project_id: X['DATA']['projectid'],dashboard_id:X.DATA['dashboard_id']},function(d){
|
||
reportlistdata = d;
|
||
X.laytpldata('#to-be-added-baobiao-dot',d,'.to-be-added-baobiao');
|
||
X.laytpldata('#to-added-baobiao-dot',d,'.to-added-baobiao');
|
||
var datalist = [
|
||
{title:'全部',id:'0'},
|
||
{title:'事件',id:'event'},
|
||
{title:'留存',id:'retention'},
|
||
{title:'ltv',id:'ltv'},
|
||
{title:'漏斗',id:'funnel'},
|
||
{title:'属性',id:'0'},
|
||
{title:'分布',id:'scatter'},
|
||
{title:'SQL',id:'0'}
|
||
]
|
||
|
||
X.laydropdown('#kanbanadmin-ss-right',datalist,function(d){
|
||
$('#kanbanadmin-ss-right span').html(d.title);
|
||
updatalist(d.id);
|
||
})
|
||
toadddataprocessing();
|
||
|
||
|
||
var sidebar = document.getElementById('to-added-baobiao');
|
||
new Sortable(sidebar, {
|
||
handle: '.kanbanadmin-list-tit', // handle class
|
||
animation: 150,
|
||
onUpdate:function(evt){
|
||
var newIndex = evt.newIndex;
|
||
var oldIndex = evt.oldIndex;
|
||
let item = submitdata.splice(oldIndex, 1); // arr删除2,把2给item
|
||
submitdata.splice(newIndex, 0, item[0]);
|
||
// console.log(item);
|
||
// console.log(submitdata);
|
||
for(let i in submitdata){
|
||
submitdata[i]['sort'] = parseInt(i) + parseInt(1)
|
||
}
|
||
X.api('dashboard/add_report','post',{_id:X['DATA']['dashboard_id'],report_ids:submitdata},function(d){
|
||
kanbanupdata();
|
||
});
|
||
}
|
||
});
|
||
|
||
})
|
||
};
|
||
|
||
function updatalist(title){
|
||
// console.log(title);
|
||
var screendata=[];//筛选后的数据
|
||
for(let i in reportlistdata){
|
||
if(title == 0){
|
||
screendata = reportlistdata;
|
||
}else {
|
||
if(reportlistdata[i]['cat'] == title){
|
||
screendata.push(reportlistdata[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
X.laytpldata('#to-be-added-baobiao-dot',screendata,'.to-be-added-baobiao');
|
||
};
|
||
|
||
// 搜索
|
||
$(document).off('click','.kanbanadmin-ss input').on('blur','.kanbanadmin-ss input',function(){
|
||
var screendata=[];//筛选后的数据
|
||
for(let i in reportlistdata){
|
||
if($(this).val() != ""){
|
||
if(reportlistdata[i]['name'].indexOf($(this).val()) != -1){
|
||
screendata.push(reportlistdata[i]);
|
||
}
|
||
}else {
|
||
screendata = reportlistdata;
|
||
}
|
||
}
|
||
X.laytpldata("#to-be-added-baobiao-dot",screendata,".to-be-added-baobiao");
|
||
});
|
||
|
||
//添加报表
|
||
$(document).off('click','.kanbanadd').on('click','.kanbanadd',function(){
|
||
var index = $(this).attr('data-index');
|
||
var id = $(this).attr('data-id');
|
||
for(let i in reportlistdata){
|
||
if(reportlistdata[i]['_id'] == id){
|
||
reportlistdata[index]['added'] = true;
|
||
X.laytpldata('#to-be-added-baobiao-dot',reportlistdata,'.to-be-added-baobiao');
|
||
X.laytpldata('#to-added-baobiao-dot',reportlistdata,'.to-added-baobiao');
|
||
toadddataprocessing();
|
||
}
|
||
}
|
||
});
|
||
|
||
// 修改报表类型
|
||
// $(document).off('click','.to-added-table').on('click','.to-added-table',function(){
|
||
// var obj = $(this);
|
||
// var id = obj.attr("data-id");
|
||
// for(let i in submitdata){
|
||
// if(submitdata[i]['report_id'] == id){
|
||
// submitdata[i]['graph_type'] = 'table';
|
||
// layer.msg('修改为表格展示',{time: 1000});
|
||
// }
|
||
// }
|
||
// });
|
||
|
||
// $(document).off('click','.to-added-chart').on('click','.to-added-chart',function(){
|
||
// var obj = $(this);
|
||
// var id = obj.attr("data-id");
|
||
// console.log(id);
|
||
// for(let i in submitdata){
|
||
// if(submitdata[i]['report_id'] == id){
|
||
// submitdata[i]['graph_type'] = 'echarts';
|
||
// layer.msg('修改为图表展示',{time: 1000});
|
||
// }
|
||
// }
|
||
// });
|
||
|
||
$(document).off('click','.kanbanadmin-menu').on('click','.kanbanadmin-menu',function(){
|
||
var obj = $(this);
|
||
var id = obj.attr("data-id");
|
||
var configdata = [];
|
||
for(let i in submitdata){
|
||
if(submitdata[i]['report_id'] == id){
|
||
configdata = submitdata[i];
|
||
}
|
||
}
|
||
X.parametersopen(configdata,'kanbantypeset','auto',function(d){
|
||
for(let i in submitdata){
|
||
if(submitdata[i]['report_id'] == id){
|
||
submitdata[i]['graph_type'] = d['graph_type'];
|
||
submitdata[i]['graph_size'] = d['graph_size'];
|
||
// submitdata[i]['sort'] = d['sort'];
|
||
}
|
||
}
|
||
})
|
||
});
|
||
|
||
//渲染已添加报表
|
||
function toadddataprocessing(){
|
||
toadddata = [];
|
||
for(let i in reportlistdata){
|
||
if(reportlistdata[i]['added'] == true){
|
||
toadddata.push(reportlistdata[i]);
|
||
}
|
||
};
|
||
submitdata = [];
|
||
for(let i in toadddata){
|
||
var arr = {
|
||
report_id:toadddata[i]['_id'],
|
||
graph_type: toadddata[i]['show_config']['graph_type'] || 'table',
|
||
model:toadddata[i]['cat'],
|
||
name:toadddata[i]['name'],
|
||
graph_size:toadddata[i]['show_config']['graph_size'] || 'in',
|
||
// sort: toadddata[i]['show_config']['sort']
|
||
sort: parseInt(i) + parseInt(1)
|
||
};
|
||
submitdata.push(arr);
|
||
}
|
||
submitdata.sort( X.compare("sort") );
|
||
};
|
||
|
||
$(document).off('click','.to-added-del').on('click','.to-added-del',function(){
|
||
var id = $(this).attr('data-id');
|
||
X.api('dashboard/del_report','post',{_id:X['DATA']['dashboard_id'],report_id:id},function(){
|
||
kanbanupdata();
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.kanbanadmin-but-qx').on('click','.kanbanadmin-but-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.kanbanadmin-but-yy').on('click','.kanbanadmin-but-yy',function(){
|
||
X.api('dashboard/add_report','post',{_id:X['DATA']['dashboard_id'],report_ids:submitdata},function(d){
|
||
if(d == 'ok'){
|
||
layer.closeAll();
|
||
layer.msg('应用成功');
|
||
me.callback && me.callback();
|
||
}
|
||
});
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/kanbanshezhi.js
|
||
(function(){
|
||
X.pageLogic['kanbanshezhi'] = {
|
||
init : function(){
|
||
var me = this;
|
||
// 弹窗占满整平
|
||
$('.kanbanshezhi-box').css('height',window.innerHeight+'px');
|
||
|
||
// me.renderdata();
|
||
|
||
//关闭弹窗
|
||
$('.kanbanshezhi-top .kanbanshezhi-tuihui').click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
// 更新方式
|
||
$(".kanbanshezhi-list-box .gxfs").click(function(){
|
||
var datatype = $(this).attr('data-type');
|
||
$(".kanbanshezhi-list-box .gxfs").removeClass('kanbanshezhi-list-on');
|
||
$(this).addClass('kanbanshezhi-list-on');
|
||
if(datatype == "realtime"){
|
||
$(".gxfs .ssgx").prop("checked", true);
|
||
$(".gxfs .dsgx").prop("checked", false);
|
||
$(".ddgxsele").attr("disabled", true); //禁用下拉框
|
||
}else{
|
||
$(".gxfs .ssgx").prop("checked", false);
|
||
$(".gxfs .dsgx").prop("checked", true);
|
||
$(".ddgxsele").removeAttr("disabled");//启用下拉框
|
||
}
|
||
})
|
||
|
||
$(".kanbanshezhi-but-box .kanbanshezhi-qd").click(function(){
|
||
var calculation = $(".kanbanshezhi-list-left .jsjs").prop("checked"); //计算
|
||
var timezoneset = $(".kanbanshezhi-list-left .sqsz").prop("checked"); //时区
|
||
var updatemode = $(".kanbanshezhi-list-box .kanbanshezhi-list-on").attr("data-type");
|
||
var timezone = $(".sqsz-select").val(); //时区
|
||
var timingtime = $(".ddgxsele").val(); //定时更新事件
|
||
var data = {
|
||
'type':'modify',
|
||
'updatemode':updatemode,
|
||
'timezoneset':timezoneset,
|
||
'calculation':calculation,
|
||
'timingtime':timingtime,
|
||
'timezone':timezone,
|
||
}
|
||
X.api("api/kanbanset",data,function(d){
|
||
// 修改成功
|
||
me.renderdata();
|
||
})
|
||
|
||
})
|
||
|
||
},
|
||
renderdata : function(){
|
||
X.api("api/kanbanset",{},function(d){
|
||
// console.log(d);
|
||
if(d.updatemode == 'timing'){
|
||
$(".gxfs .ssgx").prop("checked", false);
|
||
$(".gxfs .dsgx").prop("checked", true);
|
||
$(".ddgxsele").removeAttr("disabled");//启用下拉框
|
||
$(".ddgxsele").val(d.timingtime);
|
||
$("#dsgx").addClass('kanbanshezhi-list-on');
|
||
}else {
|
||
$(".gxfs .ssgx").prop("checked", true);
|
||
$(".gxfs .dsgx").prop("checked", false);
|
||
$(".ddgxsele").removeAttr("disabled", true);//禁用下拉框
|
||
$("#ssgx").addClass('kanbanshezhi-list-on');
|
||
}
|
||
if(d.calculation){
|
||
$(".kanbanshezhi-list-left .jsjs").prop("checked",true);
|
||
}
|
||
if(d.timezoneset){
|
||
$(".kanbanshezhi-list-left .sqsz").prop("checked",true);
|
||
$(".sqsz-select").val(d.timezone)
|
||
}
|
||
layui.form.render();
|
||
})
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/kanbantypeset.js
|
||
(function(){
|
||
X.pageLogic['kanbantypeset'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var listdata = parms.extData;
|
||
console.log(listdata);
|
||
layui.form.render();
|
||
|
||
if(listdata){
|
||
layui.form.val('kanbantypeexample',{
|
||
graph_type: listdata.graph_type || 'table',
|
||
graph_size: listdata.graph_size || 'in',
|
||
sort: listdata.sort
|
||
});
|
||
}
|
||
|
||
$(document).off('click','.adduser-top-box img').on('click','.adduser-top-box img',function(){
|
||
layer.close(parms.layIndex);
|
||
});
|
||
|
||
$(document).off('click','.kanbantypeset-but-box .adduser-btn').on('click','.kanbantypeset-but-box .adduser-btn',function(){
|
||
layer.close(parms.layIndex);
|
||
});
|
||
|
||
layui.form.on('radio(graph_type)', function (data) {
|
||
if(listdata.model == 'ltv'){
|
||
if(data.value == "echarts"){
|
||
layui.form.val('kanbantypeexample',{
|
||
graph_type: listdata.graph_type || 'table'
|
||
});
|
||
layer.msg('ltv没有图像,请选择其他方式展示');
|
||
}
|
||
}
|
||
});
|
||
|
||
layui.form.on('radio(graph_size)', function (data) {
|
||
if(listdata.model == 'ltv'){
|
||
if(data.value == "small"){
|
||
layui.form.val('kanbantypeexample',{
|
||
graph_size: listdata.graph_size || 'table'
|
||
});
|
||
layer.msg('ltv没有小图,请选择其他方式展示');
|
||
}
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.kanbantypeset-but-box .adduser-btn2').on('click','.kanbantypeset-but-box .adduser-btn2',function(){
|
||
var data = layui.form.val('kanbantypeexample');
|
||
me.callback && me.callback(data);
|
||
layer.close(parms.layIndex);
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/kongjianshezhi.js
|
||
(function(){
|
||
X.pageLogic['kongjianshezhi'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var id = parms.extData;
|
||
|
||
$(".kongjian-mc-box .kongjian-tianjia").click(function(){
|
||
$(".kongjian-box .member-box").show();
|
||
});
|
||
|
||
$(".member-top-box .member-cha").click(function(){
|
||
$(".kongjian-box .member-box").hide();
|
||
});
|
||
var userarr;
|
||
var adduadaserarr;
|
||
|
||
// var userinfo = X.DATA.userinfo;
|
||
// $(".gly-firs").html(userinfo.name.substring(0,1));
|
||
// $(".gly-name").html(userinfo.name);
|
||
|
||
if(id){
|
||
$(".editkongjian").show();
|
||
$(".kongjian-cz").show();
|
||
X.api('space/detail','post',{space_id:id},function(d){
|
||
$('.kongjian-mc-box-txt').val(d.name);
|
||
for(let i in d.members){
|
||
d.members[i]["firs"] = d.members[i]['name'].substring(0,1);
|
||
}
|
||
X.DATA['adduadaserarr'] = d.members;
|
||
adduadaserarr = d.members;
|
||
X.api('user/all_account',"get",{},function(d){
|
||
for(let i in d){
|
||
d[i]["firs"] = d[i]['name'].substring(0,1);
|
||
d[i]["authority"] = "r";
|
||
d[i]['user_id'] = d[i]['_id']
|
||
if(d[i].is_superuser){
|
||
$(".gly-firs").html(d[i].name.substring(0,1));
|
||
$(".gly-name").html(d[i].name);
|
||
}
|
||
}
|
||
for(let i in adduadaserarr){
|
||
for(let j in d){
|
||
if(adduadaserarr[i]['_id'] == d[j]['_id']){
|
||
d.splice(j,1);
|
||
}
|
||
}
|
||
}
|
||
userarr = d;
|
||
X.DATA['userarr'] = d;
|
||
me.updatauserarr();
|
||
});
|
||
})
|
||
|
||
var listarr = [
|
||
{title:'移交空间',id:'transfer'},
|
||
{title:'删除空间',id:'del'}
|
||
]
|
||
X.laydropdown("#kongjian-cz",listarr,function(d){
|
||
console.log(d);
|
||
if(d.id == 'del'){
|
||
layer.confirm('确认删除此空间吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("space/delete",'post',{_id:id},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
me.updata(X.DATA.projectid);//刷新数据
|
||
})
|
||
});
|
||
}
|
||
})
|
||
}else {
|
||
$(".addkongjian").show();
|
||
$(".kongjian-cz").hide();
|
||
adduadaserarr = [];
|
||
X.DATA['adduadaserarr'] = [];
|
||
X.api('user/all_account',"get",{},function(d){
|
||
for(let i in d){
|
||
d[i]["firs"] = d[i]['name'].substring(0,1);
|
||
d[i]["authority"] = "r";
|
||
}
|
||
userarr = d;
|
||
for(let i in userarr){
|
||
userarr[i]['user_id'] = userarr[i]['_id']
|
||
}
|
||
console.log(userarr);
|
||
X.DATA['userarr'] = userarr;
|
||
me.updatauserarr();
|
||
});
|
||
}
|
||
|
||
|
||
//筛选用户
|
||
$(".member-top-box #membertxt").bind("input propertychange",function(){
|
||
// console.log($(this).val());
|
||
var txt = $(this).val();
|
||
var arr=[];
|
||
if(txt != ''){
|
||
for(let i in userarr){
|
||
if(userarr[i]['username'].indexOf(txt) != -1){
|
||
arr.push(userarr[i]);
|
||
}
|
||
}
|
||
}else {
|
||
arr = X.DATA['userarr'];
|
||
}
|
||
|
||
X.laytpldata("#member-user-con-box-dot",arr,".member-user-con-box");
|
||
|
||
});
|
||
|
||
//给用户修改权限
|
||
$(document).off('click','.kongjian-renyuan .kongjian-renyuan-jurisdiction').on("click",".kongjian-renyuan .kongjian-renyuan-jurisdiction",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.parametersopen(obj.attr('data-type'),'jurisdiction',[offset.top+obj.height(),offset.left-160],function(val){
|
||
console.log(val)
|
||
var index = obj.attr("data-index");
|
||
adduadaserarr[index]['authority'] = val;
|
||
if(val == "r"){
|
||
obj.html('仅查看');
|
||
obj.attr('data-type','r');
|
||
}else {
|
||
obj.html('可编辑');
|
||
obj.attr('data-type','rw');
|
||
}
|
||
X.DATA["adduadaserarr"] = adduadaserarr;
|
||
})
|
||
});
|
||
//添加用户
|
||
$(document).off("click",".member-user-con-right").on("click",".member-user-con-right",function(){
|
||
var userid = $(this).attr('data-id');
|
||
for(let i in userarr){
|
||
if(userarr[i]["_id"] == userid){
|
||
adduadaserarr.push(userarr[i]);
|
||
// adduadaserarr.push({'user_id':userid});
|
||
userarr.splice(i,1);
|
||
}
|
||
}
|
||
|
||
X.DATA['adduadaserarr'] = adduadaserarr;
|
||
X.DATA['userarr'] = userarr;
|
||
me.updatauserarr();
|
||
});
|
||
|
||
//删除用户
|
||
$(document).off('click','.kongjian-renyuan-right .kongjian-renyuan-del').on("click",".kongjian-renyuan-right .kongjian-renyuan-del",function(){
|
||
var userid = $(this).attr('data-id');
|
||
for(let i in adduadaserarr){
|
||
if(adduadaserarr[i]['_id'] == userid){
|
||
userarr.push(adduadaserarr[i]);
|
||
adduadaserarr.splice(i,1);
|
||
}
|
||
}
|
||
// console.log(adduadaserarr);
|
||
// console.log(userarr);
|
||
X.DATA['adduadaserarr'] = adduadaserarr;
|
||
X.DATA['userarr'] = userarr;
|
||
me.updatauserarr();
|
||
});
|
||
|
||
$(document).off('click','.kongjian-but .kongjian-qd').on('click','.kongjian-but .kongjian-qd',function(){
|
||
var tit = $(".kongjian-mc-box .kongjian-mc-box-txt").val();
|
||
var adduserarr = X.DATA['adduadaserarr'];
|
||
if(tit == ''){
|
||
alert('请输入空间名称');
|
||
return;
|
||
}
|
||
var data = {
|
||
'name': tit,
|
||
'members': adduserarr,
|
||
'project_id':X.DATA.projectid
|
||
}
|
||
for(let i in adduserarr){
|
||
if(adduserarr[i]['_id'] == "0"){
|
||
data["is_all_member"] = true,
|
||
data["authority"] = adduserarr[i]['authority']
|
||
}else {
|
||
data["is_all_member"] = false,
|
||
data["authority"] = "r"
|
||
}
|
||
}
|
||
|
||
if(id){
|
||
console.log(adduserarr);
|
||
X.api('space/rename','post',{space_id:id,new_name:tit},function(d){
|
||
X.api('space/set_members','post',{space_id:id,members:adduserarr},function(d){
|
||
layer.closeAll();
|
||
layer.msg('修改成功');
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);
|
||
})
|
||
})
|
||
|
||
}else{
|
||
X.api('space/create',"post",data,function(d){
|
||
// if(d.code == "ok"){
|
||
layer.msg(d, function(){
|
||
//do something
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
//关闭对应弹窗
|
||
layer.closeAll();
|
||
});
|
||
// }
|
||
})
|
||
}
|
||
|
||
})
|
||
|
||
$(".kongjian-but .kongjian-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
},
|
||
updatauserarr : function(){
|
||
var adduadaserarr = X.DATA['adduadaserarr'];
|
||
var userarr = X.DATA['userarr'];
|
||
//以添加用户
|
||
console.log(adduadaserarr)
|
||
X.laytpldata("#kongjian-renyuan-box-dot",adduadaserarr,".kongjian-renyuan-box2");
|
||
//未添加的用户
|
||
X.laytpldata("#member-user-con-box-dot",userarr,".member-user-con-box");
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/login.js
|
||
(function(){
|
||
X.pageLogic['login'] = {
|
||
init : function(){
|
||
|
||
var userinfo = localStorage.getItem('loginData');
|
||
if(userinfo){
|
||
X.DATA["userinfo"] = JSON.parse(userinfo);
|
||
X.loginCache(JSON.parse(userinfo));
|
||
X.gourl("dashboard");
|
||
};
|
||
|
||
$(".login-denglu").click(function(){
|
||
postlogin();
|
||
});
|
||
|
||
document.onkeydown=function(ev){
|
||
var event=ev ||event
|
||
if(event.keyCode==13){
|
||
|
||
postlogin();
|
||
|
||
}
|
||
};
|
||
|
||
function postlogin(){
|
||
var account = $(".login-txt-box .account").val();
|
||
var password = $(".login-txt-box .password").val();
|
||
// X.gourl("dashboard");
|
||
X.api('user/login',"post",{username:account,password:password},function (d){
|
||
// console.log(d);
|
||
X.DATA["userinfo"] = d;
|
||
X.loginCache(d);
|
||
X.gourl("dashboard");
|
||
});
|
||
};
|
||
|
||
}
|
||
};
|
||
|
||
})();
|
||
// srczip/logic/ltvmodel.js
|
||
(function(){
|
||
X.pageLogic['ltvmodel'] = {
|
||
init : function(){
|
||
|
||
X.template("grouped","xinwei-whole");
|
||
var data ={
|
||
"eventView":{
|
||
"cksql":"ltv",
|
||
"endTime":"2021-06-07 23:59:59",
|
||
"filts":[],
|
||
"groupBy":[],
|
||
"e_days":0,
|
||
"s_days":7,
|
||
"relation":"and",
|
||
"startTime":"2021-05-09 00:00:00",
|
||
"statType":"retention",
|
||
"timeParticleSize":"P1D",
|
||
"unitNum":7,
|
||
"quota":'#account_id'
|
||
},
|
||
"events":[
|
||
|
||
]
|
||
};
|
||
|
||
// 日期渲染
|
||
X.daterender("#retained-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
retaineddata();
|
||
});
|
||
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
var groupitemeventsdata,filter_map;//分组项里的事件
|
||
|
||
X.api("data_auth/load_filter_props","post",{event_name:'pay'},function(val){
|
||
groupitemeventsdata = val;
|
||
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.ltvid && X.DATA.ltvid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.ltvid);
|
||
if(X.DATA.authority != 'rw'){
|
||
$('.analysis-savereport').hide();
|
||
}else {
|
||
$(".analysis-saveas").show();
|
||
}
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
//全局筛选
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var screentypedata = groupitemeventsdata;
|
||
|
||
var drr={
|
||
"columnDesc":screentypedata[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":screentypedata[0]['category'][0]['id'],//事件id
|
||
'data_type':screentypedata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"table_type":screentypedata[0]['id'],
|
||
};
|
||
// if(data['eventView']['filts'].length == 1){
|
||
// layer.msg('此项只能添加一个');
|
||
// return;
|
||
// }
|
||
data['eventView']['filts'].push(drr);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
var listarr =[
|
||
{title:'角色',id:'#account_id'},
|
||
{title:'设备',id:'#distinct_id'},
|
||
// {title:'账号',id:'binduid'},
|
||
]
|
||
X.laydropdown('.eventsplit',listarr,function(d){
|
||
$('.eventsplit').html(d.title);
|
||
data['eventView']['quota'] = d.id;
|
||
// console.log(d);
|
||
});
|
||
|
||
//删除指定全局数据
|
||
$(document).off('click','.analysis-overall-situation-del').on('click','.analysis-overall-situation-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['eventView']['filts'].splice(index,1);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-left-guanxi').on('click','.analysis-overall-situation-left-guanxi',function(){
|
||
var html = $(this).html(); //relation筛选条件的关系
|
||
if(html == "且"){
|
||
$(this).html('或');
|
||
data['eventView']['relation'] = 'or'
|
||
}else {
|
||
$(this).html('且');
|
||
data['eventView']['relation'] = 'and'
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click','.analysis-overall-situation-attr',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
console.log(val);
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['columnDesc'] = val.title;
|
||
data['eventView']['filts'][index]['columnName'] = val.id;
|
||
data['eventView']['filts'][index]['data_type'] = val.type;
|
||
data['eventView']['filts'][index]['comparator_name'] = '等于';
|
||
data['eventView']['filts'][index]['comparator'] = '==';
|
||
data['eventView']['filts'][index]['table_type'] = val.table_type;
|
||
if(val.type == 'user_label'){
|
||
data['eventView']['filts'][index]['comparator_name'] = "是";
|
||
data['eventView']['filts'][index]['comparator'] = 'in';
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var type = data['eventView']['filts'][index]['data_type'];
|
||
console.log(type)
|
||
X.querycriteriapop(filter_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['comparator_name'] = val.title;
|
||
data['eventView']['filts'][index]['comparator'] = val.id;
|
||
if(val.id == "range"){
|
||
data['eventView']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
}
|
||
})
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['eventView']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['eventView']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
$(document).off("click",".analysis-overall-situation-input").on("click",".analysis-overall-situation-input",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var columnName = data['eventView']['filts'][index]['columnName'];
|
||
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
data['eventView']['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['eventView']['filts'][index]['ftv'] = arr;
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
var valarr = val.split(",");
|
||
data['eventView']['filts'][index]['strftv'] = val;
|
||
data['eventView']['filts'][index]['ftv']= valarr;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['eventView']['filts'][index]['ftv'][0] = val;
|
||
data['eventView']['filts'][index]['section'][0] = val;
|
||
data['eventView']['filts'][index]['ftv'].push(val);
|
||
}else {
|
||
data['eventView']['filts'][index]['ftv'][1] = val;
|
||
data['eventView']['filts'][index]['section'][1] = val;
|
||
data['eventView']['filts'][index]['ftv'].push(val);
|
||
}
|
||
});
|
||
|
||
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
// 时间粒度
|
||
var timeParticleSizearr = [
|
||
{'title':'当日','id':'1'},
|
||
{'title':'次日','id':'2'},
|
||
{'title':'7日','id':'7'},
|
||
{'title':'14日','id':'14'},
|
||
{'title':'30日','id':'30'},
|
||
];
|
||
X.laydropdown('.analtsis-timeParticleSize',timeParticleSizearr,function(d){
|
||
console.log(d);
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['unitNum'] = parseInt(d.id);
|
||
retaineddata();
|
||
});
|
||
|
||
// 计算按钮
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
retaineddata()
|
||
});
|
||
|
||
function retaineddata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/ltv_model","post",dataArr,function(d){
|
||
if(d == "查无数据"){
|
||
$(".table-fenxi-th").html("");
|
||
$(".table-fenxi-td").html("");
|
||
$(".chawushuj").show();
|
||
|
||
return;
|
||
}else{
|
||
$(".chawushuj").hide();
|
||
X.laytpldata("#table-fenxi-th-dot",d.title,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",d.rows,".table-fenxi-td");
|
||
}
|
||
})
|
||
};
|
||
|
||
var baobiaodata;//已存报表
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
console.log(d);
|
||
if(d){
|
||
backfilldata(d);
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
function backfilldata(d){
|
||
data = d.query;
|
||
baobiaodata = d;
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
|
||
retaineddata();
|
||
};
|
||
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
baobiaodata['saveas'] = 0;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
//另存为
|
||
$(document).off('click','.analysis-saveas').on('click','.analysis-saveas',function(){
|
||
baobiaodata['saveas'] = 1;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
|
||
});
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
// 下载
|
||
$(document).off('click','.download-table').on('click','.download-table',function(){
|
||
// console.log(11111);
|
||
X.download('ck/ltv_model_export',data,'事件分析');
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/modeltable.js
|
||
(function(){
|
||
X.pageLogic['modeltable'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms;
|
||
X.laytpldata("#kanban-model-modify-table-dot",data,"model"+data.id,function(html){
|
||
|
||
|
||
|
||
// if(data.modeltype == 'table' && data.modelsize != "small"){
|
||
|
||
// var oldcondata = data.condata;
|
||
// var newcondata = [];
|
||
// if(data.cat == 'event' || data.cat == "ltv"){
|
||
// for(let i in oldcondata){
|
||
// var condataArr = {};
|
||
// for(let j in oldcondata[i]){
|
||
// condataArr['name'+j] = oldcondata[i][j];
|
||
// }
|
||
// newcondata.push(condataArr);
|
||
// }
|
||
|
||
// var headdata = [];
|
||
// for(let i in data.titledata){
|
||
// var arr = {
|
||
// width: 150,
|
||
// title: data.titledata[i],
|
||
// name: 'name'+i,
|
||
// align: 'center'
|
||
// };
|
||
// if(i == 0){
|
||
// arr['fixed'] = true;
|
||
// }
|
||
// headdata.push(arr);
|
||
// }
|
||
|
||
// $("#table-tbody-box-"+data.id).mmGrid({
|
||
// cols: headdata,
|
||
// items: newcondata,
|
||
// fullWidthRows: true
|
||
// });
|
||
// X.fixedTable("table-tbody-box-"+data.id,'row-col-fixed','',headdata,data.condata,data.cat);
|
||
|
||
// }
|
||
// // else if(data.cat == "retention" || data.cat == "scatter"){
|
||
// // console.log(oldcondata);
|
||
// // }else if(data.cat == "user_property"){
|
||
|
||
// // }
|
||
|
||
// }else {
|
||
$("#conent-box"+data.id).html(html);
|
||
// }
|
||
console.log(data.reverseorder , data.name);
|
||
if(data.modeltype == "table" && data.modelsize != "small"){
|
||
var tableMul;
|
||
var id = 'dataTableMul'+data['id'];
|
||
if(data.reverseorder){
|
||
tableMul = new FixedTable(id, 2);
|
||
}else {
|
||
tableMul = new FixedTable(id, 0);
|
||
}
|
||
}
|
||
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/modeltype.js
|
||
(function(){
|
||
X.pageLogic['modeltype'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms;
|
||
// console.log(data);
|
||
X.laytpldata("#kanban-model-modify-type-dot",data,"model"+data.id,function(html){
|
||
// console.log(html);
|
||
$("#model-two-"+data.id).html(html);
|
||
})
|
||
|
||
// for(var i in data){
|
||
// X.laytpldata("#kanban-model-table-dot",data[i],null,function(html){
|
||
// // console.log($("#model-box").html());
|
||
// console.log(html);
|
||
// $('#model-box').append(html);
|
||
// });
|
||
// }
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/modifyname.js
|
||
(function(){
|
||
X.pageLogic['modifyname'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;
|
||
console.log(11111,data);
|
||
$(document).off('click','.modifyname-qd').on('click','.modifyname-qd',function(){
|
||
var txt = $(".modifyname-txt").val();
|
||
X.api("dashboard/edit","post",{dashboard_id:data[0],new_name:txt},function(d){
|
||
console.log(d);
|
||
layer.closeAll(0);
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.modifyname-qx').on('click','.modifyname-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.modifyname-cha').on('click','.modifyname-cha',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/newkanban.js
|
||
(function(){
|
||
X.pageLogic['newkanban'] = {
|
||
init :function(){
|
||
// console.log(X.DATA);
|
||
|
||
//给两个下拉框赋值
|
||
var comboTree1,comboTree2;
|
||
var KanBanData = [];
|
||
for(let i in X.DATA.KanBanData){
|
||
// X.DATA.KanBanData[i]['']
|
||
var arr = {
|
||
'name' : X.DATA.KanBanData[i]['name'],
|
||
'id' : X.DATA.KanBanData[i]['_id'],
|
||
}
|
||
KanBanData.push(arr);
|
||
// console.log(X.DATA.KanBanData[i]);
|
||
}
|
||
console.log(KanBanData);
|
||
comboTree1 = $('#newjustAnotherInputBox1').comboTree({
|
||
source : KanBanData,
|
||
isMultiple: false
|
||
});
|
||
comboTree2 = $('#newjustAnotherInputBox2').comboTree({
|
||
source : X.DATA.ProjectData,
|
||
isMultiple: false
|
||
});
|
||
// console.log('xxxx',$("#new-cha"));
|
||
|
||
//叉图标关闭弹窗
|
||
$(".new-top .new-cha").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
//取消按钮
|
||
$(".new-but-box .new-qx").click(function(){
|
||
layer.closeAll();
|
||
});
|
||
//我的看板,空间切换实践
|
||
$(".new-tab-box .new-tab div").click(function(){
|
||
$(".new-tab-box .new-tab div").removeClass('tabdata');
|
||
$(this).addClass('tabdata');
|
||
if($(this).html() == "我的看板"){
|
||
$("#newjustAnotherInputBox1").show();
|
||
$("#newjustAnotherInputBox2").hide();
|
||
}else {
|
||
$("#newjustAnotherInputBox1").hide();
|
||
$("#newjustAnotherInputBox2").show();
|
||
}
|
||
$("#newjustAnotherInputBox1").val("");
|
||
$("#newjustAnotherInputBox2").val("");
|
||
})
|
||
|
||
//确定按钮事件
|
||
$(".new-but-box .new-qd").click(function(){
|
||
var txt = $("#newname-txt").val();//获取新建名
|
||
var type ='kanban'//方便根据中文名获取对应id
|
||
if($('#newjustAnotherInputBox1').val() != ""){
|
||
var Addlocation = $('#newjustAnotherInputBox1').val();
|
||
}else {
|
||
var Addlocation = $('#newjustAnotherInputBox2').val();
|
||
type = "kongjian"
|
||
}
|
||
if(Addlocation){
|
||
//根据中文获取到对应的id
|
||
var id = X.pageLogic.newkanban.matchingid(Addlocation,type);
|
||
}else {
|
||
// 为空时提示
|
||
alert('请选择添加的位置');
|
||
return;
|
||
}
|
||
|
||
var data = {
|
||
'name': txt,
|
||
'project_id': X.DATA.projectid,
|
||
'pid': id,
|
||
}
|
||
X.api('dashboard/create',"post",data,function(d){
|
||
// if(d.code == "ok"){
|
||
layer.msg(d,function(){
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
//关闭对应弹窗
|
||
layer.closeAll();
|
||
});
|
||
// }
|
||
})
|
||
|
||
});
|
||
|
||
},
|
||
//根据中文名获取侧边栏id
|
||
matchingid : function(name,type){
|
||
var id, data;
|
||
if(type == 'kanban'){
|
||
data = X.DATA.KanBanData;
|
||
}else {
|
||
data = X.DATA.ProjectData;
|
||
}
|
||
console.log(data);
|
||
for(let i in data){
|
||
if(data[i]['name'] == name){
|
||
id = data[i]['_id']
|
||
}else {
|
||
if(data[i]['children'].length > 0){
|
||
for(let j in data[i]['children']){
|
||
if(data[i]['children'][j]['name'] == name){
|
||
id = data[i]['children'][j]['_id']
|
||
}
|
||
}
|
||
}else {
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
return id
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/newwenjian.js
|
||
(function(){
|
||
X.pageLogic['newwenjian'] = {
|
||
init : function(){
|
||
var comboTree1,comboTree2
|
||
comboTree1 = $('#newwenjianjustAnotherInputBox1').comboTree({
|
||
source : X.DATA.KanBanData,
|
||
isMultiple: false
|
||
});
|
||
// comboTree2 = $('#newwenjianjustAnotherInputBox2').comboTree({
|
||
// source : X.DATA.ProjectData,
|
||
// isMultiple: false
|
||
// });
|
||
|
||
var ProjectData = X.DATA.ProjectData;
|
||
console.log(ProjectData)
|
||
var data = [];
|
||
var spaceid = '';//获取项目空间id
|
||
for(let i in ProjectData){
|
||
var arr = {};
|
||
arr['title'] = ProjectData[i]['name'],
|
||
arr['id'] = ProjectData[i]['_id']
|
||
data.push(arr);
|
||
}
|
||
console.log(data);
|
||
X.laydropdown("#newwenjianjustAnotherInputBox2",data,function(d){
|
||
spaceid = d.id;
|
||
$("#newwenjianjustAnotherInputBox2").val(d.title);
|
||
// console.log(d);
|
||
})
|
||
|
||
|
||
// 取消
|
||
$(".newwenjian-but-box .newwenjian-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
// 关闭图标
|
||
$(".newwenjian-top .newwenjian-cha").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".newwenjian-tab-box .newwenjian-tab div").click(function(){
|
||
$(".newwenjian-tab-box .newwenjian-tab div").removeClass('tabdata');
|
||
$(this).addClass('tabdata');
|
||
if($(this).html() == "我的看板"){
|
||
$("#newwenjianjustAnotherInputBox2").hide();
|
||
}else {
|
||
$("#newwenjianjustAnotherInputBox2").show();
|
||
}
|
||
$("#newwenjianjustAnotherInputBox2").val("");
|
||
})
|
||
|
||
// 确定
|
||
$(".newwenjian-but-box .newwenjian-qd").click(function(){
|
||
|
||
var txt = $(".newwenjianname-txt").val();
|
||
var type ='kanban';
|
||
var id = '';//没有默认传看板
|
||
if($('#newwenjianjustAnotherInputBox2').css("display") != 'none'){
|
||
if($('#newwenjianjustAnotherInputBox2').val() != ""){
|
||
var Addlocation = $('#newwenjianjustAnotherInputBox2').val();
|
||
}
|
||
type = "space";
|
||
}
|
||
|
||
if(type != "kanban"){
|
||
if(Addlocation){
|
||
id = X.pageLogic.newkanban.matchingid(Addlocation,type);
|
||
}else {
|
||
alert('请选择添加的位置');
|
||
return;
|
||
}
|
||
}else {
|
||
spaceid = X.DATA.projectid; //当选择看板时pid等于项目id
|
||
}
|
||
|
||
var data = {
|
||
'name': txt,
|
||
'project_id': X.DATA.projectid,
|
||
'cat': type,
|
||
'pid':spaceid
|
||
}
|
||
console.log(data);
|
||
// return;
|
||
X.api('folder/create',"post",data,function(d){
|
||
// if(d.msg == "ok"){
|
||
layer.msg(d,function(){
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
layer.closeAll();
|
||
});
|
||
// }
|
||
})
|
||
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/operation.js
|
||
(function(){
|
||
X.pageLogic['operation'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
|
||
X.layuipages("operation-pages",50,function(e){
|
||
console.log(e);
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/participate.js
|
||
(function(){
|
||
X.pageLogic['participate'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
|
||
console.log(data);
|
||
X.laytpldata("#judge-box-dot",data.list,".setgrouping-box2 .setgrouping-content-box2");
|
||
layui.form.render();
|
||
|
||
if( data.select && data.select.length > 0){
|
||
var select = data['select'];
|
||
var selectdata = {};
|
||
for(let i in select){
|
||
selectdata["like["+select[i]+"]"] = true;
|
||
}
|
||
console.log(selectdata);
|
||
layui.form.val('participateexample', selectdata);
|
||
}
|
||
|
||
// 搜索
|
||
$('.setgrouping-sousuo-txt-box input').bind('input propertychange', function() {
|
||
var value = $(this).val();
|
||
console.log(data);
|
||
if(value != ""){
|
||
$(".setgrouping-sousuo-txt-box img").show();
|
||
var filteringdata = [];
|
||
for(let i in data.list){
|
||
var detailsdata = [];
|
||
for(let j in data['list'][i]["category"]){
|
||
if(data['list'][i]["category"][j]['event_name'].indexOf(value) != -1){
|
||
detailsdata.push(data['list'][i]["category"][j]);
|
||
}
|
||
}
|
||
if(detailsdata.length >0){
|
||
var arr = {
|
||
"title": data['list'][i]['title'],
|
||
"id":data['list'][i]['id'],
|
||
"category": detailsdata
|
||
};
|
||
filteringdata.push(arr);
|
||
}
|
||
}
|
||
console.log(filteringdata);
|
||
X.laytpldata("#judge-box-dot",filteringdata,".setgrouping-box2 .setgrouping-content-box2");
|
||
}else {
|
||
$(".setgrouping-sousuo-txt-box img").hide();
|
||
X.laytpldata("#judge-box-dot",data.list,".setgrouping-box2 .setgrouping-content-box2");
|
||
}
|
||
})
|
||
|
||
//清空按钮
|
||
$(".setgrouping-sousuo-txt-box img").click(function(){
|
||
$(".setgrouping-sousuo-txt-box input").val("");
|
||
$(".setgrouping-sousuo-txt-box img").hide();
|
||
X.laytpldata("#judge-box-dot",data.list,".setgrouping-box2 .setgrouping-content-box2");
|
||
})
|
||
|
||
layui.form.on('checkbox(checkboxexample)', function(){
|
||
var data = layui.form.val('participateexample');
|
||
console.log(data);
|
||
if(Object.keys(data).length >= 30){
|
||
$(this).prop("checked", false);
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.participate-but').on('click','.participate-but',function(){
|
||
var dataarr = layui.form.val('participateexample');
|
||
console.log(data);
|
||
var idarr = [];
|
||
for(let i in dataarr){
|
||
var arr = i.substring(5);
|
||
arr = arr.substring(0,arr.length - 1);
|
||
idarr.push(arr);
|
||
}
|
||
var callbackdata = [];
|
||
for(let i in data['list']){
|
||
for(let j in data['list'][i]['category']){
|
||
for(let z in idarr){
|
||
if(data['list'][i]['category'][j]['event_name'] == idarr[z]){
|
||
var arr = {
|
||
'event_desc': data['list'][i]['category'][j]['event_desc'],
|
||
'event_name': data['list'][i]['category'][j]['event_name']
|
||
}
|
||
callbackdata.push(arr);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
// console.log(callbackdata);
|
||
me.callback && me.callback(callbackdata);
|
||
layer.close( me.parms.layIndex );//获取最新的弹窗关闭
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/personalsettings.js
|
||
(function(){
|
||
X.pageLogic['personalsettings'] = {
|
||
init : function(){
|
||
var userinfostying = localStorage.getItem('loginData');
|
||
var userinfo = JSON.parse(userinfostying);
|
||
// console.log(userinfo);
|
||
X.laytpldata("#personalsettings-bg-box-dot",userinfo,".personalsettings-bg-box");
|
||
|
||
$(document).off('click','.personalsettings-name').on('click','.personalsettings-name',function(){
|
||
$(".personalsettings-mr-name").hide();
|
||
$(".personalsettings-updata-name").show();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-name-qd').on('click','.personalsettings-name-qd',function(){
|
||
$(".personalsettings-mr-name").show();
|
||
$(".personalsettings-updata-name").hide();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-name-qx').on('click','.personalsettings-name-qx',function(){
|
||
var tit = $(".personalsettings-name-txt").val();
|
||
X.api("user/edit_profile","post",{nickname: tit},function(d){
|
||
// console.log(d);
|
||
X.DATA.userinfo['nickname'] = d.nickname;
|
||
X.laytpldata("#personalsettings-bg-box-dot",X.DATA.userinfo,".personalsettings-bg-box");
|
||
})
|
||
$(".personalsettings-mr-name").show();
|
||
$(".personalsettings-updata-name").hide();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-tel').on('click','.personalsettings-tel',function(){
|
||
$(".personalsettings-mr-tel").hide();
|
||
$(".personalsettings-binding-tel").show();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-tel-qd').on('click','.personalsettings-tel-qd',function(){
|
||
$(".personalsettings-mr-tel").show();
|
||
$(".personalsettings-binding-tel").hide();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-tel-qx').on('click','.personalsettings-tel-qx',function(){
|
||
var tit = $(".personalsettings-tel-txt").val();
|
||
X.api("user/edit_profile","post",{tel: tit},function(d){
|
||
// console.log(d);
|
||
X.DATA.userinfo['tel'] = d.tel;
|
||
X.laytpldata("#personalsettings-bg-box-dot",X.DATA.userinfo,".personalsettings-bg-box");
|
||
})
|
||
$(".personalsettings-mr-tel").show();
|
||
$(".personalsettings-binding-tel").hide();
|
||
});
|
||
|
||
$(document).off('click','.personalsettings-updata-password').on('click','.personalsettings-updata-password',function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'updatapassword'
|
||
})
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/personalsettingsedit.js
|
||
(function(){
|
||
X.pageLogic['personalsettingsedit'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
layui.form.render();
|
||
if(data != 1 && data){
|
||
layui.form.val('personalsettingseditexample', {
|
||
"show_name": data.show_name // "name": "value"
|
||
,"desc": data.desc
|
||
,"is_show":(data.is_show)? 1 : 0
|
||
});
|
||
}else {
|
||
|
||
}
|
||
$(document).off('click','.personalsettingsedit-qd').on('click','.personalsettingsedit-qd',function(){
|
||
var arr = layui.form.val('personalsettingseditexample');
|
||
arr['event_name'] = data.name;
|
||
X.api("data_mana/event_edit","post",arr,function(d){
|
||
layer.msg("保存成功");
|
||
me.callback && me.callback(d);
|
||
layer.closeAll();
|
||
})
|
||
})
|
||
|
||
$(document).off('click','.personalsettingsedit-qx').on('click','.personalsettingsedit-qx',function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/projectadmin.js
|
||
(function(){
|
||
X.pageLogic['projectadmin'] = {
|
||
init : function(parms){
|
||
var role_id,datalist;
|
||
updataroles();
|
||
function updataroles(){
|
||
X.api("authz/roles","get",{},function(d){
|
||
datalist = d;
|
||
if(d[0]){
|
||
role_id = d[0]['_id'];
|
||
$(".projectadmin-list-name").html(d[0]["name"]);
|
||
X.laytpldata("#projectadmin-con-hz-left-list-tit-xiangmu-dot",d,".projectadmin-con-hz-left-list-tit-xiangmu");
|
||
updataapiinfo(d[0]['_id']);
|
||
}else {
|
||
layer.msg('查无数据');
|
||
}
|
||
|
||
// X.laytpldata("#projectadmin-info-box-dot",d.sys_role[0]['authority'],".projectadmin-info-box");
|
||
});
|
||
}
|
||
|
||
$(document).off('click',".menu_dapax .item_kuvn").on('click',".menu_dapax .item_kuvn",function(){
|
||
$(".menu_dapax .item_kuvn").removeClass("selected___3ctlt");
|
||
$(this).addClass("selected___3ctlt");
|
||
var url = $(this).attr("data-url");
|
||
});
|
||
|
||
$(document).off('click','.roleinproject-tit').on("click",".roleinproject-tit",function(){
|
||
var index = $(this).attr("data-index");
|
||
$(".projectadmin-con-hz-left-list-con").removeClass("selected___3ctlt");
|
||
$(this).addClass("selected___3ctlt");
|
||
$(".projectadmin-list-name").html(datalist[index]['name']);
|
||
var id = $(this).attr("data-id");
|
||
updataapiinfo(id);
|
||
// X.laytpldata("#projectadmin-info-box-dot",data.dom_role[index]['authority'],".projectadmin-info-box");
|
||
});
|
||
|
||
function updataapiinfo(id){
|
||
role_id = id;
|
||
X.api("authz/get_permissions_for_user_in_domain","post",{role_id:id,game:X['DATA']['game']},function(d){
|
||
X.laytpldata("#projectadmin-info-box-dot",d,".projectadmin-info-box");
|
||
});
|
||
};
|
||
|
||
$(document).off('click','.projectadmin-del').on('click','.projectadmin-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
var path = $(this).attr('data-path');
|
||
layer.confirm('确认删除当前api吗?', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("authz/del_policy",'post',{role_id:role_id,game:X['DATA']['game'],path:path,act:"*"},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
updataapiinfo(role_id);
|
||
})
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.projectadmin-edit').on('click','.projectadmin-edit',function(params){
|
||
var path = $(this).attr('data-path');
|
||
var arr = [];
|
||
arr.push(path);
|
||
X.api("authz/add_policy",'post',{role_id:role_id,game:X['DATA']['game'],path_list:arr,act:"*"},function(d){
|
||
layer.close(layer.index);
|
||
layer.msg('添加成功');
|
||
updataapiinfo(role_id);
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.projectadmin-gongduo').on('click','.projectadmin-gongduo',function(e){
|
||
e.stopPropagation();
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var id = obj.attr('data-id');
|
||
var name = obj.attr("data-name");
|
||
var arr = [
|
||
{
|
||
title:'重命名',
|
||
id:'edit'
|
||
},
|
||
{
|
||
title:'删除',
|
||
id:'del'
|
||
}
|
||
]
|
||
X.querycriteriapop(arr,'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val.id == 'del'){
|
||
layer.confirm('确认删除当前角色吗?', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("authz/del_role_user_domain",'post',{role_id:id,game:X['DATA']['game'],username:name},function(d){
|
||
layer.close(layer.index);
|
||
layer.msg('删除成功');
|
||
updataroles();
|
||
})
|
||
});
|
||
}else {
|
||
var arr = {
|
||
id:id,
|
||
title:$(".projectadmin-list-name").html()
|
||
}
|
||
X.parametersopen(arr,"roleeditname",'auto',function(d){
|
||
updataroles();
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/projectinfo.js
|
||
(function(){
|
||
X.pageLogic['projectinfo'] = {
|
||
init : function(){
|
||
layui.form.render();
|
||
|
||
|
||
var data;
|
||
X.api("project/detail","get",{},function(d){
|
||
data = d;
|
||
X.laytpldata("#projectinfo-info-box-dot",data,".projectinfo-info-box");
|
||
// X.laytpldata("#usersbtx-dot",data.vUserIdItems,"#usersbtx");
|
||
|
||
// var ipWhitelistarr = data['ipWhitelist'].split(',');
|
||
// X.laytpldata("#projectinfo-ip-tx-box-dot",ipWhitelistarr,".projectinfo-ip-tx-box");
|
||
$(".projectinfo-ip-input").html(data['name']);
|
||
})
|
||
|
||
// var data = {
|
||
// 'projectName':'内网测试1',
|
||
// 'appid':1234545,
|
||
// "projectid":1546464,
|
||
// 'totalEventNum': 19193,//已用数据总量
|
||
// 'yuaneventtype':"8/500",
|
||
// 'yuaneventattr':'64/1000',
|
||
// 'userattr':"30/500",
|
||
// 'syncInterval':30,//间隔时间
|
||
// 'sendoutnum':30,//发送数量
|
||
// 'vUserIdItems':[
|
||
// {'columnDesc':'账户ID','id':131},
|
||
// {'columnDesc':'app版本','id':131}
|
||
// ],//用户识别体系
|
||
// ipWhitelist:'10.0.0.5,10.0.0.7'
|
||
// }
|
||
|
||
$("body").on("click",".menu_dapax .item_kuvn .item_kuvn-pl",function(){
|
||
$(".menu_dapax .item_kuvn .item_kuvn-pl").removeClass("selected___3ctlt");
|
||
$(this).addClass("selected___3ctlt");
|
||
})
|
||
|
||
|
||
|
||
$('body').on("click",".projectinfo-info-title img",function(){
|
||
$(".projectinfo-info-title").hide();
|
||
$(".projectinfo-info-title-update-box").show();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-info-title-update-cha",function(){
|
||
$(".projectinfo-info-title").show();
|
||
$(".projectinfo-info-title-update-box").hide();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-info-title-update-gou",function(){
|
||
$(".projectinfo-info-title").show();
|
||
$(".projectinfo-info-title-update-box").hide();
|
||
var tit = $(".projectinfo-info-title-update-box input").val();
|
||
X.api("project/rename","post",{project_id: X.DATA.projectid,rename: tit},function(d){
|
||
$(".projectinfo-info-title span").html(tit)
|
||
})
|
||
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-sdkpeizhi-edit",function(){
|
||
$(".projectinfo-sdkpeizhi").hide();
|
||
$(".projectinfo-sdkpeizhi-update-ope").show();
|
||
$(this).hide();
|
||
$(".projectinfo-sdkpeizhi-img").show();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-sdkpeizhi-img-del",function(){
|
||
$(".projectinfo-sdkpeizhi").show();
|
||
$(".projectinfo-sdkpeizhi-update-ope").hide();
|
||
$(this).hide();
|
||
$(".projectinfo-sdkpeizhi-img").hide();
|
||
$(".projectinfo-sdkpeizhi-edit").show();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-sdkpeizhi-img-update",function(){
|
||
$(".projectinfo-sdkpeizhi").show();
|
||
$(".projectinfo-sdkpeizhi-update-ope").hide();
|
||
$(this).hide();
|
||
$(".projectinfo-sdkpeizhi-img").hide();
|
||
$(".projectinfo-sdkpeizhi-edit").show();
|
||
var shijian = $(".projectinfo-sdkpeizhi-shijian").val();
|
||
var num = $(".projectinfo-sdkpeizhi-num").val();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-ip-edit",function(){
|
||
$(".projectinfo-ip-input").show();
|
||
$(".projectinfo-ip-tx-box").hide();
|
||
$(".projectinfo-ip-img").show();
|
||
$(this).hide();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-ip-img-del",function(){
|
||
$(".projectinfo-ip-input").hide();
|
||
$(".projectinfo-ip-tx-box").show();
|
||
$(".projectinfo-ip-img").hide();
|
||
$(".projectinfo-ip-edit").show();
|
||
})
|
||
|
||
$('body').on("click",".projectinfo-ip-img-update",function(){
|
||
$(".projectinfo-ip-input").hide();
|
||
$(".projectinfo-ip-tx-box").show();
|
||
$(".projectinfo-ip-img").hide();
|
||
$(".projectinfo-ip-edit").show();
|
||
var tit = $(".projectinfo-ip-input").html();
|
||
//ip白名单确定按钮
|
||
console.log(tit);
|
||
})
|
||
|
||
$('body').on("click",".usersattr",function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'usersbtx'
|
||
})
|
||
})
|
||
|
||
$("body").on("click",".timeadmin",function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'timeadmin'
|
||
})
|
||
})
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/retained.js
|
||
(function(){
|
||
X.pageLogic['retained'] = {
|
||
init : function(parms){
|
||
|
||
X.template("grouped","shushi");
|
||
// X.template("toptab","analysis-zhanwei",X.DATA['projectarr']);
|
||
|
||
var data ={
|
||
"eventView":{
|
||
"cksql":"retention",
|
||
"endTime":"2021-06-07 23:59:59",
|
||
"filts":[],
|
||
"groupBy":[],
|
||
"e_days":0,
|
||
"s_days":7,
|
||
"relation":"and",
|
||
"startTime":"2021-05-09 00:00:00",
|
||
"statType":"retention",
|
||
"timeParticleSize":"P1D",
|
||
"unitNum":7,
|
||
"filter_item_type":'all',
|
||
"filter_item":[]
|
||
},
|
||
"events":[
|
||
|
||
]
|
||
};
|
||
|
||
// 重新渲染控件
|
||
layui.form.render();
|
||
|
||
// 日期渲染
|
||
X.daterender("#retained-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['eventView']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['eventView']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
retaineddata();
|
||
});
|
||
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
var eventdata;
|
||
var groupitemeventsdata;//分组项里的事件
|
||
var querydata; //计算后返回的数据
|
||
var filter_map,quotas_map;
|
||
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
eventdata = d;
|
||
|
||
X.api("data_auth/load_prop_quotas","post",{event_name:eventdata[0]['category'][0]['event_name']},function(val){
|
||
|
||
type2data = val.props;
|
||
|
||
var arr = [{
|
||
"eventDesc":eventdata[0]['category'][0]['event_desc'],
|
||
"eventName":eventdata[0]['category'][0]['event_name'],
|
||
"filts":[],
|
||
"relation":"and",
|
||
"relationUser":"and",
|
||
"renameindicator":"",
|
||
"event_attr": type2data[0]['title'],
|
||
"event_attr_id": type2data[0]['id'],
|
||
},{
|
||
"eventDesc":eventdata[0]['category'][0]['event_desc'],
|
||
"eventName":eventdata[0]['category'][0]['event_name'],
|
||
"filts":[],
|
||
"relation":"and",
|
||
"relationUser":"and",
|
||
"renameindicator":"",
|
||
}]
|
||
data['events'] = arr;
|
||
X.api("data_auth/load_filter_props","post",{event_name:d[0]['category'][0]['event_name']},function(val){
|
||
groupitemeventsdata = val;
|
||
//初始事件
|
||
// console.log(data['events'][0]);
|
||
X.template("event","initial-event",data['events'][0]);
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
//从数据看板点击进来触发事件
|
||
if(X.DATA.retentionid && X.DATA.retentionid != ''){
|
||
var report_idarr = [];
|
||
report_idarr.push(X.DATA.retentionid);
|
||
if(X.DATA.authority != 'rw'){
|
||
$('.analysis-savereport').hide();
|
||
}else {
|
||
$(".analysis-saveas").show();
|
||
}
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_idarr},function(d){
|
||
backfilldata(d[0]);
|
||
})
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
|
||
})
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-zhibiao-list-type2').on('click','.analysis-zhibiao-list-type2',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
if(type2data.length >0){
|
||
X.parametersopen(type2data,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
// if(val != undefined){
|
||
console.log(val);
|
||
$("#analysis-zhibiao-list-type2-"+index).html(val.title);
|
||
data['events'][index]['event_attr'] = val.title;
|
||
data['events'][index]['event_attr_id'] = val.id;
|
||
// }
|
||
})
|
||
}
|
||
});
|
||
|
||
//开启重命名
|
||
$(document).off('click','.analysis-chongmingming-initial-event').on('click','.analysis-chongmingming-initial-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").show();
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-del-initial-event").show();
|
||
});
|
||
|
||
$(document).off('click','.analysis-chongmingming-return-event').on('click','.analysis-chongmingming-return-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-return-event").show();
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-del-return-event").show();
|
||
});
|
||
|
||
//取消重命名
|
||
$(document).off('click','.analysis-chongmingming-del-initial-event').on('click','.analysis-chongmingming-del-initial-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event").hide();
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-initial-event input").val('');
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-initial-event").show();
|
||
});
|
||
|
||
$(document).off('click','.analysis-chongmingming-del-return-event').on('click','.analysis-chongmingming-del-return-event',function(){
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-return-event").hide();
|
||
$("#analysis-con-left-screen-list-left-zhibiaoname-return-event input").val('');
|
||
$(this).hide();
|
||
$(".analysis-chongmingming-return-event").show();
|
||
});
|
||
|
||
// 添加初始事件筛选
|
||
// var initialevent = []
|
||
$(document).off('click','.analysis-shaix-initial-event').on('click','.analysis-shaix-initial-event',function(){
|
||
var arr = {
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],
|
||
"comparator":"==",
|
||
"comparatorName":"等于",
|
||
"ftv":[],
|
||
"strftv":"",
|
||
"tableType":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"data_type":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"timeUnit":""
|
||
}
|
||
// initialevent.push(arr);
|
||
data['events'][0]['filts'].push(arr);
|
||
|
||
X.template("event","initial-event",data['events'][0]);
|
||
});
|
||
var returnevent = [];
|
||
$(document).off('click','.analysis-shaix-return-event').on('click','.analysis-shaix-return-event',function(){
|
||
var arr = {
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],
|
||
"comparator":"==",
|
||
"comparatorName":"等于",
|
||
"ftv":[],
|
||
"strftv":"",
|
||
"tableType":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"data_type":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"timeUnit":""
|
||
}
|
||
// data['events'][1]['filts'].push(arr);
|
||
returnevent.push(arr);
|
||
data['events'][1]['filts'] = returnevent;
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
});
|
||
|
||
// 删除指定初始事件筛选
|
||
$(document).off('click','.analysis-zhibiao-list-del-initial-event').on('click','.analysis-zhibiao-list-del-initial-event',function(){
|
||
var index = $(this).attr("data-twonum");
|
||
data['events'][0]['filts'].splice(index,1);
|
||
X.template("event","initial-event",data['events'][0]);
|
||
});
|
||
|
||
$(document).off('click','.analysis-zhibiao-list-del-return-event').on('click','.analysis-zhibiao-list-del-return-event',function(){
|
||
var index = $(this).attr("data-twonum");
|
||
data['events'][1]['filts'].splice(index,1);
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname-initial-event input',function(){
|
||
var txt = $(this).val();
|
||
data['events'][0]['renameindicator'] = txt;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-list-left-zhibiaoname-return-event input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname-return-event input',function(){
|
||
var txt = $(this).val();
|
||
data['events'][1]['renameindicator'] = txt;
|
||
});
|
||
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var dataevent= data['events'][index];
|
||
// console.log(dataevent);
|
||
X.querycriteriapop(eventdata,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.id);
|
||
dataevent['eventName'] = val.name;
|
||
dataevent['eventDesc'] = val.id;
|
||
// console.log(data['events']);
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.ta-property-select').on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data['events'][index]['filts'][indexs]['columnDesc'] = htmlstring;
|
||
data['events'][index]['filts'][indexs]['columnName'] = val.id;
|
||
data['events'][index]['filts'][indexs]['data_type'] = val.type;
|
||
data['events'][index]['filts'][indexs]['tableType'] = val.table_type;
|
||
if(val.type == 'user_label'){
|
||
data['events'][index]['filts'][indexs]['comparatorName'] = "是";
|
||
data['events'][index]['filts'][indexs]['comparator'] = 'in';
|
||
}
|
||
if(index == 0){
|
||
X.template("event","initial-event",data['events'][0]);
|
||
}else {
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = data['events'][index]['filts'][indexs]['data_type'];
|
||
console.log(type);
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events'][index]['filts'][indexs]['comparatorName'] = val.title;
|
||
data['events'][index]['filts'][indexs]['comparator'] = val.id;
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off("click",".analysis-zhibiao-list-type4").on("click",".analysis-zhibiao-list-type4",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var indexs = $(this).attr("data-indexs");
|
||
var columnName = data['events'][index]['filts'][indexs]['columnName'];
|
||
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
data['events'][index]['filts'][indexs]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['events'][index]['filts'][indexs]['ftv'] = arr;
|
||
X.template("event","initial-event",data['events'][0]);
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
|
||
$(document).off("click",".analysis-overall-situation-input").on("click",".analysis-overall-situation-input",function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var columnName = data['eventView']['filts'][index]['columnName'];
|
||
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
if(val != "查无数据"){
|
||
X.parametersopen(val['map_'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
data['eventView']['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['eventView']['filts'][index]['ftv'] = arr;
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('change','.analysis-zhibiao-list-type4 input').on('change','.analysis-zhibiao-list-type4 input',function(){
|
||
var index = $(this).attr('data-index');
|
||
var indexs = $(this).attr('data-indexs');
|
||
var txt = $(this).val();
|
||
var txtarr = txt.split(",");
|
||
data['events'][index]['filts'][indexs]['strftv'] = txt;
|
||
data['events'][index]['filts'][indexs]['ftv'] = txtarr;
|
||
});
|
||
|
||
//全局筛选
|
||
var filtsftvdata=[];
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var screentypedata = groupitemeventsdata;
|
||
console.log(screentypedata);
|
||
var drr={
|
||
"columnName":screentypedata[0]['category'][0]['id'],//事件id
|
||
//"column_id":screentypedata[0]['category'][0]['id'],
|
||
"columnDesc":screentypedata[0]['category'][0]['title'],//事件中文显示
|
||
'data_type':screentypedata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"tableType":screentypedata[0]['id']
|
||
};
|
||
data['eventView']['filts'].push(drr);
|
||
filtsftvdata.push(screentypedata[0]['category'][0]['category']);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
//删除指定全局数据
|
||
$(document).off('click','.analysis-overall-situation-del').on('click','.analysis-overall-situation-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['eventView']['filts'].splice(index,1);
|
||
filtsftvdata.splice(index,1);
|
||
if(data['eventView']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click','.analysis-overall-situation-attr',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
console.log(val);
|
||
obj.html(val.title);
|
||
data['eventView']['filts'][index]['columnDesc'] = val.title;
|
||
data['eventView']['filts'][index]['columnName'] = val.id;
|
||
data['eventView']['filts'][index]['data_type'] = val.type;
|
||
data['eventView']['filts'][index]['comparator_name'] = '等于';
|
||
data['eventView']['filts'][index]['comparator'] = '==';
|
||
data['eventView']['filts'][index]['tableType'] = val.table_type;
|
||
filtsftvdata[index]=val.category;
|
||
|
||
if(val.type == 'user_label'){
|
||
data['eventView']['filts'][index]['comparator_name'] = "是";
|
||
data['eventView']['filts'][index]['comparator'] = 'in';
|
||
}
|
||
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
//循环给条件框渲染下拉框
|
||
// function analysisdown(){
|
||
// for(let i in data['eventView']['filts']){
|
||
// X.laydropdown("#analysis-overall-situation-fuhao-"+i,filtsftvdata[i],function(val){
|
||
// $(this).html(val.title);
|
||
// data['eventView']['filts'][i]['comparator_name'] = val.title;
|
||
// data['eventView']['filts'][i]['comparator'] = val.id;
|
||
// if(val.id == "range"){
|
||
// data['eventView']['filts'][i]['ftv'] = [-1,1];
|
||
// }
|
||
// X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
// analysisdown();
|
||
// });
|
||
// })
|
||
// }
|
||
// };
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['eventView']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['eventView']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
var type = data['eventView']['filts'][index]['data_type'];
|
||
console.log(type);
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
$(this).html(val.title);
|
||
data['eventView']['filts'][index]['comparator_name'] = val.title;
|
||
data['eventView']['filts'][index]['comparator'] = val.id;
|
||
if(val.id == "range"){
|
||
data['eventView']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('change','.analysis-overall-situation-input input').on('change','.analysis-overall-situation-input input',function(){
|
||
var index = $(this).attr('data-index');
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['eventView']['filts'][index]['ftv']=valarr;
|
||
data['eventView']['filts'][index]['strftv']=val;
|
||
})
|
||
|
||
// 分组项
|
||
$(document).off('click','.analysis-action-right').on('click','.analysis-action-right',function() {
|
||
var index = $(this).attr("data-index");
|
||
data.eventView.groupBy.splice(index,1);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
});
|
||
|
||
$(document).off('click','.analysis-footadd___2D4YB').on('click','.analysis-footadd___2D4YB',function() {
|
||
|
||
var arr = {
|
||
"columnDesc": "#account_id",//事件中文显示
|
||
"columnName": "#account_id",//事件id
|
||
'data_type': "string",//类型
|
||
'tableType': "event",
|
||
"ftv":"",//条件
|
||
"section":''//区间
|
||
};
|
||
data['eventView']['groupBy'].push(arr);
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-ant-dropdown-trigger').on('click','.analysis-ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
var htmlstring = val.title;
|
||
obj.html(htmlstring);
|
||
data.eventView.groupBy[index]['columnDesc'] = val.title;
|
||
data.eventView.groupBy[index]['columnName'] = val.id;
|
||
data.eventView.groupBy[index]['data_type'] = val.type;
|
||
data.eventView.groupBy[index]['tableType'] = val.tableType;
|
||
})
|
||
});
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
// if(querydata){
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
// }else {
|
||
// layer.msg('请先计算');
|
||
// }
|
||
|
||
});
|
||
|
||
// 时间粒度
|
||
X.laydropdown('.analtsis-timeParticleSize',X['DATA']['companylist']['retention'],function(d){
|
||
// console.log(d);
|
||
$(".analtsis-timeParticleSize").html(d.title);
|
||
data['eventView']['unitNum'] = parseInt(d.id);
|
||
retaineddata();
|
||
});
|
||
|
||
//留存流失
|
||
var retentionloss = [
|
||
{'title':'留存','id':0},
|
||
{'title':'流失','id':1}
|
||
]
|
||
var retentiontype = 0;//判断是显示流失数据还是留存
|
||
X.laydropdown('.retention-loss',retentionloss,function(d){
|
||
$('.retention-loss').html(d.title);
|
||
if(querydata['summary_values']){
|
||
retentiontype = d.id;
|
||
updata(querydata);
|
||
}
|
||
})
|
||
|
||
// 计算按钮
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
// console.log(data);
|
||
retaineddata()
|
||
});
|
||
|
||
function retaineddata(){
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/retention_model","post",dataArr,function(d){
|
||
if(d != "查无数据"){
|
||
querydata = d;
|
||
updata(d);
|
||
$(".chawushuj").hide();
|
||
}else {
|
||
$("#analysis-echarts").empty();
|
||
$(".table-fenxi-th").html("");
|
||
$(".table-fenxi-td").html("");
|
||
$(".chawushuj").show();
|
||
}
|
||
})
|
||
};
|
||
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
if(baobiaodata != '' && baobiaodata != undefined && baobiaodata != null){
|
||
baobiaodata['saveas']= 0;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
}else{
|
||
X.parametersopen(data,'savereport','auto');
|
||
}
|
||
});
|
||
|
||
//另存为
|
||
$(document).off('click','.analysis-saveas').on('click','.analysis-saveas',function(){
|
||
baobiaodata['saveas']= 1;
|
||
X.parametersopen(baobiaodata,'savereport','auto');
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
console.log(d);
|
||
if(d){
|
||
backfilldata(d);
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
var baobiaodata;//以存报表数据
|
||
function backfilldata(d){
|
||
data = d.query;
|
||
baobiaodata = d;
|
||
var time = $("#retained-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
X.template("event","initial-event",data['events'][0]);
|
||
X.template("returnvisitevent","returnvisit-event",data['events'][1]);
|
||
X.template("globalfilter","xinwei-whole",data['eventView']['filts'],function(){
|
||
renderdate();
|
||
});
|
||
X.template("grouped","shushi",data['eventView']['groupBy']);
|
||
|
||
retaineddata();
|
||
};
|
||
|
||
function updata(d){
|
||
var title = $(".select-chart").attr("title");
|
||
if(title == '数据报表'){ $(".table-div-box").show(); $(".analysis-echarts").hide(); retainedtable(d)}
|
||
else if(title == '第N日留存'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retainednRetained(d) }
|
||
else if(title == '每日留存'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retaineddayRetained(d) }
|
||
};
|
||
|
||
//数据报表渲染
|
||
function retainedtable(d){
|
||
var nname,pname
|
||
|
||
if(data['eventView']['filter_item_type'] != "all" && data['eventView']['filter_item_type']){
|
||
// var filteritem = data['eventView']['filter_item'];
|
||
// if(d['days'].length >= 0){
|
||
// var filterarr = [];
|
||
// for(let i in d['days']){
|
||
// for(let j in filteritem){
|
||
// if(d['days'][i] == filteritem[j]){
|
||
// filterarr.push(i);
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// var titarr = [];
|
||
// var tablearr = [];
|
||
// for(let i in filterarr){
|
||
// var index = Number(filterarr[i]) + 2;
|
||
// titarr.push(titdata[index]);
|
||
// }
|
||
// titarr.unshift(titdata[0],titdata[1]);
|
||
// console.log(titarr);
|
||
}
|
||
|
||
if(retentiontype == 0) {
|
||
nname = 'n';
|
||
pname = 'p';
|
||
}else {
|
||
nname = 'n_outflow';
|
||
pname = 'p_outflow';
|
||
}
|
||
var tabledata=[];
|
||
for(let i in d['summary_values']){
|
||
var arr = {
|
||
date: i,
|
||
d0:d['summary_values'][i]['d0'],
|
||
data:[]
|
||
}
|
||
for(let j in d['summary_values'][i]["n"]){
|
||
var nrr = {
|
||
n:0,
|
||
p:0
|
||
}
|
||
// if(data['eventView']['filter_item_type'] != "all" && data['eventView']['filter_item_type']){
|
||
// for(let a in filterarr){
|
||
// var index = Number(filterarr[a]);
|
||
// if(j == index){
|
||
// nrr["n"] = d['summary_values'][i][nname][j];
|
||
// nrr["p"] = d['summary_values'][i][pname][j]
|
||
// arr['data'].push(nrr);
|
||
// }
|
||
// }
|
||
// }else {
|
||
nrr["n"] = d['summary_values'][i][nname][j];
|
||
nrr["p"] = d['summary_values'][i][pname][j]
|
||
arr['data'].push(nrr);
|
||
// }
|
||
}
|
||
tabledata.push(arr)
|
||
}
|
||
|
||
// var titdata = [];
|
||
// if(data['eventView']['filter_item_type'] != "all" && data['eventView']['filter_item_type']){
|
||
// var titarr = [];
|
||
// for(let j in filterarr){
|
||
// var index = Number(filterarr[j]);
|
||
// titarr.push(d['days'][index]);
|
||
// }
|
||
// for(let i in titarr){
|
||
// var tit = "第" + titarr[i] + "日";
|
||
// titdata.push(tit);
|
||
// }
|
||
// }else {
|
||
// for(let i in d['days']){
|
||
// var tit = "第" + d['days'][i] + "日";
|
||
// titdata.push(tit);
|
||
// }
|
||
// }
|
||
// titdata.unshift("日期",d.title);
|
||
// console.log(titdata);
|
||
console.log(tabledata);
|
||
|
||
// X.fixedTable('table-div-box','row-col-fixed','',headdata);
|
||
|
||
|
||
X.laytpldata("#table-fenxi-th-dot",d.title,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",tabledata,".table-fenxi-td");
|
||
};
|
||
|
||
// 每日留存
|
||
function retaineddayRetained(d){
|
||
var arr = {};
|
||
var xAxisData=[];
|
||
var seriesData=[];
|
||
var legenddata = [];
|
||
if(jQuery.isEmptyObject(d.values)){
|
||
legenddata = d.date_range;
|
||
for(let i in d['days']){
|
||
var tit = "第" + i + "日";
|
||
xAxisData.push(tit);
|
||
}
|
||
for(let i in d['summary_values']){
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
data: d['summary_values'][i]['p']
|
||
}
|
||
seriesData.push(arr);
|
||
}
|
||
}else {
|
||
var timearr = [];
|
||
for(let i in d.values){
|
||
timearr.push(i);
|
||
for(let j in d.values[i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d.values[i][j]['p'];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d.values[i][j]['p'];
|
||
}
|
||
}
|
||
}
|
||
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in timearr ){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(timearr[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
console.log(ydata);
|
||
// for(let i in ydata){
|
||
// legenddata.push(i);
|
||
// var arr = {
|
||
// name: i,
|
||
// type: 'line',
|
||
// data: ydata[i]
|
||
// }
|
||
// seriesData.push(arr)
|
||
// }
|
||
}
|
||
return;
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: legenddata,
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: xAxisData
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
};
|
||
// 第N日留存
|
||
function retainednRetained(d){
|
||
var nname,pname
|
||
if(retentiontype == 0) {
|
||
nname = 'n';
|
||
pname = 'p';
|
||
}else {
|
||
nname = 'n_outflow';
|
||
pname = 'p_outflow';
|
||
}
|
||
var arr = {};
|
||
var legenddata = [];
|
||
var seriesData = [];
|
||
if(jQuery.isEmptyObject(d.values)){
|
||
var arr = []
|
||
for(let i in d['summary_values']){
|
||
var index = d['summary_values'][i][pname].length - 1;
|
||
legenddata.push(i);
|
||
arr.push(d['summary_values'][i][pname]);
|
||
}
|
||
d.title.splice(0,1);
|
||
xAxisData = d.title;
|
||
|
||
for(let i in arr){
|
||
var drr = {
|
||
name: d.date_range[i],
|
||
type: 'line',
|
||
data: arr[i]
|
||
}
|
||
seriesData.push(drr);
|
||
}
|
||
|
||
}else {
|
||
var timearr = [];
|
||
for(let i in d.values){
|
||
timearr.push(i);
|
||
for(let j in d.values[i]){
|
||
if(arr[j]){
|
||
arr[j][i] = d.values[i][j][pname];
|
||
}else {
|
||
arr[j]=[];
|
||
arr[j][i] = d.values[i][j][pname];
|
||
}
|
||
}
|
||
}
|
||
var ydata = {};
|
||
for(let j in arr){
|
||
if(!ydata[j]){
|
||
ydata[j] = [];
|
||
}
|
||
for( let i in timearr ){
|
||
ydata[j].push("");
|
||
for(let z in arr[j]){
|
||
if(timearr[i] == z){
|
||
var index = arr[j][z].length - 1;
|
||
ydata[j][i] =arr[j][z][index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for(let i in ydata){
|
||
legenddata.push(i);
|
||
var arr = {
|
||
name: i,
|
||
type: 'line',
|
||
data: ydata[i]
|
||
}
|
||
seriesData.push(arr)
|
||
}
|
||
|
||
}
|
||
var selected = {};//线多的话默认显示5条
|
||
if(legenddata.length > 5){
|
||
for(let i in legenddata){
|
||
if(i < 5){
|
||
selected[legenddata[i]] = true;
|
||
}else {
|
||
selected[legenddata[i]] = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
var myChart = echarts.init(document.getElementById('analysis-echarts'));
|
||
var option = {
|
||
title: {
|
||
text: ''
|
||
},
|
||
color: X.DATA.echartscolor,
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'cross',
|
||
label: {
|
||
backgroundColor: '#6a7985'
|
||
}
|
||
}
|
||
},
|
||
legend: {
|
||
type:'scroll',
|
||
data: legenddata,
|
||
selected:selected
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: false,
|
||
data: d.date_range
|
||
}
|
||
],
|
||
yAxis: [
|
||
{
|
||
type: 'value'
|
||
}
|
||
],
|
||
series: seriesData
|
||
};
|
||
myChart.setOption(option,true);
|
||
|
||
};
|
||
|
||
$(document).off('click','.analtsis-chart-switch').on('click','.analtsis-chart-switch',function(){
|
||
if(querydata){
|
||
$('.analtsis-chart-switch-box .analtsis-chart-switch').removeClass('select-chart');
|
||
$(this).addClass('select-chart');
|
||
if($(this).attr('title') == '数据报表'){ $(".table-div-box").show(); $(".analysis-echarts").hide(); retainedtable(querydata)}
|
||
else if($(this).attr('title') == '第N日留存'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retainednRetained(querydata) }
|
||
else if($(this).attr('title') == '每日留存'){ $(".table-div-box").hide(); $(".analysis-echarts").show(); retaineddayRetained(querydata) }
|
||
}else{
|
||
layer.msg('请先计算数据,在切换图表');
|
||
}
|
||
});
|
||
|
||
//显示设置
|
||
$(document).off('click','.analtsis-condition-xssz').on('click','.analtsis-condition-xssz',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
// offset.left,offset.top+obj.height()
|
||
$(".showsetup-box").show();
|
||
$(".showsetup-down-box").css('top',offset.top+obj.height());
|
||
$(".showsetup-down-box").css('left',offset.left-211);
|
||
layui.form.val('showsetupexample',{
|
||
'showsetup': data['eventView']['filter_item_type']
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.showsetup-box-zz').on('click','.showsetup-box-zz',function(){
|
||
$(".showsetup-box").hide();
|
||
});
|
||
|
||
layui.form.on('radio(showsetup)', function(val){
|
||
if(val.value == 'date'){
|
||
$(".showsetup-edit").show();
|
||
$(".showsetup-bianji-show-box-type").show();
|
||
var value = $(".showsetup-bianji-input-box textarea").val();
|
||
var valarr = value.split(',');
|
||
valarr.sort(function(a, b){return a - b});
|
||
var listarr = unique(valarr);
|
||
data['eventView']['filter_item'] = listarr;
|
||
X.laytpldata("#showsetup-bianji-show-box-dot",listarr,".showsetup-bianji-show-box");
|
||
}else {
|
||
$(".showsetup-edit").hide();
|
||
$(".showsetup-wancheng").hide();
|
||
$(".showsetup-bianji-show-box-type").hide();
|
||
$(".showsetup-bianji-input-box-type").hide();
|
||
}
|
||
data['eventView']['filter_item_type'] = val.value;
|
||
if(querydata){
|
||
retainedtable(querydata)
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.showsetup-edit').on('click','.showsetup-edit',function(){
|
||
$(".showsetup-edit").hide();
|
||
$(".showsetup-wancheng").show();
|
||
$(".showsetup-bianji-show-box-type").hide();
|
||
$(".showsetup-bianji-input-box-type").show();
|
||
});
|
||
|
||
$(document).off('click','.showsetup-wancheng').on('click','.showsetup-wancheng',function(){
|
||
$(".showsetup-edit").show();
|
||
$(".showsetup-wancheng").hide();
|
||
$(".showsetup-bianji-show-box-type").show();
|
||
$(".showsetup-bianji-input-box-type").hide();
|
||
var value = $(".showsetup-bianji-input-box textarea").val();
|
||
var valarr = value.split(',');
|
||
valarr.sort(function(a, b){return a - b});
|
||
var listarr = unique(valarr);
|
||
data['eventView']['filter_item'] = listarr;
|
||
X.laytpldata("#showsetup-bianji-show-box-dot",listarr,".showsetup-bianji-show-box");
|
||
if(querydata){
|
||
retainedtable(querydata)
|
||
}
|
||
});
|
||
|
||
function unique (arr) {
|
||
return Array.from(new Set(arr))
|
||
};
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
// 下载
|
||
$(document).off('click','.download-table').on('click','.download-table',function(){
|
||
console.log(11111);
|
||
X.download('ck/retention_model_export',data,'事件分析');
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/returnvisitevent.js
|
||
(function(){
|
||
X.pageLogic['returnvisitevent'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
// console.log(data);
|
||
X.laytpldata("#analysis-overall-situation-list-box-return-dot",data,"#returnvisit-event");
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/roleeditname.js
|
||
(function(){
|
||
X.pageLogic['roleeditname'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
|
||
$(document).off('click','.modifyname-qd').on('click','.modifyname-qd',function(){
|
||
console.log(111);
|
||
var txt = $(".modifyname-txt").val();
|
||
X.api("authz/edit_role","post",{role_id:data['id'],name:txt,desc:""},function(d){
|
||
console.log(d);
|
||
layer.closeAll(0);
|
||
me.callback && me.callback();
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.modifyname-qx').on('click','.modifyname-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.modifyname-cha').on('click','.modifyname-cha',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/route.js
|
||
(function(){
|
||
X.pageLogic['route'] = {
|
||
init : function(parms){
|
||
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
console.log(data);
|
||
X.laytpldata("#route-overall-situation-list-box-dot",data,"#event-roue-event");
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/routeanalysis.js
|
||
(function(){
|
||
X.pageLogic['routeanalysis'] = {
|
||
init : function(){
|
||
|
||
var data = {
|
||
"eventView":{
|
||
"cksql":'trace',
|
||
"col_limit":10,
|
||
"startTime":"",
|
||
"session_interval":30,
|
||
"session_type":"minute",
|
||
"endTime":""
|
||
},
|
||
"events":{
|
||
"by_fields":[
|
||
|
||
],
|
||
"event_names":[],
|
||
"source_event":{
|
||
"eventName":"",
|
||
"eventDesc":"",
|
||
"source_type":"initial_event",
|
||
"source_type_name":"初始事件",
|
||
"filts": [],
|
||
"relation":'and'
|
||
},
|
||
"user_filter":{
|
||
"filterType":"COMPOUND",
|
||
"filts":[]
|
||
}
|
||
},
|
||
"cachedata":{
|
||
"event_names":[],
|
||
}
|
||
}
|
||
|
||
|
||
X.template("route","event-roue-event",data['events']['source_event']);
|
||
|
||
// 日期渲染
|
||
X.daterender("#route-condition-date",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['eventView']['startTime'] = startTime;
|
||
data['eventView']['endTime'] = endTime;
|
||
X.api("ck/trace_model","post",data,function(d){
|
||
routeanalysisdata(d);
|
||
})
|
||
})
|
||
|
||
var time = $("#route-condition-date").val();
|
||
var timearr = time.split(" ");
|
||
data['eventView']['startTime'] = timearr[0] + " "+"00:00:00";
|
||
data['eventView']['endTime'] = timearr[2]+" "+"23:59:59";
|
||
|
||
var filter_map;
|
||
var eventdata = {};
|
||
var filtsftvdata =[];
|
||
var groupitemeventsdata = [];
|
||
var routeevent = [];
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
eventdata['list'] = d;
|
||
X.api("data_auth/load_filter_props","post",{event_name:d[0]['category'][0]['event_name']},function(val){
|
||
groupitemeventsdata= val;
|
||
})
|
||
});
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
});
|
||
|
||
|
||
$(document).off('click','.eventsplit').on('click','.eventsplit',function(){
|
||
|
||
if( routeevent && routeevent.length > data['events']['by_fields'].length){
|
||
var arr = {
|
||
"eventName": routeevent[data['events']['by_fields'].length]['id'],
|
||
"eventDesc": routeevent[data['events']['by_fields'].length]['title'],
|
||
"field":"rmbmoney",
|
||
"fieDesc":"rmbmoney",
|
||
"range":"",
|
||
"range_type":"def",
|
||
"tableType":"event",
|
||
"intervalType":"",
|
||
"quotaIntervalArr":""
|
||
};
|
||
data['events']['by_fields'].push(arr);
|
||
X.laytpldata("#eventsplit-box-dot",data['events']['by_fields'],".eventsplit-box");
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.route-action-right').on('click','.route-action-right',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['events']['by_fields'].splice(index,1);
|
||
X.laytpldata("#eventsplit-box-dot",data['events']['by_fields'],".eventsplit-box");
|
||
});
|
||
|
||
$(document).off('click','.participate-box').on('click','.participate-box',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(eventdata,'participate',offset.left,offset.top+obj.height(),function(val){
|
||
var selectdata = []; //选中事件的id数组
|
||
// var selectdescdata = []; //选中事件的别名数组
|
||
for(let i in val){
|
||
selectdata.push(val[i]['event_name']);
|
||
// selectdescdata.push(val[i]['event_desc']);
|
||
}
|
||
eventdata['select'] = selectdata;
|
||
data['events']['event_names'] = selectdata;
|
||
$('.participate-num').html(selectdata.length);
|
||
|
||
for(let i in val){
|
||
var arr = {
|
||
title: val[i]['event_desc']
|
||
,id: val[i]['event_name']
|
||
}
|
||
routeevent.push(arr);
|
||
}
|
||
data['events']['source_event']['eventName'] = routeevent[0]['id'];
|
||
data['events']['source_event']['eventDesc'] = routeevent[0]['title'];
|
||
X.template("route","event-roue-event",data['events']['source_event']);
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.route-ant-select-selector1').on('click','.route-ant-select-selector1',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
X.querycriteriapop(routeevent,'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['events']['by_fields'][index]['eventDesc'] = val.title;
|
||
data['events']['by_fields'][index]['eventName'] = val.id;
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.route-ant-select-selector2').on('click','.route-ant-select-selector2',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
console.log(val);
|
||
obj.html(val.title);
|
||
data['events']['by_fields'][index]['eventDesc'] = val.title;
|
||
data['events']['by_fields'][index]['eventName'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.userevent-granularity').on('click','.userevent-granularity',function(){
|
||
var index = $(this).attr('data-index');
|
||
var sectionid = data['events']['by_fields'][index];
|
||
console.log(sectionid);
|
||
X.parametersopen(sectionid,'groupeditemspop',"auto",function(val){
|
||
data['events']['by_fields'][index]['intervalType'] = val.type;
|
||
if(val.type == "user_defined"){
|
||
data['events']['by_fields'][index]['quotaIntervalArr'] = val.quotaIntervalArr;
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-del').on('click','.analysis-overall-situation-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
data['events']['user_filter']['filts'].splice(index,1);
|
||
if(data['events']['user_filter']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['user_filter']['filts'],function(){
|
||
renderdate()
|
||
});
|
||
});
|
||
|
||
$(document).off('click','.analysis-shaix-initial-event').on('click','.analysis-shaix-initial-event',function(){
|
||
addscreen(0)
|
||
});
|
||
|
||
$(document).off('click','.analysis-zhibiao-updata-initial-event').on('click','.analysis-zhibiao-updata-initial-event',function(){
|
||
addscreen(0)
|
||
});
|
||
|
||
// 添加筛选项
|
||
function addscreen(index){
|
||
console.log(groupitemeventsdata);
|
||
var arr = {
|
||
"columnDesc":groupitemeventsdata[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":groupitemeventsdata[0]['category'][0]['id'],//事件id
|
||
"comparator_name": filter_map[groupitemeventsdata[0]['category'][0]['data_type']][0]['title'],//选择符号中文显示
|
||
"comparator":filter_map[groupitemeventsdata[0]['category'][0]['data_type']][0]['id'],//符号id
|
||
"data_type":groupitemeventsdata[0]['category'][0]['data_type'],
|
||
"ftv":[],//条件
|
||
"strftv":'',//字符串显示条件
|
||
"tableType": groupitemeventsdata[0]['id']
|
||
} //筛选数据
|
||
data['events']['source_event']['filts'].push(arr);
|
||
X.template("route","event-roue-event",data['events']['source_event']); //更新事件
|
||
};
|
||
|
||
$(document).off('click','.analysis-con-left-screen-list-right-screen-qh-tit').on('click','.analysis-con-left-screen-list-right-screen-qh-tit',function(){
|
||
if($(this).html() == '或'){
|
||
$(this).html('且');
|
||
data['events']["source_event"]['relation'] = 'or';
|
||
}else{
|
||
$(this).html('或');
|
||
data['events']["source_event"]['relation'] = 'and';
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(routeevent,'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['events']['source_event']['eventDesc']= val.title;
|
||
data['events']['source_event']['eventName'] = val.id;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-zhibiao-list-type2').on('click','.analysis-zhibiao-list-type2',function(){
|
||
var eventdata = [
|
||
{'title':'初始事件','id':'initial_event'},
|
||
{'title':'结束事件','id':'termination_event'}
|
||
]
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(eventdata,'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
// data['events']['source_event']['source_type_name']= val.title;
|
||
data['events']['source_event']['source_type'] = val.id;
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off("click",".ta-property-select").on('click','.ta-property-select',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var indexs = obj.attr("data-indexs");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['events']['source_event']['filts'][indexs]['columnDesc'] = val.title;
|
||
data['events']['source_event']['filts'][indexs]['columnName'] = val.id;
|
||
data['events']['source_event']['filts'][indexs]['data_type'] = val.type;
|
||
data['events']['source_event']['filts'][indexs]['tableType'] = val.table_type;
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-choicetypename').on('click','.analysis-choicetypename',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var indexs = $(this).attr("data-indexs");
|
||
var type = data['events']['source_event']['filts'][indexs]['data_type'];
|
||
X.querycriteriapop(filter_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events']['source_event']['filts'][indexs]['comparator_name'] = val.title;
|
||
data['events']['source_event']['filts'][indexs]['comparator'] = val.id;
|
||
X.template("userpar","userpar-event",data['events']);
|
||
}
|
||
})
|
||
});
|
||
|
||
$(document).off('blur','.analysis-zhibiao-list-type4 input').on('blur','.analysis-zhibiao-list-type4 input',function(){
|
||
var indexs = $(this).attr("data-indexs");
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['events']['source_event']['filts'][indexs]['ftv']=valarr;
|
||
data['events']['source_event']['filts'][indexs]['strftv']=val;
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
||
var screentypedata = groupitemeventsdata;
|
||
if(!screentypedata) {alert('请先选择参与分析事件'); return;}
|
||
var drr={
|
||
"columnDesc":screentypedata[0]['category'][0]['title'],//事件中文显示
|
||
"columnName":screentypedata[0]['category'][0]['id'],//事件id
|
||
'data_type':screentypedata[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator_id":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"table_type":screentypedata[0]['id']
|
||
};
|
||
data['events']['user_filter']['filts'].push(drr);
|
||
if(data['events']['user_filter']['filts'].length > 1){
|
||
$(".analysis-overall-situation-left-guanxi").show();
|
||
}else{
|
||
$(".analysis-overall-situation-left-guanxi").hide();
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['user_filter']['filts'],function(){
|
||
renderdate()
|
||
});
|
||
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-attr').on('click','.analysis-overall-situation-attr',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
X.querycriteriapop(groupitemeventsdata,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['events']['user_filter']['filts'][index]['columnDesc'] = val.title;
|
||
data['events']['user_filter']['filts'][index]['columnName'] = val.id;
|
||
data['events']['user_filter']['filts'][index]['data_type'] = val.type;
|
||
data['events']['user_filter']['filts'][index]['tableType'] = val.table_type;
|
||
X.template("globalfilter","xinwei-whole",data['events']['user_filter']['filts'],function(){
|
||
renderdate()
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-overall-situation-fuhao').on('click','.analysis-overall-situation-fuhao',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = $(this).attr("data-index");
|
||
var type = data['events']['user_filter']['filts'][index]['data_type'];
|
||
X.querycriteriapop(filter_map[type],'dropdownlist',offset.left,offset.top+obj.height(),function(val){
|
||
if(val != undefined){
|
||
obj.html(val.title);
|
||
data['events']['user_filter']['filts'][index]['comparator_name'] = val.title;
|
||
data['events']['user_filter']['filts'][index]['comparator_id'] = val.id;
|
||
if(val.id == "range"){
|
||
data['events']['user_filter']['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.template("globalfilter","xinwei-whole",data['events']['user_filter']['filts'],function(){
|
||
renderdate()
|
||
});
|
||
}
|
||
})
|
||
});
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.analysis-overall-situation-date').on('click','.analysis-overall-situation-date',function(){
|
||
var index = $(this).attr('data-index');
|
||
render_date_index = index;
|
||
// console.log(index);
|
||
});
|
||
|
||
// 渲染过滤项时间框
|
||
function renderdate(){
|
||
lay('.analysis-overall-situation-date').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['events']['user_filter']['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['events']['user_filter']['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
||
var index = $(this).attr('data-index');
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['events']['user_filter']['filts'][index]['ftv']=valarr;
|
||
data['events']['user_filter']['filts'][index]['strftv']=val;
|
||
});
|
||
|
||
$(document).off('blur','.analysis-overall-situation-input2 input').on('blur','.analysis-overall-situation-input2 input',function(){
|
||
var name = $(this).attr('name');
|
||
var val = $(this).val();
|
||
var index = $(this).attr("data-index");
|
||
|
||
if(name == 'start'){
|
||
data['events']['user_filter']['filts'][index]['ftv'][0] = val;
|
||
data['events']['user_filter']['filts'][index]['section'][0] = val;
|
||
}else {
|
||
data['events']['user_filter']['filts'][index]['ftv'][1] = val;
|
||
data['events']['user_filter']['filts'][index]['section'][1] = val;
|
||
}
|
||
});
|
||
|
||
// 时间粒度
|
||
var timeParticleSizearr = [
|
||
{'title':'秒','id':'second'},
|
||
{'title':'分钟','id':'minute'},
|
||
{'title':'小时','id':'hour'},
|
||
];
|
||
X.laydropdown('.route-condition',timeParticleSizearr,function(d){
|
||
console.log(d);
|
||
$(".route-condition").html(d.title);
|
||
data['eventView']['session_type'] = parseInt(d.id);
|
||
});
|
||
|
||
$(document).off('blur','.analysis-con-left-screen-box2 input').on('blur','.analysis-con-left-screen-box2',function(){
|
||
data['eventView']['session_interval'] =parseInt($('.analysis-con-left-screen-box2 input').val());
|
||
});
|
||
|
||
//计算按钮
|
||
$(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){
|
||
calculationdata();
|
||
});
|
||
|
||
|
||
function calculationdata(){
|
||
// data['cachedata']['event_names'] = X['DATA']['routeevent'];
|
||
var dataArr = {
|
||
eventView: data.eventView,
|
||
events: data.events
|
||
}
|
||
X.api("ck/trace_model","post",dataArr,function(d){
|
||
routeanalysisdata(d);
|
||
})
|
||
};
|
||
|
||
// sql语句显示
|
||
$(document).off('click','.sqlquery').on('click','.sqlquery',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
X.querycriteriapop(data,'conditionquery',offset.left - 410,offset.top+obj.height(),function(){
|
||
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.analysis-savereport').on('click','.analysis-savereport',function(){
|
||
X.parametersopen(data,'savereport','auto')
|
||
});
|
||
|
||
$(document).off('click','.analysis-navigation-bar-right-img-baobiao').on('click','.analysis-navigation-bar-right-img-baobiao',function(){
|
||
X.parametersopen(data['eventView']['cksql'],'savedbaobiao','rt',function(d){
|
||
console.log(d);
|
||
if(d){
|
||
data = d.query;
|
||
$('.route-time-input').val(data['eventView']['session_interval']);
|
||
if(data['eventView']['session_type'] == "second"){
|
||
$(".route-condition").html("秒");
|
||
}else if(data['eventView']['session_type'] == "minute"){
|
||
$(".route-condition").html("分钟");
|
||
}else {
|
||
$(".route-condition").html("小时");
|
||
}
|
||
// X.DATA['routeevent'] = data.cachedata.event_names;
|
||
// $('.participate-num').html(data.cachedata.event_names.length);
|
||
|
||
X.template("route","event-roue-event",data['events']['source_event']);
|
||
X.template("globalfilter","xinwei-whole",data['events']['user_filter']['filts'],function(){
|
||
renderdate()
|
||
});
|
||
X.laytpldata("#eventsplit-box-dot",data['events']['by_fields'],".eventsplit-box");
|
||
// X.template("userpar","userpar-event",data['events']);
|
||
|
||
calculationdata();
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
function routeanalysisdata(d){
|
||
var myChart = echarts.init(document.getElementById('routeanalysis-echarts'));
|
||
|
||
var colordata = X.DATA['echartscolor'];
|
||
var levelsdata = [];
|
||
for(let i in colordata){
|
||
var arr = {
|
||
depth: i,
|
||
itemStyle: {
|
||
color: colordata[i]
|
||
},
|
||
label: {
|
||
show:true,
|
||
position: 'center'
|
||
},
|
||
lineStyle: {
|
||
color: 'source',
|
||
opacity: 0.6
|
||
}
|
||
};
|
||
levelsdata.push(arr);
|
||
}
|
||
|
||
myChart.setOption(option = {
|
||
title: {
|
||
text: '用户行为路径'
|
||
},
|
||
grid: {
|
||
left: '2%',
|
||
right: '2%',
|
||
bottom: '2%',
|
||
top: '10%',
|
||
containLabel: true
|
||
},
|
||
tooltip: {
|
||
trigger: 'item',
|
||
triggerOn: 'mousemove'
|
||
},
|
||
series: [
|
||
{
|
||
type: 'sankey',
|
||
data: d.nodes,
|
||
links: d.links,
|
||
emphasis: {
|
||
focus: 'adjacency'
|
||
},
|
||
levels: levelsdata,
|
||
lineStyle: {
|
||
curveness: 0.5
|
||
}
|
||
}
|
||
]
|
||
});
|
||
};
|
||
|
||
// 返回
|
||
$(document).off('click','.analysis-fanhui').on('click','.analysis-fanhui',function(){
|
||
X.gourl("dashboard");
|
||
// return;
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/savedbaobiao.js
|
||
(function(){
|
||
X.pageLogic['savedbaobiao'] = {
|
||
init : function(parms){
|
||
// 弹窗占满整平
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var type = parms.extData;
|
||
layui.form.render();
|
||
$(".saved-bg").css('height',window.innerHeight+'px');
|
||
|
||
var data = []
|
||
reportdata();
|
||
|
||
function reportdata(){
|
||
X.api("report/read_report",'post',{project_id:X.DATA.projectid},function(d){
|
||
data = d;
|
||
updatalist(type);
|
||
$(".saved-select-type").val(type);
|
||
})
|
||
}
|
||
|
||
//关闭页面
|
||
$(".saved-top img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
// 搜索报表选中事件
|
||
$(".saved-sousuo-box .saved-txt").focus(function(){
|
||
$(this).css("border","1px solid #3d90ff");
|
||
$(this).css("box-shadow","0 0px 4px rgba(61, 144, 255, 0.45)");
|
||
})
|
||
// 失去光标事件
|
||
$(".saved-sousuo-box .saved-txt").blur(function(){
|
||
$(this).css("border","1px solid #eee");
|
||
$(this).css("box-shadow","none");
|
||
})
|
||
|
||
// 下拉框
|
||
$(".saved-select-type").change(function(){
|
||
updatalist($(this).val())
|
||
})
|
||
|
||
function updatalist(title){
|
||
var screendata=[];//筛选后的数据
|
||
for(let i in data){
|
||
if(title == 0){
|
||
screendata = data;
|
||
}else {
|
||
if(data[i]['cat'] == title){
|
||
screendata.push(data[i]);
|
||
}
|
||
}
|
||
}
|
||
X.laytpldata("#saved-list-box-dot",screendata,".saved-list-box");
|
||
}
|
||
|
||
// 点击报表数据
|
||
$(document).off('click','.saved-list').on('click','.saved-list',function(){
|
||
var id = $(this).attr("data-id");
|
||
var cat = $(this).attr("data-cat");
|
||
if(type == cat){
|
||
for(let i in data){
|
||
if(id == data[i]['_id']){
|
||
me.callback && me.callback(data[i]);
|
||
layer.closeAll();
|
||
}
|
||
}
|
||
}else {
|
||
layer.msg('选择报表不是当前分析报表');
|
||
}
|
||
|
||
|
||
})
|
||
|
||
// 搜索
|
||
$('.saved-sousuo-box .saved-txt').bind('input propertychange', function() {
|
||
// console.log($(this).val());
|
||
var screendata=[];//筛选后的数据
|
||
for(let i in data){
|
||
if($(this).val() != ""){
|
||
if(data[i]['name'].indexOf($(this).val()) != -1){
|
||
screendata.push(data[i]);
|
||
}
|
||
}else {
|
||
screendata = data;
|
||
}
|
||
}
|
||
X.laytpldata("#saved-list-box-dot",screendata,".saved-list-box");
|
||
})
|
||
|
||
// 删除报表
|
||
$(document).off('click','.saved-list-del').on("click",".saved-list-del",function(e){
|
||
var id = $(this).attr("data-id");
|
||
e.stopPropagation();
|
||
X.api("report/delete","post",{"_id": id},function(d){
|
||
layer.msg('删除成功!!!');
|
||
reportdata();
|
||
})
|
||
})
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/savereport.js
|
||
(function(){
|
||
X.pageLogic['savereport'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
layui.form.render();
|
||
if(data._id){
|
||
console.log(data);
|
||
layui.form.val('savereportexample', {
|
||
"title": data['name']
|
||
,"desc": data['desc']
|
||
,"date_type": data['query']['eventView']['date_type'] || "dynamic"
|
||
});
|
||
}
|
||
$(document).off('click',".savereport-but-qd").on('click','.savereport-but-qd',function(){
|
||
var tabval = layui.form.val('savereportexample');
|
||
if(tabval['title'] == ""){
|
||
layer.msg("请填写报表名称");
|
||
return false;
|
||
}
|
||
if(tabval['desc'] == ""){
|
||
layer.msg("请填写报表备注");
|
||
return false;
|
||
}
|
||
|
||
if(data.saveas == 0 ){
|
||
data['query']['eventView']['date_type'] = tabval.date_type;
|
||
var arr = {
|
||
name: tabval['title'],
|
||
desc:tabval['desc'],
|
||
query:data['query'],
|
||
report_id:data['_id']
|
||
}
|
||
X.api('report/edit','post',arr,function(d){
|
||
|
||
// 提交看板修改记录
|
||
// X.submitrecord('修改'+tabval['title']+'看板')
|
||
layer.msg(d);
|
||
layer.closeAll();
|
||
|
||
})
|
||
}else {
|
||
data['eventView']['date_type'] = tabval.date_type;
|
||
var arr = {
|
||
name: tabval['title'],
|
||
desc:tabval['desc'],
|
||
query:data,
|
||
project_id:X.DATA.projectid,
|
||
cat: data['eventView']['cksql']
|
||
}
|
||
X.api('report/create','post',arr,function(d){
|
||
layer.msg(d);
|
||
layer.closeAll();
|
||
})
|
||
}
|
||
});
|
||
|
||
$(document).off('click',".savereport-but-qx").on('click','.savereport-but-qx',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/screen.js
|
||
(function(){
|
||
X.pageLogic['screen'] = {
|
||
init : function(parms){
|
||
var width = window.innerWidth - 270;
|
||
$(".screen-box").css("width",width+"px");
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var reportid = parms.extData;//获取到上层弹窗传的数据
|
||
|
||
//默认开始时有一个数据
|
||
var data = {
|
||
'filts':[],
|
||
'relation':'and'
|
||
};
|
||
if(reportid){
|
||
data = reportid;
|
||
if(reportid.relation == 'and'){
|
||
$('.screen-left-qei').html("且");
|
||
}else {
|
||
$('.screen-left-qei').html("或");
|
||
}
|
||
if(reportid['filts'].length > 1){
|
||
$('.screen-left-qei').show();
|
||
}
|
||
X.laytpldata("#screen-con-box-dot",reportid['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
}
|
||
|
||
var my_event,load_filter_props,filter_map;
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
my_event = d;
|
||
X.api("data_auth/load_filter_props","post",{event_name:my_event[0]['category'][0]['event_name']},function(val){
|
||
load_filter_props = val;
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
if(!reportid){
|
||
updatascreencon();
|
||
}
|
||
})
|
||
})
|
||
});
|
||
|
||
// 显示隐藏添加条件按钮
|
||
$(document).off('click','.screen-right-box .img').on('click','.screen-right-box .img',function(){
|
||
if($(".screen-buttom-box").css('display') == 'block'){
|
||
$(".screen-buttom-box").hide();
|
||
$(".screen-left-qei").css('bottom','0px');
|
||
$(".screen-right-box .img").css('transform','rotate(180deg)');
|
||
}else {
|
||
$(".screen-buttom-box").show();
|
||
$(".screen-left-qei").css('bottom','24px');
|
||
$(".screen-right-box .img").css('transform','rotate(360deg)');
|
||
}
|
||
});
|
||
|
||
//清空按钮
|
||
$(document).off('click','.screen-right-box .qingkong').on('click','.screen-right-box .qingkong',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.screen-left-box .screen-left-qei').on('click','.screen-left-box .screen-left-qei',function(){
|
||
if($(this).html() == "且"){
|
||
$(this).html("或");
|
||
data['relation'] = 'or';
|
||
}else {
|
||
$(this).html("且");
|
||
data['relation'] = 'and';
|
||
}
|
||
});
|
||
|
||
function updatascreencon(){
|
||
var drr={
|
||
"columnName":load_filter_props[0]['category'][0]['id'],//事件id
|
||
"columnDesc":load_filter_props[0]['category'][0]['title'],//事件中文显示
|
||
'data_type':load_filter_props[0]['category'][0]['data_type'],//类型
|
||
'comparator_name':'等于',//默认等于
|
||
"comparator":'==',//符号id
|
||
"ftv":[],//条件
|
||
"strftv":'',//显示条件
|
||
"section":[-1,1],//区间
|
||
"tableType":load_filter_props[0]['id']
|
||
};
|
||
|
||
data['filts'].push(drr);
|
||
|
||
X.laytpldata("#screen-con-box-dot",data['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
if(data['filts'].length >= 2){
|
||
$(".screen-left-qei").show();
|
||
}else {
|
||
$(".screen-left-qei").hide();
|
||
}
|
||
};
|
||
|
||
//条件添加按钮
|
||
$(document).off('click','.screen-buttom-box .screen-buttom').on('click','.screen-buttom-box .screen-buttom',function(){
|
||
updatascreencon();
|
||
});
|
||
|
||
X.daterender("#time-box-timechoice1");
|
||
|
||
var render_date_index;//且用户符合时间选择框的index
|
||
$(document).off('click','.right-date-box').on("click",'.right-date-box',function(){
|
||
var index = $(this).attr("data-index");
|
||
render_date_index = index;
|
||
});
|
||
|
||
function renderdate(){
|
||
lay('.right-date-box').each(function(){
|
||
layui.laydate.render({
|
||
elem: this
|
||
,type:"datetime"
|
||
,trigger: 'click'
|
||
,done: function(value, date, endDate){
|
||
data['filts'][render_date_index]['strftv'] = value;
|
||
var datearr = [];
|
||
datearr.push(value)
|
||
data['filts'][render_date_index]['ftv'] = datearr;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
$(document).off('click','.screen-con-bg .left-type').on('click','.screen-con-bg .left-type',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
//点击按钮,数据,向左偏移,向右偏移
|
||
X.querycriteriapop(load_filter_props,'category',offset.left,offset.top+obj.height(),function(val){
|
||
obj.html(val.title);
|
||
data['filts'][index]['columnDesc'] = val.title;
|
||
data['filts'][index]['columnName'] = val.id;
|
||
data['filts'][index]['data_type'] = val.type;
|
||
data['filts'][index]['tableType'] = val.table_type;
|
||
X.laytpldata("#screen-con-box-dot",data['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
});
|
||
});
|
||
|
||
//下拉选项触发事件
|
||
$(document).off('click','.screen-content-sel').on('click','.screen-content-sel',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
var type =obj.attr('data-type');
|
||
|
||
X.parametersopen(filter_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
// console.log(val);
|
||
obj.html(val.title);
|
||
data['filts'][index]['comparator_name'] = val.title;
|
||
data['filts'][index]['comparator'] = val.id;
|
||
if(val.id == "range"){
|
||
data['filts'][index]['ftv'] = [-1,1];
|
||
}
|
||
X.laytpldata("#screen-con-box-dot",data['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
});
|
||
|
||
$(document).off("click",'.right-box').on("click",'.right-box',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
var comparator = obj.attr("data-comparator");//选择多选时才能多选
|
||
var offset = obj.offset();
|
||
var columnName = data['filts'][index]['columnName'];
|
||
X.api("data_mana/select_attr","post",{attr_name:columnName},function(val){
|
||
var darr = {
|
||
comparator:comparator,
|
||
data: val['map_']
|
||
}
|
||
if(val != "查无数据"){
|
||
X.parametersopen(darr,'dropdownlist3',[offset.top+obj.height(),offset.left],function(val){
|
||
if(comparator == "in"){
|
||
if(data['filts'][index]['strftv'] == "" ){
|
||
var strftv = val.title;
|
||
var ftv = val.id;
|
||
}else {
|
||
var strftv = val.title;
|
||
var ftv = val.id;
|
||
}
|
||
data['filts'][index]['strftv'] = strftv;
|
||
console.log(ftv);
|
||
var valarr = ftv.split(",");
|
||
data['filts'][index]['ftv']=valarr;
|
||
|
||
}else {
|
||
data['filts'][index]['strftv'] = val.title;
|
||
var arr = [];
|
||
arr.push(val.id);
|
||
data['filts'][index]['ftv'] = arr;
|
||
}
|
||
|
||
X.laytpldata("#screen-con-box-dot",data['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
})
|
||
}
|
||
})
|
||
// console.log(data['filts'][index]['columnName'])
|
||
});
|
||
|
||
//文本框条件输入触发事件
|
||
$(document).off('click','.screen-right-txt').on('change','.screen-right-txt',function(){
|
||
var index = $(this).attr('data-index');
|
||
var val = $(this).val();
|
||
var valarr = val.split(",");
|
||
data['filts'][index]['ftv']=valarr;
|
||
data['filts'][index]['strftv']=val;
|
||
});
|
||
|
||
//删除按钮
|
||
$(document).off('click','.screen-con-bg .screen-del').on('click','.screen-con-bg .screen-del',function(){
|
||
var index = $(this).attr('data-index');
|
||
if(data['filts'].length > 1){
|
||
data['filts'].splice(index, 1);
|
||
X.laytpldata("#screen-con-box-dot",data['filts'],".screen-con-box",function(){
|
||
renderdate();
|
||
});
|
||
if(data['filts'].length < 2){
|
||
$(".screen-left-qei").hide();
|
||
}
|
||
}else {
|
||
layer.closeAll();
|
||
$(".screen-left-qei").hide();
|
||
}
|
||
});
|
||
|
||
// 计算按钮
|
||
$(document).off('click','.screen-right-box .jisuan').on('click','.screen-right-box .jisuan',function(){
|
||
console.log(data);
|
||
// 刷新看板里的数据暂时没有
|
||
me.callback && me.callback(data);
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/search.js
|
||
//cc
|
||
(function(){
|
||
X.pageLogic['search'] = {
|
||
init : function(){
|
||
$(".search_pop .zhanghu_box").click(function(){
|
||
var obj = $(".search_pop .zhanghu_box");
|
||
var offset = obj.offset();
|
||
|
||
//点击按钮,数据,向左偏移,向右偏移
|
||
X.querycriteriapop(X.DATA.search,'category',offset.left,offset.top+obj.height(),function(val){
|
||
|
||
$(".search_top .zhanghu_box span").html(val.title);
|
||
$(".search_top .zhanghu_box span").attr('data-id',val.id);
|
||
$(".search_top .zhanghu_box span").attr('data-type',val.type);
|
||
var judgeid = $(".search_left .judge_box").val();
|
||
if(val.type == 'time'){
|
||
//type为time是隐藏文本框,显示时间选择框
|
||
$(".search_left .judge_box").hide();
|
||
$(".search_left .search_txt").hide();
|
||
$(".search_left .time-box").show();
|
||
}else {
|
||
$(".search_left .judge_box").show();
|
||
if(judgeid == 4 || judgeid == 5 ){ //当judfeid 等于4和5时隐藏文本框,只显示下拉框
|
||
$(".search_left .search_txt").hide();
|
||
}else{
|
||
$(".search_left .search_txt").show();
|
||
}
|
||
$(".search_left .time-box").hide();
|
||
}
|
||
|
||
});
|
||
});
|
||
// 渲染条件框数据
|
||
X.laytpldata("#judge-box-dot",X.DATA.search['condition'],'.judge_box');
|
||
//渲染日期选择器
|
||
X.daterender(".timechoice");
|
||
|
||
// 下拉选项改变事件
|
||
$(".search_left .judge_box").change(function(){
|
||
var judgeid = $(this).val();
|
||
if(judgeid == 4 || judgeid == 5){
|
||
$('.search_left .search_txt').hide();
|
||
}else {
|
||
$('.search_left .search_txt').show();
|
||
}
|
||
});
|
||
|
||
// 搜索按钮单击事件
|
||
$(".search_top .searcg_but").click(function(){
|
||
var typeid = $(".search_top .zhanghu_box span").attr('data-id');//属性id
|
||
var type = $(".search_top .zhanghu_box span").attr('data-type');//属性id
|
||
var condition = $(".search_left .judge_box").val(); //条件
|
||
var details = $(".search_left .search_txt").val();//详情
|
||
var time = $(".search_left .time-box .timechoice").val();//时间
|
||
var timearr = time.split('-');
|
||
var startdate = timearr[0]+ "-" + timearr[1] +"-"+ timearr[2];
|
||
var enddate= timearr[3]+ "-" + timearr[4] +"-"+ timearr[5];
|
||
|
||
var start = new Date(startdate);
|
||
var starttime = Date.parse(start)/1000;
|
||
|
||
var end = new Date(enddate);
|
||
var endtime = Date.parse(end)/1000;
|
||
var data;
|
||
//当type为time时不用传condition,details,当condition为5或4时不用传details
|
||
if( type != "time" ){
|
||
if(condition == 4 || condition == 5){
|
||
data = {
|
||
typeid: typeid,
|
||
condition:condition
|
||
}
|
||
}else {
|
||
data = {
|
||
typeid: typeid,
|
||
condition:condition,
|
||
details:details
|
||
}
|
||
}
|
||
}else {
|
||
data = {
|
||
typeid: typeid,
|
||
starttime: starttime,
|
||
endtime:endtime
|
||
}
|
||
}
|
||
X.api('api/userquery',data,function (d){
|
||
X.laytpldata("#search-data-dot",d.datalist,".search_pop .search_data");
|
||
$(".more_data span").html(d.totalNum);
|
||
$(".search_pop .more_data-box").show();
|
||
});
|
||
})
|
||
},
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/setgrouping.js
|
||
(function(){
|
||
X.pageLogic['setgrouping'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
|
||
X.laytpldata("#judge-box-dot",data,".setgrouping-box .setgrouping-content-box");
|
||
|
||
// 搜索
|
||
$('.setgrouping-sousuo-txt-box input').bind('input propertychange', function() {
|
||
var value = $(this).val();
|
||
if(value != ""){
|
||
$(".setgrouping-sousuo-txt-box img").show();
|
||
var filteringdata = [];
|
||
for(let i in data){
|
||
var detailsdata = [];
|
||
for(let j in data[i]["category"]){
|
||
if(data[i]["category"][j]['event_desc'].indexOf(value) != -1){
|
||
detailsdata.push(data[i]["category"][j]);
|
||
}
|
||
}
|
||
if(detailsdata.length >0){
|
||
var arr = {
|
||
"title": data[i]['title'],
|
||
"id":data[i]['id'],
|
||
"category": detailsdata
|
||
};
|
||
filteringdata.push(arr);
|
||
}
|
||
}
|
||
X.laytpldata("#judge-box-dot",filteringdata,".setgrouping-box .setgrouping-content-box");
|
||
}else {
|
||
$(".setgrouping-sousuo-txt-box img").hide();
|
||
X.laytpldata("#judge-box-dot",data,".setgrouping-box .setgrouping-content-box");
|
||
}
|
||
})
|
||
|
||
//清空按钮
|
||
$(".setgrouping-sousuo-txt-box img").click(function(){
|
||
$(".setgrouping-sousuo-txt-box input").val("");
|
||
$(".setgrouping-sousuo-txt-box img").hide();
|
||
X.laytpldata("#judge-box-dot",data,".setgrouping-box .setgrouping-content-box");
|
||
})
|
||
|
||
$(document).off('click','.setgrouping-content-list').on('click','.setgrouping-content-list',function(){
|
||
var index = $(this).attr('data-index');
|
||
var indexs = $(this).attr('data-indexs');
|
||
var valdata = {
|
||
'name':$(this).attr('data-name'),
|
||
'id':$(this).attr('data-id'),
|
||
'event_attr':data[index]['category'][indexs].event_attr,
|
||
'event_filter':data[index]['category'][indexs].event_filter
|
||
}
|
||
me.callback && me.callback(valdata);
|
||
|
||
layer.close( me.parms.layIndex );//获取最新的弹窗关闭
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/setupbaobiao.js
|
||
(function(){
|
||
X.pageLogic['setupbaobiao'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var data = parms.extData;
|
||
// console.log('luo',data);
|
||
var report_id = [];
|
||
report_id.push(data.id);
|
||
var postdata;//上传数据
|
||
X.api('report/read_report','post',{project_id:X.DATA.projectid,report_id:report_id},function(d){
|
||
postdata = d;
|
||
$('.setupbaobiao-title').val(d[0]['name']);
|
||
$('.setupbaobiao-textarea').val(d[0]['desc']);
|
||
// 初始化时间
|
||
if(endTime && startTime){
|
||
var endTime = d[0]['query']['eventView']['endTime'];
|
||
var startTime = d[0]['query']['eventView']['startTime'];
|
||
}else {
|
||
$(".setupbaobiao-date-box").hide();
|
||
}
|
||
|
||
$(".setupbaobiao-time").html(startTime +' - '+ endTime);
|
||
if(data.modeltype == "table"){ //初始化图表类型
|
||
$("#setupbaobiao-table").addClass("icon___XxbtJ");
|
||
}else {
|
||
$("#setupbaobiao-echarts").addClass("icon___XxbtJ");
|
||
}
|
||
//初始化窗体大小
|
||
if(data.modelsize == 'in'){ //中图
|
||
$("#setupbaobiao-in").prop("checked",true);
|
||
}else if( data.modelsize == 'small' ){//小图
|
||
$("#setupbaobiao-small").prop("checked",true);
|
||
}else{//大图
|
||
$("#setupbaobiao-large").prop("checked",true);
|
||
}
|
||
//初始化xy轴切换
|
||
if(data.modelswitch && data.modelswitch != "undefined" && data.modelswitch == "true"){
|
||
$("#kxyswitch").prop("checked",true);
|
||
}else {
|
||
$("#gxyswitch").prop("checked",true);
|
||
}
|
||
//初始化倒序
|
||
if(data.ascending && data.ascending != undefined && data.ascending == "true"){
|
||
$("#kqreverseorder").prop("checked",true);
|
||
}else {
|
||
$("#gbreverseorder").prop("checked",true);
|
||
}
|
||
// 初始化首行浮动
|
||
if(data.reverseorder && data.reverseorder != undefined && data.reverseorder == "true"){
|
||
$('#kqfirstlinefloat').prop('checked',true);
|
||
}else {
|
||
$('#gbfirstlinefloat').prop('checked',true);
|
||
}
|
||
if(data.daydata && data.daydata != undefined && data.daydata == "false"){
|
||
$('#daydatafalse').prop('checked',true);
|
||
}else {
|
||
$('#daydatatrue').prop('checked',true);
|
||
}
|
||
if(data.avesumdata && data.avesumdata != undefined && data.avesumdata == "false"){
|
||
$('#avesumdatafalse').prop('checked',true);
|
||
}else {
|
||
$('#avesumdatatrue').prop('checked',true);
|
||
}
|
||
|
||
X.laytpldata("#setupbaobiao-select-dot",X['DATA']['companylist'][d[0]['cat']],".setupbaobiao-select");
|
||
});
|
||
|
||
X.daterender(".setupbaobiao-rli-box2",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
postdata[0]['query']['eventView']['startTime'] = startTime;
|
||
postdata[0]['query']['eventView']['endTime'] = endTime;
|
||
$(".setupbaobiao-time").html(startTime +' - '+ endTime);
|
||
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
postdata[0]['query']['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
postdata[0]['query']['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
});
|
||
|
||
// 分析时间粒度
|
||
$(document).off('click','.setupbaobiao-select').on('change','.setupbaobiao-select',function(){
|
||
postdata[0]['query']['eventView']['timeParticleSize'] = $(this).val();
|
||
});
|
||
|
||
$(document).off('click','.shape___2nUUi').on('click','.shape___2nUUi',function(){
|
||
if(data.cat != 'ltv'){
|
||
$('.shape___2nUUi').removeClass('icon___XxbtJ');
|
||
$(this).addClass('icon___XxbtJ');
|
||
}else {
|
||
layer.msg('该模型不能修改图表类型');
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.setupbaobiao-xq').on('click','.setupbaobiao-xq',function(){
|
||
layer.closeAll();
|
||
});
|
||
|
||
$(document).off('click','.setupbaobiao-yy').on('click','.setupbaobiao-yy',function(){
|
||
var title = $('.setupbaobiao-title').val();
|
||
var desc = $(".setupbaobiao-textarea").val();
|
||
var modeltype = $(".icon___XxbtJ").attr('data-type');
|
||
var modelsize = $('input:radio[name="modelsize"]:checked').val();
|
||
var modelswitch = $('input:radio[name="xyswitch"]:checked').val();
|
||
var ascending = $('input:radio[name="reverseorder"]:checked').val();
|
||
var avesumdata = $('input:radio[name="avesumdata"]:checked').val();
|
||
var daydata = $('input:radio[name="daydata"]:checked').val();
|
||
var reverseorder = $('input:radio[name="firstlinefloat"]:checked').val();
|
||
if(modelswitch == "true"){ modelswitch = true;}else {modelswitch = false;};
|
||
if(ascending == 'true'){ ascending = true }else { ascending = false };
|
||
if(avesumdata == "true"){ avesumdata = true;}else {avesumdata = false;};
|
||
if(daydata == 'true'){ daydata = true }else { daydata = false };
|
||
if(reverseorder == 'true'){ reverseorder = true } else { reverseorder = false };
|
||
var arr = {
|
||
_id:X.DATA.dashboard_id,
|
||
report:{
|
||
name: title,
|
||
report_id:postdata[0]['_id'],
|
||
desc:desc,
|
||
model:postdata[0]['cat'],
|
||
graph_type:modeltype,
|
||
graph_size:modelsize,
|
||
modelswitch: modelswitch,
|
||
ascending:ascending,
|
||
avesumdata:avesumdata,
|
||
daydata:daydata,
|
||
reverseorder:reverseorder
|
||
}
|
||
}
|
||
// console.log(arr);
|
||
X.api('dashboard/edit_report','post',arr,function(d){
|
||
// console.log(d);
|
||
var reportedit = {
|
||
name: title,
|
||
desc:desc,
|
||
query:postdata[0]['query'],
|
||
report_id:postdata[0]['_id']
|
||
}
|
||
X.api('report/edit','post',reportedit,function(d){
|
||
|
||
var ascending = data.ascending ==="false" ? false : true;
|
||
var avesumdata = data.avesumdata === "false" ? false : true;
|
||
var daydata = data.daydata === "false" ? false : true;
|
||
var modelswitch = data.modelswitch === "false" ? false : true;
|
||
var reverseorder = data.reverseorder === "false" ? false : true;
|
||
|
||
var updatatype='操作'+postdata[0]['name'];
|
||
if(postdata[0]['name'] != title){
|
||
updatatype+=",修改 报表名称"
|
||
}
|
||
if(postdata[0]['desc'] != desc){
|
||
// updatatype 操作 基础数据报表
|
||
updatatype+=",修改 备注"
|
||
}
|
||
if(ascending != arr['report']['ascending']){
|
||
// 倒序
|
||
updatatype+=",修改 倒序"
|
||
}
|
||
if(avesumdata != arr['report']['avesumdata']){
|
||
//平均总和
|
||
updatatype+=",修改 平均总和展示"
|
||
}
|
||
if(daydata != arr['report']['daydata']){0
|
||
// 当天数据
|
||
updatatype+=",修改 当天数据展示"
|
||
}
|
||
if(data.modelsize != arr['report']['graph_size']){
|
||
// 窗体大小
|
||
updatatype+=",修改 窗体大小"
|
||
}
|
||
if(modelswitch != arr['report']['modelswitch']){
|
||
// xy轴切换
|
||
updatatype+=",修改 xy轴切换"
|
||
}
|
||
if(data.modeltype != arr['report']['graph_type']){
|
||
// 图表类型
|
||
updatatype+=",修改 图表类型"
|
||
}
|
||
if(reverseorder != arr['report']['reverseorder']){
|
||
// 首行浮动
|
||
updatatype+=",修改 首行浮动"
|
||
}
|
||
if(updatatype){
|
||
|
||
}
|
||
// console.log(updatatype);
|
||
// X.submitrecord()
|
||
// console.log(data);
|
||
// console.log(arr);
|
||
me.callback && me.callback(d);
|
||
layer.closeAll();
|
||
|
||
})
|
||
})
|
||
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/sqlquery.js
|
||
(function(){
|
||
X.pageLogic['sqlquery'] = {
|
||
init : function(){
|
||
$(document).off('click','.sqlquery-but').on('click','.sqlquery-but',function(){
|
||
var txt = $('.sql-textarea').val();
|
||
|
||
// console.log(EncodeURIFilter(txt));
|
||
|
||
X.api("ck/sql","post",{"sql": txt},function(d){
|
||
console.log(JSON.stringify(d));
|
||
$('.table-sql-box-con').html(JSON.stringify(d));
|
||
})
|
||
|
||
|
||
});
|
||
|
||
$(document).off('click','.sqlquery-daochu').on('click','.sqlquery-daochu',function(){
|
||
var txt = $('.sql-textarea').val();
|
||
|
||
X.download('ck/sql_export',{"sql": txt},'sql');
|
||
|
||
|
||
});
|
||
|
||
// function EncodeURIFilter(str) {
|
||
// if(str != null && str != "") {
|
||
// str = str.replace(/\+/g, "%2B");
|
||
// str = str.replace(/\&/g, "%26");
|
||
// }
|
||
// return str;
|
||
// }
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/timeadmin.js
|
||
(function(){
|
||
X.pageLogic['timeadmin'] = {
|
||
init : function(){
|
||
var tagData = [{"id":12,"name":"12"},{"id":13,"name":"13"},{"id":14,"name":"14"},
|
||
{"id":15,"name":"15"},{"id":16,"name":"16"},{"id":17,"name":"17"},{"id":18,"name":"18"},
|
||
{"id":12,"name":"12"},{"id":13,"name":"13"},{"id":14,"name":"14"},{"id":15,"name":"15"},
|
||
{"id":16,"name":"16"},{"id":17,"name":"17"},{"id":18,"name":"18"}];
|
||
|
||
var timedata = layui.selectM({
|
||
//元素容器【必填】
|
||
elem: "#timeadmin-shiqu"
|
||
//候选数据【必填】
|
||
,data: tagData
|
||
,width: 42
|
||
,max: 100
|
||
//添加验证
|
||
,verify:'required'
|
||
});
|
||
timedata.set([12,13]); //给以选中时区赋值
|
||
$(document).on("click",".timeadmin-but-box .timeadmin-qd",function(){
|
||
console.log(timedata.values);
|
||
|
||
})
|
||
|
||
$(document).on("click",".timeadmin-but-box .timeadmin-qx",function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/toptab.js
|
||
(function(){
|
||
X.pageLogic['toptab'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
var data;
|
||
if(parms){
|
||
this.parms = parms;
|
||
data = parms;
|
||
}else {
|
||
X.api("project/","get",{},function(d){
|
||
data = d;
|
||
X.DATA['projectarr'] = d;
|
||
X.DATA['projectid'] = d[0]["_id"];
|
||
X.DATA["game"] = d[0]["game"];
|
||
});
|
||
}
|
||
console.log(data);
|
||
// 选择项目
|
||
|
||
X.laytpldata("#toptab-dot",data,"#analysis-zhanwei");
|
||
|
||
$(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;
|
||
//侧边栏数据渲染
|
||
X.pageLogic.dashboard.freshMenu(id);
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/updatapassword.js
|
||
(function(){
|
||
X.pageLogic['updatapassword'] = {
|
||
init : function(){
|
||
|
||
$(document).on("click",'.updatapassword-top-box',function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(document).on("click",".updatapassword-qx",function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(document).on("click",".updatapassword-qd",function(){
|
||
var data = layui.form.val('updatapasswordexample');
|
||
if(data.newpassword != data.reppassword){
|
||
layer.msg('两次密码不一致');
|
||
return;
|
||
}
|
||
X.api('user/reset_my_password',"post",{password:data.newpassword},function(d){
|
||
layer.closeAll();
|
||
layer.msg('修改成功');
|
||
})
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/updatepas.js
|
||
(function(){
|
||
X.pageLogic['updatepas'] = {
|
||
init : function(parms){
|
||
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
|
||
$(".updatepas-but-box .updatepas-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".updatepas-top-box img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".updatepas-but-box .updatepas-qd").click(function(){
|
||
var fromdata = layui.form.val("updatepasexample");
|
||
var password = fromdata['password'];
|
||
var password2 = fromdata['password2'];
|
||
if(password != password2){
|
||
layer.msg("密码不一致!!!");
|
||
return;
|
||
}
|
||
X.api('user/reset_password',"post",{username: data.name,password:password2},function(d){
|
||
layer.msg('修改成功');
|
||
me.callback && me.callback(d);
|
||
layer.closeAll();
|
||
})
|
||
})
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/useradmin.js
|
||
(function(){
|
||
X.pageLogic['useradmin'] = {
|
||
init : function(){
|
||
var me = this;
|
||
$(document).on("click",".useradmin-top-box .useradmin-tab-box .useradmin-tab",function(){
|
||
$(".useradmin-top-box .useradmin-tab-box .useradmin-tab").removeClass('useradmin-tab-click');
|
||
$(this).addClass("useradmin-tab-click");
|
||
var htmlval = $(this).html();
|
||
if(htmlval.length == 17){
|
||
$(".useradmin-btn").show();
|
||
$(".useradmin-info").show();
|
||
$(".useradmin-group").hide();
|
||
|
||
}else {
|
||
$(".useradmin-btn").hide();
|
||
$(".useradmin-info").hide();
|
||
$(".useradmin-group").show();
|
||
|
||
}
|
||
})
|
||
|
||
$(".useradmin-ss-box input").focus(function(){
|
||
$(".useradmin-ss-box").css("border",'1px solid #4fa1ff');
|
||
$(".useradmin-ss-box").css("box-shadow",'0 0 4px rgba(61,144,255,0.45)');
|
||
});
|
||
|
||
$(".useradmin-ss-box input").blur(function(){
|
||
$(".useradmin-ss-box").css("border",'1px solid #f0f0f0');
|
||
$(".useradmin-ss-box").css("box-shadow",'none');
|
||
});
|
||
|
||
me.useradmin();
|
||
|
||
$(".useradmin-info").click(function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'adduser'
|
||
})
|
||
})
|
||
|
||
$(".addexistuser").click(function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'addexistuser'
|
||
})
|
||
})
|
||
|
||
$(".importuser").click(function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'importuser'
|
||
})
|
||
})
|
||
|
||
$(".useradmin-group").click(function(){
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'addusergroup'
|
||
})
|
||
})
|
||
|
||
layui.table.on('tool(test)', function(obj){
|
||
var data = obj.data;
|
||
console.log(obj);
|
||
if(obj.event === "edit"){
|
||
// 编辑
|
||
X.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
shadeClose: true,
|
||
skin: 'yourclass',
|
||
url: 'useradminedit'
|
||
})
|
||
}else if(obj.event == "password"){
|
||
//重置密码
|
||
X.parametersopen(data,"updatepas",'auto',function(){
|
||
me.useradmin()
|
||
})
|
||
}else if(obj.event == "del"){
|
||
// 删除
|
||
// X.parametersopen(data,"deluserinfo",'auto',function(){
|
||
// me.useradmin()
|
||
// })
|
||
|
||
layer.confirm('确认删除吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("authz/del_role_user_domain",'post',{username:data.name,role_id:data.role_id,game:X.DATA['game']},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
me.useradmin();
|
||
// X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
// me.updata(X.DATA.projectid);//刷新数据
|
||
})
|
||
});
|
||
}
|
||
})
|
||
|
||
},
|
||
useradmin : function(id){
|
||
X.tabledata('#userdata','project/members',[[
|
||
{field:'name', width:180, title: '成员账号', sort: true}
|
||
,{field:'nickname', width:180, title: '成员显示名'}
|
||
,{field:'role', width:180, title: '项目角色', sort: true}
|
||
,{field:'data_auth', width:180, title: '数据权限'}
|
||
,{field:'sign', title: '所属成员组', width: 180}
|
||
,{field:'last_login_ts', title: '最后访问时间', sort: true}
|
||
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:80}
|
||
]]);
|
||
|
||
}
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/useradminedit.js
|
||
(function(){
|
||
X.pageLogic['useradminedit'] = {
|
||
init : function(){
|
||
var data = {
|
||
"authDataPowers":[
|
||
{
|
||
title: '全部事件'
|
||
,id: -1
|
||
}
|
||
],
|
||
"authRoles":[
|
||
{
|
||
title:"管理员",
|
||
id:0
|
||
},
|
||
{
|
||
title:"分析师",
|
||
id:1
|
||
},
|
||
{
|
||
title:"普通成员",
|
||
id:2
|
||
},
|
||
]
|
||
}
|
||
X.laytpldata("#useradminedit-js-dot",data["authRoles"],".useradminedit-js");
|
||
X.laytpldata("#useradminedit-sjqx-dot",data["authDataPowers"],".useradminedit-sjqx");
|
||
layui.form.render();
|
||
|
||
$(".useradminedit-top-box img").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".useradminedit-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".useradminedit-qd").click(function(){
|
||
var data = layui.form.val('example');
|
||
|
||
layer.closeAll();
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/userattradmin.js
|
||
(function(){
|
||
X.pageLogic['userattradmin'] = {
|
||
init : function(){
|
||
var me = this;
|
||
me.userattradminlist();
|
||
layui.table.on('tool(userattradmintest)', function(obj){
|
||
var data = obj.data;
|
||
if(obj.event === 'edit'){
|
||
data['cat'] = 'user'
|
||
X.parametersopen(data,"eventattradminedit",'auto',function(){
|
||
me.userattradminlist();
|
||
})
|
||
}
|
||
});
|
||
|
||
$(document).off('click','.adduserattradmin').on('click','.adduserattradmin',function(){
|
||
X.parametersopen('user',"addeventattradmin",'auto',function(){
|
||
me.userattradminlist();
|
||
})
|
||
|
||
});
|
||
|
||
},
|
||
userattradminlist : function(){
|
||
X.laytabledata("#userattradmin-table","data_mana/attr_list",[[
|
||
{field:'name', title: '属性名', sort: true}
|
||
,{field:'show_name', title: '显示名'}
|
||
,{field:'data_type', title: '数据类型', sort: true,templet:function(d){
|
||
if(d.data_type == "string"){
|
||
return '文本'
|
||
}else if(d.data_type == "ip"){
|
||
return 'ip'
|
||
}else if(d.data_type == "int"){
|
||
return '数值'
|
||
}else if(d.data_type == "float"){
|
||
return '浮点型'
|
||
}else if(d.data_type == "datetime"){
|
||
return '时间'
|
||
}else if(d.data_type == "array"){
|
||
return '数组'
|
||
}
|
||
}}
|
||
,{field:'city', title: '单位'}
|
||
,{field:'is_show', title: '显示状态', minWidth: 100,templet:function(d){
|
||
if(d.is_show){
|
||
return '显示'
|
||
}else {
|
||
return '<span style="color: #acbad0">隐藏</span>'
|
||
}
|
||
}}
|
||
,{field:'attr_type', title: '属性类型', sort: true}
|
||
,{field:'score', title: '维度表', sort: true}
|
||
,{fixed: 'right', title:'操作', toolbar: '#userattradminbarDemo', width:80}
|
||
]]
|
||
,"&cat=user");
|
||
}
|
||
|
||
|
||
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/usergroup.js
|
||
(function(){
|
||
X.pageLogic['usergroup'] = {
|
||
init : function(parms){
|
||
|
||
var fixedTable = new FixedTable({
|
||
wrap: document.getElementById("eventattradmin-table"),//生成的表格需要放到哪里
|
||
type: "row-col-fixed",//表格类型,有:head-fixed、col-fixed、row-col-fixed
|
||
extraClass: "",//需要添加到表格中的额外class
|
||
maxHeight: true,
|
||
fields: [//表格的列
|
||
{
|
||
width: "100px",
|
||
field: "日期",
|
||
fixed: true,
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "姓名",
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "省份",
|
||
//fixed: true,
|
||
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "市区"
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "地址",
|
||
// fixed: true,
|
||
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "邮编",
|
||
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "邮编",
|
||
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "邮编",
|
||
|
||
},
|
||
{
|
||
width: "100px",
|
||
field: "邮编",
|
||
|
||
}
|
||
],
|
||
tableDefaultContent: "<div>我是一个默认的div</div>"
|
||
});
|
||
|
||
fixedTable.addRow(function (){
|
||
var dataarr = [
|
||
['2016-05-03','王小虎','上海','普陀区','上海市普','200333','200333','200333','200333'],
|
||
['2016-05-03','王小虎','上海','普陀区','上海市普','200333','200333','200333','200333'],
|
||
['2016-05-03','王小虎','上海','普陀区','上海市普','200333','200333','200333','200333'],
|
||
]
|
||
var html = '';
|
||
for(let i in dataarr){
|
||
html += '<tr>';
|
||
for(let j in dataarr[i]){
|
||
html += ' <td class="ws-100"><div class="table-cell">'+ dataarr[i][j] +'</div></td>';
|
||
}
|
||
html += '</tr>';
|
||
}
|
||
return html;
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/userlabel.js
|
||
(function(){
|
||
X.pageLogic['userlabel'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
me.userlabellist();
|
||
$(document).off('click','.lable-dingyi').on('click','.lable-dingyi',function(){
|
||
X.gourl('userlabel_dy','conetnt');
|
||
});
|
||
|
||
$(document).off('click','.addlabeldata').on('click','.addlabeldata',function(){
|
||
X.DATA.userlabelid = "";
|
||
X.gourl('userlabel_dy','conetnt');
|
||
});
|
||
|
||
$(document).off('click','.lable-del').on('click','.lable-del',function(){
|
||
var _id = X.DATA.userlabelid;
|
||
layer.confirm('确认删除选中的标签吗?该操作不可恢复', {
|
||
btn: ['取消','删除 '] //按钮
|
||
}, function(){
|
||
//取消
|
||
layer.close(layer.index);
|
||
}, function(){
|
||
//删除
|
||
X.api("user_label/del",'post',{label_id: _id},function(d){
|
||
layer.msg('删除成功');
|
||
layer.close(layer.index);
|
||
me.userlabellist();
|
||
})
|
||
});
|
||
});
|
||
|
||
// 标签详情
|
||
$(document).off('click','.label-info-box').on('click','.label-info-box',function(){
|
||
X.gourl('userlabelinfo','conetnt');
|
||
});
|
||
|
||
// 监听单行事件
|
||
layui.table.on('row(userlabeltest)',function(obj){
|
||
var data = obj.data
|
||
// console.log(data);
|
||
X.DATA.userlabelid = data._id;
|
||
|
||
X.api("user_label/cluster_user_count","post",{cluster_name:data.cluster_name},function(d){
|
||
data['num'] = d.num;
|
||
// console.log(d);
|
||
X.laytpldata('#userlabel-right-box-dot',data,'.userlabel-right-box');
|
||
})
|
||
|
||
});
|
||
|
||
|
||
},
|
||
userlabellist : function(){
|
||
X.laytabledata("#userlabel-table","user_label/list",[[
|
||
{field:'cluster_name', title: '标签名', sort: true}
|
||
,{field:'display_name', title: '显示名'}
|
||
,{field:'act_name', title: '最后操作人'}
|
||
,{field:'cluster_type', title: '创建方式',templet:function(d){
|
||
if(d.cluster_type == "user_custom"){
|
||
return '自定义条件'
|
||
}else{
|
||
return '其他条件'
|
||
}
|
||
}}
|
||
// ,{fixed: 'right', title:'操作', toolbar: '#eventattradminbarDemo', width:80}
|
||
]],"",'auto',function(res, curr, count){
|
||
// console.log(res);
|
||
if(res.data.length > 0){
|
||
X.DATA.userlabelid = res.data[0]._id;
|
||
X.api("user_label/cluster_user_count","post",{cluster_name:res.data[0].cluster_name},function(d){
|
||
res.data[0]['num'] = d.num;
|
||
X.laytpldata('#userlabel-right-box-dot',res.data[0],'.userlabel-right-box');
|
||
})
|
||
}
|
||
});
|
||
}
|
||
};
|
||
})();
|
||
|
||
// srczip/logic/userlabel_dy.js
|
||
(function(){
|
||
X.pageLogic['userlabel_dy'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
var _id = X.DATA.userlabelid;
|
||
|
||
var data;
|
||
if(_id && _id != ""){
|
||
X.api("user_label/detail","post",{label_id: _id},function(d){
|
||
data = d;
|
||
$(".lablename").val(d.cluster_name);
|
||
$(".labledesc").val(d.display_name);
|
||
$(".labeldes").val(d.remarks);
|
||
updatalable();
|
||
})
|
||
}else {
|
||
data = {
|
||
"project_id": X.DATA.projectid,
|
||
"cluster_name": "",
|
||
"display_name": "",
|
||
"cluster_type":'user_custom',
|
||
"qp": {
|
||
"tagRemark": "",
|
||
"tagValue": "",
|
||
"user_cluster_def": {
|
||
'event_relation':'and',
|
||
"event_user_relation":"and",
|
||
"events": [
|
||
|
||
],
|
||
"filts": [],
|
||
"relation": "and"
|
||
},
|
||
},
|
||
"remarks": ""
|
||
};
|
||
}
|
||
|
||
|
||
// 标签值定义
|
||
var choicelabellist=[
|
||
{'title':'做过(没做过事件)',id:'0'},
|
||
{'title':'用户属性满足',id:'1'}
|
||
];
|
||
X.laydropdown('.choicelabel',choicelabellist,function(e){
|
||
console.log(e);
|
||
var arr = {};
|
||
if(e.id == 0){
|
||
arr= {
|
||
endTime: "",
|
||
eventDesc: dataArr[0]['category'][0].event_desc,
|
||
event_name: dataArr[0]['category'][0].event_name,
|
||
eventType: "event",
|
||
filts: [],
|
||
num: "",
|
||
e_days:0,
|
||
s_days:7,
|
||
relation: "and",
|
||
startTime: "",
|
||
uce_calcu_symbol: "==",
|
||
uce_calcu_symbolDesc: "等于",
|
||
prop_quota: {analysis: '', analysisDesc: '', quota: retdata[0]['id'], quotaDesc: retdata[0]["title"],quota_type: null},
|
||
is_touch: true,
|
||
}
|
||
data['qp']['user_cluster_def']['events'].push(arr);
|
||
}else {
|
||
arr = {
|
||
calcuSymbol: "C01",
|
||
columnDesc: "",
|
||
columnName: "lv",
|
||
columnType: "double",
|
||
filterType: "SIMPLE",
|
||
ftv: ["10"],
|
||
selectType: "number",
|
||
tableType: "1",
|
||
timeRelative: "",
|
||
timeUnit: ""
|
||
}
|
||
data['qp']['user_cluster_def']['filts'].push(arr);
|
||
}
|
||
|
||
updatalable();
|
||
});
|
||
|
||
$(document).off('click','.userlabel-dy-head-userlabel').on('click','.userlabel-dy-head-userlabel',function(){
|
||
X.gourl('userlabel','conetnt');
|
||
});
|
||
|
||
$(document).off("click",'.ta-isDone').on("click",'.ta-isDone',function(){
|
||
var index = $(this).attr("data-index");
|
||
data['qp']['user_cluster_def']['events'][index]['is_touch'] = !data['qp']['user_cluster_def']['events'][index]['is_touch'];
|
||
updatalable();
|
||
});
|
||
|
||
var dataArr = [],retdata = [],props=[],defaultgroupdata=[],filter_map=[],quotas_map=[];
|
||
|
||
X.api("data_auth/my_event","get",{},function(d){
|
||
|
||
dataArr = d;
|
||
X.api("data_auth/load_prop_quotas","post",{event_name:dataArr[0]['category'][0]['event_name']},function(d){
|
||
retdata = d.staid_quots.concat(d.props);
|
||
props = d.props;
|
||
|
||
X.api("data_auth/load_filter_props","post",{event_name:dataArr[0]['category'][0]['event_name']},function(val){
|
||
defaultgroupdata = val;
|
||
|
||
X.api("data_auth/filter_map","get",{},function(d){
|
||
filter_map = d;
|
||
|
||
X.api('data_auth/quotas_map',"get",{},function(d){
|
||
quotas_map = d;
|
||
|
||
})
|
||
|
||
})
|
||
|
||
})
|
||
})
|
||
});
|
||
|
||
$(document).off("click",'.my-event-data').on('click','.my-event-data',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
X.querycriteriapop(dataArr,'setgrouping',offset.left,offset.top+obj.height(),function(val){
|
||
console.log(val);
|
||
data['qp']['user_cluster_def']['events'][index]['eventDesc'] = val.id;
|
||
data['qp']['user_cluster_def']['events'][index]['event_name'] = val.name;
|
||
updatalable();
|
||
})
|
||
});
|
||
|
||
var label_time_index; //点击修改日期的index;
|
||
$(document).off('click','.time-days-box').on("click",'.time-days-box',function(){
|
||
var index = $(this).attr("data-index");
|
||
label_time_index = index;
|
||
});
|
||
|
||
function updatalable(){
|
||
X.laytpldata('#userlabel-json-box-dot',data['qp']['user_cluster_def'],'.userlabel-json-box');
|
||
|
||
X.daterender(".time-days-box",function(start, end, label){
|
||
var startTime = start.format('YYYY-MM-DD')+ " "+ "00:00:00";
|
||
var endTime = end.format('YYYY-MM-DD')+ " "+ "23:59:59";
|
||
data['qp']['user_cluster_def']['events'][label_time_index]['startTime'] = startTime;
|
||
data['qp']['user_cluster_def']['events'][label_time_index]['endTime'] = endTime;
|
||
var sameday = Date.parse(new Date()) / 1000; //当天时间戳
|
||
|
||
var enddate = new Date(end.format('YYYY-MM-DD'));
|
||
var endmonth = Date.parse(enddate)/1000;
|
||
|
||
var startdate = new Date(start.format('YYYY-MM-DD'));
|
||
var startmonth = Date.parse(startdate)/1000;
|
||
data['qp']['user_cluster_def']['events'][label_time_index]['e_days'] = parseInt((sameday - endmonth)/86400);
|
||
data['qp']['user_cluster_def']['events'][label_time_index]['s_days'] = parseInt((sameday - startmonth)/86400);
|
||
updatalable();
|
||
})
|
||
};
|
||
|
||
$(document).off("click",'.load_prop_quotas_data').on('click','.load_prop_quotas_data',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index')
|
||
X.parametersopen(retdata,'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
console.log(val);
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['quotaDesc'] = val.title;
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['quota_type'] = val.data_type;
|
||
if(val.data_type == null){
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['quota'] = val.analysis;
|
||
}else {
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['quota'] = val.id;
|
||
}
|
||
updatalable();
|
||
});
|
||
});
|
||
|
||
$(document).off("click",'.analysis-data-box').on('click','.analysis-data-box',function(){
|
||
var obj = $(this);
|
||
var offset = obj.offset();
|
||
var index = obj.attr('data-index');
|
||
var type = obj.attr('data-type');
|
||
X.parametersopen(quotas_map[type],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
console.log(val);
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['analysisDesc'] = val.title;
|
||
data['qp']['user_cluster_def']['events'][index]['prop_quota']['analysis'] = val.id;
|
||
updatalable();
|
||
})
|
||
});
|
||
|
||
$(document).off('click','.uce_calcu_symbol_box').on('click','.uce_calcu_symbol_box',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
var offset = obj.offset();
|
||
X.parametersopen(X['DATA']['search']['condition2'],'dropdownlist',[offset.top+obj.height(),offset.left],function(val){
|
||
console.log(val);
|
||
data['qp']['user_cluster_def']['events'][index]['uce_calcu_symbolDesc'] = val.title;
|
||
data['qp']['user_cluster_def']['events'][index]['uce_calcu_symbol'] = val.id;
|
||
updatalable();
|
||
})
|
||
});
|
||
|
||
$(document).off("change",'.lable-input-box input').on('change','.lable-input-box input',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
console.log(index);
|
||
var text = obj.val();
|
||
data['qp']['user_cluster_def']['events'][index]['num'] = text;
|
||
});
|
||
|
||
$(document).off('click','.action-icon-events-del').on('click','.action-icon-events-del',function(){
|
||
var obj = $(this);
|
||
var index = obj.attr("data-index");
|
||
data['qp']['user_cluster_def']['events'].splice(index,1);
|
||
updatalable();
|
||
});
|
||
|
||
$(document).off("click",'.userlabel-dy-baocun').on("click",".userlabel-dy-baocun",function(){
|
||
var lablename = $(".lablename").val();
|
||
var labledesc = $(".labledesc").val();
|
||
var labeldes = $(".labeldes").val();
|
||
if(lablename == ""){
|
||
layer.msg("请填写标签名");
|
||
return;
|
||
}
|
||
if(labledesc == ""){
|
||
layer.msg("请填写显示名");
|
||
return;
|
||
}
|
||
data['cluster_name'] = lablename;
|
||
data['display_name'] = labledesc;
|
||
data['remarks'] = labeldes;
|
||
X.api('user_label/save','post',data,function(d){
|
||
console.log(d);
|
||
layer.msg("添加成功");
|
||
})
|
||
});
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/userlabelinfo.js
|
||
(function(){
|
||
X.pageLogic['userlabelinfo'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
var userlabelid = X.DATA.userlabelid;
|
||
|
||
var page = 1; //设置首页页码
|
||
var limit = 10; //设置每页显示条数
|
||
var total; //总条数
|
||
|
||
X.api("user_label/detail","post",{label_id: userlabelid},function(val){
|
||
X.api("user_label/cluster_user_count","post",{cluster_name:val.cluster_name},function(d){
|
||
val['num'] = d.num;
|
||
total = d.num;
|
||
X.laytpldata('#userlabelinfo-right-box-dot',val,'.userlabel-right-box');
|
||
cluster_user_list_data(val);
|
||
|
||
layui.laypage.render({
|
||
elem: 'laypage' //注意,这里的 test1 是 ID,不用加 # 号
|
||
,count: total, //数据总数,从服务端得到
|
||
limit:limit, //每页条数设置
|
||
jump: function(obj, first){
|
||
//obj包含了当前分页的所有参数,比如:
|
||
// console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||
// console.log(obj.limit); //得到每页显示的条数
|
||
page=obj.curr; //改变当前页码
|
||
limit=obj.limit;
|
||
//首次不执行
|
||
if(!first){
|
||
cluster_user_list_data(val); //加载数据
|
||
}
|
||
}
|
||
});
|
||
})
|
||
});
|
||
|
||
function cluster_user_list_data(val){
|
||
X.api('user_label/cluster_user_list',"post",{cluster_name: val.cluster_name,page: page,limit: limit},function(d){
|
||
X.laytpldata("#table-fenxi-th-dot",d.columns,".table-fenxi-th");
|
||
X.laytpldata("#table-fenxi-td-dot",d.values ,".table-fenxi-td");
|
||
});
|
||
};
|
||
|
||
// 返回上一页
|
||
$(document).off("click",".userlabel-right-fanhui").on("click",".userlabel-right-fanhui",function(){
|
||
X.gourl('userlabel','conetnt');
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/userpar.js
|
||
(function(){
|
||
X.pageLogic['userpar'] = {
|
||
init : function(parms){
|
||
|
||
var me = this;
|
||
if(parms){
|
||
this.parms = parms;
|
||
var data = parms;
|
||
}else {
|
||
var data = []
|
||
}
|
||
console.log(data);
|
||
X.laytpldata("#userpar-overall-situation-list-box-dot",data[0],"#userpar-event");
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/usersbtx.js
|
||
(function(){
|
||
X.pageLogic['usersbtx'] = {
|
||
init : function(){
|
||
|
||
var data1 = [
|
||
{"value": "1", "title": "李白"}
|
||
,{"value": "2", "title": "杜甫"}
|
||
,{"value": "3", "title": "苏轼"}
|
||
,{"value": "4", "title": "李清照"}
|
||
,{"value": "5", "title": "鲁迅"}
|
||
,{"value": "6", "title": "巴金"}
|
||
,{"value": "7", "title": "冰心"}
|
||
,{"value": "8", "title": "矛盾"}
|
||
,{"value": "9", "title": "贤心"}
|
||
]
|
||
|
||
//渲染穿梭框
|
||
X.laytransfer("#lay-usersbtx",data1,['选择用户识别属性', '已添加属性'],"usersbtxinfo");
|
||
|
||
$(".usersbtx-qx").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".usersbtx-top-box").click(function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(".usersbtx-qd").click(function(){
|
||
var getData = layui.transfer.getData('usersbtxinfo');
|
||
layer.closeAll();
|
||
console.log(getData);
|
||
})
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/yidong-pop.js
|
||
(function(){
|
||
X.pageLogic['yidong-pop'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback; //选择后执行的回调
|
||
var data = parms.extData;//获取到上层弹窗传的数据
|
||
var comboTree1,comboTree2
|
||
comboTree1 = $('.yidong-txt-box .justAnotherInputBox1').comboTree({
|
||
source : X.DATA.KanBanData,
|
||
isMultiple: false
|
||
});
|
||
comboTree2 = $('.yidong-txt-box .justAnotherInputBox2').comboTree({
|
||
source : X.DATA.ProjectData,
|
||
isMultiple: false
|
||
});
|
||
|
||
//叉图标关闭弹窗
|
||
$(".yidong-top .yidong-cha").click(function(){
|
||
console.log(layer.index)
|
||
parent.layer.closeAll(layer.index);
|
||
});
|
||
//取消按钮
|
||
$(".yidong-but-box .yidong-qx").click(function(){
|
||
layer.closeAll(layer.index);
|
||
});
|
||
//我的看板,空间切换实践
|
||
$(".yidong-tab-box .yidong-tab div").click(function(){
|
||
$(".yidong-tab-box .yidong-tab div").removeClass('tabdata');
|
||
$(this).addClass('tabdata');
|
||
if($(this).html() == "我的看板"){
|
||
$(".yidong-txt-box .justAnotherInputBox1").show();
|
||
$(".yidong-txt-box .justAnotherInputBox2").hide();
|
||
}else {
|
||
$(".yidong-txt-box .justAnotherInputBox1").hide();
|
||
$(".yidong-txt-box .justAnotherInputBox2").show();
|
||
}
|
||
$(".yidong-txt-box .justAnotherInputBox1").val("");
|
||
$(".yidong-txt-box .justAnotherInputBox2").val("");
|
||
})
|
||
|
||
//确定按钮
|
||
$(".yidong-but-box .yidong-qd").click(function(){
|
||
var type ='kanban';
|
||
var id = '';//没有默认传看板
|
||
if($('#yidongjustAnotherInputBox2').val() != ""){
|
||
var Addlocation = $('#yidongjustAnotherInputBox2').val();
|
||
type = "space"
|
||
}else {
|
||
var Addlocation = $('#yidongjustAnotherInputBox1').val();
|
||
}
|
||
// console.log(Addlocation);
|
||
if(Addlocation){
|
||
id = X.pageLogic.newkanban.matchingid(Addlocation,type);
|
||
}else {
|
||
alert('请选择添加的位置');
|
||
return;
|
||
}
|
||
// var source_id = data['mykanban'].concat(data['kongjian']);
|
||
var dataArr = {
|
||
'source_ids':data,
|
||
'dest_pid': id,
|
||
'cat':type
|
||
};
|
||
console.log(dataArr);
|
||
X.api('dashboard/move','post',dataArr,function(d){
|
||
// if(d.code == "ok"){
|
||
X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
|
||
X.pageLogic.adminkanban.updata(X.DATA.projectid);//刷新数据
|
||
console.log(me.parms.layIndex);
|
||
layer.closeAll(0);
|
||
// }
|
||
})
|
||
});
|
||
|
||
|
||
}
|
||
};
|
||
})();
|
||
// srczip/logic/zidingyizhibiao.js
|
||
(function(){
|
||
X.pageLogic['zidingyizhibiao'] = {
|
||
init : function(parms){
|
||
var me = this;
|
||
this.parms = parms;
|
||
this.callback = parms.callback;
|
||
var datalist = [
|
||
{
|
||
title:'基础指标',
|
||
id:'basicindex',
|
||
checked: true,
|
||
list:[
|
||
{ title:'累计充值', checked:true,id:'cumulativerecharge'},
|
||
{ title:'活跃数', checked:true,id:'active'},
|
||
{ title:'付费数', checked:true,id:'paunum'},
|
||
{ title:'付费率', checked:true,id:'paurate'},
|
||
{ title:'付费arpu', checked:true,id:'pauarpu'},
|
||
{ title:'活跃arpu', checked:true,id:'activearpu'},
|
||
]
|
||
},{
|
||
title:'注册新增指标',
|
||
id:'registernew',
|
||
checked: false,
|
||
list:[
|
||
{ title:'新增', checked:true,id:'newadd'},
|
||
{ title:'新增付费金额', checked:true,id:'newaddmoney'},
|
||
{ title:'新增付费数', checked:true,id:'newaddnum'},
|
||
{ title:'新增付费率', checked:true,id:'newaddrate'},
|
||
{ title:'新增付费arpu', checked:true,id:'newaddpayarpu'},
|
||
{ title:'新增arpu', checked:false,id:'newaddaru'},
|
||
]
|
||
},{
|
||
title:'留存指标',
|
||
id:'retained',
|
||
checked: false,
|
||
list:[
|
||
{ title:'1日留存', checked:false,id:'retained1'},
|
||
{ title:'2日留存', checked:false,id:'retained2'},
|
||
{ title:'3日留存', checked:false,id:'retained3'},
|
||
{ title:'7日留存', checked:false,id:'retained7'},
|
||
{ title:'14日留存', checked:false,id:'retained14'},
|
||
{ title:'30日留存', checked:false,id:'retained30'},
|
||
]
|
||
},{
|
||
title:'Ltv指标',
|
||
id:'ltv',
|
||
checked: false,
|
||
list:[
|
||
{ title:'Ltv1', checked:false,id:'ltv1'},
|
||
{ title:'Ltv2', checked:false,id:'ltv2'},
|
||
{ title:'Ltv3', checked:false,id:'ltv3'},
|
||
{ title:'Ltv7', checked:false,id:'ltv7'},
|
||
{ title:'Ltv14', checked:false,id:'ltv14'},
|
||
{ title:'Ltv30', checked:false,id:'ltv30'},
|
||
]
|
||
}
|
||
];
|
||
|
||
X.laytpldata("#zhibiao-list-dot",datalist,".zidingyizhibiao-list-box");
|
||
|
||
layui.form.render();
|
||
|
||
layui.form.on('checkbox(checkboxexample)', function(d){
|
||
var data = layui.form.val('zidingyiexample');
|
||
if(data[d.value]){
|
||
for(let i in datalist){
|
||
if(datalist[i]['id'] == d.value){
|
||
datalist[i]['checked'] = true;
|
||
for(let z in datalist[i]['list']){
|
||
datalist[i]['list'][z]['checked'] = true;
|
||
}
|
||
}
|
||
}
|
||
}else{
|
||
for(let i in datalist){
|
||
if(datalist[i]['id'] == d.value){
|
||
datalist[i]['checked'] = false;
|
||
for(let z in datalist[i]['list']){
|
||
datalist[i]['list'][z]['checked'] = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
X.laytpldata("#zhibiao-list-dot",datalist,".zidingyizhibiao-list-box");
|
||
layui.form.render();
|
||
});
|
||
|
||
$(document).off('click','.adduser-btn').on('click','.adduser-btn',function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(document).off('click','.adduser-top-box img').on('click','.adduser-top-box img',function(){
|
||
layer.closeAll();
|
||
})
|
||
|
||
$(document).off('click','.adduser-btn2').on('click','.adduser-btn2',function(){
|
||
var data = layui.form.val('zidingyiexample');
|
||
me.callback && me.callback(data);
|
||
layer.closeAll();
|
||
})
|
||
|
||
|
||
|
||
}
|
||
};
|
||
})(); |