feat(tygl): 已有档案时按钮显示「更新档案」,更新成功后返回上一页
This commit is contained in:
@@ -148,7 +148,7 @@
|
|||||||
|
|
||||||
<view class="action-card">
|
<view class="action-card">
|
||||||
<button class="ghost-btn" @click="saveDraft">保存草稿</button>
|
<button class="ghost-btn" @click="saveDraft">保存草稿</button>
|
||||||
<button class="primary-btn" @click="submitForm">提交档案</button>
|
<button class="primary-btn" @click="submitForm">{{ submitButtonText }}</button>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
@@ -388,6 +388,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 已有档案(formId 来自 getCurrentTyglForm)时按钮切换为更新
|
||||||
|
submitButtonText() {
|
||||||
|
return this.formId ? '更新档案' : '提交档案'
|
||||||
|
},
|
||||||
nationLabels() {
|
nationLabels() {
|
||||||
return this.nationOptions.map((item) => item.label)
|
return this.nationOptions.map((item) => item.label)
|
||||||
},
|
},
|
||||||
@@ -1009,11 +1013,12 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const isUpdate = Boolean(this.formId)
|
||||||
const payload = this.buildSubmitPayload()
|
const payload = this.buildSubmitPayload()
|
||||||
const result = this.formId
|
const result = isUpdate
|
||||||
? await updateTyglForm(payload)
|
? await updateTyglForm(payload)
|
||||||
: await saveTyglForm(payload)
|
: await saveTyglForm(payload)
|
||||||
if (!this.formId && result && result.id) {
|
if (!isUpdate && result && result.id) {
|
||||||
this.formId = result.id
|
this.formId = result.id
|
||||||
}
|
}
|
||||||
const savedAt = this.formatNow()
|
const savedAt = this.formatNow()
|
||||||
@@ -1023,9 +1028,24 @@ export default {
|
|||||||
status: 'submitted'
|
status: 'submitted'
|
||||||
})
|
})
|
||||||
this.draftSavedAt = savedAt
|
this.draftSavedAt = savedAt
|
||||||
|
if (isUpdate) {
|
||||||
|
// 更新成功:提示后返回上一页
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack({
|
||||||
|
fail: () => {
|
||||||
|
uni.reLaunch({url: '/pages/index/index'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 800)
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提交成功',
|
title: '提交成功',
|
||||||
content: this.formId ? '团员档案已更新。' : '团员档案已创建。',
|
content: '团员档案已创建。',
|
||||||
showCancel: false
|
showCancel: false
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user