<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)' }"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{  }">
          <BtnList :btnList="forDataBtn" />
        </template>
        <template #userinfotype="{ text }">
          <a>{{ text === 2 ? '企业' : '个人' }}</a>
        </template>
        <!-- 这个状态比较特殊 判断查询类型querytype  如果是wskh表 则使用网上开户的枚举  如果是正式表 则使用正式表的枚举 -->
        <template #status="{ record }">
          <a>{{record.statusdesc }}</a>
        </template>
        <template #cardtype="{ text }">
          <a>{{ text === 0 ? "" : getCardTypeEnumItemName(text) }}</a>
        </template>
        <!-- 客户名称 -->
        <template #customername="{ record }">
          <a>{{  record.username }}</a>
        </template>

      </a-table>
    </contextMenu>
    <Middle :selectedRow="selectedRow"
            @refresh="update" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, contextMenu, BtnList, queryTableList, _getBtnList } from '@/common/export/table';
import { filterCustomTable } from '../../compoments';
import { handleSearch } from '../setup';
import { getStatusName, getWSKHStatusName } from '@/common/constants/enumsName';
import { getCardTypeEnumItemName } from '@/common/constants/enumsName';
import Middle from '@/views/platinum/platinum_customer_info/compoments/controlModal/index.vue';
import { QhjCustomer } from '@/services/go/ermcp/qhj/interface';
import { getUserId } from '@/services/bus/account';
import { queryCustomerInfo } from '@/services/go/ermcp/qhj';
export default defineComponent({
    name: 'custom-normal',
    components: {
        filterCustomTable,
        contextMenu,
        BtnList,
        Middle,
    },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick } = getTableEvent<QhjCustomer>({});

        // 表格操作按钮列表
        const [commonBtn, forDataBtn] = _getBtnList('platinum_custom_info_normal', true).value;

        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList();
        const { search, update } = handleSearch(3, queryTable);

        initData(() => {
            // 获取列表数据
            queryTable(queryCustomerInfo, { querytype: 3, userid: getUserId() });
            // 注册表头信息 过滤
            registerColumn('table_pcweb_qhj_customer_info', []);
        });

        return {
            search,
            update,
            columns,
            expandedRowKeys,
            selectedRow,
            Rowclick,
            commonBtn,
            forDataBtn,
            loading,
            tableList,
            updateColumn,
            getStatusName,
            getCardTypeEnumItemName,
            getWSKHStatusName,
            queryTable,
        };
    },
});
</script>

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