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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cool-vue/crud": "^7.1.11",
|
||||
"@cool-vue/crud": "^7.1.12",
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"@vueuse/core": "^10.4.0",
|
||||
"@wangeditor/editor": "^5.1.23",
|
||||
@ -38,6 +38,7 @@
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/lodash-es": "^4.17.8",
|
||||
"@types/mockjs": "^1.0.7",
|
||||
"@types/node": "^20.5.6",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-vue/crud",
|
||||
"version": "7.1.11",
|
||||
"version": "7.1.12",
|
||||
"private": false,
|
||||
"main": "./dist/index.umd.min.js",
|
||||
"typings": "types/index.d.ts",
|
||||
|
@ -10,13 +10,18 @@ export function setFocus(prop?: string): ClForm.Plugin {
|
||||
|
||||
return ({ exposed, onOpen }) => {
|
||||
const name = prop || exposed.config.items[0].prop;
|
||||
let _ref: any;
|
||||
|
||||
if (name) {
|
||||
function deep(arr: ClForm.Item[]) {
|
||||
arr.forEach((e) => {
|
||||
if (e.prop == name && name) {
|
||||
if (e.component) {
|
||||
e.component.ref = setRefs(name);
|
||||
if (e.component.ref) {
|
||||
_ref = e.component.ref();
|
||||
} else {
|
||||
e.component.ref = setRefs(name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
deep(e.children || []);
|
||||
@ -27,6 +32,10 @@ export function setFocus(prop?: string): ClForm.Plugin {
|
||||
deep(exposed.config.items);
|
||||
|
||||
onOpen(() => {
|
||||
if (_ref) {
|
||||
refs[name] = _ref();
|
||||
}
|
||||
|
||||
refs[name]?.focus?.();
|
||||
});
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ import { useMitt } from "./mitt";
|
||||
|
||||
export function useRefs() {
|
||||
const refs = reactive<{ [key: string]: any }>({});
|
||||
|
||||
function setRefs(name: string) {
|
||||
return (el: any) => {
|
||||
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";
|
||||
|
||||
// 调试、自定义crud
|
||||
// import Crud, { locale } from "../../../packages/crud/src";
|
||||
// import Crud, { locale, setFocus } from "../../../packages/crud/src";
|
||||
// import "../../../packages/crud/src/static/index.scss";
|
||||
|
||||
export default (): Merge<ModuleConfig, CrudOptions> => {
|
||||
@ -13,8 +13,8 @@ export default (): Merge<ModuleConfig, CrudOptions> => {
|
||||
label: "CRUD",
|
||||
description: "快速增删改查及一系列辅助组件",
|
||||
author: "COOL",
|
||||
version: "7.1.11",
|
||||
updateTime: "2024-02-01",
|
||||
version: "7.1.12",
|
||||
updateTime: "2024-02-04",
|
||||
demo: "/demo/crud",
|
||||
|
||||
// 组件全注册
|
||||
|
Loading…
Reference in New Issue
Block a user