zj
2024-06-03 e02a610447cb4c55c29eeb4441372d4a47b913b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
  <div>
    <a-modal
      title="修改股票平仓单"
      :width="500"
      :visible="editUserdialog"
      :confirmLoading="editUserDialogloading"
      @ok="OkeditUserdialog"
      @cancel="CanceleditUserdialog"
    >
      <a-form :form="editUserform" ref="editUserform">
        <a-form-item label="融资名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input placeholder="请输入融资名称" disabled v-decorator="['stockName', {}]" />
        </a-form-item>
        <a-form-item v-show="false" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input disabled v-decorator="['id', {}]" />
        </a-form-item>
        <a-form-item label="指定平仓价" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input
            placeholder="请输入指定平仓价"
            v-decorator="['stopTargetPrice', { rules: [{ required: true, message: '请输入指定平仓价' }] }]"
          />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>
<script>
// import { agentupdate } from '@/api/home'
import pick from 'lodash.pick'
import { positionEditOrder } from '@/api/position'
import moment from 'moment'
export default {
  components: {},
  props: {
    getinit: {
      type: Function,
      default: function () {},
    },
  },
  data() {
    return {
      value1: '',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 },
      },
      editUserform: this.$form.createForm(this),
      editUserdialog: false,
      editUserDialogloading: false,
      fields: ['stockName', 'buyOrderPrice', 'orderNum', 'id', 'buyOrderTime','stopTargetPrice'],
      currentDetails: {},
    }
  },
  methods: {
    onChangeRangeDate(value, dateString) {
      this.queryParam.beginTime = dateString[0]
      this.queryParam.endTime = dateString[1]
    },
    getEditorder(val) {
      val.buyOrderTime = moment(val.buyOrderTime).format('YYYY-MM-DD HH:mm:ss')
      this.currentDetails = val
 
      this.editUserdialog = true
      this.fields.forEach((v) => this.editUserform.getFieldDecorator(v))
      this.editUserform.setFieldsValue(pick(val, this.fields))
      this.editUserform.setFieldsValue(pick({ agentPwd: '' }, this.fields))
    },
    // 新增用户取消弹窗
    CanceleditUserdialog() {
      this.editUserdialog = false
      const form = this.$refs.editUserform.form
      form.resetFields()
    },
    // 新增用户确定
    OkeditUserdialog() {
      const form = this.$refs.editUserform.form
      console.log(form, 'form')
      form.validateFields((errors, values) => {
        if (!errors) {
          this.editUserDialogloading = true
          this.currentDetails.buyOrderTime = moment(this.currentDetails.buyOrderTime).valueOf()
          positionEditOrder({
            ...this.currentDetails,
            stopTargetPrice: values.stopTargetPrice,
            orderNum: values.orderNum,
          }).then((res) => {
            if (res.status == 200 || res.code === 200) {
              this.editUserdialog = false
              this.$message.success(res.msg)
              form.resetFields()
              this.getinit()
            } else {
              this.$message.error(res.msg)
            }
            this.editUserDialogloading = false
          })
        }
      })
    },
  },
}
</script>