var reqList = [{}]; //记录请求的参数和url,用于后退时使用 var colors={"0":"#5b9db5","1":"#ed7d31","2":"#a5a5a5", "3":"#ffc000","4":"#44c274","5":"#70ad47", "6":"#255e91","7":"#9e480e","8":"#7e7e7e","9":"#997300","10":"#264478","11":"#43682b","12":"#5b9db5"} Vue.use(Vuedals.default); new Vue({ el: "#main", data: { isloading:false, //加载中 start:"", end:"", dateValue: "", initDate:"", pickerOptions: { disabledDate: function(d) { return d > new Date(); } }, pieData:[], //饼图数据 tabnumber:0, diagnosisList:[], //疾病分析列表 itemList:[], //服务项目列表 drugList:[], //药品分析列表 tabledata0:[], //表格数据 topData:{}, //请求页面所需参数 levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比 areaLevel:"", // 2、市,3、区,4、社区,5、团队 initareaLevel:"", initlevel: '', initarea: '', level: '', area: '', areaTitle: '', index: '121', lowLevel: '', initlowLevel:"", lowCode: '', chooseYear: '', userRole: '', ptab:"1", tableParams:[{isloading:false,noMore:false,page:1}, //疾病分析 {isloading:false,noMore:false,page:1},//药品分析 {isloading:false,noMore:false,page:1}], //服务项分析 pieShow:true, pageSize:100, reqListLength:1, }, components: { vuedals: Vuedals.Component }, mounted: function () { var vm=this //初始化数据 initData(vm); vm.getData() vm.bindEvent() }, methods: { getData:function(isNext,type){ //是否下转 var vm = this var params={ areaLevel: vm.areaLevel, level: vm.level, area: vm.area, endDate: vm.start, startDate: vm.end, lowLevel: vm.lowLevel } _.each(vm.tableParams,function(item,index){ vm.tableParams[index].page=1 //重新搜索时,上边三个表格重新加载 }) loadData([0,1,2,3,4], vm); //刷新数据 if(isNext){ //存储请求所带的参数 reqList.push(params); vm.reqListLength=reqList.length }else{ reqList[reqList.length-1]=params vm.reqListLength=reqList.length } }, //加载上边三个表格 loadTableData:function(index){ var vm = this vm.tableParams[index].isloading=true vm.tableParams[index].page++ loadData([index], vm); //刷新数据 }, //表格tab切换/下转 getnewdata:function(arg){ var vm = this vm.lowLevel=arg.lowLevel||"" if(arg.level){ vm.level = arg.level vm.areaLevel = _.find(vm.levelList,{level:vm.level}).areaLevel } if(arg.area){ vm.area = arg.area } if(arg.areaTitle){ vm.areaTitle = arg.areaTitle } vm.getData(arg.level) //有传level,说明是下转 }, //时间选择 changeDate: function () { var vm=this if(vm.dateValue){ if(vm.initDate==vm.dateValue){ vm.end = new Date().format("yyyy-MM-dd"); var start= new Date(); start.setDate(1) vm.start = start.format("yyyy-MM-dd") }else{ var year=vm.dateValue.split("-")[0] var month=vm.dateValue.split("-")[1] vm.start=new Date(vm.dateValue).format("yyyy-MM-dd") vm.end=new Date(year,month,0).format("yyyy-MM-dd") } //搜索时,取消下转记录 vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel reqList=[{}]; //搜索时清空历史记录,重新搜索 vm.getData() vm.initTable() } }, showTab:function(){ }, backClick:function(){ var vm=this if (reqList.length == 1) { history.go(-1); } else { var preInfo = reqList.pop(); var info = reqList[reqList.length - 1]; vm.areaLevel = info.areaLevel; vm.level = info.level; vm.area = info.area; vm.lowLevel = info.lowLevel; vm.getData() vm.$refs.tableRef0.changeTab({level:vm.level,lowlevel:vm.lowLevel}) //表格tab } }, bindEvent:function(){ var vm=this //监听后退按钮的操作 EventBus.$on("back-click", function (arg) { EventBus.$emit('update-statistics-time', {}); //更新统计时间 vm.backClick() }); //监听页面刷新 EventBus.$on("refresh-click", function (arg) { EventBus.$emit('update-statistics-time', {}); //更新统计时间 loadData([0, 1,2,3,4], vm); }); $("#main").removeClass("c-hide"); }, initTable:function(){ var vm=this vm.$refs.tableRef1.initTable({ //表格表头 headers:[{thead:"疾病名称",param:"name",canclick:true,style:{width:'260px'}},{thead:"工单量(个)",param:"orderCount"}], }) vm.$refs.tableRef2.initTable({ //表格表头 headers:[{thead:"服务项目",param:"name",canclick:true,style:{width:'260px'}},{thead:"使用人数(人)",param:"patientCount"},{thead:"工单量(个)",param:"orderCount"}], }) vm.$refs.tableRef3.initTable({ //表格表头 headers:[{thead:"药品",param:"name",canclick:true,style:{width:'260px'}},{thead:"使用人数(人)",param:"patientCount"},{thead:"工单量(个)",param:"orderCount"}], }) vm.$refs.tableRef0.initTable({ tabList:[{name:"各区",level:"4",lowlevel:"3",isShow:true},{name:"社区",level:"3",lowlevel:"2",isShow:true},{name:"团队",level:"2",lowlevel:"1",isShow:true}], //表格表头 headers:[{thead:"名称",param:"name",canclick:true},{thead:"合计(个)",param:"all"},{thead:"待派单(个)",param:"waitinglist"},{thead:"待接单(个)",param:"waitingorder"}, // {thead:"已接单(个)",param:"waitingservice"}, {thead:"待服务(个)",param:"waitingpay"},{thead:"待评价(个)",param:"waitingcomment"},{thead:"已完成(个)",param:"completed"},{thead:"评价均分(分)",param:"evaluateSplit"}], tabnumber:vm.tabnumber }) }, }, }) function initData(vm) { //获得缓存中缓存的角色权限 var userRole = window.sessionStorage.getItem("selectedRole"); if (!userRole) { return false; } vm.userRole = JSON.parse(userRole); //level:2、市,3、区,4、社区,5、团队 vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4; vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2; // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1; vm.initarea =vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数 //初始化时间 var now = new Date(); vm.end = new Date().format("yyyy-MM-dd"); var start= new Date(); start.setDate(1) vm.start = start.format("yyyy-MM-dd") vm.initDate=vm.dateValue=now.format("yyyy-MM") vm.initTable() } function initReqParams(vm) { var reqParam = [{ url: "doctor/statisticAnalyze/getDoorDiagnosisAnalysis", //疾病列表 reqType: 'get', data:{ area: vm.area, level: vm.areaLevel, //等级,2市 3区 4社区 5团队 page: vm.tableParams[0].page, pageSize: vm.pageSize, startDate:vm.start, endDate: vm.end }, },{ url: "doctor/statisticAnalyze/getDoorDrugCodeAnalysis", //药品分析列表 reqType: 'get', data:{ area: vm.area, level: vm.areaLevel, //等级,2市 3区 4社区 5团队 page: vm.tableParams[1].page, pageSize: vm.pageSize, subjectClass: "010", startDate:vm.start, endDate:vm.end, }, },{ url: "doctor/statisticAnalyze/getDoorDrugCodeAnalysis", //服务项列表 reqType: 'get', data:{ area: vm.area, level: vm.areaLevel, //等级,2市 3区 4社区 5团队 page: vm.tableParams[2].page, pageSize: vm.pageSize, subjectClass: "020", startDate:vm.start, endDate:vm.end, }, },{ url: "doctor/statisticAnalyze/doorAggregateAnalysis", //头中部数据 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 }, },{ url: "doctor/statisticAnalyze/order_lowlevel_all", //工单列表--表格 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.level, //2、市,3、区,4、社区,5、团队 sort: 1, lowLevel:vm.lowLevel||"", //等级 1:团队 2社区机构 3区级 4市级 }, },] return reqParam; } function loadData(loadArr, vm) { //获取其他请求的参数 var reqParams = initReqParams(vm), reqPromise = [], newArr = []; //记录非顶部请求的请求数组 for (i = 0; i < loadArr.length; i++) { var j = loadArr[i]; var param = reqParams[j]; reqPromise.push(httpRequest.get(param.url, { data: param.data })); newArr.push(loadArr[i]); } vm.isloading=true if (reqPromise.length > 0) { Promise.all(reqPromise).then(function (ress) { var res1, res2, res3, res4, res5; for (var i = 0; i < loadArr.length; i++) { var j = loadArr[i] + 1; if (j == 1) { res1 = ress[i]; } if (j == 2) { res2 = ress[i]; } if (j == 3) { res3 = ress[i]; } if (j == 4) { res4 = ress[i]; } if (j == 5) { res5 = ress[i]; } } if (res4 && res4.status == 200) { vm.topData=res4.data // vm.topData.evaluateSplit=parseFloat(vm.topData.evaluateSplit).toFixed(2) var voucherList=_.map(vm.topData.voucherList,function(item,index){ return { code:item.slaveKey1, amount:item.result1, name:item.slaveKey1Name, } }) if(voucherList.length==0||(voucherList.length==1&&!voucherList[0].name)){ vm.pieShow=false }else{ vm.pieShow=true } setTimeout(function(){ //服务人群分析-饼图 handlePieData({elId:"pieChart",arry: voucherList, title:{},colors: colors,position:['30%', '51%']}) },10) } if (res5 && res5.status == 200) { vm.tabledata0=listHandle(res5.data["index_121"],"all", vm); } if (res1 && res1.status == 200) { if(vm.tableParams[0].page==1){ vm.diagnosisList=[] } vm.diagnosisList=listHandle(vm.diagnosisList.concat(res1.data),"orderCount",vm) vm.tableParams[0].isloading=false if(res1.data.length