From 19ccf9686a266fe617b1f59e3b909e5ef2a57a9a Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期二, 29 九月 2020 11:06:58 +0800
Subject: [PATCH] 完善事件推送
---
src/pages/datapush/index/RightEvent.vue | 148 ++++++++++++++++++++++++------------------------
1 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/src/pages/datapush/index/RightEvent.vue b/src/pages/datapush/index/RightEvent.vue
index 8448884..e02d4dc 100644
--- a/src/pages/datapush/index/RightEvent.vue
+++ b/src/pages/datapush/index/RightEvent.vue
@@ -3,12 +3,17 @@
<div class="s-right-config">
<el-form>
<el-form-item label="鍚嶇О">
- <el-input v-model="eventData.name" placeholder="璇疯緭鍏ュ悕绉�" size="small" style="width:400px"></el-input>
+ <el-input
+ v-model="taskEditData.name"
+ placeholder="璇疯緭鍏ュ悕绉�"
+ size="small"
+ style="width:400px"
+ ></el-input>
</el-form-item>
<el-form-item label="鏃堕棿">
<el-date-picker
- v-model="eventData.time"
+ v-model="taskEditData.time"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
@@ -41,9 +46,9 @@
</div>
<el-form-item label="鑱斿姩鏂瑰紡" style="margin-top: 20px;width:100">
- <el-select v-model="eventData.lineWay" placeholder="璇烽�夋嫨" size="small">
+ <el-select v-model="taskEditData.lineWay" placeholder="璇烽�夋嫨" size="small">
<el-option
- v-for="item in eventData.lineOptions"
+ v-for="item in taskEditData.lineOptions"
:key="item.value"
:label="item.label"
:value="item.value"
@@ -52,8 +57,8 @@
</el-form-item>
<el-form-item label="鏍囩">
- <el-radio v-model="eventData.radioValue" label="1">婊¤冻鍏ㄩ儴</el-radio>
- <el-radio v-model="eventData.radioValue" label="2">婊¤冻浠绘剰涓�涓�</el-radio>
+ <el-radio v-model="taskEditData.radioValue" label="1">婊¤冻鍏ㄩ儴</el-radio>
+ <el-radio v-model="taskEditData.radioValue" label="2">婊¤冻浠绘剰涓�涓�</el-radio>
</el-form-item>
</el-form>
</div>
@@ -177,7 +182,7 @@
<div class="rule-title2">
<b>瑙勫垯</b>
- <div class="div-border" v-html="eventData.eventTxt"></div>
+ <div class="div-border" v-html="taskEditData.eventTxt"></div>
</div>
<div class="save-btn">
<el-button type="info" size="small" @click="onCancle" style="color:#222">鍙栨秷</el-button>
@@ -204,59 +209,12 @@
},
computed: {
urls() {
- return this.eventData.urls
- },
- ips() {
- return this.eventData.urls.filter(item => {
- return item.type === 'ip';
- })
- },
- domains() {
- return this.eventData.urls.filter(item => {
- return item.type === 'domain';
- })
- }
- },
- watch: {
- eventObject: {
- handler(newVal, oldVal) {
- this.eventData.enable = this.eventObject.enable;
- if (newVal !== oldVal) {
- if (this.eventData.id !== newVal.id) {
- this.dataList = [];
-
- this.eventData.id = newVal.id;
- this.eventData.name = newVal.name;
- this.eventData.time = [
- this.eventObject.time_start,
- this.eventObject.time_end
- ];
- this.eventData.serverIp = newVal.ip_ports;
- this.eventData.urls = newVal.urls;
- this.eventData.lineWay = newVal.link_type;
- this.eventData.eventTxt = newVal.rule_text;
- this.eventData.radioValue = newVal.is_satisfy_all ? "1" : "2";
-
- if (!this.eventData.urls) {
- this.$set(this.eventData, "urls", [])
- }
- if (newVal.rules) {
- newVal.rules.forEach(element => {
- let newRule = Object.assign(JSON.parse(JSON.stringify(this.baseRule)), element)
- this.dataList.push(newRule)
- this.selectTopic(newRule);
- this.selectOperator(newRule);
- })
- }
- }
- }
- },
- deep: true
+ return this.taskEditData.urls
}
},
data() {
return {
- eventData: {},
+ taskEditData: {},
dataList: [],
dictionary: [],
cameras: [],
@@ -280,6 +238,43 @@
},
};
},
+ watch: {
+ eventObject: {
+ handler(newVal, oldVal) {
+ this.taskEditData.enable = this.eventObject.enable;
+ if (newVal !== oldVal) {
+ if (this.taskEditData.id !== newVal.id) {
+ this.dataList = [];
+
+ this.taskEditData.id = newVal.id;
+ this.taskEditData.name = newVal.name;
+ this.taskEditData.time = [
+ this.eventObject.time_start,
+ this.eventObject.time_end
+ ];
+ this.taskEditData.serverIp = newVal.ip_ports;
+ this.taskEditData.urls = newVal.urls;
+ this.taskEditData.lineWay = newVal.link_type;
+ this.taskEditData.eventTxt = newVal.rule_text;
+ this.taskEditData.radioValue = newVal.is_satisfy_all ? "1" : "2";
+
+ if (!this.taskEditData.urls) {
+ this.$set(this.taskEditData, "urls", [])
+ }
+ if (newVal.rules) {
+ newVal.rules.forEach(element => {
+ let newRule = Object.assign(JSON.parse(JSON.stringify(this.baseRule)), element)
+ this.dataList.push(newRule)
+ this.selectTopic(newRule);
+ this.selectOperator(newRule);
+ })
+ }
+ }
+ }
+ },
+ deep: true
+ }
+ },
created() {
this.reAdd();
},
@@ -291,28 +286,28 @@
},
methods: {
addUrl() {
- this.eventData.urls.push({
+ this.taskEditData.urls.push({
checked: true,
hash: Math.random().toString(36).substr(2),
url: "",
});
},
delUrl(index) {
- this.$set(this.eventData.urls, index, this.baseRule)
- this.eventData.urls.splice(index, 1)
+ this.$set(this.taskEditData.urls, index, this.baseRule)
+ this.taskEditData.urls.splice(index, 1)
},
// 淇濆瓨
async eventPushsSave() {
// 鍒ゆ柇淇濆瓨鐨刬p鏄惁绗﹀悎鏍煎紡瑕佹眰
- if (this.eventData.urls.length < 1) {
+ if (this.taskEditData.urls.length < 1) {
this.$notify({
type: "warning",
message: "璇烽厤缃嚦灏戜竴鍙版帹閫佹湇鍔″櫒"
});
return;
}
- for (let i = 0; i < this.eventData.urls.length; i++) {
- if (this.eventData.urls[i].url.length < 1) {
+ for (let i = 0; i < this.taskEditData.urls.length; i++) {
+ if (this.taskEditData.urls[i].url.length < 1) {
this.$notify({
type: "warning",
message: "鎺ュ彛URL鍦板潃涓嶅厑璁镐负绌�"
@@ -353,22 +348,22 @@
});
let json = {
- enable: this.eventData.enable,
- id: this.eventData.id,
- ip_ports: this.eventData.serverIp,
- name: this.eventData.name,
+ enable: this.taskEditData.enable,
+ id: this.taskEditData.id,
+ ip_ports: this.taskEditData.serverIp,
+ name: this.taskEditData.name,
rule_text: ruleDesc.join("<br/>"),
rules: ruleList,
- time_start: this.eventData.time[0],
- time_end: this.eventData.time[1],
- urls: this.eventData.urls,
- is_satisfy_all: this.eventData.radioValue === "1",
- link_type: this.eventData.lineWay
+ time_start: this.taskEditData.time[0],
+ time_end: this.taskEditData.time[1],
+ urls: this.taskEditData.urls,
+ is_satisfy_all: this.taskEditData.radioValue === "1",
+ link_type: this.taskEditData.lineWay
};
let res = await eventPushsSave(json);
if (res && res.success) {
- this.eventData.eventTxt = ruleDesc.join("<br/>");
+ this.taskEditData.eventTxt = ruleDesc.join("<br/>");
this.$emit("updateList", res.data.id);
this.$notify({
type: "success",
@@ -383,7 +378,12 @@
this.dictionary = Object.assign(this.dictionary, res.data)
this.baseRule.topicTypeOptions = this.dictionary.EVENTRULETOPIC
this.baseRule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE
- this.dictionary['alarmLevel'] = this.dictionary.ALARMLEVEL
+ this.dictionary['alarmLevel'] = this.dictionary.ALARMLEVEL.map(el => {
+ return {
+ name: el.name,
+ value: el.name
+ }
+ })
}
},
async getCameras() {
@@ -488,7 +488,7 @@
},
// 娓呯┖閲嶆柊鏂板
reAdd() {
- this.eventData = {
+ this.taskEditData = {
id: "",
name: "",
time: [
--
Gitblit v1.8.0