(function(){ X.pageLogic['attribute'] = { init : function(){ var data ={ "eventView":{ "groupBy":[ ], "userCrowds":[ ] }, "events":{ "analysis":"PER_CAPITA_NUM", "analysisDesc":"", "analysisName":"", "eventNameDisplay":"", "filts":[ ], "quota":"user_prop0", "quotaDesc":"user_prop0", "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']); $('.analysis-choicetypename').hide(); var arr = { category: user_attr, id:'', title:'用户属性' } user_data.push(arr); console.log(user_data); X.api("data_auth/quotas_map","get",{},function(val){ quotas_map = val; }) X.api("data_auth/filter_map","get",{},function(val){ filter_map = val; }) }) // 分析属性 $(document).off('click','.ant-dropdown-trigger').on('click','.ant-dropdown-trigger',function(){ var obj = $(this); var offset = obj.offset(); X.querycriteriapop(user_attr,'dropdownlist',offset.left,offset.top+obj.height(),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']['analysisName'] = 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.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']['analysisDesc'] = val.title; }) }) $(document).off('click','.analysis-con-left-screen-list-left-zhibiaoname input').on('blur','.analysis-con-left-screen-list-left-zhibiaoname input',function(){ // console.log($(this).val()); 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 = { "columnName": user_data[0]['category'][0]['title'],//事件中文显示 "column_id": 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]['column_id'] = val.id; data['eventView']['groupBy'][index]['columnName'] = 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={ "columnName":user_data[0]['category'][0]['title'],//事件中文显示 "column_id":user_data[0]['category'][0]['id'],//事件id 'data_type':user_data[0]['category'][0]['data_type'],//类型 'comparator_name':'等于',//默认等于 "comparator_id":'==',//符号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']); }) $(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]['column_id'] = val.id; data['events']['filts'][index]['columnName'] = val.title; data['events']['filts'][index]['data_type'] = val.type; X.template("globalfilter","xinwei-whole",data['events']['filts']); }) }) $(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.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_name'] = val.title; if(val.id == "range"){ data['events']['filts'][index]['ftv'] = [-1,1]; } X.template("globalfilter","xinwei-whole",data['events']['filts']); }) }) // 计算按钮 $(document).off('click','.analysis-calculation').on('click','.analysis-calculation',function(){ console.log(data); }) // $(document).off('click','.analysis-navigation-bar-right-img').on('click','.analysis-navigation-bar-right-img',function(){ // location.reload(); // }) } }; })();