Commit a937c331 by chenwq

refactor(调拨新增): 提取保存操作为独立方法

将原 saveAllocate 方法中的 API 调用和结果处理逻辑提取为独立的 saveApi 方法,简化主方法逻辑。现在 save 操作直接调用 saveApi,而审核和作废操作仍保留确认弹窗后再调用。提高代码复用性和可维护性。
1 parent cb682dc6
...@@ -618,31 +618,15 @@ export default { ...@@ -618,31 +618,15 @@ export default {
}) })
}, },
/** 保存/作废/审核提交,弹窗提示不一样 saveApi(params, btnType = 'save') {
* 按钮类型 - 单据状态
* 保存按钮(save) - 创建 - 0:待提交
* 提交审核按钮(review) - 1:待审核
* 作废按钮(invalid) - -1:作废
**/
handleConfirm(params, btnType = 'save') {
if (this.loading) {
return true
}
const tipTxtObj = { const tipTxtObj = {
save: '保存成功', save: '保存成功',
review: '提交审核成功', review: '提交审核成功',
invalid: '作废成功' invalid: '作废成功'
} }
const btnObj = this.btnTypeMap[btnType]
params.billStatus = btnObj.billStatus
this.$confirm(btnObj.confirmMsg, btnObj.title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.loading = true this.loading = true
this.$apis.stockManage[this.routeInfo.id ? 'updateStockAllocate' : 'saveStockAllocate'](params).then(res => { this.$apis.stockManage[this.routeInfo.id ? 'updateStockAllocate' : 'saveStockAllocate'](params)
.then(res => {
this.$notify({ this.$notify({
type: res.code == 0 ? 'success' : 'error', type: res.code == 0 ? 'success' : 'error',
title: res.code == 0 ? (tipTxtObj[btnType] || '操作成功') : res.message title: res.code == 0 ? (tipTxtObj[btnType] || '操作成功') : res.message
...@@ -660,12 +644,38 @@ export default { ...@@ -660,12 +644,38 @@ export default {
} }
} }
}) })
.finally(() => {
this.loading = false
})
},
/** 保存/作废/审核提交,弹窗提示不一样
* 按钮类型 - 单据状态
* 保存按钮(save) - 创建 - 0:待提交
* 提交审核按钮(review) - 1:待审核
* 作废按钮(invalid) - -1:作废
**/
handleConfirm(params, btnType = 'save') {
if (this.loading) {
return true
}
const btnObj = this.btnTypeMap[btnType]
params.billStatus = btnObj.billStatus
if (btnType == 'save') {
this.saveApi(params, btnType)
} else {
this.$confirm(btnObj.confirmMsg, btnObj.title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.saveApi(params, btnType)
}) })
.catch(err => { .catch(err => {
console.log(err) console.log(err)
}).finally(() => {
this.loading = false
}) })
}
}, },
handleAddClose(isRefresh = false) { handleAddClose(isRefresh = false) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!