|
|
@ -1,34 +1,32 @@ |
|
|
|
<template> |
|
|
|
<Dialog v-model="modelVisible" :title="title"> |
|
|
|
<div class="EventAddPlanDialog"> |
|
|
|
<ElForm :model="formData" inline :rules="rules" ref="ruleForm"> |
|
|
|
<div class="first"> |
|
|
|
<el-radio-group v-model="planName"> |
|
|
|
<el-radio-button v-for="item in info" :key="item.id" :label="item.planName"></el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
</div> |
|
|
|
<div class="first"> |
|
|
|
<el-radio-group v-model="planName" @input="changeRadio"> |
|
|
|
<el-radio-button v-for="item in info" :key="item.id" :label="item.planName"></el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="second"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="2"> |
|
|
|
<div class="text">联动设备:</div> |
|
|
|
</el-col> |
|
|
|
<el-col :span="22"> |
|
|
|
<FormTable ref="secondFormTable" :tableData="secondFormData"></FormTable> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
|
<div class="third"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="2"> |
|
|
|
<div class="text">恢复操作:</div> |
|
|
|
</el-col> |
|
|
|
<el-col :span="22"> |
|
|
|
<FormTable ref="thirdFormTable" :tableData="thirdFormData"></FormTable> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
|
</ElForm> |
|
|
|
<div class="second"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="2"> |
|
|
|
<div class="text">联动设备:</div> |
|
|
|
</el-col> |
|
|
|
<el-col :span="22"> |
|
|
|
<FormTable ref="secondFormTable" :tableData="secondFormData"></FormTable> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
|
<div class="third"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="2"> |
|
|
|
<div class="text">恢复操作:</div> |
|
|
|
</el-col> |
|
|
|
<el-col :span="22"> |
|
|
|
<FormTable ref="thirdFormTable" :tableData="thirdFormData"></FormTable> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<template #footer> |
|
|
@ -47,6 +45,7 @@ import Button from '@screen/components/Buttons/Button.vue'; |
|
|
|
import request from '@/utils/request'; |
|
|
|
import { Message } from "element-ui"; |
|
|
|
import { throttle } from "lodash" |
|
|
|
import { isDate } from 'mathjs'; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
@ -77,12 +76,8 @@ export default { |
|
|
|
title: '事件确认', |
|
|
|
dialogType: 1, |
|
|
|
planId: 0, |
|
|
|
plans: [], |
|
|
|
submitting: false, |
|
|
|
formData: { |
|
|
|
eventCategory: 1, |
|
|
|
eventType: 1, |
|
|
|
triggerMechanism: 1 |
|
|
|
}, |
|
|
|
secondFormData: [{ |
|
|
|
deviceType: 1, |
|
|
|
searchRule: 1, |
|
|
@ -180,15 +175,6 @@ export default { |
|
|
|
label: '小于(<)' |
|
|
|
}, |
|
|
|
], |
|
|
|
rules: { |
|
|
|
planName: [ |
|
|
|
{ required: true, message: '请输入预案名称', trigger: 'blur' }, |
|
|
|
|
|
|
|
], |
|
|
|
eventType: [ |
|
|
|
{ required: true, message: '请选择事件类型', trigger: 'change' } |
|
|
|
], |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
@ -198,8 +184,10 @@ export default { |
|
|
|
modelVisible: { |
|
|
|
get() { |
|
|
|
if (this.visible) { |
|
|
|
this.planName = this.info[0]?.planName || ''; |
|
|
|
this.dcExecuteAction = this.info[0]?.dcExecuteAction || []; |
|
|
|
if (this.info.length > 0) { |
|
|
|
this.planName = this.info[0]?.planName || ''; |
|
|
|
this.initData(this.info[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
return this.visible; |
|
|
|
}, |
|
|
@ -210,26 +198,37 @@ export default { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
initData(data) { |
|
|
|
this.planId = data.id; |
|
|
|
this.formData = { |
|
|
|
eventCategory: data.eventCategory, |
|
|
|
planName: data.planName, |
|
|
|
eventType: data.eventType, |
|
|
|
triggerMechanism: data.triggerMechanism, |
|
|
|
} |
|
|
|
this.secondFormData = []; |
|
|
|
this.thirdFormData = []; |
|
|
|
dcExecuteAction.forEach(it => { |
|
|
|
if (it.deviceList) { |
|
|
|
it.deviceList = it.deviceList.split(','); |
|
|
|
console.log('data', data) |
|
|
|
if (!data) return; |
|
|
|
// this.planId = data.id; |
|
|
|
let dcExecuteAction = data.dcExecuteAction; |
|
|
|
let secondFormData = []; |
|
|
|
let thirdFormData = []; |
|
|
|
dcExecuteAction.forEach(it => { |
|
|
|
let action = { ...it }; |
|
|
|
if (it.otherConfig) { |
|
|
|
let config = JSON.parse(it.otherConfig); |
|
|
|
let qbb = '' |
|
|
|
if (config.id) { |
|
|
|
qbb = config.content; |
|
|
|
config = { dcInfoBoardTemplate: config }; |
|
|
|
} |
|
|
|
if (it.actionType == 1) { |
|
|
|
this.secondFormData.push(it); |
|
|
|
} else if (it.actionType == 2) { |
|
|
|
this.thirdFormData.push(it); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// if (config.state) { |
|
|
|
// config.gzms = config.state |
|
|
|
// } |
|
|
|
action = { ...it, ...config, qbb: qbb }; |
|
|
|
} |
|
|
|
if (it.deviceList) { |
|
|
|
action.deviceList = it.deviceList.split(',').map(str => Number(str)); |
|
|
|
} |
|
|
|
if (it.actionType == 1) { |
|
|
|
secondFormData.push(action); |
|
|
|
} else if (it.actionType == 2) { |
|
|
|
thirdFormData.push(action); |
|
|
|
} |
|
|
|
}) |
|
|
|
this.secondFormData = secondFormData; |
|
|
|
this.thirdFormData = thirdFormData; |
|
|
|
}, |
|
|
|
async loadData() { |
|
|
|
if (this.deviceData.length <= 0) { |
|
|
@ -238,91 +237,20 @@ export default { |
|
|
|
method: "get", |
|
|
|
}) |
|
|
|
if (result.code != 200) return Message.error(result?.msg); |
|
|
|
console.log('123'); |
|
|
|
// console.log('123'); |
|
|
|
this.deviceData = result.data; |
|
|
|
// return result.data; |
|
|
|
} |
|
|
|
return this.deviceData; |
|
|
|
}, |
|
|
|
changeEventType(value = 1) { |
|
|
|
this.mechanismOptions = optionsMap[this.formData.eventCategory || 1][value]; |
|
|
|
}, |
|
|
|
changeRadio(value = 1) { |
|
|
|
const optionsMap = { |
|
|
|
1: [{ |
|
|
|
value: 1, |
|
|
|
label: '异常天气' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 2, |
|
|
|
label: '交通事故' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 3, |
|
|
|
label: '非法上路' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 4, |
|
|
|
label: '车辆故障' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 5, |
|
|
|
label: '交通拥堵' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 6, |
|
|
|
label: '交通管制' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 7, |
|
|
|
label: '服务区异常' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 8, |
|
|
|
label: '施工建设' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 9, |
|
|
|
label: '路障清除' |
|
|
|
}], |
|
|
|
2: [{ |
|
|
|
value: 1, |
|
|
|
label: '异常天气' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 2, |
|
|
|
label: '拥堵' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 3, |
|
|
|
label: '非机动车' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 4, |
|
|
|
label: '行人' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 5, |
|
|
|
label: '烟火' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 6, |
|
|
|
label: '抛洒物' |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: 7, |
|
|
|
label: '逆行' |
|
|
|
}, |
|
|
|
] |
|
|
|
} |
|
|
|
this.eventOptions = optionsMap[value]; |
|
|
|
this.changeEventType(); |
|
|
|
}, |
|
|
|
handleChange() { |
|
|
|
|
|
|
|
changeRadio(value) { |
|
|
|
console.log('va', value) |
|
|
|
let plan = this.info.find(it => it.planName == value); |
|
|
|
console.log('plan', plan) |
|
|
|
this.initData(plan); |
|
|
|
}, |
|
|
|
formatData(it, value = 1) { |
|
|
|
let data = { ...it, actionType: value } |
|
|
|
let data = { ...it, actionType: value, emergencyPlansId: id } |
|
|
|
if (it.deviceList && typeof it.deviceList !== 'string' && it.deviceList.length > 0) { |
|
|
|
data.deviceList = it.deviceList.join(','); |
|
|
|
} else { |
|
|
@ -334,12 +262,16 @@ export default { |
|
|
|
if (it.controlModel) { |
|
|
|
let other = { |
|
|
|
controlModel: it.controlModel, |
|
|
|
controlModelName: controlModelMap[it.controlModel], |
|
|
|
state: it.state, |
|
|
|
name: gzztMap[it.state] |
|
|
|
} |
|
|
|
if (it.time && it?.time[0]) { |
|
|
|
other = { |
|
|
|
controlModel: it.controlModel, |
|
|
|
controlModelName: controlModelMap[it.controlModel], |
|
|
|
state: it.state, |
|
|
|
name: gzztMap[it.state], |
|
|
|
startTime: it.time[0], |
|
|
|
endTime: it.time[1] |
|
|
|
} |
|
|
@ -349,74 +281,55 @@ export default { |
|
|
|
if (it.gzms) { |
|
|
|
data.otherConfig = JSON.stringify({ |
|
|
|
state: it.gzms, |
|
|
|
name: gzmsMap[it.gzms], |
|
|
|
operationDuration: it.operationDuration, |
|
|
|
}) |
|
|
|
} |
|
|
|
return data; |
|
|
|
}, |
|
|
|
handleSubmit() { |
|
|
|
this.$refs['ruleForm'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
// this.submitting = false; |
|
|
|
let secondFormTable = this.$refs['secondFormTable'].tableData || []; |
|
|
|
let thirdFormTable = this.$refs['thirdFormTable'].tableData || []; |
|
|
|
let dcArr = []; |
|
|
|
secondFormTable.forEach(it => { |
|
|
|
dcArr.push(this.formatData(it, 1)); |
|
|
|
}) |
|
|
|
thirdFormTable.forEach(it => { |
|
|
|
dcArr.push(this.formatData(it, 2)); |
|
|
|
}) |
|
|
|
|
|
|
|
console.log({ |
|
|
|
...this.formData, |
|
|
|
dcExecuteAction: dcArr |
|
|
|
}) |
|
|
|
// return; |
|
|
|
if (this.dialogType == 1) {//新增 |
|
|
|
request({ |
|
|
|
url: `/business/plans`, |
|
|
|
method: "post", |
|
|
|
data: { |
|
|
|
...this.formData, |
|
|
|
dcExecuteAction: dcArr |
|
|
|
} |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return Message.error(result?.msg); |
|
|
|
Message.success("提交成功"); |
|
|
|
this.modelVisible = false; |
|
|
|
}).catch(() => { |
|
|
|
Message.error("提交失败"); |
|
|
|
}).finally(() => { |
|
|
|
this.submitting = false; |
|
|
|
this.$emit('reInitData', true); |
|
|
|
}) |
|
|
|
} else if (this.dialogType == 2) {//修改 |
|
|
|
request({ |
|
|
|
url: `/business/plans`, |
|
|
|
method: "put", |
|
|
|
data: { |
|
|
|
...this.formData, |
|
|
|
id: this.planId, |
|
|
|
dcExecuteAction: dcArr |
|
|
|
} |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return Message.error(result?.msg); |
|
|
|
Message.success("提交成功"); |
|
|
|
this.modelVisible = false; |
|
|
|
}).catch(() => { |
|
|
|
Message.error("提交失败"); |
|
|
|
}).finally(() => { |
|
|
|
this.submitting = false; |
|
|
|
this.$emit('reInitData', true); |
|
|
|
}) |
|
|
|
// this.submitting = false; |
|
|
|
let secondFormTable = this.$refs['secondFormTable'].tableData || []; |
|
|
|
let thirdFormTable = this.$refs['thirdFormTable'].tableData || []; |
|
|
|
console.log('12', thirdFormTable); |
|
|
|
let dcArr = []; |
|
|
|
let id = ''; |
|
|
|
if (this.dialogType == 2) id = this.planId; |
|
|
|
secondFormTable.forEach(it => { |
|
|
|
dcArr.push(this.formatData(it, 1, id)); |
|
|
|
}) |
|
|
|
thirdFormTable.forEach(it => { |
|
|
|
dcArr.push(this.formatData(it, 2, id)); |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
console.log({ |
|
|
|
dcExecuteAction: dcArr |
|
|
|
}) |
|
|
|
return; |
|
|
|
if (this.dialogType == 1) {//新增 |
|
|
|
|
|
|
|
} else if (this.dialogType == 2) {//修改 |
|
|
|
// request({ |
|
|
|
// url: `/business/plans`, |
|
|
|
// method: "put", |
|
|
|
// data: { |
|
|
|
// ...this.formData, |
|
|
|
// id: this.planId, |
|
|
|
// dcExecuteAction: dcArr |
|
|
|
// } |
|
|
|
// }).then((result) => { |
|
|
|
// if (result.code != 200) return Message.error(result?.msg); |
|
|
|
// Message.success("提交成功"); |
|
|
|
// this.modelVisible = false; |
|
|
|
// }).catch(() => { |
|
|
|
// Message.error("提交失败"); |
|
|
|
// }).finally(() => { |
|
|
|
// this.submitting = false; |
|
|
|
// this.$emit('reInitData', true); |
|
|
|
// }) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|