var reqList = [],reqLists = [[],[],[],[]]; //记录请求的参数和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, //加载中 pageData4:{}, pageData3:{}, pageData2:{}, pageData1:{}, pageData:{}, tabledata01:[], tabledata02:[], tabledata1:[], tabledata2:[], hastopbar1:true, hastopbar2:true, slaveKey1_1:"", slaveKey1_2:"", reqListLength8:1, reqListLength9:1, reqListLength10:1, reqListLength11:1, ttab:1, tbtab:1, ltabList:[{},{indexNames:{'turnUpList':"上转人次",'rehabilitationList':'康复下转人次'},xDatas:{},yDatas:{},names:[]}, {indexNames:{'totalServiceList':"总服务人次"},xDatas:{},yDatas:{},names:[]},], selDateType:undefined, // 1-日,2-周, 3-月 informationShow:true, information:{code:"1",title:"专病分析",name:"zbfx",tip:"专病分析为统计当前年度至今各个专病康复管理业务动态"}, optionsName:[], valueName:"", ptab:1, //请求页面所需参数 levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比 areaLevel:"", // 2、市,3、区,4、社区,5、团队\ initareaLevel:"", initlevel: '', initarea: '', level: '', area: '', areaTitle: '', lowLevel:3, initlowLevel:3, selectedDateType: 1, //折线图坐标值1-日,2-周,3-月 lowCode: '', chooseYear: '', start: "", end: "", userRole: '', reqListLength:1, activeAreaIndex:0, hopitalList:[], chopitalList:[], hospitalItem:{}, hospitalCode:"", tabnumber:3, activeIndex:0, isHospital:false, //判断是否切换到医院权限 }, components: { vuedals: Vuedals.Component }, mounted: function () { var vm=this //初始化数据 initData(vm); vm.bindEvent() }, watch:{ areaTitle:function(val){ //更新区域名称 EventBus.$emit('update-area-name', { 'areaName': val }); }, chooseYear:function(val){ //更新年份 EventBus.$emit('update-statistics-year', { 'selectDate': val }); }, }, methods: { getData:function(isNext,index){ //是否下转 var vm = this var params={ areaLevel: vm.areaLevel, level: vm.level, area: vm.area, endDate: vm.end, startDate: vm.start, lowLevel: vm.lowLevel, index:index } if(index){ loadData([index], vm); }else{ loadData([0,1,2,3,4,5,6,7,8,9,10,11], vm); //刷新数据 } if(isNext){ //存储请求所带的参数 reqList.push(params); if(index){ reqLists[index-8].push(params) vm["reqListLength"+index] = reqLists[index-8].length+1 } } }, //表格tab切换/下转 getnewdata:function(arg,index){ var vm = this 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 } if(arg.lowLevel){ vm.lowLevel=arg.lowLevel }else{ if(vm.areaLevel){ vm.lowLevel=arg.area == '350200' ? 3 : vm.area.length == 6 ? 4 : 5; }else{ vm.lowLevel = arg.lowLevel || "" } } vm.getData(arg.level,index) //有传level,说明是下转 }, getnewdata1:function(arg){ var vm = this if(vm.hastopbar1){ //服务项时 vm.hastopbar1 = false vm.slaveKey1_1 = arg.area vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel vm.getData(true,8) }else{ vm.getnewdata(arg,8) } }, getnewdata2:function(arg){ var vm = this if(vm.hastopbar2){ //服务项时 vm.hastopbar2 = false vm.slaveKey1_2 = arg.area vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel vm.getData(true,9) }else{ vm.getnewdata(arg,9) } }, getnewdata01:function(arg){ var vm = this vm.getnewdata(arg,10) }, getnewdata02:function(arg){ var vm = this vm.getnewdata(arg,11) }, backClickHandel:function(index,lIndex,refIndex){ var vm=this var hasIndex = _.findLastIndex(reqList,{index:index}) reqList.splice(hasIndex,1); var preInfo = reqLists[lIndex].pop(); var info = reqLists[lIndex][reqLists[lIndex].length - 1]; if(reqLists[lIndex].length==0){ if(refIndex=='1'||refIndex=='2'){ vm["hastopbar"+refIndex] = true vm["slaveKey1_"+refIndex] = "" info = preInfo }else{ info = reqList[0] } } vm.areaLevel = info.areaLevel; vm.level = info.level; vm.area = info.area; vm.lowLevel = info.lowLevel; vm["reqListLength"+index] = reqLists[lIndex].length+1 vm.getData(false,index) vm.$refs["tableRef_"+refIndex].changeTab({level:vm.level,lowlevel:vm.lowLevel}) //表格tab }, backClick2:function(){ var vm=this vm.backClickHandel(10,2,'01') }, backClick3:function(){ var vm=this vm.backClickHandel(11,3,'02') }, backClick0:function(){ var vm=this vm.backClickHandel(8,0,'1') }, backClick1:function(){ var vm=this vm.backClickHandel(9,1,'2') }, //时间选择 changeDate: function () { var vm=this //搜索时,取消下转记录 vm.area=vm.initarea vm.areaLevel=vm.initareaLevel vm.level=vm.initlevel vm.lowLevel = vm.initlowLevel reqHistoryInit(vm) vm.getData(true) vm.initTable() }, //获取疾病筛查表 getOptionsName:function(){ var vm=this vm.optionsName = [{code:"",name:"全部病种"}] params = { area:vm.initarea, level:vm.initareaLevel }; statisticAPI.specialistAnalysisDiseaseType(params).then(function(res) { if(res.status == 200) { vm.optionsName = [{code:"",name:"全部病种("+res.data.length+"个)"}] vm.optionsName=vm.optionsName.concat(res.data) } else { vm.$message.error(res.msg) } }) }, //筛查表切换 seleName:function(){ var vm=this vm.changeDate() }, //切换line showTab:function(ptab){ var vm=this if(ptab){ vm.ptab=ptab } setTimeout(function(){ EventBus.$emit("draw-line-chart", { panelName : "分级诊疗情况", quotaNames : vm.ltabList[vm.ptab].names, xData : vm.ltabList[vm.ptab].xDatas[0], yDatas : vm.ltabList[vm.ptab].yDatas, colors : ["#17b3ec",'#FF9526'], nowlineid : 'lineChart'+vm.ptab, noDateType: true, chartheight:"260", unit:"人", noshowDate:false, startDate:vm.start, endDate:vm.end, }); },300) }, showtTab:function(ttab){ var vm=this }, showtbTab:function(tbtab){ var vm=this }, backClick:function(){ var vm=this if(vm.isHospital){ initData(vm) }else{ history.go(-1); } // if (reqList.length == 1) { // history.go(-1); // } else { // var lastInfo = reqList[reqList.length-1] // if(lastInfo.index){ // var idx = lastInfo.index - 8 // vm["backClick"+idx]() // } // } }, 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', {}); //更新统计时间 initData(vm) }); //弹出筛选框 EventBus.$on('filter-click', function(arg) { //弹框显示筛选条件 Vuedals.Bus.$emit('new', { title: '条件筛选', onClose:function(data){ vm.chooseYear = data.chooseYear; if(vm.chooseYear){ vm.selDateType = undefined vm.end = getEndDate(vm.chooseYear) vm.start = getDateBefore(30) }else{ vm.selDateType = "按"+data.dimensionVal vm.end = getDateBefore(0) if(data.dimensionVal == '日'){ vm.start = getDateBefore(1) }else if(data.dimensionVal == '周'){ vm.start = getDateBefore(7) }else if(data.dimensionVal == '月'){ vm.start = getDateBefore(30) } } vm.changeDate() EventBus.$emit('update-statistics-time', {});//更新统计时间 //更新维度名称 EventBus.$emit('update-dimension-name', { "dimensionVal" : vm.selDateType }); }, component: 'special-filter', props: { selectedYear: vm.chooseYear, minYear:2020, dimensionValList:['日','周','月'], } }); }); $("#main").removeClass("c-hide"); }, initTable:function(){ var vm=this var tabList1 = [{name:"各区",level:"4",lowlevel:"3",isShow:true},{name:"医院",level:"3",lowlevel:"4",isShow:true},{name:"团队",level:"2",lowlevel:"5",isShow:true}] var tabList2 = [{name:"各区",level:"4",lowlevel:"3",isShow:true},{name:"社区",level:"3",lowlevel:"4",isShow:true},{name:"团队",level:"2",lowlevel:"5",isShow:true}] var tabList01 = JSON.parse(JSON.stringify(tabList1)),tabList02 = JSON.parse(JSON.stringify(tabList2)) vm.$refs.tableRef_01.initTable({ //表格表头 tabList:tabList01, headers:[{thead:"地区",param:"name",canclick:true},{thead:"共管患者数",param:"coManagementNum"}, {thead:"转诊人数",param:"referralNum"},{thead:"下转人数",param:"rehabilitationNum"},{thead:"总服务人数",param:"totalServiceNum"}], tabnumber:vm.tabnumber, }) vm.$refs.tableRef_02.initTable({ //表格表头 tabList:tabList02, headers:[{thead:"地区",param:"name",canclick:true},{thead:"共管患者数",param:"coManagementNum"}, {thead:"转诊人数",param:"referralNum"},{thead:"下转人数",param:"rehabilitationNum"},{thead:"总服务人数",param:"totalServiceNum"}], tabnumber:vm.tabnumber, }) var tabItem = {name:"服务项名称"} tabList1.splice(3-vm.tabnumber,0,tabItem) tabList2.splice(3-vm.tabnumber,0,tabItem) vm.$refs.tableRef_1.initTable({ //表格表头 tabList:tabList1, headers:[{thead:"服务项名称",param:"name",canclick:true},{thead:"合计",param:"num"}], tabnumber:vm.tabnumber+1, }) vm.$refs.tableRef_2.initTable({ //表格表头 tabList:tabList2, headers:[{thead:"服务项名称",param:"name",canclick:true},{thead:"合计",param:"num"}], tabnumber:vm.tabnumber+1, }) }, comfireHospital:function(){ var vm = this if(vm.hospitalCode){ vm.loadding = true vm.isHospital = true //level:2、市,3、区,4、社区,5、团队 vm.initareaLevel = vm.areaLevel = vm.hospitalCode == '350200' ? 2 : vm.hospitalCode.length == 6 ? 3 : 4; vm.initlevel = vm.level = vm.hospitalCode == '350200' ? 4 : vm.hospitalCode.length == 6 ? 3 : 2; vm.initlowLevel = vm.lowLevel = vm.hospitalCode == '350200' ? 3 : vm.hospitalCode.length == 6 ? 4 : 5; vm.initarea =vm.area = vm.hospitalCode; vm.areaTitle = vm.hospitalItem.name; if(vm.activeAreaIndex=="1"){ //0:等级医院 1社区医院 vm.tbtab = 2 }else{ vm.tbtab = 1 } vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数 //初始化时间 vm.chooseYear = getSignDate() vm.selDateType = undefined vm.end = getEndDate(vm.chooseYear) vm.start = getStartDate(vm.chooseYear) vm.changeDate() vm.getOptionsName() //获取搜索疾病列表 vm.initTable() } }, hopitalListShow:function(){ var vm = this //弹框显示筛选条件 Vuedals.Bus.$emit('new', { title: '条件筛选', onClose:function(data){ if(data){ vm.hospitalItem = data.hospitalItem vm.hospitalCode = data.hospitalCode vm.activeAreaIndex = data.activeName vm.comfireHospital() } }, component: 'hospital-filter', // props: { // chopitalList:vm.chopitalList, // hopitalList:vm.hopitalList, // } props: { initarea:this.initarea } }); } } }) 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.initlowLevel = vm.lowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 4 : 5; vm.initarea =vm.area = vm.userRole.code; vm.areaTitle = vm.userRole.name; if(vm.initlevel==2){ if(vm.userRole.roleType == '2'){ vm.tbtab = 2 }else if(vm.userRole.roleType == '1'){ vm.tbtab = 1 } }else{ if(vm.isHospital){ vm.isHospital = false vm.hospitalCode = "" vm.hospitalItem = {} }else{ // selectHospital(vm,1,'hopitalList') // selectHospital(vm,2,'chopitalList') } } vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数 var url = location.search; //获取url中"?"符后的字串 if (url.indexOf("?") != -1) { //判断是否有参数 var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串 strs = str.split("="); //用等号进行分隔 (因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔) vm.valueName = strs[1] } if(vm.valueName == '15') { $('#title').html('慢阻肺') }else if(vm.valueName == '3') { $('#title').html('冠心病') }else if(vm.valueName == '9') { $('#title').html('脑卒中') }else if(vm.valueName == '10') { $('#title').html('慢性前列腺') }else if(vm.valueName == '11') { $('#title').html('肺癌') }else if(vm.valueName == '13') { $('#title').html('慢性乳腺疾病') }else if(vm.valueName == '14') { $('#title').html('慢性胃肠病') }else if(vm.valueName == '16') { $('#title').html('慢性肝病') }else if(vm.valueName == '17') { $('#title').html('慢性妇科炎症') }else if(vm.valueName == '12') { $('#title').html('慢性肾病') }else{ $('#title').html('疾病筛查分析') } //初始化时间 vm.chooseYear = getSignDate() vm.selDateType = undefined vm.end = getEndDate(vm.chooseYear) vm.start = getDateBefore(30) vm.changeDate() vm.getOptionsName() //获取搜索疾病列表 vm.initTable() } function reqHistoryInit(vm){ reqList = [] reqLists = [[],[],[],[]] _.each(reqLists,function(item,idx){ var index = 8+idx vm["reqListLength"+index] = item.length+1 }) vm.slaveKey1_1 = "" vm.slaveKey1_2 = "" vm.hastopbar1 = true vm.hastopbar2 = true } function initReqParams(vm) { var param = { startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, } var reqParam = [{ url: "/specialistStatistics/specialistAnalysisHead", //头部 reqType: 'get', data:{ diseaseType:vm.valueName, area: vm.area, level: vm.areaLevel, //2、市,3、区,4、社区,5、团队 }, },{ url: "/specialistStatistics/specialistAnalysisHeadCount", //头部统计 reqType: 'get', data:param, },{ url: "/specialistStatistics/diagnosisTreatment", //分级诊疗形式(转诊趋势) reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, interval:1, type:1, //转诊趋势 }, },{ url: "/specialistStatistics/diagnosisTreatment", //分级诊疗形式(服务人数) reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, interval:1, type:2, //服务人数 }, },{ url: "/specialistStatistics/diseaseTypeAnalysis", //疾病类型分析 reqType: 'get', data:param, },{ url: "/specialistStatistics/dailyHealthServices", //日常健康服务 reqType: 'get', data:param, },{ url: "/specialistStatistics/onlineDiagnosisTreatment", //在线诊疗情况 reqType: 'get', data:param, },{ url: "/specialistStatistics/rehabilitationPhoneRange", //电话/短信关怀率 reqType: 'get', data:param, },{ url: "/specialistStatistics/coManagementRehabilitation", //康复共管情况 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, type:1, //等级医院 slaveKey1:vm.slaveKey1_1, lowLevel:vm.slaveKey1_1?vm.lowLevel:"" }, },{ url: "/specialistStatistics/coManagementRehabilitation", //康复共管情况 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, type:2, //社区医院 slaveKey1:vm.slaveKey1_2, lowLevel:vm.slaveKey1_2?vm.lowLevel:"" }, },{ url: "/specialistStatistics/serviceRankingAnalysis", //-专病服务排名分析/医院总体服务情况 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, type:1, lowLevel:vm.lowLevel }, },{ url: "/specialistStatistics/serviceRankingAnalysis", //-专病服务排名分析/医院总体服务情况 reqType: 'get', data:{ startDate: vm.start, endDate: vm.end, area: vm.area, level: vm.areaLevel, diseaseType:vm.valueName, type:2, lowLevel:vm.lowLevel }, }]; 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, res6, res7, res8, res9, res10, res11, res12; 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 (j == 6) { res6 = ress[i]; } if (j == 7) { res7 = ress[i]; } if (j == 8) { res8 = ress[i]; } if (j == 9) { res9 = ress[i]; } if (j == 10) { res10 = ress[i]; } if (j == 11) { res11 = ress[i]; } if (j == 12) { res12 = ress[i]; } } if(res1&& res1.status == 200){ vm.pageData=res1.data } if(res2&& res2.status == 200){ vm.pageData1=res2.data } if(res3&& res3.status == 200){ handleSecondPanelData(res3.data ,1, vm) } if(res4&& res4.status == 200){ handleSecondPanelData(res4.data ,2, vm) } if(res5&& res5.status == 200){ var barData = {rehabilitationNum:[],rehabilitationTimes:[]} _.each(res5.data,function(item,index){ barData.rehabilitationNum.push({ range:item.name, amount:item.num }) barData.rehabilitationTimes.push({ range:item.name, amount:item.times }) }) getBarData({elId:'barChart', data:barData, indexNames:{"rehabilitationNum":"下转人数","rehabilitationTimes":"下转人次"},selectedDateType:vm.selectedDateType,hasLegend:true,colors:["#17b3ec",'#20D7AD'],units:{"下转人数":"人","下转人次":"人次"}}) } if(res6&& res6.status == 200){ vm.pageData2=res6.data } if(res7&& res7.status == 200){ vm.pageData3=res7.data } if(res8&& res8.status == 200){ vm.pageData4=res8.data } if(res9&& res9.status == 200){ var data9 = _.map(res9.data,function(item){ item.num = item.num||item.amount||0 return item }) vm.tabledata1=listHandle(data9,"num"); } if(res10&& res10.status == 200){ var data10 = _.map(res10.data,function(item){ item.num = item.num||item.amount||0 return item }) vm.tabledata2=listHandle(data10,"num"); } if(res11&& res11.status == 200){ vm.tabledata01=listHandle(res11.data,"totalServiceNum"); } if(res12&& res12.status == 200){ vm.tabledata02=listHandle(res12.data,"totalServiceNum"); } vm.isloading=false }) } } function handleSecondPanelData(data,index, vm) { var xDatas = [], yDatas = [], names = [] for(var p in data){ names.push(vm.ltabList[index].indexNames[p]); xData = _.map(data[p], function(o){ return o.range; }); yData = _.map(data[p], function(o){ return o.amount; }); xDatas.push(xData); yDatas.push(yData); } vm.ltabList[index].xDatas = xDatas vm.ltabList[index].yDatas = yDatas vm.ltabList[index].names = names if(vm.ptab == index){ vm.showTab() } } function listHandle(list, sort){ var topArr = [],newList=[]; if(list.length==1&&!list[0].name){ list=[] } topArr = soreRank(getKeyValueArr(list, sort||'total')); newList = _.map(list, function(o, index){ o.rank=topArr[index] return o }); return newList }