219 lines
9.7 KiB
JavaScript
219 lines
9.7 KiB
JavaScript
(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":[],
|
|
"recentDay":"1-30",
|
|
"relation":"and",
|
|
"startTime":"2021-05-09 00:00:00",
|
|
"statType":"retention",
|
|
"timeParticleSize":"P1D",
|
|
"unitNum":7
|
|
},
|
|
"events":[
|
|
|
|
],
|
|
"cachedata":{
|
|
eventdata:[],
|
|
groupitemeventsdata:[],
|
|
}
|
|
};
|
|
|
|
// 日期渲染
|
|
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;
|
|
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=[[],[]];//分组项里的事件
|
|
|
|
X.api("data_auth/my_event","get",{},function(d){
|
|
eventdata = d;
|
|
X.api("data_auth/load_filter_props","post",{event_name:d[0]['category'][0]['event_name']},function(val){
|
|
groupitemeventsdata = val;
|
|
|
|
})
|
|
});
|
|
|
|
|
|
//全局筛选
|
|
var filtsftvdata=[];
|
|
$(document).off('click','.analysis-overall-situation-add').on('click','.analysis-overall-situation-add',function(){
|
|
var screentypedata = groupitemeventsdata;
|
|
var drr={
|
|
"columnName":screentypedata[0]['category'][0]['title'],//事件中文显示
|
|
"column_id":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']
|
|
};
|
|
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();
|
|
}
|
|
console.log(data);
|
|
X.template("globalfilter","xinwei-whole",data['eventView']['filts']);
|
|
});
|
|
|
|
//删除指定全局数据
|
|
$(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']);
|
|
});
|
|
|
|
$(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]['columnName'] = val.title;
|
|
data['eventView']['filts'][index]['column_id'] = 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;
|
|
filtsftvdata[index]=val.category;
|
|
X.template("globalfilter","xinwei-whole",data['eventView']['filts']);
|
|
})
|
|
});
|
|
|
|
|
|
$(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");
|
|
X.querycriteriapop(filtsftvdata[index],'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']);
|
|
}
|
|
})
|
|
});
|
|
$(document).off('click','.analysis-overall-situation-input input').on('blur','.analysis-overall-situation-input input',function(){
|
|
var val = $(this).val();
|
|
var index = $(this).attr("data-index");
|
|
data['eventView']['filts'][index]['strftv'] = val;
|
|
data['eventView']['filts'][index]['ftv'].push(val);
|
|
});
|
|
|
|
$(document).off('click','.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(){
|
|
data['cachedata']['eventdata'] = eventdata;
|
|
data['cachedata']['groupitemeventsdata'] = groupitemeventsdata;
|
|
var dataArr = {
|
|
eventView: data.eventView,
|
|
events: data.events
|
|
}
|
|
X.api("ck/ltv_model","post",dataArr,function(d){
|
|
|
|
X.laytpldata("#table-fenxi-th-dot",d.title,".table-fenxi-th");
|
|
X.laytpldata("#table-fenxi-td-dot",d.rows,".table-fenxi-td");
|
|
})
|
|
};
|
|
|
|
$(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;
|
|
eventdata = data.cachedata.eventdata;
|
|
groupitemeventsdata = data.cachedata.groupitemeventsdata;
|
|
|
|
X.template("globalfilter","xinwei-whole",data['eventView']['filts']);
|
|
|
|
retaineddata();
|
|
}
|
|
|
|
})
|
|
});
|
|
|
|
|
|
}
|
|
};
|
|
})(); |