moveSubTask.vue 4.27 KB
<template>
  <!-- 内层dialog -->
  <el-dialog
    width="630px"
    title="视频迁移"
    :visible.sync="innerVisible"
    append-to-body
  >
    <el-table
      height="286"
      :data="moveTaskData"
      stripe
      border
      style="width: 100%"
      highlight-current-row
      @current-change="handleCurrentChange"
    >
      <el-table-column
        align="center"
        prop="task_name"
        label="任务名称"
      ></el-table-column>
      <el-table-column align="center" prop="status" label="状态">
        <template slot-scope="scope">
          <div v-html="statusFormatter(scope.row)"></div>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="task_algo_type"
        label="算法类型"
        :formatter="typeFormatter"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="store_conf.name"
        label="储存配置"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="resource_use"
        label="场景占用"
      ></el-table-column>
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="movetask">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      innerVisible: false,
      moveTaskData: [],
      curTaskData: {},
      curSubTaskData: {},
      curRow: {}
    };
  },
  methods: {
    initMoveTask(sutaskdata, taskData) {
      this.curTaskData = taskData;
      this.curSubTaskData = sutaskdata;
      this.getTaskList();
    },
    handleClose() {
      this.innerVisible = false;
    },
    handleCurrentChange(val) {
      this.curRow = val;
    },
    getTaskList() {
      this.tableData = [];
      let offset = (this.page - 1) * this.pageSize;
      this.$api.task
        .getTask({
          limit: 10000,
          offset: 0,
          task_algo_type: this.curTaskData.task_algo_type,
          source_type: "pull_video_stream",
          task_type: "normal",
          resource_use: this.curTaskData.resource_use || ""
        })
        .then(res => {
          this.total = res.total_num;
          if (res.list_data == null) {
            this.tableData = [];
          } else {
            let taskArr = [];
            for (let i = 0; i < res.list_data.length; i++) {
              if (res.list_data[i].task_id == this.curTaskData.task_id) {
                break;
              } else {
                taskArr.push(res.list_data[i]);
              }
            }
            if (taskArr.length > 0) {
              this.moveTaskData = taskArr;
              this.innerVisible = true;
            } else {
              this.$message({
                message: "没有符合的任务",
                type: "warning"
              });
            }
          }
        })
        .catch(error => {});
    },
    typeFormatter(row, column, cellValue, index) {
      if (cellValue == 0) {
        return "交通";
      } else if (cellValue == 1) {
        return "客流";
      } else if (cellValue == 2) {
        return "行为分析";
      } else if (cellValue == 3) {
        return "违停";
      } else if (cellValue == 5) {
        return "交通行人";
      } else if (cellValue == 7) {
        return "综合流量";
      } else {
        return "未知";
      }
    },
    statusFormatter(row) {
      if (row.status == "Running") {
        return "<span class='runningbox statusbox'>工作中</span>";
      } else if (row.status == "Finished") {
        return "<span class='finishedbox statusbox'>已完成</span>";
      } else if (row.status == "Pause") {
        return "<span class='pausebox statusbox'>暂停</span>";
      } else if (row.status == "Error") {
        return "<span class='errorbox statusbox'>异常</span>";
      } else if (row.status == "Deleted") {
        return "<span class='deletebox statusbox'>已删除</span>";
      } else {
        return "<span class='nomoralbox statusbox'>未部署</span>";
      }
    },
    movetask() {
      let data = {
        subtask_id: this.curSubTaskData.subtask_id
      };
      this.$api.task.moveTask(this.curTaskData.task_id, data).then(res => {
        console.log(res);
      });
    }
  }
};
</script>

<style></style>