/** * 顶部header */ import Vue from 'vue' Vue.component("screen-header", { template: `
北跨泾河-产发工程数字管理平台
项目概况
项目详情
安全管理
质量管理
进度管理
视频管理
工程管理
  • {{item.text}}
  • {{item.text}}
{{date}}
{{time}}
11~25℃
`, props: { nav:{ type:Number }, red:{ type:String }, item:{ type:Number }, }, data() { return { dept1:'', dept2:'', showSel1:false, showSel2:false, data:[], depts:[], timerID:undefined, time: '', date: '', week:'', selDept:'', localStorage1: JSON.parse(localStorage.getItem("data1")), localStorage2: JSON.parse(localStorage.getItem("data2")), isFullScreen:false } }, mounted(){ this.timerID = setInterval(this.updateTime, 1000); this.updateTime(); this.init() this.$api.dept.list().then(d=>{ this.depts=[{text:'产发集团',id:0},...(d?.data||[]).map(it=>{ it.text=it.deptName; it.id=it.deptId; return it; })] this.deptChange(); }); }, methods: { toggleFullScreen(){ let el=document.body; this.$toggleFullScreen(el); setTimeout(()=>{ this.isFullScreen=document.fullscreenElement==el; },400); }, init(){ try{ this.localStorage1=JSON.parse(localStorage.getItem("data1")) this.localStorage2=JSON.parse(localStorage.getItem("data2")) }catch(e){ } if(!this.localStorage1){ this.localStorage1={ } } if(!this.localStorage2){ this.localStorage2={} } this.dept1=this.localStorage1?.text||''; this.dept2=this.localStorage2?.text||''; if(this.dept1){ this.loadProject(true); } }, deptChange(){ let tmps=this.depts.filter(d=>d.text==this.dept1); if(tmps.length>0){ this.$bus.$emit("deptChange",tmps[0]) } }, //页面条状 pageJump(n,url,itemurl){ if(n != this.nav){ if(this.localStorage1.type == 1){ if(url){ location.href = url }else{ this.$notify({ title: '提示', message: '页面开发中,敬请期待!', type: 'warning' }); } }else{ if(n==5){ location.href = url }else{ if(itemurl){ location.href = itemurl }else{ this.$notify({ title: '提示', message: '页面开发中,敬请期待!', type: 'warning' }); } } } } }, showScreenUlSel1(){ this.showSel1 = true }, showScreenUlSel2(){ this.showSel2 = true }, hideScreenUlSel1(){ this.showSel1 = false }, hideScreenUlSel2(){ this.showSel2 = false }, setScreenLiSel1(item){ localStorage.setItem("data1",JSON.stringify(item)) this.localStorage1=JSON.parse(localStorage.getItem("data1")) this.$emit('itemdata',item); this.showSel1 = false this.dept1=item.text; this.deptChange(); this.loadProject(); }, loadProject(init){ this.$api.project.findProjectByDept(this.localStorage1.id||0).then(d=>{ let objs=(d?.data||[]).map(it=>{ it.text=it.projectName; return it; }).filter(it=>+it.progressVisible==0); this.data=[{id:0,text:'所有项目'},...objs]; this.$bus.$emit("loadProjects",this.data); if(this.data.length>0){ this.setScreenLiSel2(this.data[0],init); }else{ this.setScreenLiSel2(null); } }); }, setScreenLiSel2(item,init){ if(item){ this.showSel2 = false; if(!init){ localStorage.setItem("data2",JSON.stringify(item)) this.localStorage2=JSON.parse(localStorage.getItem("data2")) this.$emit('itemdata',item); this.dept2=item.text; } this.$bus.$emit("projectChange",this.localStorage2); }else{ localStorage.removeItem("data2"); this.localStorage2={}; this.showSel2 = false; this.dept2=''; } }, //时间方法 updateTime(){ var cd = new Date(); this.time = this.zeroPadding(cd.getHours(), 2) + ':' + this.zeroPadding(cd.getMinutes(), 2) + ':' + this.zeroPadding(cd.getSeconds(), 2); this.date = this.zeroPadding(cd.getFullYear(), 4) + '年' + this.zeroPadding(cd.getMonth()+1, 2) + '月' + this.zeroPadding(cd.getDate(), 2)+'日'; }, zeroPadding(num, digit) { var zero = ''; for(var i = 0; i < digit; i++) { zero += '0'; } return (zero + num).slice(-digit); } }, watch:{ } })