|
@ -30,7 +30,8 @@ import { Message } from "element-ui"; |
|
|
const workStatus = [ |
|
|
const workStatus = [ |
|
|
{ |
|
|
{ |
|
|
key: "00", |
|
|
key: "00", |
|
|
label: "不更新状态" |
|
|
label: "不更新状态", |
|
|
|
|
|
disabled: false |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
key: "01", |
|
|
key: "01", |
|
@ -46,8 +47,9 @@ const workStatus = [ |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
key: "04", |
|
|
key: "04", |
|
|
label: "关闭" |
|
|
label: "关闭", |
|
|
}, |
|
|
disabled: false |
|
|
|
|
|
} |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
@ -73,18 +75,28 @@ export default { |
|
|
label: "类型:", |
|
|
label: "类型:", |
|
|
key: "controlType", |
|
|
key: "controlType", |
|
|
type: "RadioGroup", |
|
|
type: "RadioGroup", |
|
|
default: "manual", |
|
|
default: "00", |
|
|
ons: { |
|
|
ons: { |
|
|
input: (value, data) => { |
|
|
input: (value, data, that) => { |
|
|
const oldFormData = this.oldFormData; |
|
|
const oldFormData = this.oldFormData; |
|
|
if (!oldFormData) return; |
|
|
if (!oldFormData) return; |
|
|
|
|
|
|
|
|
|
|
|
that.formList[1].options.options.splice(-1, 1, { |
|
|
|
|
|
...workStatus.slice(-1)[0], |
|
|
|
|
|
disabled: value != "00" |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
that.formList[1].options.options.splice(0, 1, { |
|
|
|
|
|
...workStatus[0], |
|
|
|
|
|
disabled: value != "00" |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
switch (value) { |
|
|
switch (value) { |
|
|
case "manual": |
|
|
case "01": |
|
|
data.onWorkStatus = oldFormData.onWorkStatus; |
|
|
|
|
|
data.inWorkStatus = oldFormData.inWorkStatus; |
|
|
if (['04', '00'].includes(data.onWorkStatus)) data.onWorkStatus = null; |
|
|
break; |
|
|
if (['04', '00'].includes(data.inWorkStatus)) data.inWorkStatus = null; |
|
|
case "automatic": |
|
|
|
|
|
Array.isArray(oldFormData.displayTime) && (data.displayTime = [...oldFormData.displayTime]); |
|
|
Array.isArray(oldFormData.displayTime) && (data.displayTime = [...oldFormData.displayTime]); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -94,13 +106,17 @@ export default { |
|
|
type: 'circle', |
|
|
type: 'circle', |
|
|
options: [ |
|
|
options: [ |
|
|
{ |
|
|
{ |
|
|
key: "manual", |
|
|
key: "00", |
|
|
label: "手动控制", |
|
|
label: "手动控制", |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
key: "automatic", |
|
|
key: "01", |
|
|
label: "自动控制", |
|
|
label: "自动控制", |
|
|
} |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: "02", |
|
|
|
|
|
label: "万年历", |
|
|
|
|
|
}, |
|
|
], |
|
|
], |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
@ -109,7 +125,6 @@ export default { |
|
|
key: "onWorkStatus", |
|
|
key: "onWorkStatus", |
|
|
required: true, |
|
|
required: true, |
|
|
type: "select", |
|
|
type: "select", |
|
|
visible: (data) => data.controlType == "manual", |
|
|
|
|
|
options: { |
|
|
options: { |
|
|
placeholder: "请选择", |
|
|
placeholder: "请选择", |
|
|
options: workStatus |
|
|
options: workStatus |
|
@ -120,7 +135,6 @@ export default { |
|
|
key: "inWorkStatus", |
|
|
key: "inWorkStatus", |
|
|
required: true, |
|
|
required: true, |
|
|
type: "select", |
|
|
type: "select", |
|
|
visible: (data) => data.controlType == "manual", |
|
|
|
|
|
options: { |
|
|
options: { |
|
|
placeholder: "请选择", |
|
|
placeholder: "请选择", |
|
|
options: workStatus |
|
|
options: workStatus |
|
@ -131,7 +145,7 @@ export default { |
|
|
key: "displayTime", |
|
|
key: "displayTime", |
|
|
type: "timePicker", |
|
|
type: "timePicker", |
|
|
required: true, |
|
|
required: true, |
|
|
visible: (data) => data.controlType == "automatic", |
|
|
visible: (data) => data.controlType == "01", |
|
|
options: { |
|
|
options: { |
|
|
isRange: true, |
|
|
isRange: true, |
|
|
rangeSeparator: "至", |
|
|
rangeSeparator: "至", |
|
@ -164,57 +178,67 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
reDisplay() { |
|
|
requestURL(functionId, options = {}) { |
|
|
request.post(`business/device/functions/${this.deviceId}/${52}`, {}) |
|
|
return new Promise((resolve, reject) => { |
|
|
.then(async (result) => { |
|
|
request.post(`business/device/functions/${this.deviceId}/${functionId}`, options) |
|
|
if (result.code != 200) return; |
|
|
.then((result) => { |
|
|
|
|
|
if (result.code != 200) return reject(); |
|
|
|
|
|
|
|
|
|
|
|
resolve(result.data[0]); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((err) => { |
|
|
|
|
|
reject(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
reDisplay() { |
|
|
|
|
|
this.requestURL(52) |
|
|
|
|
|
.then(async (data) => { |
|
|
await delay(0); |
|
|
await delay(0); |
|
|
|
|
|
|
|
|
const formData = this.$refs.FormConfigRef?.formData; |
|
|
const formData = this.$refs.FormConfigRef?.formData; |
|
|
|
|
|
|
|
|
const data = result.data[0]; |
|
|
formData.controlType = data.mode; |
|
|
console.log("%c [ data ]-155-「DeviceControlDialog.vue」", "font-size:15px; background:#66352f; color:#aa7973;", data); |
|
|
|
|
|
|
|
|
|
|
|
switch (data.mode) { |
|
|
switch (data.mode) { |
|
|
case "00": |
|
|
case "00": |
|
|
formData.controlType = "manual"; |
|
|
|
|
|
|
|
|
|
|
|
formData.onWorkStatus = data.onWorkStatus; |
|
|
formData.onWorkStatus = data.onWorkStatus; |
|
|
formData.inWorkStatus = data.inWorkStatus; |
|
|
formData.inWorkStatus = data.inWorkStatus; |
|
|
break; |
|
|
break; |
|
|
case "01": |
|
|
case "01": |
|
|
formData.controlType = "automatic"; |
|
|
case "02": |
|
|
|
|
|
await this.requestURL("3C") |
|
|
|
|
|
.then((data2) => { |
|
|
|
|
|
formData.onWorkStatus = data2.onWorkStatus; |
|
|
|
|
|
formData.inWorkStatus = data2.inWorkStatus; |
|
|
|
|
|
|
|
|
formData.displayTime = [data.startDisplay, data.endDisplay]; |
|
|
if (data.mode === '01') |
|
|
|
|
|
formData.displayTime = [data.startDisplay, data.endDisplay]; |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(() => { }); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.oldFormData = { ...formData }; |
|
|
this.oldFormData = { ...formData }; |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
handleSubmit() { |
|
|
handleSubmit() { |
|
|
const result = {}, formData = this.$refs.FormConfigRef?.formData; |
|
|
const result = {}, formData = this.$refs.FormConfigRef?.formData; |
|
|
|
|
|
|
|
|
let functionId = 51; |
|
|
result.mode = formData.controlType; |
|
|
|
|
|
|
|
|
result.mode = formData.controlType === 'manual' ? "00" : "01"; |
|
|
|
|
|
|
|
|
|
|
|
delete result.controlType; |
|
|
delete result.controlType; |
|
|
|
|
|
|
|
|
if (result.mode === '01') { |
|
|
if (result.mode === '01') { |
|
|
if (!formData.displayTime?.length) return Message.error(`时间不能为空!`); |
|
|
if (!formData.displayTime?.length) return Message.error(`时间不能为空!`); |
|
|
result.startDisplayTime = formData.displayTime[0]; |
|
|
|
|
|
result.endDisplayTime = formData.displayTime[1]; |
|
|
|
|
|
delete result.displayTime; |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!formData.onWorkStatus || !formData.inWorkStatus) return Message.error(`工作状态不能为空!`); |
|
|
|
|
|
|
|
|
|
|
|
result.onWorkStatus = formData.onWorkStatus |
|
|
|
|
|
result.inWorkStatus = formData.inWorkStatus |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!formData.onWorkStatus || !formData.inWorkStatus) return Message.error(`工作状态不能为空!`); |
|
|
|
|
|
|
|
|
|
|
|
result.onWorkStatus = formData.onWorkStatus; |
|
|
|
|
|
result.inWorkStatus = formData.inWorkStatus; |
|
|
|
|
|
|
|
|
this.submitting = true; |
|
|
this.submitting = true; |
|
|
|
|
|
|
|
|
// this.submitting = false; |
|
|
// this.submitting = false; |
|
@ -225,10 +249,33 @@ export default { |
|
|
* |
|
|
* |
|
|
* https://www.showdoc.com.cn/2450725213006196/10877717880262686 |
|
|
* https://www.showdoc.com.cn/2450725213006196/10877717880262686 |
|
|
*/ |
|
|
*/ |
|
|
request.post(`business/device/functions/${this.deviceId}/${functionId}`, result) |
|
|
let promise = []; |
|
|
.then((result) => { |
|
|
|
|
|
if (result.code != 200) return Message.error(`设备操作失败!`); |
|
|
switch (result.mode) { |
|
|
|
|
|
case "00": |
|
|
|
|
|
promise.push(this.requestURL("51", result)) |
|
|
|
|
|
break; |
|
|
|
|
|
case "01": |
|
|
|
|
|
case "02": |
|
|
|
|
|
|
|
|
|
|
|
const options = { mode: result.mode }; |
|
|
|
|
|
|
|
|
|
|
|
if (result.mode === '01') { |
|
|
|
|
|
options.startDisplayTime = formData.displayTime[0]; |
|
|
|
|
|
options.endDisplayTime = formData.displayTime[1]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
promise.push( |
|
|
|
|
|
this.requestURL("30", { |
|
|
|
|
|
onWorkStatus: result.onWorkStatus, |
|
|
|
|
|
inWorkStatus: result.inWorkStatus, |
|
|
|
|
|
}), |
|
|
|
|
|
this.requestURL("51", options), |
|
|
|
|
|
) |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
Promise.all(promise) |
|
|
|
|
|
.then(() => { |
|
|
this.modelVisible = false; |
|
|
this.modelVisible = false; |
|
|
}) |
|
|
}) |
|
|
.catch((err) => { |
|
|
.catch((err) => { |
|
@ -246,7 +293,7 @@ export default { |
|
|
<style lang='scss' scoped> |
|
|
<style lang='scss' scoped> |
|
|
.DeviceControlDialog { |
|
|
.DeviceControlDialog { |
|
|
width: 450px; |
|
|
width: 450px; |
|
|
height: 180px; |
|
|
height: 210px; |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
gap: 15px; |
|
|
gap: 15px; |
|
|