<template>
|
<div>
|
<ul class="sport-tabs">
|
<li :class="actives === item.key && 'active'" v-for="item in tabsList" :key="item.key" @click="clickTabs(item)">
|
{{ item.title }}
|
</li>
|
</ul>
|
<van-list v-model="loading" :finished="finished" :finished-text="$t('hj43')" :loading-text="$t('hj430')"
|
@load="onLoad">
|
<div class="sport-content-li" :style="actives === 1 ? 'height:5.52rem' : 'height:7.52rem'"
|
v-for="(item, index) in dataList" :key="index" @click="$router.push(`/Stockdetail?codes=${item.positionSn}`)">
|
<div @click.stop="pushRouter(item)">
|
<div class="title-box">
|
<div class="span">{{ item.stockName }}</div>
|
<div class="states" :class="item.orderDirection === '买跌' ? 'states-red' : ''">
|
{{ $t(item.orderDirection) }}
|
</div>
|
</div>
|
{{ item.stockSpell }}
|
</div>
|
<!-- <div @click="$router.push('/Stockdetail')"></div> -->
|
<van-row v-if="actives != 2">
|
<van-col span="8">
|
<div style="text-align: left">
|
<div class="sport-content-title2">
|
{{ $t("盈虧") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text">
|
{{ item.profitAndLose | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8">
|
<div style="text-align: center">
|
<div class="sport-content-title2">
|
{{ $t("hj141") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.profitAndLoseParent }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8">
|
<div style="text-align: right">
|
<div class="sport-content-title2">{{ $t("倉位(股)") }}</div>
|
<div class="sport-content-text">{{ item.orderNum }}</div>
|
</div>
|
</van-col>
|
</van-row>
|
<van-row>
|
<van-col span="8">
|
<div style="text-align: left">
|
<div class="sport-content-title2">
|
{{ $t("hj40") }}({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.nowPrice | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8">
|
<div style="text-align: center">
|
<div class="sport-content-title2">
|
{{ $t("持倉價") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.buyOrderPrice | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8">
|
<div style="text-align: right">
|
<div class="sport-content-title2">
|
{{ $t("訂單金額") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.targetPrice | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
</van-row>
|
<van-row>
|
<van-col span="8">
|
<div style="text-align: left">
|
<div class="sport-content-title2">
|
{{ $t("hj44") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.orderFee | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8" style="height: 100%;display: flex;align-items: center;justify-content: center;">
|
<div v-if="actives == 2">
|
<van-button type="primary" @click.stop="cancelPending(item.id)"> {{ $t("撤销挂单")
|
}}</van-button>
|
</div>
|
</van-col>
|
<!-- <van-col span="8">
|
<div style="text-align: center">
|
<div class="sport-content-title2">
|
{{ $t("止損價") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.stopTargetPrice | _toLocaleString }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="8">
|
<div style="text-align: right">
|
<div class="sport-content-title2">
|
{{ $t("止盈價") }} ({{ activeObj.symbolCode }})
|
</div>
|
<div class="sport-content-text2">
|
{{ item.profitTargetPrice | _toLocaleString }}
|
</div>
|
</div>
|
</van-col> -->
|
</van-row>
|
<van-row>
|
<van-col span="12">
|
<div style="text-align: left">
|
<div class="sport-content-title2">{{ $t("持倉時間") }}</div>
|
<div class="sport-content-text2" v-if="actives != 2">
|
{{ $moment(item.buyOrderTime).format("DD-MM-YYYY hh:mm:ss A") }}
|
</div>
|
<div class="sport-content-text2" v-else>
|
{{ $moment(item.addTime).format("DD-MM-YYYY hh:mm:ss A") }}
|
</div>
|
</div>
|
</van-col>
|
<van-col span="12">
|
<div style="text-align: right">
|
<div class="sport-content-title2">{{ $t("訂單編號") }}</div>
|
<div class="sport-content-text2">{{ item.buyOrderId }}</div>
|
</div>
|
</van-col>
|
</van-row>
|
|
<div class="but-box" v-if="actives === 0" @click.stop="close(item)">
|
<div class="but">{{ $t("平仓") }}</div>
|
<!-- <div class="but buts">止盈止损</div> -->
|
</div>
|
</div>
|
</van-list>
|
|
<!-- <van-popup v-model="show" position="top" :style="{ height: '30%' }" /> -->
|
|
<Dialog ref="closeDialog" :title="$t('确认平仓')" :confirm="confirm">
|
<template v-slot:center>
|
<div>
|
<div class="hang">
|
<div class="left">{{ $t("hj39") }}</div>
|
<div class="right">{{ closeSell.stockName }}</div>
|
</div>
|
<div class="hang">
|
<div class="left">{{ $t("買漲/買跌") }}</div>
|
<div class="right">{{ $t(closeSell.orderDirection) }}</div>
|
</div>
|
<div class="hang">
|
<div class="left">{{ $t("倉位(股)") }}</div>
|
<input class="right" inputmode="numeric" style="width: 1rem;border: 1px solid #000;color: rgb(3, 173, 143);width: 1.1rem;" v-model.number="closeNumber" @input="handleInput">
|
<!-- <div class="right" style="color: rgb(3, 173, 143)">
|
{{ closeSell.orderNum }}
|
</div> -->
|
</div>
|
<div class="hang">
|
<div class="left">{{ $t("類型") }}</div>
|
<div class="right">{{ $t("市價") }}</div>
|
</div>
|
</div>
|
</template>
|
</Dialog>
|
<Dialog ref="closeOrder" :title="$t('撤销挂单')" :confirm="cancelPendingOrder">
|
</Dialog>
|
</div>
|
</template>
|
|
<script>
|
import Dialog from "@/components/Dialog";
|
import { getchicang, sell, getorderList, delGuaDan } from "../../../axios/api";
|
import { Notify } from "vant";
|
export default {
|
components: { Dialog },
|
props: {
|
activeObj: {
|
type: Object,
|
default: {},
|
},
|
},
|
mounted() {
|
this.getList();
|
},
|
data() {
|
return {
|
pageNum: 1,
|
pageSize: 150,
|
loading: true,
|
finished: false,
|
closeSell: {
|
orderNum: 0
|
},
|
show: false,
|
actives: 0,
|
dataList: [],
|
timer: null,
|
tabsList: [
|
{
|
title: this.$t("持倉"),
|
key: 0,
|
},
|
{
|
title: this.$t("平倉"),
|
key: 1,
|
},
|
{
|
title: this.$t('当前委托'),
|
key: 2,
|
}
|
],
|
id: '',
|
closeNumber: ''
|
};
|
},
|
created() {
|
this.timer = setInterval(() => {
|
this.getList();
|
}, 1000);
|
},
|
beforeDestroy() {
|
clearInterval(this.timer); // 在组件销毁前清除定时器
|
},
|
methods: {
|
handleInput(){
|
if (this.closeNumber > this.closeSell.orderNum) {
|
this.closeNumber = this.closeSell.orderNum; // 如果超过100则设置为100
|
} else if (this.closeNumber < 1) {
|
this.closeNumber = 1; // 如果小于0则设置为0,如果不需要小于0,可以删除这个部分
|
}
|
},
|
pushRouter(item) {
|
const obj = {
|
pid: item.stockCode || "",
|
type: item.stockGid || "",
|
};
|
window.localStorage.setItem("kLine", JSON.stringify(obj));
|
// return;
|
var codes = item.stockCode;
|
var names = item.stockName;
|
|
this.$router.push({
|
path: "/kline",
|
query: {
|
name: names,
|
code: codes,
|
if_us: "",
|
if_zhishu: 0,
|
sok: "",
|
type: item.stockGid,
|
},
|
});
|
},
|
onLoad() {
|
// this.pageNum++;
|
this.loading = true;
|
},
|
async confirm() {
|
const res = await sell({
|
positionSn: this.closeSell.positionSn,
|
closeNumber: this.closeNumber
|
});
|
if (res.status === 0) {
|
this.$refs.closeDialog.show = false;
|
this.dataList = [];
|
this.pageNum = 1;
|
this.finished = false;
|
this.getList();
|
this.$emit("closingPosition");
|
} else {
|
Notify({ type: "danger", message: res.msg });
|
}
|
},
|
// 获取仓位列表
|
async getList(laber) {
|
if (laber) {
|
this.dataList = [];
|
this.pageNum = 1;
|
this.finished = false;
|
}
|
let res;
|
if (this.actives == 0 || this.actives == 1) {
|
res = await getchicang({
|
state: this.actives,
|
stockType: laber || this.activeObj.laber,
|
pageNum: 1,
|
pageSize: 100,
|
});
|
} else {
|
res = await getorderList({
|
stockType: laber || this.activeObj.laber,
|
pageNum: 1,
|
pageSize: 100,
|
});
|
}
|
this.loading = false;
|
if (res.status === 0) {
|
if (res.data.list) {
|
this.dataList = res.data.list;
|
} else {
|
this.dataList = res.data;
|
}
|
this.$forceUpdate(); // 强制Vue重新渲染
|
// if (res.data.total <= this.dataList.length) {
|
this.finished = true;
|
// }
|
} else {
|
this.loading = false;
|
this.finished = true;
|
}
|
},
|
close(item) {
|
this.closeSell = item;
|
this.$refs.closeDialog.show = true;
|
// this.closeNumber = this.closeSell.orderNum;
|
},
|
clickTabs(e) {
|
this.dataList = [];
|
this.pageNum = 1;
|
this.finished = false;
|
this.actives = e.key;
|
this.getList();
|
},
|
cancelPending(id){
|
this.id = id
|
this.$refs.closeOrder.show = true
|
},
|
async cancelPendingOrder() {
|
const res = await delGuaDan({
|
id : this.id
|
});
|
if (res.status === 1) {
|
this.$refs.closeOrder.show = false
|
Notify({ type: "success", message: res.msg });
|
this.dataList = [];
|
this.pageNum = 1;
|
this.finished = false;
|
this.getList();
|
} else {
|
Notify({ type: "danger", message: res.msg });
|
}
|
}
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
.sport-tabs {
|
// font-family: PingFang SC;
|
font-family: "DINPro";
|
width: 100%;
|
height: 0.90667rem;
|
margin-top: 0.42667rem;
|
display: flex;
|
align-items: center;
|
box-sizing: border-box;
|
justify-content: space-around;
|
border-bottom: 0.16rem solid #f7f7fa;
|
position: sticky;
|
top: 0;
|
z-index: 99;
|
background-color: #fff;
|
|
li {
|
height: 0.90667rem;
|
line-height: 0.90667rem;
|
font-style: normal;
|
font-weight: 400;
|
font-size: 0.37333rem;
|
text-align: center;
|
color: #14181f;
|
box-sizing: border-box;
|
}
|
|
.active {
|
color: #0066ed;
|
border-bottom: 0.08rem solid #0066ed;
|
}
|
}
|
|
.sport-content-li {
|
width: 100%;
|
height: 7.52rem;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
padding: 0.26667rem 0.37333rem;
|
border-bottom: 0.02667rem solid #f0f2f3;
|
box-sizing: border-box;
|
}
|
|
.title-box {
|
display: flex;
|
font-style: normal;
|
font-weight: 500;
|
font-size: 0.37333rem;
|
color: #14181f;
|
display: flex;
|
align-items: center;
|
|
.span {}
|
|
.states {
|
display: inline-flex;
|
justify-content: center;
|
padding: 0.05333rem 0.16rem;
|
align-items: center;
|
align-content: flex-start;
|
font-size: 0.26667rem;
|
height: 0.48rem;
|
margin-left: 0.10667rem;
|
line-height: 0.26667rem;
|
text-align: center;
|
color: #03ad8f;
|
border-radius: 0.05333rem;
|
background: rgba(3, 173, 143, 0.15);
|
flex-shrink: 0;
|
font-weight: 900;
|
}
|
|
.states-red {
|
background: rgba(208, 75, 100, 0.15);
|
color: rgb(208, 75, 100);
|
}
|
}
|
|
.sport-content-title2 {
|
font-style: normal;
|
font-weight: 400;
|
font-size: 0.29333rem;
|
color: #8c9fad;
|
// text-align: left;
|
}
|
|
.sport-content-text {
|
margin-top: 5px;
|
font-style: normal;
|
// font-weight: 500;
|
font-size: 0.48rem;
|
color: #14181f;
|
// font-family: "PingFang SC";
|
// line-height: 18px;
|
// text-align: right;
|
}
|
|
.sport-content-text2 {
|
margin-top: 5px;
|
// font-family: "PingFang SC";
|
font-style: normal;
|
// font-weight: 500;
|
font-size: 0.34667rem;
|
color: #14181f;
|
word-break: break-word;
|
// line-height: 18px;
|
}
|
|
.but-box {
|
display: flex;
|
justify-content: space-around;
|
|
.but {
|
text-align: center;
|
|
min-width: 2.13333rem;
|
height: 0.69333rem;
|
line-height: 0.69333rem;
|
background: #e6f2ff;
|
border-radius: 0.10667rem;
|
list-style: none;
|
font-style: normal;
|
font-weight: 400;
|
font-size: 0.29333rem;
|
color: #0067ed;
|
border: none;
|
}
|
|
.buts {
|
min-width: 2.13333rem;
|
height: 0.69333rem;
|
line-height: 0.69333rem;
|
background: #fff;
|
border-radius: 0.10667rem;
|
list-style: none;
|
font-style: normal;
|
font-weight: 400;
|
font-size: 0.29333rem;
|
border: 0.01333rem solid #e4eaed;
|
color: #14181f;
|
}
|
}
|
|
.hang {
|
display: flex;
|
justify-content: space-between;
|
|
.left {
|
font-style: normal;
|
font-weight: 500;
|
font-size: 0.34667rem;
|
color: #8c9fad;
|
}
|
|
.right {
|
font-style: normal;
|
font-weight: 500;
|
font-size: 0.34667rem;
|
color: #14181f;
|
text-align: right;
|
}
|
}
|
</style>
|