<template>
  <a-modal
    :title="title"
    :body-style="{
      padding: 0,
      minHeight: '500px',
    }"
    :destroy-on-close="true"
    :visible="visible"
    :width="modalWidth"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <AuditDossierTree
      ref="dossierDataTable"
      :code="code"
      :columns="columns"
      form-id="iamDossierData"
      page-id="audit/archives/iamDossierData"
      :treeparams="{
        configId: '22',
      }"
      :change="treechange"
    >
    </AuditDossierTree>
  </a-modal>
</template>

<script>
import AuditDossierTree from './audit-dossier-tree.vue'
import components from './_import-components/audit-select-dossier-import'
import TableColumnTypes from '@/common/services/table-column-types'

export default {
  name: 'AuditSelectDossier',
  metaInfo: {
    title: '档案文件',
  },
  components: {
    ...components,
    AuditDossierTree,
  },
  props: {
    // 弹出窗标题
    title: {
      type: String,
      default: '档案文件',
    },
    // 弹出窗宽度
    modalWidth: {
      type: String,
      default: '1200px',
    },
    // 弹出窗显示参数
    visible: {
      type: Boolean,
      default: false,
    },
    code: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      bodyStyle: {
        padding: 0,
      },
      columns: [
        { dataIndex: 'id', sdHidden: true },
        {
          title: '文件名称',
          dataIndex: 'docTitle',
        },
        {
          title: '编制人员',
          dataIndex: 'creatorName',
        },
        {
          title: '编制日期',
          dataIndex: 'creationTime',
          defaultSortOrder: 'descend', // 没有点击任何排序列时，默认的排序列
          sdRender: TableColumnTypes.dateTime,
        },
      ],
    }
  },
  methods: {
    treechange(unableselect, id) {
      this.treeId = id
    },

    handleOk(e) {
      this.$parent.visible = !this.$parent.visible
      this.$parent.visibleWJ = !this.$parent.visibleWJ
      // 列表选择事件，返回选择的数据
      this.$emit(
        'listWjSelected',
        this.$refs.dossierDataTable.$refs.dataTable.getSelectedRowKeys(),
        this.$refs.dossierDataTable.$refs.dataTable.getSelectedRows()
      )
    },
    handleCancel(e) {
      this.$parent.visible = !this.$parent.visible
      this.$parent.visibleWJ = !this.$parent.visibleWJ
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
