Vue.use(Vuedals.default); new Vue({ el: "#main", data: { height:"", isloading:false, //加载中 start:"", end:"", tabledata:[], //表格数据 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:"", years:[], chooseYear: '', userRole: '', tableHeader:[], pickerOptions:{ disabledDate:function(time) { return time.getTime() > Date.now() }, }, radio:'1', searchJson:{}, currentPage:1, currentSize:10, datatotal:0, rangeList:[], rangeCode:"", areaList:[], areaCode:"", communityList:[{code:"",name:"全部"}], communityCode:"", teamList:[{code:"",name:"全部"}], teamCode:"", fullscreenLoading:false, }, components: { vuedals: Vuedals.Component }, watch: { rangeCode: function (val) { var vm=this if(vm.initlevel != 2){ vm.communityCode="" } vm.teamCode="" }, areaCode:function(val){ var vm=this vm.selChange(3) }, communityCode:function(val){ var vm=this vm.selChange(5) }, }, mounted: function () { var vm=this //初始化数据 initData(vm); vm.height = document.body.offsetHeight - 85 window.onresize = function () { vm.height = document.body.offsetHeight - 85 console.log(vm.height) } }, methods: { beforeReq:function(flag){ var vm=this,startDate="",endDate="" if(vm.radio=="1"){ if(vm.chooseYear == 2022) { startDate = '2022-07-01' endDate = '2022-12-31' }else if(vm.chooseYear > 2022) { startDate = vm.chooseYear + '-01-01' endDate = getEndDate(vm.chooseYear) }else{ startDate = getStartDate(vm.chooseYear) endDate = getEndDate(vm.chooseYear) } }else{ if(!vm.start&&!vm.end){ this.$message({ message: '请选择创建时间', type: 'warning' }); return false }else{ if(vm.start>vm.end){ this.$message({ message: '开始时间应早于结束时间', type: 'warning' }); return false }else{ startDate = vm.start endDate = vm.end } } } return {start:startDate,end:endDate} }, searchHandle:function(){ var vm = this,searchJson=undefined searchJson = vm.beforeReq() if(searchJson){ vm.currentPage = 1 vm.searchJson = { startDate:searchJson.start, endDate:searchJson.end, range:vm.rangeCode, team:vm.teamCode, hospital:vm.communityCode, area:vm.areaCode=="350200"?"":vm.areaCode, size:vm.currentSize, page:vm.currentPage, } vm.getWHFInfoList() } }, getWHFInfoList:function(){ var vm = this vm.isloading = true var params=JSON.parse(JSON.stringify(vm.searchJson)) params.page = vm.currentPage statisticAPI.getWHFInfoList(params).then(function(res){ if(res.status == 200) { if(res.data){ vm.tabledata = res.data.consultTeams vm.datatotal = res.data.consultTeamsSize } } else { vm.$message.error(res.msg) } vm.isloading = false }) }, exportHandle:function(){ var vm =this var vm = this,searchJson=undefined vm.fullscreenLoading = true searchJson = vm.beforeReq() if(searchJson){ var areaCode = vm.areaCode=="350200"?"":vm.areaCode statisticAPI.appAdminToExcel({ startDate: searchJson.start, endDate: searchJson.end, range: vm.rangeCode, area: areaCode, hospital: vm.communityCode, team: vm.teamCode, }, "咨询未及时回复.xls").then(function(res){ vm.fullscreenLoading = false // toastr.info("导出成功") // var blob = new Blob(["Hello, world!"]); // FileSaver.saveAs(blob, "hello world.txt"); // console.log(res) // FileSaver() }) .catch(function(err){ toastr.info(err) vm.fullscreenLoading = false console.error(err) }) // var areaCode = vm.areaCode=="350200"?"":vm.areaCode // let str = httpRequest.server + 'third/door/appAdminToExcel?startDate='+searchJson.start+'&endDate='+searchJson.end+'&range='+vm.rangeCode+'&area='+areaCode+'&hospital='+vm.communityCode+'&team='+vm.teamCode // console.log(str) // window.location.href = str } }, backClick:function(){ history.go(-1); }, 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) }); $("#main").removeClass("c-hide"); }, handleCurrentChange:function(val) { this.currentPage = val this.getWHFInfoList() }, //获取省市区 type:区3 getDistrict: function(type,code,name) { var vm=this,list = [],param="" if(type == 3){ list = [{code:code,name:name}] param = "area" }else if(type == 5){ list = [{code:"",name:"全部"}] param = "community" } var params={ type:type,code:code } homeAPI.getDistrict(params).then(function(res) { if(res.status == 200) { vm[param+"List"]=list.concat(res.list) vm[param+"Code"]=vm[param+"List"][0].code } else { vm.$message.error(res.msg) } }) }, selChange:function(type){ var vm=this,name="" if(type == 3){ vm.initSelOption("community") vm.initSelOption("team") vm.getCommunityHospital() }else if(type == 5){ vm.initSelOption("team") vm.teamListByArea() } }, initSelOption:function(param){ var vm=this vm[param+"List"]=[{code:"",name:"全部"}] if(param == "team"){ vm[param+"List"]=[{id:"",name:"全部"}] } vm[param+"Code"]=vm[param+"List"][0].code||vm[param+"List"][0].id }, getCommunityHospital:function() { var vm=this,list = [{code:"",name:"全部"}],param="community" homeAPI.getCommunityHospital({area:vm.areaCode=='350200'?"":vm.areaCode}).then(function(res) { if(res.status == 200) { vm[param+"List"]=list.concat(res.data) vm[param+"Code"]=vm[param+"List"][0].code } else { vm.$message.error(res.msg) } }) }, teamListByArea:function() { var vm=this,list = [{id:"",name:"全部"}],param="team" homeAPI.teamListByArea({area:vm.areaCode=='350200'?"":vm.areaCode,hospital:vm.communityCode}).then(function(res) { if(res.status == 200) { vm[param+"List"]=list.concat(res.data) vm[param+"Code"]=vm[param+"List"][0].id } else { vm.$message.error(res.msg) } }) } }, }) 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.rangeList=[{name:"按区",code:"town"},{name:"按社区",code:"hospital"},{name:"按团队",code:"team"}] if(vm.initlevel == 4){ //市获取区 vm.getDistrict(3,vm.initarea,vm.areaTitle.substr(0,3)) vm.rangeCode = vm.rangeList[0].code }else if(vm.initlevel == 3){ //区获取社区 vm.areaList = [{code:vm.initarea,name:vm.areaTitle}] vm.areaCode = vm.initarea vm.rangeCode = vm.rangeList[0].code }else if(vm.initlevel == 2){ //社区获取团队 vm.communityList = [{code:vm.initarea,name:vm.areaTitle}] vm.communityCode = vm.initarea vm.rangeList.shift() vm.rangeCode = vm.rangeList[0].code } vm.searchJson.range = vm.rangeCode //初始化时间 var now = new Date(); vm.end = now.format("yyyy-MM-dd") var start = now.getTime() - 30*24*60*60*1000 vm.start = new Date(start).format("yyyy-MM-dd") vm.nowyear = vm.chooseYear = now.getFullYear() vm.nowmonth = now.getMonth()+1 vm.years = [] for(i=vm.nowyear; i>=2016; i--){ vm.years.push(i) } vm.tabledata = [] vm.bindEvent() }