| | |
| | | <a-row style="height: 100%"> |
| | | <a-col :span="7" class="header-left"> |
| | | <a-space> |
| | | <span v-if="!isSwitchChecked">开启功能</span> |
| | | <span v-else>关闭功能</span> |
| | | <span>功能开关</span> |
| | | <a-switch |
| | | checked-children="开" |
| | | un-checked-children="关" |
| | |
| | | <a-col :span="10" class="workshop-name">{{ workshopDetails.workshopName }}</a-col> |
| | | |
| | | <a-col :span="7" class="device-status-info"> |
| | | <!--<a-space v-for="item in deviceStatusList" :key="item.value" class="single-status-info"--> |
| | | <!--@click="handleScreenDevive(item)">--> |
| | | <!--<div :style="{color:item.checked?'#1890FF':'#fff'}">{{ item.label }}</div>--> |
| | | <!--<div class="status-square" :style="{ backgroundColor: item.color }"></div>--> |
| | | <!--<!–<a-checkbox :checked="item.checked" @change="checkboxChange(item)"></a-checkbox>–>--> |
| | | <!--<div>{{getDeviceNumberByStatus(item.value) }}</div>--> |
| | | <!--</a-space>--> |
| | | <a-space v-for="item in deviceStatusList" :key="item.value" class="single-status-info"> |
| | | <div :style="{color:item.checked?'#1890FF':'#fff'}">{{ item.label }}</div> |
| | | <div class="status-square" :style="{ backgroundColor: item.color }"></div> |
| | | <!--<a-checkbox :checked="item.checked" @change="checkboxChange(item)"></a-checkbox>--> |
| | | <div>{{getDeviceNumberByStatus(item.value) }}</div> |
| | | </a-space> |
| | | </a-col> |
| | |
| | | @click="openDetail(item)"> |
| | | <div class="device-status"> |
| | | <div |
| | | v-if="item.equipmentStatus == 2 || item.equipmentStatus == 1" |
| | | :style="{ backgroundImage: `url(${require('@/assets/yellow.png')})` }" |
| | | :style="{ backgroundImage: `url(${getStatusImgUrl(item.equipmentStatus)})` }" |
| | | class="status-image" |
| | | ></div> |
| | | <div |
| | | v-if="item.equipmentStatus == 22" |
| | | :style="{ backgroundImage: `url(${require('@/assets/red.png')})` }" |
| | | class="status-image" |
| | | ></div> |
| | | <div |
| | | v-if="item.equipmentStatus == 0" |
| | | :style="{ backgroundImage: `url(${require('@/assets/gray.png')})` }" |
| | | class="status-image" |
| | | ></div> |
| | | <div |
| | | v-if="item.equipmentStatus == 3" |
| | | :style="{ backgroundImage: `url(${require('@/assets/green.png')})` }" |
| | | class="status-image" |
| | | ></div> |
| | | <div |
| | | :style="{ backgroundImage: `url(${getImgView(item.equipmentImage)})` }" |
| | | :style="{ backgroundImage: `url(${getImgEquipmentView(item.equipmentImage)})` }" |
| | | class="device-image" |
| | | ></div> |
| | | </div> |
| | | <div class="device-id" id="deviceId" |
| | | :style="{ color:workshopDetails.equipmentIdColor }"> |
| | | <div :style="{ color:workshopDetails.equipmentIdColor }"> |
| | | {{ item.equipmentId }} |
| | | </div> |
| | | </div> |
| | |
| | | showGuideline: 'none', |
| | | guidelineXTop: 0, |
| | | guidelineYLeft: 0, |
| | | deviceList: [ |
| | | // { |
| | | // equipmentId: '123213213123232',// 设备ID |
| | | // equipmentImage: require('@/assets/8.png'), // 设备图片 |
| | | // coordinateTop: 200, // 拖拽元素距盒子顶距离 |
| | | // coordinateLeft: 100, // 拖拽元素距盒子左侧距离 |
| | | // vw: 100, // 缩放元素宽度 |
| | | // vh: 100, // 缩放元素高度 |
| | | // equipmentStatus: 1 // 设备状态 0:关机 22:报警 2:待机 3:运行 开机:1(没有四色灯标识归为待机) |
| | | // } |
| | | ], // 设备信息列表 |
| | | deviceList_copy: [], |
| | | deviceList: [], // 设备信息列表 |
| | | deviceStatusList: [ |
| | | // { |
| | | // label: '全部', |
| | | // value: 99, |
| | | // color: '#fff', |
| | | // checked: true |
| | | // }, |
| | | { |
| | | label: '关机', |
| | | value: 0, |
| | | color: '#A8A8A8', |
| | | checked: false |
| | | color: '#A8A8A8' |
| | | }, |
| | | { |
| | | label: '待机', |
| | | value: 2, |
| | | color: '#FFFF00', |
| | | checked: false |
| | | color: '#FFFF00' |
| | | }, |
| | | { |
| | | label: '运行', |
| | | value: 3, |
| | | color: '#00EE00', |
| | | checked: false |
| | | color: '#00EE00' |
| | | }, |
| | | { |
| | | label: '报警', |
| | | value: 22, |
| | | color: '#FF0000', |
| | | checked: false |
| | | color: '#FF0000' |
| | | }, |
| | | { |
| | | label: '故障', |
| | | value: 5, |
| | | color: '#C11900' |
| | | } |
| | | ],// 设备状态指示灯列表, |
| | | windowHeight: null,// 当前浏览器可视区域高度((不包括工具栏、书签、底部任务栏) |
| | |
| | | * @param id 车间Id |
| | | */ |
| | | getDeviceListByApi(id) { |
| | | console.log('重新刷新') |
| | | api.getDeviceListInWorkshopSignagePageApi(id).then((res) => { |
| | | if (res.result && res.result.length > 0) { |
| | | this.deviceList = res.result |
| | | this.deviceList_copy = res.result |
| | | } |
| | | }) |
| | | }, |
| | |
| | | getWorkshopDetailsByApi(id) { |
| | | api.getWorkshopDetailByWorkshopIdApi(id).then((res) => { |
| | | this.workshopDetails = res.result |
| | | // this.$refs.deviceContainerRef.style.backgroundImage = `url(${this.getImgView( |
| | | // this.workshopDetails.backgroundImage |
| | | // )})` |
| | | this.imgSrc = this.getImgView(this.workshopDetails.backgroundImage) |
| | | this.$refs.deviceContainerRef.style.height = (this.windowHeight - this.pageHeaderHeight) + 'px' |
| | | // this.parentH = this.windowHeight - this.pageHeaderHeight |
| | | this.parentH = 900 |
| | | this.parentLimitation = true // 在父元素高度设置后再设置限制拖拽区域,不这样有概率导致父元素高度未设置就限制拖拽 |
| | | }) |
| | |
| | | getImgView(text) { |
| | | if (text && text.indexOf(',') > 0) { |
| | | text = text.substring(0, text.indexOf(',')) |
| | | } |
| | | return getFileAccessHttpUrl(text) |
| | | }, |
| | | /** |
| | | * 设备图片预览 |
| | | * @param text 图片地址 |
| | | */ |
| | | getImgEquipmentView(text) { |
| | | if (text && text.indexOf(',') > 0) { |
| | | text = text.substring(0, text.indexOf(',')) |
| | | } |
| | | |
| | | if (text == null || text == '') { |
| | | return require('../../../assets/default.png') |
| | | } |
| | | return getFileAccessHttpUrl(text) |
| | | }, |
| | |
| | | * @param index 拖拽设备在数组中的下标 |
| | | */ |
| | | resize(newRect, index) { |
| | | // if (newRect.width > 100) { |
| | | // if (newRect.width / newRect.height < 2) { |
| | | // this.deviceList[index].fontSize = newRect.width / 10 |
| | | // } else { |
| | | // this.deviceList[index].fontSize = newRect.height / 5 |
| | | // } |
| | | // } else { |
| | | // this.deviceList[index].fontSize = 12 |
| | | // } |
| | | this.showGuideline = 'block' |
| | | this.deviceList[index].vw = newRect.width |
| | | this.deviceList[index].vh = newRect.height |
| | |
| | | * @returns {number} 设备数量 |
| | | */ |
| | | getDeviceNumberByStatus(value) { |
| | | if (value === 99) return this.deviceList_copy.length |
| | | return this.deviceList_copy.filter((item) => item.equipmentStatus === value).length |
| | | if (value === 99) return this.deviceList.length |
| | | return this.deviceList.filter((item) => item.equipmentStatus === value).length |
| | | }, |
| | | |
| | | /** |
| | |
| | | this.isDraggable = !this.isDraggable |
| | | }, |
| | | |
| | | openDetail(item) { |
| | | /** |
| | | * 开启功能触发事件 |
| | | * @param record 点击的设备信息 |
| | | */ |
| | | openDetail(record) { |
| | | if (!this.isSwitchChecked) { |
| | | if (item.equipmentStatus == 0) { |
| | | if (record.equipmentStatus == 0) { |
| | | this.$message.warning('设备处于关机状态!') |
| | | return false |
| | | } |
| | | console.log(item) |
| | | console.log(this.$refs.EquipmentDetailModal) |
| | | this.$refs.EquipmentDetailModal.initData(item.equId) |
| | | this.$refs.EquipmentDetailModal.timerModel(item.equId) |
| | | // this.equipMessageTimer = setInterval(() => { |
| | | // setTimeout( this.$refs.equmentDetaiModel.initData(item.equipmentId),0) |
| | | // },1000*10) |
| | | this.$refs.EquipmentDetailModal.initData(record.equId) |
| | | this.$refs.EquipmentDetailModal.timerModel(record.equId) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 根据设备状态值获取对应三色灯图片地址 |
| | | * @param imgStatus 设备状态值 |
| | | */ |
| | | getStatusImgUrl(imgStatus) { |
| | | switch (imgStatus) { |
| | | case 1: |
| | | case 2: |
| | | return require('@/assets/yellow.png') |
| | | case 3: |
| | | return require('@/assets/green.png') |
| | | case 22: |
| | | return require('@/assets/red.png') |
| | | case 5: |
| | | return require('@/assets/orange.png') |
| | | default: |
| | | return require('@/assets/gray.png') |
| | | } |
| | | }, |
| | | |
| | |
| | | * 浏览器尺寸发生改变时触发 |
| | | */ |
| | | handleWindowSizeChange() { |
| | | // this.isFullScreen = !this.isFullScreen |
| | | // if (!this.isFullScreen) location.reload() // 如果为全屏模式,则在切换模式时重新加载页面以重新获取浏览器可视区域高度 |
| | | const windowHeight = |
| | | window.innerHeight || |
| | | document.documentElement.clientHeight || |
| | | document.body.clientHeight |
| | | // this.parentH = 99999 |
| | | // const scaleRate = windowHeight / this.windowHeight |
| | | // this.windowHeight = windowHeight |
| | | this.$refs.deviceContainerRef.style.height = (windowHeight - this.pageHeaderHeight) + 'px' |
| | | // const timer = setTimeout(() => { |
| | | // this.deviceList.forEach(item => { |
| | | // item.coordinateTop = item.coordinateTop * scaleRate |
| | | // item.vh = item.vh * scaleRate |
| | | // console.log('vh', item.vh) |
| | | // }) |
| | | // this.parentH = windowHeight - this.pageHeaderHeight |
| | | // console.log('changeDeviceList', this.deviceList) |
| | | // }, 500) |
| | | // console.log('scaleRate', scaleRate) |
| | | }, |
| | | |
| | | checkboxChange(obj) { |
| | | //需要判断是否开启功能,目的是为了关闭定时器避免筛选后设备被定时刷新的新设备覆盖 |
| | | if (this.isOperatingDevice) { |
| | | obj.checked = !obj.checked |
| | | if (obj.value !== 99) { |
| | | if (obj.checked) this.checkedStatusCount++ |
| | | else this.checkedStatusCount-- |
| | | } |
| | | |
| | | if (obj.value == 99) { |
| | | this.deviceStatusList.forEach(item => { |
| | | if (item.value !== obj.value) item.checked = obj.checked |
| | | }) |
| | | if (obj.checked) { |
| | | this.deviceList = this.deviceList_copy |
| | | this.checkedStatusCount = this.deviceStatusList.length - 1 |
| | | } else { |
| | | this.deviceList = [] |
| | | this.checkedStatusCount = 0 |
| | | } |
| | | } else { |
| | | this.deviceStatusList.forEach(item => { |
| | | if (item.value === 99) { |
| | | if (this.checkedStatusCount !== this.deviceStatusList.length - 1 || this.checkedStatusCount === 0) item.checked = false |
| | | if (this.checkedStatusCount === this.deviceStatusList.length - 1) item.checked = true |
| | | } |
| | | }) |
| | | if (obj.checked) { |
| | | this.deviceList.push(...this.deviceList_copy.filter(item => item.equipmentStatus === obj.value)) |
| | | } else { |
| | | this.deviceList = this.deviceList.filter(item => item.equipmentStatus !== obj.value) |
| | | } |
| | | } |
| | | } else { |
| | | this.$notification.warning({ |
| | | message: '消息', |
| | | description: '请开启功能后再进行筛选' |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | handleScreenDevive(obj) { |
| | | //需要判断是否开启功能,目的是为了关闭定时器避免筛选后设备被定时刷新的新设备覆盖 |
| | | if (this.isOperatingDevice) { |
| | | obj.checked = true |
| | | this.deviceList = this.deviceList_copy |
| | | this.deviceStatusList.forEach(item => { |
| | | if (item.value !== obj.value) item.checked = false |
| | | }) |
| | | |
| | | if (obj.value == 99) this.deviceList = this.deviceList_copy |
| | | else this.deviceList = this.deviceList.filter(item => item.equipmentStatus === obj.value) |
| | | |
| | | } else { |
| | | this.$notification.warning({ |
| | | message: '消息', |
| | | description: '请开启功能后再进行筛选' |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | document.documentElement.clientHeight || |
| | | document.body.clientHeight |
| | | |
| | | // 判断浏览器可视区域高度是否等于分辨率,若相等则表示进入时浏览器为全屏模式 |
| | | // if (this.windowHeight === screen.height) this.isFullScreen = true |
| | | |
| | | window.addEventListener('resize', this.handleWindowSizeChange) |
| | | }, |
| | | beforeDestroy() { |
| | |
| | | color: #fff; |
| | | |
| | | .page-header { |
| | | /*font-size: 50px;*/ |
| | | /*text-align: center;*/ |
| | | /*position: relative;*/ |
| | | |
| | | .header-left { |
| | | height: 100%; |
| | | display: flex; |
| | |
| | | |
| | | .single-status-info { |
| | | margin: 10px; |
| | | cursor: pointer; |
| | | |
| | | .status-square { |
| | | width: 14px; |
| | |
| | | flex-direction: column; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | cursor: default; |
| | | |
| | | &:active { |
| | | border: 1px solid #1890ff; |
| | | } |
| | | cursor: pointer; |
| | | |
| | | .device-status { |
| | | width: 100%; |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /deep/ .ant-checkbox-inner { |
| | | background-color: transparent; |
| | | border-color: #fff; |
| | | } |
| | | </style> |