Commit 71bde735 by chenwq

fix(调拨): 修复表单验证和商户ID类型转换问题

- 在获取商户列表时,将merchantId转换为字符串类型,避免后续比较错误
- 编辑表单时,callOutMerchantId和callInMerchantId也转换为字符串类型
- 重构beforeConfirm方法,使用Promise.all同时验证两个表单,避免嵌套回调
1 parent f845245c
......@@ -456,6 +456,9 @@ export default {
yqMerchantId: merchantId
})
.then(res => {
res.forEach((item, idx) => {
res[idx].merchantId = item.merchantId + ''
})
if (type == 'out') {
this.callOutMerchantList = res || []
//总店
......@@ -568,6 +571,8 @@ export default {
this.editAllocationForm = res
this.editAllocationForm.callOutYqMerchantId = this.editAllocationForm.callOutYqMerchantId + ''
this.editAllocationForm.callInYqMerchantId = this.editAllocationForm.callInYqMerchantId + ''
this.editAllocationForm.callOutMerchantId = this.editAllocationForm.callOutMerchantId + ''
this.editAllocationForm.callInMerchantId = this.editAllocationForm.callInMerchantId + ''
this.chooseDataList = res.stockAllocateDetailList
// this.getListApi = this.$apis.stockManage.stockRemainPage
this.$refs.allocationTable.refreshTable()
......@@ -597,8 +602,18 @@ export default {
* 作废按钮(invalid) - 5:作废
**/
beforeConfirm(btnType = 'save') {
this.$refs.editAllocationFormRef.validate(valid => {
if (valid) {
const p1 = new Promise((resolve) => {
this.$refs.editAllocationFormRef.validate(valid => {
resolve(valid)
})
})
const p2 = new Promise((resolve) => {
this.$refs.allocationFormRef.$refs.inveFormRefd2FormRuleForm.validate(valid => {
resolve(valid)
})
})
Promise.all([p1, p2]).then(([valid1, valid2]) => {
if (valid1 && valid2) {
if (this.chooseDataList.length == 0) {
this.$notify({
type: 'warning',
......@@ -606,22 +621,18 @@ export default {
})
return
}
this.$refs.allocationFormRef.$refs.inveFormRefd2FormRuleForm.validate(valid2 => {
if (valid2) {
const data = this.$refs.allocationFormRef.formData
var params = {}
params = {
...params,
...data,
...this.editAllocationForm
}
params.stockCheckDetailList = this.chooseDataList
params.remark = data.remark || ''
console.log(params, 'params')
// 调不同按钮的方法
this.handleConfirm(params, btnType)
}
})
const data = this.$refs.allocationFormRef.formData
var params = {}
params = {
...params,
...data,
...this.editAllocationForm
}
params.stockCheckDetailList = this.chooseDataList
params.remark = data.remark || ''
console.log(params, 'params')
// 调不同按钮的方法
this.handleConfirm(params, btnType)
}
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!