Commit b7a9f8f2 by 潘际乾

checkAll之后的错误提示信息定位

parent c8cf2628
...@@ -160,27 +160,20 @@ export default class Utils { ...@@ -160,27 +160,20 @@ export default class Utils {
// 顺序 // 顺序
for (let i = 0; i < formFields.length; i++) { for (let i = 0; i < formFields.length; i++) {
const field = formFields[i]; const field = formFields[i];
for (const key in fieldErrors) { const fieldError = fieldErrors[field.prop];
if (Object.hasOwnProperty.call(fieldErrors, key)) { if (fieldError) {
if (field.prop === key) { field.validateState = 'error';
const fieldError = fieldErrors[key]; field.validateMessage = fieldError;
field.validateState = 'error'; if (!firstErrorItem) {
field.validateMessage = fieldError; firstErrorItem = field
if (!firstErrorItem) {
firstErrorItem = field
}
break;
}
} }
} }
} }
let firstErrorTab = null let firstErrorTab = null, collapsePanel = null
if (firstErrorItem) { if (firstErrorItem) {
let parentVC = firstErrorItem let parentVC = firstErrorItem
while(!firstErrorTab) { while(!firstErrorTab) {
const tag = parentVC.$vnode.tag const vcName = parentVC.$options.componentName
const tagsArr = tag.split("-")
const vcName = tagsArr[tagsArr.length - 1]
// 没有Tabs的表单 // 没有Tabs的表单
if (vcName === "ElForm") { if (vcName === "ElForm") {
break; break;
...@@ -189,12 +182,18 @@ export default class Utils { ...@@ -189,12 +182,18 @@ export default class Utils {
firstErrorTab = parentVC firstErrorTab = parentVC
break; break;
} }
if (vcName === "ElCollapseItem") {
collapsePanel = parentVC;
}
parentVC = parentVC.$parent; parentVC = parentVC.$parent;
} }
if (firstErrorTab) { if (firstErrorTab) {
const tabs = firstErrorTab.$parent const tabs = firstErrorTab.$parent
tabs.value = firstErrorTab.name tabs.value = firstErrorTab.name
} }
if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
collapsePanel.collapse.activeNames.push(collapsePanel.name)
}
setTimeout(() => { setTimeout(() => {
// 滚动到指定节点 // 滚动到指定节点
firstErrorItem.$el.scrollIntoView({ firstErrorItem.$el.scrollIntoView({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment