大宝管理后台代码
1
jhzh
2025-02-18 af103fd11d883fad506ee52945053f3e0f1cd5a8
src/views/position/components/financing-hold.vue
@@ -3,7 +3,7 @@
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
          <!-- <a-row :gutter="48">
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item label="持仓类型">
                <a-select v-model="queryParam.positionType" placeholder="请选择持仓类型">
@@ -12,14 +12,15 @@
                  <a-select-option :value="1">模拟持仓</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            </a-col> -->
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item label="下级代理">
                <a-select
                  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>
@@ -32,6 +33,11 @@
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item label="手机号">
                <a-input v-model="queryParam.phone" style="width: 100%" placeholder="请输入手机号" />
              </a-form-item>
            </a-col>
            <a-col :md="12" :lg="6" :sm="24">
              <a-form-item label="持仓订单号">
                <a-input v-model="queryParam.positionSn" style="width: 100%" placeholder="请输入持仓订单号" />
              </a-form-item>
@@ -41,15 +47,14 @@
            <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>
@@ -64,21 +69,30 @@
      :columns="columns"
      :data-source="datalist"
      rowKey="id"
      :scroll="{ x: 2800 }">
      <span slot="stockName" slot-scope="text,record">
      :scroll="{ x: 2800 }"
    >
      <span slot="stockName" slot-scope="text, record">
        <template>
          <div>
            <span style="margin-right:10px">{{ record.stockName }}</span>
            <span style="margin-right: 10px">{{ record.stockName }}</span>
            <a-tag
              :color="record.stockPlate == '科创' ? 'blue' : !record.stockPlate ? 'orange' : record.stockPlate == '创业' ? 'pink' : 'purple'">
              :color="
                record.stockPlate == '科创'
                  ? 'blue'
                  : !record.stockPlate
                  ? 'orange'
                  : record.stockPlate == '创业'
                  ? 'pink'
                  : 'purple'
              "
            >
              {{ record.stockPlate == '科创' ? '科创' : !record.stockPlate ? '股票' : record.stockPlate }}
            </a-tag>
            <p>({{ record.stockCode }})</p>
          </div>
        </template>
      </span>
      <span slot="positionType" slot-scope="text,record">
      <!-- <span slot="positionType" slot-scope="text, record">
        <template>
          <div>
            <a-tag :color="record.positionType == 1 ? 'blue' : 'green'">
@@ -86,8 +100,8 @@
            </a-tag>
          </div>
        </template>
      </span>
      <span slot="orderDirection" slot-scope="text,record">
      </span> -->
      <span slot="orderDirection" slot-scope="text, record">
        <template>
          <div>
            <a-tag :color="record.orderDirection == '买涨' ? 'red' : 'green'">
@@ -96,11 +110,18 @@
          </div>
        </template>
      </span>
      <span slot="now_price" slot-scope="text,record">
      <span slot="now_price" slot-scope="text, record">
        <template>
          <div>
            <p
              :class="Number(record.now_price) - record.buyOrderPrice < 0 ? 'greens' : Number(record.now_price) - record.buyOrderPrice > 0 ? 'reds' : ''">
              :class="
                Number(record.now_price) - record.buyOrderPrice < 0
                  ? 'greens'
                  : Number(record.now_price) - record.buyOrderPrice > 0
                  ? 'reds'
                  : ''
              "
            >
              {{ record.now_price }}
            </p>
          </div>
@@ -125,15 +146,22 @@
        </template>
      </span>
      <template slot="action" slot-scope="text,record">
      <template slot="action" slot-scope="text, record">
        <a
          slot="action"
          href="javascript:;"
          @click="Lockvisibledialog = true; clickpositionId = record.id"
          v-if="record.isLock == 0">锁仓</a>
          @click="
            Lockvisibledialog = true
            clickpositionId = record.id
          "
          v-if="record.isLock == 0"
          >锁仓</a
        >
        <a slot="action" href="javascript:;" @click="getLockopen(record.id)" v-else>解锁</a>
        <a-divider type="vertical" />
        <a slot="action" href="javascript:;" @click="getCompulsoryclosing(record.positionSn)">强制平仓</a>
        <a-divider type="vertical" />
        <a slot="action" href="javascript:;" @click="deletekopen(record.id)">删除</a>
      </template>
    </a-table>
    <a-modal
@@ -142,323 +170,370 @@
      :visible="Lockvisibledialog"
      :confirmLoading="Lockvisibleloading"
      @ok="getDialogok"
      @cancel="handleCancel">
      @cancel="handleCancel"
    >
      <a-form :form="Lockvisibleform" ref="createModal">
        <a-form-item>
          <a-input
            v-decorator="['lockMsg', { rules: [{ required: true, message: '请输入锁仓原因!', whitespace: true }] }]"
            placeholder="请输入锁仓原因!" />
            placeholder="请输入锁仓原因!"
          />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>
<script>
import { positionlist, positionlock, positionsell } from '@/api/position'
import { positionlist, positionlock, positionsell,positiondel } from '@/api/position'
import { nextagent } from '@/api/home'
import moment from 'moment'
export default {
    name: 'Financinghold',
    data () {
        return {
            columns: [
                {
                    title: '融资名称',
                    dataIndex: 'stockName',
                    align: 'center',
                    width: 180,
                    scopedSlots: { customRender: 'stockName' }
                },
                {
                    title: '账户类型',
                    dataIndex: 'positionType',
                    align: 'center',
                    scopedSlots: { customRender: 'positionType' }
                },
                {
                    title: '用户名称(ID)',
                    dataIndex: 'nickName',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return `${row.nickName}(${row.userId})`
                    }
                },
                {
                    title: '持仓订单号(ID)',
                    dataIndex: 'positionSn',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return `${row.positionSn}(${row.id})`
                    }
                },
                {
                    title: '买卖方向',
                    dataIndex: 'orderDirection',
                    align: 'center',
                    scopedSlots: { customRender: 'orderDirection' }
                },
                {
                    title: '买入价',
                    dataIndex: 'buyOrderPrice',
                    align: 'center',
                    customRender: (text, row, index) => {
                        return text.toFixed(2)
                    }
                },
                {
                    title: '现价',
                    dataIndex: 'now_price',
                    align: 'center',
                    scopedSlots: { customRender: 'now_price' }
                },
                {
                    title: '浮动盈亏',
                    dataIndex: 'profitAndLose',
                    align: 'center',
                    scopedSlots: { customRender: 'profitAndLose' }
                },
                {
                    title: '总盈亏',
                    dataIndex: 'allProfitAndLose',
                    align: 'center',
                    scopedSlots: { customRender: 'allProfitAndLose' }
                },
                {
                    title: '数量(股)',
                    dataIndex: 'orderNum',
                    align: 'center'
                },
                {
                    title: '总市值',
                    dataIndex: 'orderTotalPrice',
                    align: 'center'
                },
                {
                    title: '杠杆倍数',
                    dataIndex: 'orderLever',
                    align: 'center'
                },
                {
                    title: '手续费',
                    dataIndex: 'orderFee',
                    align: 'center'
                },
                {
                    title: '印花税',
                    dataIndex: 'orderSpread',
                    align: 'center'
                },
                {
                    title: '留仓费',
                    dataIndex: 'orderStayFee',
                    align: 'center'
                },
                {
                    title: '留仓天数',
                    dataIndex: 'orderStayDays',
                    align: 'center'
                },
                {
                    title: '锁定原因',
                    dataIndex: 'lockMsg',
                    align: 'center'
                },
                {
                    title: '买入时间',
                    dataIndex: 'buyOrderTime',
                    align: 'center',
                    width: 180,
                    customRender: (text, row, index) => {
                        return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
                    }
                },
                {
                    title: '操作',
                    key: 'action',
                    align: 'center',
                    fixed: 'right',
                    width: 150,
                    scopedSlots: { customRender: 'action' }
                }
            ],
            // 表头
            pagination: {
                total: 0,
                pageSize: 10, // 每页中显示10条数据
                showSizeChanger: true,
                pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
                onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
                onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
                showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
            },
            loading: false,
            queryParam: {
                pageNum: 1,
                pageSize: 10,
                positionType: '',
                agentId: undefined,
                userId: '',
                positionSn: '',
                state: 0
            },
            datalist: [],
            agentlist: [],
            agentloading: false,
            Lockvisibledialog: false,
            Lockvisibleloading: false,
            Lockvisibleform: this.$form.createForm(this),
            clickpositionId: '',
            agentqueryParam: {
                pageNum: 1,
                pageSize: 100
            }
        }
    },
    created () {
        this.getlist()
    },
    methods: {
        getCompulsoryclosing (val) {
            var that = this
            this.$confirm({
                title: '提示',
                content: '确认要强制平仓吗?',
                onOk () {
                    var data = {
                        positionSn: val
                    }
                    positionsell(data).then(res => {
                        if (res.status == 0) {
                            that.$message.success({ content: res.msg, duration: 2 })
                            that.getlist()
                        } else {
                            that.$message.error({ content: '平仓失败' })
                        }
                    }).catch(error => {
                        that.$message.error({ content: '平仓失败' })
                    })
                },
                onCancel () {
                    console.log('Cancel')
                }
            })
  name: 'Financinghold',
  data() {
    return {
      columns: [
        {
          title: '融资名称',
          dataIndex: 'stockName',
          align: 'center',
          width: 180,
          scopedSlots: { customRender: 'stockName' },
        },
        getLockopen (val) {
            var that = this
            this.$confirm({
                title: '提示',
                content: '确认要解锁该持仓单?',
                onOk () {
                    var data = {
                        state: 0,
                        positionId: val
                    }
                    positionlock(data).then(res => {
                        if (res.status == 0) {
                            that.$message.success({ content: res.msg, duration: 2 })
                            that.getlist()
                        } else {
                            that.$message.error({ content: res.msg })
                        }
                    })
                },
                onCancel () {
                    console.log('Cancel')
                }
            })
        // {
        //   title: '账户类型',
        //   dataIndex: 'positionType',
        //   align: 'center',
        //   scopedSlots: { customRender: 'positionType' },
        // },
        {
          title: '用户名称(ID)',
          dataIndex: 'nickName',
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.nickName}(${row.userId})`
          },
        },
        handleCancel () {
            this.Lockvisibledialog = false
            const form = this.$refs.createModal.form
            form.resetFields()
        {
          title: '持仓订单号(ID)',
          dataIndex: 'positionSn',
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.positionSn}(${row.id})`
          },
        },
        getDialogok () {
            const form = this.$refs.createModal.form
            form.validateFields((errors, values) => {
                if (!errors) {
                    this.Lockvisibleloading = true
                    var data = {
                        state: 1,
                        lockMsg: values.lockMsg,
                        positionId: this.clickpositionId
                    }
                    positionlock(data).then(res => {
                        if (res.status == 0) {
                            this.Lockvisibledialog = false
                            this.$message.success({ content: res.msg, duration: 2 })
                            form.resetFields()
                            this.getlist()
                        } else {
                            this.$message.error({ content: res.msg })
                        }
                        this.Lockvisibleloading = false
                    }).catch(error => {
                        reject(error)
                    })
                }
            })
        {
          title: '买卖方向',
          dataIndex: 'orderDirection',
          align: 'center',
          scopedSlots: { customRender: 'orderDirection' },
        },
        getinit () {
            this.queryParam = {
                pageNum: 1,
                pageSize: 10,
                positionType: '',
                agentId: undefined,
                userId: '',
                positionSn: '',
                state: 0
            }
            this.getlist()
        {
          title: '买入价',
          dataIndex: 'buyOrderPrice',
          align: 'center',
          customRender: (text, row, index) => {
            return text.toFixed(2)
          },
        },
        getqueryParam () {
            this.queryParam = {
                pageNum: 1,
                pageSize: 10,
                positionType: '',
                agentId: undefined,
                userId: '',
                positionSn: '',
                state: 0
            }
        {
          title: '现价',
          dataIndex: 'now_price',
          align: 'center',
          scopedSlots: { customRender: 'now_price' },
        },
        getagentlist () {
            var that = this
            this.agentloading = true
            nextagent(this.agentqueryParam).then(res => {
                this.agentlist = res.data.list
                setTimeout(() => {
                    that.agentloading = false
                }, 500)
            })
        {
          title: '浮动盈亏',
          dataIndex: 'profitAndLose',
          align: 'center',
          scopedSlots: { customRender: 'profitAndLose' },
        },
        getlist () {
            this.loading = true
            positionlist(this.queryParam).then(res => {
                this.datalist = res.data.list
                this.pagination.total = res.data.total
                this.loading = false
            })
        {
          title: '总盈亏',
          dataIndex: 'allProfitAndLose',
          align: 'center',
          scopedSlots: { customRender: 'allProfitAndLose' },
        },
        onPageChange (page, pageSize) {
            this.queryParam.pageNum = page
            this.getlist()
        {
          title: '数量(股)',
          dataIndex: 'orderNum',
          align: 'center',
        },
        onSizeChange (current, pageSize) {
            this.queryParam.pageNum = current
            this.queryParam.pageSize = pageSize
            this.getlist()
        }
        {
          title: '账号',
          dataIndex: 'phone',
          align: 'center',
        },
        {
          title: '所属代理(ID)',
          dataIndex: 'agentName_Id',
          align: 'center',
          customRender: (text, row, index) => {
            return `${row.agentName}(${row.agentId})`
          },
        },
        {
          title: '总市值',
          dataIndex: 'orderTotalPrice',
          align: 'center',
        },
        {
          title: '杠杆倍数',
          dataIndex: 'orderLever',
          align: 'center',
        },
        {
          title: '手续费',
          dataIndex: 'orderFee',
          align: 'center',
        },
        {
          title: '印花税',
          dataIndex: 'orderSpread',
          align: 'center',
        },
        {
          title: '留仓费',
          dataIndex: 'orderStayFee',
          align: 'center',
        },
        {
          title: '留仓天数',
          dataIndex: 'orderStayDays',
          align: 'center',
        },
        {
          title: '锁定原因',
          dataIndex: 'lockMsg',
          align: 'center',
        },
        {
          title: '买入时间',
          dataIndex: 'buyOrderTime',
          align: 'center',
          width: 180,
          customRender: (text, row, index) => {
            return text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''
          },
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          fixed: 'right',
          width: 150,
          scopedSlots: { customRender: 'action' },
        },
      ],
      // 表头
      pagination: {
        total: 0,
        pageSize: 10, // 每页中显示10条数据
        showSizeChanger: true,
        pageSizeOptions: ['10', '20', '50', '100'], // 每页中显示的数据
        onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize), // 改变每页数量时更新显示
        onChange: (page, pageSize) => this.onPageChange(page, pageSize), // 点击页码事件
        showTotal: (total) => `共有 ${total} 条数据`, // 分页中显示总的数据
      },
      loading: false,
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        positionType: '',
        agentId: undefined,
        userId: '',
        positionSn: '',
        state: 0,
        phone: '',
      },
      datalist: [],
      agentlist: [],
      agentloading: false,
      Lockvisibledialog: false,
      Lockvisibleloading: false,
      Lockvisibleform: this.$form.createForm(this),
      clickpositionId: '',
      agentqueryParam: {
        pageNum: 1,
        pageSize: 100,
      },
    }
  },
  created() {
    this.getlist()
  },
  methods: {
    deletekopen(id){
      var that = this
      this.$confirm({
        title: '提示',
        content: '确认要删除吗?',
        onOk() {
          var data = {
            positionId: id,
          }
          positiondel(data)
            .then((res) => {
              if (res.status == 0) {
                that.$message.success(res.msg)
                that.getlist()
              } else {
                that.$message.error({ content: '删除失败' })
              }
            })
            .catch((error) => {
              that.$message.error({ content: '删除失败' })
            })
        },
        onCancel() {
          console.log('Cancel')
        },
      })
    },
    getCompulsoryclosing(val) {
      var that = this
      this.$confirm({
        title: '提示',
        content: '确认要强制平仓吗?',
        onOk() {
          var data = {
            positionSn: val,
          }
          positionsell(data)
            .then((res) => {
              if (res.status == 0) {
                that.$message.success(res.msg)
                that.getlist()
              } else {
                that.$message.error({ content: '平仓失败' })
              }
            })
            .catch((error) => {
              that.$message.error({ content: '平仓失败' })
            })
        },
        onCancel() {
          console.log('Cancel')
        },
      })
    },
    getLockopen(val) {
      var that = this
      this.$confirm({
        title: '提示',
        content: '确认要解锁该持仓单?',
        onOk() {
          var data = {
            state: 0,
            positionId: val,
          }
          positionlock(data).then((res) => {
            if (res.status == 0) {
              that.$message.success(res.msg)
              that.getlist()
            } else {
              that.$message.error(res.msg)
            }
          })
        },
        onCancel() {
          console.log('Cancel')
        },
      })
    },
    handleCancel() {
      this.Lockvisibledialog = false
      const form = this.$refs.createModal.form
      form.resetFields()
    },
    getDialogok() {
      const form = this.$refs.createModal.form
      form.validateFields((errors, values) => {
        if (!errors) {
          this.Lockvisibleloading = true
          var data = {
            state: 1,
            lockMsg: values.lockMsg,
            positionId: this.clickpositionId,
          }
          positionlock(data)
            .then((res) => {
              if (res.status == 0) {
                this.Lockvisibledialog = false
                this.$message.success(res.msg)
                form.resetFields()
                this.getlist()
              } else {
                this.$message.error(res.msg)
              }
              this.Lockvisibleloading = false
            })
            .catch((error) => {
              reject(error)
            })
        }
      })
    },
    getinit() {
      this.queryParam = {
        pageNum: 1,
        pageSize: 10,
        positionType: '',
        agentId: undefined,
        userId: '',
        positionSn: '',
        state: 0,
        phone: '',
      }
      this.getlist()
    },
    getqueryParam() {
      this.queryParam = {
        pageNum: 1,
        pageSize: 10,
        positionType: '',
        agentId: undefined,
        userId: '',
        positionSn: '',
        state: 0,
        phone: '',
      }
    },
    getagentlist() {
      var that = this
      this.agentloading = true
      nextagent(this.agentqueryParam).then((res) => {
        this.agentlist = res.data.list
        setTimeout(() => {
          that.agentloading = false
        }, 500)
      })
    },
    getlist() {
      this.loading = true
      positionlist(this.queryParam).then((res) => {
        this.datalist = res.data.list
        this.pagination.total = res.data.total
        this.loading = false
      })
    },
    onPageChange(page, pageSize) {
      this.queryParam.pageNum = page
      this.getlist()
    },
    onSizeChange(current, pageSize) {
      this.queryParam.pageNum = current
      this.queryParam.pageSize = pageSize
      this.getlist()
    },
  },
}
</script>
<style scoped>
.greens {
    color: #52c41a;
  color: #52c41a;
}
.reds {
    color: #f5222d;
  color: #f5222d;
}
</style>