@tmagic/form 1.5.0-beta.9 → 1.5.1
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 → tmagic-form.css} +53 -2
- package/dist/tmagic-form.js +295 -181
- package/dist/tmagic-form.umd.cjs +294 -181
- package/package.json +10 -8
- package/src/Form.vue +29 -8
- package/src/FormBox.vue +11 -5
- package/src/FormDialog.vue +6 -4
- package/src/FormDrawer.vue +6 -4
- package/src/containers/Col.vue +6 -3
- package/src/containers/Container.vue +92 -34
- 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 +32 -32
- 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 +3 -2
- package/src/schema.ts +30 -16
- package/src/theme/form.scss +2 -2
- package/src/theme/text.scss +56 -0
- package/types/index.d.ts +433 -657
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, tMagicMessageBox, 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
|
-
import {
|
|
8
|
+
import { 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");
|
|
@@ -369,9 +402,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
369
402
|
}, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
370
403
|
createVNode(unref(TMagicFormItem), {
|
|
371
404
|
style: normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
|
|
372
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
405
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
373
406
|
prop: itemProp.value,
|
|
374
407
|
"label-width": itemLabelWidth.value,
|
|
408
|
+
"label-position": _ctx.config.labelPosition,
|
|
375
409
|
rules: rule.value
|
|
376
410
|
}, {
|
|
377
411
|
label: withCtx(() => [
|
|
@@ -419,7 +453,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
419
453
|
}, null, 8, _hoisted_4$3)) : createCommentVNode("", true)
|
|
420
454
|
]),
|
|
421
455
|
_: 1
|
|
422
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
456
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
423
457
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
424
458
|
key: 0,
|
|
425
459
|
placement: "left"
|
|
@@ -442,9 +476,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
442
476
|
], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
443
477
|
createVNode(unref(TMagicFormItem), {
|
|
444
478
|
style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
|
|
445
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
479
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
446
480
|
prop: itemProp.value,
|
|
447
481
|
"label-width": itemLabelWidth.value,
|
|
482
|
+
"label-position": _ctx.config.labelPosition,
|
|
448
483
|
rules: rule.value
|
|
449
484
|
}, {
|
|
450
485
|
label: withCtx(() => [
|
|
@@ -488,7 +523,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
488
523
|
}, null, 8, _hoisted_8$1)) : createCommentVNode("", true)
|
|
489
524
|
]),
|
|
490
525
|
_: 1
|
|
491
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
526
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
492
527
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
493
528
|
key: 0,
|
|
494
529
|
placement: "left"
|
|
@@ -510,9 +545,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
510
545
|
})) : createCommentVNode("", true),
|
|
511
546
|
createVNode(unref(TMagicFormItem), {
|
|
512
547
|
style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
|
|
513
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
548
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
514
549
|
prop: itemProp.value,
|
|
515
550
|
"label-width": itemLabelWidth.value,
|
|
551
|
+
"label-position": _ctx.config.labelPosition,
|
|
516
552
|
rules: rule.value
|
|
517
553
|
}, {
|
|
518
554
|
label: withCtx(() => [
|
|
@@ -556,7 +592,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
556
592
|
}, null, 8, _hoisted_12)) : createCommentVNode("", true)
|
|
557
593
|
]),
|
|
558
594
|
_: 1
|
|
559
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
595
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
560
596
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
561
597
|
key: 1,
|
|
562
598
|
placement: "left"
|
|
@@ -577,11 +613,11 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
577
613
|
_: 1
|
|
578
614
|
})) : createCommentVNode("", true)
|
|
579
615
|
], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
|
580
|
-
(
|
|
616
|
+
(isValidName() ? _ctx.model[name.value] : _ctx.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
|
|
581
617
|
return openBlock(), createBlock(_component_Container, {
|
|
582
618
|
key: key(item),
|
|
583
|
-
model:
|
|
584
|
-
"last-values":
|
|
619
|
+
model: isValidName() ? _ctx.model[name.value] : _ctx.model,
|
|
620
|
+
"last-values": isValidName() ? _ctx.lastValues[name.value] || {} : _ctx.lastValues,
|
|
585
621
|
"is-compare": _ctx.isCompare,
|
|
586
622
|
config: item,
|
|
587
623
|
size: _ctx.size,
|
|
@@ -659,16 +695,17 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
659
695
|
}
|
|
660
696
|
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
661
697
|
});
|
|
662
|
-
const
|
|
663
|
-
emit("change",
|
|
698
|
+
const valueChangeHandler = (value) => {
|
|
699
|
+
emit("change", value, { modifyKey: "value" });
|
|
664
700
|
};
|
|
701
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
665
702
|
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
666
703
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
667
704
|
return (_ctx, _cache) => {
|
|
668
705
|
return (name.value ? _ctx.model[name.value] : _ctx.model) ? (openBlock(), createElementBlock("fieldset", {
|
|
669
706
|
key: 0,
|
|
670
707
|
class: "m-fieldset",
|
|
671
|
-
style: normalizeStyle(show.value ? "padding: 15px
|
|
708
|
+
style: normalizeStyle(show.value ? "padding: 15px" : "border: 0")
|
|
672
709
|
}, [
|
|
673
710
|
name.value && _ctx.config.checkbox ? (openBlock(), createBlock(resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
|
|
674
711
|
default: withCtx(() => [
|
|
@@ -676,7 +713,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
676
713
|
modelValue: _ctx.model[name.value].value,
|
|
677
714
|
"onUpdate:modelValue": [
|
|
678
715
|
_cache[0] || (_cache[0] = ($event) => _ctx.model[name.value].value = $event),
|
|
679
|
-
|
|
716
|
+
valueChangeHandler
|
|
680
717
|
],
|
|
681
718
|
prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.config.name}.value`,
|
|
682
719
|
"true-value": 1,
|
|
@@ -720,7 +757,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
720
757
|
disabled: _ctx.disabled,
|
|
721
758
|
labelWidth: lWidth.value,
|
|
722
759
|
size: _ctx.size,
|
|
723
|
-
onChange:
|
|
760
|
+
onChange: changeHandler,
|
|
724
761
|
onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
|
|
725
762
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
|
|
726
763
|
}), 128))
|
|
@@ -741,7 +778,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
741
778
|
labelWidth: lWidth.value,
|
|
742
779
|
size: _ctx.size,
|
|
743
780
|
disabled: _ctx.disabled,
|
|
744
|
-
onChange:
|
|
781
|
+
onChange: changeHandler,
|
|
745
782
|
onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
|
|
746
783
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
|
|
747
784
|
}), 128)) : createCommentVNode("", true)
|
|
@@ -795,7 +832,9 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
795
832
|
const length = computed(() => props.groupModel?.length || 0);
|
|
796
833
|
const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
797
834
|
const removeHandler = () => emit("remove-item", props.index);
|
|
798
|
-
const changeHandler = () =>
|
|
835
|
+
const changeHandler = (v, eventData) => {
|
|
836
|
+
emit("change", props.model, eventData);
|
|
837
|
+
};
|
|
799
838
|
const expandHandler = () => {
|
|
800
839
|
expand.value = !expand.value;
|
|
801
840
|
};
|
|
@@ -947,9 +986,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
947
986
|
}
|
|
948
987
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
949
988
|
});
|
|
950
|
-
const changeHandler = () => {
|
|
951
|
-
|
|
952
|
-
emit("change", props.model[props.name]);
|
|
989
|
+
const changeHandler = (v, eventData) => {
|
|
990
|
+
emit("change", props.model, eventData);
|
|
953
991
|
};
|
|
954
992
|
const addHandler = async () => {
|
|
955
993
|
if (!props.name) return false;
|
|
@@ -969,18 +1007,25 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
969
1007
|
initValues
|
|
970
1008
|
});
|
|
971
1009
|
props.model[props.name].push(groupValue);
|
|
972
|
-
|
|
1010
|
+
emit("change", props.model[props.name], {
|
|
1011
|
+
changeRecords: [
|
|
1012
|
+
{
|
|
1013
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
1014
|
+
value: groupValue
|
|
1015
|
+
}
|
|
1016
|
+
]
|
|
1017
|
+
});
|
|
973
1018
|
};
|
|
974
1019
|
const removeHandler = (index) => {
|
|
975
1020
|
if (!props.name) return false;
|
|
976
1021
|
props.model[props.name].splice(index, 1);
|
|
977
|
-
|
|
1022
|
+
emit("change", props.model[props.name]);
|
|
978
1023
|
};
|
|
979
1024
|
const swapHandler = (idx1, idx2) => {
|
|
980
1025
|
if (!props.name) return false;
|
|
981
1026
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
982
1027
|
props.model[props.name].splice(idx2, 0, currRow);
|
|
983
|
-
|
|
1028
|
+
emit("change", props.model[props.name]);
|
|
984
1029
|
};
|
|
985
1030
|
const toggleMode = () => {
|
|
986
1031
|
props.config.type = "table";
|
|
@@ -1023,15 +1068,16 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1023
1068
|
}), 128)),
|
|
1024
1069
|
addable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1025
1070
|
key: 3,
|
|
1026
|
-
|
|
1027
|
-
size: "small",
|
|
1028
|
-
disabled: _ctx.disabled
|
|
1071
|
+
type: "primary",
|
|
1072
|
+
size: _ctx.config.enableToggleMode ? "small" : "default",
|
|
1073
|
+
disabled: _ctx.disabled,
|
|
1074
|
+
onClick: addHandler
|
|
1029
1075
|
}, {
|
|
1030
1076
|
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
1031
1077
|
createTextVNode("新增")
|
|
1032
1078
|
])),
|
|
1033
1079
|
_: 1
|
|
1034
|
-
}, 8, ["disabled"])) : createCommentVNode("", true),
|
|
1080
|
+
}, 8, ["size", "disabled"])) : createCommentVNode("", true),
|
|
1035
1081
|
_ctx.config.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1036
1082
|
key: 4,
|
|
1037
1083
|
icon: unref(Grid),
|
|
@@ -1080,7 +1126,9 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1080
1126
|
const expand = ref(props.config.expand !== false);
|
|
1081
1127
|
const items = computed(() => props.config.items);
|
|
1082
1128
|
const filter = (config) => filterFunction(mForm, config, props);
|
|
1083
|
-
const changeHandler = () =>
|
|
1129
|
+
const changeHandler = (v, eventData) => {
|
|
1130
|
+
emit("change", props.model, eventData);
|
|
1131
|
+
};
|
|
1084
1132
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1085
1133
|
return (_ctx, _cache) => {
|
|
1086
1134
|
return items.value && items.value.length ? (openBlock(), createBlock(unref(TMagicCard), {
|
|
@@ -1177,7 +1225,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
1177
1225
|
const emit = __emit;
|
|
1178
1226
|
const mForm = inject("mForm");
|
|
1179
1227
|
const display$1 = computed(() => display(mForm, props.config.display, props));
|
|
1180
|
-
const changeHandler = () => emit("change",
|
|
1228
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
1181
1229
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1182
1230
|
return (_ctx, _cache) => {
|
|
1183
1231
|
return withDirectives((openBlock(), createBlock(unref(TMagicCol), { span: _ctx.span }, {
|
|
@@ -1226,7 +1274,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1226
1274
|
const props = __props;
|
|
1227
1275
|
const emit = __emit;
|
|
1228
1276
|
const mForm = inject("mForm");
|
|
1229
|
-
const changeHandler = () =>
|
|
1277
|
+
const changeHandler = (v, eventData) => {
|
|
1278
|
+
emit("change", props.name ? props.model[props.name] : props.model, eventData);
|
|
1279
|
+
};
|
|
1230
1280
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1231
1281
|
return (_ctx, _cache) => {
|
|
1232
1282
|
return openBlock(), createBlock(unref(TMagicRow), { gutter: 10 }, {
|
|
@@ -1262,6 +1312,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1262
1312
|
__name: "Step",
|
|
1263
1313
|
props: {
|
|
1264
1314
|
model: {},
|
|
1315
|
+
name: {},
|
|
1265
1316
|
lastValues: {},
|
|
1266
1317
|
isCompare: { type: Boolean },
|
|
1267
1318
|
config: {},
|
|
@@ -1283,8 +1334,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1283
1334
|
active.value = index + 1;
|
|
1284
1335
|
mForm?.$emit("update:stepActive", active.value);
|
|
1285
1336
|
};
|
|
1286
|
-
const changeHandler = () => {
|
|
1287
|
-
emit("change", props.model);
|
|
1337
|
+
const changeHandler = (v, eventData) => {
|
|
1338
|
+
emit("change", props.model, eventData);
|
|
1288
1339
|
};
|
|
1289
1340
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1290
1341
|
return (_ctx, _cache) => {
|
|
@@ -1397,10 +1448,6 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1397
1448
|
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
|
|
1398
1449
|
}
|
|
1399
1450
|
};
|
|
1400
|
-
const foreUpdate = () => {
|
|
1401
|
-
updateKey.value += 1;
|
|
1402
|
-
setTimeout(() => rowDrop());
|
|
1403
|
-
};
|
|
1404
1451
|
const swapArray = (index1, index2) => {
|
|
1405
1452
|
props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
|
|
1406
1453
|
if (props.sortKey) {
|
|
@@ -1410,31 +1457,25 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1410
1457
|
}
|
|
1411
1458
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1412
1459
|
};
|
|
1460
|
+
let sortable;
|
|
1413
1461
|
const rowDrop = () => {
|
|
1462
|
+
sortable?.destroy();
|
|
1414
1463
|
const tableEl = tMagicTable.value?.instance.$el;
|
|
1415
1464
|
const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
|
|
1416
|
-
if (tBodyEl) {
|
|
1417
|
-
|
|
1418
|
-
onEnd: ({ newIndex, oldIndex }) => {
|
|
1419
|
-
if (typeof newIndex === "undefined") return;
|
|
1420
|
-
if (typeof oldIndex === "undefined") return;
|
|
1421
|
-
swapArray(newIndex, oldIndex);
|
|
1422
|
-
emit("change", props.model[modelName.value]);
|
|
1423
|
-
foreUpdate();
|
|
1424
|
-
sortable.destroy();
|
|
1425
|
-
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1426
|
-
sleep(1e3).then(() => {
|
|
1427
|
-
const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
|
|
1428
|
-
if (elTrs?.[newIndex]) {
|
|
1429
|
-
elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
|
|
1430
|
-
sleep(1e3).then(() => {
|
|
1431
|
-
elTrs[newIndex].style.backgroundColor = "";
|
|
1432
|
-
});
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1465
|
+
if (!tBodyEl) {
|
|
1466
|
+
return;
|
|
1437
1467
|
}
|
|
1468
|
+
sortable = Sortable.create(tBodyEl, {
|
|
1469
|
+
draggable: ".tmagic-design-table-row",
|
|
1470
|
+
direction: "vertical",
|
|
1471
|
+
onEnd: ({ newIndex, oldIndex }) => {
|
|
1472
|
+
if (typeof newIndex === "undefined") return;
|
|
1473
|
+
if (typeof oldIndex === "undefined") return;
|
|
1474
|
+
swapArray(newIndex, oldIndex);
|
|
1475
|
+
emit("change", props.model[modelName.value]);
|
|
1476
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1438
1479
|
};
|
|
1439
1480
|
const newHandler = async (row) => {
|
|
1440
1481
|
if (props.config.max && props.model[modelName.value].length >= props.config.max) {
|
|
@@ -1493,7 +1534,14 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1493
1534
|
inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
|
|
1494
1535
|
}
|
|
1495
1536
|
props.model[modelName.value].push(inputs);
|
|
1496
|
-
emit("change", props.model[modelName.value]
|
|
1537
|
+
emit("change", props.model[modelName.value], {
|
|
1538
|
+
changeRecords: [
|
|
1539
|
+
{
|
|
1540
|
+
propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
|
|
1541
|
+
value: inputs
|
|
1542
|
+
}
|
|
1543
|
+
]
|
|
1544
|
+
});
|
|
1497
1545
|
};
|
|
1498
1546
|
onMounted(() => {
|
|
1499
1547
|
if (props.config.defautSort) {
|
|
@@ -1696,6 +1744,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1696
1744
|
return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
|
|
1697
1745
|
};
|
|
1698
1746
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1747
|
+
const changeHandler = (v, eventData) => {
|
|
1748
|
+
emit("change", props.model, eventData);
|
|
1749
|
+
};
|
|
1699
1750
|
__expose({
|
|
1700
1751
|
toggleRowSelection
|
|
1701
1752
|
});
|
|
@@ -1736,7 +1787,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1736
1787
|
onSortChange: sortChange
|
|
1737
1788
|
}, {
|
|
1738
1789
|
default: withCtx(() => [
|
|
1739
|
-
_ctx.config.itemExtra ? (openBlock(), createBlock(unref(TMagicTableColumn), {
|
|
1790
|
+
_ctx.config.itemExtra && !_ctx.config.dropSort ? (openBlock(), createBlock(unref(TMagicTableColumn), {
|
|
1740
1791
|
key: 0,
|
|
1741
1792
|
fixed: "left",
|
|
1742
1793
|
width: "30",
|
|
@@ -1859,8 +1910,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1859
1910
|
lastValues: lastData.value[scope.$index],
|
|
1860
1911
|
"is-compare": _ctx.isCompare,
|
|
1861
1912
|
size: _ctx.size,
|
|
1862
|
-
onChange:
|
|
1863
|
-
onAddDiffCount: _cache[
|
|
1913
|
+
onChange: changeHandler,
|
|
1914
|
+
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
1864
1915
|
}, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : createCommentVNode("", true)
|
|
1865
1916
|
]),
|
|
1866
1917
|
_: 2
|
|
@@ -1881,9 +1932,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1881
1932
|
type: "primary",
|
|
1882
1933
|
disabled: _ctx.disabled,
|
|
1883
1934
|
plain: "",
|
|
1884
|
-
onClick: _cache[
|
|
1935
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
1885
1936
|
}, {
|
|
1886
|
-
default: withCtx(() => _cache[
|
|
1937
|
+
default: withCtx(() => _cache[3] || (_cache[3] = [
|
|
1887
1938
|
createTextVNode("新增一行")
|
|
1888
1939
|
])),
|
|
1889
1940
|
_: 1
|
|
@@ -1896,7 +1947,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1896
1947
|
type: "primary",
|
|
1897
1948
|
onClick: toggleMode
|
|
1898
1949
|
}, {
|
|
1899
|
-
default: withCtx(() => _cache[
|
|
1950
|
+
default: withCtx(() => _cache[4] || (_cache[4] = [
|
|
1900
1951
|
createTextVNode("展开配置")
|
|
1901
1952
|
])),
|
|
1902
1953
|
_: 1
|
|
@@ -1930,7 +1981,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1930
1981
|
disabled: _ctx.disabled,
|
|
1931
1982
|
plain: ""
|
|
1932
1983
|
}, {
|
|
1933
|
-
default: withCtx(() => _cache[
|
|
1984
|
+
default: withCtx(() => _cache[5] || (_cache[5] = [
|
|
1934
1985
|
createTextVNode("导入EXCEL")
|
|
1935
1986
|
])),
|
|
1936
1987
|
_: 1
|
|
@@ -1944,9 +1995,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1944
1995
|
type: "warning",
|
|
1945
1996
|
disabled: _ctx.disabled,
|
|
1946
1997
|
plain: "",
|
|
1947
|
-
onClick: _cache[
|
|
1998
|
+
onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
|
|
1948
1999
|
}, {
|
|
1949
|
-
default: withCtx(() => _cache[
|
|
2000
|
+
default: withCtx(() => _cache[6] || (_cache[6] = [
|
|
1950
2001
|
createTextVNode("清空")
|
|
1951
2002
|
])),
|
|
1952
2003
|
_: 1
|
|
@@ -2035,24 +2086,35 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2035
2086
|
});
|
|
2036
2087
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
2037
2088
|
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
2038
|
-
const onTabAdd = () => {
|
|
2039
|
-
if (!props.
|
|
2089
|
+
const onTabAdd = async () => {
|
|
2090
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2040
2091
|
if (typeof props.config.onTabAdd === "function") {
|
|
2041
2092
|
props.config.onTabAdd(mForm, {
|
|
2042
2093
|
model: props.model,
|
|
2043
2094
|
prop: props.prop,
|
|
2044
2095
|
config: props.config
|
|
2045
2096
|
});
|
|
2046
|
-
|
|
2047
|
-
|
|
2097
|
+
emit("change", props.model);
|
|
2098
|
+
} else {
|
|
2099
|
+
const newObj = await initValue(mForm, {
|
|
2100
|
+
config: props.config.items,
|
|
2101
|
+
initValues: {}
|
|
2102
|
+
});
|
|
2048
2103
|
newObj.title = `标签${tabs.value.length + 1}`;
|
|
2049
|
-
props.model[props.
|
|
2104
|
+
props.model[props.name].push(newObj);
|
|
2105
|
+
emit("change", props.model[props.name], {
|
|
2106
|
+
changeRecords: [
|
|
2107
|
+
{
|
|
2108
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
2109
|
+
value: newObj
|
|
2110
|
+
}
|
|
2111
|
+
]
|
|
2112
|
+
});
|
|
2050
2113
|
}
|
|
2051
|
-
emit("change", props.model);
|
|
2052
|
-
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2114
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2053
2115
|
};
|
|
2054
2116
|
const onTabRemove = (tabName) => {
|
|
2055
|
-
if (!props.
|
|
2117
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2056
2118
|
if (typeof props.config.onTabRemove === "function") {
|
|
2057
2119
|
props.config.onTabRemove(mForm, tabName, {
|
|
2058
2120
|
model: props.model,
|
|
@@ -2060,20 +2122,17 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2060
2122
|
config: props.config
|
|
2061
2123
|
});
|
|
2062
2124
|
} else {
|
|
2063
|
-
props.model[props.
|
|
2064
|
-
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.
|
|
2125
|
+
props.model[props.name].splice(+tabName, 1);
|
|
2126
|
+
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
|
|
2065
2127
|
activeTabName.value = (+activeTabName.value - 1).toString();
|
|
2066
2128
|
tabClick(mForm, { name: activeTabName.value }, props);
|
|
2067
2129
|
}
|
|
2068
2130
|
}
|
|
2069
2131
|
emit("change", props.model);
|
|
2070
|
-
mForm?.$emit("field-change", props.prop, props.model[props.
|
|
2132
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2071
2133
|
};
|
|
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
|
-
}
|
|
2134
|
+
const changeHandler = (v, eventData) => {
|
|
2135
|
+
emit("change", props.model, eventData);
|
|
2077
2136
|
};
|
|
2078
2137
|
const onAddDiffCount = (tabIndex) => {
|
|
2079
2138
|
if (!diffCount.value[tabIndex]) {
|
|
@@ -2616,9 +2675,9 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
2616
2675
|
const props = __props;
|
|
2617
2676
|
const emit = __emit;
|
|
2618
2677
|
useAddField(props.prop);
|
|
2619
|
-
const value = props.model?.[props.name]
|
|
2678
|
+
const value = props.model?.[props.name]?.toString();
|
|
2620
2679
|
if (props.model) {
|
|
2621
|
-
if (value === "Invalid Date") {
|
|
2680
|
+
if (!value || value === "Invalid Date") {
|
|
2622
2681
|
props.model[props.name] = "";
|
|
2623
2682
|
} else {
|
|
2624
2683
|
props.model[props.name] = datetimeFormatter(
|
|
@@ -2717,7 +2776,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2717
2776
|
let oldVal = props.model?.[v.name] || "";
|
|
2718
2777
|
if (!oldVal && v.defaultValue !== void 0) {
|
|
2719
2778
|
oldVal = v.defaultValue;
|
|
2720
|
-
emit("change", oldVal, v.name);
|
|
2779
|
+
emit("change", oldVal, { modifyKey: v.name });
|
|
2721
2780
|
}
|
|
2722
2781
|
fieldMap.value[v.name] = oldVal;
|
|
2723
2782
|
fieldLabelMap.value[v.name] = v.label || "";
|
|
@@ -2740,7 +2799,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2740
2799
|
}
|
|
2741
2800
|
});
|
|
2742
2801
|
const inputChangeHandler = (key) => {
|
|
2743
|
-
emit("change", fieldMap.value[key],
|
|
2802
|
+
emit("change", fieldMap.value[key], {
|
|
2803
|
+
modifyKey: key
|
|
2804
|
+
});
|
|
2744
2805
|
};
|
|
2745
2806
|
return (_ctx, _cache) => {
|
|
2746
2807
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
@@ -2821,9 +2882,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2821
2882
|
labelPosition: { default: "right" },
|
|
2822
2883
|
keyProp: { default: "__key" },
|
|
2823
2884
|
popperClass: {},
|
|
2885
|
+
preventSubmitDefault: { type: Boolean },
|
|
2824
2886
|
extendState: {}
|
|
2825
2887
|
},
|
|
2826
|
-
emits: ["change", "error", "field-input", "field-change"],
|
|
2888
|
+
emits: ["change", "error", "field-input", "field-change", "update:stepActive"],
|
|
2827
2889
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2828
2890
|
const props = __props;
|
|
2829
2891
|
const emit = __emit;
|
|
@@ -2848,11 +2910,13 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2848
2910
|
setField: (prop, field) => fields.set(prop, field),
|
|
2849
2911
|
getField: (prop) => fields.get(prop),
|
|
2850
2912
|
deleteField: (prop) => fields.delete(prop),
|
|
2913
|
+
$messageBox: tMagicMessageBox,
|
|
2914
|
+
$message: tMagicMessage,
|
|
2851
2915
|
post: (options) => {
|
|
2852
2916
|
if (requestFuc) {
|
|
2853
2917
|
return requestFuc({
|
|
2854
|
-
|
|
2855
|
-
|
|
2918
|
+
method: "POST",
|
|
2919
|
+
...options
|
|
2856
2920
|
});
|
|
2857
2921
|
}
|
|
2858
2922
|
}
|
|
@@ -2873,9 +2937,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2873
2937
|
}
|
|
2874
2938
|
});
|
|
2875
2939
|
provide("mForm", formState);
|
|
2940
|
+
const changeRecords = shallowRef([]);
|
|
2876
2941
|
watch(
|
|
2877
2942
|
[() => props.config, () => props.initValues],
|
|
2878
2943
|
([config], [preConfig]) => {
|
|
2944
|
+
changeRecords.value = [];
|
|
2879
2945
|
if (!isEqual(toRaw(config), toRaw(preConfig))) {
|
|
2880
2946
|
initialized.value = false;
|
|
2881
2947
|
}
|
|
@@ -2898,16 +2964,28 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2898
2964
|
},
|
|
2899
2965
|
{ immediate: true }
|
|
2900
2966
|
);
|
|
2901
|
-
const changeHandler = () => {
|
|
2902
|
-
|
|
2967
|
+
const changeHandler = (v, eventData) => {
|
|
2968
|
+
if (eventData.changeRecords?.length) {
|
|
2969
|
+
changeRecords.value.push(...eventData.changeRecords);
|
|
2970
|
+
}
|
|
2971
|
+
emit("change", values.value, eventData);
|
|
2972
|
+
};
|
|
2973
|
+
const submitHandler = (e) => {
|
|
2974
|
+
if (props.preventSubmitDefault) {
|
|
2975
|
+
e.preventDefault();
|
|
2976
|
+
}
|
|
2903
2977
|
};
|
|
2904
2978
|
__expose({
|
|
2905
2979
|
values,
|
|
2906
2980
|
lastValuesProcessed,
|
|
2907
2981
|
formState,
|
|
2908
2982
|
initialized,
|
|
2983
|
+
changeRecords,
|
|
2909
2984
|
changeHandler,
|
|
2910
|
-
resetForm: () =>
|
|
2985
|
+
resetForm: () => {
|
|
2986
|
+
tMagicForm.value?.resetFields();
|
|
2987
|
+
changeRecords.value = [];
|
|
2988
|
+
},
|
|
2911
2989
|
submitForm: async (native) => {
|
|
2912
2990
|
try {
|
|
2913
2991
|
await tMagicForm.value?.validate();
|
|
@@ -2935,7 +3013,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2935
3013
|
"label-width": _ctx.labelWidth,
|
|
2936
3014
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
2937
3015
|
inline: _ctx.inline,
|
|
2938
|
-
"label-position": _ctx.labelPosition
|
|
3016
|
+
"label-position": _ctx.labelPosition,
|
|
3017
|
+
onSubmit: submitHandler
|
|
2939
3018
|
}, {
|
|
2940
3019
|
default: withCtx(() => [
|
|
2941
3020
|
initialized.value && Array.isArray(_ctx.config) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.config, (item, index) => {
|
|
@@ -2978,7 +3057,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2978
3057
|
labelPosition: {},
|
|
2979
3058
|
zIndex: {},
|
|
2980
3059
|
size: {},
|
|
2981
|
-
confirmText: { default: "确定" }
|
|
3060
|
+
confirmText: { default: "确定" },
|
|
3061
|
+
preventSubmitDefault: { type: Boolean }
|
|
2982
3062
|
},
|
|
2983
3063
|
emits: ["close", "submit", "error", "change"],
|
|
2984
3064
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -3014,7 +3094,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3014
3094
|
const save = async () => {
|
|
3015
3095
|
try {
|
|
3016
3096
|
const values = await form.value?.submitForm();
|
|
3017
|
-
emit("submit", values);
|
|
3097
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
3018
3098
|
} catch (e) {
|
|
3019
3099
|
emit("error", e);
|
|
3020
3100
|
}
|
|
@@ -3025,8 +3105,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3025
3105
|
const nextStep = () => {
|
|
3026
3106
|
stepActive.value += 1;
|
|
3027
3107
|
};
|
|
3028
|
-
const changeHandler = (value) => {
|
|
3029
|
-
emit("change", value);
|
|
3108
|
+
const changeHandler = (value, eventData) => {
|
|
3109
|
+
emit("change", value, eventData);
|
|
3030
3110
|
};
|
|
3031
3111
|
const show = () => {
|
|
3032
3112
|
dialogVisible.value = true;
|
|
@@ -3147,8 +3227,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3147
3227
|
"label-width": _ctx.labelWidth,
|
|
3148
3228
|
"label-position": _ctx.labelPosition,
|
|
3149
3229
|
inline: _ctx.inline,
|
|
3230
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
3150
3231
|
onChange: changeHandler
|
|
3151
|
-
}, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
3232
|
+
}, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
3152
3233
|
renderSlot(_ctx.$slots, "default")
|
|
3153
3234
|
], 4)) : createCommentVNode("", true)
|
|
3154
3235
|
]),
|
|
@@ -3874,7 +3955,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3874
3955
|
}
|
|
3875
3956
|
});
|
|
3876
3957
|
|
|
3877
|
-
const _hoisted_1$1 = {
|
|
3958
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3878
3959
|
const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3879
3960
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3880
3961
|
...{
|
|
@@ -3919,11 +4000,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3919
4000
|
emit("change", props.model[props.name].trim() || "");
|
|
3920
4001
|
popoverVisible.value = false;
|
|
3921
4002
|
};
|
|
3922
|
-
const checkWhiteSpace = (value) => {
|
|
4003
|
+
const checkWhiteSpace = debounce((value) => {
|
|
3923
4004
|
if (typeof value === "string" && !props.config.trim) {
|
|
3924
4005
|
popoverVisible.value = value.trim() !== value;
|
|
3925
4006
|
}
|
|
3926
|
-
};
|
|
4007
|
+
}, 300);
|
|
3927
4008
|
const changeHandler = (value) => {
|
|
3928
4009
|
emit("change", value);
|
|
3929
4010
|
};
|
|
@@ -3990,45 +4071,70 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3990
4071
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
3991
4072
|
emit("change", props.model[props.name]);
|
|
3992
4073
|
};
|
|
4074
|
+
const popoverEl = ref();
|
|
4075
|
+
const input = ref();
|
|
4076
|
+
const instanceRef = shallowRef();
|
|
4077
|
+
watch(popoverEl, (el) => {
|
|
4078
|
+
destroyPopover();
|
|
4079
|
+
if (!input.value?.$el || !el) return;
|
|
4080
|
+
instanceRef.value = createPopper(input.value.$el, el, {
|
|
4081
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
4082
|
+
strategy: "absolute",
|
|
4083
|
+
modifiers: [
|
|
4084
|
+
{
|
|
4085
|
+
name: "offset",
|
|
4086
|
+
options: {
|
|
4087
|
+
offset: [0, 10]
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
]
|
|
4091
|
+
});
|
|
4092
|
+
});
|
|
4093
|
+
const destroyPopover = () => {
|
|
4094
|
+
if (!instanceRef.value) return;
|
|
4095
|
+
instanceRef.value.destroy();
|
|
4096
|
+
instanceRef.value = void 0;
|
|
4097
|
+
};
|
|
3993
4098
|
return (_ctx, _cache) => {
|
|
3994
|
-
return openBlock(),
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
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
|
-
|
|
4099
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
4100
|
+
createVNode(unref(TMagicInput), {
|
|
4101
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4102
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4103
|
+
ref_key: "input",
|
|
4104
|
+
ref: input,
|
|
4105
|
+
clearable: "",
|
|
4106
|
+
size: _ctx.size,
|
|
4107
|
+
placeholder: _ctx.config.placeholder,
|
|
4108
|
+
disabled: _ctx.disabled,
|
|
4109
|
+
onChange: changeHandler,
|
|
4110
|
+
onInput: inputHandler,
|
|
4111
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4112
|
+
}, createSlots({ _: 2 }, [
|
|
4113
|
+
appendConfig.value ? {
|
|
4114
|
+
name: "append",
|
|
4115
|
+
fn: withCtx(() => [
|
|
4116
|
+
appendConfig.value.type === "button" ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4117
|
+
key: 0,
|
|
4118
|
+
style: { "color": "#409eff" },
|
|
4119
|
+
size: _ctx.size,
|
|
4120
|
+
onClick: withModifiers(buttonClickHandler, ["prevent"])
|
|
4121
|
+
}, {
|
|
4122
|
+
default: withCtx(() => [
|
|
4123
|
+
createTextVNode(toDisplayString(appendConfig.value.text), 1)
|
|
4124
|
+
]),
|
|
4125
|
+
_: 1
|
|
4126
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
4127
|
+
]),
|
|
4128
|
+
key: "0"
|
|
4129
|
+
} : void 0
|
|
4130
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4131
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4132
|
+
popoverVisible.value ? (openBlock(), createElementBlock("div", {
|
|
4133
|
+
key: 0,
|
|
4134
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4135
|
+
ref_key: "popoverEl",
|
|
4136
|
+
ref: popoverEl
|
|
4137
|
+
}, [
|
|
4032
4138
|
_cache[5] || (_cache[5] = createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
|
|
4033
4139
|
createElementVNode("div", _hoisted_2, [
|
|
4034
4140
|
createVNode(unref(TMagicButton), {
|
|
@@ -4051,11 +4157,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
4051
4157
|
])),
|
|
4052
4158
|
_: 1
|
|
4053
4159
|
})
|
|
4054
|
-
])
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4160
|
+
]),
|
|
4161
|
+
_cache[6] || (_cache[6] = createElementVNode("span", {
|
|
4162
|
+
class: "tmagic-form-text-popper-arrow",
|
|
4163
|
+
"data-popper-arrow": ""
|
|
4164
|
+
}, null, -1))
|
|
4165
|
+
], 512)) : createCommentVNode("", true)
|
|
4166
|
+
]))
|
|
4167
|
+
]);
|
|
4059
4168
|
};
|
|
4060
4169
|
}
|
|
4061
4170
|
});
|
|
@@ -4240,6 +4349,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4240
4349
|
confirmText: { default: "确定" },
|
|
4241
4350
|
inline: { type: Boolean },
|
|
4242
4351
|
labelPosition: {},
|
|
4352
|
+
preventSubmitDefault: { type: Boolean },
|
|
4243
4353
|
beforeClose: {}
|
|
4244
4354
|
},
|
|
4245
4355
|
emits: ["close", "closed", "submit", "error", "change", "open", "opened"],
|
|
@@ -4259,13 +4369,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4259
4369
|
const submitHandler = async () => {
|
|
4260
4370
|
try {
|
|
4261
4371
|
const values = await form.value?.submitForm();
|
|
4262
|
-
emit("submit", values);
|
|
4372
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4263
4373
|
} catch (e) {
|
|
4264
4374
|
emit("error", e);
|
|
4265
4375
|
}
|
|
4266
4376
|
};
|
|
4267
|
-
const changeHandler = (value) => {
|
|
4268
|
-
emit("change", value);
|
|
4377
|
+
const changeHandler = (value, eventData) => {
|
|
4378
|
+
emit("change", value, eventData);
|
|
4269
4379
|
};
|
|
4270
4380
|
const openHandler = () => {
|
|
4271
4381
|
emit("open");
|
|
@@ -4376,8 +4486,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4376
4486
|
"label-width": _ctx.labelWidth,
|
|
4377
4487
|
"label-position": _ctx.labelPosition,
|
|
4378
4488
|
inline: _ctx.inline,
|
|
4489
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
4379
4490
|
onChange: changeHandler
|
|
4380
|
-
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
4491
|
+
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
4381
4492
|
renderSlot(_ctx.$slots, "default")
|
|
4382
4493
|
], 512)) : createCommentVNode("", true)
|
|
4383
4494
|
]),
|
|
@@ -4404,9 +4515,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4404
4515
|
size: {},
|
|
4405
4516
|
confirmText: { default: "确定" },
|
|
4406
4517
|
inline: { type: Boolean },
|
|
4407
|
-
labelPosition: {}
|
|
4518
|
+
labelPosition: {},
|
|
4519
|
+
preventSubmitDefault: { type: Boolean }
|
|
4408
4520
|
},
|
|
4409
|
-
emits: ["
|
|
4521
|
+
emits: ["change", "submit", "error"],
|
|
4410
4522
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4411
4523
|
const props = __props;
|
|
4412
4524
|
const emit = __emit;
|
|
@@ -4432,13 +4544,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4432
4544
|
const submitHandler = async () => {
|
|
4433
4545
|
try {
|
|
4434
4546
|
const values = await form.value?.submitForm();
|
|
4435
|
-
emit("submit", values);
|
|
4547
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4436
4548
|
} catch (e) {
|
|
4437
4549
|
emit("error", e);
|
|
4438
4550
|
}
|
|
4439
4551
|
};
|
|
4440
|
-
const changeHandler = (value) => {
|
|
4441
|
-
emit("change", value);
|
|
4552
|
+
const changeHandler = (value, eventData) => {
|
|
4553
|
+
emit("change", value, eventData);
|
|
4442
4554
|
};
|
|
4443
4555
|
const show = () => {
|
|
4444
4556
|
};
|
|
@@ -4472,8 +4584,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4472
4584
|
"label-width": _ctx.labelWidth,
|
|
4473
4585
|
"label-position": _ctx.labelPosition,
|
|
4474
4586
|
inline: _ctx.inline,
|
|
4587
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
4475
4588
|
onChange: changeHandler
|
|
4476
|
-
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
4589
|
+
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
4477
4590
|
renderSlot(_ctx.$slots, "default")
|
|
4478
4591
|
]),
|
|
4479
4592
|
_: 3
|
|
@@ -4511,8 +4624,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4511
4624
|
const createForm = (config) => config;
|
|
4512
4625
|
const defaultInstallOpt = {};
|
|
4513
4626
|
const index = {
|
|
4514
|
-
install(app, opt) {
|
|
4515
|
-
const option = Object.assign(defaultInstallOpt, opt
|
|
4627
|
+
install(app, opt = {}) {
|
|
4628
|
+
const option = Object.assign(defaultInstallOpt, opt);
|
|
4516
4629
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
4517
4630
|
setConfig(option);
|
|
4518
4631
|
app.component("m-form", _sfc_main$d);
|
|
@@ -4526,6 +4639,7 @@ const index = {
|
|
|
4526
4639
|
app.component("m-form-table", _sfc_main$p);
|
|
4527
4640
|
app.component("m-form-tab", _sfc_main$o);
|
|
4528
4641
|
app.component("m-fields-text", _sfc_main$5);
|
|
4642
|
+
app.component("m-fields-img-upload", _sfc_main$5);
|
|
4529
4643
|
app.component("m-fields-number", _sfc_main$a);
|
|
4530
4644
|
app.component("m-fields-number-range", _sfc_main$9);
|
|
4531
4645
|
app.component("m-fields-textarea", _sfc_main$4);
|