<template>
  <!-- 单据查询 持仓-->
  <div class="platinum_fixed_investment_price_query_tab">
    <Filter @search="search" />
    <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 #userinfotype="{ record }">
        <a>{{ record.userinfotype === 1 ? '个人' : '企业' }}</a>
      </template>
    </a-table>
  </div>
</template>

<script lang="ts">
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { ComposeTableParam, defineComponent, handleComposeTable, queryTableList } from '@/common/export/commonTable';
import { getUserId } from '@/services/bus/user';
import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
import { queryTradePosition } from '@/services/go/ermcp/qhj';
import { QueryTradePositionReq } from 'src/services/go/ermcp/qhj/interface';
import Filter from './compoments/filter/index.vue';

export default defineComponent({
  name: 'platinum_document_query_position',
  components: { Filter },
  setup() {
    // 表格列表数据
    const { loading, tableList, queryTable } = queryTableList<QueryTradePositionRsp>();
    const queryTableAction = () => {
      // 获取列表数据
      queryTable(queryTradePosition, { userid: getUserId() });
    };

    // 表格通用逻辑
    const param: ComposeTableParam = {
      queryFn: queryTableAction,
      tableName: 'table_pcweb_qhj_holder_order',
    };

    function search(value: any) {
      const { includesub, goodsid, filtername, userid, userinfotype } = value;
      const param: QueryTradePositionReq = {
        userid: userid[0] ? userid[0] : getUserId(),
        userinfotype: userinfotype[0] ? userinfotype[0] : 0,
        filtername: filtername[0],
        goodsid: goodsid[0],
        includesub,
      };
      queryTable(queryTradePosition, param);
    }

    return {
      ...handleComposeTable<QueryTradePositionRsp>(param),
      search,
      loading,
      tableList,
    };
  },
});
</script>