<template>
  <table-module
    :pageData="pageData"
    :timeCellWidth="timeCellWidth"
    @columnEvent="columnEvent"
    @paginationEvent="paginationEvent"
  />
</template>
<script setup>
import api from "@/api/zwgk.js";
import { useRouter } from "vue-router";
import { onMounted, reactive } from "vue";
import tableModule from "@/components/tableModule/publicInfo.vue";

const router = useRouter();
const timeCellWidth = 280;
const pageData = reactive({
  pagination: {
    total: 0,
    size: 20,
    current: 1,
  },
  tableData: [],
  mouduleName: "行政许可",
});
onMounted(() => {
  getTableList();
});

function getTableList() {
  api.permission(pageData.pagination).then((res) => {
    if (res.code == 200) {
      pageData.pagination.size = res.data.size;
      pageData.pagination.total = res.data.total;
      pageData.pagination.current = res.data.pages;
      pageData.tableData = res.data.records;
      pageData.tableData.map((item) => {
        item.publishDate =
          item.validityStart.substring(0, 10) +
          "-" +
          item.validityEnd.substring(0, 10);
        item.documentName = item.enterpriseName + ":" + item.licenseNumber;
      });
    }
  });
}

// 分页
function paginationEvent(val) {
  pageData.pagination.current = val;
  getTableList();
}

function columnEvent(data) {
  //定义一个路径
  let href = router.resolve({
    path: "/articleDetails",
    query: { type: "xzxk", id: data.id },
  }).href;
  //打开新的页面 到 href 这个页面
  window.open(href, "_blank");
}
</script>

<style scoped lang="less">
:v-deep(.el-table) {
  .el-table_1_column_2 {
    width: 280px;
  }
}
</style>
