editApplyRoomDiscountRecord.vue
5.25 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<template>
<el-dialog :title="$t('applyRoomDiscount.editRecord.title')" :visible.sync="visible" width="60%" @close="handleClose">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item :label="$t('applyRoomDiscount.editRecord.ardId')" prop="ardId">
<el-input v-model="form.ardId" disabled />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.roomName')" prop="roomName">
<el-input v-model="form.roomName" disabled />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.applyTypeName')" prop="applyTypeName">
<el-input v-model="form.applyTypeName" disabled />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.createUserName')" prop="createUserName">
<el-input v-model="form.createUserName" disabled />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.createUserTel')" prop="createUserTel">
<el-input v-model="form.createUserTel" disabled />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.startTime')" prop="startTime">
<el-date-picker v-model="form.startTime" type="datetime"
:placeholder="$t('applyRoomDiscount.editRecord.startTimePlaceholder')" value-format="yyyy-MM-dd HH:mm:ss"
style="width:100%" @change="validateDate" />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.endTime')" prop="endTime">
<el-date-picker v-model="form.endTime" type="datetime"
:placeholder="$t('applyRoomDiscount.editRecord.endTimePlaceholder')" value-format="yyyy-MM-dd HH:mm:ss"
style="width:100%" @change="validateDate" />
</el-form-item>
<el-form-item :label="$t('applyRoomDiscount.editRecord.stateName')" prop="stateName">
<el-input v-model="form.stateName" disabled />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('common.cancel') }}
</el-button>
<el-button type="primary" @click="submitForm">
{{ $t('common.save') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
import { editApplyRoomDiscount } from '@/api/fee/applyRoomDiscountManageApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'EditApplyRoomDiscountRecord',
data() {
return {
visible: false,
form: {
ardId: '',
roomName: '',
roomId: '',
discountId: '',
discountName: '',
applyTypeName: '',
createUserName: '',
createUserTel: '',
startTime: '',
endTime: '',
stateName: '',
state: '',
communityId: ''
},
rules: {
ardId: [
{ required: true, message: this.$t('applyRoomDiscount.validate.ardIdRequired'), trigger: 'blur' }
],
roomName: [
{ required: true, message: this.$t('applyRoomDiscount.validate.roomRequired'), trigger: 'blur' }
],
applyTypeName: [
{ required: true, message: this.$t('applyRoomDiscount.validate.applyTypeRequired'), trigger: 'blur' }
],
createUserName: [
{ required: true, message: this.$t('applyRoomDiscount.validate.createUserRequired'), trigger: 'blur' }
],
startTime: [
{ required: true, message: this.$t('applyRoomDiscount.validate.startTimeRequired'), trigger: 'change' }
],
endTime: [
{ required: true, message: this.$t('applyRoomDiscount.validate.endTimeRequired'), trigger: 'change' }
],
stateName: [
{ required: true, message: this.$t('applyRoomDiscount.validate.stateRequired'), trigger: 'blur' }
]
}
}
},
methods: {
open(data) {
this.form = {
...this.form,
...data,
communityId: getCommunityId()
}
this.visible = true
},
handleClose() {
this.$refs.form.resetFields()
this.form = {
ardId: '',
roomName: '',
roomId: '',
discountId: '',
discountName: '',
applyTypeName: '',
createUserName: '',
createUserTel: '',
startTime: '',
endTime: '',
stateName: '',
state: '',
communityId: ''
}
},
validateDate() {
if (this.form.startTime && this.form.endTime) {
const start = new Date(this.form.startTime)
const end = new Date(this.form.endTime)
if (start >= end) {
this.$message.error(this.$t('applyRoomDiscount.validate.dateInvalid'))
this.form.endTime = ''
}
}
},
submitForm() {
this.$refs.form.validate(valid => {
if (valid) {
this.updateApplyRoomDiscount()
}
})
},
async updateApplyRoomDiscount() {
try {
await editApplyRoomDiscount(this.form)
this.$message.success(this.$t('applyRoomDiscount.message.updateSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
this.$message.error(error.message || this.$t('applyRoomDiscount.message.updateFailed'))
}
}
}
}
</script>
<style lang="scss" scoped>
.el-form-item {
margin-bottom: 22px;
}
</style>