From e1d88fc602ec9475369f3850ed6a6af28e1cc1b8 Mon Sep 17 00:00:00 2001
From: z_yu <1534695664@qq.com>
Date: Wed, 17 Aug 2022 17:38:08 +0800
Subject: [PATCH] =?UTF-8?q?3D=E5=BA=93=E6=88=BF=E6=A1=A3=E6=A1=88=E5=BA=93?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA=20=E5=AE=9A=E6=97=B6?=
=?UTF-8?q?=E8=AF=B7=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../deviceManage/module/deviceDetail.vue | 23 +++---
.../warehouse3D/archivesStorage/index.vue | 73 +++++++++---------
.../storeManage/warehouse3DConfig/index.vue | 76 +++++++++++++------
3 files changed, 105 insertions(+), 67 deletions(-)
diff --git a/src/views/storeManage/deviceManage/module/deviceDetail.vue b/src/views/storeManage/deviceManage/module/deviceDetail.vue
index 24a72d9..894753c 100644
--- a/src/views/storeManage/deviceManage/module/deviceDetail.vue
+++ b/src/views/storeManage/deviceManage/module/deviceDetail.vue
@@ -16,7 +16,7 @@
绑定设备
- 绑定参数
+ 绑定参数
@@ -289,14 +289,14 @@ export default {
}
},
rules() {
- const checkDeviceIp = (rule, value, callback) => {
- const reg = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/
- if (reg.test(value)) {
- callback()
- } else {
- callback(new Error('设备IP格式错误'))
- }
- }
+ // const checkDeviceIp = (rule, value, callback) => {
+ // const reg = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/
+ // if (reg.test(value)) {
+ // callback()
+ // } else {
+ // callback(new Error('设备IP格式错误'))
+ // }
+ // }
const checkDevicePort = (rule, value, callback) => {
const reg = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{4}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/
if (reg.test(value)) {
@@ -321,8 +321,9 @@ export default {
}
if (this.selectedDeviceType === '密集架' || this.selectedDeviceType === '回转柜' || this.selectedDeviceType === '摄像头' || this.isInsidedevices) {
this.$set(validateRule, 'deviceIp', [
- { required: true, message: '请输入接口IP', trigger: 'blur' },
- { validator: checkDeviceIp, trigger: 'blur' }
+ { required: true, message: '请输入接口IP', trigger: 'blur' }
+ // ,
+ // { validator: checkDeviceIp, trigger: 'blur' }
])
this.$set(validateRule, 'devicePort', [
{ required: true, message: '请输入端口号', trigger: 'blur' },
diff --git a/src/views/storeManage/warehouse3D/archivesStorage/index.vue b/src/views/storeManage/warehouse3D/archivesStorage/index.vue
index 17f5bde..50f454f 100644
--- a/src/views/storeManage/warehouse3D/archivesStorage/index.vue
+++ b/src/views/storeManage/warehouse3D/archivesStorage/index.vue
@@ -181,7 +181,7 @@ export default {
}
window.addEventListener('message', this.handleMessageDevice)
// 定时请求第三方数据,更新页面数据
- setInterval(async() => {
+ this.timer = setInterval(async() => {
await _this.getRealTimeData()
_this.handleAQI()
}, 4000)
@@ -247,43 +247,48 @@ export default {
}
},
getRealTimeData() {
- thirdApi.getRealTimeData({ ids: this.allDeviceIds, url: this.url }).then((data) => {
- this.oaoMessage.splice(0, this.oaoMessage.length)
- this.displayConfigData.forEach(element => {
- if (element.divPosition.includes('TOP') && element.deviceSpecParams[0]) {
- const result = data.find((item) => {
- return item.property_id === element.deviceSpecParams[0].paramId && item.device_id === element.deviceInfo.deviceId
- })
- this.$set(this.topDisplayData, element.divPosition, {
- show: true,
- curValue: result.curvalue,
- unit: result.unit,
- curstatus: result.curstatus
- })
- } else {
- const wenduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '温度' })?.paramId
- const siduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '湿度' })?.paramId
- let wendu = {}
- let sidu = {}
- if (wenduParamId) {
- wendu = data.find((item) => {
- return item.property_id === wenduParamId && item.device_id === element.deviceInfo.deviceId
+ if (this.allDeviceIds.length > 0) {
+ thirdApi.getRealTimeData({ ids: this.allDeviceIds, url: this.url }).then((data) => {
+ this.oaoMessage.splice(0, this.oaoMessage.length)
+ console.log(this.displayConfigData)
+ this.displayConfigData.forEach(element => {
+ if (element.divPosition.includes('TOP') && element.deviceSpecParams[0]) {
+ // 获取页面div显示的数据
+ const result = data.find((item) => {
+ return item.property_id === element.deviceSpecParams[0].paramId && item.device_id === element.deviceInfo.deviceId
})
- }
- if (siduParamId) {
- sidu = data.find((item) => {
- return item.property_id === siduParamId && item.device_id === element.deviceInfo.deviceId
+ this.$set(this.topDisplayData, element.divPosition, {
+ show: true,
+ curValue: result.curvalue,
+ unit: result.unit,
+ curstatus: result.curstatus
+ })
+ } else {
+ // 获取3D弹窗显示的数据
+ const wenduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '温度' })?.paramId
+ const siduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '湿度' })?.paramId
+ let wendu = {}
+ let sidu = {}
+ if (wenduParamId) {
+ wendu = data.find((item) => {
+ return item.property_id === wenduParamId && item.device_id === element.deviceInfo.deviceId
+ })
+ }
+ if (siduParamId) {
+ sidu = data.find((item) => {
+ return item.property_id === siduParamId && item.device_id === element.deviceInfo.deviceId
+ })
+ }
+ this.oaoMessage.push({
+ id: element.divPosition,
+ wendu: (wendu?.curvalue) ? (Math.round(wendu?.curvalue)) : '-',
+ sidu: (sidu?.curvalue) ? (Math.round(sidu?.curvalue)) : '-',
+ alarmState: (wendu && wendu.curstatus === '1') || (sidu && sidu.curstatus === '1')
})
}
- this.oaoMessage.push({
- id: element.divPosition,
- wendu: (wendu?.curvalue) ? (Math.round(wendu?.curvalue)) : '-',
- sidu: (sidu?.curvalue) ? (Math.round(sidu?.curvalue)) : '-',
- alarmState: (wendu && wendu.curstatus === '1') || (sidu && sidu.curstatus === '1')
- })
- }
+ })
})
- })
+ }
}
}
}
diff --git a/src/views/storeManage/warehouse3DConfig/index.vue b/src/views/storeManage/warehouse3DConfig/index.vue
index f6cc643..a68d37b 100644
--- a/src/views/storeManage/warehouse3DConfig/index.vue
+++ b/src/views/storeManage/warehouse3DConfig/index.vue
@@ -42,7 +42,7 @@
-
+
@@ -51,7 +51,7 @@
{{ form.divPosition }}
-
+
{{ item.label }} - {{ item.info }}
@@ -87,6 +87,14 @@ import { getParams } from '@/api/storeManage/deviceManage/param'
import { getRooms } from '@/api/storeManage/deviceManage/storeroom'
export default {
data() {
+ // 对应字典必填判断
+ var checkDeviceInfo = (rule, value, callback) => {
+ if (!this.form.deviceInfo.id) {
+ callback(new Error('绑定设备不可为空!'))
+ } else {
+ callback()
+ }
+ }
return {
room: '选项1',
// 库房选择
@@ -95,7 +103,8 @@ export default {
selections: [],
dialogVisible: false,
cameraTypeId: '',
- airEquipmentTypeId: '',
+ airEquipmentTypeId: '', // 空气质量检测设备
+ temperaSensorTypeId: '', // 温湿度感应器
form: { deviceInfo: {}},
// 设备绑定
devVal: '',
@@ -105,7 +114,7 @@ export default {
paramsOptions: [],
rules: {
deviceInfo: [
- { required: true, message: '请选择设备', trigger: 'blur' }
+ { required: true, validator: checkDeviceInfo, trigger: 'change' }
]
}
}
@@ -120,6 +129,7 @@ export default {
crudDevice.getDeviceType().then((data) => {
this.cameraTypeId = data.find((x) => { return x.name === '摄像头' }).id
this.airEquipmentTypeId = data.find((x) => { return x.name === '空气质量检测设备' }).id
+ this.temperaSensorTypeId = data.find((x) => { return x.name === '温湿度感应器' }).id
})
},
methods: {
@@ -135,6 +145,7 @@ export default {
}
},
handleBindParam() {
+ console.log(1111)
if (this.selections.length === 1) {
this.form = JSON.parse(JSON.stringify(this.selections[0]))
if (!this.form.deviceInfo) {
@@ -144,8 +155,10 @@ export default {
const isCAM = this.form.divPosition.includes('CAM')
if (isCAM) {
deviceTypeId = this.cameraTypeId
- } else {
+ } else if (this.form.divPosition.includes('TOP')) {
deviceTypeId = this.airEquipmentTypeId
+ } else {
+ deviceTypeId = this.temperaSensorTypeId
}
// 获取设备选项
crudDevice.getDeviceList({ storeroomId: this.room, deviceTypeId: deviceTypeId }).then((data) => {
@@ -157,7 +170,15 @@ export default {
})
// 温湿度感应器
if (!isCAM && this.form.deviceInfo.id) {
+ // 获取参数选项
this.getParamsOptionsList()
+ } else {
+ this.paramsOptions.splice(0, this.paramsOptions.length)
+ if (this.form.divPosition.includes('TOP')) {
+ this.form.deviceSpecParams = ''
+ } else {
+ this.form.deviceSpecParams.splice(0, this.form.deviceSpecParams.length)
+ }
}
if (this.form.deviceSpecParams && this.form.deviceSpecParams.length > 0) {
let formParams = this.form.deviceSpecParams.map((item) => { return item.id })
@@ -179,21 +200,27 @@ export default {
this.$refs.table.toggleRowSelection(row) // 单选选中
},
handleConfirm() {
- this.form.deviceInfo = this.devOptions.find((option) => { return option.value === this.form.deviceInfo.id }).self
- if (Array.isArray(this.form.deviceSpecParams)) {
- const paramValues = this.paramsOptions.filter((option) => { return this.form.deviceSpecParams.includes(option.value) })
- this.form.deviceSpecParams = paramValues.map((paramValue) => { return paramValue.self })
- } else if (this.form.deviceSpecParams !== null) {
- const paramValue = this.paramsOptions.find((option) => { return option.value === this.form.deviceSpecParams })
- if (paramValue) {
- this.form.deviceSpecParams = []
- this.form.deviceSpecParams.push(paramValue.self)
+ this.$refs.formDom.validate((valid) => {
+ if (valid) {
+ this.form.deviceInfo = this.devOptions.find((option) => { return option.value === this.form.deviceInfo.id }).self
+ if (Array.isArray(this.form.deviceSpecParams)) {
+ const paramValues = this.paramsOptions.filter((option) => { return this.form.deviceSpecParams.includes(option.value) })
+ this.form.deviceSpecParams = paramValues.map((paramValue) => { return paramValue.self })
+ } else if (this.form.deviceSpecParams !== null) {
+ const paramValue = this.paramsOptions.find((option) => { return option.value === this.form.deviceSpecParams })
+ if (paramValue) {
+ this.form.deviceSpecParams = []
+ this.form.deviceSpecParams.push(paramValue.self)
+ }
+ }
+ displayConfigApi.bind(this.form).then(() => {
+ this.$message.success('绑定成功 ')
+ this.dialogVisible = false
+ this.getDisplayConfigList()
+ })
+ } else {
+ return false
}
- }
- displayConfigApi.bind(this.form).then(() => {
- this.$message.success('绑定成功 ')
- this.dialogVisible = false
- this.getDisplayConfigList()
})
},
getDisplayConfigList() {
@@ -202,9 +229,14 @@ export default {
})
},
getParamsOptionsList() {
- getParams({ deviceInfoId: this.form.deviceInfo.id }).then((data) => {
- this.paramsOptions = data.map(data => { return { value: data.id, label: data.paramName, info: data.paramId, self: data } })
- })
+ if (this.form.deviceInfo.id) {
+ getParams({ deviceInfoId: this.form.deviceInfo.id }).then((data) => {
+ this.paramsOptions = data.map(data => { return { value: data.id, label: data.paramName, info: data.paramId, self: data } })
+ })
+ }
+ },
+ opened() {
+ this.$refs.formDom.clearValidate()
}
}
}