diff --git a/acs/nladmin-ui/src/components/Crud/crud.js b/acs/nladmin-ui/src/components/Crud/crud.js index 74d4f802f..523fd1881 100644 --- a/acs/nladmin-ui/src/components/Crud/crud.js +++ b/acs/nladmin-ui/src/components/Crud/crud.js @@ -268,7 +268,11 @@ function CRUD(options) { /** * 取消新增/编辑 */ - cancelCU() { + cancelCU(formName) { + if (formName instanceof PointerEvent) { + formName = 'form' + } + const addStatus = crud.status.add const editStatus = crud.status.edit const viewStatus = crud.status.view @@ -296,18 +300,21 @@ function CRUD(options) { callVmHook(crud, CRUD.HOOK.afterEditCancel, crud.form) } // 清除表单验证 - if (crud.findVM('form').$refs['form']) { - crud.findVM('form').$refs['form'].clearValidate() + if (crud.findVM('form').$refs[formName]) { + crud.findVM('form').$refs[formName].clearValidate() } }, /** * 提交新增/编辑 */ - submitCU(form) { + submitCU(formName) { + if (formName instanceof PointerEvent) { + formName = 'form' + } if (!callVmHook(crud, CRUD.HOOK.beforeValidateCU)) { return } - crud.findVM('form').$refs['form'].validate(valid => { + crud.findVM('form').$refs[formName].validate(valid => { if (!valid) { return } @@ -493,8 +500,10 @@ function CRUD(options) { } } // add by ghl 2020-10-04 页面重复添加信息时,下拉框的校验会存在,需要找工取消 - if (crud.findVM('form').$refs['form']) { - crud.findVM('form').$refs['form'].clearValidate() + let form_ref = 'form' + if (crudFrom.form_ref) form_ref = crudFrom.form_ref + if (crud.findVM('form').$refs[form_ref]) { + crud.findVM('form').$refs[form_ref].clearValidate() } }, /** diff --git a/lms/nladmin-ui/src/components/Crud/crud.js b/lms/nladmin-ui/src/components/Crud/crud.js index 74d4f802f..523fd1881 100644 --- a/lms/nladmin-ui/src/components/Crud/crud.js +++ b/lms/nladmin-ui/src/components/Crud/crud.js @@ -268,7 +268,11 @@ function CRUD(options) { /** * 取消新增/编辑 */ - cancelCU() { + cancelCU(formName) { + if (formName instanceof PointerEvent) { + formName = 'form' + } + const addStatus = crud.status.add const editStatus = crud.status.edit const viewStatus = crud.status.view @@ -296,18 +300,21 @@ function CRUD(options) { callVmHook(crud, CRUD.HOOK.afterEditCancel, crud.form) } // 清除表单验证 - if (crud.findVM('form').$refs['form']) { - crud.findVM('form').$refs['form'].clearValidate() + if (crud.findVM('form').$refs[formName]) { + crud.findVM('form').$refs[formName].clearValidate() } }, /** * 提交新增/编辑 */ - submitCU(form) { + submitCU(formName) { + if (formName instanceof PointerEvent) { + formName = 'form' + } if (!callVmHook(crud, CRUD.HOOK.beforeValidateCU)) { return } - crud.findVM('form').$refs['form'].validate(valid => { + crud.findVM('form').$refs[formName].validate(valid => { if (!valid) { return } @@ -493,8 +500,10 @@ function CRUD(options) { } } // add by ghl 2020-10-04 页面重复添加信息时,下拉框的校验会存在,需要找工取消 - if (crud.findVM('form').$refs['form']) { - crud.findVM('form').$refs['form'].clearValidate() + let form_ref = 'form' + if (crudFrom.form_ref) form_ref = crudFrom.form_ref + if (crud.findVM('form').$refs[form_ref]) { + crud.findVM('form').$refs[form_ref].clearValidate() } }, /**