Fixiaobai
2023-11-15 a12fbf14327027e7081eea89a777cb3e3012c170
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
108
<template>
  <el-dialog
    width="40%"
    title="退回原因"
    top="10vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      label-width="120px"
      class="l-mes"
    >
      <el-row>
        <el-col :span="23">
          <el-form-item label="退回原因" prop="returnReason" label-width="60px">
            <el-input
              type="textarea"
              :rows="5"
              v-model="dataForm.returnReason"
              placeholder="必填"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import { returnOrder } from '@/api/plan/customerorder'
import { mapGetters } from 'vuex'
 
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    customerOrderList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      innerVisible: false,
      dataForm: {
        returnReason: null
      },
      dataRule: {}
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
      }
    }
  },
  methods: {
    dataFormSubmit() {
      if (
        this.dataForm.returnReason != null &&
        this.dataForm.returnReason != ''
      ) {
        const ids = []
        this.customerOrderList.forEach((item) => {
          ids.push(item.id)
        })
        console.log('this.userInfo.username', this.userInfo.username)
        const setDataForm = {
          customerOrderIds: ids,
          returnUser: this.userInfo.staffName,
          returnReason: this.dataForm.returnReason
        }
        returnOrder(setDataForm).then((response) => {
          const reaData = response.data
          if (reaData.code === 0) {
            this.$emit('refreshCustomerOrder')
            this.innerVisible = false
            this.dataForm.returnReason = ''
            this.$message.success('订单退回成功')
          } else {
            this.$message.error('订单退回失败')
          }
        })
      } else {
        this.$message.error('请填写退回原因')
      }
    }
  }
}
</script>