Commit b7a9f8f2 by 潘际乾

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

parent c8cf2628
......@@ -160,27 +160,20 @@ export default class Utils {
// 顺序
for (let i = 0; i < formFields.length; i++) {
const field = formFields[i];
for (const key in fieldErrors) {
if (Object.hasOwnProperty.call(fieldErrors, key)) {
if (field.prop === key) {
const fieldError = fieldErrors[key];
field.validateState = 'error';
field.validateMessage = fieldError;
if (!firstErrorItem) {
firstErrorItem = field
}
break;
}
const fieldError = fieldErrors[field.prop];
if (fieldError) {
field.validateState = 'error';
field.validateMessage = fieldError;
if (!firstErrorItem) {
firstErrorItem = field
}
}
}
}
let firstErrorTab = null
let firstErrorTab = null, collapsePanel = null
if (firstErrorItem) {
let parentVC = firstErrorItem
while(!firstErrorTab) {
const tag = parentVC.$vnode.tag
const tagsArr = tag.split("-")
const vcName = tagsArr[tagsArr.length - 1]
const vcName = parentVC.$options.componentName
// 没有Tabs的表单
if (vcName === "ElForm") {
break;
......@@ -189,12 +182,18 @@ export default class Utils {
firstErrorTab = parentVC
break;
}
if (vcName === "ElCollapseItem") {
collapsePanel = parentVC;
}
parentVC = parentVC.$parent;
}
if (firstErrorTab) {
const tabs = firstErrorTab.$parent
tabs.value = firstErrorTab.name
}
if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
collapsePanel.collapse.activeNames.push(collapsePanel.name)
}
setTimeout(() => {
// 滚动到指定节点
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