Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7da6a5f54b | ||
|
|
b8b2c793a7 | ||
|
|
e6c195e6fa |
@@ -45,5 +45,7 @@ UMD 方式(挂到 `window.funjiaUI`):
|
||||
|
||||
| 版本 | 说明 |
|
||||
| --- | --- |
|
||||
| 1.3.1 | 修复**编辑弹窗「点确定没反应」**:表单 vnode 改由 `render()` 创建,避免 Vue 3.5 在渲染外重算 computed 导致字符串 ref 失去 owner、`$refs.formRef` 为 null |
|
||||
| 1.3.0 | 新增**列冻结**(`fixed: "left" \| "right"`、操作列 `operateFixed`),体检新增两条冻结相关规则;顺带修复 `sort: 0` 被当成 `1` 的排序缺陷 |
|
||||
| 1.2.0 | 内核层重构(core/)、类型统一、编辑链路修复、配置体检、UMD 全局名修正为 `funjiaUI` |
|
||||
| 1.0.0 | 初版产物(`um_table.es.js`,已被 1.2.0 取代),保留在 `v1.0.0` 标签 |
|
||||
|
||||
Vendored
+3
-5
@@ -31,6 +31,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
||||
[x: string]: any;
|
||||
}>;
|
||||
setFormModel: (models: any) => void;
|
||||
getFormInstance: () => any;
|
||||
}, {
|
||||
rules: Record<string, any>;
|
||||
formItems: any[];
|
||||
@@ -39,11 +40,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
||||
showList: string[];
|
||||
cascadeMap: Map<string, string[]>;
|
||||
throttleRefreshForm: import("lodash").DebouncedFunc<(this: any, v: any, oldV: any, needFreshCascadeField: string[]) => Promise<void>>;
|
||||
}, {
|
||||
formCom(): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | null;
|
||||
}, {
|
||||
}, {}, {
|
||||
refreshForm(v: any, oldV: any, needFreshCascadeField: string[]): Promise<void | undefined>;
|
||||
onSubmit(): Promise<void>;
|
||||
getRule(rule: IFormRule): {
|
||||
@@ -104,6 +101,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
||||
initRule(isBeforeMount?: boolean): void;
|
||||
init(): Promise<void>;
|
||||
initForm(fieldName: string, value: any): void;
|
||||
buildForm(): any;
|
||||
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("ok" | "cancel" | "formModelChange")[], "ok" | "cancel" | "formModelChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
||||
onOk?: ((...args: any[]) => any) | undefined;
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
|
||||
Vendored
+8
@@ -27,6 +27,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: false;
|
||||
};
|
||||
fixed: {
|
||||
type: null;
|
||||
required: false;
|
||||
};
|
||||
showOverflowTooltip: {
|
||||
type: BooleanConstructor;
|
||||
required: false;
|
||||
@@ -306,6 +310,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: false;
|
||||
};
|
||||
fixed: {
|
||||
type: null;
|
||||
required: false;
|
||||
};
|
||||
showOverflowTooltip: {
|
||||
type: BooleanConstructor;
|
||||
required: false;
|
||||
|
||||
Vendored
+20
-5
@@ -4,6 +4,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
[x: string]: any;
|
||||
}>;
|
||||
setFormModel: (models: any) => void;
|
||||
getFormInstance: () => any;
|
||||
}, {
|
||||
rules: Record<string, any>;
|
||||
formItems: any[];
|
||||
@@ -16,11 +17,7 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
cascadeMap: Map<string, string[]>;
|
||||
/** 表单刷新按 100ms 合并,避免连续输入时反复重建整个表单 */
|
||||
throttleRefreshForm: import("lodash").DebouncedFunc<(this: any, v: any, oldV: any, needFreshCascadeField: string[]) => Promise<void>>;
|
||||
}, {
|
||||
formCom(): import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}> | null;
|
||||
}, {
|
||||
}, {}, {
|
||||
refreshForm(v: any, oldV: any, needFreshCascadeField: string[]): Promise<void | undefined>;
|
||||
onSubmit(): Promise<void>;
|
||||
/** 把 `IFormRule` 翻译成 element-plus 的 FormItemRule */
|
||||
@@ -91,6 +88,24 @@ declare const _sfc_main: import("vue").DefineComponent<{}, {
|
||||
init(): Promise<void>;
|
||||
/** 单字段赋值:整体替换对象,触发父层的 formModel watch */
|
||||
initForm(fieldName: string, value: any): void;
|
||||
/**
|
||||
* 造出 ElForm 的 vnode。
|
||||
*
|
||||
* ⚠️ 必须由 `render()` 直接调用,**不要**挪回 `computed` 里。
|
||||
*
|
||||
* Vue 3.5 起,调度器会在渲染之外重新求值 computed
|
||||
* (`flushJobs` → `runIfDirty` → `refreshComputed`,实测在首次渲染后 2ms 就会来一次)。
|
||||
* 那一刻 `currentRenderingInstance` 是 null,于是 `h(ElForm, { ref: "formRef" })`
|
||||
* 造出来的 vnode 里 ref 的 owner 就是 null;Vue 的 `setRef` 会打印
|
||||
* `Missing ref owner context. ref cannot be used on hoisted vnodes`
|
||||
* 并**直接跳过赋值** —— `$refs.formRef` 永远是 null。
|
||||
*
|
||||
* 症状极具迷惑性:表单照常渲染、数据照常回填,只有「点确定」没反应
|
||||
* (`onSubmit` 里 `refs.formRef?.validate?.()` 静默落空),
|
||||
* 而且是否复现取决于「最后一次求值落在渲染内还是渲染外」。
|
||||
* 在 render 里创建则每次都有正确的 owner。
|
||||
*/
|
||||
buildForm(): any;
|
||||
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("ok" | "cancel" | "formModelChange")[], "ok" | "cancel" | "formModelChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
||||
onOk?: ((...args: any[]) => any) | undefined;
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
|
||||
Vendored
+38
-1
@@ -1,5 +1,5 @@
|
||||
import type { VNode } from "vue";
|
||||
import type { IToolbar, TDecoratorKey, TEvent, TOperateType } from "../types";
|
||||
import type { IToolbar, TDecoratorKey, TEvent, TFixed, TOperateType } from "../types";
|
||||
import { type IEventTask, type TFireHook } from "./events";
|
||||
/**
|
||||
* 列 / 操作列 / 工具栏的装配逻辑。
|
||||
@@ -10,6 +10,27 @@ import { type IEventTask, type TFireHook } from "./events";
|
||||
*/
|
||||
/** 收集数据列 VNode(按 sort 升序) */
|
||||
export declare const collectDataColumns: (target: any) => VNode[];
|
||||
/**
|
||||
* 把配置里写的冻结值规范化成 el-table 认识的形式。
|
||||
*
|
||||
* - `true` / `"left"` -> `"left"`(`true` 是历史写法,语义就是左侧)
|
||||
* - `"right"` -> `"right"`
|
||||
* - `false` / 其他非法值 -> `undefined`(不冻结,交给诊断模块报出来)
|
||||
*/
|
||||
export declare const normalizeFixed: (value: TFixed | undefined) => "left" | "right" | undefined;
|
||||
/** `fixed` 的合法取值(供诊断模块判断"写错的值") */
|
||||
export declare const FIXED_VALUES: TFixed[];
|
||||
/**
|
||||
* 数据列里是否存在左侧冻结列。
|
||||
*
|
||||
* 序号 / 选择 / 展开列是组件自动插到最前面的,它们不在配置类里声明。
|
||||
* 一旦有数据列冻结到左侧,这三列如果不跟着冻结,就会夹在边缘与冻结列之间,
|
||||
* 导致后面的冻结列失效(el-table 要求冻结列从边缘起连续)。
|
||||
* 所以组件用这个函数决定"要不要把前置列一起冻结"。
|
||||
*/
|
||||
export declare const hasLeftFixedColumn: (target: any) => boolean;
|
||||
/** 数据列里是否存在右侧冻结列(用于判断操作列是否该并入右侧冻结组) */
|
||||
export declare const hasRightFixedColumn: (target: any) => boolean;
|
||||
/** 操作列分组:同一 id(缺省用 type)的多个方法会聚合到同一个按钮上 */
|
||||
export interface IOperateGroup {
|
||||
type: TOperateType;
|
||||
@@ -37,11 +58,27 @@ export declare const collectOperateGroups: (target: any) => IOperateGroup[];
|
||||
export declare const resolveShowOperate: (target: any, hasOperate: boolean) => boolean;
|
||||
/** 解析操作列宽度(支持实例属性与类静态属性两种写法) */
|
||||
export declare const resolveOperateWidth: (target: any, fallback?: number | string) => number | string;
|
||||
/**
|
||||
* 解析操作列的冻结方向。
|
||||
*
|
||||
* 与 `operateWidth` 一样,在配置类上声明一个**普通属性**即可(不加装饰器):
|
||||
* ```ts
|
||||
* export class Employee {
|
||||
* operateWidth = 190;
|
||||
* operateFixed = "right"; // 操作列冻结在右侧
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* 默认不冻结 —— 这是新能力,不改变既有表格的行为。
|
||||
*/
|
||||
export declare const resolveOperateFixed: (target: any) => "left" | "right" | undefined;
|
||||
export interface IBuildOperateColumnOptions {
|
||||
fire: TFireHook;
|
||||
/** 透传给操作事件的行数据集合 */
|
||||
tableData?: any[];
|
||||
width?: number | string;
|
||||
/** 冻结方向,见 resolveOperateFixed */
|
||||
fixed?: "left" | "right";
|
||||
/** 需要延后执行 onAfter 的按钮类型,见 IDeferOptions */
|
||||
deferAfterTypes?: string[];
|
||||
}
|
||||
|
||||
Vendored
+17
@@ -15,6 +15,16 @@ import type { Component, VNode } from "vue";
|
||||
export type TColumnType = "selection" | "index" | "expand" | "operate";
|
||||
/** 兼容历史命名 */
|
||||
export type columnType = TColumnType;
|
||||
/**
|
||||
* 列的冻结(固定列)方向。
|
||||
*
|
||||
* `true` 等价于 `"left"`,`false` / 不传表示不冻结。
|
||||
*
|
||||
* 注意冻结列必须**从表格边缘开始连续排列**:`"left"` 的列要排在最前面,
|
||||
* `"right"` 的列要排在最后面,中间夹一个不冻结的列,后面的冻结列就不会生效。
|
||||
* 组件会把序号 / 选择 / 展开列自动并入左侧冻结组,但数据列之间的顺序由 `sort` 决定。
|
||||
*/
|
||||
export type TFixed = boolean | "left" | "right";
|
||||
/** 操作列按钮类型 */
|
||||
export type TOperateType = "edit" | "del" | "copy" | "customOperateEvent";
|
||||
/**
|
||||
@@ -79,6 +89,13 @@ export interface IFieldMetaValue {
|
||||
fieldName?: string;
|
||||
width?: number;
|
||||
minWidth?: number;
|
||||
/**
|
||||
* 列的冻结方向(固定列)。
|
||||
*
|
||||
* 只在数据列(`@TableColumnPropertyDecorator`)上生效;
|
||||
* 冻结列必须从表格边缘起连续排列,见 `TFixed` 的说明。
|
||||
*/
|
||||
fixed?: TFixed;
|
||||
/** 用于初始化组件数据(级联数据的来源) */
|
||||
getData?: (currentData?: any) => MaybePromise<any>;
|
||||
/** 查询表单中所需要的组件类型 */
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+136
-44
@@ -1416,6 +1416,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
||||
label: null,
|
||||
width: { default: 180 },
|
||||
minWidth: null,
|
||||
fixed: null,
|
||||
showOverflowTooltip: { type: Boolean },
|
||||
operateItems: { default: () => [] },
|
||||
expandTemplate: null,
|
||||
@@ -1435,7 +1436,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
||||
width: __props.minWidth ? void 0 : __props.width,
|
||||
"min-width": __props.minWidth,
|
||||
label: unref(resolvedLabel),
|
||||
"show-overflow-tooltip": __props.showOverflowTooltip
|
||||
"show-overflow-tooltip": __props.showOverflowTooltip,
|
||||
fixed: __props.fixed
|
||||
}, {
|
||||
default: withCtx((scope) => {
|
||||
var _a, _b;
|
||||
@@ -1460,7 +1462,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
||||
];
|
||||
}),
|
||||
_: 1
|
||||
}, 8, ["type", "prop", "width", "min-width", "label", "show-overflow-tooltip"]);
|
||||
}, 8, ["type", "prop", "width", "min-width", "label", "show-overflow-tooltip", "fixed"]);
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -3053,20 +3055,38 @@ async function runEventPipeline(options) {
|
||||
}
|
||||
return current;
|
||||
}
|
||||
const collectDataColumns = (target) => scanDecoratedMembers(target, "table:field").map((member) => ({
|
||||
sort: member.meta.sort || 1,
|
||||
const collectDataColumns = (target) => scanDecoratedMembers(target, "table:field").map((member) => {
|
||||
var _a;
|
||||
return {
|
||||
sort: (_a = member.meta.sort) != null ? _a : 1,
|
||||
vnode: h(_sfc_main$e, {
|
||||
prop: member.fieldName,
|
||||
label: member.meta.def,
|
||||
fieldType: member.meta.fieldType,
|
||||
width: member.meta.width,
|
||||
minWidth: member.meta.minWidth,
|
||||
fixed: normalizeFixed(member.meta.fixed),
|
||||
columnRender: member.meta.columnRender,
|
||||
isShow: member.meta.isShow,
|
||||
showOverflowTooltip: member.meta.showOverflowTooltip,
|
||||
dateFormat: member.meta.dateFormat
|
||||
})
|
||||
})).sort((a, b) => a.sort - b.sort).map((item) => item.vnode);
|
||||
};
|
||||
}).sort((a, b) => a.sort - b.sort).map((item) => item.vnode);
|
||||
const normalizeFixed = (value) => {
|
||||
if (value === true || value === "left")
|
||||
return "left";
|
||||
if (value === "right")
|
||||
return "right";
|
||||
return void 0;
|
||||
};
|
||||
const FIXED_VALUES = [true, false, "left", "right"];
|
||||
const hasLeftFixedColumn = (target) => scanDecoratedMembers(target, "table:field").some(
|
||||
(member) => normalizeFixed(member.meta.fixed) === "left"
|
||||
);
|
||||
const hasRightFixedColumn = (target) => scanDecoratedMembers(target, "table:field").some(
|
||||
(member) => normalizeFixed(member.meta.fixed) === "right"
|
||||
);
|
||||
const collectOperateGroups = (target) => {
|
||||
var _a;
|
||||
const groups = /* @__PURE__ */ new Map();
|
||||
@@ -3117,6 +3137,12 @@ const resolveOperateWidth = (target, fallback = "120px") => {
|
||||
const instance = createTargetInstance(target);
|
||||
return (_b = (_a = instance.operateWidth) != null ? _a : target == null ? void 0 : target.operateWidth) != null ? _b : fallback;
|
||||
};
|
||||
const resolveOperateFixed = (target) => {
|
||||
var _a;
|
||||
const instance = createTargetInstance(target);
|
||||
const value = (_a = instance.operateFixed) != null ? _a : target == null ? void 0 : target.operateFixed;
|
||||
return normalizeFixed(value);
|
||||
};
|
||||
const isDeferredAfter = (type, deferred) => !!(deferred == null ? void 0 : deferred.some((item) => item === type));
|
||||
const withoutDeferredAfter = (tasks, deferred) => tasks.filter(
|
||||
(task) => {
|
||||
@@ -3138,6 +3164,7 @@ const buildOperateColumn = (groups, options) => {
|
||||
fire,
|
||||
tableData = [],
|
||||
width = "120px",
|
||||
fixed,
|
||||
deferAfterTypes
|
||||
} = options;
|
||||
const operateItems = [...groups].sort((a, b) => a.sort - b.sort).map((group) => ({
|
||||
@@ -3158,7 +3185,8 @@ const buildOperateColumn = (groups, options) => {
|
||||
type: "operate",
|
||||
label: "\u64CD\u4F5C",
|
||||
operateItems,
|
||||
width
|
||||
width,
|
||||
fixed
|
||||
});
|
||||
};
|
||||
const collectTypedTasks = (target, decoratorKey, type) => sortTasksByPriority(
|
||||
@@ -3410,6 +3438,15 @@ const diagnoseTarget = (target, options = {}) => {
|
||||
hint: `\u5408\u6CD5\u503C\uFF1A${Object.keys(FIELD_TYPE_SET).join(" / ")}`
|
||||
});
|
||||
}
|
||||
if (dKey === "table:field" && meta.fixed !== void 0 && meta.fixed !== null && !FIXED_VALUES.includes(meta.fixed)) {
|
||||
push({
|
||||
level: "warn",
|
||||
code: "invalid-fixed-value",
|
||||
member: entry.member.key,
|
||||
message: `fixed: ${JSON.stringify(meta.fixed)} \u4E0D\u662F\u5408\u6CD5\u7684\u51BB\u7ED3\u65B9\u5411\uFF0C\u8FD9\u4E00\u5217\u4E0D\u4F1A\u88AB\u51BB\u7ED3`,
|
||||
hint: '\u53EF\u7528 "left" / "right"\uFF08true \u7B49\u4EF7\u4E8E "left"\uFF09'
|
||||
});
|
||||
}
|
||||
}
|
||||
if ((formMeta == null ? void 0 : formMeta.fieldType) && FORM_UNIMPLEMENTED.has(formMeta.fieldType) && !formMeta.component) {
|
||||
push({
|
||||
@@ -3452,6 +3489,28 @@ const diagnoseTarget = (target, options = {}) => {
|
||||
hint: "\u68C0\u67E5 @TableColumnPropertyDecorator \u662F\u5426\u6302\u5728\u4E86\u7C7B\u7684\u5C5E\u6027\u4E0A\uFF08\u800C\u4E0D\u662F\u9759\u6001\u5C5E\u6027 / \u6784\u9020\u51FD\u6570\u91CC\uFF09"
|
||||
});
|
||||
}
|
||||
const orderedColumns = [...columns].sort(
|
||||
(a, b) => {
|
||||
var _a2, _b2;
|
||||
return ((_a2 = a.meta.sort) != null ? _a2 : 1) - ((_b2 = b.meta.sort) != null ? _b2 : 1);
|
||||
}
|
||||
);
|
||||
const fixDirs = orderedColumns.map((column) => normalizeFixed(column.meta.fixed));
|
||||
const reportFixedEdge = (column, dir) => push({
|
||||
level: "warn",
|
||||
code: "fixed-column-not-at-edge",
|
||||
member: column.key,
|
||||
message: `"${column.meta.def || column.key}" \u51BB\u7ED3\u5230\u4E86${dir === "left" ? "\u5DE6" : "\u53F3"}\u4FA7\uFF0C\u4F46\u5B83\u7684${dir === "left" ? "\u524D\u9762" : "\u540E\u9762"}\u8FD8\u6709\u4E0D\u51BB\u7ED3\u7684\u5217\uFF0C\u8FD9\u4E00\u5217\u4E0D\u4F1A\u771F\u7684\u51BB\u7ED3`,
|
||||
hint: `\u51BB\u7ED3\u5217\u5FC5\u987B\u4ECE\u8FB9\u7F18\u8D77\u8FDE\u7EED\uFF1A\u6539 sort \u628A\u5B83\u6392\u5230${dir === "left" ? "\u6700\u524D" : "\u6700\u540E"}\uFF0C\u6216\u8005\u8BA9\u76F8\u90BB\u7684\u5217\u4E00\u8D77 fixed`
|
||||
});
|
||||
orderedColumns.forEach((column, index) => {
|
||||
const dir = fixDirs[index];
|
||||
if (!dir)
|
||||
return;
|
||||
const blocked = dir === "left" ? fixDirs.slice(0, index).some((item) => item !== "left") : fixDirs.slice(index + 1).some((item) => item !== "right");
|
||||
if (blocked)
|
||||
reportFixedEdge(column, dir);
|
||||
});
|
||||
const hasFormSubmit = byType.has("edit") || byType.has("\u6DFB\u52A0");
|
||||
const primaryKeys = columns.filter(
|
||||
(column) => column.meta.fieldType === "primaryKey"
|
||||
@@ -3569,12 +3628,14 @@ const _sfc_main$d = defineComponent({
|
||||
});
|
||||
let columnList = collectDataColumns(target);
|
||||
const deferAfterTypes = this.$attrs["defer-after-types"];
|
||||
const leadFixed = hasLeftFixedColumn(target) ? "left" : void 0;
|
||||
const operateGroups = collectOperateGroups(target);
|
||||
if (resolveShowOperate(target, operateGroups.length > 0)) {
|
||||
const operateColumn = buildOperateColumn(operateGroups, {
|
||||
fire,
|
||||
tableData: data,
|
||||
width: resolveOperateWidth(target),
|
||||
fixed: resolveOperateFixed(target),
|
||||
deferAfterTypes
|
||||
});
|
||||
if (operateColumn)
|
||||
@@ -3587,19 +3648,22 @@ const _sfc_main$d = defineComponent({
|
||||
columnList = [
|
||||
h(_sfc_main$e, {
|
||||
type: "expand",
|
||||
expandTemplate: this.$attrs["expand-template"]
|
||||
expandTemplate: this.$attrs["expand-template"],
|
||||
fixed: leadFixed
|
||||
})
|
||||
].concat(columnList);
|
||||
}
|
||||
const hasIndex = this.$attrs["show-index"] !== false;
|
||||
if (hasIndex) {
|
||||
columnList = [
|
||||
h(ElTableColumn, { type: "index", label: "\u5E8F\u53F7", width: 56 })
|
||||
h(ElTableColumn, { type: "index", label: "\u5E8F\u53F7", width: 56, fixed: leadFixed })
|
||||
].concat(columnList);
|
||||
}
|
||||
const enableSelection = toolbars.some((item) => item.type === "\u6279\u91CF\u5220\u9664");
|
||||
if (enableSelection) {
|
||||
columnList = [h(ElTableColumn, { type: "selection" })].concat(columnList);
|
||||
columnList = [
|
||||
h(ElTableColumn, { type: "selection", fixed: leadFixed })
|
||||
].concat(columnList);
|
||||
}
|
||||
return h(
|
||||
UmTable,
|
||||
@@ -4812,15 +4876,40 @@ const _sfc_main$4 = defineComponent({
|
||||
}
|
||||
formModel.value = data;
|
||||
};
|
||||
const getFormInstance = () => {
|
||||
var _a, _b;
|
||||
const viaRefs = (_b = (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$refs) == null ? void 0 : _b.formRef;
|
||||
if (typeof (viaRefs == null ? void 0 : viaRefs.validate) === "function")
|
||||
return viaRefs;
|
||||
let found = null;
|
||||
const pick = (comp) => (comp == null ? void 0 : comp.exposed) ? comp.exposeProxy || comp.proxy : comp == null ? void 0 : comp.proxy;
|
||||
const walk = (vnode) => {
|
||||
var _a2, _b2;
|
||||
if (!vnode || found || typeof vnode !== "object")
|
||||
return;
|
||||
const name = ((_a2 = vnode.type) == null ? void 0 : _a2.name) || ((_b2 = vnode.type) == null ? void 0 : _b2.__name);
|
||||
if (name === "ElForm" && vnode.component) {
|
||||
found = pick(vnode.component);
|
||||
return;
|
||||
}
|
||||
if (vnode.component)
|
||||
walk(vnode.component.subTree);
|
||||
if (Array.isArray(vnode.children))
|
||||
vnode.children.forEach(walk);
|
||||
};
|
||||
walk(instance == null ? void 0 : instance.subTree);
|
||||
return found;
|
||||
};
|
||||
expose({
|
||||
setFormModel,
|
||||
getFormModel: () => unref(formModel),
|
||||
getFormInstance,
|
||||
onSubmit: () => {
|
||||
var _a, _b;
|
||||
return (_b = (_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.onSubmit) == null ? void 0 : _b.call(_a);
|
||||
}
|
||||
});
|
||||
return { formModel, setFormModel };
|
||||
return { formModel, setFormModel, getFormInstance };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -4846,14 +4935,20 @@ const _sfc_main$4 = defineComponent({
|
||||
return this.throttleRefreshForm(v, oldV, needFreshCascadeField);
|
||||
},
|
||||
async onSubmit() {
|
||||
var _a, _b;
|
||||
const refs = this.$refs;
|
||||
let valid = false;
|
||||
var _a;
|
||||
const form = (_a = this.getFormInstance) == null ? void 0 : _a.call(this);
|
||||
let valid = true;
|
||||
if (typeof (form == null ? void 0 : form.validate) === "function") {
|
||||
try {
|
||||
valid = await ((_b = (_a = refs.formRef) == null ? void 0 : _a.validate) == null ? void 0 : _b.call(_a));
|
||||
valid = await form.validate();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
"[funjiaui] UmTableForm \u672A\u80FD\u62FF\u5230 ElForm \u5B9E\u4F8B\uFF0C\u672C\u6B21\u8DF3\u8FC7\u8868\u5355\u6821\u9A8C\u76F4\u63A5\u63D0\u4EA4\uFF0C\u8BF7\u53CD\u9988\u6B64\u95EE\u9898\u3002"
|
||||
);
|
||||
}
|
||||
if (valid)
|
||||
this.$emit("ok", cloneDeep(this.formModel));
|
||||
},
|
||||
@@ -5214,35 +5309,8 @@ const _sfc_main$4 = defineComponent({
|
||||
},
|
||||
initForm(fieldName, value) {
|
||||
this.formModel = { ...this.formModel, [fieldName]: value };
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
formModel: {
|
||||
async handler(v, oldV) {
|
||||
var _a, _b;
|
||||
this.initRule(false);
|
||||
const refs = this.$refs;
|
||||
let needFreshCascadeField = [];
|
||||
const editingField = [];
|
||||
for (const key in v) {
|
||||
if (!isEqual(v[key], oldV == null ? void 0 : oldV[key])) {
|
||||
needFreshCascadeField = this.cascadeMap.get(key) || [];
|
||||
editingField.push(key);
|
||||
}
|
||||
}
|
||||
await this.refreshForm(v, oldV, needFreshCascadeField);
|
||||
await nextTick();
|
||||
for (const item of editingField) {
|
||||
try {
|
||||
await ((_b = (_a = refs == null ? void 0 : refs.formRef) == null ? void 0 : _a.validateField) == null ? void 0 : _b.call(_a, item));
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
formCom() {
|
||||
buildForm() {
|
||||
if (!this.formItems)
|
||||
return null;
|
||||
return h(
|
||||
@@ -5260,13 +5328,37 @@ const _sfc_main$4 = defineComponent({
|
||||
);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
formModel: {
|
||||
async handler(v, oldV) {
|
||||
var _a, _b, _c;
|
||||
this.initRule(false);
|
||||
let needFreshCascadeField = [];
|
||||
const editingField = [];
|
||||
for (const key in v) {
|
||||
if (!isEqual(v[key], oldV == null ? void 0 : oldV[key])) {
|
||||
needFreshCascadeField = this.cascadeMap.get(key) || [];
|
||||
editingField.push(key);
|
||||
}
|
||||
}
|
||||
await this.refreshForm(v, oldV, needFreshCascadeField);
|
||||
await nextTick();
|
||||
for (const item of editingField) {
|
||||
try {
|
||||
await ((_c = (_b = (_a = this.getFormInstance) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.validateField) == null ? void 0 : _c.call(_b, item));
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
this.rules = {};
|
||||
this.initRule();
|
||||
this.init();
|
||||
},
|
||||
render() {
|
||||
return this.formCom;
|
||||
return this.buildForm();
|
||||
}
|
||||
});
|
||||
const cssModules$2 = {
|
||||
@@ -5629,4 +5721,4 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
||||
};
|
||||
}
|
||||
});
|
||||
export { _sfc_main as AreaTree, DEFAULT_DEFER_TYPES, EVENT_PHASES, _sfc_main$k as Iconfont, TableColumnMethodDecorator, TableColumnPropertyDecorator, TableFormColumnPropertyDecorator, TableSearchFormPropertyDecorator, _sfc_main$d as UmByClass, UmByClassEnhance, UmColumnRender, _sfc_main$c as UmDialog, UmDistrictTree, UmDistrictTreeNode, UmPagination, UmSearchForm, _sfc_main$3 as UmSyncNodeForm, UmTable, _sfc_main$e as UmTableColumn, _sfc_main$b as UmTableDialog, UmTableForm, UmTableOperate, UmTableToolbar, _sfc_main$6 as UmTree, _sfc_main$5 as UmTreeSelect, buildOperateColumn, collectClassMembers, collectDataColumns, collectOperateGroups, collectToolbar, collectTypedTasks, createTargetInstance, diagnoseTarget, findMethodMeta, getMemberMeta, isDiagnosticsEnabled, normalizeFieldName, reportDiagnostics, reportDiagnosticsOnce, resolveOperateWidth, resolveShowOperate, runEventPipeline, scanDecoratedMembers, setDiagnosticsEnabled, sortTasksByPriority, transformFields };
|
||||
export { _sfc_main as AreaTree, DEFAULT_DEFER_TYPES, EVENT_PHASES, FIXED_VALUES, _sfc_main$k as Iconfont, TableColumnMethodDecorator, TableColumnPropertyDecorator, TableFormColumnPropertyDecorator, TableSearchFormPropertyDecorator, _sfc_main$d as UmByClass, UmByClassEnhance, UmColumnRender, _sfc_main$c as UmDialog, UmDistrictTree, UmDistrictTreeNode, UmPagination, UmSearchForm, _sfc_main$3 as UmSyncNodeForm, UmTable, _sfc_main$e as UmTableColumn, _sfc_main$b as UmTableDialog, UmTableForm, UmTableOperate, UmTableToolbar, _sfc_main$6 as UmTree, _sfc_main$5 as UmTreeSelect, buildOperateColumn, collectClassMembers, collectDataColumns, collectOperateGroups, collectToolbar, collectTypedTasks, createTargetInstance, diagnoseTarget, findMethodMeta, getMemberMeta, hasLeftFixedColumn, hasRightFixedColumn, isDiagnosticsEnabled, normalizeFieldName, normalizeFixed, reportDiagnostics, reportDiagnosticsOnce, resolveOperateFixed, resolveOperateWidth, resolveShowOperate, runEventPipeline, scanDecoratedMembers, setDiagnosticsEnabled, sortTasksByPriority, transformFields };
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "funjiaui_vue_package",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.1",
|
||||
"description": "FunjiaUI —— 装饰器 / 配置类驱动的 Vue3 + Element Plus 表格组件库(构建产物)",
|
||||
"main": "funjiaui.cjs.js",
|
||||
"module": "funjiaui.es.js",
|
||||
|
||||
Reference in New Issue
Block a user