<template>
  <!-- 所有任务 -->
  <div class="gl-page-content">
    <taskTable
      showIndex
      ref="tableRef"
      tableName="SIMULATION_TASK_ALL_LIST"
      :params="{type:2}"
      :api="queryTaskListApi"
      :actionsWidth="tableActionsLength['4-4-2']"
      exportFileName="所以任务列表"
    >
      <template #tableActions="{ row }">
        <div class="gl-table-actions">
          <el-link type="primary">查看详情</el-link>
          <el-link v-if="row.attentionFlag === TASK_ATTENTION_STATUS.NO_ATTENTION" type="success" @click="attentionTaskFun(row,true)">关注</el-link>
          <el-popconfirm
            v-if="row.attentionFlag === TASK_ATTENTION_STATUS.ATTENTION"
            title="确认取消关注吗？"
            @confirm="attentionTaskFun(row,false)"
          >
            <template #reference>
              <el-link type="danger">取消关注</el-link>
            </template>
          </el-popconfirm>
        </div>
      </template>
    </taskTable>
    <!-- <BaseTable
      tableName="SIMULATION_TASK_ALL_LIST"
      :params="{type:0}"
      :api="queryTaskListApi"
      :searchLimitNum="3"
    >
      <template #tableActions="{ row }">
        <div class="actions">
          <el-link type="danger">查看详情</el-link>
          <el-popconfirm
            title="确认取消关注吗？"
            @confirm="attentionTaskFun(row,false)"
          >
            <template #reference>
              <el-link type="danger">取消关注</el-link>
            </template>
          </el-popconfirm>
          <el-link type="danger" @click="attentionTaskFun(row,false)">关注</el-link>
        </div>
      </template>
    </BaseTable> -->
  </div>
</template>

<script setup lang="ts">
import { attentionTaskApi, queryTaskListApi } from '@/api/project/task';
// import BaseTable from '@/components/common/table/baseTable.vue';
import { ElMessage } from 'element-plus';
import taskTable from '../components/taskTable.vue';
import { tableActionsLength } from '@/utils/common';
import { TASK_ATTENTION_STATUS } from '@/utils/enum/task';
import { onMounted, ref } from 'vue';
import { disposeAttentionParams } from '../taskPage';
// enum TaskType {
//   /** 待确认任务 */
//   CONFIRM = 'confirm',
//   /** 执行的任务 */
//   EXECUTE = 'execute',
//   /** 发起的任务 */
//   SPONSOR = 'sponsor',
//   /** 关注的任务 */
//   ATTENTION = 'attention',
//   /** 所有任务 */
//   ALL = 'all',
// }
// SIMULATION_TASK_ALL_LIST
// const headData = ref<any[]>([
//   { title: '任务名称', key: 'taskName', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '任务状态', key: 'taskStatus', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '风险状态', key: 'achievement', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '任务进度', key: 'progress', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '审批状态', key: 'approvalStatus', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '仿真负责人', key: 'simLeader', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '项目', key: 'project', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '学科', key: 'discipline', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '计划开始时间', key: 'beginTime', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '计划结束时间', key: 'endTime', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
//   { title: '实际结束时间', key: 'actualEndTime', isShow: true, inputMode: 'input', type: 1, inForm: false, required: true },
// ]);

const tableRef = ref();

const attentionTaskFun = async(row:any, isAttention:boolean) => {
  const res:any = await attentionTaskApi(disposeAttentionParams(row.uuid, isAttention));
  if (res.code === 200) {
    if (isAttention) {
      ElMessage.success('关注成功');
    } else {
      ElMessage.success('取消关注成功');
    }
    tableRef.value.tableRef.resetFun();
  }
};
onMounted(() => {
});
</script>

