From c264438b92a9ded3aa0796ab6968c70195ecac01 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Sun, 28 Sep 2025 15:09:58 +0800
Subject: [PATCH] 1

---
 src/components/tabHead.vue              |    4 ++--
 src/page/user/Warehouse/Stockdetail.vue |   28 +++-------------------------
 src/page/trading/TradeNew.vue           |   26 ++++++++++++++++++++++++--
 src/axios/api.js                        |    2 +-
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/axios/api.js b/src/axios/api.js
index a12d8cf..7e1f527 100644
--- a/src/axios/api.js
+++ b/src/axios/api.js
@@ -255,7 +255,7 @@
 export function sell(options) {
   return post("/user/sell.do", options);
 }
-// 用户平仓
+// 用户一键平仓
 export function allsell(options) {
   return post("/user/allsell.do", options);
 }
diff --git a/src/components/tabHead.vue b/src/components/tabHead.vue
index 599932b..27df46a 100644
--- a/src/components/tabHead.vue
+++ b/src/components/tabHead.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="tab_head">
-    <div class="head_left">
-      <div class="icon" @click="searchShow = true" v-if="leftShow">
+    <div class="head_left flex-center">
+      <div class="icon" @click="searchShow = true" v-if="leftShow" style="margin-right:.2666rem;">
         <van-icon name="search" size=".5em" />
       </div>
       <slot name="left"></slot>
diff --git a/src/page/trading/TradeNew.vue b/src/page/trading/TradeNew.vue
index 76a7fba..3c6b5ce 100644
--- a/src/page/trading/TradeNew.vue
+++ b/src/page/trading/TradeNew.vue
@@ -1,6 +1,12 @@
 <template>
   <div class="trade_new">
-    <tab-head></tab-head>
+    <tab-head>
+      <van-popover v-model="showPopover" trigger="click" :actions="actions" @select="onSelect" slot="left">
+        <template #reference>
+          <van-button type="primary">{{ $t("一键平仓") }}</van-button>
+        </template>
+      </van-popover>
+    </tab-head>
 
     <div class="order_tabs">
       <van-tabs v-model="active" swipe-threshold="1">
@@ -84,6 +90,7 @@
 import tabHead from "@/components/tabHead.vue";
 import * as api from "@/axios/api";
 import nPagination from "@/components/nPagination.vue";
+import { Notify } from "vant";
 
 export default {
   components: {
@@ -102,7 +109,9 @@
         2: "IPO",
         3: this.$t("hj621"),
         4: "AI"
-      }
+      },
+      actions: [{ text: '确定', key: '1' }, { text: '取消', key: '2' }],
+      showPopover: false,
     };
   },
   watch: {
@@ -158,6 +167,19 @@
       times = setInterval(() => {
         this.getList();
       }, 3000);
+    },
+    // 一键平仓确认弹框
+    onSelect(action) {
+      if (action.key == 1) this.oneClose();
+    },
+    // 一键平仓
+    async oneClose() {
+      const res = await api.allsell();
+      if (res.status === 0) {
+        Notify({ type: "success", message: res.msg });
+      } else {
+        Notify({ type: "danger", message: res.msg });
+      }
     }
   }
 };
diff --git a/src/page/user/Warehouse/Stockdetail.vue b/src/page/user/Warehouse/Stockdetail.vue
index acf44a8..39fd880 100644
--- a/src/page/user/Warehouse/Stockdetail.vue
+++ b/src/page/user/Warehouse/Stockdetail.vue
@@ -96,13 +96,13 @@
         </div>
       </div>
       <div class="buttonbox flex-center" v-show="!pages.sellOrderTime">
-        <!-- <van-button type="primary" @click="close"> {{ $t("平仓") }}</van-button> -->
+        <van-button type="primary" @click="close"> {{ $t("平仓") }}</van-button>
 
-        <van-popover v-model="showPopover" trigger="click" placement="top" :actions="actions" @select="onSelect">
+        <!-- <van-popover v-model="showPopover" trigger="click" placement="top" :actions="actions" @select="onSelect">
           <template #reference>
             <van-button type="primary"> {{ $t("一键平仓") }}</van-button>
           </template>
-        </van-popover>
+        </van-popover> -->
       </div>
 
       <Dialog ref="closeDialog" :title="$t('确认平仓')" :confirm="confirm">
@@ -142,9 +142,6 @@
     return {
       pages: {},
       ordernum: "",
-      showPopover: false,
-      // 通过 actions 属性来定义菜单选项
-      actions: [{ text: '确定', key: '1' }, { text: '取消', key: '2' }],
     };
   },
   // 生命周期 - 创建完成(访问当前this实例)
@@ -203,25 +200,6 @@
         Notify({ type: "danger", message: res.msg });
       }
     },
-    // 一键平仓确认弹框
-    onSelect(action) {
-      console.log(action.key);
-      if (action.key == 1) this.oneClose();
-    },
-    // 一键平仓
-    async oneClose() {
-      const res = await api.sell({
-        positionSn: this.pages.positionSn,
-        number: this.pages.orderNum
-      });
-      if (res.status === 0) {
-        this.finished = false;
-        Notify({ type: "success", message: res.msg });
-        this.$router.go(-1);
-      } else {
-        Notify({ type: "danger", message: res.msg });
-      }
-    }
   }
 };
 </script>

--
Gitblit v1.9.3