<template>
  <table-module
    :pageData="pageData"
    @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 pageData = reactive({
  pagination: {
    total: 0,
    size: 20,
    current: 1,
  },
  tableData: [],
  mouduleName: "行政处罚",
});
onMounted(() => {
  getTableList();
});

function getTableList() {
  api.penalize(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.documentName = item.punishedEntity + ":" + item.caseTypeId;
        item.publishDate = item.createTime.substring(0, 10);
      });
    }
  });
}

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

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