<template>
  <a-divider orientation="left">历次评审信息</a-divider>
  <a-table :columns="columns" :data-source="localData" :pagination="false" bordered size="middle">
    <!--操作栏-->
    <template #action="{ record }">
      <a-button type="link" @click="toDetail(record)">查看</a-button>
    </template>
    <template #bodyCell="{ column, record }">
      <template v-if="column?.dataIndex === 'tgjg'">
        <template v-if="record.tgjg === 0">未通过</template>
        <template v-else-if="record.tgjg === 1">通过，无需修改</template>
        <template v-else-if="record.tgjg === 2">通过但需修改</template>
      </template>
    </template>
  </a-table>
  <HistoryInfoModal @register="registerModal" />
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import { useModal } from '/@/components/Modal';
  import { getZjyjHis } from '@/api/dkgl.api';
  import HistoryInfoModal from './HistoryInfoModal.vue';
  const [registerModal, { openModal }] = useModal();
  const props = defineProps({
    wrdkid: {
      type: String,
      default: '',
    },
    pgtype: {
      type: String,
      default: '',
    },
    scjdbm: {
      type: String,
      default: '',
    },
    type: {
      type: String,
      default: '', // 不同的模块
    },
    columns: {
      type: Array,
      default: () => [
        {
          title: '第几次评审',
          dataIndex: 'pscs',
          align: 'center',
        },
        {
          title: '会议时间',
          dataIndex: 'hysj',
          align: 'center',
        },
        {
          title: '处理时间',
          dataIndex: 'tsamp',
          align: 'center',
        },
        {
          title: '会议地点',
          dataIndex: 'hydd',
          align: 'center',
        },
        {
          title: '会议组织方',
          dataIndex: 'hyzzf',
          align: 'center',
        },
        {
          title: '报告是否通过',
          dataIndex: 'tgjg',
          align: 'center',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 100,
          slots: { customRender: 'action' },
        },
      ],
    },
  });
  const localData = ref([]);
  getHistory();
  async function getHistory() {
    localData.value = await getZjyjHis({
      wrdkid: props.wrdkid,
      pgtype: props.pgtype,
      scjdbm: props.scjdbm,
    });
  }
  function toDetail(record) {
    console.log('toDetail', record);
    openModal(true, {
      type: props.type,
      record: record,
      showFooter: false,
    });
  }
</script>
