hanbaoshan
2021-02-03 041e543111ff5b38dfa2815169cb4e31424e1893
事件推送字段配置接口调试
2个文件已修改
69 ■■■■ 已修改文件
src/api/event.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/datapush/index/RightEvent.vue 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/event.ts
@@ -76,4 +76,12 @@
    method: "get"
  })
}
//获取所有的推送字段配置
export const getPushSet = ()=>{
  return request({
    url:'/data/api-v/eventPush/getPushSet',
    method:'get'
  })
}
src/pages/datapush/index/RightEvent.vue
@@ -186,7 +186,7 @@
      </div>
      <div class="config-item">
        <b>推送字段</b>
        <el-button type="primary" size="mini" @click="pushFieldDialog=true">设置</el-button>
        <el-button type="primary" size="mini" @click="openPushSetDialog">设置</el-button>
      </div>
      <div class="save-btn">
        <el-button type="info" size="small" @click="onCancle" style="color:#222">取消</el-button>
@@ -206,7 +206,7 @@
          <el-checkbox v-model="allFieldChecked"></el-checkbox>
        </div>
      </div>
      <div class="check-area" v-for="configObj in pushFields" :key="configObj.id">
      <div class="check-area" v-for="configObj in tempPushSet" :key="configObj.id">
        <div class="header">
          <div class="title">{{configObj.name}}</div>
          <div class="right">
@@ -228,7 +228,7 @@
        </div>
      </div>
      <div slot="footer" class="text-center">
        <el-button size="small">取消</el-button>
        <el-button size="small" @click="canclePushFieldSet">取消</el-button>
        <el-button
          size="small"
          type="primary"
@@ -241,7 +241,7 @@
</template>
<script>
import { eventPushsSave, findByEventTopic } from "@/api/event";
import { eventPushsSave, findByEventTopic,getPushSet } from "@/api/event";
import { findDictionaryByType, findDictionaryByID } from "@/api/dictionary";
import { getTaskList } from "@/api/search";
@@ -285,6 +285,7 @@
        ruleValueOptions: []
      },
      pushFieldDialog: false,
      tempPushSet: [],
      pushFields: [],
      allFieldChecked: false,
      disabledPushFieldSet: true,
@@ -313,6 +314,12 @@
            if (!this.taskEditData.urls) {
              this.$set(this.taskEditData, "urls", [])
            }
            //this.taskEditData.push_set = this.eventObject.push_set;
            if(!this.eventObject.push_set.length){
              this.$set(this.taskEditData, "push_set", this.pushFields)
            }else{
              this.$set(this.taskEditData, "push_set", this.eventObject.push_set)
            }
            if (newVal.rules) {
              newVal.rules.forEach(element => {
                let newRule = Object.assign(JSON.parse(JSON.stringify(this.baseRule)), element)
@@ -326,7 +333,7 @@
      },
      deep: true
    },
    pushFields: {
    tempPushSet: {
      handler (n, o) {
        let _this = this;
        let flag = false;
@@ -363,6 +370,10 @@
    this.getPushFields();
  },
  methods: {
    openPushSetDialog(){
      this.pushFieldDialog=true;
      this.tempPushSet = JSON.parse(JSON.stringify(this.taskEditData.push_set));
    },
    varifyField (param) {
      var reg = /^[A-Za-z]+[0-9-_]?$/;
      if (!reg.test(param.alias)) {
@@ -377,9 +388,13 @@
      // })
    },
    canclePushFieldSet(){
      this.pushFieldDialog = false;
    },
    submitPushFieldSet () {
      let flag = false;
      this.pushFields.forEach(configObj => {
      //this.pushFields.forEach(configObj => {
      this.tempPushSet.forEach(configObj => {
        let errorOne = configObj.children.find(param => param.checked && param.error);
        if (errorOne) {
          this.$notify({
@@ -390,9 +405,12 @@
        }
      });
      if(flag){
        //NO SUBMIT
        return
      }
      alert('submit')
      this.taskEditData.push_set = this.tempPushSet;
      console.log(this.taskEditData.push_set);
      this.pushFieldDialog = false;
    },
    toggleConfigCheck (configObj) {
      configObj.children.forEach(child => {
@@ -400,17 +418,21 @@
      })
    },
    getPushFields () {
      this.pushFields = [
        {          id: 'sxjxx', name: '摄像机信息', checked: false, alias: '',
          children: [
            { name: '摄像机ID', checked: false, alias: 'cameraID', id: 'cameraID', children: null },
            { name: '摄像机名称', checked: false, alias: 'cameraName', id: 'cameraName', children: null },
            { name: '摄像机地址', checked: false, alias: 'cameraAddr', id: 'cameraAddr', children: null },
            { name: '摄像机址', checked: false, alias: 'cameraAdr', id: 'cameraAdr', children: null }
          ]        },
        {          id: 'cjxx', name: '场景信息', checked: false, alias: '',
          children: [{ name: '场景ID', checked: false, alias: 'taskId', id: 'tskId', children: null }]        },
      ];
      let _this = this;
      getPushSet().then(res=>{
        _this.pushFields = res.data;
      })
      // this.pushFields = [
      //   {          id: 'sxjxx', name: '摄像机信息', checked: false, alias: '',
      //     children: [
      //       { name: '摄像机ID', checked: false, alias: 'cameraID', id: 'cameraID', children: null },
      //       { name: '摄像机名称', checked: false, alias: 'cameraName', id: 'cameraName', children: null },
      //       { name: '摄像机地址', checked: false, alias: 'cameraAddr', id: 'cameraAddr', children: null },
      //       { name: '摄像机址', checked: false, alias: 'cameraAdr', id: 'cameraAdr', children: null }
      //     ]        },
      //   {          id: 'cjxx', name: '场景信息', checked: false, alias: '',
      //     children: [{ name: '场景ID', checked: false, alias: 'taskId', id: 'tskId', children: null }]        },
      // ];
    },
    addUrl () {
@@ -486,7 +508,8 @@
        time_end: this.taskEditData.time[1],
        urls: this.taskEditData.urls,
        is_satisfy_all: this.taskEditData.radioValue === "1",
        link_type: this.taskEditData.lineWay
        link_type: this.taskEditData.lineWay,
        push_set: this.taskEditData.push_set
      };
      let res = await eventPushsSave(json);