writeOweFeeCallable.vue
3.41 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
<el-dialog :title="$t('writeOweFeeCallable.title')" :visible.sync="dialogVisible" width="40%"
:before-close="handleClose">
<div class="ibox-content">
<el-form label-width="120px" class="text-left">
<el-form-item :label="$t('writeOweFeeCallable.room')">
<el-input v-model="writeOweFeeCallableInfo.roomName" readonly
:placeholder="$t('writeOweFeeCallable.roomPlaceholder')"></el-input>
</el-form-item>
<el-form-item :label="$t('writeOweFeeCallable.fees')">
<el-checkbox-group v-model="writeOweFeeCallableInfo.feeIds">
<el-checkbox v-for="(item, index) in writeOweFeeCallableInfo.fees" :key="index" :label="item.feeId">
{{ item.feeName }}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item :label="$t('writeOweFeeCallable.remark')">
<el-input type="textarea" :rows="5" v-model="writeOweFeeCallableInfo.remark"
:placeholder="$t('writeOweFeeCallable.remarkPlaceholder')"></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ $t('writeOweFeeCallable.cancel') }}</el-button>
<el-button type="primary" @click="_wirteCallable">{{ $t('writeOweFeeCallable.submit') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getCommunityId } from '@/api/community/communityApi'
import { writeOweFeeCallable, listFee } from '@/api/fee/writeOweFeeCallableApi'
export default {
name: 'WriteOweFeeCallable',
data() {
return {
dialogVisible: false,
writeOweFeeCallableInfo: {
roomId: '',
roomName: '',
fees: [],
feeIds: [],
remark: ''
}
}
},
created() {
this._initEvent()
},
methods: {
_initEvent() {
this.$on('openWriteOweFeeCallableModal', this.open)
},
open(param) {
Object.assign(this.writeOweFeeCallableInfo, param)
this._loadWriteOweRoomFees()
this.dialogVisible = true
},
handleClose(done) {
this.clearWriteOweFeeCallable()
done()
},
async _wirteCallable() {
try {
const params = {
...this.writeOweFeeCallableInfo,
communityId: getCommunityId()
}
const res = await writeOweFeeCallable(params)
if (res.code === 0) {
this.dialogVisible = false
this.clearWriteOweFeeCallable()
this.$emit('listOweFeeCallable', {})
this.$emit('listOwnerData', {})
this.$emit('success', {})
this.$message.success(this.$t('writeOweFeeCallable.success'))
} else {
this.$message.error(res.msg)
}
} catch (error) {
console.error('Request failed:', error)
this.$message.error(error.message)
}
},
clearWriteOweFeeCallable() {
this.writeOweFeeCallableInfo = {
roomId: '',
roomName: '',
fees: [],
feeIds: [],
remark: ''
}
},
async _loadWriteOweRoomFees() {
try {
const res = await listFee({
page: 1,
row: 100,
communityId: getCommunityId(),
payerObjId: this.writeOweFeeCallableInfo.roomId,
state: '2008001'
})
this.writeOweFeeCallableInfo.fees = res.fees
} catch (error) {
console.error('Request failed:', error)
}
}
}
}
</script>