123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- 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 - 125
- window.onresize = function () {
- vm.height = document.body.offsetHeight - 125
- console.log(vm.height)
- }
- vm.listFunction()
- },
- methods: {
- rangeCodeChange:function() {
-
- },
- parameter:function() {
- var vm = this
- var time = vm.beforeReq()
- var v = {
- signYear:vm.chooseYear,
- team:vm.teamCode,
- startDate:time.start,
- endDate:time.end,
- area:vm.areaCode=="350200"?"":vm.areaCode,
- hospital:vm.communityCode,
- range:vm.rangeCode,
- }
- return v
- },
- listFunction:function(){
- var vm = this
- vm.isloading = true
- statisticAPI.getAnnualAssessment(vm.parameter()).then(function(res){
- // console.log(res,"年度考核报表")
- if(res.status == 200) {
- vm.tabledata = res.data
- vm.isloading = false
- }else{
- toastr.error(res.msg)
- vm.isloading = false
- }
- })
- },
- beforeReq:function(flag){
- var vm=this,startDate="",endDate=""
- if(vm.radio=="2"){
- 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
- vm.listFunction()
-
- // 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
- var areaCode = vm.areaCode=="350200"?"":vm.areaCode
- vm.fullscreenLoading = true
- if(vm.datatotal.length!=0){
- statisticAPI.statisticsExportExportAnnualAssessment(vm.parameter(),"年度考核报表.xls").then(function(res){
- vm.fullscreenLoading = false
- // var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
- // FileSaver.saveAs(blob, "hello world.txt");
- // FileSaver()
- })
- .catch(function(err){
- toastr.info(err)
- vm.fullscreenLoading = false
- console.error(err)
- })
- // let str = httpRequest.server + 'statisticsExport/exportAnnualAssessment?signYear='+vm.chooseYear+
- // '&team='+vm.teamCode+'&area='+areaCode+'&hospital='+vm.communityCode+'&range='+vm.rangeCode
- // 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()
- }
|