<template>
  <!-- 客户信息: 停用 -->
  <div class="custom-normal"
       :loading="loading">
    <filterCustomTable @search="search">
      <BtnList :btnList="commonBtn" />
    </filterCustomTable>
    <contextMenu :contextMenuList="forDataBtn">
      <a-table :columns="columns"
               class="srcollYTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               :pagination="false"
               rowKey="key"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{  }">
          <BtnList :btnList="forDataBtn" />
        </template>
        <template #userinfotype="{ text }">
          <a>{{ text === 2 ? '企业' : '个人' }}</a>
        </template>
        <!-- 客户名称 -->
        <template #customername="{ record }">
          <a>{{ record.userinfotype === 2 ? record.customername :  record.username }}</a>
        </template>
        <template #status="{ text }">
          <a>{{ getStatusName(text) }}</a>
        </template>
        <template #cardtype="{ text }">
          <a>{{ getCardTypeEnumItemName(text) }}</a>
        </template>
      </a-table>
    </contextMenu>
    <Middle :selectedRow="selectedRow"
            @refresh="queryTable" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, getBtnList, contextMenu, BtnList } from '@/common/export/table';

import { filterCustomTable } from '../../compoments';

import { queryTableList, QueryCustomInfoType } from '../index';
import { getStatusName } from '@/common/constants/enumsName';
import { getCardTypeEnumItemName } from '@/common/constants/enumsName';
import Middle from '@/views/information/custom/compoments/controlModal/index.vue';

export default defineComponent({
    name: 'custom-normal',
    components: {
        filterCustomTable,
        contextMenu,
        BtnList,
        Middle,
    },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick } = getTableEvent<QueryCustomInfoType>({});
        // 表格操作按钮列表
        const { commonBtn, forDataBtn } = getBtnList('custom_info_disabled', true);
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList(4);
        initData(() => {
            // 获取列表数据
            queryTable();
            // 注册表头信息 过滤
            registerColumn('table_pcweb_userinfo', ['userinfotype', 'nickname', 'contactname', 'mobile']);
        });
        return {
            columns,
            expandedRowKeys,
            selectedRow,
            Rowclick,
            commonBtn,
            forDataBtn,
            loading,
            tableList,
            updateColumn,
            getStatusName,
            getCardTypeEnumItemName,
            queryTable,
        };
    },
});
</script>

<style lang="less">
.custom-normal {
}
</style
>;
