li.shaoyi преди 4 години
родител
ревизия
c3fd8a505f

+ 43 - 76
src/views/order/funding_information/components/funding_information_funding_summary/index.vue

@@ -1,46 +1,18 @@
 <template>
   <!-- 资金汇总 -->
   <section>
-    <a-table :columns="tableColumns" class="srcollYTable expandLeftTable" :scroll="{ x: '100%', y: '190px' }" :pagination="false" :loading="loading" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :expandIcon="expandIcon" :expandIconAsCell="false" rowKey="key" :data-source="tableList">
-      <!-- 额外的展开行 -->
-      <template v-if="btnList.length" #expandedRowRender="{ record }">
-        <BtnList :btnList="btnList" :record="record" class="btn-list-sticky" @click="openComponent" />
-      </template>
-      <template #balance="{record}">
-        <span>{{canUseMoney(record)}}</span>
-      </template>
-      <template #freezemargin="{record}">
-        <span>{{getFreeze(record, true)}}</span>
-      </template>
-      <!-- 浮动盈亏 -->
-      <template #closepl="{record}">
-        <span>{{handleProfitloss(record)}}</span>
-      </template>
-      <!-- 风险率 -->
-      <template #accountname="{record}">
-        <span>{{hazardRates(record)}}</span>
-      </template>
-      <!-- 净值 -->
-      <template #netWorth="{record}">
-        <span>{{netWorth(record)}}</span>
-      </template>
-      <template #tradestatus="{text}">
-        <span>{{getTaacountStatus(text)}}</span>
-      </template>
-    </a-table>
+    <a-table :columns="getColumns()" class="srcollYTable expandLeftTable" :scroll="{ x: '100%', y: '190px' }" :pagination="false" :loading="loading" :expandedRowKeys="expandedRowKeys" :customRow="Rowclick" :expandIcon="expandIcon" :expandIconAsCell="false" rowKey="key" :data-source="tableList"></a-table>
     <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"></component>
   </section>
 </template>
 
 <script lang="ts">
 import { enumOrderComponents } from '@/common/constants/enumOrderComponents';
-import { getTaacountStatus } from '@/common/constants/enumsName';
 import { BtnList, defineComponent, queryTableList } from '@/common/export/commonTable';
 import { getRecordItemTab } from '@/common/setup/order/orderData';
 import { expandIcon } from '@/common/setup/table/clolumn';
 import { handleComposeOrderTable } from '@/common/setup/table/compose';
 import { ComposeOrderTableParam } from '@/common/setup/table/interface';
-import { getCanUseMoney, getFreeze } from '@/services/bus/account';
 import { geLoginID_number } from '@/services/bus/login';
 import { queryTradePosition } from '@/services/go/ermcp/order';
 import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
@@ -48,55 +20,50 @@ import { getTaAccounts } from '@/services/go/TaAccount';
 import { GetTaAccountsReq, Taaccount } from '@/services/go/TaAccount/interface';
 import Bus from '@/utils/eventBus/index';
 import { ref } from 'vue';
-import { tableColumns, useHazardRates } from './setup';
+import { getColumns } from './setup';
 
 export default defineComponent({
-    name: enumOrderComponents.funding_information_funding_summary,
-    components: {
-        BtnList,
-    },
-    setup() {
-        // 表格列表数据
-        const { loading, tableList, queryTable } = queryTableList<Taaccount>();
-        // 持仓汇总
-        const holdsList = ref<QueryTradePositionRsp[]>([]);
-        // 获取列表数据
-        const queryTableAction = () => {
-            const param: GetTaAccountsReq = {
-                loginID: Number(geLoginID_number()),
-            };
-            queryTable(getTaAccounts, param);
-            // 获取头寸
-            queryTradePosition().then((res) => {
-                holdsList.value = res;
-            });
-        };
-        const { handleProfitloss, hazardRates, netWorth, canUseMoney } = useHazardRates(holdsList);
-        // 资金变化,重新加载数据
-        Bus.$on('moneyChangedNtf_UI', () => {
-            queryTableAction();
-        });
-        // 表格通用逻辑
-        const param: ComposeOrderTableParam = {
-            queryFn: queryTableAction,
-            tableName: 'table_pcweb_spot_trade_bottom_funding_info_summary',
-            recordList: getRecordItemTab(),
-        };
-        return {
-            ...handleComposeOrderTable<Taaccount>(param),
-            loading,
-            tableList,
-            getCanUseMoney,
-            getFreeze,
-            expandIcon,
-            handleProfitloss,
-            hazardRates,
-            tableColumns,
-            getTaacountStatus,
-            netWorth,
-            canUseMoney,
-        };
-    },
+  name: enumOrderComponents.funding_information_funding_summary,
+  components: {
+    BtnList,
+  },
+  setup() {
+    // 表格列表数据
+    const { loading, tableList, queryTable } = queryTableList<Taaccount>(true, 2);
+    // 持仓汇总
+    const holdsList = ref<QueryTradePositionRsp[]>([]);
+    // 获取列表数据
+    const queryTableAction = () => {
+      const param: GetTaAccountsReq = {
+        loginID: Number(geLoginID_number()),
+      };
+      queryTable(getTaAccounts, param);
+      // 获取头寸
+      queryTradePosition().then((res) => {
+        holdsList.value = res;
+      });
+    };
+
+    // 资金变化,重新加载数据
+    Bus.$on('moneyChangedNtf_UI', () => {
+      queryTableAction();
+    });
+
+    // 表格通用逻辑
+    const param: ComposeOrderTableParam = {
+      queryFn: queryTableAction,
+      tableName: 'table_pcweb_spot_trade_bottom_funding_info_summary',
+      recordList: getRecordItemTab(),
+    };
+
+    return {
+      ...handleComposeOrderTable<Taaccount>(param),
+      loading,
+      tableList,
+      expandIcon,
+      getColumns,
+    };
+  },
 });
 </script>
 

+ 62 - 83
src/views/order/funding_information/components/funding_information_funding_summary/setup.ts

@@ -5,100 +5,79 @@ import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
 import { Taaccount } from '@/services/go/TaAccount/interface';
 import { Systemparam } from '@/services/go/useInfo/interface';
 import { Ref } from 'vue';
+import { getCanUseMoney, getFreeze } from '@/services/bus/account';
+import { getTaacountStatus } from '@/common/constants/enumsName';
 
-export const tableColumns = [
-    {
-        key: '0th',
-        dataIndex: 'accountid',
-        title: '资金账号',
-        align: 'center',
-        slots: {
-            customRender: 'accountid',
+export function getColumns() {
+    const columns = [
+        {
+            title: '资金账号',
+            key: 'accountid',
         },
-        width: 120,
-    },
-    {
-        key: '1th',
-        dataIndex: 'netWorth',
-        title: '净值',
-        align: 'center',
-        slots: {
-            customRender: 'netWorth',
+        {
+            title: '币种',
+            key: 'currencyid',
+            customRender: ({ record }: { record: Taaccount }) => {
+                return record.currencyid
+            }
+        },
+        {
+            title: '当前权益',
+            key: 'currentbalance',
+        },
+        {
+            title: '可用资金',
+            key: 'balance',
+            customRender: ({ record }: { record: Taaccount }) => {
+                return getCanUseMoney(record)
+            }
         },
-        width: 120,
-    },
-    {
-        key: '2th',
-        dataIndex: 'balance',
-        title: '可用资金',
-        align: 'center',
-        slots: {
-            customRender: 'balance',
+        {
+            title: '占用资金',
+            key: 'usedmargin',
         },
-        width: 120,
-    },
-    {
-        key: '3th',
-        dataIndex: 'usedmargin',
-        title: '占用资金',
-        align: 'center',
-        slots: {
-            customRender: 'usedmargin',
+        {
+            title: '冻结金额',
+            key: 'freezemargin',
+            customRender: ({ record }: { record: Taaccount }) => {
+                return getFreeze(record)
+            }
         },
-        width: 120,
-    },
-    {
-        key: '4th',
-        dataIndex: 'freezemargin',
-        title: '冻结资金',
-        align: 'center',
-        slots: {
-            customRender: 'freezemargin',
+        {
+            title: '持仓盈亏',
+            key: 'positionpl',
         },
-        width: 120,
-    },
-    {
-        key: '5th',
-        dataIndex: 'closepl',
-        title: '浮动盈亏',
-        align: 'center',
-        slots: {
-            customRender: 'closepl',
+        {
+            title: '平仓盈亏',
+            key: 'closepl',
         },
-        width: 120,
-    },
-    {
-        key: '51th',
-        dataIndex: 'currentbalance',
-        title: '余额',
-        align: 'center',
-        slots: {
-            customRender: 'currentbalance',
+        {
+            title: '入金',
+            key: 'inamount',
         },
-        width: 120,
-    },
-    {
-        key: '6th',
-        dataIndex: 'usedmargin',
-        title: '风险率',
-        align: 'center',
-        slots: {
-            customRender: 'accountname',
+        {
+            title: '出金',
+            key: 'outamount',
         },
-        width: 120,
-    },
-    {
-        key: '7th',
-        dataIndex: 'tradestatus',
-        title: '状态',
-        align: 'center',
-        slots: {
-            customRender: 'tradestatus',
+        {
+            title: '状态',
+            key: 'tradestatus',
+            customRender: ({ record }: { record: Taaccount }) => {
+                return getTaacountStatus(record.tradestatus)
+            }
         },
-        width: 120,
-    },
-];
+    ];
 
+    return columns.map(el => {
+        return {
+            dataIndex: el.key,
+            width: 150,
+            align: 'center',
+            slots: { customRender: el.key, },
+            ...el
+        }
+    })
+}
 
 export const useHazardRates = (positions: Ref<QueryTradePositionRsp[]>) => {
     // 获取报价小数位