This commit is contained in:
icssoa 2023-11-27 00:12:18 +08:00
parent 0cec75dc6e
commit 31d65496e6
6 changed files with 39 additions and 27 deletions

View File

@ -9,7 +9,7 @@
"lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix" "lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix"
}, },
"dependencies": { "dependencies": {
"@cool-vue/crud": "^7.0.5", "@cool-vue/crud": "^7.0.6",
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.1.0",
"@vueuse/core": "^10.4.0", "@vueuse/core": "^10.4.0",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-vue/crud", "name": "@cool-vue/crud",
"version": "7.0.5", "version": "7.0.6",
"private": false, "private": false,
"main": "./dist/index.umd.min.js", "main": "./dist/index.umd.min.js",
"typings": "types/index.d.ts", "typings": "types/index.d.ts",

View File

@ -27,22 +27,32 @@ export function useTabs({ config, Form }: { config: ClForm.Config; Form: Vue.Ref
} }
// 查找分组 // 查找分组
function findGroup(list: ClForm.Item[], prop: string) { function toGroup(opts: { config: ClForm.Config; prop: string; refs: any }) {
let name; if (active.value) {
let name;
function deep(d: ClForm.Item) { // 查找标签上绑定的数据
if (d.prop == prop) { const el = opts.refs.form.querySelector(`[data-prop="${opts.prop}"]`);
name = d.group;
// 各自判断
if (el) {
name = el?.getAttribute("data-group");
} else { } else {
if (d.children) { function deep(d: ClForm.Item) {
d.children.forEach(deep); if (d.prop == opts.prop) {
name = d.group;
} else {
if (d.children) {
d.children.forEach(deep);
}
}
} }
config.items.forEach(deep);
} }
set(name);
} }
list.forEach(deep);
return name;
} }
// 获取参数 // 获取参数
@ -134,6 +144,6 @@ export function useTabs({ config, Form }: { config: ClForm.Config; Form: Vue.Ref
change, change,
clear, clear,
mergeProp, mergeProp,
findGroup toGroup
}; };
} }

View File

@ -181,14 +181,12 @@ export default defineComponent({
done(); done();
} }
} else { } else {
// 判断是否使用 cl-form-tabs切换到对应的选项卡 // 切换到对应的选项卡
if (Tabs.active.value) { Tabs.toGroup({
const group = Tabs.findGroup(config.items, Object.keys(error)[0]); refs,
config,
if (group) { prop: Object.keys(error)[0]
Tabs.set(group); });
}
}
} }
}); });
} }

View File

@ -12,5 +12,9 @@ export declare function useTabs({ config, Form }: {
change: (value: any, isValid?: boolean) => Promise<unknown>; change: (value: any, isValid?: boolean) => Promise<unknown>;
clear: () => void; clear: () => void;
mergeProp: (item: ClForm.Item) => void; mergeProp: (item: ClForm.Item) => void;
findGroup: (list: ClForm.Item[], prop: string) => undefined; toGroup: (opts: {
config: ClForm.Config;
prop: string;
refs: any;
}) => void;
}; };

View File

@ -295,10 +295,10 @@
mitt "^3.0.1" mitt "^3.0.1"
vue "^3.3.4" vue "^3.3.4"
"@cool-vue/crud@^7.0.5": "@cool-vue/crud@^7.0.6":
version "7.0.5" version "7.0.6"
resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.5.tgz#63cf8794241ec639ac802cc443d05d82ecf9c442" resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.6.tgz#32e49364dd3ded9d97d0551d1f381a6632d39f57"
integrity sha512-PWR/yeJh9EfhKDDiiK1bfrCUpY9vtIMTQ/MsLzaKnKsTTALisOfimvSxaA6dVS2jb9LsfhIKcB3WQinJnI/GIQ== integrity sha512-NQvsXPixIAynwjiTj0ivNjC8EOWq9ChHPJZHsvjJZrchTKyEajjUr14w4Q1OupZa/AKDN6SOGuNkY/Lj1dNHpg==
dependencies: dependencies:
"@cool-vue/crud" "^7.0.1-beta14" "@cool-vue/crud" "^7.0.1-beta14"
array.prototype.flat "^1.2.4" array.prototype.flat "^1.2.4"