<template>
  <TableProMax
      ref="tableRef"
      :request-api="reqApi"
      :columns="columns"
      :searchFormOptions="searchFormOptions"
  >

  </TableProMax>
</template>

<script setup lang="ts">
import TableProMax from "@/components/table/TableProMax.vue";
import {TableProMaxProps} from "@/types/components/table";
import {SecurityUnitPagerQueryParams, SecurityUnitPagerVo} from "@/types/views/unitManage/securityUnit.ts";
import api from "@/axios";
import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers";
import {enumSelectNodes} from "@/config/dict.ts";

type TableProps = TableProMaxProps<SecurityUnitPagerVo, SecurityUnitPagerQueryParams>

const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
const reqApi: TableProps['requestApi'] = (params) => api.post('/securityUnit/pager', params)
const columns: TableProps['columns'] = [
  {
    dataIndex: 'name',
    title: '名称'
  }, {
    dataIndex: 'socialCode',
    title: '社会编码'
  }, {
    dataIndex: 'businessLicense',
    title: '印业执照'
  }, {
    dataIndex: 'legalPersonInfo',
    title: '法人信息'
  }, {
    dataIndex: 'provinceName',
    title: '行政区划',
    customRender: ({record}) => [record.provinceName, record.cityName, record.districtsName, record.streetName].filter(Boolean).join('/')
  }, {
    dataIndex: 'nature',
    title: '性质'
  }, {
    dataIndex: 'isEnable',
    title: '是否启用'
  }, {
    dataIndex: 'checkStatus',
    title: '审核状态'
  }, {
    dataIndex: 'createTime',
    title: '创建时间'
  }
]
const searchFormOptions: TableProps["searchFormOptions"] = {
  name: {
    type: 'input',
    label: '名称'
  }, socialCode: {
    type: 'input',
    label: '社会编码'
  }, isEnable: {
    type: 'select',
    label: '是否启用',
    options: [
      {
        value: null,
        label: '全部'
      }, ...enumSelectNodes('IsEnable')
    ]
  }, checkStatus: {
    type: 'select',
    label: '审核状态',
    options: [
      {
        value: null,
        label: '全部'
      }, ...enumSelectNodes('CheckStatus')
    ]
  }
}

</script>


<style scoped lang="scss">

</style>
