@tmagic/form 1.5.0-beta.13 → 1.5.0-beta.15
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/style.css +51 -0
- package/dist/tmagic-form.js +245 -140
- package/dist/tmagic-form.umd.cjs +245 -141
- package/package.json +8 -6
- package/src/Form.vue +17 -6
- package/src/FormBox.vue +9 -5
- package/src/FormDialog.vue +4 -4
- package/src/FormDrawer.vue +4 -4
- package/src/containers/Col.vue +6 -3
- package/src/containers/Container.vue +86 -31
- package/src/containers/Fieldset.vue +13 -12
- package/src/containers/GroupList.vue +26 -10
- package/src/containers/GroupListItem.vue +4 -2
- package/src/containers/Panel.vue +8 -3
- package/src/containers/Row.vue +8 -3
- package/src/containers/Step.vue +9 -4
- package/src/containers/Table.vue +15 -3
- package/src/containers/Tabs.vue +35 -20
- package/src/fields/DateTime.vue +2 -2
- package/src/fields/DynamicField.vue +4 -2
- package/src/fields/Text.vue +71 -36
- package/src/index.ts +2 -2
- package/src/schema.ts +26 -16
- package/src/theme/text.scss +56 -0
- package/types/index.d.ts +410 -672
package/dist/tmagic-form.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
|
|
1
|
+
import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, shallowRef, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
|
|
2
2
|
import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
|
|
3
|
-
import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
|
|
4
|
-
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch,
|
|
3
|
+
import { cloneDeep, isEqual, isEmpty, debounce } from 'lodash-es';
|
|
4
|
+
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import utc from 'dayjs/plugin/utc';
|
|
7
7
|
import Sortable from 'sortablejs';
|
|
8
8
|
import { sleep, asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
|
|
9
|
+
import { createPopper } from '@popperjs/core';
|
|
9
10
|
|
|
10
11
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
11
12
|
const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
|
|
@@ -243,7 +244,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
243
244
|
} else {
|
|
244
245
|
return props.prop;
|
|
245
246
|
}
|
|
246
|
-
|
|
247
|
+
if (typeof props.prop !== "undefined" && props.prop !== "") {
|
|
248
|
+
return `${props.prop}.${n}`;
|
|
249
|
+
}
|
|
250
|
+
return `${n}`;
|
|
247
251
|
});
|
|
248
252
|
const tagName = computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
249
253
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
@@ -299,40 +303,69 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
299
303
|
}
|
|
300
304
|
return value;
|
|
301
305
|
};
|
|
302
|
-
const changeHandler = (onChange, value) => {
|
|
303
|
-
if (typeof onChange === "function") {
|
|
304
|
-
return onChange(mForm, value, {
|
|
305
|
-
model: props.model,
|
|
306
|
-
values: mForm?.initValues,
|
|
307
|
-
formValue: mForm?.values,
|
|
308
|
-
prop: itemProp.value,
|
|
309
|
-
config: props.config
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
306
|
const trimHandler = (trim, value) => {
|
|
314
307
|
if (typeof value === "string" && trim) {
|
|
315
308
|
return value.replace(/^\s*/, "").replace(/\s*$/, "");
|
|
316
309
|
}
|
|
317
310
|
};
|
|
318
311
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
const hasModifyKey = (eventDataItem) => typeof eventDataItem?.modifyKey !== "undefined" && eventDataItem.modifyKey !== "";
|
|
313
|
+
const isValidName = () => {
|
|
314
|
+
const valueType = typeof name.value;
|
|
315
|
+
if (valueType !== "string" && valueType !== "symbol" && valueType !== "number") {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
if (name.value === "") {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
if (typeof name.value === "number") {
|
|
322
|
+
return name.value >= 0;
|
|
323
|
+
}
|
|
324
|
+
return true;
|
|
325
|
+
};
|
|
326
|
+
const onChangeHandler = async function(v, eventData = {}) {
|
|
327
|
+
const { filter, onChange, trim, dynamicKey } = props.config;
|
|
328
|
+
let value = toRaw(v);
|
|
329
|
+
const changeRecords = eventData.changeRecords || [];
|
|
330
|
+
const newChangeRecords = [...changeRecords];
|
|
322
331
|
try {
|
|
323
332
|
value = filterHandler(filter, v);
|
|
324
|
-
|
|
333
|
+
if (typeof onChange === "function") {
|
|
334
|
+
value = await onChange(mForm, value, {
|
|
335
|
+
model: props.model,
|
|
336
|
+
values: mForm?.initValues,
|
|
337
|
+
formValue: mForm?.values,
|
|
338
|
+
prop: itemProp.value,
|
|
339
|
+
config: props.config,
|
|
340
|
+
changeRecords: newChangeRecords
|
|
341
|
+
}) ?? value;
|
|
342
|
+
}
|
|
325
343
|
value = trimHandler(trim, value) ?? value;
|
|
326
344
|
} catch (e) {
|
|
327
345
|
console.error(e);
|
|
328
346
|
}
|
|
329
|
-
|
|
330
|
-
|
|
347
|
+
let valueProp = itemProp.value;
|
|
348
|
+
if (hasModifyKey(eventData)) {
|
|
349
|
+
if (dynamicKey) {
|
|
350
|
+
props.model[eventData.modifyKey] = value;
|
|
351
|
+
} else if (isValidName()) {
|
|
352
|
+
props.model[name.value][eventData.modifyKey] = value;
|
|
353
|
+
}
|
|
354
|
+
valueProp = valueProp ? `${valueProp}.${eventData.modifyKey}` : eventData.modifyKey;
|
|
355
|
+
delete eventData.modifyKey;
|
|
356
|
+
} else if (isValidName() && props.model !== value && (v !== value || props.model[name.value] !== value)) {
|
|
357
|
+
props.model[name.value] = value;
|
|
331
358
|
}
|
|
332
|
-
if (
|
|
333
|
-
|
|
359
|
+
if (changeRecords.length === 0) {
|
|
360
|
+
newChangeRecords.push({
|
|
361
|
+
propPath: valueProp,
|
|
362
|
+
value
|
|
363
|
+
});
|
|
334
364
|
}
|
|
335
|
-
emit("change", props.model
|
|
365
|
+
emit("change", props.model, {
|
|
366
|
+
...eventData,
|
|
367
|
+
changeRecords: newChangeRecords
|
|
368
|
+
});
|
|
336
369
|
};
|
|
337
370
|
return (_ctx, _cache) => {
|
|
338
371
|
const _component_m_fields_hidden = resolveComponent("m-fields-hidden");
|
|
@@ -577,11 +610,11 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
577
610
|
_: 1
|
|
578
611
|
})) : createCommentVNode("", true)
|
|
579
612
|
], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
|
580
|
-
(
|
|
613
|
+
(isValidName() ? _ctx.model[name.value] : _ctx.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
|
|
581
614
|
return openBlock(), createBlock(_component_Container, {
|
|
582
615
|
key: key(item),
|
|
583
|
-
model:
|
|
584
|
-
"last-values":
|
|
616
|
+
model: isValidName() ? _ctx.model[name.value] : _ctx.model,
|
|
617
|
+
"last-values": isValidName() ? _ctx.lastValues[name.value] || {} : _ctx.lastValues,
|
|
585
618
|
"is-compare": _ctx.isCompare,
|
|
586
619
|
config: item,
|
|
587
620
|
size: _ctx.size,
|
|
@@ -659,16 +692,17 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
659
692
|
}
|
|
660
693
|
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
661
694
|
});
|
|
662
|
-
const
|
|
663
|
-
emit("change",
|
|
695
|
+
const valueChangeHandler = (value) => {
|
|
696
|
+
emit("change", value, { modifyKey: "value" });
|
|
664
697
|
};
|
|
698
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
665
699
|
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
666
700
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
667
701
|
return (_ctx, _cache) => {
|
|
668
702
|
return (name.value ? _ctx.model[name.value] : _ctx.model) ? (openBlock(), createElementBlock("fieldset", {
|
|
669
703
|
key: 0,
|
|
670
704
|
class: "m-fieldset",
|
|
671
|
-
style: normalizeStyle(show.value ? "padding: 15px
|
|
705
|
+
style: normalizeStyle(show.value ? "padding: 15px" : "border: 0")
|
|
672
706
|
}, [
|
|
673
707
|
name.value && _ctx.config.checkbox ? (openBlock(), createBlock(resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
|
|
674
708
|
default: withCtx(() => [
|
|
@@ -676,7 +710,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
676
710
|
modelValue: _ctx.model[name.value].value,
|
|
677
711
|
"onUpdate:modelValue": [
|
|
678
712
|
_cache[0] || (_cache[0] = ($event) => _ctx.model[name.value].value = $event),
|
|
679
|
-
|
|
713
|
+
valueChangeHandler
|
|
680
714
|
],
|
|
681
715
|
prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.config.name}.value`,
|
|
682
716
|
"true-value": 1,
|
|
@@ -720,7 +754,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
720
754
|
disabled: _ctx.disabled,
|
|
721
755
|
labelWidth: lWidth.value,
|
|
722
756
|
size: _ctx.size,
|
|
723
|
-
onChange:
|
|
757
|
+
onChange: changeHandler,
|
|
724
758
|
onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
|
|
725
759
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
|
|
726
760
|
}), 128))
|
|
@@ -741,7 +775,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
741
775
|
labelWidth: lWidth.value,
|
|
742
776
|
size: _ctx.size,
|
|
743
777
|
disabled: _ctx.disabled,
|
|
744
|
-
onChange:
|
|
778
|
+
onChange: changeHandler,
|
|
745
779
|
onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
|
|
746
780
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
|
|
747
781
|
}), 128)) : createCommentVNode("", true)
|
|
@@ -795,7 +829,9 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
795
829
|
const length = computed(() => props.groupModel?.length || 0);
|
|
796
830
|
const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
797
831
|
const removeHandler = () => emit("remove-item", props.index);
|
|
798
|
-
const changeHandler = () =>
|
|
832
|
+
const changeHandler = (v, eventData) => {
|
|
833
|
+
emit("change", props.model, eventData);
|
|
834
|
+
};
|
|
799
835
|
const expandHandler = () => {
|
|
800
836
|
expand.value = !expand.value;
|
|
801
837
|
};
|
|
@@ -947,9 +983,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
947
983
|
}
|
|
948
984
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
949
985
|
});
|
|
950
|
-
const changeHandler = () => {
|
|
951
|
-
|
|
952
|
-
emit("change", props.model[props.name]);
|
|
986
|
+
const changeHandler = (v, eventData) => {
|
|
987
|
+
emit("change", props.model, eventData);
|
|
953
988
|
};
|
|
954
989
|
const addHandler = async () => {
|
|
955
990
|
if (!props.name) return false;
|
|
@@ -969,18 +1004,25 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
969
1004
|
initValues
|
|
970
1005
|
});
|
|
971
1006
|
props.model[props.name].push(groupValue);
|
|
972
|
-
|
|
1007
|
+
emit("change", props.model[props.name], {
|
|
1008
|
+
changeRecords: [
|
|
1009
|
+
{
|
|
1010
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
1011
|
+
value: groupValue
|
|
1012
|
+
}
|
|
1013
|
+
]
|
|
1014
|
+
});
|
|
973
1015
|
};
|
|
974
1016
|
const removeHandler = (index) => {
|
|
975
1017
|
if (!props.name) return false;
|
|
976
1018
|
props.model[props.name].splice(index, 1);
|
|
977
|
-
|
|
1019
|
+
emit("change", props.model[props.name]);
|
|
978
1020
|
};
|
|
979
1021
|
const swapHandler = (idx1, idx2) => {
|
|
980
1022
|
if (!props.name) return false;
|
|
981
1023
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
982
1024
|
props.model[props.name].splice(idx2, 0, currRow);
|
|
983
|
-
|
|
1025
|
+
emit("change", props.model[props.name]);
|
|
984
1026
|
};
|
|
985
1027
|
const toggleMode = () => {
|
|
986
1028
|
props.config.type = "table";
|
|
@@ -1023,15 +1065,16 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1023
1065
|
}), 128)),
|
|
1024
1066
|
addable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1025
1067
|
key: 3,
|
|
1026
|
-
|
|
1027
|
-
size: "small",
|
|
1028
|
-
disabled: _ctx.disabled
|
|
1068
|
+
type: "primary",
|
|
1069
|
+
size: _ctx.config.enableToggleMode ? "small" : "default",
|
|
1070
|
+
disabled: _ctx.disabled,
|
|
1071
|
+
onClick: addHandler
|
|
1029
1072
|
}, {
|
|
1030
1073
|
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
1031
1074
|
createTextVNode("新增")
|
|
1032
1075
|
])),
|
|
1033
1076
|
_: 1
|
|
1034
|
-
}, 8, ["disabled"])) : createCommentVNode("", true),
|
|
1077
|
+
}, 8, ["size", "disabled"])) : createCommentVNode("", true),
|
|
1035
1078
|
_ctx.config.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1036
1079
|
key: 4,
|
|
1037
1080
|
icon: unref(Grid),
|
|
@@ -1080,7 +1123,9 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1080
1123
|
const expand = ref(props.config.expand !== false);
|
|
1081
1124
|
const items = computed(() => props.config.items);
|
|
1082
1125
|
const filter = (config) => filterFunction(mForm, config, props);
|
|
1083
|
-
const changeHandler = () =>
|
|
1126
|
+
const changeHandler = (v, eventData) => {
|
|
1127
|
+
emit("change", props.model, eventData);
|
|
1128
|
+
};
|
|
1084
1129
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1085
1130
|
return (_ctx, _cache) => {
|
|
1086
1131
|
return items.value && items.value.length ? (openBlock(), createBlock(unref(TMagicCard), {
|
|
@@ -1177,7 +1222,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
1177
1222
|
const emit = __emit;
|
|
1178
1223
|
const mForm = inject("mForm");
|
|
1179
1224
|
const display$1 = computed(() => display(mForm, props.config.display, props));
|
|
1180
|
-
const changeHandler = () => emit("change",
|
|
1225
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
1181
1226
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1182
1227
|
return (_ctx, _cache) => {
|
|
1183
1228
|
return withDirectives((openBlock(), createBlock(unref(TMagicCol), { span: _ctx.span }, {
|
|
@@ -1226,7 +1271,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1226
1271
|
const props = __props;
|
|
1227
1272
|
const emit = __emit;
|
|
1228
1273
|
const mForm = inject("mForm");
|
|
1229
|
-
const changeHandler = () =>
|
|
1274
|
+
const changeHandler = (v, eventData) => {
|
|
1275
|
+
emit("change", props.name ? props.model[props.name] : props.model, eventData);
|
|
1276
|
+
};
|
|
1230
1277
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1231
1278
|
return (_ctx, _cache) => {
|
|
1232
1279
|
return openBlock(), createBlock(unref(TMagicRow), { gutter: 10 }, {
|
|
@@ -1262,6 +1309,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1262
1309
|
__name: "Step",
|
|
1263
1310
|
props: {
|
|
1264
1311
|
model: {},
|
|
1312
|
+
name: {},
|
|
1265
1313
|
lastValues: {},
|
|
1266
1314
|
isCompare: { type: Boolean },
|
|
1267
1315
|
config: {},
|
|
@@ -1283,8 +1331,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1283
1331
|
active.value = index + 1;
|
|
1284
1332
|
mForm?.$emit("update:stepActive", active.value);
|
|
1285
1333
|
};
|
|
1286
|
-
const changeHandler = () => {
|
|
1287
|
-
emit("change", props.model);
|
|
1334
|
+
const changeHandler = (v, eventData) => {
|
|
1335
|
+
emit("change", props.model, eventData);
|
|
1288
1336
|
};
|
|
1289
1337
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1290
1338
|
return (_ctx, _cache) => {
|
|
@@ -1493,7 +1541,14 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1493
1541
|
inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
|
|
1494
1542
|
}
|
|
1495
1543
|
props.model[modelName.value].push(inputs);
|
|
1496
|
-
emit("change", props.model[modelName.value]
|
|
1544
|
+
emit("change", props.model[modelName.value], {
|
|
1545
|
+
changeRecords: [
|
|
1546
|
+
{
|
|
1547
|
+
propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
|
|
1548
|
+
value: inputs
|
|
1549
|
+
}
|
|
1550
|
+
]
|
|
1551
|
+
});
|
|
1497
1552
|
};
|
|
1498
1553
|
onMounted(() => {
|
|
1499
1554
|
if (props.config.defautSort) {
|
|
@@ -1696,6 +1751,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1696
1751
|
return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
|
|
1697
1752
|
};
|
|
1698
1753
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1754
|
+
const changeHandler = (v, eventData) => {
|
|
1755
|
+
emit("change", props.model, eventData);
|
|
1756
|
+
};
|
|
1699
1757
|
__expose({
|
|
1700
1758
|
toggleRowSelection
|
|
1701
1759
|
});
|
|
@@ -1859,8 +1917,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1859
1917
|
lastValues: lastData.value[scope.$index],
|
|
1860
1918
|
"is-compare": _ctx.isCompare,
|
|
1861
1919
|
size: _ctx.size,
|
|
1862
|
-
onChange:
|
|
1863
|
-
onAddDiffCount: _cache[
|
|
1920
|
+
onChange: changeHandler,
|
|
1921
|
+
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
1864
1922
|
}, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : createCommentVNode("", true)
|
|
1865
1923
|
]),
|
|
1866
1924
|
_: 2
|
|
@@ -1881,9 +1939,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1881
1939
|
type: "primary",
|
|
1882
1940
|
disabled: _ctx.disabled,
|
|
1883
1941
|
plain: "",
|
|
1884
|
-
onClick: _cache[
|
|
1942
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
1885
1943
|
}, {
|
|
1886
|
-
default: withCtx(() => _cache[
|
|
1944
|
+
default: withCtx(() => _cache[3] || (_cache[3] = [
|
|
1887
1945
|
createTextVNode("新增一行")
|
|
1888
1946
|
])),
|
|
1889
1947
|
_: 1
|
|
@@ -1896,7 +1954,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1896
1954
|
type: "primary",
|
|
1897
1955
|
onClick: toggleMode
|
|
1898
1956
|
}, {
|
|
1899
|
-
default: withCtx(() => _cache[
|
|
1957
|
+
default: withCtx(() => _cache[4] || (_cache[4] = [
|
|
1900
1958
|
createTextVNode("展开配置")
|
|
1901
1959
|
])),
|
|
1902
1960
|
_: 1
|
|
@@ -1930,7 +1988,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1930
1988
|
disabled: _ctx.disabled,
|
|
1931
1989
|
plain: ""
|
|
1932
1990
|
}, {
|
|
1933
|
-
default: withCtx(() => _cache[
|
|
1991
|
+
default: withCtx(() => _cache[5] || (_cache[5] = [
|
|
1934
1992
|
createTextVNode("导入EXCEL")
|
|
1935
1993
|
])),
|
|
1936
1994
|
_: 1
|
|
@@ -1944,9 +2002,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1944
2002
|
type: "warning",
|
|
1945
2003
|
disabled: _ctx.disabled,
|
|
1946
2004
|
plain: "",
|
|
1947
|
-
onClick: _cache[
|
|
2005
|
+
onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
|
|
1948
2006
|
}, {
|
|
1949
|
-
default: withCtx(() => _cache[
|
|
2007
|
+
default: withCtx(() => _cache[6] || (_cache[6] = [
|
|
1950
2008
|
createTextVNode("清空")
|
|
1951
2009
|
])),
|
|
1952
2010
|
_: 1
|
|
@@ -2035,24 +2093,35 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2035
2093
|
});
|
|
2036
2094
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
2037
2095
|
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
2038
|
-
const onTabAdd = () => {
|
|
2039
|
-
if (!props.
|
|
2096
|
+
const onTabAdd = async () => {
|
|
2097
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2040
2098
|
if (typeof props.config.onTabAdd === "function") {
|
|
2041
2099
|
props.config.onTabAdd(mForm, {
|
|
2042
2100
|
model: props.model,
|
|
2043
2101
|
prop: props.prop,
|
|
2044
2102
|
config: props.config
|
|
2045
2103
|
});
|
|
2046
|
-
|
|
2047
|
-
|
|
2104
|
+
emit("change", props.model);
|
|
2105
|
+
} else {
|
|
2106
|
+
const newObj = await initValue(mForm, {
|
|
2107
|
+
config: props.config.items,
|
|
2108
|
+
initValues: {}
|
|
2109
|
+
});
|
|
2048
2110
|
newObj.title = `标签${tabs.value.length + 1}`;
|
|
2049
|
-
props.model[props.
|
|
2111
|
+
props.model[props.name].push(newObj);
|
|
2112
|
+
emit("change", props.model[props.name], {
|
|
2113
|
+
changeRecords: [
|
|
2114
|
+
{
|
|
2115
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
2116
|
+
value: newObj
|
|
2117
|
+
}
|
|
2118
|
+
]
|
|
2119
|
+
});
|
|
2050
2120
|
}
|
|
2051
|
-
emit("change", props.model);
|
|
2052
|
-
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2121
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2053
2122
|
};
|
|
2054
2123
|
const onTabRemove = (tabName) => {
|
|
2055
|
-
if (!props.
|
|
2124
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2056
2125
|
if (typeof props.config.onTabRemove === "function") {
|
|
2057
2126
|
props.config.onTabRemove(mForm, tabName, {
|
|
2058
2127
|
model: props.model,
|
|
@@ -2060,20 +2129,17 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2060
2129
|
config: props.config
|
|
2061
2130
|
});
|
|
2062
2131
|
} else {
|
|
2063
|
-
props.model[props.
|
|
2064
|
-
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.
|
|
2132
|
+
props.model[props.name].splice(+tabName, 1);
|
|
2133
|
+
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
|
|
2065
2134
|
activeTabName.value = (+activeTabName.value - 1).toString();
|
|
2066
2135
|
tabClick(mForm, { name: activeTabName.value }, props);
|
|
2067
2136
|
}
|
|
2068
2137
|
}
|
|
2069
2138
|
emit("change", props.model);
|
|
2070
|
-
mForm?.$emit("field-change", props.prop, props.model[props.
|
|
2139
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2071
2140
|
};
|
|
2072
|
-
const changeHandler = () => {
|
|
2073
|
-
emit("change", props.model);
|
|
2074
|
-
if (typeof props.config.onChange === "function") {
|
|
2075
|
-
props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
|
|
2076
|
-
}
|
|
2141
|
+
const changeHandler = (v, eventData) => {
|
|
2142
|
+
emit("change", props.model, eventData);
|
|
2077
2143
|
};
|
|
2078
2144
|
const onAddDiffCount = (tabIndex) => {
|
|
2079
2145
|
if (!diffCount.value[tabIndex]) {
|
|
@@ -2616,9 +2682,9 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
2616
2682
|
const props = __props;
|
|
2617
2683
|
const emit = __emit;
|
|
2618
2684
|
useAddField(props.prop);
|
|
2619
|
-
const value = props.model?.[props.name]
|
|
2685
|
+
const value = props.model?.[props.name]?.toString();
|
|
2620
2686
|
if (props.model) {
|
|
2621
|
-
if (value === "Invalid Date") {
|
|
2687
|
+
if (!value || value === "Invalid Date") {
|
|
2622
2688
|
props.model[props.name] = "";
|
|
2623
2689
|
} else {
|
|
2624
2690
|
props.model[props.name] = datetimeFormatter(
|
|
@@ -2717,7 +2783,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2717
2783
|
let oldVal = props.model?.[v.name] || "";
|
|
2718
2784
|
if (!oldVal && v.defaultValue !== void 0) {
|
|
2719
2785
|
oldVal = v.defaultValue;
|
|
2720
|
-
emit("change", oldVal, v.name);
|
|
2786
|
+
emit("change", oldVal, { modifyKey: v.name });
|
|
2721
2787
|
}
|
|
2722
2788
|
fieldMap.value[v.name] = oldVal;
|
|
2723
2789
|
fieldLabelMap.value[v.name] = v.label || "";
|
|
@@ -2740,7 +2806,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2740
2806
|
}
|
|
2741
2807
|
});
|
|
2742
2808
|
const inputChangeHandler = (key) => {
|
|
2743
|
-
emit("change", fieldMap.value[key],
|
|
2809
|
+
emit("change", fieldMap.value[key], {
|
|
2810
|
+
modifyKey: key
|
|
2811
|
+
});
|
|
2744
2812
|
};
|
|
2745
2813
|
return (_ctx, _cache) => {
|
|
2746
2814
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
@@ -2824,7 +2892,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2824
2892
|
preventSubmitDefault: { type: Boolean },
|
|
2825
2893
|
extendState: {}
|
|
2826
2894
|
},
|
|
2827
|
-
emits: ["change", "error", "field-input", "field-change"],
|
|
2895
|
+
emits: ["change", "error", "field-input", "field-change", "update:stepActive"],
|
|
2828
2896
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2829
2897
|
const props = __props;
|
|
2830
2898
|
const emit = __emit;
|
|
@@ -2874,9 +2942,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2874
2942
|
}
|
|
2875
2943
|
});
|
|
2876
2944
|
provide("mForm", formState);
|
|
2945
|
+
const changeRecords = shallowRef([]);
|
|
2877
2946
|
watch(
|
|
2878
2947
|
[() => props.config, () => props.initValues],
|
|
2879
2948
|
([config], [preConfig]) => {
|
|
2949
|
+
changeRecords.value = [];
|
|
2880
2950
|
if (!isEqual(toRaw(config), toRaw(preConfig))) {
|
|
2881
2951
|
initialized.value = false;
|
|
2882
2952
|
}
|
|
@@ -2899,8 +2969,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2899
2969
|
},
|
|
2900
2970
|
{ immediate: true }
|
|
2901
2971
|
);
|
|
2902
|
-
const changeHandler = () => {
|
|
2903
|
-
|
|
2972
|
+
const changeHandler = (v, eventData) => {
|
|
2973
|
+
if (eventData.changeRecords?.length) {
|
|
2974
|
+
changeRecords.value.push(...eventData.changeRecords);
|
|
2975
|
+
}
|
|
2976
|
+
emit("change", values.value, eventData);
|
|
2904
2977
|
};
|
|
2905
2978
|
const submitHandler = (e) => {
|
|
2906
2979
|
if (props.preventSubmitDefault) {
|
|
@@ -2912,8 +2985,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2912
2985
|
lastValuesProcessed,
|
|
2913
2986
|
formState,
|
|
2914
2987
|
initialized,
|
|
2988
|
+
changeRecords,
|
|
2915
2989
|
changeHandler,
|
|
2916
|
-
resetForm: () =>
|
|
2990
|
+
resetForm: () => {
|
|
2991
|
+
tMagicForm.value?.resetFields();
|
|
2992
|
+
changeRecords.value = [];
|
|
2993
|
+
},
|
|
2917
2994
|
submitForm: async (native) => {
|
|
2918
2995
|
try {
|
|
2919
2996
|
await tMagicForm.value?.validate();
|
|
@@ -3022,7 +3099,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3022
3099
|
const save = async () => {
|
|
3023
3100
|
try {
|
|
3024
3101
|
const values = await form.value?.submitForm();
|
|
3025
|
-
emit("submit", values);
|
|
3102
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
3026
3103
|
} catch (e) {
|
|
3027
3104
|
emit("error", e);
|
|
3028
3105
|
}
|
|
@@ -3033,8 +3110,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3033
3110
|
const nextStep = () => {
|
|
3034
3111
|
stepActive.value += 1;
|
|
3035
3112
|
};
|
|
3036
|
-
const changeHandler = (value) => {
|
|
3037
|
-
emit("change", value);
|
|
3113
|
+
const changeHandler = (value, eventData) => {
|
|
3114
|
+
emit("change", value, eventData);
|
|
3038
3115
|
};
|
|
3039
3116
|
const show = () => {
|
|
3040
3117
|
dialogVisible.value = true;
|
|
@@ -3883,7 +3960,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3883
3960
|
}
|
|
3884
3961
|
});
|
|
3885
3962
|
|
|
3886
|
-
const _hoisted_1$1 = {
|
|
3963
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3887
3964
|
const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3888
3965
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3889
3966
|
...{
|
|
@@ -3928,11 +4005,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3928
4005
|
emit("change", props.model[props.name].trim() || "");
|
|
3929
4006
|
popoverVisible.value = false;
|
|
3930
4007
|
};
|
|
3931
|
-
const checkWhiteSpace = (value) => {
|
|
4008
|
+
const checkWhiteSpace = debounce((value) => {
|
|
3932
4009
|
if (typeof value === "string" && !props.config.trim) {
|
|
3933
4010
|
popoverVisible.value = value.trim() !== value;
|
|
3934
4011
|
}
|
|
3935
|
-
};
|
|
4012
|
+
}, 300);
|
|
3936
4013
|
const changeHandler = (value) => {
|
|
3937
4014
|
emit("change", value);
|
|
3938
4015
|
};
|
|
@@ -3999,45 +4076,70 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3999
4076
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
4000
4077
|
emit("change", props.model[props.name]);
|
|
4001
4078
|
};
|
|
4079
|
+
const popoverEl = ref();
|
|
4080
|
+
const input = ref();
|
|
4081
|
+
const instanceRef = shallowRef();
|
|
4082
|
+
watch(popoverEl, (el) => {
|
|
4083
|
+
destroyPopover();
|
|
4084
|
+
if (!input.value?.$el || !el) return;
|
|
4085
|
+
instanceRef.value = createPopper(input.value.$el, el, {
|
|
4086
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
4087
|
+
strategy: "absolute",
|
|
4088
|
+
modifiers: [
|
|
4089
|
+
{
|
|
4090
|
+
name: "offset",
|
|
4091
|
+
options: {
|
|
4092
|
+
offset: [0, 10]
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
]
|
|
4096
|
+
});
|
|
4097
|
+
});
|
|
4098
|
+
const destroyPopover = () => {
|
|
4099
|
+
if (!instanceRef.value) return;
|
|
4100
|
+
instanceRef.value.destroy();
|
|
4101
|
+
instanceRef.value = void 0;
|
|
4102
|
+
};
|
|
4002
4103
|
return (_ctx, _cache) => {
|
|
4003
|
-
return openBlock(),
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4104
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
4105
|
+
createVNode(unref(TMagicInput), {
|
|
4106
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4107
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4108
|
+
ref_key: "input",
|
|
4109
|
+
ref: input,
|
|
4110
|
+
clearable: "",
|
|
4111
|
+
size: _ctx.size,
|
|
4112
|
+
placeholder: _ctx.config.placeholder,
|
|
4113
|
+
disabled: _ctx.disabled,
|
|
4114
|
+
onChange: changeHandler,
|
|
4115
|
+
onInput: inputHandler,
|
|
4116
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4117
|
+
}, createSlots({ _: 2 }, [
|
|
4118
|
+
appendConfig.value ? {
|
|
4119
|
+
name: "append",
|
|
4120
|
+
fn: withCtx(() => [
|
|
4121
|
+
appendConfig.value.type === "button" ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4122
|
+
key: 0,
|
|
4123
|
+
style: { "color": "#409eff" },
|
|
4124
|
+
size: _ctx.size,
|
|
4125
|
+
onClick: withModifiers(buttonClickHandler, ["prevent"])
|
|
4126
|
+
}, {
|
|
4127
|
+
default: withCtx(() => [
|
|
4128
|
+
createTextVNode(toDisplayString(appendConfig.value.text), 1)
|
|
4129
|
+
]),
|
|
4130
|
+
_: 1
|
|
4131
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
4132
|
+
]),
|
|
4133
|
+
key: "0"
|
|
4134
|
+
} : void 0
|
|
4135
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4136
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4137
|
+
popoverVisible.value ? (openBlock(), createElementBlock("div", {
|
|
4138
|
+
key: 0,
|
|
4139
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4140
|
+
ref_key: "popoverEl",
|
|
4141
|
+
ref: popoverEl
|
|
4142
|
+
}, [
|
|
4041
4143
|
_cache[5] || (_cache[5] = createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
|
|
4042
4144
|
createElementVNode("div", _hoisted_2, [
|
|
4043
4145
|
createVNode(unref(TMagicButton), {
|
|
@@ -4060,11 +4162,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
4060
4162
|
])),
|
|
4061
4163
|
_: 1
|
|
4062
4164
|
})
|
|
4063
|
-
])
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4165
|
+
]),
|
|
4166
|
+
_cache[6] || (_cache[6] = createElementVNode("span", {
|
|
4167
|
+
class: "tmagic-form-text-popper-arrow",
|
|
4168
|
+
"data-popper-arrow": ""
|
|
4169
|
+
}, null, -1))
|
|
4170
|
+
], 512)) : createCommentVNode("", true)
|
|
4171
|
+
]))
|
|
4172
|
+
]);
|
|
4068
4173
|
};
|
|
4069
4174
|
}
|
|
4070
4175
|
});
|
|
@@ -4269,13 +4374,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4269
4374
|
const submitHandler = async () => {
|
|
4270
4375
|
try {
|
|
4271
4376
|
const values = await form.value?.submitForm();
|
|
4272
|
-
emit("submit", values);
|
|
4377
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4273
4378
|
} catch (e) {
|
|
4274
4379
|
emit("error", e);
|
|
4275
4380
|
}
|
|
4276
4381
|
};
|
|
4277
|
-
const changeHandler = (value) => {
|
|
4278
|
-
emit("change", value);
|
|
4382
|
+
const changeHandler = (value, eventData) => {
|
|
4383
|
+
emit("change", value, eventData);
|
|
4279
4384
|
};
|
|
4280
4385
|
const openHandler = () => {
|
|
4281
4386
|
emit("open");
|
|
@@ -4418,7 +4523,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4418
4523
|
labelPosition: {},
|
|
4419
4524
|
preventSubmitDefault: { type: Boolean }
|
|
4420
4525
|
},
|
|
4421
|
-
emits: ["
|
|
4526
|
+
emits: ["change", "submit", "error"],
|
|
4422
4527
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4423
4528
|
const props = __props;
|
|
4424
4529
|
const emit = __emit;
|
|
@@ -4444,13 +4549,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4444
4549
|
const submitHandler = async () => {
|
|
4445
4550
|
try {
|
|
4446
4551
|
const values = await form.value?.submitForm();
|
|
4447
|
-
emit("submit", values);
|
|
4552
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4448
4553
|
} catch (e) {
|
|
4449
4554
|
emit("error", e);
|
|
4450
4555
|
}
|
|
4451
4556
|
};
|
|
4452
|
-
const changeHandler = (value) => {
|
|
4453
|
-
emit("change", value);
|
|
4557
|
+
const changeHandler = (value, eventData) => {
|
|
4558
|
+
emit("change", value, eventData);
|
|
4454
4559
|
};
|
|
4455
4560
|
const show = () => {
|
|
4456
4561
|
};
|
|
@@ -4524,8 +4629,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4524
4629
|
const createForm = (config) => config;
|
|
4525
4630
|
const defaultInstallOpt = {};
|
|
4526
4631
|
const index = {
|
|
4527
|
-
install(app, opt) {
|
|
4528
|
-
const option = Object.assign(defaultInstallOpt, opt
|
|
4632
|
+
install(app, opt = {}) {
|
|
4633
|
+
const option = Object.assign(defaultInstallOpt, opt);
|
|
4529
4634
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
4530
4635
|
setConfig(option);
|
|
4531
4636
|
app.component("m-form", _sfc_main$d);
|