From 645730962750ed6a81b5b6d1a134706607b20576 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Mon, 29 Sep 2025 14:32:21 +0800
Subject: [PATCH] 1

---
 src/views/home/components/HomeRight.vue |   74 +++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 40 deletions(-)

diff --git a/src/views/home/components/HomeRight.vue b/src/views/home/components/HomeRight.vue
index 829fddb..ea64cfa 100644
--- a/src/views/home/components/HomeRight.vue
+++ b/src/views/home/components/HomeRight.vue
@@ -1,39 +1,22 @@
 <template>
   <div class="home_right">
     <div class="deal_type">
-      <div
-        class="deal_item flex-center bt"
-        :class="{ deal_item_active: active == 0 }"
-        @click="changeTab(0)"
-      >
+      <div class="deal_item flex-center bt" :class="{ deal_item_active: active == 0 }" @click="changeTab(0)">
         {{ $t("buy") }}
       </div>
-      <div
-        v-if="!!positionSn"
-        class="deal_item flex-center bt"
-        :class="{ deal_item_active: active == 1 }"
-        @click="changeTab(1)"
-      >
+      <div v-if="!!positionSn" class="deal_item flex-center bt" :class="{ deal_item_active: active == 1 }"
+        @click="changeTab(1)">
         {{ $t("hj121") }}
       </div>
     </div>
     <!-- buy -->
     <div class="submit_form" v-if="active == 0">
-      <el-input
-        v-model="bform.price"
-        style="text-align: end"
-        oninput="value=value.replace(/[^\d.]/g,'')"
-        disabled
-      >
+      <el-input v-model="bform.price" style="text-align: end" oninput="value=value.replace(/[^\d.]/g,'')" disabled>
         <div slot="prefix" class="inp_prefix flex-center">{{ $t("bp") }}</div>
       </el-input>
 
-      <el-input
-        v-model="bform.num"
-        style="text-align: end"
-        oninput="value=value.replace(/[^\d.]/g,'')"
-      >
-        <div slot="prefix" class="inp_prefix flex-center">{{ $t("sl") }}</div>
+      <el-input v-model="bform.num" style="text-align: end" oninput="value=value.replace(/[^\d.]/g,'')">
+        <div slot="prefix" class="inp_prefix flex-center">{{ $t("sl") }}({{ $t('hj117') }})</div>
       </el-input>
 
       <div class="slider_box">
@@ -44,7 +27,7 @@
         <div class="label">{{ $t("tc") }}</div>
         <div class="value">
           {{ obj.type | currencySymbol }}
-          {{ (obj.nowPrice * bform.num) | _toLocaleString }}
+          {{ (obj.nowPrice * bform.num * stockNum) | _toLocaleString }}
           <!-- <div v-if="obj.type != $mc">
             ≈ $
             {{ (obj.nowPrice * bform.num * rate(obj.type)) | _toLocaleString }}
@@ -78,26 +61,17 @@
         </div>
       </div>
 
-      <el-input
-        v-model="sform.price"
-        style="text-align: end"
-        oninput="value=value.replace(/[^\d.]/g,'')"
-        disabled
-      >
+      <el-input v-model="sform.price" style="text-align: end" oninput="value=value.replace(/[^\d.]/g,'')" disabled>
         <div slot="prefix" class="inp_prefix flex-center">{{ $t("sp") }}</div>
       </el-input>
 
-      <el-input
-        v-model="sform.num"
-        style="text-align: end"
-        oninput="value=value.replace(/[^\d.]/g,'')"
-      >
+      <el-input v-model="sform.num" style="text-align: end" oninput="value=value.replace(/[^\d.]/g,'')" disabled>
         <div slot="prefix" class="inp_prefix flex-center">{{ $t("sl") }}</div>
       </el-input>
 
-      <div class="slider_box">
+      <!-- <div class="slider_box">
         <el-slider v-model="sVal" :marks="marks"> </el-slider>
-      </div>
+      </div> -->
 
       <div class="info_item flex-between">
         <div class="label">{{ $t("tc") }}</div>
@@ -147,12 +121,13 @@
       depositAmount: "", // 存款金额
       moneyData: [], // 账户金额
       pages: {}, // 已购买股票信息
+      stockNum: 0, // 每手股数
     };
   },
   props: {
     obj: {
       type: Object,
-      default: () => {},
+      default: () => { },
     },
     positionSn: {
       type: String,
@@ -173,9 +148,14 @@
   },
   watch: {
     obj: {
-      handler(val) {
+      handler(val, oldVal) {
         this.sform.price = this.bform.price =
           Math.floor(val.nowPrice * 100) / 100 || 0;
+
+        // 判断如果新获取的数据和旧的数据不一样,则重新获取每手股数
+        if (val.code != oldVal.code) {
+          this.getStockBuySetting(val.type)
+        }
       },
       immediate: true,
     },
@@ -183,7 +163,7 @@
     bVal(val) {
       this.bform.num = Math.floor(
         (this.CurrentMoneyData.availableBalance * (val / 100)) /
-          this.obj.nowPrice
+        (this.obj.nowPrice * this.stockNum)
       );
     },
     sVal(val) {
@@ -224,6 +204,7 @@
       if (data.status === 0) {
         this.$message.success(data.msg);
         this.getMoney();
+        this.$emit("Refresh");
       } else {
         this.$message.error(data.msg);
       }
@@ -236,6 +217,7 @@
       let data = await api.findByPostionSn(res);
       if (data.status === 0) {
         this.pages = data.data;
+        this.sform.num = data.data.orderNum;
       }
     },
     // 平仓
@@ -248,8 +230,16 @@
       if (data.status == 0) {
         this.$message.success(data.msg);
         this.getInfoSite();
+        this.$emit("Refresh");
       }
     }),
+    // 获取每手的股数
+    async getStockBuySetting(bayType) {
+      let data = await api.queryStockBuySetting({ stockType: bayType });
+      if (data.status === 0) {
+        this.stockNum = data.data[0].stockNum;
+      }
+    }
   },
 };
 </script>
@@ -257,6 +247,7 @@
 <style lang="scss" scoped>
 .home_right {
   width: 100%;
+
   .submit_form {
     padding: 16px;
     display: flex;
@@ -274,6 +265,7 @@
       display: flex;
       flex-direction: column;
       gap: 10px;
+
       .position_item {
         background-color: #fff;
         padding: 10px;
@@ -336,6 +328,7 @@
         height: 40px;
         border-radius: 40px;
       }
+
       .bt2 {
         background-color: #dfb758;
       }
@@ -362,6 +355,7 @@
       color: #fff;
       background-color: #07c160;
     }
+
     .deal_item_active:nth-child(2) {
       background-color: #dfb758;
     }

--
Gitblit v1.9.3