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
129
130
131
132
133
<template>
<el-dialog
title="退款"
center
append-to-body
:visible="show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" :rules="rules" >
<el-row :gutter="20">
<el-col :span="4"><label>退款金额</label></el-col>
<el-col :span="8">
<el-form-item prop="key">
<el-input v-model="form.money"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-button type="success" round size="small" @click="form.money=100">¥100</el-button>
<el-button type="success" round size="mini" @click="form.money=150">¥150</el-button>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="4"><label>退课</label></el-col>
<el-col :span="8">
<el-form-item>
<el-switch
v-model="form.refund_type"
:active-value="2"
:inactive-value="1">
</el-switch>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="4"><label>退款原因</label></el-col>
<el-col :span="12">
<el-form-item>
<el-input v-model="form.desc" type="textarea"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="show = false">取 消</el-button>
<el-button type="primary" @click="save">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import {refundApi} from "../../service/api";
export default {
name: "dialogObj",
props:[
'dialogObj'
],
data(){
return{
show:false,
id: '',
loading:true,
form:{
money:0,
refund_type:1,
desc:''
},
rules:{
money:[
{ required: true, message: '请输入退款金额', trigger: 'change' }
],
desc:[
{ required: true, message: '请输入退款原因', trigger: 'change' }
]
}
}
},
methods:{
save(){
this.$confirm('确定保存?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(()=>{
if(this.dialogObj.id){
this.$refs['form'].validate((valid) => {
if(valid){
let json = {
refund_money: parseFloat(this.form.money) * 100,
desc: this.form.desc,
refund_type:this.form.refund_type
};
console.log(json)
refundApi(this.dialogObj.id,json).then(res=>{
this.$message({
type: 'success',
message: '退款成功!'
});
this.$emit("reflash");
this.show = false;
})
}
});
}
});
},
initDialog(){
this.show = this.dialogObj.show;
if (this.dialogObj.id) {
this.id = this.dialogObj.id;
}
this.form.money = parseFloat(this.dialogObj.money / 100);
this.form.desc = this.dialogObj.desc;
this.loading = false
}
},
watch:{
'dialogObj.show'(value){
if(value){
this.initDialog()
}
},
show(value){
this.$emit("changeShow",value);
}
}
}
</script>
<style scoped lang="less">
</style>