|
|
@ -42,7 +42,7 @@ |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
<!-- 绑定参数对话框 --> |
|
|
|
<el-dialog title="绑定参数" :visible.sync="dialogVisible"> |
|
|
|
<el-dialog title="绑定参数" :visible.sync="dialogVisible" @opened="opened"> |
|
|
|
<span class="dialog-right-top" /> |
|
|
|
<span class="dialog-left-bottom" /> |
|
|
|
<div class="setting-dialog"> |
|
|
@ -51,7 +51,7 @@ |
|
|
|
<!-- <input-select :options="options" @selectValue="handleSelectValue" /> --> |
|
|
|
<p class="form-first">{{ form.divPosition }}</p> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="设备绑定" prop="deviceInfo.id"> |
|
|
|
<el-form-item label="设备绑定" prop="deviceInfo"> |
|
|
|
<el-select v-model="form.deviceInfo.id" placeholder="请选择" clearable filterable @change="getParamsOptionsList"> |
|
|
|
<el-option v-for="item in devOptions" :key="item.value" :label="item.label" :value="item.value"> |
|
|
|
<span style="float: left">{{ item.label }} - {{ item.info }}</span> |
|
|
@ -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,6 +200,8 @@ export default { |
|
|
|
this.$refs.table.toggleRowSelection(row) // 单选选中 |
|
|
|
}, |
|
|
|
handleConfirm() { |
|
|
|
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) }) |
|
|
@ -195,6 +218,10 @@ export default { |
|
|
|
this.dialogVisible = false |
|
|
|
this.getDisplayConfigList() |
|
|
|
}) |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
getDisplayConfigList() { |
|
|
|
displayConfigApi.list({ storeroomId: this.room }).then((data) => { |
|
|
@ -202,10 +229,15 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
getParamsOptionsList() { |
|
|
|
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() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|