Commit 71bde735 by chenwq

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

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