1 Commits
Author SHA1 Message Date
funjia 7da6a5f54b fix: 产物更新 v1.3.1,修复编辑弹窗「点确定没反应」
对应源码仓库 commit 0692249。UmTableForm 的表单 vnode 改由 render() 创建
(删除 computed.formCom,新增 methods.buildForm),避免 Vue 3.5 在渲染外重算
computed 导致字符串 ref 失去 owner、$refs.formRef 为 null;并新增
getFormInstance() 兜底回捞 ElForm 实例。

消费方实测:旧产物点确定无反应,新产物弹窗正常关闭并提交成功。
2026-09-24 12:06:34 +08:00
7 changed files with 97 additions and 55 deletions
+1
View File
@@ -45,6 +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` 标签 |
+3 -5
View File
@@ -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;
+20 -5
View File
@@ -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;
+3 -3
View File
File diff suppressed because one or more lines are too long
+62 -34
View File
@@ -4876,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 {
@@ -4910,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));
},
@@ -5278,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(
@@ -5324,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 = {
+3 -3
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "funjiaui_vue_package",
"version": "1.3.0",
"version": "1.3.1",
"description": "FunjiaUI —— 装饰器 / 配置类驱动的 Vue3 + Element Plus 表格组件库(构建产物)",
"main": "funjiaui.cjs.js",
"module": "funjiaui.es.js",