diff --git a/web/main.html b/web/main.html index 4460902..0778846 100644 --- a/web/main.html +++ b/web/main.html @@ -8,6 +8,7 @@ + @@ -18,8 +19,11 @@ - - + + + + + diff --git a/web/pages/attribute.html b/web/pages/attribute.html index 41c1c6c..e51102c 100644 --- a/web/pages/attribute.html +++ b/web/pages/attribute.html @@ -134,23 +134,23 @@
-
-
+
+
-
+
- + - + @@ -180,3 +180,18 @@ {{# }); }} + + + + diff --git a/web/pages/dashboard.html b/web/pages/dashboard.html index 19fce7c..32a6658 100644 --- a/web/pages/dashboard.html +++ b/web/pages/dashboard.html @@ -1,26 +1,29 @@
-
+
    - +
-
+
@@ -142,7 +145,7 @@
当前时间
-
+
@@ -156,19 +159,21 @@ -
+
- +
+ +
-
+
+ +
+ -
-
+ -
+ +
@@ -501,14 +528,15 @@ + + \ No newline at end of file + + + + + diff --git a/web/pages/toptab.html b/web/pages/toptab.html index 4ed4b94..4b5a2bb 100644 --- a/web/pages/toptab.html +++ b/web/pages/toptab.html @@ -1,4 +1,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/web/src/x.min.js b/web/src/x.min.js index 532965d..72062d0 100644 --- a/web/src/x.min.js +++ b/web/src/x.min.js @@ -103,8 +103,8 @@ var X = window.X || { (function(){ - // var ipurl = "http://10.0.0.77:7889/api/v1/"; - var ipurl = "http://139.159.159.3:9865/api/v1/"; + var ipurl = "http://10.0.0.77:7889/api/v1/"; + // var ipurl = "http://139.159.159.3:9865/api/v1/"; //设置或读取登录缓存,需要保存到localStorage,防止刷新时候登录数据丢失 X.loginCache = function(data){ @@ -169,7 +169,7 @@ var X = window.X || { layer.close(index); } }); - } + }; X.template = function(url,id,data,callback){ $.get('pages/'+ url + '.html',function(content){ @@ -273,7 +273,7 @@ var X = window.X || { extData : data, callback : callback }); - } + }; X.parametersopen = function(data,url,offset,callback){ X.open({ @@ -287,7 +287,7 @@ var X = window.X || { extData : data, callback : callback }); - } + }; // 渲染树形菜单 X.treemenu = function(elem,data,id){ @@ -299,7 +299,7 @@ var X = window.X || { ,isJump: false //是否允许点击节点时弹出新窗口跳转 }); - } + }; //渲染穿梭框 X.laytransfer = function(elem,data,title,id){ @@ -310,7 +310,7 @@ var X = window.X || { ,showSearch: true ,id: id }) - } + }; // 分组项取交集 X.groupintersection=function(c , a , callback){ @@ -349,7 +349,7 @@ var X = window.X || { } callback && callback(dataArr); - } + }; // 日期选择器 X.daterender = function(id,callback){ @@ -376,7 +376,7 @@ var X = window.X || { 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; @@ -391,7 +391,12 @@ var X = window.X || { 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){ @@ -406,7 +411,7 @@ var X = window.X || { ,verify:'required', callback:callback }); - } + }; X.layuidate=function(id){ layui.laydate.render({ @@ -414,7 +419,25 @@ var X = window.X || { ,type: 'datetime' ,range: true }); - } + }; + + X.eventtable=function(data,callback){ + var titledata,condata = []; + for(let i in data){ + if(data[i]['groups']['length'] == 0){ + titledata= $.extend(true,[],data[0]['date_range']) ; + titledata.unshift('指标','阶段总和'); + condata.push(data[i].values[0]); + condata[i].unshift(data[i]['event_name'],data[i]['sum']); + // console.log(condata); + } + } + var dataArr = { + titledata:titledata, + condata:condata + } + callback && callback(dataArr); + }; // 分组项 // X.grouped=function(data,id){ @@ -522,8 +545,10 @@ var X = window.X || { } X.gourl = function(url,id){ - setHashParms('page',url); - setContentByUrl(url,id); + if(url || id){ + setHashParms('page',url); + setContentByUrl(url,id); + } }; @@ -1307,8 +1332,9 @@ var X = window.X || { 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); @@ -1335,9 +1361,9 @@ var X = window.X || { }) }) // groupeddata = d.group_by; - - }) + // }); + // 渲染选择时间下拉框 layui.dropdown.render({ @@ -1459,7 +1485,7 @@ var X = window.X || { $(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 index = obj.attr('data-index') X.querycriteriapop(dataArr,'setgrouping',offset.left,offset.top+obj.height(),function(val){ var htmlstring = val.id; obj.html(htmlstring); @@ -2324,6 +2350,7 @@ var X = window.X || { var data ={ "eventView":{ + "cksql":'user_property', "groupBy":[ ], @@ -2332,15 +2359,14 @@ var X = window.X || { ] }, "events":{ - "analysis":"PER_CAPITA_NUM", - "analysisDesc":"", + "analysis":"", "analysisName":"", "eventNameDisplay":"", "filts":[ ], - "quota":"user_prop0", - "quotaDesc":"user_prop0", + "quota":"", + "quotaDesc":"", "quotatype":"", "relation":"and", "tableType":"user" @@ -2378,7 +2404,7 @@ var X = window.X || { data['events']['quotaDesc'] = user_attr[0]['title']; data['events']['quotatype'] = user_attr[0]['data_type']; $('.ant-dropdown-trigger').html(user_attr[0]['title']); - $('.analysis-choicetypename').hide(); + var arr = { category: user_attr, @@ -2386,10 +2412,17 @@ var X = window.X || { title:'用户属性' } user_data.push(arr); - console.log(user_data); + // console.log(user_data); 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){ @@ -2398,6 +2431,15 @@ var X = window.X || { }) + // 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); @@ -2411,7 +2453,7 @@ var X = window.X || { $('.analysis-choicetypename').hide(); }else { $('.analysis-choicetypename').show(); - data['events']['analysisName'] = quotas_map[val.data_type][0].id; + 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']); } @@ -2423,7 +2465,7 @@ var X = window.X || { var offset = obj.offset(); X.querycriteriapop(quotas_map[data['events']['quotatype']],'dropdownlist',offset.left,offset.top+obj.height(),function(val){ obj.html(val.title); - data['events']['analysisName'] = val.id; + data['events']['analysis'] = val.id; data['events']['analysisDesc'] = val.title; }) @@ -2494,7 +2536,7 @@ var X = window.X || { "column_id":user_data[0]['category'][0]['id'],//事件id 'data_type':user_data[0]['category'][0]['data_type'],//类型 'comparator_name':'等于',//默认等于 - "comparator_id":'==',//符号id + "comparator":'==',//符号id "ftv":[],//条件 "strftv":'',//显示条件 "section":[-1,1],//区间 @@ -2544,7 +2586,7 @@ var X = window.X || { var filter_type = data['events']['filts'][index]['data_type']; X.querycriteriapop( filter_map[filter_type] ,'dropdownlist',offset.left,offset.top+obj.height(),function(val){ obj.html(val.title); - data['events']['filts'][index]['comparator_id'] = val.id; + 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]; @@ -2553,14 +2595,161 @@ var X = window.X || { }) }) - // 计算按钮 - $(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){ - console.log(data); + $(document).off('click','.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('click','.analysis-navigation-bar-right-img').on('click','.analysis-navigation-bar-right-img',function(){ - // location.reload(); - // }) + $(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['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']); + }) + + // 计算按钮 + $(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){ + + X.api("ck/user_property_model","post",data,function(val){ + attributetable(val); + querydata = val; + updata(val) + }) + + }) + + 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); + } } }; @@ -2717,23 +2906,25 @@ var X = window.X || { var popid=''; - // $(".toptab").load("./pages/toptab.html"); - layui.element.init(); // 项目列表 // http://10.0.0.7:6789/ X.api("project/","get",{},function(d){ X.laytpldata('#layui-project-dot',d,'.layui-project-box'); + X.DATA['projectarr'] = d; X.DATA['projectid'] = d[0]["_id"]; X.DATA["game"] = d[0]["game"]; me.freshMenu(d[0]["_id"]); + // X.template("toptab","analysis-zhanwei",d); }); + + // $(".username").html(X.DATA.userinfo.name); // 选择项目 - $(document).on('click','.selectproject',function(){ + $(document).off('click','.selectproject').on('click','.selectproject',function(){ var id = $(this).attr("data-id"); var game = $(this).attr("data-game"); $(".projecttit").html($(this).html()); @@ -2741,20 +2932,45 @@ var X = window.X || { X.DATA["game"] = game; //侧边栏数据渲染 me.freshMenu(id); - }) + // X.pageLogic.dashboard.freshMenu(id); + }); //a标签点击跳转事件 $(document).on('click','.layui-nav-child a',function(){ var url = $(this).attr("data-url"); X.gourl(url); - }) + }); // 修改面板名 $(document).on('click','.layui-left-dd',function(){ - // console.log($(this).find("span").html()); $(".tab-tit-box .tab-tit").html($(this).find("span").html()); - }) + X.DATA['dashboard_id'] = $(this).attr('data-id'); //看板id + // 获取报表数据 + gettabledata(); + }); + + // 获取表格数据 + function gettabledata(){ + X.api('dashboard','post',{id:X.DATA['dashboard_id']},function(d){ + // console.log(d); + for(let i in d){ + X.api("ck/"+d[i]['model']+"_model","post",{report_id:d[i]['report_id']},function(val){ + // console.log(val); + if(d[i]['model'] == "event"){ + if(d[i]['graph_type'] == 'table'){ + X.eventtable(val,function(data){ + console.log(data); + }) + }else if(d[i]['graph_type'] == 'echarts'){ + } + } + + }) + } + }) + }; + // 渲染添加按钮侧边栏下拉框 X.laydropdown("#chuangjian",X.DATA.createsidebar,function(d){ if(d.url){ @@ -2777,7 +2993,7 @@ var X = window.X || { //更新时间按钮 $(".updatetime").click(function(){ X.updatatime(".updatetime"); - }) + }); //管理我创建的看板 $(".sousuo-box .kbglkanbanbtn").click(function(){ @@ -2791,7 +3007,7 @@ var X = window.X || { skin: 'yourclass', url: 'adminkanban' }) - }) + }); //渲染时区下拉框 layui.dropdown.render({ @@ -2804,7 +3020,7 @@ var X = window.X || { //数据更新 // this.elem.val(obj.title); } - }); + }); //筛选 $(".tab-right-box .tjsx").click(function(){ @@ -2901,7 +3117,7 @@ var X = window.X || { }) }); - $(".tab-right-box .baobiao").click(function(){ + $(document).off('click','.tab-right-box .shezhi').on("click",".tab-right-box .shezhi",function(){ X.open({ type: 1, title: false, @@ -2912,7 +3128,14 @@ var X = window.X || { skin: 'yourclass', url: 'kanbanshezhi' }) - }) + }); + // 保存报表列表 + $(document).off('click','.baobiao').on('click','.baobiao',function(){ + X.parametersopen({},'kanbanadmin','rt',function(){ + console.log(111); + gettabledata(); + }) + }); //侧边栏更多控制按钮 // taboperation = function(e,type,id,name){ @@ -2939,6 +3162,80 @@ var X = window.X || { }; })(); +// srczip/logic/dataOverview.js +(function(){ + X.pageLogic['dataOverview'] = { + init : function(){ + + // X.template("toptab","analysis-zhanwei",X.DATA['projectarr'],function(d){ + // console.log(d); + // }); + var mainchannel = xmSelect.render({ + el: '#main-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var sonchannel = xmSelect.render({ + el: '#son-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + // 日期渲染 + X.daterender("#registration-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"; + data['eventView']['startTime'] = startTime; + data['eventView']['endTime'] = endTime; + }); + + layui.form.render(); + + // 自定义指标 + $(document).off('click','.zidingyizhibiao').on('click','.zidingyizhibiao',function(){ + X.parametersopen('','zidingyizhibiao','auto',function(d){ + console.log(d); + }) + }) + + // 搜索 + $(document).off('click','.searchbut').on('click','.searchbut',function(){ + var data = layui.form.val('example'); + var mainchanneldata = mainchannel.getValue("nameStr"); + var sonchanneldata = sonchannel.getValue("nameStr"); + var time = $("#registration-time").val(); + var timearr = time.split('-'); + var startTime = timearr[0]+'-'+timearr[1]+'-'+timearr[2]+ "" +"00:00:00"; + var endTime = timearr[3]+'-'+timearr[4]+'-'+timearr[5]+ " " +"23:59:59"; + console.log(timearr); + console.log(startTime); + console.log(endTime.trim()); + // console.log($("#registration-time").val()); + // console.log(mainchanneldata); + // console.log(sonchanneldata); + // console.log(data); + }) + + } + }; +})(); // srczip/logic/datarights.js (function(){ X.pageLogic['datarights'] = { @@ -4523,7 +4820,6 @@ var X = window.X || { X.laytpldata("#table-fenxi-td-dot",tabdata,".table-fenxi-td"); } - 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'); @@ -4809,6 +5105,145 @@ var X = window.X || { }; })(); +// 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:'漏斗分析',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.title); + }) + toadddataprocessing(); + }) + } + + + 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'); + 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(); + }) + + + //渲染已添加报表下拉框 + function toadddataprocessing(){ + for(let i in reportlistdata){ + if(reportlistdata[i]['added'] == true){ + toadddata.push(reportlistdata[i]); + } + } + var downmenu = [ + {title:'表格',id:'table'}, + {title:'图形',id:'echarts'}, + {title:'删除',id:'del'}, + ] + + for(let i in toadddata){ + var arr = { + report_id:toadddata[i]['_id'], + graph_type:'table', + model:toadddata[i]['cat'] + } + submitdata.push(arr); + X.laydropdown('.to-added-more'+i,downmenu,function(d){ + if(d.id != 'del'){ + // 删除报表 + submitdata[i]['graph_type'] = d.id; + + }else { + // reportlistdata[i]['added'] = true; + for(let j in reportlistdata){ + if(reportlistdata[j]['_id'] == submitdata[i]['report_id']){ + console.log(submitdata[i]['report_id']); + X.api('dashboard/del_report','post',{_id:X['DATA']['dashboard_id'],report_id:submitdata[i]['report_id']},function(){ + kanbanupdata(); + }) + // reportlistdata[j]['added'] = false; + // 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','.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'){ + me.callback && me.callback(); + layer.closeAll(); + layer.msg('应用成功'); + } + }) + }) + + } + }; +})(); // srczip/logic/kanbanshezhi.js (function(){ X.pageLogic['kanbanshezhi'] = { @@ -4817,7 +5252,7 @@ var X = window.X || { // 弹窗占满整平 $('.kanbanshezhi-box').css('height',window.innerHeight+'px'); - me.renderdata(); + // me.renderdata(); //关闭弹窗 $('.kanbanshezhi-top .kanbanshezhi-tuihui').click(function(){ @@ -4908,7 +5343,7 @@ var X = window.X || { var userinfo = X.DATA.userinfo; $(".gly-firs").html(userinfo.name.substring(0,1)); $(".gly-name").html(userinfo.name); - X.api('user/all_user',"get",{},function(d){ + 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"; @@ -5061,6 +5496,176 @@ var X = window.X || { } }; })(); +// srczip/logic/ltv.js +(function(){ + X.pageLogic['ltv'] = { + init : function(){ + + var mainchannel = xmSelect.render({ + el: '#main-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var sonchannel = xmSelect.render({ + el: '#son-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var custom = xmSelect.render({ + el: '#custom', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + // 日期渲染 + X.daterender("#registration-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"; + data['eventView']['startTime'] = startTime; + data['eventView']['endTime'] = endTime; + }); + + layui.form.render(); + + // 自定义指标 + $(document).off('click','.zidingyizhibiao').on('click','.zidingyizhibiao',function(){ + X.parametersopen('','zidingyizhibiao','auto',function(d){ + console.log(d); + }) + }) + + // 搜索 + $(document).off('click','.searchbut').on('click','.searchbut',function(){ + var data = layui.form.val('example'); + var mainchanneldata = mainchannel.getValue("nameStr"); + var sonchanneldata = sonchannel.getValue("nameStr"); + var time = $("#registration-time").val(); + var timearr = time.split('-'); + var startTime = timearr[0]+'-'+timearr[1]+'-'+timearr[2]+ "" +"00:00:00"; + var endTime = timearr[3]+'-'+timearr[4]+'-'+timearr[5]+ " " +"23:59:59"; + console.log(timearr); + console.log(startTime); + console.log(endTime.trim()); + // console.log($("#registration-time").val()); + // console.log(mainchanneldata); + // console.log(sonchanneldata); + // console.log(data); + }) + + } + }; +})(); +// srczip/logic/manytimespay.js +(function(){ + X.pageLogic['manytimespay'] = { + init : function(){ + + var mainchannel = xmSelect.render({ + el: '#main-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var sonchannel = xmSelect.render({ + el: '#son-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var custom = xmSelect.render({ + el: '#custom', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + // 日期渲染 + X.daterender("#registration-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"; + data['eventView']['startTime'] = startTime; + data['eventView']['endTime'] = endTime; + }); + + layui.form.render(); + + // 自定义指标 + $(document).off('click','.zidingyizhibiao').on('click','.zidingyizhibiao',function(){ + X.parametersopen('','zidingyizhibiao','auto',function(d){ + console.log(d); + }) + }) + + // 搜索 + $(document).off('click','.searchbut').on('click','.searchbut',function(){ + var data = layui.form.val('example'); + var mainchanneldata = mainchannel.getValue("nameStr"); + var sonchanneldata = sonchannel.getValue("nameStr"); + var time = $("#registration-time").val(); + var timearr = time.split('-'); + var startTime = timearr[0]+'-'+timearr[1]+'-'+timearr[2]+ "" +"00:00:00"; + var endTime = timearr[3]+'-'+timearr[4]+'-'+timearr[5]+ " " +"23:59:59"; + console.log(timearr); + console.log(startTime); + console.log(endTime.trim()); + // console.log($("#registration-time").val()); + // console.log(mainchanneldata); + // console.log(sonchanneldata); + // console.log(data); + }) + + } + }; +})(); // srczip/logic/newkanban.js (function(){ X.pageLogic['newkanban'] = { @@ -5668,9 +6273,8 @@ var X = window.X || { X.pageLogic['retained'] = { init : function(parms){ - // X.gourl("grouped","shushi"); X.template("grouped","shushi"); - + // X.template("toptab","analysis-zhanwei",X.DATA['projectarr']); var data ={ "eventView":{ "cksql":"retention", @@ -6394,6 +6998,176 @@ var X = window.X || { } }; })(); +// srczip/logic/retainedpay.js +(function(){ + X.pageLogic['retainedpay'] = { + init : function(){ + + var mainchannel = xmSelect.render({ + el: '#main-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var sonchannel = xmSelect.render({ + el: '#son-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var custom = xmSelect.render({ + el: '#custom', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + // 日期渲染 + X.daterender("#registration-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"; + data['eventView']['startTime'] = startTime; + data['eventView']['endTime'] = endTime; + }); + + layui.form.render(); + + // 自定义指标 + $(document).off('click','.zidingyizhibiao').on('click','.zidingyizhibiao',function(){ + X.parametersopen('','zidingyizhibiao','auto',function(d){ + console.log(d); + }) + }) + + // 搜索 + $(document).off('click','.searchbut').on('click','.searchbut',function(){ + var data = layui.form.val('example'); + var mainchanneldata = mainchannel.getValue("nameStr"); + var sonchanneldata = sonchannel.getValue("nameStr"); + var time = $("#registration-time").val(); + var timearr = time.split('-'); + var startTime = timearr[0]+'-'+timearr[1]+'-'+timearr[2]+ "" +"00:00:00"; + var endTime = timearr[3]+'-'+timearr[4]+'-'+timearr[5]+ " " +"23:59:59"; + console.log(timearr); + console.log(startTime); + console.log(endTime.trim()); + // console.log($("#registration-time").val()); + // console.log(mainchanneldata); + // console.log(sonchanneldata); + // console.log(data); + }) + + } + }; +})(); +// srczip/logic/retainedrate.js +(function(){ + X.pageLogic['retainedrate'] = { + init : function(){ + + var mainchannel = xmSelect.render({ + el: '#main-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var sonchannel = xmSelect.render({ + el: '#son-channel', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + var custom = xmSelect.render({ + el: '#custom', + language: 'zn', + toolbar: { + show: true, + }, + filterable: true, + data: [ + {name: '张三', value: 1}, + {name: '李四', value: 2}, + {name: '王五', value: 3}, + ] + }); + + // 日期渲染 + X.daterender("#registration-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"; + data['eventView']['startTime'] = startTime; + data['eventView']['endTime'] = endTime; + }); + + layui.form.render(); + + // 自定义指标 + $(document).off('click','.zidingyizhibiao').on('click','.zidingyizhibiao',function(){ + X.parametersopen('','zidingyizhibiao','auto',function(d){ + console.log(d); + }) + }) + + // 搜索 + $(document).off('click','.searchbut').on('click','.searchbut',function(){ + var data = layui.form.val('example'); + var mainchanneldata = mainchannel.getValue("nameStr"); + var sonchanneldata = sonchannel.getValue("nameStr"); + var time = $("#registration-time").val(); + var timearr = time.split('-'); + var startTime = timearr[0]+'-'+timearr[1]+'-'+timearr[2]+ "" +"00:00:00"; + var endTime = timearr[3]+'-'+timearr[4]+'-'+timearr[5]+ " " +"23:59:59"; + console.log(timearr); + console.log(startTime); + console.log(endTime.trim()); + // console.log($("#registration-time").val()); + // console.log(mainchanneldata); + // console.log(sonchanneldata); + // console.log(data); + }) + + } + }; +})(); // srczip/logic/returnvisitevent.js (function(){ X.pageLogic['returnvisitevent'] = { @@ -7517,28 +8291,35 @@ var X = window.X || { // srczip/logic/toptab.js (function(){ X.pageLogic['toptab'] = { - init : function(){ - console.log(111) - var data = {'_id':'111',create_date: "2021-05-05T21:42:14.256000",name: "ddd",user_id: "5df2b9bbada711eb8857001a7dda710c",}; - var getTpl = demo.innerHTML, - view = document.getElementById('toptab'); - X.api("project/","get",function(d){ - // X.laytpldata('#layui-project-dot',d,'.layui-project-box'); - data=d; - console.log(d); - layui.use('laytpl', function () { - var laytpl = layui.laytpl; - laytpl(getTpl).render(data, function (html) { - view.innerHTML = html; - }); - }) - - layui.element.init(); - - // X.pageLogic.dashboard.freshMenu(d[0]["_id"]); - // // me.freshMenu(d[0]["_id"]); - // X.DATA['projectid'] = d[0]["_id"]; - }); + 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); + }) + } }; })(); @@ -7966,6 +8747,114 @@ var X = window.X || { }); + } + }; +})(); +// 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(); + }) + + + } }; })(); \ No newline at end of file diff --git a/web/srczip/base/ajaxpage.js b/web/srczip/base/ajaxpage.js index 90e42c2..f86c93f 100644 --- a/web/srczip/base/ajaxpage.js +++ b/web/srczip/base/ajaxpage.js @@ -40,8 +40,10 @@ } X.gourl = function(url,id){ - setHashParms('page',url); - setContentByUrl(url,id); + if(url || id){ + setHashParms('page',url); + setContentByUrl(url,id); + } }; diff --git a/web/srczip/common.js b/web/srczip/common.js index ab6e837..0cb001a 100644 --- a/web/srczip/common.js +++ b/web/srczip/common.js @@ -102,8 +102,8 @@ var X = window.X || { (function(){ - // var ipurl = "http://10.0.0.77:7889/api/v1/"; - var ipurl = "http://139.159.159.3:9865/api/v1/"; + var ipurl = "http://10.0.0.77:7889/api/v1/"; + // var ipurl = "http://139.159.159.3:9865/api/v1/"; //设置或读取登录缓存,需要保存到localStorage,防止刷新时候登录数据丢失 X.loginCache = function(data){ @@ -168,7 +168,7 @@ var X = window.X || { layer.close(index); } }); - } + }; X.template = function(url,id,data,callback){ $.get('pages/'+ url + '.html',function(content){ @@ -272,7 +272,7 @@ var X = window.X || { extData : data, callback : callback }); - } + }; X.parametersopen = function(data,url,offset,callback){ X.open({ @@ -286,7 +286,7 @@ var X = window.X || { extData : data, callback : callback }); - } + }; // 渲染树形菜单 X.treemenu = function(elem,data,id){ @@ -298,7 +298,7 @@ var X = window.X || { ,isJump: false //是否允许点击节点时弹出新窗口跳转 }); - } + }; //渲染穿梭框 X.laytransfer = function(elem,data,title,id){ @@ -309,7 +309,7 @@ var X = window.X || { ,showSearch: true ,id: id }) - } + }; // 分组项取交集 X.groupintersection=function(c , a , callback){ @@ -348,7 +348,7 @@ var X = window.X || { } callback && callback(dataArr); - } + }; // 日期选择器 X.daterender = function(id,callback){ @@ -375,7 +375,7 @@ var X = window.X || { 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; @@ -390,7 +390,12 @@ var X = window.X || { 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){ @@ -405,7 +410,7 @@ var X = window.X || { ,verify:'required', callback:callback }); - } + }; X.layuidate=function(id){ layui.laydate.render({ @@ -413,7 +418,25 @@ var X = window.X || { ,type: 'datetime' ,range: true }); - } + }; + + X.eventtable=function(data,callback){ + var titledata,condata = []; + for(let i in data){ + if(data[i]['groups']['length'] == 0){ + titledata= $.extend(true,[],data[0]['date_range']) ; + titledata.unshift('指标','阶段总和'); + condata.push(data[i].values[0]); + condata[i].unshift(data[i]['event_name'],data[i]['sum']); + // console.log(condata); + } + } + var dataArr = { + titledata:titledata, + condata:condata + } + callback && callback(dataArr); + }; // 分组项 // X.grouped=function(data,id){ diff --git a/web/srczip/logic/analysis.js b/web/srczip/logic/analysis.js index b29b2a0..5496493 100644 --- a/web/srczip/logic/analysis.js +++ b/web/srczip/logic/analysis.js @@ -59,8 +59,9 @@ 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); @@ -87,9 +88,9 @@ }) }) // groupeddata = d.group_by; - - }) + // }); + // 渲染选择时间下拉框 layui.dropdown.render({ @@ -211,7 +212,7 @@ $(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 index = obj.attr('data-index') X.querycriteriapop(dataArr,'setgrouping',offset.left,offset.top+obj.height(),function(val){ var htmlstring = val.id; obj.html(htmlstring); diff --git a/web/srczip/logic/attribute.js b/web/srczip/logic/attribute.js index 5ba4ee0..b16d1c8 100644 --- a/web/srczip/logic/attribute.js +++ b/web/srczip/logic/attribute.js @@ -4,6 +4,7 @@ var data ={ "eventView":{ + "cksql":'user_property', "groupBy":[ ], @@ -12,15 +13,14 @@ ] }, "events":{ - "analysis":"PER_CAPITA_NUM", - "analysisDesc":"", + "analysis":"", "analysisName":"", "eventNameDisplay":"", "filts":[ ], - "quota":"user_prop0", - "quotaDesc":"user_prop0", + "quota":"", + "quotaDesc":"", "quotatype":"", "relation":"and", "tableType":"user" @@ -58,7 +58,7 @@ data['events']['quotaDesc'] = user_attr[0]['title']; data['events']['quotatype'] = user_attr[0]['data_type']; $('.ant-dropdown-trigger').html(user_attr[0]['title']); - $('.analysis-choicetypename').hide(); + var arr = { category: user_attr, @@ -66,10 +66,17 @@ title:'用户属性' } user_data.push(arr); - console.log(user_data); + // console.log(user_data); 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){ @@ -78,6 +85,15 @@ }) + // 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); @@ -91,7 +107,7 @@ $('.analysis-choicetypename').hide(); }else { $('.analysis-choicetypename').show(); - data['events']['analysisName'] = quotas_map[val.data_type][0].id; + 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']); } @@ -103,7 +119,7 @@ var offset = obj.offset(); X.querycriteriapop(quotas_map[data['events']['quotatype']],'dropdownlist',offset.left,offset.top+obj.height(),function(val){ obj.html(val.title); - data['events']['analysisName'] = val.id; + data['events']['analysis'] = val.id; data['events']['analysisDesc'] = val.title; }) @@ -174,7 +190,7 @@ "column_id":user_data[0]['category'][0]['id'],//事件id 'data_type':user_data[0]['category'][0]['data_type'],//类型 'comparator_name':'等于',//默认等于 - "comparator_id":'==',//符号id + "comparator":'==',//符号id "ftv":[],//条件 "strftv":'',//显示条件 "section":[-1,1],//区间 @@ -224,7 +240,7 @@ var filter_type = data['events']['filts'][index]['data_type']; X.querycriteriapop( filter_map[filter_type] ,'dropdownlist',offset.left,offset.top+obj.height(),function(val){ obj.html(val.title); - data['events']['filts'][index]['comparator_id'] = val.id; + 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]; @@ -233,14 +249,161 @@ }) }) - // 计算按钮 - $(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){ - console.log(data); + $(document).off('click','.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('click','.analysis-navigation-bar-right-img').on('click','.analysis-navigation-bar-right-img',function(){ - // location.reload(); - // }) + $(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['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']); + }) + + // 计算按钮 + $(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){ + + X.api("ck/user_property_model","post",data,function(val){ + attributetable(val); + querydata = val; + updata(val) + }) + + }) + + 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); + } } }; diff --git a/web/srczip/logic/dashboard.js b/web/srczip/logic/dashboard.js index 230c0c0..0619cb9 100644 --- a/web/srczip/logic/dashboard.js +++ b/web/srczip/logic/dashboard.js @@ -6,23 +6,25 @@ var popid=''; - // $(".toptab").load("./pages/toptab.html"); - layui.element.init(); // 项目列表 // http://10.0.0.7:6789/ X.api("project/","get",{},function(d){ X.laytpldata('#layui-project-dot',d,'.layui-project-box'); + X.DATA['projectarr'] = d; X.DATA['projectid'] = d[0]["_id"]; X.DATA["game"] = d[0]["game"]; me.freshMenu(d[0]["_id"]); + // X.template("toptab","analysis-zhanwei",d); }); + + // $(".username").html(X.DATA.userinfo.name); // 选择项目 - $(document).on('click','.selectproject',function(){ + $(document).off('click','.selectproject').on('click','.selectproject',function(){ var id = $(this).attr("data-id"); var game = $(this).attr("data-game"); $(".projecttit").html($(this).html()); @@ -30,20 +32,46 @@ X.DATA["game"] = game; //侧边栏数据渲染 me.freshMenu(id); - }) + // X.pageLogic.dashboard.freshMenu(id); + }); //a标签点击跳转事件 $(document).on('click','.layui-nav-child a',function(){ var url = $(this).attr("data-url"); X.gourl(url); - }) + }); // 修改面板名 $(document).on('click','.layui-left-dd',function(){ - // console.log($(this).find("span").html()); $(".tab-tit-box .tab-tit").html($(this).find("span").html()); - }) + X.DATA['dashboard_id'] = $(this).attr('data-id'); //看板id + // 获取报表数据 + gettabledata(); + }); + + // 获取表格数据 + function gettabledata(){ + X.api('dashboard','post',{id:X.DATA['dashboard_id']},function(d){ + // console.log(d); + for(let i in d){ + X.api("ck/"+d[i]['model']+"_model","post",{report_id:d[i]['report_id']},function(val){ + // console.log(val); + if(d[i]['model'] == "event"){ + if(d[i]['graph_type'] == 'table'){ + X.eventtable(val,function(data){ + console.log(data); + X.template("modeltable","chart-box",data); + }) + }else if(d[i]['graph_type'] == 'echarts'){ + } + } + + }) + } + }) + }; + // 渲染添加按钮侧边栏下拉框 X.laydropdown("#chuangjian",X.DATA.createsidebar,function(d){ if(d.url){ @@ -66,7 +94,7 @@ //更新时间按钮 $(".updatetime").click(function(){ X.updatatime(".updatetime"); - }) + }); //管理我创建的看板 $(".sousuo-box .kbglkanbanbtn").click(function(){ @@ -80,7 +108,7 @@ skin: 'yourclass', url: 'adminkanban' }) - }) + }); //渲染时区下拉框 layui.dropdown.render({ @@ -93,7 +121,7 @@ //数据更新 // this.elem.val(obj.title); } - }); + }); //筛选 $(".tab-right-box .tjsx").click(function(){ @@ -190,7 +218,7 @@ }) }); - $(".tab-right-box .baobiao").click(function(){ + $(document).off('click','.tab-right-box .shezhi').on("click",".tab-right-box .shezhi",function(){ X.open({ type: 1, title: false, @@ -201,7 +229,14 @@ skin: 'yourclass', url: 'kanbanshezhi' }) - }) + }); + // 保存报表列表 + $(document).off('click','.baobiao').on('click','.baobiao',function(){ + X.parametersopen({},'kanbanadmin','rt',function(){ + console.log(111); + gettabledata(); + }) + }); //侧边栏更多控制按钮 // taboperation = function(e,type,id,name){ diff --git a/web/srczip/logic/funnelanalysis.js b/web/srczip/logic/funnelanalysis.js index f88dfef..4702315 100644 --- a/web/srczip/logic/funnelanalysis.js +++ b/web/srczip/logic/funnelanalysis.js @@ -674,7 +674,6 @@ X.laytpldata("#table-fenxi-td-dot",tabdata,".table-fenxi-td"); } - 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'); diff --git a/web/srczip/logic/kanbanshezhi.js b/web/srczip/logic/kanbanshezhi.js index 9898708..0e29a5c 100644 --- a/web/srczip/logic/kanbanshezhi.js +++ b/web/srczip/logic/kanbanshezhi.js @@ -5,7 +5,7 @@ // 弹窗占满整平 $('.kanbanshezhi-box').css('height',window.innerHeight+'px'); - me.renderdata(); + // me.renderdata(); //关闭弹窗 $('.kanbanshezhi-top .kanbanshezhi-tuihui').click(function(){ diff --git a/web/srczip/logic/kongjianshezhi.js b/web/srczip/logic/kongjianshezhi.js index a67564e..eef7536 100644 --- a/web/srczip/logic/kongjianshezhi.js +++ b/web/srczip/logic/kongjianshezhi.js @@ -15,7 +15,7 @@ var userinfo = X.DATA.userinfo; $(".gly-firs").html(userinfo.name.substring(0,1)); $(".gly-name").html(userinfo.name); - X.api('user/all_user',"get",{},function(d){ + 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"; diff --git a/web/srczip/logic/retained.js b/web/srczip/logic/retained.js index 62d0da3..68d3d24 100644 --- a/web/srczip/logic/retained.js +++ b/web/srczip/logic/retained.js @@ -2,9 +2,8 @@ X.pageLogic['retained'] = { init : function(parms){ - // X.gourl("grouped","shushi"); X.template("grouped","shushi"); - + // X.template("toptab","analysis-zhanwei",X.DATA['projectarr']); var data ={ "eventView":{ "cksql":"retention", diff --git a/web/srczip/logic/toptab.js b/web/srczip/logic/toptab.js index 577d96f..ef8b76e 100644 --- a/web/srczip/logic/toptab.js +++ b/web/srczip/logic/toptab.js @@ -1,27 +1,34 @@ (function(){ X.pageLogic['toptab'] = { - init : function(){ - console.log(111) - var data = {'_id':'111',create_date: "2021-05-05T21:42:14.256000",name: "ddd",user_id: "5df2b9bbada711eb8857001a7dda710c",}; - var getTpl = demo.innerHTML, - view = document.getElementById('toptab'); - X.api("project/","get",function(d){ - // X.laytpldata('#layui-project-dot',d,'.layui-project-box'); - data=d; - console.log(d); - layui.use('laytpl', function () { - var laytpl = layui.laytpl; - laytpl(getTpl).render(data, function (html) { - view.innerHTML = html; - }); - }) - - layui.element.init(); - - // X.pageLogic.dashboard.freshMenu(d[0]["_id"]); - // // me.freshMenu(d[0]["_id"]); - // X.DATA['projectid'] = d[0]["_id"]; - }); + 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); + }) + } }; })(); diff --git a/web/static/css/analysis.css b/web/static/css/analysis.css index ef28e25..9c42079 100644 --- a/web/static/css/analysis.css +++ b/web/static/css/analysis.css @@ -291,4 +291,36 @@ .table-sql-box { padding: 16px; overflow: auto; } .slq-left { text-align: left; } +/* 看板管理 */ +.kanbanadmin-box{ width: 734px; background-color: #fff; } +.kanbanadmin-top { padding: 16px 24px; color: rgba(0, 0, 0, 0.85); border-bottom: 1px solid #f0f0f0; border-radius: 2px 2px 0 0; display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 500; } +.kanbanadmin-tuihui { cursor: pointer; } +.kanbanadmin-con-box { width: 734px; display: flex; height: calc(100% - 105px); } +.kanbanadmin-left-box { width: 50%; border-right: 1px solid #f0f0f0; height: 100%; } +.kanbanadmin-right-box { width: 50%; height: 100%; } +.kanbanadmin-head-box { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f0f0f0; height: 56px; padding: 0 24px; line-height: 56px; } +.kanbanadmin-head-box span { font-size: 14px; } +.kanbanadmin-head-tit { color: #202d3f; } +.kanbanadmin-head-right { color: #67729d; } +.baobiaoguanli { cursor: pointer; } +.kanbanadmin-ss-box { display: flex; justify-content: space-between; align-items: center; height: 48px; padding: 0px 16px; line-height: 32px; border-bottom: 1px solid #f0f0f0; } +.kanbanadmin-ss { width: 230px; height: 32px; padding: 0 8px 0 30px; color: #42546d; font-size: 14px; line-height: 30px; border-right: 2px; background: url("../img/fangdajing2.png") no-repeat 100%; background-position: left; display: flex; align-items: center; } +.kanbanadmin-ss img { display: none; width: 16px; height: 16px; cursor: pointer; } +.kanbanadmin-ss input { border: 0px; height: 30px; line-height: 30px; } +.kanbanadmin-ss-right { display: inline-block; height: 32px; padding: 0 8px; overflow: hidden; color: #67729d; line-height: 32px; text-overflow: ellipsis; border-right: 2px; cursor: pointer; } +.kanbanadmin-ss-right:hover{ background-color: #f6f8fa; color: #4fa1ff; } +.to-be-added-baobiao { height: calc(100% - 115px); padding: 4px; overflow-x: hidden; overflow-y: auto; } +.kanbanadmin-list-box { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 8px 0 0; line-height: 40px; cursor: grab; } +.kanbanadmin-list-box:hover{ background-color: #f6f8fa; } +.kanbanadmin-list-box:hover > .kanbanadmin-list-add-box{ display: block; } +.kanbanadmin-list-tit { font-size: 13px; color: #42546d; margin-left: 16px; } +.kanbanadmin-list-add-box { display: none; } +.kanbanadmin-list-add { display: inline-block; min-width: 24px; height: 24px; padding: 0 4px; line-height: 22px; text-align: center; border-right: 2px; cursor: pointer; font-size: 20px; } +.kanbanadmin-list-add:hover{ background-color: #f0f2f5; color: #3d90ff; } +.kanbanadmin-but-box { display: flex; align-items: center; justify-content: flex-end; padding: 8px 16px; border-top: 1px solid #f0f0f0; } +.kanbanadmin-but-box div { margin-left: 16px; padding: 0 12px; height: 32px; font-weight: 400; font-size: 14px; line-height: 30px; text-shadow: none; border-radius: 2px; cursor: pointer; } +.kanbanadmin-but-qx { color: #42546d; border: 1px solid #f0f0f0; } +.kanbanadmin-but-yy { color: #fff; background-color: #3d90ff; } +.to-added-baobiao { height: calc(100% - 65px); padding: 4px; overflow-x: hidden; overflow-y: auto; } + diff --git a/web/static/css/style.css b/web/static/css/style.css index 2d974f0..89669aa 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -1,5 +1,5 @@ .layui-layout-admin .modify-layui-header { background-color: #475285; } -.modify-layui-logo { background-color: #404a77; width: 80px !important; height: 60px; color: #fff; text-align: center;} +.modify-layui-logo { position: absolute; left: 0; top: 0; height: 100%; line-height: 60px; text-align: center; font-size: 16px; background-color: #404a77; width: 80px !important; height: 60px; color: #fff; text-align: center;} .modify-layui-side { width: 270px !important; } .modify-layui-bg-black { background-color: #fff !important; } .modify-layui-side-scroll { width: 290px !important; } @@ -20,7 +20,7 @@ .layui-table-body { height: 100% !important; } .layui-form-item .layui-form-checkbox[lay-skin=primary] { text-indent: 0px !important; } .layui-anim-downbit { max-height: 350px; overflow-y: auto; overflow-x: hidden; } -..layui-nav .layui-nav-child dd.layui-this a, .layui-nav-child dd.layui-this { background-color: #f6f8fa !important; } +.layui-nav .layui-nav-child dd.layui-this a, .layui-nav-child dd.layui-this { background-color: #f6f8fa !important; } .username { color: #67729d; margin-right: 16px; } .layui-project { position:absolute; top: 0; left: 80px; ;} @@ -83,7 +83,7 @@ .layui-card:last-child { padding-bottom: 12px; } .echarts { width: 100%; height: 204px; } .control { display: none; } -.table-box { padding: 0 24px; margin-top: 10px; height: 283px; } +.table-box { margin: 10px 24px 0 24px; height: 283px; overflow-x: auto; } .layui-table-body { height: 242px; overflow: auto; }