<template>
  <div class="p-2">
    <el-tabs v-model="activeName"  @tab-change="getList">
      <el-tab-pane label="实时视频" name="1">
        <el-table v-loading="loading" :data="monitorTaskList" >
          <el-table-column label="任务编号" align="center" prop="id"  />
          <el-table-column label="所属监控点" align="center" show-overflow-tooltip prop="pointName" />
          <el-table-column label="配置事件类型" align="center" show-overflow-tooltip prop="eventTypes" />
          <el-table-column label="目标类型" align="center"  >
            <template #default="scope">
              <dict-tag :options="video_type" :value="scope.row.videoType"></dict-tag>
            </template>
          </el-table-column>
          <el-table-column label="开始时间" align="center" prop="createTime" />
          <el-table-column label="状态" align="center" prop="status" >
            <template #default="scope">
              <dict-tag :options="task_status" :value="scope.row.status"></dict-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-tooltip content="修改" placement="top">
                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                  v-hasPermi="['manage:monitorTask:edit']"></el-button>
              </el-tooltip>
              <el-tooltip content="删除" placement="top">
                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
                  v-hasPermi="['manage:monitorTask:remove']"></el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="离线视频" name="2">
        <el-table v-loading="loading" :data="monitorTaskList" >
          <el-table-column label="文件名" align="center" prop="fileName" />
          <el-table-column label="任务编号" align="center" prop="id"  />
          <el-table-column label="创建时间" align="center" show-overflow-tooltip prop="createTime" />
          <el-table-column label="所属监控点" align="center" prop="pointName" />
          <el-table-column label="配置事件类型" align="center" prop="eventTypes" />
          <el-table-column label="目标类型" align="center"  >
            <template #default="scope">
              <dict-tag :options="video_type" :value="scope.row.videoType"></dict-tag>
            </template>
          </el-table-column>
          <el-table-column label="完成进度" align="center" prop="progress" />
          <el-table-column label="状态" align="center" prop="status" >
            <template #default="scope">
              <dict-tag :options="task_status" :value="scope.row.status"></dict-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-tooltip content="修改" placement="top">
                <el-button link type="primary" icon="Edit"
                  v-hasPermi="['manage:monitorTask:edit']"></el-button>
              </el-tooltip>
              <el-tooltip content="删除" placement="top">
                <el-button link type="primary" icon="Delete"
                  v-hasPermi="['manage:monitorTask:remove']"></el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script setup name="MonitorTask" lang="ts">
import { listMonitorTask} from '@/api/manage/monitorTask';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { video_type } = toRefs<any>(proxy?.useDict('video_type'));
const { task_status } = toRefs<any>(proxy?.useDict('task_status'));
const monitorTaskList = ref([]);
const loading = ref(true);
const total = ref(0);
const activeName = ref('1')
const queryParams = reactive({
  pageNum: 1,
  pageSize:10
})
const handleUpdate = (row) => {

}
const handleDelete = (row) => {

}


/** 查询任务管理列表 */
const getList = async () => {
  loading.value = true;
  const res = await listMonitorTask({videoType: activeName.value,...queryParams});
  monitorTaskList.value = res.rows;
  total.value = res.total;
  loading.value = false;
}
onMounted(() => {
  getList();
});
</script>
