|
@ -1,13 +1,13 @@ |
|
|
<template> |
|
|
<template> |
|
|
<Dialog v-model="modelVisible" title="设备操作"> |
|
|
<Dialog v-model="modelVisible" title="设备操作"> |
|
|
<div class='DeviceControlDialog'> |
|
|
<div class='DeviceControlDialog'> |
|
|
<Form class="form" ref="FormConfigRef" :formList="formList" column="1" style="flex: 1;" labelWidth="90px" /> |
|
|
<Form class="form" ref="FormConfigRef" :formList="formList" column="1" style="flex: 1;" labelWidth="120px" /> |
|
|
|
|
|
|
|
|
<div class="footer"> |
|
|
<div class="footer"> |
|
|
<Button style="background-color: rgba(0, 179, 204, .3);" @click.native="modelVisible = false"> |
|
|
<Button style="background-color: rgba(0, 179, 204, .3);" @click.native="modelVisible = false, submitting = false"> |
|
|
取消 |
|
|
取消 |
|
|
</Button> |
|
|
</Button> |
|
|
<Button @click.native="handleSearch"> |
|
|
<Button @click.native="handleSubmit" :loading="submitting"> |
|
|
确定 |
|
|
确定 |
|
|
</Button> |
|
|
</Button> |
|
|
</div> |
|
|
</div> |
|
@ -21,6 +21,33 @@ import Button from "@screen/components/Buttons/Button.vue" |
|
|
import Form from '@screen/components/FormConfig'; |
|
|
import Form from '@screen/components/FormConfig'; |
|
|
|
|
|
|
|
|
import { cloneDeep } from "lodash" |
|
|
import { cloneDeep } from "lodash" |
|
|
|
|
|
import { delay } from "@screen/utils/common.js" |
|
|
|
|
|
|
|
|
|
|
|
import { Message } from "element-ui"; |
|
|
|
|
|
import { axiosIns } from "@screen/utils/axios/auth.js"; |
|
|
|
|
|
|
|
|
|
|
|
const workStatus = [ |
|
|
|
|
|
{ |
|
|
|
|
|
key: "00", |
|
|
|
|
|
label: "不更新状态" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: "01", |
|
|
|
|
|
label: "常亮" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: "02", |
|
|
|
|
|
label: "流水" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: "03", |
|
|
|
|
|
label: "闪烁" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: "04", |
|
|
|
|
|
label: "关闭" |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'DeviceControlDialog', |
|
|
name: 'DeviceControlDialog', |
|
@ -34,44 +61,68 @@ export default { |
|
|
event: "update:value" |
|
|
event: "update:value" |
|
|
}, |
|
|
}, |
|
|
props: { |
|
|
props: { |
|
|
visible: Boolean |
|
|
visible: Boolean, |
|
|
|
|
|
deviceId: String |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
submitting: false, |
|
|
formList: [ |
|
|
formList: [ |
|
|
{ |
|
|
{ |
|
|
label: "类型:", |
|
|
label: "类型:", |
|
|
key: "key291", |
|
|
key: "controlType", |
|
|
type: "RadioGroup", |
|
|
type: "RadioGroup", |
|
|
isAlone: true, |
|
|
default: "manual", |
|
|
required: true, |
|
|
|
|
|
options: { |
|
|
options: { |
|
|
type: 'circle', |
|
|
type: 'circle', |
|
|
options: [ |
|
|
options: [ |
|
|
{ |
|
|
{ |
|
|
key: "手动控制", |
|
|
key: "manual", |
|
|
label: "手动控制", |
|
|
label: "手动控制", |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
key: "自动控制", |
|
|
key: "automatic", |
|
|
label: "自动控制", |
|
|
label: "自动控制", |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: "工作状态:", |
|
|
label: "上行工作状态:", |
|
|
key: "key999", |
|
|
key: "onWorkStatus", |
|
|
|
|
|
required: true, |
|
|
|
|
|
type: "select", |
|
|
|
|
|
visible: (data) => data.controlType == "manual", |
|
|
|
|
|
options: { |
|
|
|
|
|
placeholder: "请选择", |
|
|
|
|
|
options: workStatus |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: "下行工作状态:", |
|
|
|
|
|
key: "inWorkStatus", |
|
|
|
|
|
required: true, |
|
|
type: "select", |
|
|
type: "select", |
|
|
|
|
|
visible: (data) => data.controlType == "manual", |
|
|
|
|
|
options: { |
|
|
|
|
|
placeholder: "请选择", |
|
|
|
|
|
options: workStatus |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: "选择时间:", |
|
|
label: "选择时间:", |
|
|
key: "key009", |
|
|
key: "displayTime", |
|
|
type: "datePicker", |
|
|
type: "datePicker", |
|
|
|
|
|
required: true, |
|
|
|
|
|
visible: (data) => data.controlType == "automatic", |
|
|
options: { |
|
|
options: { |
|
|
type: "daterange", |
|
|
type: "datetimerange", |
|
|
|
|
|
angeSeparator: "至", |
|
|
|
|
|
valueFormat: "yyyy-MM-dd HH:mm:ss", |
|
|
|
|
|
startPlaceholder: "开始时间", |
|
|
|
|
|
endPlaceholder: "结束时间", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -85,9 +136,85 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
watch: { |
|
|
|
|
|
modelVisible: { |
|
|
|
|
|
immediate: true, |
|
|
|
|
|
handler(bool) { |
|
|
|
|
|
if (!bool) return; |
|
|
|
|
|
|
|
|
|
|
|
axiosIns.post(`business/device/functions/${this.deviceId}/${51}`) |
|
|
|
|
|
.then(async (result) => { |
|
|
|
|
|
if (result.code != 200) return; |
|
|
|
|
|
|
|
|
|
|
|
await delay(0); |
|
|
|
|
|
|
|
|
|
|
|
const formData = this.$refs.FormConfigRef?.formData; |
|
|
|
|
|
|
|
|
|
|
|
const data = result.data; |
|
|
|
|
|
|
|
|
|
|
|
switch (data.mode) { |
|
|
|
|
|
case "00": |
|
|
|
|
|
formData.controlType = "manual"; |
|
|
|
|
|
|
|
|
|
|
|
formData.onWorkStatus = data.onWorkStatus; |
|
|
|
|
|
formData.inWorkStatus = data.inWorkStatus; |
|
|
|
|
|
break; |
|
|
|
|
|
case "01": |
|
|
|
|
|
formData.controlType = "automatic"; |
|
|
|
|
|
|
|
|
|
|
|
formData.datePicker = [data.startDisplay, data.endDisplay]; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleSearch() { |
|
|
handleSubmit() { |
|
|
const result = cloneDeep(this.$refs.FormConfigRef?.formData); |
|
|
const result = cloneDeep(this.$refs.FormConfigRef?.formData); |
|
|
|
|
|
|
|
|
|
|
|
let functionId = 51; |
|
|
|
|
|
|
|
|
|
|
|
result.mode = result.controlType === 'manual' ? "00" : "01"; |
|
|
|
|
|
|
|
|
|
|
|
delete result.controlType; |
|
|
|
|
|
|
|
|
|
|
|
if (result.mode === '01') { |
|
|
|
|
|
if (!result.displayTime?.length) return Message.error(`时间不能为空!`); |
|
|
|
|
|
result.startDisplayTime = result.displayTime[0]; |
|
|
|
|
|
result.endDisplayTime = result.displayTime[1]; |
|
|
|
|
|
delete result.displayTime; |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!result.onWorkStatus || !result.inWorkStatus) return Message.error(`工作状态不能为空!`) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.submitting = true; |
|
|
|
|
|
|
|
|
|
|
|
console.log(result); |
|
|
|
|
|
|
|
|
|
|
|
// this.submitting = false; |
|
|
|
|
|
// return; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 接口 地址 |
|
|
|
|
|
* https://www.showdoc.com.cn/2450725213006196/10877717880262686 |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
axiosIns.post(`business/device/functions/${this.deviceId}/${functionId}`, result) |
|
|
|
|
|
.then((result) => { |
|
|
|
|
|
if (result.code != 200) return Message.error(`设备操作失败!`); |
|
|
|
|
|
|
|
|
|
|
|
this.modelVisible = false; |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((err) => { |
|
|
|
|
|
console.log("%c [ err ]-110-「DeviceControlDialog.vue」", "font-size:15px; background:#547bf2; color:#98bfff;", err); |
|
|
|
|
|
Message.error(`设备操作失败!`); |
|
|
|
|
|
}) |
|
|
|
|
|
.finally(() => { |
|
|
|
|
|
this.submitting = false; |
|
|
|
|
|
console.log(this.submitting) |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(result) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
@ -95,8 +222,8 @@ export default { |
|
|
|
|
|
|
|
|
<style lang='scss' scoped> |
|
|
<style lang='scss' scoped> |
|
|
.DeviceControlDialog { |
|
|
.DeviceControlDialog { |
|
|
width: 360px; |
|
|
width: 450px; |
|
|
height: 150px; |
|
|
height: 180px; |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
gap: 15px; |
|
|
gap: 15px; |
|
|