1
PC-20250623MANY\Administrator
2025-09-25 a96f8fe6fcdb95d1ab77187afb0b98cfa2ea0515
src/views/home/components/HomeLb.vue
@@ -8,31 +8,18 @@
    </div>
    <div class="order_list" v-if="activeName == '0'">
      <el-table
        height="100%"
        :data="tableData"
        style="width: 100%"
        size="small"
        empty-text="No Data"
        @row-click="Choice"
      >
      <el-table height="100%" :data="tableData" style="width: 100%" size="small" empty-text="No Data"
        @row-click="Choice">
        <el-table-column prop="stockSpell" :label="$t('hj313')">
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.stockGid != $mc ? 'success' : ''"
              size="small"
              style="margin-right: 8px"
            >
            <el-tag :type="scope.row.stockGid != $mc ? 'success' : ''" size="small" style="margin-right: 8px">
              {{ scope.row.stockGid }}
            </el-tag>
            <span>{{ scope.row.stockName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="positionType"
          :label="`${$t('hj313')} ${$t('類型')}`"
        >
        <el-table-column prop="positionType" :label="`${$t('hj313')} ${$t('類型')}`">
          <template slot-scope="scope">
            <el-tag type="warning">
              {{ dictionary.gplx[scope.row.positionType] }}
@@ -52,15 +39,12 @@
        <el-table-column prop="profitAndLoseParent" :label="$t('Profit')">
          <template slot-scope="scope">
            <span
              :class="`${
                scope.row.profitAndLose < 0
                  ? 'r_c'
                  : scope.row.profitAndLose > 0
                  ? 'lc_c'
                  : ''
              }`"
            >
            <span :class="`${scope.row.profitAndLose < 0
              ? 'r_c'
              : scope.row.profitAndLose > 0
                ? 'lc_c'
                : ''
              }`">
              {{ scope.row.profitAndLose }} ({{
                scope.row.profitAndLoseParent
              }})
@@ -99,14 +83,8 @@
    </div>
    <div class="order_list" v-else-if="activeName == '1'">
      <el-table
        :data="tableData"
        style="width: 100%"
        height="100%"
        size="small"
        empty-text="No Data"
        @row-click="Choice"
      >
      <el-table :data="tableData" style="width: 100%" height="100%" size="small" empty-text="No Data"
        @row-click="Choice">
        <el-table-column prop="stockCode" :label="$t('sc')" width="130">
        </el-table-column>
@@ -115,22 +93,14 @@
        <el-table-column prop="stockSpell" :label="$t('hj313')" min-width="150">
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.stockGid != $mc ? 'success' : ''"
              size="small"
              style="margin-right: 8px"
            >
            <el-tag :type="scope.row.stockGid != $mc ? 'success' : ''" size="small" style="margin-right: 8px">
              {{ scope.row.stockGid }}
            </el-tag>
            <span>{{ scope.row.stockName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="positionType"
          :label="`${$t('hj313')} ${$t('類型')}`"
          width="150"
        >
        <el-table-column prop="positionType" :label="`${$t('hj313')} ${$t('類型')}`" width="150">
          <template slot-scope="scope">
            <el-tag type="warning">
              {{ dictionary.gplx[scope.row.positionType] }}
@@ -139,27 +109,16 @@
          1
        </el-table-column>
        <el-table-column
          prop="orderNum"
          :label="$t('sl')"
          width="100"
        ></el-table-column>
        <el-table-column prop="orderNum" :label="$t('sl')" width="100"></el-table-column>
        <el-table-column
          prop="profitAndLoseParent"
          :label="$t('Profit')"
          width="130"
        >
        <el-table-column prop="profitAndLoseParent" :label="$t('Profit')" width="130">
          <template slot-scope="scope">
            <span
              :class="`${
                scope.row.profitAndLose < 0
                  ? 'r_c'
                  : scope.row.profitAndLose > 0
                  ? 'lc_c'
                  : ''
              }`"
            >
            <span :class="`${scope.row.profitAndLose < 0
              ? 'r_c'
              : scope.row.profitAndLose > 0
                ? 'lc_c'
                : ''
              }`">
              {{ scope.row.profitAndLose }} ({{
                scope.row.profitAndLoseParent
              }})
@@ -214,20 +173,15 @@
    </div>
    <div class="pagination_box">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :current-page="pageNum"
        :page-size="pageSize"
        @current-change="handleCurrentChange"
      >
      <el-pagination background layout="prev, pager, next" :total="total" :current-page="pageNum" :page-size="pageSize"
        @current-change="handleCurrentChange">
      </el-pagination>
    </div>
  </div>
</template>
<script>
let times = null; // 计时器
import mixins from "@/mixins/myMixins"; // 混入
import * as api from "@/axios/api";
export default {
@@ -243,17 +197,37 @@
    this.opt.state = this.activeName;
    this.apiInterface = api.getchicang;
    this.init();
    this.stopTimer()
    times = setInterval(() => {
      this.getList()
    }, 3000)
  },
  beforeDestroy() {
    this.stopTimer()
  },
  methods: {
    handleClick() {
      this.opt.state = this.activeName;
      this.tableData = [];
      this.init();
      this.stopTimer()
      if (this.activeName == 1) return // 如果是平仓则不轮询
      times = setInterval(() => {
        this.getList()
      }, 3000)
    },
    // 股票选择
    Choice(val) {
      this.$emit("choice", val.stockCode, val.positionSn);
      console.log("1");
    },
    stopTimer() {
      if (times) {
        clearInterval(times);
        times = null;
      }
    },
  },
};
@@ -266,6 +240,7 @@
    justify-content: flex-end;
    padding: 10px;
  }
  .order_list {
    height: 0;
    flex: 1;