jhzh
2024-05-15 c57f75664da5f522e6824023af7e5c8fbe8ed38b
src/page/user/Warehouse/data.list.vue
@@ -14,6 +14,7 @@
      v-model="loading"
      :finished="finished"
      :finished-text="$t('hj43')"
      :loading-text="$t('hj430')"
      @load="onLoad"
    >
      <div
@@ -21,31 +22,36 @@
        :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 class="title-box">
          <div class="span">{{ item.stockName }}</div>
          <div
            class="states"
            :class="item.orderDirection === '买跌' ? 'states-red' : ''"
          >
            {{ $t(item.orderDirection) }}
        <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>
          <van-col span="8">
            <div style="text-align: left">
              <div class="sport-content-title2">
                {{ $t("盈虧") }} ({{ item.stockGid }})
                {{ $t("盈虧") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text" style="color: #d04b64">
                {{ item.profitAndLose }}
              <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") }} ({{ item.stockGid }})
                {{ $t("hj141") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">
                {{ item.profitAndLoseParent }}
@@ -63,25 +69,31 @@
          <van-col span="8">
            <div style="text-align: left">
              <div class="sport-content-title2">
                {{ $t("hj40") }}({{ item.stockGid }})
                {{ $t("hj40") }}({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">{{ item.now_price }}</div>
              <div class="sport-content-text2">
                {{ item.now_price | _toLocaleString }}
              </div>
            </div>
          </van-col>
          <van-col span="8">
            <div style="text-align: center">
              <div class="sport-content-title2">
                {{ $t("持倉價") }} ({{ item.stockGid }})
                {{ $t("持倉價") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">{{ item.buyOrderPrice }}</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("訂單金額") }} ({{ item.stockGid }})
                {{ $t("訂單金額") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">{{ item.orderTotalPrice }}</div>
              <div class="sport-content-text2">
                {{ item.orderTotalPrice | _toLocaleString }}
              </div>
            </div>
          </van-col>
        </van-row>
@@ -89,38 +101,40 @@
          <van-col span="8">
            <div style="text-align: left">
              <div class="sport-content-title2">
                {{ $t("開倉手續費") }} ({{ item.stockGid }})
              </div>
              <div class="sport-content-text2">{{ item.orderFee }}</div>
            </div>
          </van-col>
          <van-col span="8">
            <div style="text-align: center">
              <div class="sport-content-title2">
                {{ $t("止損價") }} ({{ item.stockGid }})
                {{ $t("hj44") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">
                -{{ item.profitTargetPrice || "--" }}
                {{ item.orderFee | _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.stopTargetPrice | _toLocaleString }}
              </div>
            </div>
          </van-col>
          <van-col span="8">
            <div style="text-align: right">
              <div class="sport-content-title2">
                {{ $t("止盈價") }} ({{ item.stockGid }})
                {{ $t("止盈價") }} ({{ activeObj.symbolCode }})
              </div>
              <div class="sport-content-text2">
                -{{ item.stopTargetPrice || "--" }}
                {{ item.profitTargetPrice | _toLocaleString }}
              </div>
            </div>
          </van-col>
          </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">
                {{ $moment(item.buyOrderTime).format("YYYY-MM-DD HH:mm:ss") }}
                {{ $moment(item.buyOrderTime).format("DD-MM-YYYY hh:mm:ss A") }}
              </div>
            </div>
          </van-col>
@@ -132,8 +146,8 @@
          </van-col>
        </van-row>
        <div class="but-box" v-if="actives === 0">
          <div class="but" @click="close(item)">{{ $t("平仓") }}</div>
        <div class="but-box" v-if="actives === 0" @click.stop="close(item)">
          <div class="but">{{ $t("平仓") }}</div>
          <!-- <div class="but buts">止盈止损</div> -->
        </div>
      </div>
@@ -169,18 +183,21 @@
</template>
<script>
import Dialog from '@/components/Dialog'
import { getchicang, sell } from '../../../axios/api'
import { Notify } from 'vant'
import Dialog from "@/components/Dialog";
import { getchicang, sell } from "../../../axios/api";
import { Notify } from "vant";
export default {
  components: { Dialog },
  props: {
    activeObj: {
      type: Object,
      default: {}
    }
      default: {},
    },
  },
  data () {
  mounted() {
    this.getList();
  },
  data() {
    return {
      pageNum: 1,
      pageSize: 150,
@@ -190,78 +207,109 @@
      show: false,
      actives: 0,
      dataList: [],
      timer: null,
      tabsList: [
        {
          title: this.$t('持倉'),
          key: 0
          title: this.$t("持倉"),
          key: 0,
        },
        {
          title: this.$t('平倉'),
          key: 1
        }
      ]
    }
          title: this.$t("平倉"),
          key: 1,
        },
      ],
    };
  },
  created(){
    this.timer = setInterval(() => {
      this.getList();
    }, 1000);
  },
  beforeDestroy() {
    clearInterval(this.timer); // 在组件销毁前清除定时器
  },
  methods: {
    onLoad () {
      this.pageNum++
      this.loading = true
    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,
        },
      });
    },
    async confirm () {
    onLoad() {
      // this.pageNum++;
      this.loading = true;
    },
    async confirm() {
      const res = await sell({
        positionSn: this.closeSell.positionSn
      })
        positionSn: this.closeSell.positionSn,
      });
      if (res.status === 0) {
        this.$refs.closeDialog.show = false
        this.dataList = []
        this.pageNum = 1
        this.finished = false
        this.getList()
        this.$emit('closingPosition')
        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 })
        Notify({ type: "danger", message: res.msg });
      }
    },
    // 获取仓位列表
    async getList (laber) {
    async getList(laber) {
      if (laber) {
        this.dataList = []
        this.pageNum = 1
        this.finished = false
        this.dataList = [];
        this.pageNum = 1;
        this.finished = false;
      }
      const res = await getchicang({
        state: this.actives,
        stockType: laber || this.activeObj.laber,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      })
        pageNum: 1,
        pageSize: 100,
      });
      this.loading = false
      this.loading = false;
      if (res.status === 0) {
        this.dataList = res.data.list
        if (res.data.total <= this.dataList.length) {
          this.finished = true
        }
        this.dataList = res.data.list;
        this.$forceUpdate(); // 强制Vue重新渲染
        // if (res.data.total <= this.dataList.length) {
        this.finished = true;
        //   }
      } else {
        this.loading = false
        this.finished = true
        this.loading = false;
        this.finished = true;
      }
    },
    close (item) {
      this.closeSell = item
      this.$refs.closeDialog.show = true
    close(item) {
      this.closeSell = item;
      this.$refs.closeDialog.show = true;
    },
    clickTabs (e) {
      this.dataList = []
      this.pageNum = 1
      this.finished = false
      this.actives = e.key
      this.getList()
    }
  }
}
    clickTabs(e) {
      this.dataList = [];
      this.pageNum = 1;
      this.finished = false;
      this.actives = e.key;
      this.getList();
    },
  },
};
</script>
<style lang="less" scoped>