From 8a87100aa2c8d905362630cdd09825c2a2239f04 Mon Sep 17 00:00:00 2001
From: heyujie <516346543@qq.com>
Date: 星期四, 25 二月 2021 10:07:06 +0800
Subject: [PATCH] 配置指向20:10
---
src/pages/datapush/index/RightEvent.vue | 163 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 110 insertions(+), 53 deletions(-)
diff --git a/src/pages/datapush/index/RightEvent.vue b/src/pages/datapush/index/RightEvent.vue
index 59d8ad1..dcaae85 100644
--- a/src/pages/datapush/index/RightEvent.vue
+++ b/src/pages/datapush/index/RightEvent.vue
@@ -241,7 +241,7 @@
</template>
<script>
-import { eventPushsSave, findByEventTopic,getPushSet } from "@/api/event";
+import { eventPushsSave, findByEventTopic, getPushSet } from "@/api/event";
import { findDictionaryByType, findDictionaryByID } from "@/api/dictionary";
import { getTaskList } from "@/api/search";
@@ -256,11 +256,11 @@
}
},
computed: {
- urls () {
+ urls() {
return this.taskEditData.urls
}
},
- data () {
+ data() {
return {
taskEditData: {},
dataList: [],
@@ -277,7 +277,6 @@
rule_values: [],
topic_arg: "",
topic_type: "",
-
topicTypeOptions: {},
topicArgOptions: {},
operatorOptions: {},
@@ -293,7 +292,7 @@
},
watch: {
eventObject: {
- handler (newVal, oldVal) {
+ handler(newVal, oldVal) {
this.taskEditData.enable = this.eventObject.enable;
if (newVal !== oldVal) {
if (this.taskEditData.id !== newVal.id) {
@@ -315,9 +314,9 @@
this.$set(this.taskEditData, "urls", [])
}
//this.taskEditData.push_set = this.eventObject.push_set;
- if(!this.eventObject.push_set.length){
+ if (!this.eventObject.push_set.length) {
this.$set(this.taskEditData, "push_set", this.pushFields)
- }else{
+ } else {
this.$set(this.taskEditData, "push_set", this.eventObject.push_set)
}
if (newVal.rules) {
@@ -334,7 +333,7 @@
deep: true
},
tempPushSet: {
- handler (n, o) {
+ handler(n, o) {
let _this = this;
let flag = false;
n.forEach(configObj => {
@@ -359,10 +358,10 @@
deep: true
}
},
- created () {
+ created() {
this.reAdd();
},
- mounted () {
+ mounted() {
// 鍔犺浇瀛楀吀
this.findByType();
this.getCameras();
@@ -370,15 +369,14 @@
this.getPushFields();
},
methods: {
- openPushSetDialog(){
- this.pushFieldDialog=true;
+ openPushSetDialog() {
+ this.pushFieldDialog = true;
this.tempPushSet = JSON.parse(JSON.stringify(this.taskEditData.push_set));
},
- varifyField (param) {
+ varifyField(param) {
var reg = /^[A-Za-z]+[0-9-_]?$/;
if (!reg.test(param.alias)) {
this.$message('璇疯緭鍏ュ悎娉曞瓧娈靛悕');
- debugger
param.error = true;
} else {
param.error = false;
@@ -388,10 +386,10 @@
// })
},
- canclePushFieldSet(){
+ canclePushFieldSet() {
this.pushFieldDialog = false;
},
- submitPushFieldSet () {
+ submitPushFieldSet() {
let flag = false;
//this.pushFields.forEach(configObj => {
this.tempPushSet.forEach(configObj => {
@@ -404,7 +402,7 @@
flag = true
}
});
- if(flag){
+ if (flag) {
//NO SUBMIT
return
}
@@ -412,14 +410,14 @@
console.log(this.taskEditData.push_set);
this.pushFieldDialog = false;
},
- toggleConfigCheck (configObj) {
+ toggleConfigCheck(configObj) {
configObj.children.forEach(child => {
child.checked = configObj.checked
})
},
- getPushFields () {
+ getPushFields() {
let _this = this;
- getPushSet().then(res=>{
+ getPushSet().then(res => {
_this.pushFields = res.data;
})
// this.pushFields = [
@@ -435,19 +433,19 @@
// ];
},
- addUrl () {
+ addUrl() {
this.taskEditData.urls.push({
checked: true,
hash: Math.random().toString(36).substr(2),
url: "",
});
},
- delUrl (index) {
- this.$set(this.taskEditData.urls, index, this.baseRule)
- this.taskEditData.urls.splice(index, 1)
+ delUrl(index) {
+ this.$set(this.taskEditData.urls, index, this.baseRule);
+ this.taskEditData.urls.splice(index, 1);
},
// 淇濆瓨
- async eventPushsSave () {
+ async eventPushsSave() {
// 鍒ゆ柇淇濆瓨鐨刬p鏄惁绗﹀悎鏍煎紡瑕佹眰
if (this.taskEditData.urls.length < 1) {
this.$notify({
@@ -480,10 +478,16 @@
str += ' = ';
}
- str += i.rule_value === "all*all" ? "鍏ㄩ儴" : i.rule_value;
+ if (i.rule_value === "all*all") {
+ str += "鍏ㄩ儴";
+ } else if (i.rule_value === "null*null") {
+ str += "绌�";
+ } else {
+ str += i.rule_value;
+ }
if (str.length > 0) {
- ruleDesc.push(str)
+ ruleDesc.push(str);
}
});
// 澶勭悊瑙勫垯鍒楄〃鏁版嵁缁撴瀯
@@ -523,7 +527,7 @@
}
},
// 鏌ユ壘瀛楀吀
- async findByType () {
+ async findByType() {
let res = await findDictionaryByType();
if (res && res.success) {
this.dictionary = Object.assign(this.dictionary, res.data)
@@ -537,10 +541,10 @@
})
}
},
- async getCameras () {
+ async getCameras() {
let rsp = await findByEventTopic({ topic: 'camera', type: 'name' });
if (rsp && rsp.success) {
- this.dictionary['camera'] = rsp.data
+ this.dictionary['camera'] = rsp.data;
}
rsp = await findByEventTopic({ topic: 'dbtable' });
@@ -553,7 +557,7 @@
})
}
},
- async getTasks () {
+ async getTasks() {
this.dictionary['task'] = []
let rsp = await getTaskList();
if (rsp && rsp.success) {
@@ -564,61 +568,77 @@
value: task.name,
name: task.name
})
- hash[task.name] = true
+ hash[task.name] = true;
}
})
}
},
// 鏂板缓閰嶇疆
- createSet () {
+ createSet() {
this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)));
},
- cleanSet () {
+ cleanSet() {
this.dataList.splice(0, this.dataList.length);
},
// 娣诲姞瀛愯鍒�
- addRule () {
+ addRule() {
this.dataList.push(JSON.parse(JSON.stringify(this.baseRule)));
},
// 鍒犻櫎瀛愯鍒�
- delRule (index) {
+ delRule(index) {
this.dataList.splice(index, 1);
},
// 瑙勫垯涓笅鎷夋鐨勯�夋嫨鍥炶皟
- selectTopic (rule, resetNext = false) {
+ selectTopic(rule, resetNext = false) {
rule.topicTypeOptions.forEach(element => {
if (element.value === rule.topic_type) {
rule.topicArgOptions = element.children;
if (resetNext) {
- rule.topic_arg = rule.topicArgOptions[0].value
- this.selectArg(rule, resetNext)
+ rule.topic_arg = rule.topicArgOptions[0].value;
+ this.selectArg(rule, resetNext);
}
}
});
},
- selectArg (rule, resetNext = false) {
+ selectArg(rule, resetNext = false) {
let argInfo = rule.topicArgOptions.filter(arg => {
- return arg.value === rule.topic_arg
+ return arg.value === rule.topic_arg;
})
if (argInfo.length > 0) {
- let desc = argInfo[0].description.split(",")
+ let desc = argInfo[0].description.split(",");
if (desc.length > 0) {
rule.operatorTypeOpionts = this.dictionary.EVENTTYPECOMPUTE.filter(el => {
- return desc.indexOf(el.value) >= 0
+ return desc.indexOf(el.value) >= 0;
})
}
}
if (resetNext) {
- rule.operator_type = rule.operatorTypeOpionts[rule.operatorTypeOpionts.length - 1].value
- this.selectOperator(rule, resetNext)
+ rule.operator_type = rule.operatorTypeOpionts[rule.operatorTypeOpionts.length - 1].value;
+ this.selectOperator(rule, resetNext);
}
},
- selectOperator (rule, resetNext = false) {
+ selectOperator(rule, resetNext = false) {
if (rule.operator_type === "option") {
- rule.ruleValueOptions = this.dictionary[rule.topic_type] ? this.dictionary[rule.topic_type] : []
- rule.rule_values = rule.rule_value.split(",")
+ rule.ruleValueOptions = this.dictionary[rule.topic_type] ? this.dictionary[rule.topic_type] : [];
+
+ if (rule.rule_value != "") {
+ rule.rule_values = rule.rule_value.split(",");
+ }
+
+ // 澶勭悊 鍏ㄩ儴/绌�
+ for (let i = 0; i < rule.rule_values.length; i++) {
+ if (rule.rule_values[i] === "all*all") {
+ rule.rule_values[i] = "鍏ㄩ儴";
+ }
+
+ if (rule.rule_values[i] === "null*null") {
+ rule.rule_values[i] = "绌�";
+ }
+ }
+
+ this.setOptionsDisable(rule);
}
if (resetNext) {
@@ -626,11 +646,48 @@
rule.rule_values = [];
}
},
- selectValue (rule, val) {
- rule.rule_value = val.join(",")
+ selectValue(rule, val) {
+ if (rule.operator_type === "option") {
+ this.setOptionsDisable(rule);
+
+ if (val.indexOf("鍏ㄩ儴") >= 0) {
+ rule.rule_value = "all*all";
+ return;
+ }
+
+ if (val.indexOf("绌�") >= 0) {
+ rule.rule_value = "null*null";
+ return;
+ }
+ }
+
+ rule.rule_value = val.join(",");
+ },
+ setOptionsDisable(rule) {
+ let isAllSelect = (rule.rule_values.indexOf("鍏ㄩ儴") >= 0);
+ let isNullSelect = (rule.rule_values.indexOf("绌�") >= 0);
+
+ rule.ruleValueOptions.forEach(opt => {
+ if (!rule.rule_values.length) {
+ opt.disabled = false;
+ return
+ }
+
+ if (opt.name === "鍏ㄩ儴") {
+ opt.disabled = !isAllSelect;
+ return
+ }
+
+ if (opt.name === "绌�") {
+ opt.disabled = !isNullSelect;
+ return
+ }
+
+ opt.disabled = (isAllSelect || isNullSelect);
+ })
},
// 鏍规嵁value杩斿洖瀵瑰簲鐨刵ame
- getNameByValue (arr, value) {
+ getNameByValue(arr, value) {
let s = arr.find(item => {
return item.value === value;
});
@@ -638,7 +695,7 @@
return s.name;
},
// 娓呯┖閲嶆柊鏂板
- reAdd () {
+ reAdd() {
this.taskEditData = {
id: "",
name: "",
@@ -667,7 +724,7 @@
};
this.dataList = [];
},
- onCancle () {
+ onCancle() {
this.$emit('onCancle')
}
}
--
Gitblit v1.8.0