<template>
  <div class="bg-[#fff]">
    <a-page-header style="border: 1px solid rgb(235, 237, 240)" @back="router.go(-1)">
      <template #backIcon>
        <div><a-button type="primary">返回</a-button></div>
      </template>
      <template #title>
        <div> <a-button type="primary" @click="handle" v-auth="'hqgl-ckglxx'">查看详情</a-button></div>
      </template>
    </a-page-header>
    <!--引用表格-->
    <BasicTable @register="registerTable" :rowSelection="rowSelection"> </BasicTable>
  </div>
</template>

<script lang="ts" name="dkgl-investigate-Acceptance" setup>
  import { ref } from 'vue';
  import { BasicTable } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { columnsH } from './data';
  import { findGljl, getImportUrl, getExportUrl } from './api';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useRouter } from 'vue-router';

  const { createMessage } = useMessage();
  let router = useRouter();
  const params = ref(router.currentRoute.value.query);
  //注册table数据
  const { tableContext } = useListPage({
    tableProps: {
      title: '',
      api: findGljl,
      beforeFetch(param) {
        param.wrdkid = params.value.wrdkid;
        param.type = 0;
      },
      afterFetch(param) {
        param.forEach((v) => {
          v.wrdkmc = params.value.wrdkmc;
          v.wrdkbm = params.value.wrdkbm;
        });
      },
      columns: columnsH,
      useSearchForm: false,
      canResize: false,
      //定义rowSelection的类型，默认是checkbox多选，可以设置成radio单选
      rowKey: 'id',
      clickToRowSelect: true,
      showActionColumn: false,
      rowSelection: { type: 'radio' },
      actionColumn: {
        width: 120,
      },
    },
    exportConfig: {
      name: '查看后期管理记录',
      url: getExportUrl,
    },
    importConfig: {
      url: getImportUrl,
    },
  });

  const [registerTable, {}, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;

  function handle() {
    if (selectedRowKeys.value.length == 0) {
      createMessage.info('请选择需要处理的内容，每次只能选中一条');
      return;
    }
    sessionStorage.setItem('data', JSON.stringify(selectedRows.value[0]));
    router.push(`/dkgl/hqgl/add?wrdkid=${selectedRowKeys.value[0]}&type=view`);
  }
</script>
<style scoped></style>
