7505cb92
wuxw
开发完成折扣设置
|
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
|
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('common.cancel') }}
</el-button>
<el-button type="primary" @click="editFeeDiscount">
{{ $t('common.save') }}
</el-button>
</span>
</el-dialog>
</template>
<script>
import { getDict } from '@/api/community/communityApi'
import { updateFeeDiscount, queryFeeDiscountRule } from '@/api/fee/feeDiscountManageApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'EditFeeDiscount',
data() {
return {
visible: false,
editFeeDiscountInfo: {
discountId: '',
discountName: '',
discountType: '',
discountTypes: [],
ruleId: '',
discountDesc: '',
rules: [],
feeDiscountRuleSpecs: [],
communityId: ''
},
rules: {
discountName: [
{ required: true, message: this.$t('feeDiscountManage.edit.discountNameRequired'), trigger: 'blur' },
{ max: 256, message: this.$t('feeDiscountManage.edit.discountNameMaxLength'), trigger: 'blur' }
],
discountType: [
{ required: true, message: this.$t('feeDiscountManage.edit.discountTypeRequired'), trigger: 'change' }
],
ruleId: [
{ required: true, message: this.$t('feeDiscountManage.edit.ruleRequired'), trigger: 'change' }
],
discountId: [
{ required: true, message: this.$t('feeDiscountManage.edit.discountIdRequired'), trigger: 'blur' }
]
}
}
},
methods: {
open(row) {
this.visible = true
this.getCommunityId()
this.getDictData()
this.$nextTick(() => {
this.editFeeDiscountInfo = {
...row,
discountTypes: this.editFeeDiscountInfo.discountTypes,
rules: this.editFeeDiscountInfo.rules,
feeDiscountRuleSpecs: row.feeDiscountSpecs || [],
communityId: this.editFeeDiscountInfo.communityId
}
})
},
async getCommunityId() {
try {
const communityId = await getCommunityId()
this.editFeeDiscountInfo.communityId = communityId
} catch (error) {
console.error('获取communityId失败:', error)
}
},
async getDictData() {
try {
const data = await getDict('fee_discount', 'discount_type')
this.editFeeDiscountInfo.discountTypes = data
} catch (error) {
console.error('获取字典数据失败:', error)
}
},
async _loadEditFeeDiscountRules() {
if (!this.editFeeDiscountInfo.discountType) return
|
7505cb92
wuxw
开发完成折扣设置
|
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
|
try {
const params = {
page: 1,
row: 100,
discountType: this.editFeeDiscountInfo.discountType
}
const { data } = await queryFeeDiscountRule(params)
this.editFeeDiscountInfo.rules = data
} catch (error) {
console.error('获取规则列表失败:', error)
}
},
_changeEditFeeDiscountRule() {
const selectedRule = this.editFeeDiscountInfo.rules.find(
item => item.ruleId === this.editFeeDiscountInfo.ruleId
)
if (selectedRule) {
this.editFeeDiscountInfo.feeDiscountRuleSpecs = selectedRule.feeDiscountRuleSpecs.map(item => ({
...item,
specValue: ''
}))
}
},
_changeEditFeeDiscountType() {
this.editFeeDiscountInfo.ruleId = ''
this.editFeeDiscountInfo.feeDiscountRuleSpecs = []
this._loadEditFeeDiscountRules()
},
async editFeeDiscount() {
this.$refs.form.validate(async valid => {
if (!valid) return
|
7505cb92
wuxw
开发完成折扣设置
|
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
176
177
178
179
180
181
|
try {
await updateFeeDiscount(this.editFeeDiscountInfo)
this.$message.success(this.$t('common.saveSuccess'))
this.$emit('success')
this.visible = false
this.resetForm()
} catch (error) {
console.error('更新折扣信息失败:', error)
}
})
},
resetForm() {
this.$refs.form.resetFields()
this.editFeeDiscountInfo = {
discountId: '',
discountName: '',
discountType: '',
discountTypes: this.editFeeDiscountInfo.discountTypes,
ruleId: '',
discountDesc: '',
rules: [],
feeDiscountRuleSpecs: [],
communityId: this.editFeeDiscountInfo.communityId
}
},
handleClose() {
this.resetForm()
}
}
}
</script>
|