Blame view

merchant-web-master/src/views/order/pending/components/changePrice.vue 2.48 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="updatePrice">
      <el-dialog
        :visible.sync="visible"
        :close-on-click-modal="false"
          custom-class="bian_css"
        title="商品改价"
          width="65%"
      >
        <el-form
          ref="ruleForm"
          :model="ruleForm"
          :rules="rules"
          label-width="120px"
        >
          <el-form-item label="订单应付价格" prop="price">
            <el-input v-model="ruleForm.price" disabled />
          </el-form-item>
          <el-form-item label="修改价格" prop="newPrice">
            <el-input
              v-model="ruleForm.newPrice"
              @change="
                (val) => {
                  scope.row.newPrice = parseFloat(val) ? parseFloat(val) : 1;
                }
              "
            />
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button :loading="loading" @click="changeOrderPrice('ruleForm')" style="background-color: #3F9B6A;color: #fff">确 定</el-button>
          <el-button @click="cancel('ruleForm')"    class="buttonHover"
                    style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">取 消</el-button>
        </span>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import { updateOrderPrice } from '@/api/order'
  export default {
    data() {
      return {
        visible: false,
        loading: false,
        ruleForm: {
          orderId: null,
          price: 0,
          newPrice: 0
        },
        rules: {
          newPrice: [
            { required: true, message: '请输入修改后的价格', trigger: 'blur' }
          ],
        }
      }
    },
    methods: {
      show(row) {
        this.visible = true
        this.ruleForm.orderId = row.orderId
        this.ruleForm.price = row.price
      },
      cancel(ref) {
        this.$refs[ref].resetFields();
        this.visible = false
      },
      changeOrderPrice(ref) {
        this.$refs[ref].validate((valid) => {
          if (valid && !this.loading) {
            this.loading = true
            updateOrderPrice({
              orderId: this.ruleForm.orderId,
60d9bf40   杨鑫   '1'
74
              price: this.ruleForm.newPrice,
3f535f30   杨鑫   '初始'
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
            }).then(res => {
              if (res.code === '') {
                this.$message.success('修改成功')
                this.visible = false
                this.$emit('success')
              }
            }).catch(err => {
              console.log(err)
            }).finally(() => {
              this.loading = false
            })
          }
        })
      }
    }
  }
  </script>
  
  <style lang="scss">
  @import url("../../../../styles/elDialog.scss");
  </style>