<template>
  <div class="app-container">
    <!-- 顶部搜索区域 -->
    <el-form :model="queryData" :inline="true">
      <el-form-item label="专利名称">
        <el-input
          v-model="queryData.title"
          placeholder="请输入专利名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="申请人">
        <el-input
          v-model="queryData.applyName"
          placeholder="请输入申请人"
        ></el-input>
      </el-form-item>

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

    <!--表格区域-->
    <el-table :data="dataList" style="width: 100%">
      <el-table-column prop="id" label="数据编号" align="center" />
      <el-table-column label="专利名称" align="center" prop="title" />
      <el-table-column prop="applyCode" label="申请号" align="center" />
      <el-table-column
        prop="applyName"
        label="申请（专利权人）"
        align="center"
      />
      <el-table-column prop="inventor" label="发明人" align="center" />
      <el-table-column prop="applyAt" label="申请日" align="center" />
      <el-table-column prop="examineStatus" label="状态" align="center">
        <template #default="{ row }">
          {{ row.isDeleted === "0" ? "未删除" : "已删除" }}
        </template>
      </el-table-column>
      <el-table-column prop="" label="操作" align="center">
        <template #default="{ row }">
          <el-button size="small" type="text" @click="btndel(row.id)"
            >解除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

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

<script setup>
import { tenantSelect } from "@/api/subPlatform/tenant";
import { expertList, delList } from "@/api/patent/index";
import { useRouter, useRoute } from "vue-router";
import { ElMessageBox } from "element-plus";
const router = useRouter();
const route = useRoute();
// console.log(route.query.id);
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 expertList(route.query.id);
  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();
};
// 解绑按钮
const btndel = async (id) => {
  await ElMessageBox.confirm("确认解绑吗");
  await delList({ expertId: route.query.id, patentId: id });
  getList();
};
getList();
getSiteList();
</script>
<style></style>
