addCommunitySpacePerson.vue
6.34 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
164
165
166
167
168
169
170
171
172
173
174
175
<template>
<el-dialog :title="$t('addCommunitySpacePerson.title')" :visible.sync="visible" width="800px" @close="closeDialog">
<el-form ref="form" :model="formData" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.personName')" prop="personName">
<el-input v-model="formData.personName" :placeholder="$t('addCommunitySpacePerson.requiredPersonName')" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.personTel')" prop="personTel">
<el-input v-model="formData.personTel" :placeholder="$t('addCommunitySpacePerson.requiredPersonTel')" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.receivableAmount')" prop="receivableAmount">
<el-input v-model="formData.receivableAmount"
:placeholder="$t('addCommunitySpacePerson.requiredReceivableAmount')" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.receivedAmount')" prop="receivedAmount">
<el-input v-model="formData.receivedAmount"
:placeholder="$t('addCommunitySpacePerson.requiredReceivedAmount')" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.payWay')" prop="payWay">
<el-select v-model="formData.payWay" :placeholder="$t('addCommunitySpacePerson.selectPayWay')"
style="width:100%">
<el-option v-for="item in payOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('addCommunitySpacePerson.appointmentTime')" prop="appointmentTime">
<el-input v-model="formData.appointmentTime" disabled
:placeholder="$t('addCommunitySpacePerson.requiredAppointmentTime')" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item :label="$t('addCommunitySpacePerson.remark')" prop="remark">
<el-input v-model="formData.remark" type="textarea"
:placeholder="$t('addCommunitySpacePerson.requiredRemark')" :rows="3" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="handleSubmit">{{ $t('common.save') }}</el-button>
</div>
</el-dialog>
</template>
<script>
import { saveCommunitySpacePerson } from '@/api/community/reportCommunitySpaceApi'
import { getCommunityId } from '@/api/community/communityApi'
import { dateFormat } from '@/utils/dateUtil'
export default {
name: 'AddCommunitySpacePerson',
props: {
communityId: {
type: String,
default: () => getCommunityId()
}
},
data() {
return {
visible: false,
formData: {
spaceId: '',
personName: '',
personTel: '',
appointmentTime: '',
receivableAmount: '',
receivedAmount: '',
payWay: '',
remark: '',
openTime: '',
communityId: this.communityId,
state: 'S'
},
rules: {
personName: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredPersonName'), trigger: 'blur' },
{ max: 64, message: this.$t('addCommunitySpacePerson.maxPersonName'), trigger: 'blur' }
],
personTel: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredPersonTel'), trigger: 'blur' },
{ max: 11, message: this.$t('addCommunitySpacePerson.maxPersonTel'), trigger: 'blur' }
],
appointmentTime: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredAppointmentTime'), trigger: 'blur' }
],
receivableAmount: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredReceivableAmount'), trigger: 'blur' },
{ max: 10, message: this.$t('addCommunitySpacePerson.maxReceivableAmount'), trigger: 'blur' }
],
receivedAmount: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredReceivedAmount'), trigger: 'blur' },
{ max: 10, message: this.$t('addCommunitySpacePerson.maxReceivedAmount'), trigger: 'blur' }
],
payWay: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredPayWay'), trigger: 'change' }
],
remark: [
{ required: true, message: this.$t('addCommunitySpacePerson.requiredRemark'), trigger: 'blur' },
{ max: 512, message: this.$t('addCommunitySpacePerson.maxRemark'), trigger: 'blur' }
]
},
payOptions: [
{ value: '1', label: this.$t('addCommunitySpacePerson.cash') },
{ value: '2', label: this.$t('addCommunitySpacePerson.wechat') },
{ value: '3', label: this.$t('addCommunitySpacePerson.alipay') }
]
}
},
methods: {
open(data) {
this.resetForm()
Object.assign(this.formData, data)
this.formData.appointmentTime = dateFormat(this.formData.appointmentTime) + ` ${this.formData.openTime}:00`
this.visible = true
},
closeDialog() {
this.$refs.form.resetFields()
},
resetForm() {
this.formData = {
spaceId: '',
personName: '',
personTel: '',
appointmentTime: '',
receivableAmount: '',
receivedAmount: '',
payWay: '',
remark: '',
openTime: '',
communityId: this.communityId,
state: 'S'
}
},
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.saveData()
}
})
},
async saveData() {
try {
await saveCommunitySpacePerson(this.formData)
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
this.$message.error(error.message || this.$t('common.saveFailed'))
}
}
}
}
</script>