| | |
| | | <template> |
| | | <dv-full-screen-container class="full-screen-container"> |
| | | <header class="page-header" :style="{height: pageHeaderHeight+'px'}"> |
| | | {{ workshopDetails.workshopName }} |
| | | <div class="header-left" v-has="'home:saveDevicePositionAndSize'" v-if="!isFullScreen"> |
| | | <a-space> |
| | | <span v-if="!isSwitchChecked">开启功能</span> |
| | | <span v-else>关闭功能</span> |
| | | <a-switch |
| | | checked-children="开" |
| | | un-checked-children="关" |
| | | @change="handleSwitchChange" |
| | | v-model="isSwitchChecked" |
| | | :disabled="isSwitchChecked" |
| | | /> |
| | | </a-space> |
| | | <a-button type="primary" icon="save" size="large" @click="saveDevicePositionAndSizeByApi">保存位置</a-button> |
| | | </div> |
| | | <div class="device-status-info"> |
| | | <a-space v-for="item in deviceStatusList" :key="item.value" class="single-status-info"> |
| | | <div>{{ item.label }}</div> |
| | | <div class="status-square" :style="{ backgroundColor: item.color }"></div> |
| | | <div>{{ getDeviceNumberByStatus(item.value) }}</div> |
| | | </a-space> |
| | | </div> |
| | | </header> |
| | | <div> |
| | | <!--页头区域--> |
| | | <header class="page-header" :style="{height: pageHeaderHeight+'px'}"> |
| | | <a-row style="height: 100%"> |
| | | <a-col :span="7" class="header-left"> |
| | | <a-space> |
| | | <span v-if="!isSwitchChecked">开启功能</span> |
| | | <span v-else>关闭功能</span> |
| | | <a-switch |
| | | checked-children="开" |
| | | un-checked-children="关" |
| | | @change="handleSwitchChange" |
| | | v-model="isSwitchChecked" |
| | | :disabled="isSwitchChecked" |
| | | /> |
| | | <a-button type="primary" icon="save" size="large" @click="saveDevicePositionAndSizeByApi">保存位置</a-button> |
| | | </a-space> |
| | | </a-col> |
| | | |
| | | <dv-border-box-8> |
| | | <div class="content-container" ref="deviceContainerRef"> |
| | | <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> |
| | | </a-row> |
| | | </header> |
| | | |
| | | <!--拖拽设备区域--> |
| | | <div class="content-container" ref="deviceContainerRef" style="overflow: auto"> |
| | | <img :src="imgSrc" width="1920" height="900"> |
| | | <VueDragResize |
| | | v-for="(item, index) in deviceList" |
| | | :key="item.equipmentId" |
| | |
| | | v-on:dragging="resize($event, index)" |
| | | :parentLimitation="parentLimitation" |
| | | :parentH="parentH" |
| | | :parentW="parentW" |
| | | :minw="70" |
| | | :minh="70" |
| | | :isDraggable="isDraggable" |
| | |
| | | ></div> |
| | | </div> |
| | | <div class="device-id" id="deviceId" |
| | | :style="{ fontSize: item.fontSize + 'px',color:workshopDetails.equipmentIdColor }"> |
| | | :style="{ color:workshopDetails.equipmentIdColor }"> |
| | | {{ item.equipmentId }} |
| | | </div> |
| | | </div> |
| | | </VueDragResize> |
| | | </div> |
| | | </dv-border-box-8> |
| | | |
| | | <EquipmentDetailModal ref="EquipmentDetailModal"></EquipmentDetailModal> |
| | | <EquipmentDetailModal ref="EquipmentDetailModal"></EquipmentDetailModal> |
| | | </div> |
| | | </dv-full-screen-container> |
| | | </template> |
| | | |
| | |
| | | isSwitchChecked: false, // 是否开启功能 |
| | | timingAcquisition: null, // 定时刷新是否开启 |
| | | parentH: 5000,//父级高度 |
| | | parentW: 1920,//父级宽度 |
| | | deviceList: [ |
| | | // { |
| | | // equipmentId: '123213213123232',// 设备ID |
| | |
| | | // coordinateLeft: 100, // 拖拽元素距盒子左侧距离 |
| | | // vw: 100, // 缩放元素宽度 |
| | | // vh: 100, // 缩放元素高度 |
| | | // fontSize: 12, // 缩放元素字体大小 |
| | | // equipmentStatus: 1 // 设备状态 0:关机 22:报警 2:待机 3:运行 开机:1(没有四色灯标识归为待机) |
| | | // } |
| | | ], // 设备信息列表 |
| | | deviceList_copy: [], |
| | | deviceStatusList: [ |
| | | // { |
| | | // label: '全部', |
| | | // value: 99, |
| | | // color: '#fff', |
| | | // checked: true |
| | | // }, |
| | | { |
| | | label: '关机', |
| | | value: 0, |
| | | color: '#A8A8A8' |
| | | color: '#A8A8A8', |
| | | checked: false |
| | | }, |
| | | { |
| | | label: '待机', |
| | | value: 2, |
| | | color: '#FFFF00' |
| | | color: '#FFFF00', |
| | | checked: false |
| | | }, |
| | | { |
| | | label: '运行', |
| | | value: 3, |
| | | color: '#00EE00' |
| | | color: '#00EE00', |
| | | checked: false |
| | | }, |
| | | { |
| | | label: '报警', |
| | | value: 22, |
| | | color: '#FF0000' |
| | | color: '#FF0000', |
| | | checked: false |
| | | } |
| | | ],// 设备状态指示灯列表, |
| | | windowHeight: null,// 当前浏览器可视区域高度((不包括工具栏、书签、底部任务栏),进入页面时计算一次,除非重新加载页面否则浏览器可视区域高度则不发生改变 |
| | | windowHeight: null,// 当前浏览器可视区域高度((不包括工具栏、书签、底部任务栏) |
| | | isFullScreen: false,// 进入看板页面时是否为全屏模式,不包括正常模式进入后切换为全屏模式 |
| | | parentLimitation: false// 拖拽区域是否限制在父元素区域内 |
| | | parentLimitation: false,// 拖拽区域是否限制在父元素区域内, |
| | | checkedStatusCount: null,// 已勾选筛选状态个数 |
| | | imgSrc: ''// 车间图纸地址 |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | 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.$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 = this.windowHeight - this.pageHeaderHeight |
| | | this.parentH = 900 |
| | | this.parentLimitation = true // 在父元素高度设置后再设置限制拖拽区域,不这样有概率导致父元素高度未设置就限制拖拽 |
| | | }) |
| | | }, |
| | |
| | | * @returns {number} 设备数量 |
| | | */ |
| | | getDeviceNumberByStatus(value) { |
| | | return this.deviceList.filter((item) => item.equipmentStatus === value).length |
| | | if (value === 99) return this.deviceList_copy.length |
| | | return this.deviceList_copy.filter((item) => item.equipmentStatus === value).length |
| | | }, |
| | | |
| | | /** |
| | |
| | | * 浏览器尺寸发生改变时触发 |
| | | */ |
| | | handleWindowSizeChange() { |
| | | this.isFullScreen = !this.isFullScreen |
| | | if (!this.isFullScreen) location.reload() // 如果为全屏模式,则在切换模式时重新加载页面以重新获取浏览器可视区域高度 |
| | | // 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() { |
| | |
| | | this.getDeviceListByApi(this.$route.params.id) |
| | | this.getWorkshopDetailsByApi(this.$route.params.id) |
| | | } |
| | | this.checkedStatusCount = this.deviceStatusList.length - 1 |
| | | }, |
| | | mounted() { |
| | | // 禁止用户选中内容 |
| | |
| | | document.body.clientHeight |
| | | |
| | | // 判断浏览器可视区域高度是否等于分辨率,若相等则表示进入时浏览器为全屏模式 |
| | | if (this.windowHeight === screen.height) this.isFullScreen = true |
| | | // if (this.windowHeight === screen.height) this.isFullScreen = true |
| | | |
| | | window.addEventListener('resize', this.handleWindowSizeChange) |
| | | }, |
| | |
| | | color: #fff; |
| | | |
| | | .page-header { |
| | | font-size: 50px; |
| | | text-align: center; |
| | | position: relative; |
| | | /*font-size: 50px;*/ |
| | | /*text-align: center;*/ |
| | | /*position: relative;*/ |
| | | |
| | | .header-left { |
| | | width: 450px; |
| | | position: absolute; |
| | | left: 0; |
| | | top: 35px; |
| | | height: 100%; |
| | | display: flex; |
| | | justify-content: space-evenly; |
| | | justify-content: center; |
| | | align-items: center; |
| | | font-size: 16px; |
| | | padding-top: 20px; |
| | | } |
| | | |
| | | .workshop-name { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | font-size: 50px; |
| | | } |
| | | |
| | | .device-status-info { |
| | | font-size: 16px; |
| | | width: 400px; |
| | | position: absolute; |
| | | top: 40px; |
| | | right: 40px; |
| | | height: 100%; |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | padding-top: 20px; |
| | | |
| | | .single-status-info { |
| | | margin: 10px; |
| | | cursor: pointer; |
| | | |
| | | .status-square { |
| | | width: 14px; |
| | | height: 14px; |
| | | border: 1px solid #fff; |
| | | border-radius: 2px; |
| | | border-radius: 3px; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /deep/ .ant-checkbox-inner { |
| | | background-color: transparent; |
| | | border-color: #fff; |
| | | } |
| | | </style> |