var reqList = []; Vue.use(Vuedals.default); new Vue({ el: "#main", data: { appname: "长处分分析", isback: true, isrefresh: true, isfilter: true, isopen: true, //页面请求参数 level: '', area: '', areaTitle: '', userRole: {}, lowLevel: '3', //市级对应lowLevel为3,逐级递减 dateType: 1, //折线图坐标值1-日,2-周,3-月 startDate: "", endDate: "", tagCode: 1, //顶部各个tag标签对应的值 sumType: 1, //记录从筛选页面选择的统计维度 1-订单统计,2-费用统计,3-配送统计,4-年龄统计 sumTypeName: "订单统计", disease: "", //疾病类型 diseaseName: "全部", orderTagDatas: { total: 0, finishCount: 0, patientCancelCount: 0, noReviewedCount: 0, processingCount: 0, payOuttimeCount: 0 }, paymentData: { sum: 0, avg: 0 }, expressData: { self: 0, doctor: 0, delivery: 0 }, ageDatas: [ {name: "0~6岁", color: "#ff5442", value: 0}, {name: "7~18岁", color: "#ffc800", value: 0}, {name: "19~30岁", color: "#4ce428", value: 0}, {name: "31~50岁", color: "#24bbfa", value: 0}, {name: "51~64岁", color: "#fb5dab", value: 0}, {name: "65岁以上", color: "#9b5ffd", value: 0}] }, components: { vuedals: Vuedals.Component }, mounted: function(){ //初始化数据 initData(this); //获得顶部各tab的值 loadData([0,1,2], this); //参数组数表示请求的区域为上中下 //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel, tagCode: this.tagCode, sumType: this.sumType, disease: this.disease, dateType: this.dateType }); //设置监听器, 监听折线图日期变化 var vm = this; //监听后退按钮的操作 EventBus.$on("back-click", function(arg){ if(reqList.length == 1){ history.go(-1); } else{ var preInfo = reqList.pop(); var info = reqList[reqList.length - 1]; vm.level = info.level; vm.area = info.area; vm.areaTitle = info.areaTitle; vm.lowLevel = info.lowLevel; vm.tagCode = info.tagCode; vm.sumType = info.sumType; vm.disease = info.disease; vm.dateType = info.dateType; loadData([0,1,2], vm); EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); } }); //监听页面刷新 EventBus.$on("refresh-click", function(arg){ loadData([0,1,2], vm); }); //弹出筛选框 EventBus.$on('filter-click', function(arg) { //弹框显示筛选条件 Vuedals.Bus.$emit('new', { title: '条件筛选', onClose:function(data){ vm.sumType = data.sumType; vm.sumTypeName = data.sumTypeName; vm.disease = data.disease; vm.diseaseName = data.diseaseName; //将参数职位初始值 vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; vm.lowLevel = vm.level - 1; vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; vm.dateType = 1; EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); //然后清空请求列表数组 reqList.splice(0, reqList.length); loadData([0, 1, 2], vm);//刷新数据 //存储请求所带的参数 reqList.push({ level: vm.level, area: vm.area, areaTitle: vm.areaTitle, endDate: vm.endDate, startDate: vm.startDate, lowLevel: vm.lowLevel, tagCode: vm.tagCode, sumType: vm.sumType, disease: vm.disease, dateType: vm.dateType }); EventBus.$emit('update-statistics-year',{selectDate: vm.sumTypeName} );//显示统计维度的名称 EventBus.$emit('update-dimension-name', {dimensionVal: vm.diseaseName});//显示疾病类型的名称 EventBus.$emit('update-statistics-time', {});//更新统计时间 }, component: 'prescription-filter', props: { sumType: vm.sumType, disease: vm.disease } }); }); }, methods: { changeTagCode: function(val){ this.tagCode = val; if(this.sumType == 2){ //费用统计只查看人均费用的变化趋势 loadData([2], this); }else{ loadData([1,2], this); } //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel, tagCode: this.tagCode, sumType: this.sumType, disease: this.disease, dateType: this.dateType }) }, getBarData: function(arg){ this.dateType = arg.dateType; loadData([1], this); }, getPaymentLineData: function(arg){ this.dateType = arg.dateType; loadData([1], this); }, getBottomAreaData: function(arg){ //如果level改变,则需要重新加载整个页面的数据,否则只需加载底部区域数据 if(arg.level == this.level){ this.lowLevel = arg.lowLevel; loadData([2], this); }else{ this.level = arg.level; //长处方这边level改了lowLevel也需要跟着一起变 this.lowLevel = arg.level - 1; this.area = arg.area; this.areaTitle = arg.areaTitle; loadData([0,1,2], this); } EventBus.$emit('update-area-name', {areaName: this.areaTitle}); //存储请求所带的参数 reqList.push({ level: this.level, area: this.area, areaTitle: this.areaTitle, endDate: this.endDate, startDate: this.startDate, lowLevel: this.lowLevel, tagCode: this.tagCode, sumType: this.sumType, disease: this.disease, }) } } }); function initData(vm){ //获得缓存中缓存的角色权限 var userRole = window.localStorage.getItem("selectedRole"); if(!userRole){ return false; } vm.userRole = JSON.parse(userRole); vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; vm.lowLevel = vm.level - 1; vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; EventBus.$emit('update-area-name', {areaName: vm.areaTitle}); var now = new Date(); vm.endDate = now.format("yyyy-MM-dd"); EventBus.$emit('update-statistics-year',{selectDate: vm.sumTypeName} );//显示统计维度的名称 EventBus.$emit('update-dimension-name', {dimensionVal: vm.diseaseName});//显示疾病类型的名称 } function initReqParams(vm){ //sumType: 1-订单统计,2-费用统计,3-配送统计,4-年龄统计 var reqParam = []; switch(vm.sumType){ case 1: //tagCode: 1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消 reqParam = [{ url: "/statistics/getPrescriptionCount", data: {level: vm.level, area: vm.area, disease: vm.disease} },{ url: "/statistics/getPrescriptionTotalHistogram", data: {level: vm.level, area: vm.area, disease: vm.disease, type: vm.tagCode, interval: vm.dateType} },{ url: "/statistics/getPrescriptionTotalLowLevel", data: {level: vm.level, lowlevel: vm.lowLevel, area: vm.area, disease: vm.disease, type: vm.tagCode} }]; break; case 2: //dateType: 折线图坐标值1-日,2-周,3-月 //tagCode: 1.总量,2.平均值 vm.startDate = getBeforeMonthStartDate(3, vm.dateType); reqParam = [{ url: "/statistics/getPrescriptionCost", data: {level: vm.level, area: vm.area, disease: vm.disease} },{ url: "/statistics/getPrescriptionCostAvgLine", data: {level: vm.level, area: vm.area, disease: vm.disease, type: vm.dateType, startDate: vm.startDate, endDate: vm.endDate} },{ url: "/statistics/getPrescriptionCostLowLevel", data: {level: vm.level, lowlevel: vm.lowLevel, area: vm.area, disease: vm.disease, type: vm.tagCode} }]; break; case 3: //tagCode: 1.自取,2.快递配送,3.健管师配送 reqParam = [{ url: "/statistics/getPrescriptionDispatchingTotal", data: {level: vm.level, area: vm.area, disease: vm.disease} },{ url: "/statistics/getPrescriptionDispatchingHistogram", data: {level: vm.level, area: vm.area, disease: vm.disease, type: vm.tagCode, interval: vm.dateType} },{ url: "/statistics/getPrescriptionDispatchingLowLevel", data: {level: vm.level, lowlevel: vm.lowLevel, area: vm.area, disease: vm.disease, type: vm.tagCode} }]; break; case 4: reqParam = [{ url: "/statistics/getPrescriptionAgeTotal", data: {level: vm.level, area: vm.area, disease: vm.disease} },{ url: "/statistics/getPrescriptionAgeHistogram", data: {level: vm.level, area: vm.area, disease: vm.disease} },{ url: "/statistics/getPrescriptionAgeLowLevel", data: {level: vm.level, lowlevel: vm.lowLevel, area: vm.area, disease: vm.disease} }]; break; default: reqParam = []; break; }; return reqParam; } function loadData(loadArr, vm){ //获取其他请求的参数 var reqParams = initReqParams(vm), reqPromise = []; for(i=0; i 0){ Promise.all(reqPromise).then(function(ress){ var res1, res2, res2; for(var i=0; i