li.shaoyi 4 年之前
父節點
當前提交
dcf517598e

+ 4 - 3
src/common/setup/table/event.ts

@@ -31,9 +31,10 @@ export function getTableEvent<T>(param: TableEventCB = {}) {
                 }
                 param.clickCB && param.clickCB(record)
             },
-            // onDblclick: () => { // 双击
-            //     console.log('onDblclick');
-            // },
+            onDblclick: () => { // 双击
+                selectedRow.value = record
+                param.dblclick && param.dblclick(record)
+            },
             onContextmenu: (event: MouseEvent) => {  // 表格右键
                 selectedRow.value = record
                 const { clientX, clientY } = event;

+ 3 - 4
src/views/market/futures/compoments/futures-trade/index.less

@@ -3,10 +3,9 @@
 }
 
 .futures_trade {
-    display  : flex;
-    height   : 100%;
-    max-width: 450px;
-    padding  : 20px;
+    display: flex;
+    height : 100%;
+    padding: 20px;
 
     &__left {
         flex          : 1;

+ 9 - 5
src/views/market/futures/compoments/futures-trade/index.vue

@@ -11,7 +11,7 @@
               </a-select>
             </a-form-item>
             <a-form-item label="合约">
-              <a-select class="inlineFormSelect" placeholder="请选择" v-model:value="formData.GoodsID" @change="goodsChange">
+              <a-select class="inlineFormSelect" placeholder="请选择" :filterOption="filterOption" show-search v-model:value="formData.GoodsID" @change="goodsChange">
                 <a-select-option v-for="item in goodsList" :value="item.goodsid" :key="item.goodsid">{{ item.goodsname }}</a-select-option>
               </a-select>
             </a-form-item>
@@ -49,7 +49,6 @@
           </a-button>
           <!--如果有持仓则显示按钮-->
           <a-button :loading="loading" @click="submit('close')" v-show="positionList.length">
-            <span>优先平今</span>
             <span>平仓</span>
           </a-button>
         </div>
@@ -70,14 +69,13 @@ import Drawer from '@/common/components/drawer/index.vue';
 import { _closeModal } from '@/common/setup/modal/modal';
 import { MinusOutlined, PlusOutlined } from '@ant-design/icons-vue';
 import { defineComponent, ref, computed } from 'vue';
-import { handleForm } from './setup';
+import { handleForm, getColumns } from './setup';
 import { channelOrderReq } from '@/services/proto/futures';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { BuyOrSell, BuildType, PriceType } from '@/common/constants/enumCommon';
 import { validateAction } from '@/common/setup/form';
 import { GoodsQuote } from '@/services/go/ermcp/goodsInfo/interface';
 import { getGoodsQuoteList } from '@/services/bus/goods';
-import { getColumns } from '@/views/order/futures_information/components/futures_information_position/columns';
 import { message } from 'ant-design-vue';
 
 export default defineComponent({
@@ -97,7 +95,7 @@ export default defineComponent({
         },
     },
     setup(props, context) {
-        const goodsList = getGoodsQuoteList(props.exchangeId);
+        const goodsList = getGoodsQuoteList();
         const getGoods = (id: number) => goodsList.find((item) => item.goodsid === id)!;
         // 当前选中的商品合约
         const selectedGoods = ref<GoodsQuote>(getGoods(props.goodsId));
@@ -187,6 +185,11 @@ export default defineComponent({
             }
         }
 
+        // 搜索商品合约
+        function filterOption(input: string, option: any) {
+            return option.children[0].children.includes(input);
+        }
+
         // 选择商品合约
         function goodsChange(id: number) {
             formData.OrderPrice = 0;
@@ -297,6 +300,7 @@ export default defineComponent({
             priceTypeList,
             PriceType,
             selectedPriceType,
+            filterOption,
             priceTypeChange,
             getColumns,
             onSelectChange,

+ 47 - 0
src/views/market/futures/compoments/futures-trade/setup.ts

@@ -4,6 +4,7 @@ import { GoodsQuote } from '@/services/go/ermcp/goodsInfo/interface';
 import { ChannelOrderReq } from '@/services/proto/futures/interface';
 import { v4 as uuidv4 } from 'uuid';
 import { PriceType } from '@/common/constants/enumCommon';
+import { getBuyOrSellName } from '@/common/constants/enumsName';
 import { geLoginID_number } from '@/services/bus/login';
 import { getUserId } from '@/services/bus/user';
 import { RuleObject } from 'ant-design-vue/es/form/interface';
@@ -11,6 +12,52 @@ import { getAccountTypeList } from '@/services/bus/account';
 import { queryErmcpTradePosition } from '@/services/go/ermcp/futures';
 import { QueryErmcpTradePositionRsp } from '@/services/go/ermcp/futures/interface';
 
+export function getColumns() {
+    const columns = [
+        {
+            title: '方向',
+            key: 'buyorsell',
+            customRender: ({ record }: { record: QueryErmcpTradePositionRsp }) => {
+                return getBuyOrSellName(record.buyorsell)
+            }
+        },
+        {
+            title: '可用',
+            key: 'enableqty'
+        },
+        {
+            title: '开仓均价',
+            key: 'openaverageprice',
+            customRender: ({ record }: { record: QueryErmcpTradePositionRsp }) => {
+                const { opencost, curpositionqty, agreeunit } = record;
+                // 开仓成本 ÷ 期末头寸 ÷ 合约单位
+                const result = opencost / curpositionqty / agreeunit;
+                return result.toFixed(2)
+            }
+        },
+        {
+            title: '持仓均价',
+            key: 'positionaverageprice',
+            customRender: ({ record }: { record: QueryErmcpTradePositionRsp }) => {
+                const { positioncost, curpositionqty, agreeunit } = record;
+                // 持仓成本 ÷ 期末头寸 ÷ 合约单位
+                const result = positioncost / curpositionqty / agreeunit;
+                return result.toFixed(2);
+            }
+        },
+    ];
+
+    return columns.map(el => {
+        return {
+            dataIndex: el.key,
+            width: 100,
+            align: 'center',
+            slots: { customRender: el.key, },
+            ...el
+        }
+    })
+}
+
 export function handleForm(selectedRow: GoodsQuote) {
     // 数据初始化
     const formData = reactive<ChannelOrderReq>({