@tmagic/form 1.8.0-beta.0 → 1.8.0-beta.2
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/es/Form.vue_vue_type_script_setup_true_lang.js +97 -24
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +193 -77
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +9 -8
- package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/containers/table/Table.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/es/index.js +2 -1
- package/dist/es/schema.js +4 -0
- package/dist/es/style.css +4 -1
- package/dist/style.css +4 -1
- package/dist/tmagic-form.umd.cjs +311 -113
- package/package.json +4 -4
- package/src/Form.vue +139 -23
- package/src/containers/Container.vue +174 -52
- package/src/containers/GroupList.vue +1 -1
- package/src/containers/GroupListItem.vue +4 -3
- package/src/containers/Tabs.vue +10 -2
- package/src/containers/table/Table.vue +9 -3
- package/src/schema.ts +47 -0
- package/src/theme/container.scss +4 -1
- package/types/index.d.ts +932 -418
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { FORM_DIFF_CONFIG_KEY } from "./schema.js";
|
|
1
2
|
import { getConfig } from "./utils/config.js";
|
|
2
3
|
import { initValue } from "./utils/form.js";
|
|
3
4
|
import Container_default from "./containers/Container.js";
|
|
4
|
-
import { Fragment, createBlock, createCommentVNode, createElementBlock, defineComponent, normalizeStyle, openBlock, provide, reactive, ref, renderList, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
5
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, createSlots, defineComponent, mergeProps, normalizeStyle, openBlock, provide, reactive, ref, renderList, renderSlot, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
|
|
5
6
|
import { cloneDeep, isEqual } from "lodash-es";
|
|
6
7
|
import { TMagicForm, tMagicMessage, tMagicMessageBox } from "@tmagic/design";
|
|
7
8
|
import { setValueByKeyPath } from "@tmagic/utils";
|
|
@@ -34,7 +35,9 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
34
35
|
keyProp: { default: "__key" },
|
|
35
36
|
popperClass: {},
|
|
36
37
|
preventSubmitDefault: { type: Boolean },
|
|
37
|
-
extendState: {}
|
|
38
|
+
extendState: {},
|
|
39
|
+
showDiff: {},
|
|
40
|
+
selfDiffFieldTypes: {}
|
|
38
41
|
},
|
|
39
42
|
emits: [
|
|
40
43
|
"change",
|
|
@@ -52,14 +55,45 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
52
55
|
const lastValuesProcessed = ref({});
|
|
53
56
|
const fields = /* @__PURE__ */ new Map();
|
|
54
57
|
const requestFuc = getConfig("request");
|
|
58
|
+
/**
|
|
59
|
+
* formState 实现说明:
|
|
60
|
+
*
|
|
61
|
+
* 1. 与 props 直接对应的字段(config / initValues / lastValues / isCompare / parentValues /
|
|
62
|
+
* keyProp / popperClass)使用「访问器(getter)」定义,每次读取都会回到 `props.xxx`
|
|
63
|
+
* 取最新值,不存在「props 变了但 formState 还没同步过来」的中间态。
|
|
64
|
+
*
|
|
65
|
+
* 2. `values` / `lastValuesProcessed` 是 ref,Vue 的 `reactive` 会自动解包,因此每次
|
|
66
|
+
* 访问 `formState.values` / `formState.lastValuesProcessed` 也都是当前 ref 值。
|
|
67
|
+
*
|
|
68
|
+
* 3. `extendState` 注入的字段在下方的 `watchEffect` 中合并到 `formState`:
|
|
69
|
+
* - data 描述符(普通字段)通过 `formState[key] = value` 写入,走 reactive proxy 的
|
|
70
|
+
* set,触发依赖通知;`extendState` 同步段读到的响应式数据变化时会自动重跑,
|
|
71
|
+
* 把最新值刷进 formState。
|
|
72
|
+
* - accessor 描述符(`{ get stage() { return ... } }`)按原样写入,调用方可以控制
|
|
73
|
+
* 读时求值,每次读取都会重新执行 getter。
|
|
74
|
+
*/
|
|
55
75
|
const formState = reactive({
|
|
56
|
-
keyProp
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
get keyProp() {
|
|
77
|
+
return props.keyProp;
|
|
78
|
+
},
|
|
79
|
+
get popperClass() {
|
|
80
|
+
return props.popperClass;
|
|
81
|
+
},
|
|
82
|
+
get config() {
|
|
83
|
+
return props.config;
|
|
84
|
+
},
|
|
85
|
+
get initValues() {
|
|
86
|
+
return props.initValues;
|
|
87
|
+
},
|
|
88
|
+
get isCompare() {
|
|
89
|
+
return props.isCompare;
|
|
90
|
+
},
|
|
91
|
+
get lastValues() {
|
|
92
|
+
return props.lastValues;
|
|
93
|
+
},
|
|
94
|
+
get parentValues() {
|
|
95
|
+
return props.parentValues;
|
|
96
|
+
},
|
|
63
97
|
values,
|
|
64
98
|
lastValuesProcessed,
|
|
65
99
|
$emit: emit,
|
|
@@ -76,22 +110,57 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
76
110
|
});
|
|
77
111
|
}
|
|
78
112
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
113
|
+
/**
|
|
114
|
+
* `extendState` 的同步段(直到第一个 `await` 之前)所访问的任何响应式数据,
|
|
115
|
+
* 都会被 `watchEffect` 自动跟踪。这样可以兼容历史用法 ——
|
|
116
|
+
*
|
|
117
|
+
* extendState: (formState) => ({
|
|
118
|
+
* username: store.username, // 同步读 store,会被跟踪
|
|
119
|
+
* env: store.env,
|
|
120
|
+
* })
|
|
121
|
+
*
|
|
122
|
+
* 当 `store.username` 变化时,整个 effect 重跑,新值会被刷进 `formState`。
|
|
123
|
+
*
|
|
124
|
+
* prop 派生字段(initValues / config / ...)已经在上方用 getter 定义,
|
|
125
|
+
* 这里不再重复同步;因此 `props.initValues` 这类高频变化也不会再触发
|
|
126
|
+
* `extendState` 重跑(旧版的性能问题修复点)。
|
|
127
|
+
*
|
|
128
|
+
* 实现细节:
|
|
129
|
+
* - data 描述符:通过 `formState[key] = value` 走 reactive proxy 的 set,
|
|
130
|
+
* 触发依赖通知;与旧版「逐项赋值」语义完全等价。
|
|
131
|
+
* - accessor 描述符(`{ get stage() {...} }`)按原样写入 formState,调用方
|
|
132
|
+
* 可以自行控制读时求值;强制 `configurable: true` 以便下一次重跑可再 define。
|
|
133
|
+
*/
|
|
134
|
+
watchEffect(async (onCleanup) => {
|
|
135
|
+
const { extendState } = props;
|
|
136
|
+
if (typeof extendState !== "function") return;
|
|
137
|
+
let stale = false;
|
|
138
|
+
onCleanup(() => {
|
|
139
|
+
stale = true;
|
|
140
|
+
});
|
|
141
|
+
let state = {};
|
|
142
|
+
try {
|
|
143
|
+
state = await extendState(formState) || {};
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error("[MForm] extendState failed:", e);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (stale) return;
|
|
149
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(state))) if ("value" in descriptor) formState[key] = state[key];
|
|
150
|
+
else {
|
|
151
|
+
descriptor.configurable = true;
|
|
152
|
+
Object.defineProperty(formState, key, descriptor);
|
|
92
153
|
}
|
|
93
154
|
});
|
|
94
155
|
provide("mForm", formState);
|
|
156
|
+
provide(FORM_DIFF_CONFIG_KEY, {
|
|
157
|
+
get showDiff() {
|
|
158
|
+
return props.showDiff;
|
|
159
|
+
},
|
|
160
|
+
get selfDiffFieldTypes() {
|
|
161
|
+
return props.selfDiffFieldTypes;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
95
164
|
const changeRecords = shallowRef([]);
|
|
96
165
|
watch([() => props.config, () => props.initValues], ([config], [preConfig]) => {
|
|
97
166
|
changeRecords.value = [];
|
|
@@ -208,7 +277,11 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
208
277
|
"step-active": __props.stepActive,
|
|
209
278
|
size: __props.size,
|
|
210
279
|
onChange: changeHandler
|
|
211
|
-
},
|
|
280
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.label ? {
|
|
281
|
+
name: "label",
|
|
282
|
+
fn: withCtx((labelProps) => [renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, labelProps))]),
|
|
283
|
+
key: "0"
|
|
284
|
+
} : void 0]), 1032, [
|
|
212
285
|
"disabled",
|
|
213
286
|
"config",
|
|
214
287
|
"model",
|
|
@@ -219,7 +292,7 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
219
292
|
"size"
|
|
220
293
|
]);
|
|
221
294
|
}), 128)) : createCommentVNode("v-if", true)]),
|
|
222
|
-
_:
|
|
295
|
+
_: 3
|
|
223
296
|
}, 8, [
|
|
224
297
|
"model",
|
|
225
298
|
"label-width",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { FORM_DIFF_CONFIG_KEY } from "../schema.js";
|
|
1
2
|
import Hidden_default from "../fields/Hidden.js";
|
|
2
3
|
import { getField } from "../utils/config.js";
|
|
3
4
|
import { createObjectProp, display, filterFunction, getRules } from "../utils/form.js";
|
|
4
5
|
import FormLabel_default from "./FormLabel.js";
|
|
5
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, readonly, ref, renderList, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, readonly, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
|
|
6
7
|
import { isEqual } from "lodash-es";
|
|
7
8
|
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from "@tmagic/design";
|
|
8
9
|
import { getValueByKeyPath } from "@tmagic/utils";
|
|
@@ -15,7 +16,8 @@ var _hoisted_4 = ["innerHTML"];
|
|
|
15
16
|
var _hoisted_5 = ["innerHTML"];
|
|
16
17
|
var _hoisted_6 = ["innerHTML"];
|
|
17
18
|
var _hoisted_7 = ["innerHTML"];
|
|
18
|
-
var _hoisted_8 =
|
|
19
|
+
var _hoisted_8 = ["innerHTML"];
|
|
20
|
+
var _hoisted_9 = {
|
|
19
21
|
key: 5,
|
|
20
22
|
style: { "text-align": "center" }
|
|
21
23
|
};
|
|
@@ -45,11 +47,20 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
45
47
|
const props = __props;
|
|
46
48
|
const emit = __emit;
|
|
47
49
|
const mForm = inject("mForm");
|
|
50
|
+
const diffConfig = inject(FORM_DIFF_CONFIG_KEY, {});
|
|
48
51
|
const expand = ref(false);
|
|
49
52
|
const name = computed(() => props.config.name || "");
|
|
50
53
|
const showDiff = computed(() => {
|
|
51
54
|
if (!props.isCompare) return false;
|
|
52
|
-
|
|
55
|
+
const curValue = name.value ? props.model[name.value] : props.model;
|
|
56
|
+
const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
|
|
57
|
+
const customShowDiff = diffConfig.showDiff;
|
|
58
|
+
if (typeof customShowDiff === "function") return Boolean(customShowDiff({
|
|
59
|
+
curValue,
|
|
60
|
+
lastValue,
|
|
61
|
+
config: props.config
|
|
62
|
+
}));
|
|
63
|
+
return !isEqual(curValue, lastValue);
|
|
53
64
|
});
|
|
54
65
|
const items = computed(() => props.config.items);
|
|
55
66
|
const itemProp = computed(() => {
|
|
@@ -70,6 +81,35 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
70
81
|
if (type.value === "component" && props.config.component) return props.config.component;
|
|
71
82
|
return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
|
|
72
83
|
});
|
|
84
|
+
/**
|
|
85
|
+
* 自接管对比的字段类型白名单。
|
|
86
|
+
*
|
|
87
|
+
* 这类字段在 `isCompare === true` 且存在差异时,不再由 Container 渲染前后两份独立组件来对比,
|
|
88
|
+
* 而是只渲染一次组件,将 `model` / `lastValues` / `isCompare` 一并传给字段组件,
|
|
89
|
+
* 由字段组件内部自行展示前后差异(典型场景:vs-code 字段使用 monaco 自带的 diff 编辑器)。
|
|
90
|
+
*
|
|
91
|
+
* 这样做的好处:
|
|
92
|
+
* 1. 避免重型字段(如 monaco 编辑器)在对比模式下被实例化两次,节省资源;
|
|
93
|
+
* 2. 提供更专业的对比视觉效果(如 monaco diff 的行级高亮、左右滚动同步等)。
|
|
94
|
+
*
|
|
95
|
+
* 注意:像 `event-select` / `code-select-col` 这类内部由列表 / 嵌套子表单组成的复合字段,若按默认逻辑
|
|
96
|
+
* 渲染前后两份独立组件,会出现两套下拉框 + 两份参数表单(或两套「添加事件」按钮、两份完整面板),
|
|
97
|
+
* 体验很差。这类字段在内部把 `is-compare`/`lastValues` 透传给子级容器,由子级逐项展示差异,
|
|
98
|
+
* 因此同样归类为自接管对比字段。
|
|
99
|
+
*/
|
|
100
|
+
const DEFAULT_SELF_DIFF_FIELD_TYPES = [
|
|
101
|
+
"vs-code",
|
|
102
|
+
"event-select",
|
|
103
|
+
"code-select-col",
|
|
104
|
+
"code-select"
|
|
105
|
+
];
|
|
106
|
+
const effectiveSelfDiffFieldTypes = computed(() => {
|
|
107
|
+
const custom = diffConfig.selfDiffFieldTypes;
|
|
108
|
+
if (typeof custom === "function") return new Set(custom([...DEFAULT_SELF_DIFF_FIELD_TYPES]));
|
|
109
|
+
if (Array.isArray(custom)) return new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
|
|
110
|
+
return new Set(DEFAULT_SELF_DIFF_FIELD_TYPES);
|
|
111
|
+
});
|
|
112
|
+
const isSelfDiffField = computed(() => effectiveSelfDiffFieldTypes.value.has(type.value));
|
|
73
113
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
74
114
|
const text = computed(() => filterFunction(mForm, props.config.text, props));
|
|
75
115
|
const tooltip = computed(() => {
|
|
@@ -238,7 +278,13 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
238
278
|
"label-width",
|
|
239
279
|
"style"
|
|
240
280
|
])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value } }), {
|
|
241
|
-
label: withCtx(() => [
|
|
281
|
+
label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
|
|
282
|
+
config: __props.config,
|
|
283
|
+
type: type.value,
|
|
284
|
+
text: text.value,
|
|
285
|
+
prop: itemProp.value,
|
|
286
|
+
disabled: disabled.value
|
|
287
|
+
}, () => [createVNode(FormLabel_default, {
|
|
242
288
|
tip: __props.config.tip,
|
|
243
289
|
type: type.value,
|
|
244
290
|
"use-label": __props.config.useLabel,
|
|
@@ -250,7 +296,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
250
296
|
"use-label",
|
|
251
297
|
"label-title",
|
|
252
298
|
"text"
|
|
253
|
-
])]),
|
|
299
|
+
])])]),
|
|
254
300
|
default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
255
301
|
key: 0,
|
|
256
302
|
placement: tooltip.value.placement
|
|
@@ -279,7 +325,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
279
325
|
"last-values",
|
|
280
326
|
"is-compare"
|
|
281
327
|
]))]),
|
|
282
|
-
_:
|
|
328
|
+
_: 3
|
|
283
329
|
}, 16, ["class"]), __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
284
330
|
key: 0,
|
|
285
331
|
placement: "top"
|
|
@@ -295,12 +341,18 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
295
341
|
_: 1
|
|
296
342
|
})) : createCommentVNode("v-if", true)], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
297
343
|
createCommentVNode(" 对比 "),
|
|
298
|
-
createCommentVNode("
|
|
299
|
-
|
|
344
|
+
createCommentVNode(" 自接管对比的字段类型(如 vs-code):只渲染一次组件,由字段内部用 diff 编辑器/视图自行展示前后差异 "),
|
|
345
|
+
isSelfDiffField.value ? (openBlock(), createBlock(unref(TMagicFormItem), mergeProps({ key: 0 }, formItemProps.value, { class: {
|
|
300
346
|
"tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
|
|
301
|
-
"
|
|
347
|
+
"self-diff": true
|
|
302
348
|
} }), {
|
|
303
|
-
label: withCtx(() => [
|
|
349
|
+
label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
|
|
350
|
+
config: __props.config,
|
|
351
|
+
type: type.value,
|
|
352
|
+
text: text.value,
|
|
353
|
+
prop: itemProp.value,
|
|
354
|
+
disabled: disabled.value
|
|
355
|
+
}, () => [createVNode(FormLabel_default, {
|
|
304
356
|
tip: __props.config.tip,
|
|
305
357
|
type: type.value,
|
|
306
358
|
"use-label": __props.config.useLabel,
|
|
@@ -312,88 +364,148 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
312
364
|
"use-label",
|
|
313
365
|
"label-title",
|
|
314
366
|
"text"
|
|
315
|
-
])]),
|
|
367
|
+
])])]),
|
|
316
368
|
default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
317
369
|
key: 0,
|
|
318
370
|
placement: tooltip.value.placement
|
|
319
371
|
}, {
|
|
320
372
|
content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_4)]),
|
|
321
373
|
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
|
|
322
|
-
model: __props.
|
|
374
|
+
model: __props.model,
|
|
375
|
+
"last-values": __props.lastValues,
|
|
376
|
+
"is-compare": __props.isCompare,
|
|
323
377
|
onChange: onChangeHandler
|
|
324
|
-
}), null, 16, [
|
|
378
|
+
}), null, 16, [
|
|
379
|
+
"model",
|
|
380
|
+
"last-values",
|
|
381
|
+
"is-compare"
|
|
382
|
+
]))]),
|
|
325
383
|
_: 1
|
|
326
384
|
}, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
|
|
327
|
-
model: __props.
|
|
385
|
+
model: __props.model,
|
|
386
|
+
"last-values": __props.lastValues,
|
|
387
|
+
"is-compare": __props.isCompare,
|
|
328
388
|
onChange: onChangeHandler
|
|
329
|
-
}), null, 16, [
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}, {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"margin-left": "5px"
|
|
340
|
-
} }, {
|
|
341
|
-
default: withCtx(() => [createVNode(unref(WarningFilled))]),
|
|
342
|
-
_: 1
|
|
343
|
-
})]),
|
|
344
|
-
_: 1
|
|
345
|
-
})) : createCommentVNode("v-if", true),
|
|
346
|
-
createCommentVNode(" 当前内容 "),
|
|
347
|
-
createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
|
|
348
|
-
style: __props.config.tip ? "flex: 1" : "",
|
|
349
|
-
class: {
|
|
389
|
+
}), null, 16, [
|
|
390
|
+
"model",
|
|
391
|
+
"last-values",
|
|
392
|
+
"is-compare"
|
|
393
|
+
]))]),
|
|
394
|
+
_: 3
|
|
395
|
+
}, 16, ["class"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
396
|
+
createCommentVNode(" 普通字段:渲染前后两份独立的组件用于对比 "),
|
|
397
|
+
createCommentVNode(" 上次内容 "),
|
|
398
|
+
createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: {
|
|
350
399
|
"tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
|
|
351
|
-
"show-diff": true
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
400
|
+
"show-before-diff": true
|
|
401
|
+
} }), {
|
|
402
|
+
label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
|
|
403
|
+
config: __props.config,
|
|
404
|
+
type: type.value,
|
|
405
|
+
text: text.value,
|
|
406
|
+
prop: itemProp.value,
|
|
407
|
+
disabled: disabled.value
|
|
408
|
+
}, () => [createVNode(FormLabel_default, {
|
|
409
|
+
tip: __props.config.tip,
|
|
410
|
+
type: type.value,
|
|
411
|
+
"use-label": __props.config.useLabel,
|
|
412
|
+
"label-title": __props.config.labelTitle,
|
|
413
|
+
text: text.value
|
|
414
|
+
}, null, 8, [
|
|
415
|
+
"tip",
|
|
416
|
+
"type",
|
|
417
|
+
"use-label",
|
|
418
|
+
"label-title",
|
|
419
|
+
"text"
|
|
420
|
+
])])]),
|
|
421
|
+
default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
422
|
+
key: 0,
|
|
423
|
+
placement: tooltip.value.placement
|
|
424
|
+
}, {
|
|
425
|
+
content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_5)]),
|
|
426
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
|
|
427
|
+
model: __props.lastValues,
|
|
428
|
+
onChange: onChangeHandler
|
|
429
|
+
}), null, 16, ["model"]))]),
|
|
430
|
+
_: 1
|
|
431
|
+
}, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
|
|
432
|
+
model: __props.lastValues,
|
|
433
|
+
onChange: onChangeHandler
|
|
434
|
+
}), null, 16, ["model"]))]),
|
|
435
|
+
_: 3
|
|
436
|
+
}, 16, ["class"]),
|
|
437
|
+
__props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
368
438
|
key: 0,
|
|
369
|
-
placement:
|
|
439
|
+
placement: "top"
|
|
370
440
|
}, {
|
|
371
|
-
content: withCtx(() => [createElementVNode("div", { innerHTML:
|
|
372
|
-
default: withCtx(() => [(
|
|
441
|
+
content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_6)]),
|
|
442
|
+
default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
|
|
443
|
+
"line-height": "40px",
|
|
444
|
+
"margin-left": "5px"
|
|
445
|
+
} }, {
|
|
446
|
+
default: withCtx(() => [createVNode(unref(WarningFilled))]),
|
|
447
|
+
_: 1
|
|
448
|
+
})]),
|
|
449
|
+
_: 1
|
|
450
|
+
})) : createCommentVNode("v-if", true),
|
|
451
|
+
createCommentVNode(" 当前内容 "),
|
|
452
|
+
createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
|
|
453
|
+
style: __props.config.tip ? "flex: 1" : "",
|
|
454
|
+
class: {
|
|
455
|
+
"tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
|
|
456
|
+
"show-after-diff": true
|
|
457
|
+
}
|
|
458
|
+
}), {
|
|
459
|
+
label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
|
|
460
|
+
config: __props.config,
|
|
461
|
+
type: type.value,
|
|
462
|
+
text: text.value,
|
|
463
|
+
prop: itemProp.value,
|
|
464
|
+
disabled: disabled.value
|
|
465
|
+
}, () => [createVNode(FormLabel_default, {
|
|
466
|
+
tip: __props.config.tip,
|
|
467
|
+
type: type.value,
|
|
468
|
+
"use-label": __props.config.useLabel,
|
|
469
|
+
"label-title": __props.config.labelTitle,
|
|
470
|
+
text: text.value
|
|
471
|
+
}, null, 8, [
|
|
472
|
+
"tip",
|
|
473
|
+
"type",
|
|
474
|
+
"use-label",
|
|
475
|
+
"label-title",
|
|
476
|
+
"text"
|
|
477
|
+
])])]),
|
|
478
|
+
default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
479
|
+
key: 0,
|
|
480
|
+
placement: tooltip.value.placement
|
|
481
|
+
}, {
|
|
482
|
+
content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_7)]),
|
|
483
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
|
|
484
|
+
model: __props.model,
|
|
485
|
+
onChange: onChangeHandler
|
|
486
|
+
}), null, 16, ["model"]))]),
|
|
487
|
+
_: 1
|
|
488
|
+
}, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
|
|
373
489
|
model: __props.model,
|
|
374
490
|
onChange: onChangeHandler
|
|
375
491
|
}), null, 16, ["model"]))]),
|
|
492
|
+
_: 3
|
|
493
|
+
}, 16, ["style", "class"]),
|
|
494
|
+
__props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
495
|
+
key: 1,
|
|
496
|
+
placement: "top"
|
|
497
|
+
}, {
|
|
498
|
+
content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_8)]),
|
|
499
|
+
default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
|
|
500
|
+
"line-height": "40px",
|
|
501
|
+
"margin-left": "5px"
|
|
502
|
+
} }, {
|
|
503
|
+
default: withCtx(() => [createVNode(unref(WarningFilled))]),
|
|
504
|
+
_: 1
|
|
505
|
+
})]),
|
|
376
506
|
_: 1
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
onChange: onChangeHandler
|
|
380
|
-
}), null, 16, ["model"]))]),
|
|
381
|
-
_: 1
|
|
382
|
-
}, 16, ["style", "class"]),
|
|
383
|
-
__props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
384
|
-
key: 1,
|
|
385
|
-
placement: "top"
|
|
386
|
-
}, {
|
|
387
|
-
content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_7)]),
|
|
388
|
-
default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
|
|
389
|
-
"line-height": "40px",
|
|
390
|
-
"margin-left": "5px"
|
|
391
|
-
} }, {
|
|
392
|
-
default: withCtx(() => [createVNode(unref(WarningFilled))]),
|
|
393
|
-
_: 1
|
|
394
|
-
})]),
|
|
395
|
-
_: 1
|
|
396
|
-
})) : createCommentVNode("v-if", true)
|
|
507
|
+
})) : createCommentVNode("v-if", true)
|
|
508
|
+
], 64))
|
|
397
509
|
], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [(isValidName() ? __props.model[name.value] : __props.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
|
|
398
510
|
return openBlock(), createBlock(_component_Container, {
|
|
399
511
|
key: key(item),
|
|
@@ -409,7 +521,11 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
409
521
|
prop: itemProp.value,
|
|
410
522
|
onChange: onChangeHandler,
|
|
411
523
|
onAddDiffCount
|
|
412
|
-
},
|
|
524
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.label ? {
|
|
525
|
+
name: "label",
|
|
526
|
+
fn: withCtx((labelProps) => [renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, labelProps))]),
|
|
527
|
+
key: "0"
|
|
528
|
+
} : void 0]), 1032, [
|
|
413
529
|
"model",
|
|
414
530
|
"last-values",
|
|
415
531
|
"is-compare",
|
|
@@ -421,7 +537,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
421
537
|
"label-width",
|
|
422
538
|
"prop"
|
|
423
539
|
]);
|
|
424
|
-
}), 128)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true), __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div",
|
|
540
|
+
}), 128)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true), __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_9, [createVNode(unref(TMagicButton), {
|
|
425
541
|
type: "primary",
|
|
426
542
|
size: "small",
|
|
427
543
|
disabled: false,
|
|
@@ -8,7 +8,10 @@ var _hoisted_3 = {
|
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "el-table__empty-block"
|
|
10
10
|
};
|
|
11
|
-
var _hoisted_4 = {
|
|
11
|
+
var _hoisted_4 = {
|
|
12
|
+
key: 3,
|
|
13
|
+
class: "m-fields-group-list-footer"
|
|
14
|
+
};
|
|
12
15
|
var _hoisted_5 = { style: {
|
|
13
16
|
"display": "flex",
|
|
14
17
|
"justify-content": "flex-end",
|
|
@@ -91,7 +94,7 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
91
94
|
"group-model"
|
|
92
95
|
]);
|
|
93
96
|
}), 128)),
|
|
94
|
-
|
|
97
|
+
!__props.isCompare ? (openBlock(), createElementBlock("div", _hoisted_4, [renderSlot(_ctx.$slots, "toggle-button"), createElementVNode("div", _hoisted_5, [renderSlot(_ctx.$slots, "add-button")])])) : createCommentVNode("v-if", true)
|
|
95
98
|
]);
|
|
96
99
|
};
|
|
97
100
|
}
|
|
@@ -99,16 +99,17 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
99
99
|
}), createElementVNode("span", { innerHTML: title.value }, null, 8, _hoisted_1)]),
|
|
100
100
|
_: 1
|
|
101
101
|
}, 8, ["disabled"]),
|
|
102
|
-
withDirectives(
|
|
102
|
+
!__props.isCompare ? withDirectives((openBlock(), createBlock(unref(TMagicButton), {
|
|
103
|
+
key: 0,
|
|
103
104
|
type: "danger",
|
|
104
105
|
size: "small",
|
|
105
106
|
link: "",
|
|
106
107
|
icon: unref(Delete),
|
|
107
108
|
disabled: __props.disabled,
|
|
108
109
|
onClick: removeHandler
|
|
109
|
-
}, null, 8, ["icon", "disabled"]), [[vShow, showDelete.value]]),
|
|
110
|
-
copyable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
111
|
-
key:
|
|
110
|
+
}, null, 8, ["icon", "disabled"])), [[vShow, showDelete.value]]) : createCommentVNode("v-if", true),
|
|
111
|
+
copyable.value && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
112
|
+
key: 1,
|
|
112
113
|
link: "",
|
|
113
114
|
size: "small",
|
|
114
115
|
type: "primary",
|
|
@@ -119,7 +120,7 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
119
120
|
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("复制", -1)])]),
|
|
120
121
|
_: 1
|
|
121
122
|
}, 8, ["icon", "disabled"])) : createCommentVNode("v-if", true),
|
|
122
|
-
movable.value ? (openBlock(), createElementBlock(Fragment, { key:
|
|
123
|
+
movable.value && !__props.isCompare ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [withDirectives(createVNode(unref(TMagicButton), {
|
|
123
124
|
link: "",
|
|
124
125
|
size: "small",
|
|
125
126
|
disabled: __props.disabled,
|
|
@@ -138,8 +139,8 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
138
139
|
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("下移", -1)])]),
|
|
139
140
|
_: 1
|
|
140
141
|
}, 8, ["disabled", "icon"]), [[vShow, __props.index !== length.value - 1]])], 64)) : createCommentVNode("v-if", true),
|
|
141
|
-
__props.config.moveSpecifyLocation ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
142
|
-
key:
|
|
142
|
+
__props.config.moveSpecifyLocation && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
143
|
+
key: 3,
|
|
143
144
|
trigger: "click",
|
|
144
145
|
placement: "top",
|
|
145
146
|
width: "200",
|
|
@@ -185,7 +186,7 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
185
186
|
_: 1
|
|
186
187
|
}, 8, ["visible"])) : createCommentVNode("v-if", true),
|
|
187
188
|
itemExtra.value ? (openBlock(), createElementBlock("span", {
|
|
188
|
-
key:
|
|
189
|
+
key: 4,
|
|
189
190
|
innerHTML: itemExtra.value,
|
|
190
191
|
class: "m-form-tip"
|
|
191
192
|
}, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { display, filterFunction, initValue } from "../utils/form.js";
|
|
2
2
|
import Container_default from "./Container.js";
|
|
3
|
-
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, unref, watchEffect, withCtx } from "vue";
|
|
3
|
+
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, unref, watch, watchEffect, withCtx } from "vue";
|
|
4
4
|
import { isEmpty } from "lodash-es";
|
|
5
5
|
import { TMagicBadge, getDesignConfig } from "@tmagic/design";
|
|
6
6
|
//#region packages/form/src/containers/Tabs.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -74,6 +74,9 @@ var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
74
74
|
prop: props.prop
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
watch([() => props.model, () => props.lastValues], () => {
|
|
78
|
+
diffCount.value = {};
|
|
79
|
+
});
|
|
77
80
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
78
81
|
const tabClickHandler = (tab) => {
|
|
79
82
|
if (typeof tab === "object") tabClick(mForm, tab, props);
|
|
@@ -148,7 +151,7 @@ var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
148
151
|
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(tabs.value, (tab, tabIndex) => {
|
|
149
152
|
return openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), mergeProps({ key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex }, { ref_for: true }, unref(tabPaneComponent)?.props({
|
|
150
153
|
name: filter(tab.status) || tabIndex.toString(),
|
|
151
|
-
lazy: tab.lazy || false
|
|
154
|
+
lazy: __props.isCompare ? false : tab.lazy || false
|
|
152
155
|
}) || {}), {
|
|
153
156
|
label: withCtx(() => [createElementVNode("span", null, [createTextVNode(toDisplayString(filter(tab.title)), 1), createVNode(unref(TMagicBadge), {
|
|
154
157
|
hidden: !diffCount.value[Number(tabIndex)],
|
|
@@ -122,7 +122,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
122
122
|
default: withCtx(() => [createTextVNode(toDisplayString(unref(isFullscreen) ? "退出全屏" : "全屏编辑"), 1)]),
|
|
123
123
|
_: 1
|
|
124
124
|
}, 8, ["icon", "onClick"])) : createCommentVNode("v-if", true),
|
|
125
|
-
unref(importable) ? (openBlock(), createBlock(unref(TMagicUpload), {
|
|
125
|
+
unref(importable) && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicUpload), {
|
|
126
126
|
key: 2,
|
|
127
127
|
style: { "display": "inline-block" },
|
|
128
128
|
ref: "excelBtn",
|
|
@@ -142,7 +142,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
142
142
|
}, 8, ["disabled"])]),
|
|
143
143
|
_: 1
|
|
144
144
|
}, 8, ["disabled", "on-change"])) : createCommentVNode("v-if", true),
|
|
145
|
-
unref(importable) ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
145
|
+
unref(importable) && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
146
146
|
key: 3,
|
|
147
147
|
size: "small",
|
|
148
148
|
type: "warning",
|
|
@@ -153,7 +153,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
153
153
|
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("清空", -1)])]),
|
|
154
154
|
_: 1
|
|
155
155
|
}, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true)
|
|
156
|
-
]), renderSlot(_ctx.$slots, "add-button")]),
|
|
156
|
+
]), !__props.isCompare ? renderSlot(_ctx.$slots, "add-button", { key: 0 }) : createCommentVNode("v-if", true)]),
|
|
157
157
|
__props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(unref(TMagicPagination), {
|
|
158
158
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
159
159
|
"hide-on-single-page": __props.model[modelName.value].length < unref(pageSize),
|