jiangping
2023-08-21 2837bdd57f72e386bbf9a725e7b3a13e5eb9e930
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<template>
  <GlobalWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="submit"
  >
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
    >
      <el-form-item
        class="check-with"
        label="取消原因:"
        prop="detail"
      >
        <el-input
          type="textarea"
          :autosize="{minRows: 4}"
          placeholder="请输入取消原因,不超过200字"
          maxlength="200"
          v-model="form.detail"
        />
      </el-form-item>
    </el-form>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { cancelById } from '@/api/ext/wOutboundExt'
import { cancel } from '@/api/ext/wTransferExt'
export default {
  name: 'OrderCancel',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      // 表单数据
      form: {
        id: null,
        detail: ''
      },
      type: 0, // 0出入库 1转库
      // 验证规则
      rules: {
        detail: [
          { required: true, message: '请输入取消原因', trigger: 'blur' },
          { max: 200, message: '输入字数不超过200', trigger: 'change' }
        ]
      }
    }
  },
  created () {
    // this.config({
    //   api: '/ext/awardExt',
    //   'field.id': 'id'
    // })
  },
  methods: {
    open (title, target, type) {
      this.title = title
      this.type = type
      this.visible = true
      // 编辑
      this.$nextTick(() => {
        for (const key in this.form) {
          this.form[key] = target[key]
        }
      })
    },
    submit () {
      this.$refs.form.validate(
        v => {
          if (!v) {
            return
          }
          // console.log('审核')
          this.isWorking = true
          const query = '?id=' + this.form.id + '&detail=' + this.form.detail
          if (this.type === 0) {
            cancelById(query)
              .then(res => {
                // console.log(res)
                this.$emit('success')
              })
              .catch(err => {
                this.$message.error(err.message)
              })
              .finally(() => {
                this.$refs.form.resetFields()
                this.isWorking = false
                this.visible = false
              })
          } else {
            cancel(query)
              .then(res => {
                // console.log(res)
                this.$emit('success')
              })
              .catch(err => {
                this.$message.error(err.message)
              })
              .finally(() => {
                this.$refs.form.resetFields()
                this.isWorking = false
                this.visible = false
              })
          }
        })
    },
    chechStatus (v) {
      // console.log(v)
      if (v === '1') {
        this.$refs.form.clearValidate()
      }
    }
  }
}
</script>
 
<style>
.check-with {
  width: calc(100%-30px);
}
</style>