index.vue 14.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
<template>
  <div class="box">
    <div>
      <el-table
        :data="taskInfo.mtasks[0].scenes"
        border
        stripe
        highlight-current-row
        style="width: 80%;float:left"
        height="25vh"
        @cell-click="handleCurrentChange"
        v-loading="loading"
      >
        <el-table-column label="序号" type="index" width="50" align="center">
        </el-table-column>
        <el-table-column align="center" label="预置位编号" width="120">
          <template slot-scope="scope">
            <div>
              {{ setpositionnum(scope.row.position_num) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="预设位置配置" width="120">
          <template slot-scope="scope">
            <div class="yzw-setbox">
              <span
                class="icon el-icon-delete"
                @click="resetRoi(scope.row)"
              ></span>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="时间设置" width="160">
          <template slot-scope="scope">
            <div class="yzw-setbox">
              <setTimer
                ref="settimer"
                :runtime="scope.row.runtime"
                :runindex="scope.$index"
                @timerchange="submitTimer(scope.row, $event)"
              ></setTimer>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="address" align="center" label="参数设置">
          <template slot-scope="scope">
            <div class="table-set">
              <el-tooltip
                class="item"
                effect="dark"
                :content="taskInfo.param_status == 0 ? '运行中' : '下发中'"
                placement="top"
              >
                <span @click="setParam(scope.row, scope.$index)">参数设置</span>
              </el-tooltip>
              <el-tooltip
                class="item"
                effect="dark"
                :content="taskInfo.roi_status == 0 ? '运行中' : '下发中'"
                placement="top"
              >
                <span @click="setArea(scope.row, scope.$index)">区域设置</span>
              </el-tooltip>
              <el-tooltip
                class="item"
                effect="dark"
                :content="taskInfo.calibration_status == 0 ? '运行中' : '下发中'"
                placement="top"
              >
                <span @click="setDemarcate(scope.row, scope.$index)"
                  >标定设置</span
                >
              </el-tooltip>
              <!-- <span @click="setTimer(scope.row, scope.$index)">时间设置</span> -->
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="setting-box">
        <div class="set-header ">基础操作</div>
        <div class="set-item" @click="setsounces">
          场景配置 <span class="set-icon  el-icon-circle-plus"></span>
        </div>
        <div class="set-item">
          轮循播放
          <span class="set-icon">
            <el-switch :width="25" v-model="switchstate" @change="suspends">
            </el-switch>
          </span>
        </div>
        <div class="set-item" @click="handleparam('upload')">
          配置导入 <span class="set-icon el-icon-download"></span>
        </div>
        <div class="set-item" @click="handleparam('export')">
          配置导出 <span class="set-icon el-icon-upload"></span>
        </div>
        <div class="set-item" @click="showview()">
          效果展示 <span class="set-icon el-icon-s-help"></span>
        </div>
      </div>
      <handleparam ref="handleparam"></handleparam>
    </div>
    <div class="yt-box">
      <ytconfig
        ref="yt"
        @subpostion="submitPosion"
        @deleteytconfig="deleteytconfig"
        :vchan="vchan"
      ></ytconfig>
    </div>
    <div>
      <parameter ref="parameter"></parameter>
    </div>
    <div>
      <areas ref="areas"></areas>
    </div>
    <div>
      <demarcate ref="demarcate"></demarcate>
    </div>
    <div></div>
  </div>
</template>
<script>
import areas from "./area";
import demarcate from "./demarcate";
import parameter from "./parameter";
import ytconfig from "./ytconfig";
import handleparam from "./handleparam";
import setTimer from "./setTimer";
export default {
  data() {
    return {
      timer: 0,
      user_unid: "",
      loading: false,
      polling_state: false,
      timersel: 0,
      timerDialog: false,
      curindex: 0,
      timerscenes: null,
      currentRow: null,
      taskInfo: {
        mtasks: [
          {
            scenes: []
          }
        ]
      },
      switchstate: false
    };
  },
  props: ["taskid", "subtaskid", "playurl", "vchan", "subtaskdata"],
  components: {
    areas,
    demarcate,
    parameter,
    ytconfig,
    handleparam,
    setTimer
  },
  methods: {
    setParam(scenesdata, index) {
      if (this.checkpollstate()) {
        this.curindex = index;
        this.$refs.parameter.init(scenesdata, this.taskInfo);
      }
    },
    setArea(roidata, index) {
      if (this.checkpollstate()) {
        this.curindex = index;
        this.$refs.areas.showModal(roidata, this.taskInfo);
      }
    },
    setDemarcate(scenesdata, index) {
      if (this.checkpollstate()) {
        this.curindex = index;
        console.log("scenesdata", scenesdata);
        this.$refs.demarcate.showModal(scenesdata, this.taskInfo);
      }
    },
    handleparam(type) {
      this.$refs.handleparam.show(type);
    },
    setsounces() {
      if (this.checkpollstate()) {
        this.$refs.yt.openyt(this.currentRow);
        this.getSipSetting();
      }
    },
    getSipSetting: function() {
      if (this.dev_unid) {
        this.$api.device.sipSet(this.dev_unid, this.user_unid).then(res => {
          if (!res.ecode) {
            console.log("获取sip配置返回:", JSON.stringify(res));
            document
              .getElementById("VionVideo")
              .PtzRegistDev(
                res.sip_serv_ip,
                res.sip_unid,
                res.sip_password,
                res.sip_serv_id
              );
          } else {
            this.$message({
              message: "获取播放地址失败,请前往配置sip服务!!请重试!",
              type: "error"
            });
          }
        });
      } else {
        console.log("运维ID获取失败");
        this.$message({
          type: "warning",
          message: "运维ID获取失败"
        });
      }
    },
    TaskParams(subid) {
      this.loading = true;
      this.$api.task.getTaskParams(this.taskid, subid).then(res => {
        this.taskInfo = res;
        this.switchstate = res.alternate_status == "1" ? true : false;
        this.loading = false;
        this.$forceUpdate();
      });
    },
    setTimer(data) {
      this.timerscenes = data;
      this.polling_state = data.pollingState;
      this.$store.commit("setocxstate", 0);
      this.timerDialog = true;
      this.timer = data.runtime;
    },
    resetRoi(row) {
      var that = this;
      this.$store.commit("setocxstate", 0);
      this.$confirm("删除参数设置,区域设置,标定设置信息?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          debugger;
          that.taskInfo.mtasks[0].scenes.map(ele => {
            if (ele.scene_unid == row.scene_unid) {
              ele.config = {};
              ele.rois[0].roi =
                '<?xml version="1.0" encoding="UTF-8" ?><roi><flow_roi><flow_type></flow_type><flow_region><polygon_point_count>0</polygon_point_count></flow_region></flow_roi><plate_detect_region><detect_polygon><polygon_point_count>0</polygon_point_count></detect_polygon></plate_detect_region><lane_line><line_count>0</line_count></lane_line><lanes><lane_count>0</lane_count></lanes><lights><light_count>0</light_count></lights><no_stop_region><region_count>0</region_count></no_stop_region><pedestrian_detection_region><region_count>0</region_count></pedestrian_detection_region><median_lines><lane_count>0</lane_count></median_lines><pedestrian_density_region><region_count>0</region_count></pedestrian_density_region><foreign_detection_region><region_count>0</region_count></foreign_detection_region><test_result_region><region_count>0</region_count></test_result_region></roi>';
              ele.runtime = 0;
            }
          });
          that.subRoi(that.taskInfo.mtasks);
        })
        .catch(() => {
          this.$store.commit("setocxstate", 1);
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    setpositionnum(index) {
      return index == -1 ? "未设置" : index;
    },
    handleTimerClose() {
      this.timerDialog = false;
      this.$store.commit("setocxstate", 1);
    },
    handleCurrentChange(val) {
      if (val.algo_type == 3) {
        this.currentRow = val;
        this.$api.task
          .switchScene(this.taskid, this.subtaskid, val.scene_unid)
          .then(res => {
            console.log(res);
          });
      }
    },
    suspends() {
      if (this.subtaskid) {
        let _s = this.switchstate ? 1 : 0;
        this.$api.task
          .suspendAlternate(this.taskid, this.subtaskid, _s)
          .then(res => {
            console.log(res);
          });
      }
    },
    checkpollstate() {
      let state = false;
      if (this.switchstate) {
        this.$message({
          message: "请先关闭轮循再进行操作!",
          type: "warning"
        });
        state = false;
      } else {
        state = true;
      }
      return state;
    },
    submitPosion(positionnum) {
      this.taskInfo.mtasks[0].scenes.map(ele => {
        if (ele.scene_unid == this.currentRow.scene_unid) {
          ele.position_num = positionnum;
        }
      });
      this.subRoi(this.taskInfo.mtasks);
    },
    deleteytconfig(positionnum) {
      this.taskInfo.mtasks[0].scenes.map(ele => {
        if (ele.scene_unid == this.currentRow.scene_unid) {
          ele.position_num = -1;
        }
      });
      this.subRoi(this.taskInfo.mtasks);
    },
    submitTimer(item, stimer) {
      this.taskInfo.mtasks[0].scenes.map(ele => {
        if (ele.scene_unid == item.scene_unid) {
          ele.runtime = stimer;
        }
      });
      this.subRoi(this.taskInfo.mtasks);
    },
    subRoi(mdata) {
      let data = {
        subtask_id: this.subtaskid,
        mtasks: mdata
      };
      this.$api.task.editRoi(this.taskid, this.subtaskid, data).then(res => {
        if (res.ecode == 200) {
          this.timerDialog = false;
          this.$message({
            message: res.enote,
            type: "success"
          });
          this.$store.commit("setocxstate", 1);
          this.TaskParams(this.subtaskid);
        }
      });
    },
    showview() {
      let routeData = this.$router.resolve({
        name: "show",
        query: {
          taskid: this.taskid,
          subtaskid: this.subtaskid,
          playurl: this.playurl
        }
      });
      window.open(routeData.href, "_blank");
    },
    submit: function(xml, type) {
      let postObj = {
        subtask_id: this.subtaskid,
        mtasks: [
          {
            mtask_unid: this.taskInfo.mtasks[0].mtask_unid,
            // type: 0,
            // priority: 0,
            scenes: this.taskInfo.mtasks[0].scenes
          }
        ]
      };
      if (type == "roi") {
        postObj.mtasks[0].scenes[this.curindex].rois = [
          {
            roi: xml
          }
        ];
        postObj.conf_type = "rois";
      } else if (type == "config") {
        postObj.mtasks[0].scenes[this.curindex].config = {
          xml: xml
        };
        postObj.conf_type = "paramsconfig";
      } else if (type == "calibration") {
        console.log(xml);
        postObj.mtasks[0].scenes[this.curindex].calibration = {
          calibration: xml
        };
        postObj.conf_type = "calibration";
      }
      this.$api.task
        .editRoi(this.taskid, this.subtaskid, postObj, {
          headers: {
            authorization: localStorage.getItem("atoken")
          }
        })
        .then(m => {
          if (m.ecode == "200") {
            this.$message({
              message: "设置成功!",
              type: "success"
            });
            switch (type) {
              case "roi":
                this.taskInfo.roi_status = 1;
                this.taskInfo.mtasks[0].scenes[this.curindex].rois = [
                  {
                    roi: xml
                  }
                ];
                break;
              case "calibration":
                this.taskInfo.calibration_status = 1;
                this.taskInfo.mtasks[0].scenes[this.curindex].calibration = {
                  calibration: xml
                };
                break;
              case "config":
                this.taskInfo.param_status = 1;
                this.taskInfo.mtasks[0].scenes[this.curindex].config = {
                  xml: xml
                };
                break;
              default:
                break;
            }
          } else {
            this.$message({
              message: m.enote,
              type: "error"
            });
          }
        });
    }
  },
  created() {
    this.user_unid = window.sessionStorage.getItem("user_unid");
  },
  watch: {
    // subtaskid(val) {
    //   this.loading = true;
    //   this.$api.task.getTaskParams(this.taskid, val).then(res => {
    //     this.taskInfo = res;
    //     this.switchstate = res.alternate_status == 1 ? true : false;
    //     this.loading = false;
    //     this.$forceUpdate();
    //   });
    // }
  }
};
</script>
<style lang="stylus" scoped>
.box{
  position relative
}
.yzw-setbox{
  .icon {
    font-size 16px
    padding 0 10px
    cursor pointer
  }
  .icon:first-child{
    color #6783E3
  }
  .icon:last-child{
    color red
  }
}

.setting-box{
  width 18%;
  float right
}
.table-set span{
    padding 0 10px
    cursor pointer
    color #666666
    border-right 1px solid #E5E5E5
}
.table-set span:last-child{
  border-right 0
}
.table-set span:hover{
  color #3BB7FF
}
.set-header{
  height 30px
  line-height 30px
  text-align center
  background #ACC1FF
}
.set-item{
  height 3vh
  line-height 3vh
  min-height 30px
  padding:0 10px
  color #555555
  margin-top 1vh
  cursor pointer
  .set-icon{
    display inline-block
    float right
    line-height 3vh
    font-size 20px
    color #CCCCCC
  }
  .set-icon:hover{
    color #3BB7FF
  }
}
.upload-box {
  margin-right 20px
}
.yt-box{

}
.settimertype,.sel-box{
  display flex
  margin-bottom 10px
  .title {
    line-height 30px;
    padding-right 10px
  }
}
</style>