Commit 623ecf2c by chenwq

refactor(storeCredit): 优化异步请求处理并添加加载状态

在created钩子中将async/await改为Promise链式调用,并添加loading状态管理
在handleConfirm方法中增加loading状态检查防止重复提交
移除调试用的console.log语句
1 parent cf957e42
......@@ -364,29 +364,33 @@ export default {
}
}
},
async created() {
/** loginpath:标识系统
* 门店版:/login
* 1、默认带出商户,“选择商户”按钮置灰
* 2、导入充值人群,去掉“管理层”
* 运营版:/oss
*/
if(this.$globalState.session.loginpath == '/login') {
this.baseData.personTypeList.splice(1, 1)
this.configForm.merchantId = this.$globalState.session.merchantId
this.configForm.merchantName = this.$globalState.session.merchantName
const res = await this.$apis.points.getMerchantCharge({ merchantId: this.configForm.merchantId })
if (res) {
this.totalFormData.map(e => {
if (['gasCardServiceCharge', 'passageServiceCharge'].includes(e.name)) {
const val = res[e.name] || 0
e.label = e.label.replace(/\d+/g, val)
this.chargeObject[e.name] = val
}
})
}
}
},
created() {
/** loginpath:标识系统
* 门店版:/login
* 1、默认带出商户,“选择商户”按钮置灰
* 2、导入充值人群,去掉“管理层”
* 运营版:/oss
*/
if (this.$globalState.session.loginpath == '/login') {
this.baseData.personTypeList.splice(1, 1)
this.configForm.merchantId = this.$globalState.session.merchantId
this.configForm.merchantName = this.$globalState.session.merchantName
this.loading = true
this.$apis.points.getMerchantCharge({ merchantId: this.configForm.merchantId }).then(res => {
if (res) {
this.totalFormData.map(e => {
if (['gasCardServiceCharge', 'passageServiceCharge'].includes(e.name)) {
const val = res[e.name] || 0
e.label = e.label.replace(/\d+/g, val)
this.chargeObject[e.name] = val
}
})
}
}).finally(() => {
this.loading = false
})
}
},
mounted() {
const { id, type } = this.$route.query
if (id) this.getDetail(id, type)
......@@ -436,9 +440,9 @@ export default {
handleConfirm() {
const { disabled, id } = this.pageObject
if (disabled) return this.$router.go(-1)
if(this.loading) {
return true
}
if (this.loading) {
return true
}
this.$refs.fromRef.$refs.formRef.validate(async valid => {
if (valid) {
try {
......@@ -486,7 +490,7 @@ export default {
}
if (id) params.id = id
const res = await this.$apis.points.updateCustomerIntegral(params)
console.log(res)
console.log(res)
if (res.code == 0) {
this.$message({
message: id ? '编辑成功' : '创建成功',
......@@ -494,8 +498,8 @@ export default {
})
setTimeout(() => this.$router.go(-1), 1e3)
} else {
this.loading = false
}
this.loading = false
}
} catch (error) {
this.loading = false
this.$message.error(error || '操作失败')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!