jhbigscreen/src/components/header.js

244 lines
13 KiB
JavaScript
Raw Normal View History

2023-08-10 01:16:23 +08:00
/**
* 顶部header
*/
import Vue from 'vue'
Vue.component("screen-header", {
template: `
<div :class="red?'head-title red-head':'head-title'">
<div class="head-title-label">
北跨泾河-产发工程数字管理平台
</div>
<div class="head-title-tab">
<div :class="nav==1?'head-nav active':'head-nav'" @click="pageJump(1,'index.html','index.html')">项目概况</div>
<div :class="nav==2?'head-nav active':'head-nav'" @click="pageJump(2,'projectDetail.html','projectDetail.html')">项目详情</div>
<div :class="nav==3?'head-nav active':'head-nav'" @click="pageJump(3,'projectSafety.html','projectSafety.html')">安全管理</div>
<div :class="nav==4?'head-nav active':'head-nav'" @click="pageJump(4,'projectQuality.html','projectQuality.html')">质量管理</div>
<div :class="nav==5?'head-nav active':'head-nav'" @click="pageJump(5,'projectProgress.html','projectProgress.html')">进度管理</div>
<div :class="nav==6?'head-nav active':'head-nav'" @click="pageJump(6,'projectVideo.html','projectVideo.html')">视频管理</div>
2023-08-10 23:36:55 +08:00
<div :class="nav==7?'head-nav active':'head-nav'" @click="pageJump(7)">工程管理</div>
2023-08-10 01:16:23 +08:00
</div>
<div class="head-title-select" @mouseleave="hideScreenUlSel1" v-if="localStorage1">
<div class="head-select">
<input type="text" :value="dept1" @click="showScreenUlSel1" placeholder="请选择公司" readonly>
</div>
<el-collapse-transition>
<ul class="header-screen-ul" v-show="showSel1" ref="selectUl">
<li v-for="item in depts" @click="setScreenLiSel1(item)" :title="item.text" >{{item.text}}</li>
</ul>
</el-collapse-transition>
</div>
<div class="head-title-select" @mouseleave="hideScreenUlSel2" v-if="localStorage2">
<div class="head-select">
<input type="text" :value="dept2" @click="showScreenUlSel2" placeholder="请选择项目" readonly>
</div>
<el-collapse-transition>
<ul class="header-screen-ul" v-show="showSel2" ref="selectUl">
<li v-for="item in data" @click="setScreenLiSel2(item)" :title="item.text">{{item.text}}</li>
</ul>
</el-collapse-transition>
</div>
<div class="head-title-date">
<div class="head-title-time">
<div class="head-title-date-con">{{date}}</div>
<div class="head-title-time-con">{{time}}</div>
</div>
<div class="head-title-weather">
<img src="images/weather.png">
<span></span>
<span>11~25</span>
</div>
</div>
2023-08-27 22:39:11 +08:00
<i class="set-fullscreen set-font-size" style="margin-left: 16px;position: absolute;top: 4px;right: 16px;" @click="toggleFullScreen">
<svg class="icon" v-if="!isFullScreen" style="width: 24px; vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3304"><path d="M145.066667 85.333333h153.6c25.6 0 42.666667-17.066667 42.666666-42.666666S324.266667 0 298.666667 0H34.133333C25.6 0 17.066667 8.533333 8.533333 17.066667 0 25.6 0 34.133333 0 42.666667v256c0 25.6 17.066667 42.666667 42.666667 42.666666s42.666667-17.066667 42.666666-42.666666V145.066667l230.4 230.4c17.066667 17.066667 42.666667 17.066667 59.733334 0 17.066667-17.066667 17.066667-42.666667 0-59.733334L145.066667 85.333333z m170.666666 563.2L162.133333 802.133333l-76.8 76.8V725.333333C85.333333 699.733333 68.266667 682.666667 42.666667 682.666667s-42.666667 17.066667-42.666667 42.666666v256c0 25.6 17.066667 42.666667 42.666667 42.666667h256c25.6 0 42.666667-17.066667 42.666666-42.666667s-17.066667-42.666667-42.666666-42.666666H145.066667l76.8-76.8 153.6-153.6c17.066667-17.066667 17.066667-42.666667 0-59.733334-17.066667-17.066667-42.666667-17.066667-59.733334 0z m665.6 34.133334c-25.6 0-42.666667 17.066667-42.666666 42.666666v153.6l-76.8-76.8-153.6-153.6c-17.066667-17.066667-42.666667-17.066667-59.733334 0-17.066667 17.066667-17.066667 42.666667 0 59.733334l153.6 153.6 76.8 76.8H725.333333c-25.6 0-42.666667 17.066667-42.666666 42.666666s17.066667 42.666667 42.666666 42.666667h256c25.6 0 42.666667-17.066667 42.666667-42.666667v-256c0-25.6-17.066667-42.666667-42.666667-42.666666z m0-682.666667h-256c-25.6 0-42.666667 17.066667-42.666666 42.666667s17.066667 42.666667 42.666666 42.666666h153.6l-76.8 76.8-153.6 153.6c-17.066667 17.066667-17.066667 42.666667 0 59.733334 17.066667 17.066667 42.666667 17.066667 59.733334 0l153.6-153.6 76.8-76.8v153.6c0 25.6 17.066667 42.666667 42.666666 42.666666s42.666667-17.066667 42.666667-42.666666v-256c0-25.6-17.066667-42.666667-42.666667-42.666667z" fill="" p-id="3305"></path></svg>
<svg class="icon" v-else style="width: 24px; vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3952"><path d="M384 597.333333h-256c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666667h153.6L17.066667 947.2c-17.066667 17.066667-17.066667 42.666667 0 59.733333 17.066667 17.066667 42.666667 17.066667 59.733333 0L341.333333 742.4v153.6c0 25.6 17.066667 42.666667 42.666667 42.666667s42.666667-17.066667 42.666667-42.666667v-256c0-25.6-17.066667-42.666667-42.666667-42.666667z m358.4 85.333334h153.6c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666667h-256c-25.6 0-42.666667 17.066667-42.666667 42.666667v256c0 25.6 17.066667 42.666667 42.666667 42.666667s42.666667-17.066667 42.666667-42.666667V742.4l264.533333 264.533333c17.066667 17.066667 42.666667 17.066667 59.733333 0 17.066667-17.066667 17.066667-42.666667 0-59.733333L742.4 682.666667zM640 426.666667h256c25.6 0 42.666667-17.066667 42.666667-42.666667s-17.066667-42.666667-42.666667-42.666667H742.4L1006.933333 76.8c17.066667-17.066667 17.066667-42.666667 0-59.733333-17.066667-17.066667-42.666667-17.066667-59.733333 0L682.666667 281.6V128c0-25.6-17.066667-42.666667-42.666667-42.666667s-42.666667 17.066667-42.666667 42.666667v256c0 25.6 17.066667 42.666667 42.666667 42.666667z m-256-341.333334c-25.6 0-42.666667 17.066667-42.666667 42.666667v153.6L76.8 8.533333C59.733333 0 25.6 0 8.533333 8.533333 0 25.6 0 59.733333 8.533333 76.8L281.6 341.333333H128c-25.6 0-42.666667 17.066667-42.666667 42.666667s17.066667 42.666667 42.666667 42.666667h256c25.6 0 42.666667-17.066667 42.666667-42.666667v-256c0-25.6-17.066667-42.666667-42.666667-42.666667z" p-id="3953"></path></svg>
</i>
2023-08-10 01:16:23 +08:00
</div>
`,
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")),
2023-08-27 22:39:11 +08:00
isFullScreen:false
2023-08-10 01:16:23 +08:00
}
},
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: {
2023-08-27 22:39:11 +08:00
toggleFullScreen(){
let el=document.body;
this.$toggleFullScreen(el);
setTimeout(()=>{
this.isFullScreen=document.fullscreenElement==el;
},400);
},
2023-08-10 01:16:23 +08:00
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).then(d=>{
2023-08-17 22:47:44 +08:00
let objs=(d?.data||[]).map(it=>{
it.text=it.projectName;
return it;
}).filter(it=>+it.progressVisible==0);
this.data=[{id:0,text:'所有项目'},...objs];
2023-08-10 01:16:23 +08:00
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:{
}
})