1
jhzh
2026-01-14 fa821ce7a7755dd0e13897cefc57071d4596431b
src/page/user/Warehouse.vue
@@ -8,7 +8,7 @@
            <div class="sert">
                <span v-for="(item, index) in chicangList" :key="index" @click="chicangidx = index"
                    :class="chicangidx == index ? 'sdpl' : ''">{{ item.name }}</span>
                <a :style="{ left: getIndicatorLeft() + 'rem' }"></a>
                <a :style="{ left: getIndicatorLeft() }"></a>
            </div>
            <div class="bnm"></div>
        </div>
@@ -17,7 +17,7 @@
        <van-list v-model="loading" :finished="finished" :finished-text="$t('hj43')"
                v-show="chicangidx === 0" @load="onLoad" :immediate-check="immediate">
            <!-- <div class="cichang" v-for="(item,index) in tabsPositionNumArr" :key="item.buyOrderId"> -->
         <div class="cichang" v-for="(item, key) in tabsPositionObj" :key="item.buyOrderId">
         <div class="cichang" v-for="(item, key) in tabsPositionObj" :key="item.buyOrderId" @click="goDetail(item)">
                <div class="dingbu">
                    <div class="dl">
                        <h6>{{ item.stockName ? item.stockName : item.indexName }}</h6>
@@ -31,7 +31,7 @@
                  <div class="button-container">
                    <!-- <div class="dr" style="margin-right: 16px" v-if="chicangidx == 0" @click="goBuyDetail(item)">买入</div>
                    <div class="dr-blue" style="margin-right: 16px"  v-if="chicangidx == 0" @click="getpingcangbf(item.positionSn,item.orderNum)"> 部分平仓 </div> -->
               <div class="dr-blue" style="margin-right: 16px"  v-if="chicangidx == 0" @click="getpingcang(item.positionSn)"> {{ $t('hj121') }} </div>
               <div class="dr-blue" style="margin-right: 16px"  v-if="chicangidx == 0" @click.stop="getpingcang(item.positionSn)"> {{ $t('hj121') }} </div>
                  </div>
                         </div>
@@ -58,7 +58,7 @@
                    <!-- <p v-if="chicangidx == 1"><span>{{ $t('jy19') }}</span><a class="red">5.49/{{ $t('jy96') }}</a></p>
                    <p v-if="chicangidx == 1"><span>{{ $t('jy15') }}</span><a class="red">49959.00</a></p> -->
               <!-- <p><span>{{ $t('jy531') }}</span><a class="red">{{item.orderLever}}</a></p> -->
               <p><span>{{ $t('jy37') }}</span><a class="red">{{item.buyAmtAutual}}</a></p>
               <!-- <p><span>{{ $t('jy37') }}</span><a class="red">{{item.buyAmtAutual}}</a></p> -->
                </div>
            </div>
        </van-list>
@@ -99,7 +99,7 @@
                    <p><span>{{ $t('jy533') }}</span><a class="red">{{item.orderFee}}</a></p>
                    <p><span>{{ $t('jy17') }}</span><a class="red">{{item.orderTotalPrice}}</a></p>
               <p><span>{{ $t('jy153') }}</span><a class="red">{{item.orderSpread}}</a></p>
                    <p v-if="chicangidx == 1"><span>{{ $t('jy15') }}</span><a class="red">{{item.orderStayFee}}</a></p>
                    <!-- <p v-if="chicangidx == 1"><span>{{ $t('jy15') }}</span><a class="red">{{item.orderStayFee}}</a></p> -->
                </div>
            </div>
        </van-list>
@@ -137,7 +137,7 @@
                    <p><span>{{ $t('jy19') }}</span><a class="red">{{item.buyOrderPrice}}/{{ $t('jy96') }}</a></p>
               <p v-if="chicangidx == 1"><span>{{ $t('jy25') }}</span><a class="red">{{item.sellOrderPrice}}/{{ $t('jy96') }}</a></p>
                    <p><span>{{ $t('jy18') }}</span><a class="red">{{item.orderNum}}</a></p>
                    <p><span>挂单时间</span><a class="red">{{ item.buyOrderTime | gettime }}</a></p>
                    <p><span>{{ $t('jy521') }}</span><a class="red">{{ item.buyOrderTime | gettime }}</a></p>
                    <p><span>{{ $t('jy17') }}</span><a class="red">{{item.orderTotalPrice}}</a></p>
               <!-- <p><span>{{ $t('jy153') }}</span><a class="red">{{item.orderSpread}}</a></p> -->
                    <p v-if="chicangidx == 1"><span>{{ $t('jy15') }}</span><a class="red">{{item.orderStayFee}}</a></p>
@@ -170,7 +170,7 @@
                    name: this.$t('jy410')
                },
                {
                    name: '我的委托'
                    name: this.$t('jy520')
                }
            ],
            chicangidx: 0,
@@ -206,19 +206,22 @@
    methods: {
        // 计算滑动指示器的位置
        getIndicatorLeft() {
            const totalWidth = 5.34 // .sert 的总宽度(rem)
            const tabCount = this.chicangList.length
            const indicatorWidth = 0.53 // 指示器宽度(rem)
            
            // 计算每个标签的中心位置
            const tabWidth = totalWidth / tabCount
            const centerPosition = (this.chicangidx + 0.7) * tabWidth
            // 每个标签占的百分比
            const tabWidthPercent = 100 / tabCount
            
            // 减去指示器宽度的一半,使其居中
            return centerPosition - indicatorWidth / 2
            // 当前选中标签的中心位置(百分比)
            const centerPositionPercent = (this.chicangidx + 0.5) * tabWidthPercent
            // 返回百分比,指示器会自动居中
            return centerPositionPercent + '%'
        },
        goDetail(item) {
            this.$router.push(`/WarehouseDetail?positionSn=${item.positionSn}`)
            // 根据当前的tab索引传递不同的类型值
            // chicangidx: 0-持仓, 1-平仓, 2-委托
            const type = this.chicangidx === 1 ? 'pingcang' : this.chicangidx === 2 ? 'weituo' : 'chicang';
            this.$router.push(`/WarehouseDetail?positionSn=${item.positionSn}&type=${type}`)
        },
        onLoad() {
      //持仓
@@ -308,20 +311,20 @@
       // 如果 chicangidx 为 0,表示是沪深京市场(可能是股票市场的不同板块)
       if (this.chicangidx == 0) {
           // 先弹出一个选择平仓数量的输入框
           this.$prompt('平仓数量', '部分平仓', {
           this.$prompt(this.$t('jy522'), this.$t('jy523'), {
               confirmButtonText: this.$t('hj161'),
               cancelButtonText: this.$t('hj106'),
               inputPattern: /^[0-9]*[1-9][0-9]*$/, // 限制输入为正整数
               inputErrorMessage: '格式错误' // 输入不合法时的错误提示
               inputErrorMessage: this.$t('jy524') // 输入不合法时的错误提示
           }).then(async ({ value }) => {
               const selectedQuantity = Number(value);  // 用户选择的平仓数量
               
               if (selectedQuantity <= 0) {
                   Toast('格式错误');  // 如果输入无效数量,提示错误
                   Toast(this.$t('jy524'));  // 如果输入无效数量,提示错误
                   return;
               }
            if(selectedQuantity > orderNum){
               Toast('超过最大数量'+orderNum);  // 如果输入无效数量,提示错误
               Toast(this.$t('jy525') + orderNum);  // 如果输入无效数量,提示错误
               return;
            }
               // 弹出确认框,询问用户是否确认平仓
@@ -580,14 +583,17 @@
    border-radius: 0.4rem 0.4rem 0 0;
    margin-top: -0.4rem;
    background: #fff;
    padding: 0 0.4rem;
    box-sizing: border-box;
    .sert {
        width: 5.34rem;
        width: 100%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        position: relative;
        height: 1.07rem;
        box-sizing: border-box;
        span {
            text-align: center;
@@ -595,6 +601,11 @@
            font-size: .4rem;
            font-weight: 550;
            line-height: 1.07rem;
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0;
        }
        .sdpl {
@@ -608,7 +619,7 @@
            border-radius: 0.05rem;
            position: absolute;
            bottom: 0;
            margin-left: -0.266rem;
            transform: translateX(-50%);
            transition: all .5s;
        }
    }