Przeglądaj źródła

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin 4 lat temu
rodzic
commit
f39905f988

+ 11 - 5
src/common/components/echart/echart-timeline/setup.ts

@@ -84,11 +84,17 @@ export function handleEchart() {
                     color: '#4d535c',
                 },
                 formatter: (params: any) => {
-                    const i = params[0].dataIndex;
-                    let result = '<div class="tooltip-title">' + moment(times[i]).format('YYYY-MM-DD HH:mm') + '</div>';
-                    result += '<div class="tooltip-item"><span><i style="background-color:' + params[0].color + ';"></i>收盘</span><span>' + datas[i] + '</span></div>';
-                    result += '<div class="tooltip-item"><span><i style="background-color:' + params[2].color + ';"></i>均价</span><span>' + ma5[i] + '</span></div>';
-                    result += '<div class="tooltip-item"><span><i></i>涨幅</span><span>' + calcRatio(datas[i]) + '</span></div>';
+                    let result = '';
+                    params.forEach((item: any, index: number) => {
+                        if (index === 0) {
+                            result += '<div class="tooltip-title">' + moment(times[item.dataIndex]).format('YYYY-MM-DD HH:mm') + '</div>';
+                            result += '<div class="tooltip-item"><span><i style="background-color:' + item.color + ';"></i>收盘</span><span>' + item.value + '</span></div>';
+                        }
+                        if (index === 2) {
+                            result += '<div class="tooltip-item"><span><i style="background-color:' + item.color + ';"></i>均价</span><span>' + item.value + '</span></div>';
+                            result += '<div class="tooltip-item"><span><i></i>涨幅</span><span>' + calcRatio(item.value) + '</span></div>';
+                        }
+                    })
                     return result;
                 },
             },

+ 40 - 0
src/hooks/form/verify.ts

@@ -1,4 +1,6 @@
 import { RuleObject } from "ant-design-vue/lib/form/interface";
+import { getGoodsById, getQuoteDayInfoByCode } from '@/services/bus/goods';
+import { getRules } from '@/services/bus/rules';
 
 // 验证 挂牌数量
 /**
@@ -34,3 +36,41 @@ export const useVerifyListingNum = <T extends object, k extends keyof T>(formSta
     return { v_num }
 }
 
+
+/**
+ * 验证 挂牌基差
+ * @param formState 表单状态
+ * @param key 商品ID对应的key
+ * @returns
+ */
+export const useVerifyListingBasis = <T, k extends keyof T>(formState: T, key: k) => {
+    const v_basis = async (rule: RuleObject, value: number) => {
+        if (formState[key]) {
+            if (value) {
+                const goodsCode = getGoodsById(formState[key] as unknown as number)?.goodscode as string;
+                const quote = getQuoteDayInfoByCode(goodsCode);
+                if (quote) {
+                    const { basisdownratio, basisupratio } = getRules()[0];
+                    // 最小值 = 基差下限百分比 * 昨日收盘价 * -1
+                    const minValue = (basisdownratio * quote.presettle * -1).toFixed(2);
+                    // 最大值 = 基差上限百分比 * 昨日收盘价
+                    const maxValue = (basisupratio * quote.presettle).toFixed(2);
+
+                    if (value < Number(minValue)) {
+                        return Promise.reject(`基差不能小于${minValue}`);
+                    }
+                    if (value > Number(maxValue)) {
+                        return Promise.reject(`基差不能大于${maxValue}`);
+                    }
+                    return Promise.resolve();
+                }
+                return Promise.reject('商品合约不存在');
+            } else {
+                return Promise.reject('请输入基差');
+            }
+        } else {
+            return Promise.reject('请选择商品合约');
+        }
+    };
+    return { v_basis }
+}

+ 11 - 20
src/views/market/spot_trade/components/buy-sell-market/index.vue

@@ -57,7 +57,7 @@
                     </div>
                 </div>
             </div>
-            <a-button class="market" v-if="isFloat()" @click="openChartComponent">
+            <a-button class="market" v-if="isFloat()" @click="openComponent({ code: 'GoodsChart' })">
                 <div class="first">{{ selectedRow.goodscode }}</div>
                 <div class="last red">{{ getGoodsPrice() }}</div>
                 <LineChartOutlined />
@@ -77,8 +77,7 @@
                 <Buy :enumName="enumName" ref="buyRef" :time="time" :parantSelectedRow="selectedRow" :btnList="handleBtnList(buyMarket.btnList)" />
             </a-col>
         </a-row>
-        <GoodsChart v-if="showChartComponent" :enumName="enumName" :selectedRow="quoteDayInfo" @cancel="closeChartComponent" />
-        <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" :goodsPrice="getGoodsPrice()" :enumName="enumName" :time="time" @cancel="closeComponent"> </component>
+        <component :is="componentId" v-if="componentId" :selectedRow="getSelectedRow()" :goodsPrice="getGoodsPrice()" :enumName="enumName" :time="time" @cancel="closeComponent"> </component>
     </div>
 </template>
 
@@ -135,9 +134,6 @@ export default defineComponent({
         const loading = ref<boolean>(false);
         const { visible, cancel } = _closeModal(context);
 
-        const showChartComponent = ref(false); // 显示/隐藏图表
-        const quoteDayInfo = ref<QueryQuoteDayRsp>(); // 盘口数据
-
         const { isWR, isFloat } = handleIs(props.enumName, BuyOrSell.buy);
         // 买卖大厅 配置数据
         // 表格操作按钮列表
@@ -194,17 +190,15 @@ export default defineComponent({
         // 单据挂牌成功 通知买大厅刷新数据
         Bus.$on('spotTrade', queryFn);
 
-        const openChartComponent = () => {
-            quoteDayInfo.value = getQuoteDayInfoByCode(props.selectedRow.goodscode);
-            if (quoteDayInfo.value) {
-                showChartComponent.value = true;
-            } else {
-                console.error('盘口数据获取失败');
+        const quote = getQuoteDayInfoByCode(props.selectedRow.goodscode);
+        // 切换组件数据
+        const getSelectedRow = () => {
+            if (componentId.value === 'GoodsChart') {
+                return quote;
+            }
+            if (componentId.value === 'HisChart') {
+                return props.selectedRow;
             }
-        };
-
-        const closeChartComponent = () => {
-            showChartComponent.value = false;
         };
 
         return {
@@ -225,10 +219,7 @@ export default defineComponent({
             handleBtnList,
             isWR,
             timeChange,
-            quoteDayInfo,
-            showChartComponent,
-            openChartComponent,
-            closeChartComponent,
+            getSelectedRow,
         };
     },
 });

+ 83 - 134
src/views/market/spot_trade/components/post_buying/index.vue

@@ -1,116 +1,70 @@
 <template>
-  <!-- 挂牌求购 -->
-  <Drawer :title="'挂牌求购'"
-          :placement="'right'"
-          :visible="visible"
-          @cancel="cancel"
-          class="top">
-    <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"
-                   v-if="!isFloat()">
-              <a-form-item label="挂牌价格"
-                           name="FixedPrice">
-                <a-input-number class="commonInput"
-                                style="width: 260px"
-                                :min="0"
-                                v-model:value="formState.FixedPrice" />
-              </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">{{ getPrice() }}</span>
-              </a-form-item>
-            </a-col>
+    <!-- 挂牌求购 -->
+    <Drawer :title="'挂牌求购'" :placement="'right'" :visible="visible" @cancel="cancel" class="top">
+        <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" v-if="!isFloat()">
+                            <a-form-item label="挂牌价格" name="FixedPrice">
+                                <a-input-number class="commonInput" style="width: 260px" :min="0" v-model:value="formState.FixedPrice" />
+                            </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">{{ getPrice() }}</span>
+                            </a-form-item>
+                        </a-col>
 
-            <a-col :span="24">
-              <a-form-item label="挂牌数量"
-                           name="OrderQty">
-                <a-input-number class="commonInput"
-                                style="width: 260px"
-                                :min="0"
-                                :max="getMaxNum()"
-                                v-model:value="formState.OrderQty" />
-                <span class="input-enumdicname">{{ selectedRow.enumdicname }}</span>
-              </a-form-item>
-            </a-col>
-            <a-col :span="24"
-                   v-if="!isWR()">
-              <a-form-item label="交收月"
-                           name="DeliveryMonth">
-                <a-month-picker style="width: 260px"
-                                v-model:value="formState.DeliveryMonth"
-                                :allowClear="false"
-                                class="commonDatePicker dialogDatePicker" />
-              </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">
-              <a-form-item label="起摘数量"
-                           name="DelistMinQty"
-                           class="relative">
-                <a-input-number class="commonInput"
-                                :suffix="selectedRow.enumdicname"
-                                v-model:value="formState.DelistMinQty"
-                                :min="0"
-                                style="width: 260px !important" />
-                <div class="tip">最小单位:{{ selectedRow.minivalue }}{{ selectedRow.enumdicname }}</div>
-              </a-form-item>
-            </a-col>
-            <a-col :span="24"
-                   class="relative mt20">
-              <a-form-item :label="isFloat() ? '估算金额' : '挂牌金额'">
-                <span class="white ml8">{{ getMoney() }}</span>
-              </a-form-item>
-            </a-col>
-            <a-col :span="24"
-                   v-if="getMargin()">
-              <a-form-item :label="getMargin() ? '履约保证金' : ''">
-                <!-- <a-row>
+                        <a-col :span="24">
+                            <a-form-item label="挂牌数量" name="OrderQty">
+                                <a-input-number class="commonInput" style="width: 260px" :min="0" :max="getMaxNum()" v-model:value="formState.OrderQty" />
+                                <span class="input-enumdicname">{{ selectedRow.enumdicname }}</span>
+                            </a-form-item>
+                        </a-col>
+                        <a-col :span="24" v-if="!isWR()">
+                            <a-form-item label="交收月" name="DeliveryMonth">
+                                <a-month-picker style="width: 260px" v-model:value="formState.DeliveryMonth" :allowClear="false" class="commonDatePicker dialogDatePicker" />
+                            </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">
+                            <a-form-item label="起摘数量" name="DelistMinQty" class="relative">
+                                <a-input-number class="commonInput" :suffix="selectedRow.enumdicname" v-model:value="formState.DelistMinQty" :min="0" style="width: 260px !important" />
+                                <div class="tip">最小单位:{{ selectedRow.minivalue }}{{ selectedRow.enumdicname }}</div>
+                            </a-form-item>
+                        </a-col>
+                        <a-col :span="24" class="relative mt20">
+                            <a-form-item :label="isFloat() ? '估算金额' : '挂牌金额'">
+                                <span class="white ml8">{{ getMoney() }}</span>
+                            </a-form-item>
+                        </a-col>
+                        <a-col :span="24" v-if="getMargin()">
+                            <a-form-item :label="getMargin() ? '履约保证金' : ''">
+                                <!-- <a-row>
                                 <a-col :span="8">-->
-                <span class="white ml8">{{ getMargin() }}</span>
-                <!-- </a-col>
+                                <span class="white ml8">{{ getMargin() }}</span>
+                                <!-- </a-col>
                                     <a-col :span="4" class="tr">
                                         <span class="grey1">可用资金</span>
                                     </a-col>
@@ -120,31 +74,26 @@
                                         >{{getCanUseMoney(getSelectedAccount())}}</span>
                                     </a-col>
                                 </a-row>-->
-              </a-form-item>
-            </a-col>
-            <a-col :span="24">
-              <a-form-item label="可用资金">
-                <span class="white ml8">{{ getCanUseMoney(getSelectedAccount()) }}</span>
-              </a-form-item>
-            </a-col>
-          </a-row>
+                            </a-form-item>
+                        </a-col>
+                        <a-col :span="24">
+                            <a-form-item label="可用资金">
+                                <span class="white ml8">{{ getCanUseMoney(getSelectedAccount()) }}</span>
+                            </a-form-item>
+                        </a-col>
+                    </a-row>
+                </div>
+                <a-row :gutter="24">
+                    <a-col :span="24" class="fixedBtns">
+                        <a-form-item class="btnCenter">
+                            <a-button class="listedBtn" @click="submit" :loading="loading">买入</a-button>
+                            <a-button class="ml10 cancelBtn" @click="cancel" :disabled="loading">取消</a-button>
+                        </a-form-item>
+                    </a-col>
+                </a-row>
+            </a-form>
         </div>
-        <a-row :gutter="24">
-          <a-col :span="24"
-                 class="fixedBtns">
-            <a-form-item class="btnCenter">
-              <a-button class="listedBtn"
-                        @click="submit"
-                        :loading="loading">买入</a-button>
-              <a-button class="ml10 cancelBtn"
-                        @click="cancel"
-                        :disabled="loading">取消</a-button>
-            </a-form-item>
-          </a-col>
-        </a-row>
-      </a-form>
-    </div>
-  </Drawer>
+    </Drawer>
 </template>
 
 <script lang="ts">

+ 6 - 3
src/views/market/spot_trade/components/post_buying/setup.ts

@@ -1,6 +1,6 @@
 import { BuyOrSell } from "@/common/constants/enumCommon";
 import { EnumRouterName } from "@/common/constants/enumRouterName";
-import { useVerifyListingNum } from '@/hooks/form/verify';
+import { useVerifyListingNum, useVerifyListingBasis } from '@/hooks/form/verify';
 import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
 import { getRules } from '@/services/bus/rules';
 import { AccountListItem } from "@/services/dataCenter/interafce/account";
@@ -24,11 +24,14 @@ const formState: UnwrapRef<FormParam> = reactive(initFormData())
 export function handleForm(selectedRow: TempWrOrderQuoteDetail) {
     const formRef = ref();
     formState.OrderQty = selectedRow.minivalue
-    const { v_num } = useVerifyListingNum<FormParam, 'DelistMinQty'>(formState, 'DelistMinQty', selectedRow.minivalue)
+
+    const { v_num } = useVerifyListingNum<FormParam, 'DelistMinQty'>(formState, 'DelistMinQty', selectedRow.minivalue);
+    const { v_basis } = useVerifyListingBasis(selectedRow, 'goodsid');
+
     const rules = {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', }],
         OrderQty: [{ required: true, validator: v_num, trigger: 'change', type: 'number' }],
-        PriceMove: [{ required: true, message: '请输入基差', trigger: 'blur', type: 'number' }],
+        PriceMove: [{ required: true, validator: v_basis, trigger: 'blur', type: 'number', }],
         accountid: [{ required: true, message: '请输入交易账号' }],
     }
     onBeforeUnmount(() => {

+ 6 - 0
src/views/order/financing_manager/components/financing_manager_contract/components/buyback/index.vue

@@ -154,4 +154,10 @@ export default defineComponent({
 </script>
 
 <style lang="less" scoped>
+.ant-form.dialogForm .ant-row.ant-form-item .ant-form-item-label {
+    width: 90px;
+}
+.ant-form.dialogForm .ant-row.ant-form-item .ant-form-item-control-wrapper {
+    width: calc(100% - 90px);
+}
 </style>;

+ 5 - 4
src/views/order/pre_sale_warehouse_receipt/components/pre_sale_warehouse_receipt_order_summary/components/listed/setup.ts

@@ -1,8 +1,8 @@
 import { TradeMode } from '@/common/constants/enumCommon';
 import { validateCommon } from '@/common/setup/validate';
 import { handleForm as useForm } from '@/common/setup/warehouse_receipt_trade/listing';
-import { useVerifyListingNum } from '@/hooks/form/verify';
-import { getGoodsGroupsByTradeMode, getIPOGoodsList, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
+import { useVerifyListingNum, useVerifyListingBasis } from '@/hooks/form/verify';
+import { getGoodsGroupsByTradeMode, getIPOGoodsList, getGoodsById, getQuoteDayInfoByCode, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
 import { getRules } from '@/services/bus/rules';
 import { Goods } from "@/services/go/ermcp/goodsInfo/interface";
 import { WrPosition } from "@/services/go/wrtrade/interface";
@@ -45,12 +45,13 @@ export function handleForm(data: WrPosition) {
         }
     };
 
-    const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, creditenableqty)
+    const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, creditenableqty);
+    const { v_basis } = useVerifyListingBasis(formState, 'goodsid');
 
     const rule = {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', min: 1, }],
         OrderQty: [{ required: true, validator: v_num, trigger: 'blur', type: 'number' }],
-        PriceMove: [{ required: true, message: '请输入基差', trigger: 'blur', type: 'number' }],
+        PriceMove: [{ required: true, validator: v_basis, trigger: 'blur', type: 'number', }],
         DelistMinQty: [{ required: true, message: '请输入起摘数量', trigger: 'blur', type: 'number', min: 0, }],
         DeliveryMonth: [{ required: true, message: '请选择交收月', }],
         goodsid: [{ required: true, validator: v_group }],

+ 3 - 34
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/setup.ts

@@ -1,7 +1,7 @@
 import { TradeMode } from '@/common/constants/enumCommon';
 import { validateCommon } from '@/common/setup/validate';
 import { handleForm as useForm } from '@/common/setup/warehouse_receipt_trade/listing';
-import { useVerifyListingNum } from '@/hooks/form/verify';
+import { useVerifyListingNum, useVerifyListingBasis } from '@/hooks/form/verify';
 import { getGoodsGroupsByTradeMode, getIPOGoodsList, getGoodsById, getQuoteDayInfoByCodeFindPrice, getQuoteDayInfoByCode } from '@/services/bus/goods';
 import { getRules } from '@/services/bus/rules';
 import { Goods } from "@/services/go/ermcp/goodsInfo/interface";
@@ -46,39 +46,8 @@ export function handleForm(data: WrHoldLB) {
         }
     };
 
-    // 验证基差上下限
-    const v_basis = async (rule: RuleObject, value: number) => {
-        if (formState.goodsid) {
-            if (value) {
-                const goodsCode = getGoodsById(formState.goodsid)?.goodscode as string;
-                const quote = getQuoteDayInfoByCode(goodsCode);
-                if (quote) {
-                    const { basisdownratio, basisupratio } = getRules()[0];
-                    // 最小值 = 基差下限百分比 * 昨日收盘价 * -1
-                    const minValue = basisdownratio * quote.presettle * -1;
-                    // 最大值 = 基差上限百分比 * 昨日收盘价
-                    const maxValue = basisupratio * quote.presettle;
-
-                    if (value > minValue && value < maxValue) {
-                        return Promise.resolve();
-                    } else {
-                        if (value < minValue) {
-                            return Promise.reject(`基差下限不能小于${minValue.toFixed(2)}`);
-                        }
-                        if (value > maxValue) {
-                            return Promise.reject(`基差上限不能大于${maxValue.toFixed(2)}`);
-                        }
-                    }
-                }
-            } else {
-                return Promise.reject('请输入基差');
-            }
-        } else {
-            return Promise.reject('没有合约商品');
-        }
-    }
-
-    const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, enableqty)
+    const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, enableqty);
+    const { v_basis } = useVerifyListingBasis(formState, 'goodsid');
 
     const rule = {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', min: 1, }],