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
<template>
<el-dialog
title="退款"
center
append-to-body
:visible.sync="show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" :rules="rules" >
<el-row>
<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-row>
<el-row>
<el-col :span="4"><label>退款原因</label></el-col>
<el-col :span="8">
<el-form-item>
<el-input v-model="form.desc" type="textarea"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="show = false">取 消</el-button>
<el-button type="primary" @click="save">确 定</el-button>
</span>
</div>
</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,
desc:''
},
rules:{
money:[
{ required: true, message: '请输入退款金额', trigger: 'change' }
],
desc:[
{ required: true, message: '请输入退款原因', trigger: 'change' }
]
}
}
},
methods:{
save(){
if(this.dialogObj.id){
this.$refs['form'].validate((valid) => {
if(valid){
let json = {
refund_money: parseFloat(this.form.money) * 100,
desc: this.form.desc
}
refundApi(this.dialogObj.id,json).then(res=>{
this.$message({
type: 'success',
message: '退款成功!'
});
this.$emit("reflash");
this.show = false;
})
}
});
}
},
initDialog(){
console.log('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:{
handler: function () {
this.initDialog()
},
deep: true
},
show(value){
this.$emit("changeShow",value);
}
}
}
</script>
<style scoped lang="less">
</style>