<template>
  <ele-pro-table
    ref="table"
    :columns="columns"
    :datasource="tableList"
    class="dict-table"
    tool-class="ele-toolbar-form"
    :need-page="false"
  >
    <template v-slot:code="{ row }">
      <el-link type="primary" :underline="false" @click="openDetail(row)">{{
        row.code
      }}</el-link>

      <p class="ele-text-info">
        {{ getDictValue('客户/供应商资质类型', row.type) }}
      </p>
    </template>
    <template v-slot:time="{ row }">
      <p>起：{{ row.validityStartTime }}</p>
      <p class="ele-text-info">止：{{ row.validityEndTime }}</p>
    </template>
    <template v-slot:createUser="{ row }">
      <p>{{ row.createUserName }}</p>
      <p>{{ row.createUserDeptName }}</p>
      <p class="ele-text-info">{{ row.createTime }}</p>
    </template>
    <template v-slot:picture="{ row }">
      <fileMain v-model="row.fileObj" type="view"></fileMain>
    </template>
    <ele-modal
      :visible.sync="visible"
      :close-on-click-modal="false"
      width="60%"
      :maxable="true"
      append-to-body

    >
      <certificateQualificationsDialog
        v-if="visible"
        :businessId="businessId"
      ></certificateQualificationsDialog>
    </ele-modal>
  </ele-pro-table>
</template>

<script>
  import certificateQualificationsDialog from './certificateQualificationsDialog.vue';

  import dictMixins from '@/mixins/dictMixins';
  import { holderTypeOptions, reviewStatus } from '@/enum/dict.js';
  // import fileMain from '@/components/addDoc/index.vue';

  import { identityphotoList } from '@/api/bpm/components/documentManagement';
  export default {
    mixins: [dictMixins],
    components: { certificateQualificationsDialog, 
      // fileMain 
    },
    data() {
      return {
        visible: false,
        tableList: [],
        businessId: '',
        columns: [
          {
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center'
          },
          // {
          //   label: '持证类型',
          //   align: 'center',
          //   prop: 'holderType',
          //   formatter: (row) => {
          //     return holderTypeOptions.find(
          //       (item) => item.value == row.holderType
          //     )?.label;
          //   },
          //   width: 150
          // },
          {
            align: 'center',
            label: '证照编号',
            prop: 'code',
            slot: 'code',
            width: 180
          },
          {
            label: '状态',
            align: 'center',
            prop: 'status',
            formatter: (row) => {
              return this.getDictValue('规则状态', row.status);
            }
          },
          {
            label: '执证对象',
            align: 'center',
            prop: 'holder'
          },
          {
            align: 'center',
            label: '有效期限',
            prop: 'time',
            slot: 'time',
            minWidth: '180',
            showOverflowTooltip: true
          },
          {
            label: '创建人信息',
            align: 'center',
            prop: 'createUser',
            slot: 'createUser',
            minWidth: '200',
            showOverflowTooltip: true
          },
          {
            label: '证照',
            align: 'center',
            prop: 'picture',
            slot: 'picture'
          },
          {
            label: '备注',
            align: 'center',
            prop: 'remark',
            minWidth: '100',
            showOverflowTooltip: true
          },
          {
            label: '审核状态',
            prop: 'approvalStatus',
            align: 'center',
            width: 120,
            formatter: (_row, _column, cellValue) => {
              return reviewStatus[_row.approvalStatus];
            }
          }
        ]
      };
    },
    created() {
      this.requestDict('客户/供应商资质类型');
      this.requestDict('规则状态');
    },
    methods: {
      getTable(holderId, holderType) {
        identityphotoList({
          holderType,
          holderId
        }).then((res) => {
          this.tableList = res;
        });
      },

      openDetail(row) {
        this.visible=true
        this.businessId = row.id;
      }
    }
  };
</script>

<style class=""></style>
