1
jhzh
2025-07-06 c24f01e317c68e8d490af53210cee83d46297e20
src/views/position/components/futures-flat.vue
@@ -19,8 +19,7 @@
                  v-model="queryParam.agentId"
                  placeholder="请选择下级代理"
                  @focus="getagentlist"
                  :loading="agentloading"
                >
                  :loading="agentloading">
                  <a-select-option v-for="(item, index) in agentlist" :key="index" :value="item.id">
                    {{ item.agentName }}
                  </a-select-option>
@@ -46,22 +45,22 @@
                  v-model="times"
                  style="width: 100%"
                  @change="onChangeRangeDate"
                  format="YYYY-MM-DD HH:mm:ss"
                >
                  format="YYYY-MM-DD HH:mm:ss">
                </a-range-picker>
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item>
                <span class="table-page-search-submitButtons">
                  <a-button @click="getqueryParam" icon="redo"> 重置</a-button>
                  <a-button @click="getqueryParam" icon="redo">
                    重置</a-button>
                  <a-button
                    type="primary"
                    icon="search"
                    style="margin-left: 8px"
                    @click=";(queryParam.pageNum = 1), getlist()"
                    >查询
                    @click="queryParam.pageNum = 1, getlist()">查询
                  </a-button>
                </span>
              </a-form-item>
            </a-col>
@@ -76,8 +75,8 @@
      :columns="columns"
      :data-source="datalist"
      rowKey="id"
      :scroll="{ x: 2800 }"
    >
      :scroll="{ x: 2800 }">
      <span slot="positionType" slot-scope="text, record">
        <template>
          <div>
@@ -99,7 +98,9 @@
      <span slot="profitAndLose" slot-scope="text, record">
        <template>
          <div>
            <p :class="text < 0 ? 'greens' : text > 0 ? 'reds' : ''">{{ text }}{{ record.coinCode }}</p>
            <p :class="text < 0 ? 'greens' : text > 0 ? 'reds' : ''">
              {{ text }}{{ record.coinCode }}
            </p>
            <P>≈{{ (record.profitAndLose * record.coinRate).toFixed(2) }} CNY</P>
          </div>
        </template>
@@ -107,7 +108,9 @@
      <span slot="allProfitAndLose" slot-scope="text, record">
        <template>
          <div>
            <p :class="text < 0 ? 'greens' : text > 0 ? 'reds' : ''">{{ text }}{{ record.coinCode }}</p>
            <p :class="text < 0 ? 'greens' : text > 0 ? 'reds' : ''">
              {{ text }}{{ record.coinCode }}
            </p>
            <P>≈{{ (record.allProfitAndLose * record.coinRate).toFixed(2) }} CNY</P>
          </div>
        </template>
@@ -115,8 +118,6 @@
      <template slot="action" slot-scope="text, record">
        <a slot="action" href="javascript:;" @click="getFuturesdetails(record)">查看详情</a>
        <a-divider type="vertical" />
        <a slot="action" href="javascript:;" @click="getDelflat(record.id)">删除</a>
      </template>
    </a-table>
    <a-modal title="期货详情" :width="1200" :visible="futuresDialog" :footer="false" @cancel="futuresDialog = false">
@@ -136,26 +137,22 @@
        </a-descriptions-item>
        <a-descriptions-item label="浮动盈亏">
          <span :class="clickitem.profitAndLose > 0 ? 'reds' : clickitem.profitAndLose < 0 ? 'greens' : ''">
            {{ clickitem.profitAndLose }}{{ clickitem.coinCode }} ≈
            {{ (clickitem.profitAndLose * clickitem.coinRate).toFixed(2) }} CNY
            {{ clickitem.profitAndLose }}{{ clickitem.coinCode }} ≈ {{ (clickitem.profitAndLose *
              clickitem.coinRate).toFixed(2)
            }} CNY
          </span>
        </a-descriptions-item>
        <a-descriptions-item label="总盈亏">
          <span :class="clickitem.allProfitAndLose > 0 ? 'reds' : clickitem.allProfitAndLose < 0 ? 'greens' : ''">
            {{ clickitem.allProfitAndLose }}{{ clickitem.coinCode }} ≈
            {{ (clickitem.allProfitAndLose * clickitem.coinRate).toFixed(2) }} CNY
          <span
            :class="clickitem.allProfitAndLose > 0 ? 'reds' : clickitem.allProfitAndLose < 0 ? 'greens' : ''">
            {{ clickitem.allProfitAndLose }}{{ clickitem.coinCode }} ≈ {{ (clickitem.allProfitAndLose *
              clickitem.coinRate).toFixed(2)
            }} CNY
          </span>
        </a-descriptions-item>
        <a-descriptions-item label="当前价格" v-if="clickitem.now_price">
          <span
            :class="
              clickitem.now_price - clickitem.buyOrderPrice > 0
                ? 'reds'
                : clickitem.now_price - clickitem.buyOrderPrice < 0
                ? 'greens'
                : ''
            "
          >
            :class="clickitem.now_price - clickitem.buyOrderPrice > 0 ? 'reds' : clickitem.now_price - clickitem.buyOrderPrice < 0 ? 'greens' : ''">
            {{ clickitem.now_price }}
          </span>
        </a-descriptions-item>
@@ -191,12 +188,15 @@
        </a-descriptions-item>
        <a-descriptions-item label="手续费">
          <span>
            {{ clickitem.orderFee }}{{ clickitem.coinCode }} ≈
            {{ (clickitem.orderFee * clickitem.coinRate).toFixed(2) }} CNY
            {{ clickitem.orderFee }}{{ clickitem.coinCode }} ≈ {{ (clickitem.orderFee *
              clickitem.coinRate).toFixed(2)
            }} CNY
          </span>
        </a-descriptions-item>
        <a-descriptions-item label="当前汇率">
          <span> 1 {{ clickitem.coinCode }} ≈ {{ clickitem.coinRate }} CNY </span>
          <span>
            1 {{ clickitem.coinCode }} ≈ {{ clickitem.coinRate }} CNY
          </span>
        </a-descriptions-item>
        <a-descriptions-item label="买入时间">
          <span>
@@ -219,8 +219,8 @@
  </div>
</template>
<script>
import { futurespositionlist, futurespositiondel } from '@/api/position'
import { nextagent } from '@/api/home'
import { futurespositionlist } from '@/api/position'
import { agentgetSecondAgent } from '@/api/home'
import moment from 'moment'
export default {
  name: 'Setting',
@@ -234,13 +234,13 @@
          width: 180,
          customRender: (text, row, index) => {
            return `${row.futuresName}(${row.futuresCode})`
          },
                    }
        },
        {
          title: '账户类型',
          dataIndex: 'positionType',
          align: 'center',
          scopedSlots: { customRender: 'positionType' },
                    scopedSlots: { customRender: 'positionType' }
        },
        {
          title: '用户名称(ID)',
@@ -248,7 +248,8 @@
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.realName}(${row.userId})`
          },
                    }
        },
        {
          title: '持仓订单号(ID)',
@@ -256,13 +257,14 @@
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.positionSn}(${row.id})`
          },
                    }
        },
        {
          title: '买卖方向',
          dataIndex: 'orderDirection',
          align: 'center',
          scopedSlots: { customRender: 'orderDirection' },
                    scopedSlots: { customRender: 'orderDirection' }
        },
        {
          title: '买入点数',
@@ -270,34 +272,34 @@
          align: 'center',
          customRender: (text, row, index) => {
            return text.toFixed(2)
          },
                    }
        },
        {
          title: '卖出点数',
          dataIndex: 'sellOrderPrice',
          align: 'center',
                    align: 'center'
        },
        {
          title: '保证金(CNY)',
          dataIndex: 'allDepositAmt',
          align: 'center',
                    align: 'center'
        },
        {
          title: '浮动盈亏',
          dataIndex: 'profitAndLose',
          align: 'center',
          scopedSlots: { customRender: 'profitAndLose' },
                    scopedSlots: { customRender: 'profitAndLose' }
        },
        {
          title: '总盈亏',
          dataIndex: 'allProfitAndLose',
          align: 'center',
          scopedSlots: { customRender: 'allProfitAndLose' },
                    scopedSlots: { customRender: 'allProfitAndLose' }
        },
        {
          title: '数量(手)',
          dataIndex: 'orderNum',
          align: 'center',
                    align: 'center'
        },
        {
          title: '每标准手',
@@ -305,7 +307,7 @@
          align: 'center',
          customRender: (text, row, index) => {
            return row.futuresStandard + row.futuresUnit
          },
                    }
        },
        {
          title: '手续费',
@@ -313,7 +315,7 @@
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.orderFee} ${row.coinCode} ≈ ${(row.orderFee * row.coinRate).toFixed(2)} CNY`
          },
                    }
        },
        {
          title: '当前汇率',
@@ -321,12 +323,12 @@
          align: 'center',
          customRender: (text, row, index) => {
            return `1${row.coinCode} ≈ ${row.coinRate}CNY`
          },
                    }
        },
        {
          title: '锁定原因',
          dataIndex: 'lockMsg',
          align: 'center',
                    align: 'center'
        },
        {
          title: '买入时间',
@@ -335,7 +337,7 @@
          width: 180,
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          },
                    }
        },
        {
          title: '卖出时间',
@@ -344,7 +346,7 @@
          width: 180,
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          },
                    }
        },
        {
          title: '操作',
@@ -352,8 +354,8 @@
          align: 'center',
          fixed: 'right',
          width: 150,
          scopedSlots: { customRender: 'action' },
        },
                    scopedSlots: { customRender: 'action' }
                }
      ],
      // 表头
      pagination: {
@@ -363,7 +365,7 @@
        pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
        onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
        onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
        showTotal: (total) => `共有 ${total} 条数据`, // 分页中显示总的数据
                showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
      },
      loading: false,
      queryParam: {
@@ -375,7 +377,7 @@
        positionSn: '',
        state: 1,
        beginTime: '',
        endTime: '',
                endTime: ''
      },
      datalist: [],
      agentlist: [],
@@ -385,38 +387,16 @@
      clickitem: {},
      agentqueryParam: {
        pageNum: 1,
        pageSize: 100,
      },
                pageSize: 100
            }
    }
  },
  created() {},
    created () {
    },
  methods: {
    getFuturesdetails(item) {
      this.clickitem = item
      this.futuresDialog = true
    },
    getDelflat(val) {
      var that = this
      this.$confirm({
        title: '提示',
        content: '确认删除平仓单吗?此操作不可恢复',
        onOk() {
          var data = {
            positionId: val,
          }
          futurespositiondel(data).then((res) => {
            if (res.status == 0) {
              that.$message.success(res.msg)
              that.getlist()
            } else {
              that.$message.error(res.msg)
            }
          })
        },
        onCancel() {
          console.log('Cancel')
        },
      })
    },
    getinit() {
      this.queryParam = {
@@ -428,7 +408,7 @@
        positionSn: '',
        state: 1,
        beginTime: '',
        endTime: '',
                endTime: ''
      }
      this.times = []
      this.getlist()
@@ -443,7 +423,7 @@
        positionSn: '',
        state: 1,
        beginTime: '',
        endTime: '',
                endTime: ''
      }
      this.times = []
    },
@@ -454,7 +434,7 @@
    getagentlist() {
      var that = this
      this.agentloading = true
      nextagent(this.agentqueryParam).then((res) => {
            agentgetSecondAgent(this.agentqueryParam).then(res => {
        this.agentlist = res.data.list
        setTimeout(() => {
          that.agentloading = false
@@ -463,7 +443,7 @@
    },
    getlist() {
      this.loading = true
      futurespositionlist(this.queryParam).then((res) => {
            futurespositionlist(this.queryParam).then(res => {
        this.datalist = res.data.list
        this.pagination.total = res.data.total
        this.loading = false
@@ -477,8 +457,8 @@
      this.queryParam.pageNum = current
      this.queryParam.pageSize = pageSize
      this.getlist()
    },
  },
        }
    }
}
</script>
<style scoped>