<template>
  <iam-audit-tree-table
    :columns="columns"
    :actions="actions"
    :form-id="'iamLaw'"
    :page-id="'core/law/iamLaw'"
    :treeparams="{
      configId: '2',
    }"
  >
  </iam-audit-tree-table>
</template>

<script>
import TableColumnTypes from '@/common/services/table-column-types'
import TableActionTypes from '@/common/services/table-action-types'
import iamAuditTreeTable from '../../components/iam-audit-tree-table.vue'
import components from './_import-components/test-tree-table-import'

export default {
  name: 'TestTreeTable',
  metaInfo: {
    title: 'TestTreeTable',
  },
  components: {
    ...components,
    iamAuditTreeTable,
  },
  data() {
    return {
      columns: [
        {
          title: '序号',
          dataIndex: 'sortNumber',
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          dataIndex: 'id',
          sdHidden: true,
        },
        {
          dataIndex: 'parentId',
          sdHidden: true,
        },
        {
          title: '标题',
          dataIndex: 'docTitle',
          // sdClickable: true, // 列内容是否可点击
          scopedSlots: { customRender: 'customCell' },
        },
        {
          title: '发布单位',
          dataIndex: 'publishUnit',
        },
        {
          title: '发文字号',
          dataIndex: 'dispatchWord',
        },
        {
          title: '发布日期',
          dataIndex: 'publishTime',
          sdRender: TableColumnTypes.date,
          sorter: true,
          defaultSortOrder: 'desc',
        },
        {
          title: '实施日期',
          dataIndex: 'implementTime',
          sdRender: TableColumnTypes.date,
        },
        {
          title: '时效性',
          dataIndex: 'period',
        },
        {
          title: '效力级别',
          dataIndex: 'devoteLevel',
        },
        {
          title: '创建时间',
          dataIndex: 'creationTime',
          sdHidden: true,
        },
      ],
      actions: [
        {
          label: '新建',
          id: 'new',
          type: TableActionTypes.ex.create,
        },
        {
          label: '删除',
          id: 'delete',
          type: TableActionTypes.ex.delete, // 删除按钮，不需要回调，会自动处理（对sd-data-table无效）
        },
        {
          label: '测试',
          id: 'test',
          permission: null,
          callback: this.testFun,
        },
      ],
      selectedKeys: ['0'],
    }
  },
  methods: {
    customClick(record) {
      console.log(record)
    },
    testFun() {
      console.log(this.$children[0].$refs.dataTable.getSelectedRows())
    },
  },
}
</script>

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