Bladeren bron

修改商品掉期 挂牌

huangbin 4 jaren geleden
bovenliggende
commit
f44d8eb46a

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://103.40.249.123:28280/cfg?key=mtp_20"
+    "apiUrl": "http://192.168.31.139:8080/cfg?key=test_139"
 }

+ 137 - 129
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/post_buying/index.vue

@@ -1,135 +1,141 @@
 <template>
-    <!-- 挂牌求购 -->
-    <Drawer
-        :title="isBuy() ? '挂牌求购' : '挂牌卖出' "
-        :placement="'right'"
-        :visible="visible"
-        @cancel="cancel"
-        class="top"
-    >
-        <div class="title_right">
-            <span class="tline"></span>
-            <svg class="icon svg-icon" aria-hidden="true">
-                <use xlink:href="#icon-xinjianzengjiaxinzeng-20" />
-            </svg>
-            <span @click="changeDirection">{{isBuy() ? '卖出' : '求购'}}</span>
-        </div>
-        <div class="post_buying">
-            <a-form class="inlineForm dialogForm" ref="formRef" :model="formState" :rules="rules">
-                <div class="formBar">
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="交易账户" name="accountid">
-                                <a-select
-                                    class="inlineFormSelect"
-                                    style="width: 260px"
-                                    v-model:value="formState.accountid"
-                                    placeholder="请选择"
-                                >
-                                    <a-select-option
-                                        v-for="item in accountList"
-                                        :value="item.accountid"
-                                        :key="item.accountid"
-                                    >{{item.accountid}}</a-select-option>
-                                </a-select>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24">
-                            <a-form-item label="价格类型" name>
-                                <a-radio-group
-                                    class="commonRadioGroup"
-                                    v-model:value="formState.priceType"
-                                >
-                                    <a-radio :value="2">固定价</a-radio>
-                                    <!-- 掉期交易商有固定价和浮动价选择 -->
-                                    <!-- 普通交易商只有固定价 -->
-                                    <a-radio :value="3" v-if="!useUserType()">浮动价</a-radio>
-                                </a-radio-group>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" v-if="!isFloat()">
-                            <a-form-item label="挂牌价格" name="FixedPrice" class="inputIconBox">
-                                <a-input-number
-                                    class="commonInput"
-                                    style="width: 260px"
-                                    :min="0"
-                                    v-model:value="formState.FixedPrice"
-                                />
-                                <MinusOutlined @click="decreasePrice" />
-                                <PlusOutlined @click="increasePrice" />
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" v-else>
-                            <a-form-item label="基差" name="PriceMove">
-                                <a-input-number
-                                    class="commonInput"
-                                    style="width: 260px"
-                                    v-model:value="formState.PriceMove"
-                                />
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" v-if="isFloat()">
-                            <a-form-item label="估算价" name="PriceMove">
-                                <span class="white">{{getFloatPrice()}}</span>
-                            </a-form-item>
-                        </a-col>
+  <!-- 挂牌求购 -->
+  <Drawer :title="isBuy() ? '挂牌求购' : '挂牌卖出' "
+          :placement="'right'"
+          :visible="visible"
+          @cancel="cancel"
+          class="top">
+    <div class="title_right">
+      <span class="tline"></span>
+      <svg class="icon svg-icon"
+           aria-hidden="true">
+        <use xlink:href="#icon-xinjianzengjiaxinzeng-20" />
+      </svg>
+      <span @click="changeDirection">{{isBuy() ? '卖出' : '求购'}}</span>
+    </div>
+    <div class="post_buying">
+      <a-form class="inlineForm dialogForm"
+              ref="formRef"
+              :model="formState"
+              :rules="rules">
+        <div class="formBar">
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item label="交易账户"
+                           name="accountid">
+                <a-select class="inlineFormSelect"
+                          style="width: 260px"
+                          v-model:value="formState.accountid"
+                          placeholder="请选择">
+                  <a-select-option v-for="item in accountList"
+                                   :value="item.accountid"
+                                   :key="item.accountid">{{item.accountid}}</a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-item label="价格类型"
+                           name>
+                <a-radio-group class="commonRadioGroup"
+                               v-model:value="formState.priceType">
+                  <a-radio :value="2">固定价</a-radio>
+                  <!-- 掉期交易商有固定价和浮动价选择 -->
+                  <!-- 普通交易商只有固定价 -->
+                  <a-radio :value="3"
+                           v-if="!useUserType()">浮动价</a-radio>
+                </a-radio-group>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   v-if="!isFloat()">
+              <a-form-item label="挂牌价格"
+                           name="FixedPrice"
+                           class="inputIconBox">
+                <a-input-number class="commonInput"
+                                style="width: 260px"
+                                :min="0"
+                                v-model:value="formState.FixedPrice" />
+                <MinusOutlined @click="decreasePrice" />
+                <PlusOutlined @click="increasePrice" />
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   v-else>
+              <a-form-item label="基差"
+                           name="PriceMove">
+                <a-input-number class="commonInput"
+                                style="width: 260px"
+                                v-model:value="formState.PriceMove" />
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   v-if="isFloat()">
+              <a-form-item label="估算价"
+                           name="PriceMove">
+                <span class="white">{{getFloatPrice()}}</span>
+              </a-form-item>
+            </a-col>
 
-                        <a-col :span="24">
-                            <a-form-item label="挂牌数量" name="OrderQty" class="inputIconBox">
-                                <a-input-number
-                                    class="commonInput"
-                                    style="width: 260px"
-                                    :min="0"
-                                    :max="getMaxNum()"
-                                    v-model:value="formState.OrderQty"
-                                />
-                                <MinusOutlined @click="decreasePrice" />
-                                <PlusOutlined @click="increasePrice" />
-                                <span class="input-enumdicname">{{selectedRow.enumdicname}}</span>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" class="mt-10">
-                            <a-form-item>
-                                <a-slider
-                                    :min="0"
-                                    v-model:value="formState.OrderQty"
-                                    :max="getMaxNum()"
-                                    class="formSlider"
-                                />
-                                <div class="unit">
-                                    <span>{{getMaxNum() ? selectedRow.minivalue : 0}}</span>
-                                    <span>{{getMaxNum()}}{{selectedRow.enumdicname}}</span>
-                                </div>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" class="relative mt20">
-                            <a-form-item :label="'挂牌金额'">
-                                <span class="white ml8">{{getMoney()}}</span>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24" v-if="getMargin()">
-                            <a-form-item :label="'履约保证金'">
-                                <span class="white ml8">{{getMargin()}}</span>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="24">
-                            <a-form-item label="可用资金">
-                                <span class="white ml8">{{canUseMoney()}}</span>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
+            <a-col :span="24">
+              <a-form-item label="挂牌数量"
+                           name="OrderQty"
+                           class="inputIconBox">
+                <a-input-number class="commonInput"
+                                style="width: 260px"
+                                :min="0"
+                                :max="getMaxNum()"
+                                v-model:value="formState.OrderQty" />
+                <MinusOutlined @click="increaseNum" />
+                <PlusOutlined @click="decreaseNum" />
+                <span class="input-enumdicname">{{selectedRow.enumdicname}}</span>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   class="mt-10">
+              <a-form-item>
+                <a-slider :min="0"
+                          v-model:value="formState.OrderQty"
+                          :max="getMaxNum()"
+                          class="formSlider" />
+                <div class="unit">
+                  <span>{{getMaxNum() ? selectedRow.minivalue : 0}}</span>
+                  <span>{{getMaxNum()}}{{selectedRow.enumdicname}}</span>
                 </div>
-                <a-row :gutter="24">
-                    <a-col :span="24" class="fixedBtns">
-                        <a-form-item class="btnCenter">
-                            <a-button class="listedBtn" @click="submit">{{isBuy() ? '买入' : '卖出'}}</a-button>
-                            <a-button class="ml10 cancelBtn" @click="cancel">取消</a-button>
-                        </a-form-item>
-                    </a-col>
-                </a-row>
-            </a-form>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   class="relative mt20">
+              <a-form-item :label="'挂牌金额'">
+                <span class="white ml8">{{getMoney()}}</span>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24"
+                   v-if="getMargin()">
+              <a-form-item :label="'履约保证金'">
+                <span class="white ml8">{{getMargin()}}</span>
+              </a-form-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-item label="可用资金">
+                <span class="white ml8">{{canUseMoney()}}</span>
+              </a-form-item>
+            </a-col>
+          </a-row>
         </div>
-    </Drawer>
+        <a-row :gutter="24">
+          <a-col :span="24"
+                 class="fixedBtns">
+            <a-form-item class="btnCenter">
+              <a-button class="listedBtn"
+                        @click="submit">{{isBuy() ? '买入' : '卖出'}}</a-button>
+              <a-button class="ml10 cancelBtn"
+                        @click="cancel">取消</a-button>
+            </a-form-item>
+          </a-col>
+        </a-row>
+      </a-form>
+    </div>
+  </Drawer>
 </template>
 
 <script lang="ts">
@@ -156,7 +162,7 @@ import { v4 as uuidv4 } from 'uuid';
 import { defineComponent, PropType, ref } from 'vue';
 import { useUserType } from '../setup';
 import { FormParam } from './interface';
-import { handleForm, isFloat, useBuySellDirection } from './setup';
+import { handleForm, isFloat, useBuySellDirection, usePrice, useNum } from './setup';
 
 export default defineComponent({
     emits: ['cancel', 'update'],
@@ -263,6 +269,8 @@ export default defineComponent({
             useUserType,
             canUseMoney,
             accountList,
+            ...usePrice(),
+            ...useNum(),
         };
     },
 });

+ 25 - 0
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/post_buying/setup.ts

@@ -52,4 +52,29 @@ export function useBuySellDirection() {
         return direction.value === BuyOrSell.buy
     }
     return { direction, changeDirection, isBuy }
+}
+
+// 价格
+export const usePrice = () => {
+    function increasePrice() {
+        formState.FixedPrice++;
+    }
+    function decreasePrice() {
+        if (formState.FixedPrice) {
+            formState.FixedPrice--;
+        }
+    }
+    return { increasePrice, decreasePrice };
+};
+
+export const useNum = () => {
+    function increaseNum() {
+        formState.OrderQty++;
+    }
+    function decreaseNum() {
+        if (formState.OrderQty) {
+            formState.OrderQty--;
+        }
+    }
+    return { increaseNum, decreaseNum };
 }

+ 151 - 0
src/views/order/commodity_contract/components/commodity_contract_bargain/index.vue

@@ -0,0 +1,151 @@
+<template>
+  <!-- 商品订单 - 议价单 -->
+  <section>
+    <a-table :columns="columns"
+             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="handleBtnList(record, btnList)"
+                 :record="record"
+                 class="btn-list-sticky"
+                 @click="openComponent" />
+      </template>
+      <template #createtime="{ record }">
+        <a>{{ formatTime(record.createtime) }}</a>
+      </template>
+      <!-- 现价 -->
+      <template #lastprice="{ record }">
+        <a>{{ getLastprice(record) }}</a>
+      </template>
+      <!-- 持仓金额  -->
+      <template #holderprice="{ record }">
+        <a>{{ getHolderprice(record) }}</a>
+      </template>
+      <!-- 持仓盈亏 -->
+      <template #profitloss="{ record }">
+        <a>{{ getProfitloss(record) }}</a>
+      </template>
+    </a-table>
+    <component :is="componentId"
+               v-if="componentId"
+               :selectedRow="selectedRow"
+               :tableList="tableList"
+               @cancel="closeComponent"></component>
+  </section>
+</template>
+
+<script lang="ts">
+import { enumOrderComponents } from '@/common/constants/enumOrderComponents';
+import { queryTableList, BtnList, defineAsyncComponent, defineComponent, ModalEnum } from '@/common/export/commonTable';
+import { getRecordItemTab } from '@/common/setup/order/orderData';
+import { handleComposeOrderTable } from '@/common/setup/table/compose';
+import { ComposeOrderTableParam } from '@/common/setup/table/interface';
+import { formatTime } from '@/common/methods';
+import { expandIcon } from '@/common/setup/table/clolumn';
+import { queryTradePosition } from '@/services/go/ermcp/order';
+import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
+import { handleSubcriteQuote } from '@/common/setup/table/tableQuote';
+import { findGoodsTradeModeById, getQuoteDayInfoByCode } from '@/services/bus/goods';
+import { handleDeliveryRelation } from '@/common/setup/deliveryRelation';
+import { TradeMode } from '@/common/constants/enumCommon';
+import { BtnListType } from '@/common/components/btnList/interface';
+import { columns } from './setup';
+
+export default defineComponent({
+    name: 'commodity_contract_bargain',
+    components: {
+        BtnList,
+        // [ModalEnum.commodity_contract_summary_settlement]: defineAsyncComponent(() => import('./components/commodity_contract_summary_settlement/index.vue')),
+        // [ModalEnum.commodity_contract_summary_transfer]: defineAsyncComponent(() => import('./components/commodity_contract_summary_transfer/index.vue')),
+        // commodity_contract_summary_deal_closed: defineAsyncComponent(() => import('./components/commodity_contract_summary_deal_closed/index.vue')),
+    },
+    setup() {
+        // 表格列表数据
+        const { loading, tableList, queryTable } = queryTableList<QueryTradePositionRsp>();
+        const { subscribeAction } = handleSubcriteQuote();
+        // 交割商品
+        handleDeliveryRelation();
+        // 获取列表数据
+        const queryTableAction = () => {
+            queryTable(queryTradePosition).then((res) => {
+                const goodsList = res.map((el) => {
+                    return el.goodscode;
+                });
+                //  行情订阅
+                subscribeAction(goodsList);
+            });
+        };
+        // 表格通用逻辑
+        const param: ComposeOrderTableParam = {
+            queryFn: queryTableAction,
+            recordList: getRecordItemTab(),
+        };
+        // 现价
+        function getLastprice({ goodscode, decimalplace }: QueryTradePositionRsp) {
+            const item = getQuoteDayInfoByCode(goodscode);
+            let result = '';
+            if (item) {
+                const { last, presettle } = item;
+                if (last) {
+                    result = last.toFixed(decimalplace); // 最新
+                } else if (presettle) {
+                    result = presettle.toFixed(decimalplace); // 昨结
+                }
+            }
+            return result;
+        }
+        // 持仓金额 = 数量 * 现价 * 合约单位
+        function getHolderprice(record: QueryTradePositionRsp) {
+            const price = getLastprice(record);
+            if (price !== '--') {
+                const { decimalplace, agreeunit, curpositionqty } = record;
+                return (+price * curpositionqty * agreeunit).toFixed(decimalplace);
+            } else {
+                return price;
+            }
+        }
+        /// 持仓盈亏 买方向 = (最新价 - 持仓均价) * 买期末头寸 * 合约单位;卖方向 = (持仓均价 - 最新价) * 卖期末头寸 * 合约单位
+        function getProfitloss(record: QueryTradePositionRsp) {
+            const price = getLastprice(record);
+            if (price !== '--') {
+                const { averageprice, decimalplace, agreeunit, curpositionqty } = record;
+                return ((+price - averageprice) * curpositionqty * agreeunit).toFixed(decimalplace);
+            } else {
+                return price;
+            }
+        }
+        function handleBtnList(record: QueryTradePositionRsp, btnList: BtnListType[]) {
+            if (findGoodsTradeModeById(record.goodsid) === TradeMode.DiaoQi) {
+                return btnList.filter((e) => e.code === 'commodity_contract_summary_deal_closed');
+            } else {
+                return btnList.filter((e) => e.code !== 'commodity_contract_summary_deal_closed');
+            }
+        }
+        return {
+            ...handleComposeOrderTable<QueryTradePositionRsp>(param),
+            columns,
+            loading,
+            tableList,
+            formatTime,
+            expandIcon,
+            getLastprice,
+            getHolderprice,
+            getProfitloss,
+            handleBtnList,
+        };
+    },
+});
+</script>
+
+<style lang="less">
+</style>;

+ 9 - 0
src/views/order/commodity_contract/components/commodity_contract_bargain/setup.ts

@@ -0,0 +1,9 @@
+export const columns = [
+    { title: '订单合约', dataIndex: 'goodsname', key: 'goodsname', align: 'center' },
+    { title: '方向', dataIndex: 'buyorsell', key: 'buyorsell', align: 'center', slots: { customRender: 'buyorsell' } },
+    { title: '协议价', dataIndex: 'transferprice', key: 'transferprice', align: 'center' },
+    { title: '数量', dataIndex: 'qty', key: 'qty', align: 'center', slots: { customRender: 'qty' } },
+    { title: '金额', dataIndex: 'transferamount', key: 'transferamount', align: 'center', slots: { customRender: 'transferamount' } },
+    { title: '状态', dataIndex: 'applystatus', key: 'applystatus', align: 'center', slots: { customRender: 'applystatus' } },
+    { title: '时间', dataIndex: 'applytime', key: 'applytime', align: 'center', slots: { customRender: 'applytime' } },
+];

+ 1 - 0
src/views/order/commodity_contract/index.vue

@@ -24,6 +24,7 @@ export default defineComponent({
         [enumOrderComponents.commodity_contract_commission]: defineAsyncComponent(() => import('./components/commodity_contract_commission/index.vue')),
         [enumOrderComponents.commodity_contract_make_deal]: defineAsyncComponent(() => import('./components/commodity_contract_make_deal/index.vue')),
         [enumOrderComponents.commodity_contract_settlement]: defineAsyncComponent(() => import('./components/commodity_contract_settlement/index.vue')),
+        commodity_contract_bargain: defineAsyncComponent(() => import('./components/commodity_contract_bargain/index.vue')),
     },
     setup() {
         return { ...handleOrderDetailList(enumOrderComponents.commodity_contract) };