@veltra/desktop 1.1.27 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/action/action-group.vue.d.ts +3 -3
- package/dist/components/action/action.vue.d.ts +2 -2
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.vue.d.ts +2 -2
- package/dist/components/batch-edit/di.js.map +1 -1
- package/dist/components/cascade/cascade.vue.d.ts +5 -5
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +1 -1
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +1 -1
- package/dist/components/form/form-model.d.ts +8 -8
- package/dist/components/form/form-model.js +2 -2
- package/dist/components/form/form-model.js.map +1 -1
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +5 -5
- package/dist/components/notification/notification.vue.d.ts +1 -1
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/pop-confirm/pop-confirm.vue.d.ts +1 -1
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/tabs/tabs-horizontal.vue.d.ts +1 -1
- package/dist/components/tabs/tabs.vue.d.ts +1 -1
- package/dist/components/textarea/textarea.vue.d.ts +3 -3
- package/dist/components/tip/tip.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +5 -5
- package/dist/types/form.d.ts +7 -7
- package/package.json +6 -6
- package/src/components/batch-edit/batch-edit.vue +2 -2
- package/src/components/batch-edit/di.ts +2 -2
- package/src/components/form/form-model.ts +16 -20
- package/src/types/form.ts +7 -7
|
@@ -8,11 +8,11 @@ type __VLS_Slots = {
|
|
|
8
8
|
default?: () => VNode[];
|
|
9
9
|
};
|
|
10
10
|
declare const __VLS_base: _$vue.DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
|
|
11
|
-
size: "small" | "default" | "large";
|
|
12
11
|
type: _$_veltra_utils0.ColorType;
|
|
13
|
-
|
|
14
|
-
max: number;
|
|
12
|
+
size: "small" | "default" | "large";
|
|
15
13
|
text: boolean;
|
|
14
|
+
max: number;
|
|
15
|
+
circle: boolean;
|
|
16
16
|
loading: boolean;
|
|
17
17
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -15,10 +15,10 @@ declare const __VLS_base: _$vue.DefineComponent<ActionProps, {}, {}, {}, {}, _$v
|
|
|
15
15
|
}, string, _$vue.PublicProps, Readonly<ActionProps> & Readonly<{
|
|
16
16
|
onRun?: (() => any) | undefined;
|
|
17
17
|
}>, {
|
|
18
|
-
size: _$_veltra_utils0.ComponentSize;
|
|
19
18
|
type: ButtonType;
|
|
20
|
-
|
|
19
|
+
size: _$_veltra_utils0.ComponentSize;
|
|
21
20
|
text: boolean;
|
|
21
|
+
circle: boolean;
|
|
22
22
|
loading: boolean;
|
|
23
23
|
inDropdown: boolean;
|
|
24
24
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr)\"\n gap=\"8px\"\n resizable\n @keydown=\"handleKeydown\"\n tabindex=\"-1\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm v-slot=\"scoped\">\n <!-- @vue-ignore -->\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup generic=\"Model extends
|
|
1
|
+
{"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr)\"\n gap=\"8px\"\n resizable\n @keydown=\"handleKeydown\"\n tabindex=\"-1\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm v-slot=\"scoped\">\n <!-- @vue-ignore -->\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup generic=\"Model extends IFormModel\">\nimport { bem } from '@veltra/utils'\nimport { computed, inject, provide, shallowRef, watch } from 'vue'\n\nimport type {\n BatchEditEmits,\n BatchEditFeature,\n BatchEditProps,\n IFormModel,\n TableColumnSlotsScope,\n TableExposed,\n TableRow\n} from '../../types'\nimport { DialogDIKey } from '../dialog/di'\nimport { ULayout } from '../layout'\nimport BatchEditForm from './batch-edit-form.vue'\nimport BatchEditList from './batch-edit-list.vue'\nimport { BatchEditDIKey } from './di'\nimport { useEdit } from './use-edit'\n\ndefineOptions({ name: 'BatchEdit' })\n\nconst props = withDefaults(defineProps<BatchEditProps<Model>>(), {\n cols: () => ['1fr', '420px'],\n mode: 'normal'\n})\n\nconst emit = defineEmits<BatchEditEmits>()\n\nconst staticFeatures = computed(() => {\n const { features } = props\n\n if (Array.isArray(features)) {\n return new Set(features)\n }\n\n const defaultFeatures = new Set<BatchEditFeature>(['create', 'delete', 'update', 'createChild'])\n\n if (!features) {\n return defaultFeatures\n }\n\n // 函数与 false 的特性视为关闭;显式 true 视为开启(即便不在默认集合内)\n Object.entries(features).forEach(([key, value]) => {\n const k = key as BatchEditFeature\n if (typeof value === 'function' || value === false) {\n defaultFeatures.delete(k)\n } else if (value === true) {\n defaultFeatures.add(k)\n }\n })\n return defaultFeatures\n})\n\nconst dynamicFeatures = computed<\n Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n>(() => {\n const { features } = props\n if (!Array.isArray(features) && typeof features === 'object') {\n const ret = Object.entries(features)\n .filter(([_, value]) => {\n return typeof value === 'function'\n })\n .reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {} as Record<BatchEditFeature, (row?: TableRow) => boolean>\n )\n return ret\n }\n\n return {} as Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n})\n\nconst slots = defineSlots<\n {\n form?: (props: {\n /** 表单数据 */\n data: Model['data']\n /** 表单模型 */\n model: Model\n /** 当前编辑的层级 */\n depth?: number\n /** 当前编辑的行 */\n row?: TableRow\n /** 当前编辑的行索引 */\n index?: number\n /** 操作的目标行索引路径 */\n indexes?: number[]\n }) => any\n\n header?: () => any\n } & Partial<{ [key: `column:${string}`]: (props: TableColumnSlotsScope) => any }>\n>()\n\nconst cls = bem('batch-edit')\n\nconst tableRef = shallowRef<TableExposed>()\n\nconst editCtx = useEdit({ props, emit, tableRef })\n\nconst { state, handleClose, handleSave, handleDelete, handleCreate } = editCtx\n\nprovide(BatchEditDIKey, { cls, props, emit, tableRef, staticFeatures, dynamicFeatures, ...editCtx })\n\nconst dialogCtx = inject(DialogDIKey, undefined)\n\ndialogCtx &&\n watch(dialogCtx.visible, (visible) => {\n !visible && editCtx.handleClose()\n })\n\nconst cols = computed(() => {\n return !!state.row || state.visible ? props.cols : undefined\n})\n\n/**\n * 键盘快捷键:\n * - Esc 关闭表单\n * - ⌘/Ctrl + S 保存\n * - ⌘/Ctrl + Backspace 删除当前编辑行\n * - ⌘/Ctrl + N 新增(仅在不在表单中时)\n */\nfunction handleKeydown(e: KeyboardEvent) {\n if (props.readonly && e.key !== 'Escape') return\n\n if (e.key === 'Escape') {\n if (state.visible) {\n e.preventDefault()\n handleClose()\n }\n return\n }\n\n const meta = e.metaKey || e.ctrlKey\n if (!meta) return\n\n const key = e.key.toLowerCase()\n\n if (key === 's' && state.visible) {\n e.preventDefault()\n handleSave()\n return\n }\n\n if (e.key === 'Backspace' && state.row && state.type === 'update') {\n e.preventDefault()\n handleDelete(state.row)\n return\n }\n\n if (key === 'n' && !state.visible) {\n e.preventDefault()\n handleCreate()\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAKd,MAAM,OAAO;EAEb,MAAM,iBAAiB,eAAe;GACpC,MAAM,EAAE,aAAa;GAErB,IAAI,MAAM,QAAQ,SAAQ,EACxB,OAAO,IAAI,IAAI,SAAQ;GAGzB,MAAM,kBAAkB,IAAI,IAAsB;IAAC;IAAU;IAAU;IAAU;IAAc,CAAA;GAE/F,IAAI,CAAC,UACH,OAAO;GAIT,OAAO,QAAQ,SAAQ,CAAE,SAAS,CAAC,KAAK,WAAW;IACjD,MAAM,IAAI;IACV,IAAI,OAAO,UAAU,cAAc,UAAU,OAC3C,gBAAgB,OAAO,EAAC;SACnB,IAAI,UAAU,MACnB,gBAAgB,IAAI,EAAC;KAExB;GACD,OAAO;IACR;EAED,MAAM,kBAAkB,eAEhB;GACN,MAAM,EAAE,aAAa;GACrB,IAAI,CAAC,MAAM,QAAQ,SAAQ,IAAK,OAAO,aAAa,UAYlD,OAXY,OAAO,QAAQ,SAAQ,CAChC,QAAQ,CAAC,GAAG,WAAW;IACtB,OAAO,OAAO,UAAU;KACzB,CACA,QACE,KAAK,CAAC,KAAK,WAAW;IACrB,IAAI,OAAO;IACX,OAAO;MAET,EACF,CACK;GAGT,OAAO,EAAC;IACT;EAED,MAAM,QAAQ,UAAA;EAqBd,MAAM,MAAM,IAAI,aAAY;EAE5B,MAAM,WAAW,YAAyB;EAE1C,MAAM,UAAU,QAAQ;GAAE;GAAO;GAAM;GAAU,CAAA;EAEjD,MAAM,EAAE,OAAO,aAA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|
|
|
1
|
+
import { IFormModel } from "../../types/form.js";
|
|
1
2
|
import { TableColumn, TableColumnSlotsScope, TableRow } from "../../types/table.js";
|
|
2
3
|
import { BatchEditEmits, BatchEditProps } from "../../types/batch-edit.js";
|
|
3
|
-
import { FormModel } from "../form/form-model.js";
|
|
4
4
|
import * as _$vue from "vue";
|
|
5
5
|
import * as _$_cat_kit_core0 from "@cat-kit/core";
|
|
6
6
|
|
|
7
7
|
//#region src/components/batch-edit/batch-edit.vue.d.ts
|
|
8
|
-
declare const __VLS_export: <Model extends
|
|
8
|
+
declare const __VLS_export: <Model extends IFormModel>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
9
9
|
props: _$vue.PublicProps & __VLS_PrettifyLocal<BatchEditProps<Model> & {
|
|
10
10
|
"onUpdate:selected"?: ((value: Record<string, any> | undefined) => any) | undefined;
|
|
11
11
|
"onUpdate:checked"?: ((value: Record<string, any>[]) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.js","names":[],"sources":["../../../src/components/batch-edit/di.ts"],"sourcesContent":["import type { BEM } from '@veltra/utils'\nimport type { ComputedRef, InjectionKey, ShallowRef } from 'vue'\n\nimport type {\n BatchEditEmits,\n BatchEditFeature,\n BatchEditProps,\n TableExposed,\n TableRow\n} from '../../types'\nimport type {
|
|
1
|
+
{"version":3,"file":"di.js","names":[],"sources":["../../../src/components/batch-edit/di.ts"],"sourcesContent":["import type { BEM } from '@veltra/utils'\nimport type { ComputedRef, InjectionKey, ShallowRef } from 'vue'\n\nimport type {\n BatchEditEmits,\n BatchEditFeature,\n BatchEditProps,\n IFormModel,\n TableExposed,\n TableRow\n} from '../../types'\nimport type { EditReturned } from './use-edit'\nexport const BatchEditDIKey: InjectionKey<\n {\n cls: BEM<'batch-edit', 'u-'>\n props: BatchEditProps<IFormModel>\n emit: BatchEditEmits\n tableRef: ShallowRef<TableExposed | undefined>\n staticFeatures: ComputedRef<Set<BatchEditFeature>>\n dynamicFeatures: ComputedRef<\n Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n >\n } & EditReturned\n> = Symbol('BatchEditDIKey')\n"],"mappings":";AAYA,MAAa,iBAWT,OAAO,iBAAiB"}
|
|
@@ -4,24 +4,24 @@ import * as _$vue from "vue";
|
|
|
4
4
|
//#region src/components/cascade/cascade.vue.d.ts
|
|
5
5
|
declare const __VLS_export: _$vue.DefineComponent<CascadeProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {} & {
|
|
6
6
|
"update:modelValue": (value?: string | string[] | undefined) => any;
|
|
7
|
-
change: (...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any;
|
|
8
7
|
clear: () => any;
|
|
8
|
+
change: (...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any;
|
|
9
9
|
}, string, _$vue.PublicProps, Readonly<CascadeProps> & Readonly<{
|
|
10
10
|
"onUpdate:modelValue"?: ((value?: string | string[] | undefined) => any) | undefined;
|
|
11
|
-
onChange?: ((...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any) | undefined;
|
|
12
11
|
onClear?: (() => any) | undefined;
|
|
12
|
+
onChange?: ((...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any) | undefined;
|
|
13
13
|
}>, {
|
|
14
14
|
disabled: boolean;
|
|
15
15
|
readonly: boolean;
|
|
16
|
+
placeholder: string;
|
|
17
|
+
clearable: boolean;
|
|
16
18
|
labelKey: string;
|
|
17
19
|
valueKey: string;
|
|
18
20
|
childrenKey: string;
|
|
19
21
|
data: Record<string, any>[];
|
|
20
|
-
placeholder: string;
|
|
21
|
-
clearable: boolean;
|
|
22
|
-
separator: string;
|
|
23
22
|
filterable: boolean;
|
|
24
23
|
visibilityLimit: number;
|
|
24
|
+
separator: string;
|
|
25
25
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
26
26
|
declare const _default: typeof __VLS_export;
|
|
27
27
|
//#endregion
|
|
@@ -20,9 +20,9 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
20
20
|
"onUpdate:modelValue"?: ((checked: boolean) => any) | undefined;
|
|
21
21
|
onChange?: ((checked: boolean) => any) | undefined;
|
|
22
22
|
}>, {
|
|
23
|
+
type: _$_veltra_utils0.ColorType;
|
|
23
24
|
disabled: boolean;
|
|
24
25
|
readonly: boolean;
|
|
25
|
-
type: _$_veltra_utils0.ColorType;
|
|
26
26
|
round: boolean;
|
|
27
27
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
28
28
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -11,8 +11,8 @@ declare const __VLS_export: _$vue.DefineComponent<DatePanelProps, {}, {}, {}, {}
|
|
|
11
11
|
"onSelect:range-date"?: ((rangeDate?: [_$_cat_kit_core0.Dater, _$_cat_kit_core0.Dater] | undefined) => any) | undefined;
|
|
12
12
|
"onSelect:date"?: ((date: _$_cat_kit_core0.Dater) => any) | undefined;
|
|
13
13
|
}>, {
|
|
14
|
-
size: _$_veltra_utils0.ComponentSize;
|
|
15
14
|
type: "date" | "month" | "year";
|
|
15
|
+
size: _$_veltra_utils0.ComponentSize;
|
|
16
16
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
17
17
|
declare const _default: typeof __VLS_export;
|
|
18
18
|
//#endregion
|
|
@@ -7,9 +7,9 @@ declare const __VLS_export: _$vue.DefineComponent<DatePickerProps, {}, {}, {}, {
|
|
|
7
7
|
}, string, _$vue.PublicProps, Readonly<DatePickerProps> & Readonly<{
|
|
8
8
|
"onUpdate:modelValue"?: ((value?: string | number | Date | undefined) => any) | undefined;
|
|
9
9
|
}>, {
|
|
10
|
+
type: "date" | "month" | "year";
|
|
10
11
|
disabled: boolean;
|
|
11
12
|
readonly: boolean;
|
|
12
|
-
type: "date" | "month" | "year";
|
|
13
13
|
placeholder: string;
|
|
14
14
|
clearable: boolean;
|
|
15
15
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
@@ -7,9 +7,9 @@ declare const __VLS_export: _$vue.DefineComponent<DateRangePickerProps, {}, {},
|
|
|
7
7
|
}, string, _$vue.PublicProps, Readonly<DateRangePickerProps> & Readonly<{
|
|
8
8
|
"onUpdate:modelValue"?: ((value?: [string, string] | undefined) => any) | undefined;
|
|
9
9
|
}>, {
|
|
10
|
+
type: "date" | "month" | "year";
|
|
10
11
|
disabled: boolean;
|
|
11
12
|
readonly: boolean;
|
|
12
|
-
type: "date" | "month" | "year";
|
|
13
13
|
placeholder: [string, string];
|
|
14
14
|
clearable: boolean;
|
|
15
15
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataSettingConfig, FormModelField, IFormModel, ModelData } from "../../types/form.js";
|
|
2
2
|
import { Reactive } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/form/form-model.d.ts
|
|
@@ -17,10 +17,10 @@ declare class FormModel<Fields extends Record<string, FormModelField> = Record<s
|
|
|
17
17
|
* @description
|
|
18
18
|
* 这个值会在表单组件渲染时由表单设置,因为只有真正渲染的组件才应该被校验
|
|
19
19
|
*/
|
|
20
|
-
formKeys: Map<number,
|
|
20
|
+
formKeys: Map<number, string[]>;
|
|
21
21
|
/** 初始数据 */
|
|
22
22
|
readonly initialData: ModelData<Fields>;
|
|
23
|
-
readonly errors: Map<
|
|
23
|
+
readonly errors: Map<string, string[] | undefined>;
|
|
24
24
|
private validator;
|
|
25
25
|
/**
|
|
26
26
|
* 是否在表单值更新时校验
|
|
@@ -40,18 +40,18 @@ declare class FormModel<Fields extends Record<string, FormModelField> = Record<s
|
|
|
40
40
|
* @param fields 需要校验的字段, 不传则校验所有字段
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
|
-
validate(fields?:
|
|
43
|
+
validate(fields?: string | string[]): Promise<boolean>;
|
|
44
44
|
/**
|
|
45
45
|
* 重置数据
|
|
46
46
|
* @param fields 需要重置的字段
|
|
47
47
|
*/
|
|
48
|
-
resetData(keys?:
|
|
48
|
+
resetData(keys?: string | string[]): void;
|
|
49
49
|
/**
|
|
50
50
|
* 设置值
|
|
51
51
|
* @param formData 表单值
|
|
52
52
|
* @param options 配置
|
|
53
53
|
*/
|
|
54
|
-
setData(formData: Partial<
|
|
54
|
+
setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): FormModel<Fields>;
|
|
55
55
|
/**
|
|
56
56
|
* 设置初始值
|
|
57
57
|
* @description 初始值在重置数据和查看原始数据时会用到
|
|
@@ -64,9 +64,9 @@ declare class FormModel<Fields extends Record<string, FormModelField> = Record<s
|
|
|
64
64
|
* 监听值变更
|
|
65
65
|
* @param cb 回调
|
|
66
66
|
*/
|
|
67
|
-
onChange(cb: (field:
|
|
67
|
+
onChange(cb: (field: string, val: any) => void): void;
|
|
68
68
|
/** 关闭监听值变更 */
|
|
69
|
-
offChange(cb: (field:
|
|
69
|
+
offChange(cb: (field: string, val: any) => void): void;
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
export { FormModel };
|
|
@@ -87,8 +87,8 @@ var FormModel = class {
|
|
|
87
87
|
getValidateFields(fields) {
|
|
88
88
|
if (!fields) if (this.formKeys.size) {
|
|
89
89
|
let _fields = [];
|
|
90
|
-
this.formKeys.forEach((
|
|
91
|
-
_fields = _fields.concat(
|
|
90
|
+
this.formKeys.forEach((keys) => {
|
|
91
|
+
_fields = _fields.concat(keys);
|
|
92
92
|
});
|
|
93
93
|
return _fields;
|
|
94
94
|
} else return this.allKeys;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-model.js","names":[],"sources":["../../../src/components/form/form-model.ts"],"sourcesContent":["import { o } from '@cat-kit/core'\nimport { middleProxy, Validator } from '@veltra/utils'\nimport { nextTick, reactive, shallowReactive, watch, type Reactive } from 'vue'\n\nimport type {\n ModelData,\n DataSettingConfig,\n IFormModel,\n
|
|
1
|
+
{"version":3,"file":"form-model.js","names":[],"sources":["../../../src/components/form/form-model.ts"],"sourcesContent":["import { o } from '@cat-kit/core'\nimport { middleProxy, Validator } from '@veltra/utils'\nimport { nextTick, reactive, shallowReactive, watch, type Reactive } from 'vue'\n\nimport type {\n ModelData,\n DataSettingConfig,\n IFormModel,\n FormModelItem,\n FormModelField\n} from '../../types'\n\n/**\n * 递归展平字段逻辑\n */\nfunction flattenFields(fields: Record<string, any>, prefix = ''): Record<string, FormModelItem> {\n const result: Record<string, FormModelItem> = {}\n for (const key in fields) {\n const item = fields[key]\n const fullPath = prefix ? `${prefix}.${key}` : key\n if (item && typeof item === 'object' && '__isNested' in item && item.__isNested) {\n Object.assign(result, flattenFields((item as any).fields, fullPath))\n } else {\n result[fullPath] = item\n }\n }\n return result\n}\n\n/**\n * 表单模型\n */\nexport class FormModel<\n Fields extends Record<string, FormModelField> = Record<string, FormModelField>\n> implements IFormModel<Fields> {\n /** 表单数据 */\n data!: ModelData<Fields>\n\n /** 表单规则 */\n readonly fields: Fields\n\n /** 所有的键 */\n readonly allKeys: string[]\n\n /**\n * 不同表单所需要校验的字段\n * @description\n * 这个值会在表单组件渲染时由表单设置,因为只有真正渲染的组件才应该被校验\n */\n formKeys: Map<number, string[]> = new Map()\n\n /** 初始数据 */\n readonly initialData: ModelData<Fields>\n\n readonly errors: Map<string, string[] | undefined> = shallowReactive(new Map())\n\n private validator: Validator<Record<string, FormModelItem>>\n\n /**\n * 是否在表单值更新时校验\n */\n private validateOnFieldChange = true\n\n private modelChangeCallback: Set<(fields: string, val: any) => void> = new Set()\n\n constructor(fields: Fields) {\n this.fields = fields\n const flatFields = flattenFields(fields)\n const rawData = {} as ModelData<Fields>\n const allKeys: string[] = []\n\n for (const key in flatFields) {\n const fieldItem = flatFields[key]!\n allKeys.push(key)\n const { value } = fieldItem\n let v = value\n\n if (typeof value === 'function') {\n watch(value, (v) => {\n o(this.initialData).set(key, v)\n })\n v = value()\n }\n\n o(rawData).set(key, v)\n }\n\n this.allKeys = allKeys\n this.initialData = JSON.parse(JSON.stringify(rawData))\n\n this.setProxyData(reactive(rawData))\n\n this.validator = new Validator(flatFields)\n\n return shallowReactive(this)\n }\n\n /**\n * 设置响应式值, 替换掉原有的数据\n * @description 设置响应式值时,会自动监听值的变化,并进行校验\n * @param proxyData 响应式的值\n */\n setProxyData(proxyData: ModelData<Fields> | Reactive<ModelData<Fields>>): void {\n const data = middleProxy(proxyData, {\n set: (field, val) => {\n this.modelChangeCallback.forEach((cb) => cb(field, val))\n },\n\n changed: (fields) => {\n if (!this.validateOnFieldChange) {\n this.validateOnFieldChange = true\n return\n }\n this.validate(fields as any)\n }\n })\n\n this.data = data as ModelData<Fields>\n }\n\n private getValidateFields(fields?: string | string[]) {\n if (!fields) {\n if (this.formKeys.size) {\n let _fields: string[] = []\n this.formKeys.forEach((keys) => {\n _fields = _fields.concat(keys)\n })\n return _fields\n } else {\n return this.allKeys\n }\n }\n\n if (!Array.isArray(fields)) {\n return [fields]\n }\n return fields\n }\n\n /**\n * 模型校验\n * @param fields 需要校验的字段, 不传则校验所有字段\n * @returns\n */\n async validate(fields?: string | string[]): Promise<boolean> {\n const { errors, validator, data } = this\n\n const results = await validator.validate(data, this.getValidateFields(fields))\n\n // 全量校验\n if (!fields) {\n errors.clear()\n\n for (const field in results) {\n errors.set(field as any, results[field])\n }\n }\n // 局部校验\n else {\n ~(Array.isArray(fields) ? fields : [fields]).forEach((field) => {\n const errs = results[field as string]\n if (errs?.length) {\n errors.set(field, errs)\n } else {\n errors.delete(field)\n }\n })\n }\n\n if (errors.size > 0) {\n if (!fields) {\n nextTick(() => {\n document.querySelector('.u-form-item.is-error')?.scrollIntoView({ block: 'nearest' })\n })\n }\n return Promise.reject(false)\n }\n\n return true\n }\n\n /**\n * 重置数据\n * @param fields 需要重置的字段\n */\n resetData(keys?: string | string[]): void {\n if (typeof keys === 'string') {\n keys = [keys]\n } else if (Array.isArray(keys)) {\n } else {\n keys = this.allKeys\n }\n\n this.clearValidate()\n\n this.validateOnFieldChange = false\n\n keys.forEach((field) => {\n o(this.data).set(field as string, o(this.initialData).get(field as string))\n })\n }\n\n /**\n * 设置值\n * @param formData 表单值\n * @param options 配置\n */\n setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): FormModel<Fields> {\n const { validate = true } = config || {}\n\n if (!validate) {\n this.validateOnFieldChange = false\n }\n\n this.allKeys.forEach((key) => {\n const value = o(formData).get(key)\n if (value !== undefined) {\n o(this.data).set(key, value)\n }\n })\n\n return this\n }\n\n /**\n * 设置初始值\n * @description 初始值在重置数据和查看原始数据时会用到\n * @param data 初始值\n */\n setInitialData(data: Partial<ModelData<Fields>>): FormModel<Fields> {\n this.allKeys.forEach((key) => {\n o(this.initialData).set(key, o(data).get(key))\n })\n\n return this\n }\n\n /** 清除校验 */\n clearValidate(): void {\n this.errors.clear()\n }\n\n /**\n * 监听值变更\n * @param cb 回调\n */\n onChange(cb: (field: string, val: any) => void): void {\n this.modelChangeCallback.add(cb)\n }\n\n /** 关闭监听值变更 */\n offChange(cb: (field: string, val: any) => void): void {\n this.modelChangeCallback.delete(cb)\n }\n}\n"],"mappings":";;;;;;;AAeA,SAAS,cAAc,QAA6B,SAAS,IAAmC;CAC9F,MAAM,SAAwC,EAAE;CAChD,KAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,OAAO,OAAO;EACpB,MAAM,WAAW,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AAS,UAAU,EAAE;EAExC,IAAI,CAAC,UACH,KAAK,wBAAwB;EAG/B,KAAK,QAAQ,SAAS,QAAQ;GAC5B,MAAM,QAAQ,EAAE,SAAS,CAAC,IAAI,IAAI;GAClC,IAAI,UAAU,KAAA,GACZ,EAAE,KAAK,KAAK,CAAC,IAAI,KAAK,MAAM;IAE9B;EAEF,OAAO;;;;;;;CAQT,eAAe,MAAqD;EAClE,KAAK,QAAQ,SAAS,QAAQ;GAC5B,EAAE,KAAK,YAAY,CAAC,IAAI,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;IAC9C;EAEF,OAAO;;;CAIT,gBAAsB;EACpB,KAAK,OAAO,OAAO;;;;;;CAOrB,SAAS,IAA6C;EACpD,KAAK,oBAAoB,IAAI,GAAG;;;CAIlC,UAAU,IAA6C;EACrD,KAAK,oBAAoB,OAAO,GAAG"}
|
|
@@ -17,20 +17,20 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, _InputExposed
|
|
|
17
17
|
"update:modelValue": (value: string | undefined) => any;
|
|
18
18
|
} & {
|
|
19
19
|
"update:modelValue": (value: string) => any;
|
|
20
|
+
clear: () => any;
|
|
20
21
|
change: (value: string) => any;
|
|
21
22
|
"suffix:click": (value?: string | undefined) => any;
|
|
22
23
|
"prefix:click": (value?: string | undefined) => any;
|
|
23
24
|
focus: (value?: string | undefined) => any;
|
|
24
|
-
clear: () => any;
|
|
25
25
|
blur: (value?: string | undefined) => any;
|
|
26
26
|
"native:input": (ev: Event) => any;
|
|
27
27
|
}, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
28
28
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
29
|
+
onClear?: (() => any) | undefined;
|
|
29
30
|
onChange?: ((value: string) => any) | undefined;
|
|
30
31
|
"onSuffix:click"?: ((value?: string | undefined) => any) | undefined;
|
|
31
32
|
"onPrefix:click"?: ((value?: string | undefined) => any) | undefined;
|
|
32
33
|
onFocus?: ((value?: string | undefined) => any) | undefined;
|
|
33
|
-
onClear?: (() => any) | undefined;
|
|
34
34
|
onBlur?: ((value?: string | undefined) => any) | undefined;
|
|
35
35
|
"onNative:input"?: ((ev: Event) => any) | undefined;
|
|
36
36
|
}>, {
|
|
@@ -30,11 +30,11 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
30
30
|
}>, {
|
|
31
31
|
disabled: boolean;
|
|
32
32
|
readonly: boolean;
|
|
33
|
-
labelKey: string;
|
|
34
|
-
valueKey: string;
|
|
35
|
-
minWidth: string;
|
|
36
33
|
placeholder: string;
|
|
37
34
|
clearable: boolean;
|
|
35
|
+
minWidth: string;
|
|
36
|
+
labelKey: string;
|
|
37
|
+
valueKey: string;
|
|
38
38
|
visibilityLimit: number;
|
|
39
39
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
40
40
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -15,21 +15,21 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
15
15
|
"update:modelValue": (value: (string | number)[]) => any;
|
|
16
16
|
} & {
|
|
17
17
|
"update:modelValue": (value: any[]) => any;
|
|
18
|
-
change: (checked: Record<string, any>[]) => any;
|
|
19
18
|
clear: () => any;
|
|
19
|
+
change: (checked: Record<string, any>[]) => any;
|
|
20
20
|
}, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
|
|
22
|
-
onChange?: ((checked: Record<string, any>[]) => any) | undefined;
|
|
23
22
|
onClear?: (() => any) | undefined;
|
|
23
|
+
onChange?: ((checked: Record<string, any>[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
disabled: boolean;
|
|
26
26
|
readonly: boolean;
|
|
27
|
+
placeholder: string;
|
|
28
|
+
clearable: boolean;
|
|
29
|
+
minWidth: string;
|
|
27
30
|
expandAll: boolean;
|
|
28
31
|
labelKey: string;
|
|
29
32
|
valueKey: string;
|
|
30
|
-
minWidth: string;
|
|
31
|
-
placeholder: string;
|
|
32
|
-
clearable: boolean;
|
|
33
33
|
filterable: boolean;
|
|
34
34
|
visibilityLimit: number;
|
|
35
35
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
@@ -4,9 +4,9 @@ import * as _$_veltra_utils0 from "@veltra/utils";
|
|
|
4
4
|
|
|
5
5
|
//#region src/components/notification/notification.vue.d.ts
|
|
6
6
|
declare const __VLS_export: _$vue.DefineComponent<NotificationProps, _$_veltra_utils0.DeconstructValue<_NotificationExposed>, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<NotificationProps> & Readonly<{}>, {
|
|
7
|
-
duration: number;
|
|
8
7
|
closable: boolean;
|
|
9
8
|
position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
9
|
+
duration: number;
|
|
10
10
|
offset: number;
|
|
11
11
|
buttonText: string;
|
|
12
12
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
@@ -15,12 +15,12 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
15
15
|
"update:modelValue": (value: number | undefined) => any;
|
|
16
16
|
} & {
|
|
17
17
|
"update:modelValue": (value?: number | undefined) => any;
|
|
18
|
-
change: (value?: number | undefined) => any;
|
|
19
18
|
clear: () => any;
|
|
19
|
+
change: (value?: number | undefined) => any;
|
|
20
20
|
}, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((value?: number | undefined) => any) | undefined;
|
|
22
|
-
onChange?: ((value?: number | undefined) => any) | undefined;
|
|
23
22
|
onClear?: (() => any) | undefined;
|
|
23
|
+
onChange?: ((value?: number | undefined) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
disabled: boolean;
|
|
26
26
|
readonly: boolean;
|
|
@@ -15,8 +15,8 @@ declare const __VLS_base: _$vue.DefineComponent<PopConfirmProps, {}, {}, {}, {},
|
|
|
15
15
|
onCancel?: (() => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
17
|
trigger: "hover" | "click";
|
|
18
|
-
icon: _$vue.Component;
|
|
19
18
|
direction: TipDirection;
|
|
19
|
+
icon: _$vue.Component;
|
|
20
20
|
iconColor: string;
|
|
21
21
|
confirmText: string;
|
|
22
22
|
cancelText: string;
|
|
@@ -28,10 +28,10 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
28
28
|
}>, {
|
|
29
29
|
disabled: boolean;
|
|
30
30
|
readonly: boolean;
|
|
31
|
-
labelKey: string;
|
|
32
|
-
valueKey: string;
|
|
33
31
|
placeholder: string;
|
|
34
32
|
clearable: boolean;
|
|
33
|
+
labelKey: string;
|
|
34
|
+
valueKey: string;
|
|
35
35
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
36
36
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
37
37
|
declare const _default: typeof __VLS_export;
|
|
@@ -23,10 +23,10 @@ declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {
|
|
|
23
23
|
onClose?: ((item: TabItem, index: number) => any) | undefined;
|
|
24
24
|
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
|
-
block: boolean;
|
|
27
26
|
closable: boolean;
|
|
28
27
|
rounded: boolean;
|
|
29
28
|
position: "top" | "bottom";
|
|
29
|
+
block: boolean;
|
|
30
30
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
31
31
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
32
|
declare const _default: typeof __VLS_export;
|
|
@@ -18,10 +18,10 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
|
|
|
18
18
|
onClose?: ((item: TabItem, index: number) => any) | undefined;
|
|
19
19
|
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
20
20
|
}>, {
|
|
21
|
-
block: boolean;
|
|
22
21
|
closable: boolean;
|
|
23
22
|
rounded: boolean;
|
|
24
23
|
position: "left" | "right" | "top" | "bottom";
|
|
24
|
+
block: boolean;
|
|
25
25
|
keepAlive: boolean;
|
|
26
26
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
27
27
|
declare const _default: typeof __VLS_export;
|
|
@@ -11,20 +11,20 @@ declare const __VLS_export: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {},
|
|
|
11
11
|
"update:modelValue": (value: string | undefined) => any;
|
|
12
12
|
} & {
|
|
13
13
|
"update:modelValue": (value: string) => any;
|
|
14
|
+
clear: () => any;
|
|
14
15
|
change: (value: string) => any;
|
|
15
16
|
focus: () => any;
|
|
16
|
-
clear: () => any;
|
|
17
17
|
blur: () => any;
|
|
18
18
|
}, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
19
19
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
20
|
+
onClear?: (() => any) | undefined;
|
|
20
21
|
onChange?: ((value: string) => any) | undefined;
|
|
21
22
|
onFocus?: (() => any) | undefined;
|
|
22
|
-
onClear?: (() => any) | undefined;
|
|
23
23
|
onBlur?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
+
resize: boolean;
|
|
25
26
|
disabled: boolean;
|
|
26
27
|
readonly: boolean;
|
|
27
|
-
resize: boolean;
|
|
28
28
|
placeholder: string;
|
|
29
29
|
clearable: boolean;
|
|
30
30
|
autosize: boolean;
|
|
@@ -14,8 +14,8 @@ declare const __VLS_base: _$vue.DefineComponent<TipProps, {}, {}, {}, {}, _$vue.
|
|
|
14
14
|
trigger: "hover" | "click";
|
|
15
15
|
contentTag: string;
|
|
16
16
|
visible: boolean;
|
|
17
|
-
content: string;
|
|
18
17
|
direction: TipDirection;
|
|
18
|
+
content: string;
|
|
19
19
|
alignment: TipAlign;
|
|
20
20
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
21
21
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -15,23 +15,23 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
|
15
15
|
declare const __VLS_base: _$vue.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
|
|
16
16
|
"update:modelValue": (value: string | number | undefined) => any;
|
|
17
17
|
} & {
|
|
18
|
-
change: (value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any;
|
|
19
18
|
clear: () => any;
|
|
19
|
+
change: (value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any;
|
|
20
20
|
"update:text": (text?: string | undefined) => any;
|
|
21
21
|
}, string, _$vue.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
22
|
"onUpdate:modelValue"?: ((value: string | number | undefined) => any) | undefined;
|
|
23
|
-
onChange?: ((value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any) | undefined;
|
|
24
23
|
onClear?: (() => any) | undefined;
|
|
24
|
+
onChange?: ((value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any) | undefined;
|
|
25
25
|
"onUpdate:text"?: ((text?: string | undefined) => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
27
|
disabled: boolean;
|
|
28
28
|
readonly: boolean;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
clearable: boolean;
|
|
31
|
+
minWidth: string;
|
|
29
32
|
expandAll: boolean;
|
|
30
33
|
labelKey: string;
|
|
31
34
|
valueKey: string;
|
|
32
|
-
minWidth: string;
|
|
33
|
-
placeholder: string;
|
|
34
|
-
clearable: boolean;
|
|
35
35
|
filterable: boolean;
|
|
36
36
|
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
37
37
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
package/dist/types/form.d.ts
CHANGED
|
@@ -25,23 +25,23 @@ type IFormModel<Fields extends Record<string, any> = Record<string, any>> = {
|
|
|
25
25
|
* 字段键
|
|
26
26
|
*/
|
|
27
27
|
readonly allKeys: string[]; /** 需要校验的key */
|
|
28
|
-
formKeys: Map<number,
|
|
29
|
-
readonly errors: Map<
|
|
28
|
+
formKeys: Map<number, string[]>; /** 错误 */
|
|
29
|
+
readonly errors: Map<string, string[] | undefined>;
|
|
30
30
|
/**
|
|
31
31
|
* 字段校验
|
|
32
32
|
* @param fields 字段, 如果不传入时将会使用keyFields来进行校验
|
|
33
33
|
*/
|
|
34
|
-
validate: (fields?:
|
|
35
|
-
resetData(fields?:
|
|
34
|
+
validate: (fields?: string | string[]) => Promise<boolean>; /** 重置数据 */
|
|
35
|
+
resetData(fields?: string | string[]): void;
|
|
36
36
|
/**
|
|
37
37
|
* 设置数据
|
|
38
38
|
* @param formData 表单值
|
|
39
39
|
* @param options 配置
|
|
40
40
|
*/
|
|
41
|
-
setData(formData: Partial<
|
|
41
|
+
setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): void; /** 清除校验 */
|
|
42
42
|
clearValidate(): void; /** 监听值变更 */
|
|
43
|
-
onChange(cb: (field:
|
|
44
|
-
offChange(cb: (field:
|
|
43
|
+
onChange(cb: (field: string, val: any) => void): void; /** 关闭监听值变更 */
|
|
44
|
+
offChange(cb: (field: string, val: any) => void): void;
|
|
45
45
|
};
|
|
46
46
|
/** 表单组件属性 */
|
|
47
47
|
interface FormProps<Model extends IFormModel = IFormModel> extends ComponentProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src"
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"@cat-kit/core": ">=1.1.5",
|
|
69
69
|
"@cat-kit/excel": ">=1.0.0",
|
|
70
70
|
"@cat-kit/fe": "^1.1.5",
|
|
71
|
-
"@veltra/compositions": "1.1.
|
|
72
|
-
"@veltra/directives": "1.1.
|
|
73
|
-
"@veltra/icons": "1.1.
|
|
74
|
-
"@veltra/styles": "1.1.
|
|
75
|
-
"@veltra/utils": "1.1.
|
|
71
|
+
"@veltra/compositions": "1.1.28",
|
|
72
|
+
"@veltra/directives": "1.1.28",
|
|
73
|
+
"@veltra/icons": "1.1.28",
|
|
74
|
+
"@veltra/styles": "1.1.28",
|
|
75
|
+
"@veltra/utils": "1.1.28",
|
|
76
76
|
"vue": ">=3.5.0"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</u-layout>
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
|
-
<script lang="ts" setup generic="Model extends
|
|
22
|
+
<script lang="ts" setup generic="Model extends IFormModel">
|
|
23
23
|
import { bem } from '@veltra/utils'
|
|
24
24
|
import { computed, inject, provide, shallowRef, watch } from 'vue'
|
|
25
25
|
|
|
@@ -27,12 +27,12 @@ import type {
|
|
|
27
27
|
BatchEditEmits,
|
|
28
28
|
BatchEditFeature,
|
|
29
29
|
BatchEditProps,
|
|
30
|
+
IFormModel,
|
|
30
31
|
TableColumnSlotsScope,
|
|
31
32
|
TableExposed,
|
|
32
33
|
TableRow
|
|
33
34
|
} from '../../types'
|
|
34
35
|
import { DialogDIKey } from '../dialog/di'
|
|
35
|
-
import type { FormModel } from '../form'
|
|
36
36
|
import { ULayout } from '../layout'
|
|
37
37
|
import BatchEditForm from './batch-edit-form.vue'
|
|
38
38
|
import BatchEditList from './batch-edit-list.vue'
|
|
@@ -5,15 +5,15 @@ import type {
|
|
|
5
5
|
BatchEditEmits,
|
|
6
6
|
BatchEditFeature,
|
|
7
7
|
BatchEditProps,
|
|
8
|
+
IFormModel,
|
|
8
9
|
TableExposed,
|
|
9
10
|
TableRow
|
|
10
11
|
} from '../../types'
|
|
11
|
-
import type { FormModel } from '../form'
|
|
12
12
|
import type { EditReturned } from './use-edit'
|
|
13
13
|
export const BatchEditDIKey: InjectionKey<
|
|
14
14
|
{
|
|
15
15
|
cls: BEM<'batch-edit', 'u-'>
|
|
16
|
-
props: BatchEditProps<
|
|
16
|
+
props: BatchEditProps<IFormModel>
|
|
17
17
|
emit: BatchEditEmits
|
|
18
18
|
tableRef: ShallowRef<TableExposed | undefined>
|
|
19
19
|
staticFeatures: ComputedRef<Set<BatchEditFeature>>
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
ModelData,
|
|
7
7
|
DataSettingConfig,
|
|
8
8
|
IFormModel,
|
|
9
|
-
AllKeys,
|
|
10
9
|
FormModelItem,
|
|
11
10
|
FormModelField
|
|
12
11
|
} from '../../types'
|
|
@@ -48,12 +47,12 @@ export class FormModel<
|
|
|
48
47
|
* @description
|
|
49
48
|
* 这个值会在表单组件渲染时由表单设置,因为只有真正渲染的组件才应该被校验
|
|
50
49
|
*/
|
|
51
|
-
formKeys: Map<number,
|
|
50
|
+
formKeys: Map<number, string[]> = new Map()
|
|
52
51
|
|
|
53
52
|
/** 初始数据 */
|
|
54
53
|
readonly initialData: ModelData<Fields>
|
|
55
54
|
|
|
56
|
-
readonly errors: Map<
|
|
55
|
+
readonly errors: Map<string, string[] | undefined> = shallowReactive(new Map())
|
|
57
56
|
|
|
58
57
|
private validator: Validator<Record<string, FormModelItem>>
|
|
59
58
|
|
|
@@ -119,16 +118,16 @@ export class FormModel<
|
|
|
119
118
|
this.data = data as ModelData<Fields>
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
private getValidateFields(fields?:
|
|
121
|
+
private getValidateFields(fields?: string | string[]) {
|
|
123
122
|
if (!fields) {
|
|
124
123
|
if (this.formKeys.size) {
|
|
125
|
-
let _fields:
|
|
126
|
-
this.formKeys.forEach((
|
|
127
|
-
_fields = _fields.concat(
|
|
124
|
+
let _fields: string[] = []
|
|
125
|
+
this.formKeys.forEach((keys) => {
|
|
126
|
+
_fields = _fields.concat(keys)
|
|
128
127
|
})
|
|
129
128
|
return _fields
|
|
130
129
|
} else {
|
|
131
|
-
return this.allKeys
|
|
130
|
+
return this.allKeys
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
@@ -143,10 +142,10 @@ export class FormModel<
|
|
|
143
142
|
* @param fields 需要校验的字段, 不传则校验所有字段
|
|
144
143
|
* @returns
|
|
145
144
|
*/
|
|
146
|
-
async validate(fields?:
|
|
145
|
+
async validate(fields?: string | string[]): Promise<boolean> {
|
|
147
146
|
const { errors, validator, data } = this
|
|
148
147
|
|
|
149
|
-
const results = await validator.validate(data, this.getValidateFields(fields)
|
|
148
|
+
const results = await validator.validate(data, this.getValidateFields(fields))
|
|
150
149
|
|
|
151
150
|
// 全量校验
|
|
152
151
|
if (!fields) {
|
|
@@ -184,12 +183,12 @@ export class FormModel<
|
|
|
184
183
|
* 重置数据
|
|
185
184
|
* @param fields 需要重置的字段
|
|
186
185
|
*/
|
|
187
|
-
resetData(keys?:
|
|
186
|
+
resetData(keys?: string | string[]): void {
|
|
188
187
|
if (typeof keys === 'string') {
|
|
189
188
|
keys = [keys]
|
|
190
189
|
} else if (Array.isArray(keys)) {
|
|
191
190
|
} else {
|
|
192
|
-
keys = this.allKeys
|
|
191
|
+
keys = this.allKeys
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
this.clearValidate()
|
|
@@ -206,10 +205,7 @@ export class FormModel<
|
|
|
206
205
|
* @param formData 表单值
|
|
207
206
|
* @param options 配置
|
|
208
207
|
*/
|
|
209
|
-
setData(
|
|
210
|
-
formData: Partial<ModelData<Fields> & Record<string, any>>,
|
|
211
|
-
config?: DataSettingConfig
|
|
212
|
-
): FormModel<Fields> {
|
|
208
|
+
setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): FormModel<Fields> {
|
|
213
209
|
const { validate = true } = config || {}
|
|
214
210
|
|
|
215
211
|
if (!validate) {
|
|
@@ -248,12 +244,12 @@ export class FormModel<
|
|
|
248
244
|
* 监听值变更
|
|
249
245
|
* @param cb 回调
|
|
250
246
|
*/
|
|
251
|
-
onChange(cb: (field:
|
|
252
|
-
this.modelChangeCallback.add(cb
|
|
247
|
+
onChange(cb: (field: string, val: any) => void): void {
|
|
248
|
+
this.modelChangeCallback.add(cb)
|
|
253
249
|
}
|
|
254
250
|
|
|
255
251
|
/** 关闭监听值变更 */
|
|
256
|
-
offChange(cb: (field:
|
|
257
|
-
this.modelChangeCallback.delete(cb
|
|
252
|
+
offChange(cb: (field: string, val: any) => void): void {
|
|
253
|
+
this.modelChangeCallback.delete(cb)
|
|
258
254
|
}
|
|
259
255
|
}
|
package/src/types/form.ts
CHANGED
|
@@ -52,29 +52,29 @@ export type IFormModel<Fields extends Record<string, any> = Record<string, any>>
|
|
|
52
52
|
*/
|
|
53
53
|
readonly allKeys: string[]
|
|
54
54
|
/** 需要校验的key */
|
|
55
|
-
formKeys: Map<number,
|
|
55
|
+
formKeys: Map<number, string[]>
|
|
56
56
|
/** 错误 */
|
|
57
|
-
readonly errors: Map<
|
|
57
|
+
readonly errors: Map<string, string[] | undefined>
|
|
58
58
|
/**
|
|
59
59
|
* 字段校验
|
|
60
60
|
* @param fields 字段, 如果不传入时将会使用keyFields来进行校验
|
|
61
61
|
*/
|
|
62
|
-
validate: (fields?:
|
|
62
|
+
validate: (fields?: string | string[]) => Promise<boolean>
|
|
63
63
|
/** 重置数据 */
|
|
64
|
-
resetData(fields?:
|
|
64
|
+
resetData(fields?: string | string[]): void
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* 设置数据
|
|
68
68
|
* @param formData 表单值
|
|
69
69
|
* @param options 配置
|
|
70
70
|
*/
|
|
71
|
-
setData(formData: Partial<
|
|
71
|
+
setData(formData: Partial<Record<string, any>>, config?: DataSettingConfig): void
|
|
72
72
|
/** 清除校验 */
|
|
73
73
|
clearValidate(): void
|
|
74
74
|
/** 监听值变更 */
|
|
75
|
-
onChange(cb: (field:
|
|
75
|
+
onChange(cb: (field: string, val: any) => void): void
|
|
76
76
|
/** 关闭监听值变更 */
|
|
77
|
-
offChange(cb: (field:
|
|
77
|
+
offChange(cb: (field: string, val: any) => void): void
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** 表单组件属性 */
|