|
|
@ -1,19 +1,18 @@ |
|
|
|
<template> |
|
|
|
<Dialog v-model="modelVisible" title="设备操作" width="550px"> |
|
|
|
<Dialog v-model="modelVisible" title="设备操作" width="600px"> |
|
|
|
<div class="DeviceControlDialog"> |
|
|
|
<Form |
|
|
|
column="2" |
|
|
|
v-if="formList && formList.length" |
|
|
|
class="form" |
|
|
|
ref="FormConfigRef" |
|
|
|
label-width='120px' |
|
|
|
label-width='150px' |
|
|
|
:formList="formList" |
|
|
|
:value="formData" |
|
|
|
/> |
|
|
|
</div> |
|
|
|
<template #footer> |
|
|
|
<!-- 王思祥 回读待确认 2024-05-16 TODO--> |
|
|
|
<Button @click.native="handleSubmit" :loading="submitting"> 发送 </Button> |
|
|
|
<Button @click.native="handleSubmit"> 发送 </Button> |
|
|
|
</template> |
|
|
|
</Dialog> |
|
|
|
</template> |
|
|
@ -23,6 +22,8 @@ |
|
|
|
import Button from "@screen/components/Buttons/Button.vue"; |
|
|
|
import Dialog from "@screen/components/Dialog/index.vue"; |
|
|
|
import request from "@/utils/request"; |
|
|
|
|
|
|
|
import { Message } from 'element-ui' |
|
|
|
import Form from "@screen/components/FormConfig"; |
|
|
|
export default { |
|
|
|
name: "DeviceControlDialog", |
|
|
@ -36,6 +37,12 @@ export default { |
|
|
|
event: "update:value", |
|
|
|
}, |
|
|
|
props: { |
|
|
|
|
|
|
|
rebind: { |
|
|
|
type: Function, |
|
|
|
default: null |
|
|
|
}, |
|
|
|
|
|
|
|
visible: Boolean, |
|
|
|
dialogData: { |
|
|
|
type: Object, |
|
|
@ -80,36 +87,106 @@ export default { |
|
|
|
"triggerTextDuration", |
|
|
|
"normalTextDisplaySettings", |
|
|
|
"vehicleDetectorSensitivity", |
|
|
|
"calculationCycle" |
|
|
|
"calculationCycle", |
|
|
|
"firstTimePeriodStartTTime", |
|
|
|
"firstTimePeriodEndTime", |
|
|
|
"firstTimePeriodRedAndBlueFlash", |
|
|
|
"firstTimePeriodScreenSwitch", |
|
|
|
"firstTimePeriodWhetherToReport", |
|
|
|
"firstTimePeriodHornSwitch", |
|
|
|
"secondTimePeriodStartTTime", |
|
|
|
"secondTimePeriodEndTime", |
|
|
|
"secondTimePeriodRedAndBlueFlash", |
|
|
|
"secondTimePeriodScreenSwitch", |
|
|
|
"secondTimePeriodWhetherToReport", |
|
|
|
"secondTimePeriodHornSwitch", |
|
|
|
"thirdlyTimePeriodStartTTime", |
|
|
|
"thirdlyTimePeriodEndTime", |
|
|
|
"thirdlyTimePeriodRedAndBlueFlash", |
|
|
|
"thirdlyTimePeriodScreenSwitch", |
|
|
|
"thirdlyTimePeriodWhetherToReport", |
|
|
|
"thirdlyTimePeriodHornSwitch" |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
handleSubmit(){ |
|
|
|
this.$message.success('发送成功') |
|
|
|
const self = this; |
|
|
|
this.$refs.FormConfigRef.validate().then((data) => { |
|
|
|
|
|
|
|
data.numberOfDevices = this.dialogData.iotDeviceId.substr(this.dialogData.iotDeviceId.lastIndexOf('-')+1) |
|
|
|
request({ |
|
|
|
url: `/business/device/functions/${self.dialogData.iotDeviceId}/0b`, |
|
|
|
method: "POST", |
|
|
|
data: data |
|
|
|
}) |
|
|
|
.then(result => { |
|
|
|
if (result.code != 200) { |
|
|
|
Message.error("操作失败"); |
|
|
|
self.rebind() |
|
|
|
self.modelVisible = false |
|
|
|
return; |
|
|
|
}; |
|
|
|
Message.success("操作成功"); |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
Message.error("操作失败"); |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
async created() { |
|
|
|
let devs = []; |
|
|
|
request({ |
|
|
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId}`, |
|
|
|
method: "get", |
|
|
|
}).then(result => { |
|
|
|
if (result.code != 200) return Message.error("操作失败"); |
|
|
|
console.log(result.data) |
|
|
|
let n = _.find(result.data,{property:'numberOfPeriods'}); |
|
|
|
|
|
|
|
let pv = ""; |
|
|
|
result.data.forEach(x=>{ |
|
|
|
pv += `${x.propertyName},${x.type},${x.property}.` |
|
|
|
}) |
|
|
|
|
|
|
|
let n = _.find(result.data,{property:'numberOfPeriods'}); |
|
|
|
let _formList = []; |
|
|
|
this.list.forEach(e => { |
|
|
|
const p = _.find(result.data,{property:e}) |
|
|
|
if(p) { |
|
|
|
if(p.type === 'string' || p.type === 'long'){ |
|
|
|
this.formList.push( { |
|
|
|
_formList.push( { |
|
|
|
label: p.propertyName+':', |
|
|
|
key: p.property, |
|
|
|
}) |
|
|
|
} else if(p.type === 'enum' ){ |
|
|
|
if(p.property.indexOf('PeriodHornSwitch') !== -1 || |
|
|
|
p.property.indexOf('PeriodRedAndBlueFlash') !== -1 || |
|
|
|
p.property.indexOf('PeriodWhetherToReport') !== -1 || |
|
|
|
p.property.indexOf('firstTimePeriodScreenSwitch') !== -1 ){ // 号角开关 | 红蓝爆闪灯 |
|
|
|
_formList.push({ |
|
|
|
label: p.propertyName+':', |
|
|
|
key: p.property, |
|
|
|
type: "RadioGroup", |
|
|
|
options: { |
|
|
|
activeColor: "linear-gradient(180deg, #37E7FF 0%, #009BCC 100%)", |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
key: "0", |
|
|
|
label: "关闭", |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: "1", |
|
|
|
label: "开启", |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
}) |
|
|
|
} else if(p.property.indexOf('PeriodHornSwitch') !== -1){ |
|
|
|
|
|
|
|
} |
|
|
|
else if(p.property==="colour"){ |
|
|
|
this.formList.push({ |
|
|
|
|
|
|
|
|
|
|
|
} else if(p.property==="colour"){ |
|
|
|
_formList.push({ |
|
|
|
label: p.propertyName+':', |
|
|
|
key: p.property, |
|
|
|
type: "select", |
|
|
@ -118,9 +195,8 @@ export default { |
|
|
|
options: this.enum_color |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
else if(p.property==="wordFlickerFrequency"){ |
|
|
|
this.formList.push({ |
|
|
|
} else if(p.property==="wordFlickerFrequency"){ |
|
|
|
_formList.push({ |
|
|
|
label: p.propertyName+':', |
|
|
|
key: p.property, |
|
|
|
type: "select", |
|
|
@ -130,11 +206,10 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
this.formData[ p.property] =p.formatValue |
|
|
|
this.formData[p.property] = p.value |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
console.log(this.formList,this.formData) |
|
|
|
this.formList = _formList; |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -143,7 +218,7 @@ export default { |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
.DeviceControlDialog { |
|
|
|
width: 510px; |
|
|
|
width: 550px; |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
gap: 15px; |
|
|
|