<template>
  <!-- 融资信息 -->
  <div class="platinum_financing_information_tab">
    <Filter @search="updateColumn" />
    <a-table :columns="columns" class="srcollYTable" :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }" :pagination="false" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :rowKey="(record,index)=>index" :data-source="tableList">
      <!-- 额外的展开行 -->
      <template #expandedRowRender="{ record }">
        <mtp-table-button class="btn-list-sticky" :buttons="buttons" :record="record" @click="openComponent" />
      </template>
      <!-- 物流信息 -->
      <template #scfcontractstatus="{ record }">
        <div>{{ getFinancingStatus(record.currisklevel, record.reckonrecovermargin) }}</div>
        <div v-if="record.currisklevel === 2">{{ "需追加" + record.reckonrecovermargin + "元" }}</div>
      </template>

      <!-- 账户类型 -->
      <template #userinfotype="{ record }">
        <a>{{ record.userinfotype === 1 ? "个人" : "企业" }}</a>
      </template>
    </a-table>
    <!-- 右键 -->
    <contextMenu :contextMenu="contextMenu" @cancel="closeContext" :list="buttons"></contextMenu>
    <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"></component>
  </div>
</template>

<script lang="ts">
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { getFinancingStatus } from '@/common/constants/enumsName';
import { ComposeTableParam, contextMenu, defineAsyncComponent, defineComponent, handleComposeTable, MtpTableButton, queryTableList } from '@/common/export/commonTable';
import { getTableButton } from '@/common/setup/table/button';
import { queryContract } from '@/services/go/ermcp/qhj';
import { QhjContract } from '@/services/go/ermcp/qhj/interface';
import Filter from './compoments/filter/index.vue';

export default defineComponent({
  name: 'platinum_financing_information_tab',
  components: {
    Filter,
    contextMenu,
    MtpTableButton,
    information_detail: defineAsyncComponent(() => import('./compoments/detail/index.vue')), // 详情
  },
  setup() {
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<QhjContract>();
    const queryTableAction = () => {
      // 获取列表数据
      queryTable(queryContract);
    };

    // 表格通用逻辑
    const param: ComposeTableParam = {
      queryFn: queryTableAction,
      tableName: 'table_pcweb_qhj_fixed_financing_information',
    };
    const buttons = getTableButton();
    return {
      ...handleComposeTable<QhjContract>(param),
      loading,
      tableList,
      buttons,
      getFinancingStatus,
    };
  },
});
</script>