mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
优化 crud 插件
This commit is contained in:
parent
64475d0e9c
commit
f119e4cc1d
@ -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.1.11",
|
"@cool-vue/crud": "^7.1.12",
|
||||||
"@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",
|
||||||
@ -38,6 +38,7 @@
|
|||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/lodash-es": "^4.17.8",
|
"@types/lodash-es": "^4.17.8",
|
||||||
"@types/mockjs": "^1.0.7",
|
"@types/mockjs": "^1.0.7",
|
||||||
"@types/node": "^20.5.6",
|
"@types/node": "^20.5.6",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-vue/crud",
|
"name": "@cool-vue/crud",
|
||||||
"version": "7.1.11",
|
"version": "7.1.12",
|
||||||
"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",
|
||||||
|
@ -10,14 +10,19 @@ export function setFocus(prop?: string): ClForm.Plugin {
|
|||||||
|
|
||||||
return ({ exposed, onOpen }) => {
|
return ({ exposed, onOpen }) => {
|
||||||
const name = prop || exposed.config.items[0].prop;
|
const name = prop || exposed.config.items[0].prop;
|
||||||
|
let _ref: any;
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
function deep(arr: ClForm.Item[]) {
|
function deep(arr: ClForm.Item[]) {
|
||||||
arr.forEach((e) => {
|
arr.forEach((e) => {
|
||||||
if (e.prop == name && name) {
|
if (e.prop == name && name) {
|
||||||
if (e.component) {
|
if (e.component) {
|
||||||
|
if (e.component.ref) {
|
||||||
|
_ref = e.component.ref();
|
||||||
|
} else {
|
||||||
e.component.ref = setRefs(name);
|
e.component.ref = setRefs(name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
deep(e.children || []);
|
deep(e.children || []);
|
||||||
}
|
}
|
||||||
@ -27,6 +32,10 @@ export function setFocus(prop?: string): ClForm.Plugin {
|
|||||||
deep(exposed.config.items);
|
deep(exposed.config.items);
|
||||||
|
|
||||||
onOpen(() => {
|
onOpen(() => {
|
||||||
|
if (_ref) {
|
||||||
|
refs[name] = _ref();
|
||||||
|
}
|
||||||
|
|
||||||
refs[name]?.focus?.();
|
refs[name]?.focus?.();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ import { useMitt } from "./mitt";
|
|||||||
|
|
||||||
export function useRefs() {
|
export function useRefs() {
|
||||||
const refs = reactive<{ [key: string]: any }>({});
|
const refs = reactive<{ [key: string]: any }>({});
|
||||||
|
|
||||||
function setRefs(name: string) {
|
function setRefs(name: string) {
|
||||||
return (el: any) => {
|
return (el: any) => {
|
||||||
refs[name] = el;
|
refs[name] = el;
|
||||||
|
return () => refs[name];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import Crud, { locale, setFocus } from "@cool-vue/crud";
|
|||||||
import "@cool-vue/crud/dist/index.css";
|
import "@cool-vue/crud/dist/index.css";
|
||||||
|
|
||||||
// 调试、自定义crud
|
// 调试、自定义crud
|
||||||
// import Crud, { locale } from "../../../packages/crud/src";
|
// import Crud, { locale, setFocus } from "../../../packages/crud/src";
|
||||||
// import "../../../packages/crud/src/static/index.scss";
|
// import "../../../packages/crud/src/static/index.scss";
|
||||||
|
|
||||||
export default (): Merge<ModuleConfig, CrudOptions> => {
|
export default (): Merge<ModuleConfig, CrudOptions> => {
|
||||||
@ -13,8 +13,8 @@ export default (): Merge<ModuleConfig, CrudOptions> => {
|
|||||||
label: "CRUD",
|
label: "CRUD",
|
||||||
description: "快速增删改查及一系列辅助组件",
|
description: "快速增删改查及一系列辅助组件",
|
||||||
author: "COOL",
|
author: "COOL",
|
||||||
version: "7.1.11",
|
version: "7.1.12",
|
||||||
updateTime: "2024-02-01",
|
updateTime: "2024-02-04",
|
||||||
demo: "/demo/crud",
|
demo: "/demo/crud",
|
||||||
|
|
||||||
// 组件全注册
|
// 组件全注册
|
||||||
|
Loading…
Reference in New Issue
Block a user