<template>
  <div class="app-container">
    <!-- 顶部搜索区域 -->
    <el-form :inline="true" :model="queryData">
      <el-form-item label="实验室名称">
        <el-input
          v-model="queryData.name"
          placeholder="请输入关键字"
          style="width: 150px"
        ></el-input>
      </el-form-item>
      <el-form-item label="审核状态">
        <el-select
          v-model="queryData.examineStatus"
          class="m-2"
          placeholder="请选择"
          style="width: 100px"
        >
          <el-option :value="1" label="已审核" />
          <el-option :value="2" label="已拒绝" />
        </el-select>
      </el-form-item>

      <el-form-item style="float: right">
        <el-button
          icon="search"
          size="default"
          type="primary"
          @click="handleQuery"
          >搜索
        </el-button>
        <el-button icon="refresh" size="default" @click="resetQuery"
          >重置
        </el-button>
      </el-form-item>
    </el-form>

    <!--表格区域-->
    <el-table :data="dataList" border style="width: 100%">
      <el-table-column type="selection" width="55" />
      <el-table-column align="center" label="数据编号" prop="id" />
      <el-table-column align="center" label="实验室全称" prop="name" />
      <el-table-column align="center" label="所属院所或高校" prop="school" />
      <el-table-column align="center" label="实验室简介" show-overflow-tooltip>
        <template #default="{ row }">
          <div v-html="row.introduction"></div>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="核心成员及简介"
        show-overflow-tooltip
      >
        <template #default="{ row }">
          <div v-html="row.member"></div>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="研究方向"
        prop="researchDirection"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="主要技术应用场景"
        prop="primaryTechnology"
      />
      <el-table-column align="center" label="所属行业领域" prop="industryStr" />
      <el-table-column align="center" label="联系电话" prop="phone" />
      <el-table-column align="center" label="网址" prop="url" />
      <el-table-column align="center" label="审核状态" prop="examineStatus">
        <template #default="{ row }">
          <dict-tag :options="auditStatusDict" :value="row.examineStatus" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" prop="">
        <template #default="{ row }">
          <el-button size="small" type="text" @click="btnAudit(row.id)"
            >审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页器 -->
    <pagination
      v-show="total > 0"
      v-model:limit="queryData.page_size"
      v-model:page="queryData.pageNum"
      :total="total"
      @pagination="getList"
    />
  </div>
</template>

<script setup>
import { tenantSelect } from "@/api/subPlatform/tenant";
import { useRouter } from "vue-router";
import { reactive, ref, toRefs } from "vue";
import { casLaboratoryList } from "@/api/dataList/laboratory";
import DictTag from "@/components/DictTag/index.vue";
import { auditStatusDict } from "@/constant/dict";

const router = useRouter();
const data = reactive({
  queryData: {
    pageNum: 1,
    pageSize: 10,
    examineStatus: "",
  },
});
const total = ref(0);
const dataList = ref([]);
const siteList = ref([]);
const { queryData } = toRefs(data);

// 获取列表
const getList = async () => {
  const res = await casLaboratoryList(queryData.value);
  dataList.value = res.rows;
  total.value = res.total;
};
// 获取站点列表
const getSiteList = async () => {
  const resp = await tenantSelect();
  siteList.value = resp.rows;
};
// 搜索查询
const handleQuery = () => {
  getList(queryData.value);
};
// 重置按钮
const resetQuery = () => {
  queryData.value = {
    pageNum: 1,
    pageSize: 10,
    examineStatus: "",
  };
  getList();
};
/**
 * 审核按钮
 * @param id
 */
const btnAudit = (id) => {
  router.push({
    path: "/approval/data-list/laboratory/approval",
    query: { id },
  });
};
getList();
// getSiteList();
</script>
<style></style>
