diff --git a/src/modules/demo/views/crud/components/form/setFocus.vue b/src/modules/demo/views/crud/components/form/setFocus.vue
new file mode 100644
index 0000000..467e039
--- /dev/null
+++ b/src/modules/demo/views/crud/components/form/setFocus.vue
@@ -0,0 +1,63 @@
+
+
# {{ b.label }}
@@ -55,6 +64,7 @@ import FormCrud from './components/form/crud.vue'; import FormRules from './components/form/rules.vue'; import FormComponent from './components/form/component/index.vue'; import FormPlugin from './components/form/plugin/index.vue'; +import FormSetFocus from './components/form/setFocus.vue'; import TableBase from './components/table/base.vue'; import TableFormatter from './components/table/formatter.vue'; @@ -139,19 +149,6 @@ const list = [ } ] }, - { - title: 'cl-upsert', - children: [ - { - label: '基础', - children: [UpsertBase, UpsertEvent, UpsertMode] - }, - { - label: '高级', - children: [UpsertHook] - } - ] - }, { title: 'cl-form', children: [ @@ -177,7 +174,20 @@ const list = [ }, { label: '插件', - children: [FormPlugin] + children: [FormPlugin, FormSetFocus] + } + ] + }, + { + title: 'cl-upsert', + children: [ + { + label: '基础', + children: [UpsertBase, UpsertEvent, UpsertMode] + }, + { + label: '高级', + children: [UpsertHook] } ] }, diff --git a/src/plugins/crud/plugins/form/setFocus.ts b/src/plugins/crud/plugins/form/setFocus.ts index c8b30da..7cd9544 100644 --- a/src/plugins/crud/plugins/form/setFocus.ts +++ b/src/plugins/crud/plugins/form/setFocus.ts @@ -2,13 +2,17 @@ import { useRefs } from '/@/cool'; /** * 设置聚焦,prop为空则默认第一个选项 - * @param prop + * @param prop 字段标识 * @returns */ export function setFocus(prop?: string): ClForm.Plugin { const { refs, setRefs } = useRefs(); return ({ exposed, onOpen }) => { + if (prop === '') { + return; + } + const name = prop || exposed.config?.items?.[0]?.prop; let _ref: any;