cancel-dialog.vue
1.9 KB
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
<template>
<el-dialog title="作废记录" :visible.sync="visible" width="500px" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="作废原因" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="4" placeholder="请输入作废原因" maxlength="500" show-word-limit />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="danger" @click="submit" :loading="loading">确定作废</el-button>
</div>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
export default {
name: 'CancelDialog',
data() {
return {
visible: false,
loading: false,
form: {
id: '',
remark: ''
},
rules: {
remark: [{ required: true, message: '请输入作废原因', trigger: 'blur' }]
}
}
},
methods: {
// 初始化
init(row) {
this.visible = true
this.form = {
id: row.id,
remark: ''
}
this.$nextTick(() => {
if (this.$refs.form) {
this.$refs.form.clearValidate()
}
})
},
// 提交
submit() {
this.$refs.form.validate(valid => {
if (!valid) return
this.loading = true
request({
url: '/api/Extend/LqLaundryFlow/Cancel',
method: 'POST',
data: {
id: this.form.id,
remark: this.form.remark
}
}).then(res => {
this.loading = false
if (res.code == 200) {
this.$message.success(res.msg || '作废成功')
this.visible = false
this.$emit('refresh')
} else {
this.$message.error(res.msg || '作废失败')
}
}).catch(() => {
this.loading = false
})
})
}
},
watch: {
visible(val) {
if (!val) {
this.$refs.form && this.$refs.form.resetFields()
}
}
}
}
</script>
<style lang="scss" scoped>
.dialog-footer {
text-align: right;
}
</style>