ZZJ
2021-11-09 ccee429d379e0108b7445f72ade8d97c110a6fb3
src/pages/datapush/index/RightEvent.vue
@@ -203,7 +203,7 @@
      <div slot="title" class="slot-title">
        <p>请选择想要推送的字段</p>
        <div class="right">
          <el-checkbox v-model="allFieldChecked"></el-checkbox>
          <el-checkbox v-model="allFieldChecked" @change="allCheckChange"></el-checkbox>
        </div>
      </div>
      <div class="check-area" v-for="configObj in tempPushSet" :key="configObj.id">
@@ -215,7 +215,7 @@
        </div>
        <div class="flex-box flex-wrap">
          <div class="param flex-box" v-for="param in configObj.children" :key="param.id">
            <el-checkbox v-model="param.checked"></el-checkbox>
            <el-checkbox v-model="param.checked" @change="checkChildren"></el-checkbox>
            <span class="param-name">{{param.name}}</span>
            <el-input
              v-model="param.alias"
@@ -372,12 +372,33 @@
    openPushSetDialog() {
      this.pushFieldDialog = true;
      this.tempPushSet = JSON.parse(JSON.stringify(this.taskEditData.push_set));
      this.checkFlag()
    },
    checkFlag() {
      // debugger
      let flag = true
      this.tempPushSet.forEach(item => {
        if (item.checked == false) {
          flag = false
        }
      });
      this.allFieldChecked = flag
    },
    checkChildren(val) {
      console.log(val, 12121);
      if (val == false) {
        this.allFieldChecked = false
      } else if (val == true && this.allFieldChecked == false) {
        this.$nextTick(() => {
          this.checkFlag()
        })
      }
    },
    varifyField(param) {
      var reg = /^[A-Za-z]+[0-9-_]?$/;
      if (!reg.test(param.alias)) {
        this.$message('请输入合法字段名');
        debugger
        param.error = true;
      } else {
        param.error = false;
@@ -389,6 +410,15 @@
    },
    canclePushFieldSet() {
      this.pushFieldDialog = false;
    },
    allCheckChange(val) {
      this.tempPushSet.forEach(function (item) {
        item.checked = val
        item.children.forEach(function (child) {
          child.checked = val
        })
      })
    },
    submitPushFieldSet() {
      let flag = false;
@@ -407,14 +437,19 @@
        //NO SUBMIT
        return
      }
      this.taskEditData.push_set = this.tempPushSet;
      console.log(this.taskEditData.push_set);
      this.pushFieldDialog = false;
      // 保存规则
      this.eventPushsSave()
    },
    toggleConfigCheck(configObj) {
      configObj.children.forEach(child => {
        child.checked = configObj.checked
      })
      this.checkFlag()
    },
    getPushFields() {
      let _this = this;
@@ -442,8 +477,8 @@
      });
    },
    delUrl(index) {
      this.$set(this.taskEditData.urls, index, this.baseRule)
      this.taskEditData.urls.splice(index, 1)
      this.$set(this.taskEditData.urls, index, this.baseRule);
      this.taskEditData.urls.splice(index, 1);
    },
    // 保存
    async eventPushsSave() {
@@ -480,15 +515,15 @@
        }
        if (i.rule_value === "all*all") {
          str += "全部"
          str += "全部";
        } else if (i.rule_value === "null*null") {
          str += "空"
          str += "空";
        } else {
          str += i.rule_value
          str += i.rule_value;
        }
        if (str.length > 0) {
          ruleDesc.push(str)
          ruleDesc.push(str);
        }
      });
      // 处理规则列表数据结构
@@ -545,7 +580,7 @@
    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' });
@@ -569,7 +604,7 @@
              value: task.name,
              name: task.name
            })
            hash[task.name] = true
            hash[task.name] = true;
          }
        })
      }
@@ -595,44 +630,48 @@
        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) {
      debugger
      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) {
      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] = "全部"
            rule.rule_values[i] = "全部";
          }
          if (rule.rule_values[i] === "null*null") {
            rule.rule_values[i] = "空"
            rule.rule_values[i] = "空";
          }
        }
@@ -659,7 +698,7 @@
        }
      }
      rule.rule_value = val.join(",")
      rule.rule_value = val.join(",");
    },
    setOptionsDisable(rule) {
      let isAllSelect = (rule.rule_values.indexOf("全部") >= 0);
@@ -718,7 +757,8 @@
          }
        ],
        radioValue: "1",
        eventTxt: ""
        eventTxt: "",
        push_set: this.pushFields
      };
      this.dataList = [];
    },