<template>
  <!-- 融资信息 -->
  <div class="platinum_financing_information_tab">
    <Filter @search="updateColumn" />
    <contextMenu :contextMenuList="firstBtn">
      <a-table :columns="columns"
               class="topOrderTable"
               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
               :pagination="false"
               :expandedRowKeys="expandedRowKeys"
               :customRow="Rowclick"
               rowKey="key"
               :data-source="tableList">
        <!-- 额外的展开行 -->
        <template #expandedRowRender="{ record }">
          <BtnList :btnList="firstBtn"
                   class="btn-list-sticky"
                   @onClick="btnClick(record)" />
        </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>
    <Detail :selectedRow="selectedRow" />
  </div>
</template>

<script lang="ts">
import { defineComponent, initData, getTableColumns, getTableEvent, contextMenu, BtnList, _getBtnList, queryTableList } from '@/common/export/table';
import Filter from './compoments/filter/index.vue';
import Detail from './compoments/detail/index.vue';
import { QhjContract } from '@/services/go/ermcp/qhj/interface';
import { queryContract } from '@/services/go/ermcp/qhj';
import { getContractName, getFinancingStatus } from '@/common/constants/enumsName';

export default defineComponent({
    name: 'platinum_financing_information_tab',
    components: { Filter, contextMenu, BtnList, Detail },
    setup() {
        // 表头数据
        const { columns, registerColumn, updateColumn } = getTableColumns();
        // 表格事件
        const { expandedRowKeys, selectedRow, Rowclick, btnClick } = getTableEvent<QhjContract>({});
        // 表格操作按钮列表
        const [firstBtn] = _getBtnList('platinum_financing_information_tab', false).value;
        // 表格列表数据
        const { loading, tableList, queryTable } = queryTableList();
        initData(() => {
            // 获取列表数据
            queryTable(queryContract);
            // 注册表头信息 过滤
            registerColumn('table_pcweb_qhj_fixed_financing_information', ['goodsid', 'contractconfirmtime']);
        });

        return {
            columns,
            expandedRowKeys,
            selectedRow,
            Rowclick,
            firstBtn,
            loading,
            tableList,
            updateColumn,
            queryTable,
            btnClick,
            getFinancingStatus,
        };
    },
});
</script>