<template>
  <div class="app-container simulation-his-task-list">
    <div class="search-container">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true" style="flex-grow: 1;text-align: right;">
        <el-form-item label="" prop="keywords">
          <el-input v-model="queryParams.keywords" placeholder="请输入模型名称" clearable style="width: 250px"
            @keyup.enter="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleQuery"><i-ep-search />搜索</el-button>
          <el-button @click="resetQuery">
            <i-ep-refresh />
            重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-card>
      <el-table v-loading="loading" :data="tableData" stripe @selection-change="handleSelectionChange">
        <el-table-column label="任务名称" align="left" prop="taskName" />
        <el-table-column label="任务说明" align="left" prop="desc" />
        <el-table-column label="使用数据集"  align="left" prop="dataSet" />
        <el-table-column label="运行模型" align="left" prop="model" width="120"/>
        <el-table-column label="模型网络" align="left" prop="netName"  width="120"/>
        <el-table-column label="创建时间"  align="left" prop="crTime" width="120"/>        
        <el-table-column label="操作" fixed="right" align="center" width="200">
          <template #default="scope">          
            <el-button text type="primary" size="small"
              @click="doShowDetail(scope.row)"><i-ep-view />查看报告</el-button>
            <el-button text type="primary" size="small"
              @click="doDelete(scope.row)"><i-ep-close-bold/>删除</el-button> 
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card class="card-footer">
      <pagination v-if="total > 0" v-model:total="total" v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize" @pagination="handleQuery" />
    </el-card>

  </div>
</template>

<script setup>
const queryFormRef = ref(ElForm); // 查询表单
const router = useRouter();

const loading = ref(false); //  加载状态
const queryParams = reactive({
  pageNum: 1,
  pageSize: 10,
  keywords: '',
});
const total = ref(100); // 数据总数
/** 查询 */
function handleQuery() {
  loading.value = true;
  ElMessage.success("查询成功");
  loading.value = false;

}
let tableData=reactive([
  {id:"1",taskName:"模型名称模型名称模型名称1",desc:"进行10种类型 的目标分类模型查看",dataSet:"图像分类",model:"人脸模型",netName:"VIT",crTime:'2024-02-02'},
  {id:"2",taskName:"模型名称模型名称模型名称2",desc:"进行10种类型 的目标分类模型查看",dataSet:"图像分类",model:"人脸模型",netName:"VIT",crTime:'2024-02-02'},
  {id:"3",taskName:"模型名称模型名称模型名称3",desc:"进行10种类型 的目标分类模型查看",dataSet:"图像分类",model:"人脸模型",netName:"VIT",crTime:'2024-02-02'},
  {id:"4",taskName:"模型名称模型名称模型名称4",desc:"进行10种类型 的目标分类模型查看",dataSet:"图像分类",model:"人脸模型",netName:"VIT",crTime:'2024-02-02'},
]);

const doDelete=(row)=>{
  ElMessageBox.confirm("确认删除?", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(function () {

    let idx=tableData.indexOf(row);
    if(idx>=0){
      tableData.splice(idx,1);
      ElMessage.success("删除成功");
    }      
   
  });
}
const doShowDetail=row=>{    
    router.push({ path: "/simulationEvaluation/taskDesc",query:{...row} });
}
</script>
<style lang='scss'>
.simulation-his-task-list {
  .card-footer {
    position: fixed;
    width: calc(100% - 215px);
    bottom: 0px;

    .el-card__body {
      padding: 0px;

      .el-pagination {
        justify-content: end;
      }
    }
  }
}
</style>