@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.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/design'), require('dayjs'), require('dayjs/plugin/utc'), require('sortablejs'), require('@tmagic/utils')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', '@tmagic/design', 'dayjs', 'dayjs/plugin/utc', 'sortablejs', '@tmagic/utils'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.lodashEs, global.design, global.dayjs, global.utc, global.Sortable, global.utils));
|
|
5
|
-
})(this, (function (exports, vue, iconsVue, lodashEs, design, dayjs, utc, Sortable, utils) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/design'), require('dayjs'), require('dayjs/plugin/utc'), require('sortablejs'), require('@tmagic/utils'), require('@popperjs/core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', '@tmagic/design', 'dayjs', 'dayjs/plugin/utc', 'sortablejs', '@tmagic/utils', '@popperjs/core'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.lodashEs, global.design, global.dayjs, global.utc, global.Sortable, global.utils, global.core));
|
|
5
|
+
})(this, (function (exports, vue, iconsVue, lodashEs, design, dayjs, utc, Sortable, utils, core) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
8
8
|
const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
|
|
@@ -240,7 +240,10 @@
|
|
|
240
240
|
} else {
|
|
241
241
|
return props.prop;
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
if (typeof props.prop !== "undefined" && props.prop !== "") {
|
|
244
|
+
return `${props.prop}.${n}`;
|
|
245
|
+
}
|
|
246
|
+
return `${n}`;
|
|
244
247
|
});
|
|
245
248
|
const tagName = vue.computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
246
249
|
const disabled = vue.computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
@@ -296,40 +299,69 @@
|
|
|
296
299
|
}
|
|
297
300
|
return value;
|
|
298
301
|
};
|
|
299
|
-
const changeHandler = (onChange, value) => {
|
|
300
|
-
if (typeof onChange === "function") {
|
|
301
|
-
return onChange(mForm, value, {
|
|
302
|
-
model: props.model,
|
|
303
|
-
values: mForm?.initValues,
|
|
304
|
-
formValue: mForm?.values,
|
|
305
|
-
prop: itemProp.value,
|
|
306
|
-
config: props.config
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
302
|
const trimHandler = (trim, value) => {
|
|
311
303
|
if (typeof value === "string" && trim) {
|
|
312
304
|
return value.replace(/^\s*/, "").replace(/\s*$/, "");
|
|
313
305
|
}
|
|
314
306
|
};
|
|
315
307
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
308
|
+
const hasModifyKey = (eventDataItem) => typeof eventDataItem?.modifyKey !== "undefined" && eventDataItem.modifyKey !== "";
|
|
309
|
+
const isValidName = () => {
|
|
310
|
+
const valueType = typeof name.value;
|
|
311
|
+
if (valueType !== "string" && valueType !== "symbol" && valueType !== "number") {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
if (name.value === "") {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (typeof name.value === "number") {
|
|
318
|
+
return name.value >= 0;
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
};
|
|
322
|
+
const onChangeHandler = async function(v, eventData = {}) {
|
|
323
|
+
const { filter, onChange, trim, dynamicKey } = props.config;
|
|
324
|
+
let value = vue.toRaw(v);
|
|
325
|
+
const changeRecords = eventData.changeRecords || [];
|
|
326
|
+
const newChangeRecords = [...changeRecords];
|
|
319
327
|
try {
|
|
320
328
|
value = filterHandler(filter, v);
|
|
321
|
-
|
|
329
|
+
if (typeof onChange === "function") {
|
|
330
|
+
value = await onChange(mForm, value, {
|
|
331
|
+
model: props.model,
|
|
332
|
+
values: mForm?.initValues,
|
|
333
|
+
formValue: mForm?.values,
|
|
334
|
+
prop: itemProp.value,
|
|
335
|
+
config: props.config,
|
|
336
|
+
changeRecords: newChangeRecords
|
|
337
|
+
}) ?? value;
|
|
338
|
+
}
|
|
322
339
|
value = trimHandler(trim, value) ?? value;
|
|
323
340
|
} catch (e) {
|
|
324
341
|
console.error(e);
|
|
325
342
|
}
|
|
326
|
-
|
|
327
|
-
|
|
343
|
+
let valueProp = itemProp.value;
|
|
344
|
+
if (hasModifyKey(eventData)) {
|
|
345
|
+
if (dynamicKey) {
|
|
346
|
+
props.model[eventData.modifyKey] = value;
|
|
347
|
+
} else if (isValidName()) {
|
|
348
|
+
props.model[name.value][eventData.modifyKey] = value;
|
|
349
|
+
}
|
|
350
|
+
valueProp = valueProp ? `${valueProp}.${eventData.modifyKey}` : eventData.modifyKey;
|
|
351
|
+
delete eventData.modifyKey;
|
|
352
|
+
} else if (isValidName() && props.model !== value && (v !== value || props.model[name.value] !== value)) {
|
|
353
|
+
props.model[name.value] = value;
|
|
328
354
|
}
|
|
329
|
-
if (
|
|
330
|
-
|
|
355
|
+
if (changeRecords.length === 0) {
|
|
356
|
+
newChangeRecords.push({
|
|
357
|
+
propPath: valueProp,
|
|
358
|
+
value
|
|
359
|
+
});
|
|
331
360
|
}
|
|
332
|
-
emit("change", props.model
|
|
361
|
+
emit("change", props.model, {
|
|
362
|
+
...eventData,
|
|
363
|
+
changeRecords: newChangeRecords
|
|
364
|
+
});
|
|
333
365
|
};
|
|
334
366
|
return (_ctx, _cache) => {
|
|
335
367
|
const _component_m_fields_hidden = vue.resolveComponent("m-fields-hidden");
|
|
@@ -366,9 +398,10 @@
|
|
|
366
398
|
}, 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 ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
367
399
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
368
400
|
style: vue.normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
|
|
369
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
401
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
370
402
|
prop: itemProp.value,
|
|
371
403
|
"label-width": itemLabelWidth.value,
|
|
404
|
+
"label-position": _ctx.config.labelPosition,
|
|
372
405
|
rules: rule.value
|
|
373
406
|
}, {
|
|
374
407
|
label: vue.withCtx(() => [
|
|
@@ -416,7 +449,7 @@
|
|
|
416
449
|
}, null, 8, _hoisted_4$3)) : vue.createCommentVNode("", true)
|
|
417
450
|
]),
|
|
418
451
|
_: 1
|
|
419
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
452
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
420
453
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
421
454
|
key: 0,
|
|
422
455
|
placement: "left"
|
|
@@ -439,9 +472,10 @@
|
|
|
439
472
|
], 64)) : type.value && display$1.value && showDiff.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
440
473
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
441
474
|
style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
|
|
442
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
475
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
443
476
|
prop: itemProp.value,
|
|
444
477
|
"label-width": itemLabelWidth.value,
|
|
478
|
+
"label-position": _ctx.config.labelPosition,
|
|
445
479
|
rules: rule.value
|
|
446
480
|
}, {
|
|
447
481
|
label: vue.withCtx(() => [
|
|
@@ -485,7 +519,7 @@
|
|
|
485
519
|
}, null, 8, _hoisted_8$1)) : vue.createCommentVNode("", true)
|
|
486
520
|
]),
|
|
487
521
|
_: 1
|
|
488
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
522
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
489
523
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
490
524
|
key: 0,
|
|
491
525
|
placement: "left"
|
|
@@ -507,9 +541,10 @@
|
|
|
507
541
|
})) : vue.createCommentVNode("", true),
|
|
508
542
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
509
543
|
style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
|
|
510
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
544
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
511
545
|
prop: itemProp.value,
|
|
512
546
|
"label-width": itemLabelWidth.value,
|
|
547
|
+
"label-position": _ctx.config.labelPosition,
|
|
513
548
|
rules: rule.value
|
|
514
549
|
}, {
|
|
515
550
|
label: vue.withCtx(() => [
|
|
@@ -553,7 +588,7 @@
|
|
|
553
588
|
}, null, 8, _hoisted_12)) : vue.createCommentVNode("", true)
|
|
554
589
|
]),
|
|
555
590
|
_: 1
|
|
556
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
591
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
557
592
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
558
593
|
key: 1,
|
|
559
594
|
placement: "left"
|
|
@@ -574,11 +609,11 @@
|
|
|
574
609
|
_: 1
|
|
575
610
|
})) : vue.createCommentVNode("", true)
|
|
576
611
|
], 64)) : items.value && display$1.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 4 }, [
|
|
577
|
-
(
|
|
612
|
+
(isValidName() ? _ctx.model[name.value] : _ctx.model) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(items.value, (item) => {
|
|
578
613
|
return vue.openBlock(), vue.createBlock(_component_Container, {
|
|
579
614
|
key: key(item),
|
|
580
|
-
model:
|
|
581
|
-
"last-values":
|
|
615
|
+
model: isValidName() ? _ctx.model[name.value] : _ctx.model,
|
|
616
|
+
"last-values": isValidName() ? _ctx.lastValues[name.value] || {} : _ctx.lastValues,
|
|
582
617
|
"is-compare": _ctx.isCompare,
|
|
583
618
|
config: item,
|
|
584
619
|
size: _ctx.size,
|
|
@@ -656,16 +691,17 @@
|
|
|
656
691
|
}
|
|
657
692
|
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
658
693
|
});
|
|
659
|
-
const
|
|
660
|
-
emit("change",
|
|
694
|
+
const valueChangeHandler = (value) => {
|
|
695
|
+
emit("change", value, { modifyKey: "value" });
|
|
661
696
|
};
|
|
697
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
662
698
|
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
663
699
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
664
700
|
return (_ctx, _cache) => {
|
|
665
701
|
return (name.value ? _ctx.model[name.value] : _ctx.model) ? (vue.openBlock(), vue.createElementBlock("fieldset", {
|
|
666
702
|
key: 0,
|
|
667
703
|
class: "m-fieldset",
|
|
668
|
-
style: vue.normalizeStyle(show.value ? "padding: 15px
|
|
704
|
+
style: vue.normalizeStyle(show.value ? "padding: 15px" : "border: 0")
|
|
669
705
|
}, [
|
|
670
706
|
name.value && _ctx.config.checkbox ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
|
|
671
707
|
default: vue.withCtx(() => [
|
|
@@ -673,7 +709,7 @@
|
|
|
673
709
|
modelValue: _ctx.model[name.value].value,
|
|
674
710
|
"onUpdate:modelValue": [
|
|
675
711
|
_cache[0] || (_cache[0] = ($event) => _ctx.model[name.value].value = $event),
|
|
676
|
-
|
|
712
|
+
valueChangeHandler
|
|
677
713
|
],
|
|
678
714
|
prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.config.name}.value`,
|
|
679
715
|
"true-value": 1,
|
|
@@ -717,7 +753,7 @@
|
|
|
717
753
|
disabled: _ctx.disabled,
|
|
718
754
|
labelWidth: lWidth.value,
|
|
719
755
|
size: _ctx.size,
|
|
720
|
-
onChange:
|
|
756
|
+
onChange: changeHandler,
|
|
721
757
|
onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
|
|
722
758
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
|
|
723
759
|
}), 128))
|
|
@@ -738,7 +774,7 @@
|
|
|
738
774
|
labelWidth: lWidth.value,
|
|
739
775
|
size: _ctx.size,
|
|
740
776
|
disabled: _ctx.disabled,
|
|
741
|
-
onChange:
|
|
777
|
+
onChange: changeHandler,
|
|
742
778
|
onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
|
|
743
779
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
|
|
744
780
|
}), 128)) : vue.createCommentVNode("", true)
|
|
@@ -792,7 +828,9 @@
|
|
|
792
828
|
const length = vue.computed(() => props.groupModel?.length || 0);
|
|
793
829
|
const itemExtra = vue.computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
794
830
|
const removeHandler = () => emit("remove-item", props.index);
|
|
795
|
-
const changeHandler = () =>
|
|
831
|
+
const changeHandler = (v, eventData) => {
|
|
832
|
+
emit("change", props.model, eventData);
|
|
833
|
+
};
|
|
796
834
|
const expandHandler = () => {
|
|
797
835
|
expand.value = !expand.value;
|
|
798
836
|
};
|
|
@@ -944,9 +982,8 @@
|
|
|
944
982
|
}
|
|
945
983
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
946
984
|
});
|
|
947
|
-
const changeHandler = () => {
|
|
948
|
-
|
|
949
|
-
emit("change", props.model[props.name]);
|
|
985
|
+
const changeHandler = (v, eventData) => {
|
|
986
|
+
emit("change", props.model, eventData);
|
|
950
987
|
};
|
|
951
988
|
const addHandler = async () => {
|
|
952
989
|
if (!props.name) return false;
|
|
@@ -966,18 +1003,25 @@
|
|
|
966
1003
|
initValues
|
|
967
1004
|
});
|
|
968
1005
|
props.model[props.name].push(groupValue);
|
|
969
|
-
|
|
1006
|
+
emit("change", props.model[props.name], {
|
|
1007
|
+
changeRecords: [
|
|
1008
|
+
{
|
|
1009
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
1010
|
+
value: groupValue
|
|
1011
|
+
}
|
|
1012
|
+
]
|
|
1013
|
+
});
|
|
970
1014
|
};
|
|
971
1015
|
const removeHandler = (index) => {
|
|
972
1016
|
if (!props.name) return false;
|
|
973
1017
|
props.model[props.name].splice(index, 1);
|
|
974
|
-
|
|
1018
|
+
emit("change", props.model[props.name]);
|
|
975
1019
|
};
|
|
976
1020
|
const swapHandler = (idx1, idx2) => {
|
|
977
1021
|
if (!props.name) return false;
|
|
978
1022
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
979
1023
|
props.model[props.name].splice(idx2, 0, currRow);
|
|
980
|
-
|
|
1024
|
+
emit("change", props.model[props.name]);
|
|
981
1025
|
};
|
|
982
1026
|
const toggleMode = () => {
|
|
983
1027
|
props.config.type = "table";
|
|
@@ -1020,15 +1064,16 @@
|
|
|
1020
1064
|
}), 128)),
|
|
1021
1065
|
addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1022
1066
|
key: 3,
|
|
1023
|
-
|
|
1024
|
-
size: "small",
|
|
1025
|
-
disabled: _ctx.disabled
|
|
1067
|
+
type: "primary",
|
|
1068
|
+
size: _ctx.config.enableToggleMode ? "small" : "default",
|
|
1069
|
+
disabled: _ctx.disabled,
|
|
1070
|
+
onClick: addHandler
|
|
1026
1071
|
}, {
|
|
1027
1072
|
default: vue.withCtx(() => _cache[2] || (_cache[2] = [
|
|
1028
1073
|
vue.createTextVNode("新增")
|
|
1029
1074
|
])),
|
|
1030
1075
|
_: 1
|
|
1031
|
-
}, 8, ["disabled"])) : vue.createCommentVNode("", true),
|
|
1076
|
+
}, 8, ["size", "disabled"])) : vue.createCommentVNode("", true),
|
|
1032
1077
|
_ctx.config.enableToggleMode ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1033
1078
|
key: 4,
|
|
1034
1079
|
icon: vue.unref(iconsVue.Grid),
|
|
@@ -1077,7 +1122,9 @@
|
|
|
1077
1122
|
const expand = vue.ref(props.config.expand !== false);
|
|
1078
1123
|
const items = vue.computed(() => props.config.items);
|
|
1079
1124
|
const filter = (config) => filterFunction(mForm, config, props);
|
|
1080
|
-
const changeHandler = () =>
|
|
1125
|
+
const changeHandler = (v, eventData) => {
|
|
1126
|
+
emit("change", props.model, eventData);
|
|
1127
|
+
};
|
|
1081
1128
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1082
1129
|
return (_ctx, _cache) => {
|
|
1083
1130
|
return items.value && items.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), {
|
|
@@ -1174,7 +1221,7 @@
|
|
|
1174
1221
|
const emit = __emit;
|
|
1175
1222
|
const mForm = vue.inject("mForm");
|
|
1176
1223
|
const display$1 = vue.computed(() => display(mForm, props.config.display, props));
|
|
1177
|
-
const changeHandler = () => emit("change",
|
|
1224
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
1178
1225
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1179
1226
|
return (_ctx, _cache) => {
|
|
1180
1227
|
return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCol), { span: _ctx.span }, {
|
|
@@ -1223,7 +1270,9 @@
|
|
|
1223
1270
|
const props = __props;
|
|
1224
1271
|
const emit = __emit;
|
|
1225
1272
|
const mForm = vue.inject("mForm");
|
|
1226
|
-
const changeHandler = () =>
|
|
1273
|
+
const changeHandler = (v, eventData) => {
|
|
1274
|
+
emit("change", props.name ? props.model[props.name] : props.model, eventData);
|
|
1275
|
+
};
|
|
1227
1276
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1228
1277
|
return (_ctx, _cache) => {
|
|
1229
1278
|
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRow), { gutter: 10 }, {
|
|
@@ -1259,6 +1308,7 @@
|
|
|
1259
1308
|
__name: "Step",
|
|
1260
1309
|
props: {
|
|
1261
1310
|
model: {},
|
|
1311
|
+
name: {},
|
|
1262
1312
|
lastValues: {},
|
|
1263
1313
|
isCompare: { type: Boolean },
|
|
1264
1314
|
config: {},
|
|
@@ -1280,8 +1330,8 @@
|
|
|
1280
1330
|
active.value = index + 1;
|
|
1281
1331
|
mForm?.$emit("update:stepActive", active.value);
|
|
1282
1332
|
};
|
|
1283
|
-
const changeHandler = () => {
|
|
1284
|
-
emit("change", props.model);
|
|
1333
|
+
const changeHandler = (v, eventData) => {
|
|
1334
|
+
emit("change", props.model, eventData);
|
|
1285
1335
|
};
|
|
1286
1336
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1287
1337
|
return (_ctx, _cache) => {
|
|
@@ -1394,10 +1444,6 @@
|
|
|
1394
1444
|
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
|
|
1395
1445
|
}
|
|
1396
1446
|
};
|
|
1397
|
-
const foreUpdate = () => {
|
|
1398
|
-
updateKey.value += 1;
|
|
1399
|
-
setTimeout(() => rowDrop());
|
|
1400
|
-
};
|
|
1401
1447
|
const swapArray = (index1, index2) => {
|
|
1402
1448
|
props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
|
|
1403
1449
|
if (props.sortKey) {
|
|
@@ -1407,31 +1453,25 @@
|
|
|
1407
1453
|
}
|
|
1408
1454
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1409
1455
|
};
|
|
1456
|
+
let sortable;
|
|
1410
1457
|
const rowDrop = () => {
|
|
1458
|
+
sortable?.destroy();
|
|
1411
1459
|
const tableEl = tMagicTable.value?.instance.$el;
|
|
1412
1460
|
const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
|
|
1413
|
-
if (tBodyEl) {
|
|
1414
|
-
|
|
1415
|
-
onEnd: ({ newIndex, oldIndex }) => {
|
|
1416
|
-
if (typeof newIndex === "undefined") return;
|
|
1417
|
-
if (typeof oldIndex === "undefined") return;
|
|
1418
|
-
swapArray(newIndex, oldIndex);
|
|
1419
|
-
emit("change", props.model[modelName.value]);
|
|
1420
|
-
foreUpdate();
|
|
1421
|
-
sortable.destroy();
|
|
1422
|
-
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1423
|
-
utils.sleep(1e3).then(() => {
|
|
1424
|
-
const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
|
|
1425
|
-
if (elTrs?.[newIndex]) {
|
|
1426
|
-
elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
|
|
1427
|
-
utils.sleep(1e3).then(() => {
|
|
1428
|
-
elTrs[newIndex].style.backgroundColor = "";
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
});
|
|
1461
|
+
if (!tBodyEl) {
|
|
1462
|
+
return;
|
|
1434
1463
|
}
|
|
1464
|
+
sortable = Sortable.create(tBodyEl, {
|
|
1465
|
+
draggable: ".tmagic-design-table-row",
|
|
1466
|
+
direction: "vertical",
|
|
1467
|
+
onEnd: ({ newIndex, oldIndex }) => {
|
|
1468
|
+
if (typeof newIndex === "undefined") return;
|
|
1469
|
+
if (typeof oldIndex === "undefined") return;
|
|
1470
|
+
swapArray(newIndex, oldIndex);
|
|
1471
|
+
emit("change", props.model[modelName.value]);
|
|
1472
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1435
1475
|
};
|
|
1436
1476
|
const newHandler = async (row) => {
|
|
1437
1477
|
if (props.config.max && props.model[modelName.value].length >= props.config.max) {
|
|
@@ -1490,7 +1530,14 @@
|
|
|
1490
1530
|
inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
|
|
1491
1531
|
}
|
|
1492
1532
|
props.model[modelName.value].push(inputs);
|
|
1493
|
-
emit("change", props.model[modelName.value]
|
|
1533
|
+
emit("change", props.model[modelName.value], {
|
|
1534
|
+
changeRecords: [
|
|
1535
|
+
{
|
|
1536
|
+
propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
|
|
1537
|
+
value: inputs
|
|
1538
|
+
}
|
|
1539
|
+
]
|
|
1540
|
+
});
|
|
1494
1541
|
};
|
|
1495
1542
|
vue.onMounted(() => {
|
|
1496
1543
|
if (props.config.defautSort) {
|
|
@@ -1693,6 +1740,9 @@
|
|
|
1693
1740
|
return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
|
|
1694
1741
|
};
|
|
1695
1742
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1743
|
+
const changeHandler = (v, eventData) => {
|
|
1744
|
+
emit("change", props.model, eventData);
|
|
1745
|
+
};
|
|
1696
1746
|
__expose({
|
|
1697
1747
|
toggleRowSelection
|
|
1698
1748
|
});
|
|
@@ -1733,7 +1783,7 @@
|
|
|
1733
1783
|
onSortChange: sortChange
|
|
1734
1784
|
}, {
|
|
1735
1785
|
default: vue.withCtx(() => [
|
|
1736
|
-
_ctx.config.itemExtra ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1786
|
+
_ctx.config.itemExtra && !_ctx.config.dropSort ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1737
1787
|
key: 0,
|
|
1738
1788
|
fixed: "left",
|
|
1739
1789
|
width: "30",
|
|
@@ -1856,8 +1906,8 @@
|
|
|
1856
1906
|
lastValues: lastData.value[scope.$index],
|
|
1857
1907
|
"is-compare": _ctx.isCompare,
|
|
1858
1908
|
size: _ctx.size,
|
|
1859
|
-
onChange:
|
|
1860
|
-
onAddDiffCount: _cache[
|
|
1909
|
+
onChange: changeHandler,
|
|
1910
|
+
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
1861
1911
|
}, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : vue.createCommentVNode("", true)
|
|
1862
1912
|
]),
|
|
1863
1913
|
_: 2
|
|
@@ -1878,9 +1928,9 @@
|
|
|
1878
1928
|
type: "primary",
|
|
1879
1929
|
disabled: _ctx.disabled,
|
|
1880
1930
|
plain: "",
|
|
1881
|
-
onClick: _cache[
|
|
1931
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
1882
1932
|
}, {
|
|
1883
|
-
default: vue.withCtx(() => _cache[
|
|
1933
|
+
default: vue.withCtx(() => _cache[3] || (_cache[3] = [
|
|
1884
1934
|
vue.createTextVNode("新增一行")
|
|
1885
1935
|
])),
|
|
1886
1936
|
_: 1
|
|
@@ -1893,7 +1943,7 @@
|
|
|
1893
1943
|
type: "primary",
|
|
1894
1944
|
onClick: toggleMode
|
|
1895
1945
|
}, {
|
|
1896
|
-
default: vue.withCtx(() => _cache[
|
|
1946
|
+
default: vue.withCtx(() => _cache[4] || (_cache[4] = [
|
|
1897
1947
|
vue.createTextVNode("展开配置")
|
|
1898
1948
|
])),
|
|
1899
1949
|
_: 1
|
|
@@ -1927,7 +1977,7 @@
|
|
|
1927
1977
|
disabled: _ctx.disabled,
|
|
1928
1978
|
plain: ""
|
|
1929
1979
|
}, {
|
|
1930
|
-
default: vue.withCtx(() => _cache[
|
|
1980
|
+
default: vue.withCtx(() => _cache[5] || (_cache[5] = [
|
|
1931
1981
|
vue.createTextVNode("导入EXCEL")
|
|
1932
1982
|
])),
|
|
1933
1983
|
_: 1
|
|
@@ -1941,9 +1991,9 @@
|
|
|
1941
1991
|
type: "warning",
|
|
1942
1992
|
disabled: _ctx.disabled,
|
|
1943
1993
|
plain: "",
|
|
1944
|
-
onClick: _cache[
|
|
1994
|
+
onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
|
|
1945
1995
|
}, {
|
|
1946
|
-
default: vue.withCtx(() => _cache[
|
|
1996
|
+
default: vue.withCtx(() => _cache[6] || (_cache[6] = [
|
|
1947
1997
|
vue.createTextVNode("清空")
|
|
1948
1998
|
])),
|
|
1949
1999
|
_: 1
|
|
@@ -2032,24 +2082,35 @@
|
|
|
2032
2082
|
});
|
|
2033
2083
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
2034
2084
|
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
2035
|
-
const onTabAdd = () => {
|
|
2036
|
-
if (!props.
|
|
2085
|
+
const onTabAdd = async () => {
|
|
2086
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2037
2087
|
if (typeof props.config.onTabAdd === "function") {
|
|
2038
2088
|
props.config.onTabAdd(mForm, {
|
|
2039
2089
|
model: props.model,
|
|
2040
2090
|
prop: props.prop,
|
|
2041
2091
|
config: props.config
|
|
2042
2092
|
});
|
|
2043
|
-
|
|
2044
|
-
|
|
2093
|
+
emit("change", props.model);
|
|
2094
|
+
} else {
|
|
2095
|
+
const newObj = await initValue(mForm, {
|
|
2096
|
+
config: props.config.items,
|
|
2097
|
+
initValues: {}
|
|
2098
|
+
});
|
|
2045
2099
|
newObj.title = `标签${tabs.value.length + 1}`;
|
|
2046
|
-
props.model[props.
|
|
2100
|
+
props.model[props.name].push(newObj);
|
|
2101
|
+
emit("change", props.model[props.name], {
|
|
2102
|
+
changeRecords: [
|
|
2103
|
+
{
|
|
2104
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
2105
|
+
value: newObj
|
|
2106
|
+
}
|
|
2107
|
+
]
|
|
2108
|
+
});
|
|
2047
2109
|
}
|
|
2048
|
-
emit("change", props.model);
|
|
2049
|
-
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2110
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2050
2111
|
};
|
|
2051
2112
|
const onTabRemove = (tabName) => {
|
|
2052
|
-
if (!props.
|
|
2113
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2053
2114
|
if (typeof props.config.onTabRemove === "function") {
|
|
2054
2115
|
props.config.onTabRemove(mForm, tabName, {
|
|
2055
2116
|
model: props.model,
|
|
@@ -2057,20 +2118,17 @@
|
|
|
2057
2118
|
config: props.config
|
|
2058
2119
|
});
|
|
2059
2120
|
} else {
|
|
2060
|
-
props.model[props.
|
|
2061
|
-
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.
|
|
2121
|
+
props.model[props.name].splice(+tabName, 1);
|
|
2122
|
+
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
|
|
2062
2123
|
activeTabName.value = (+activeTabName.value - 1).toString();
|
|
2063
2124
|
tabClick(mForm, { name: activeTabName.value }, props);
|
|
2064
2125
|
}
|
|
2065
2126
|
}
|
|
2066
2127
|
emit("change", props.model);
|
|
2067
|
-
mForm?.$emit("field-change", props.prop, props.model[props.
|
|
2128
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2068
2129
|
};
|
|
2069
|
-
const changeHandler = () => {
|
|
2070
|
-
emit("change", props.model);
|
|
2071
|
-
if (typeof props.config.onChange === "function") {
|
|
2072
|
-
props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
|
|
2073
|
-
}
|
|
2130
|
+
const changeHandler = (v, eventData) => {
|
|
2131
|
+
emit("change", props.model, eventData);
|
|
2074
2132
|
};
|
|
2075
2133
|
const onAddDiffCount = (tabIndex) => {
|
|
2076
2134
|
if (!diffCount.value[tabIndex]) {
|
|
@@ -2613,9 +2671,9 @@
|
|
|
2613
2671
|
const props = __props;
|
|
2614
2672
|
const emit = __emit;
|
|
2615
2673
|
useAddField(props.prop);
|
|
2616
|
-
const value = props.model?.[props.name]
|
|
2674
|
+
const value = props.model?.[props.name]?.toString();
|
|
2617
2675
|
if (props.model) {
|
|
2618
|
-
if (value === "Invalid Date") {
|
|
2676
|
+
if (!value || value === "Invalid Date") {
|
|
2619
2677
|
props.model[props.name] = "";
|
|
2620
2678
|
} else {
|
|
2621
2679
|
props.model[props.name] = datetimeFormatter(
|
|
@@ -2714,7 +2772,7 @@
|
|
|
2714
2772
|
let oldVal = props.model?.[v.name] || "";
|
|
2715
2773
|
if (!oldVal && v.defaultValue !== void 0) {
|
|
2716
2774
|
oldVal = v.defaultValue;
|
|
2717
|
-
emit("change", oldVal, v.name);
|
|
2775
|
+
emit("change", oldVal, { modifyKey: v.name });
|
|
2718
2776
|
}
|
|
2719
2777
|
fieldMap.value[v.name] = oldVal;
|
|
2720
2778
|
fieldLabelMap.value[v.name] = v.label || "";
|
|
@@ -2737,7 +2795,9 @@
|
|
|
2737
2795
|
}
|
|
2738
2796
|
});
|
|
2739
2797
|
const inputChangeHandler = (key) => {
|
|
2740
|
-
emit("change", fieldMap.value[key],
|
|
2798
|
+
emit("change", fieldMap.value[key], {
|
|
2799
|
+
modifyKey: key
|
|
2800
|
+
});
|
|
2741
2801
|
};
|
|
2742
2802
|
return (_ctx, _cache) => {
|
|
2743
2803
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
@@ -2818,9 +2878,10 @@
|
|
|
2818
2878
|
labelPosition: { default: "right" },
|
|
2819
2879
|
keyProp: { default: "__key" },
|
|
2820
2880
|
popperClass: {},
|
|
2881
|
+
preventSubmitDefault: { type: Boolean },
|
|
2821
2882
|
extendState: {}
|
|
2822
2883
|
},
|
|
2823
|
-
emits: ["change", "error", "field-input", "field-change"],
|
|
2884
|
+
emits: ["change", "error", "field-input", "field-change", "update:stepActive"],
|
|
2824
2885
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2825
2886
|
const props = __props;
|
|
2826
2887
|
const emit = __emit;
|
|
@@ -2845,11 +2906,13 @@
|
|
|
2845
2906
|
setField: (prop, field) => fields.set(prop, field),
|
|
2846
2907
|
getField: (prop) => fields.get(prop),
|
|
2847
2908
|
deleteField: (prop) => fields.delete(prop),
|
|
2909
|
+
$messageBox: design.tMagicMessageBox,
|
|
2910
|
+
$message: design.tMagicMessage,
|
|
2848
2911
|
post: (options) => {
|
|
2849
2912
|
if (requestFuc) {
|
|
2850
2913
|
return requestFuc({
|
|
2851
|
-
|
|
2852
|
-
|
|
2914
|
+
method: "POST",
|
|
2915
|
+
...options
|
|
2853
2916
|
});
|
|
2854
2917
|
}
|
|
2855
2918
|
}
|
|
@@ -2870,9 +2933,11 @@
|
|
|
2870
2933
|
}
|
|
2871
2934
|
});
|
|
2872
2935
|
vue.provide("mForm", formState);
|
|
2936
|
+
const changeRecords = vue.shallowRef([]);
|
|
2873
2937
|
vue.watch(
|
|
2874
2938
|
[() => props.config, () => props.initValues],
|
|
2875
2939
|
([config], [preConfig]) => {
|
|
2940
|
+
changeRecords.value = [];
|
|
2876
2941
|
if (!lodashEs.isEqual(vue.toRaw(config), vue.toRaw(preConfig))) {
|
|
2877
2942
|
initialized.value = false;
|
|
2878
2943
|
}
|
|
@@ -2895,16 +2960,28 @@
|
|
|
2895
2960
|
},
|
|
2896
2961
|
{ immediate: true }
|
|
2897
2962
|
);
|
|
2898
|
-
const changeHandler = () => {
|
|
2899
|
-
|
|
2963
|
+
const changeHandler = (v, eventData) => {
|
|
2964
|
+
if (eventData.changeRecords?.length) {
|
|
2965
|
+
changeRecords.value.push(...eventData.changeRecords);
|
|
2966
|
+
}
|
|
2967
|
+
emit("change", values.value, eventData);
|
|
2968
|
+
};
|
|
2969
|
+
const submitHandler = (e) => {
|
|
2970
|
+
if (props.preventSubmitDefault) {
|
|
2971
|
+
e.preventDefault();
|
|
2972
|
+
}
|
|
2900
2973
|
};
|
|
2901
2974
|
__expose({
|
|
2902
2975
|
values,
|
|
2903
2976
|
lastValuesProcessed,
|
|
2904
2977
|
formState,
|
|
2905
2978
|
initialized,
|
|
2979
|
+
changeRecords,
|
|
2906
2980
|
changeHandler,
|
|
2907
|
-
resetForm: () =>
|
|
2981
|
+
resetForm: () => {
|
|
2982
|
+
tMagicForm.value?.resetFields();
|
|
2983
|
+
changeRecords.value = [];
|
|
2984
|
+
},
|
|
2908
2985
|
submitForm: async (native) => {
|
|
2909
2986
|
try {
|
|
2910
2987
|
await tMagicForm.value?.validate();
|
|
@@ -2932,7 +3009,8 @@
|
|
|
2932
3009
|
"label-width": _ctx.labelWidth,
|
|
2933
3010
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
2934
3011
|
inline: _ctx.inline,
|
|
2935
|
-
"label-position": _ctx.labelPosition
|
|
3012
|
+
"label-position": _ctx.labelPosition,
|
|
3013
|
+
onSubmit: submitHandler
|
|
2936
3014
|
}, {
|
|
2937
3015
|
default: vue.withCtx(() => [
|
|
2938
3016
|
initialized.value && Array.isArray(_ctx.config) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.config, (item, index) => {
|
|
@@ -2975,7 +3053,8 @@
|
|
|
2975
3053
|
labelPosition: {},
|
|
2976
3054
|
zIndex: {},
|
|
2977
3055
|
size: {},
|
|
2978
|
-
confirmText: { default: "确定" }
|
|
3056
|
+
confirmText: { default: "确定" },
|
|
3057
|
+
preventSubmitDefault: { type: Boolean }
|
|
2979
3058
|
},
|
|
2980
3059
|
emits: ["close", "submit", "error", "change"],
|
|
2981
3060
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -3011,7 +3090,7 @@
|
|
|
3011
3090
|
const save = async () => {
|
|
3012
3091
|
try {
|
|
3013
3092
|
const values = await form.value?.submitForm();
|
|
3014
|
-
emit("submit", values);
|
|
3093
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
3015
3094
|
} catch (e) {
|
|
3016
3095
|
emit("error", e);
|
|
3017
3096
|
}
|
|
@@ -3022,8 +3101,8 @@
|
|
|
3022
3101
|
const nextStep = () => {
|
|
3023
3102
|
stepActive.value += 1;
|
|
3024
3103
|
};
|
|
3025
|
-
const changeHandler = (value) => {
|
|
3026
|
-
emit("change", value);
|
|
3104
|
+
const changeHandler = (value, eventData) => {
|
|
3105
|
+
emit("change", value, eventData);
|
|
3027
3106
|
};
|
|
3028
3107
|
const show = () => {
|
|
3029
3108
|
dialogVisible.value = true;
|
|
@@ -3144,8 +3223,9 @@
|
|
|
3144
3223
|
"label-width": _ctx.labelWidth,
|
|
3145
3224
|
"label-position": _ctx.labelPosition,
|
|
3146
3225
|
inline: _ctx.inline,
|
|
3226
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
3147
3227
|
onChange: changeHandler
|
|
3148
|
-
}, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
3228
|
+
}, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
3149
3229
|
vue.renderSlot(_ctx.$slots, "default")
|
|
3150
3230
|
], 4)) : vue.createCommentVNode("", true)
|
|
3151
3231
|
]),
|
|
@@ -3871,7 +3951,7 @@
|
|
|
3871
3951
|
}
|
|
3872
3952
|
});
|
|
3873
3953
|
|
|
3874
|
-
const _hoisted_1$1 = {
|
|
3954
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3875
3955
|
const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3876
3956
|
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3877
3957
|
...{
|
|
@@ -3916,11 +3996,11 @@
|
|
|
3916
3996
|
emit("change", props.model[props.name].trim() || "");
|
|
3917
3997
|
popoverVisible.value = false;
|
|
3918
3998
|
};
|
|
3919
|
-
const checkWhiteSpace = (value) => {
|
|
3999
|
+
const checkWhiteSpace = lodashEs.debounce((value) => {
|
|
3920
4000
|
if (typeof value === "string" && !props.config.trim) {
|
|
3921
4001
|
popoverVisible.value = value.trim() !== value;
|
|
3922
4002
|
}
|
|
3923
|
-
};
|
|
4003
|
+
}, 300);
|
|
3924
4004
|
const changeHandler = (value) => {
|
|
3925
4005
|
emit("change", value);
|
|
3926
4006
|
};
|
|
@@ -3987,45 +4067,70 @@
|
|
|
3987
4067
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
3988
4068
|
emit("change", props.model[props.name]);
|
|
3989
4069
|
};
|
|
4070
|
+
const popoverEl = vue.ref();
|
|
4071
|
+
const input = vue.ref();
|
|
4072
|
+
const instanceRef = vue.shallowRef();
|
|
4073
|
+
vue.watch(popoverEl, (el) => {
|
|
4074
|
+
destroyPopover();
|
|
4075
|
+
if (!input.value?.$el || !el) return;
|
|
4076
|
+
instanceRef.value = core.createPopper(input.value.$el, el, {
|
|
4077
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
4078
|
+
strategy: "absolute",
|
|
4079
|
+
modifiers: [
|
|
4080
|
+
{
|
|
4081
|
+
name: "offset",
|
|
4082
|
+
options: {
|
|
4083
|
+
offset: [0, 10]
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
]
|
|
4087
|
+
});
|
|
4088
|
+
});
|
|
4089
|
+
const destroyPopover = () => {
|
|
4090
|
+
if (!instanceRef.value) return;
|
|
4091
|
+
instanceRef.value.destroy();
|
|
4092
|
+
instanceRef.value = void 0;
|
|
4093
|
+
};
|
|
3990
4094
|
return (_ctx, _cache) => {
|
|
3991
|
-
return vue.openBlock(), vue.
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
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
|
-
|
|
4095
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
4096
|
+
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
4097
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4098
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4099
|
+
ref_key: "input",
|
|
4100
|
+
ref: input,
|
|
4101
|
+
clearable: "",
|
|
4102
|
+
size: _ctx.size,
|
|
4103
|
+
placeholder: _ctx.config.placeholder,
|
|
4104
|
+
disabled: _ctx.disabled,
|
|
4105
|
+
onChange: changeHandler,
|
|
4106
|
+
onInput: inputHandler,
|
|
4107
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4108
|
+
}, vue.createSlots({ _: 2 }, [
|
|
4109
|
+
appendConfig.value ? {
|
|
4110
|
+
name: "append",
|
|
4111
|
+
fn: vue.withCtx(() => [
|
|
4112
|
+
appendConfig.value.type === "button" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
4113
|
+
key: 0,
|
|
4114
|
+
style: { "color": "#409eff" },
|
|
4115
|
+
size: _ctx.size,
|
|
4116
|
+
onClick: vue.withModifiers(buttonClickHandler, ["prevent"])
|
|
4117
|
+
}, {
|
|
4118
|
+
default: vue.withCtx(() => [
|
|
4119
|
+
vue.createTextVNode(vue.toDisplayString(appendConfig.value.text), 1)
|
|
4120
|
+
]),
|
|
4121
|
+
_: 1
|
|
4122
|
+
}, 8, ["size"])) : vue.createCommentVNode("", true)
|
|
4123
|
+
]),
|
|
4124
|
+
key: "0"
|
|
4125
|
+
} : void 0
|
|
4126
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4127
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4128
|
+
popoverVisible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4129
|
+
key: 0,
|
|
4130
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4131
|
+
ref_key: "popoverEl",
|
|
4132
|
+
ref: popoverEl
|
|
4133
|
+
}, [
|
|
4029
4134
|
_cache[5] || (_cache[5] = vue.createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
|
|
4030
4135
|
vue.createElementVNode("div", _hoisted_2, [
|
|
4031
4136
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
@@ -4048,11 +4153,14 @@
|
|
|
4048
4153
|
])),
|
|
4049
4154
|
_: 1
|
|
4050
4155
|
})
|
|
4051
|
-
])
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4156
|
+
]),
|
|
4157
|
+
_cache[6] || (_cache[6] = vue.createElementVNode("span", {
|
|
4158
|
+
class: "tmagic-form-text-popper-arrow",
|
|
4159
|
+
"data-popper-arrow": ""
|
|
4160
|
+
}, null, -1))
|
|
4161
|
+
], 512)) : vue.createCommentVNode("", true)
|
|
4162
|
+
]))
|
|
4163
|
+
]);
|
|
4056
4164
|
};
|
|
4057
4165
|
}
|
|
4058
4166
|
});
|
|
@@ -4237,6 +4345,7 @@
|
|
|
4237
4345
|
confirmText: { default: "确定" },
|
|
4238
4346
|
inline: { type: Boolean },
|
|
4239
4347
|
labelPosition: {},
|
|
4348
|
+
preventSubmitDefault: { type: Boolean },
|
|
4240
4349
|
beforeClose: {}
|
|
4241
4350
|
},
|
|
4242
4351
|
emits: ["close", "closed", "submit", "error", "change", "open", "opened"],
|
|
@@ -4256,13 +4365,13 @@
|
|
|
4256
4365
|
const submitHandler = async () => {
|
|
4257
4366
|
try {
|
|
4258
4367
|
const values = await form.value?.submitForm();
|
|
4259
|
-
emit("submit", values);
|
|
4368
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4260
4369
|
} catch (e) {
|
|
4261
4370
|
emit("error", e);
|
|
4262
4371
|
}
|
|
4263
4372
|
};
|
|
4264
|
-
const changeHandler = (value) => {
|
|
4265
|
-
emit("change", value);
|
|
4373
|
+
const changeHandler = (value, eventData) => {
|
|
4374
|
+
emit("change", value, eventData);
|
|
4266
4375
|
};
|
|
4267
4376
|
const openHandler = () => {
|
|
4268
4377
|
emit("open");
|
|
@@ -4373,8 +4482,9 @@
|
|
|
4373
4482
|
"label-width": _ctx.labelWidth,
|
|
4374
4483
|
"label-position": _ctx.labelPosition,
|
|
4375
4484
|
inline: _ctx.inline,
|
|
4485
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
4376
4486
|
onChange: changeHandler
|
|
4377
|
-
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
4487
|
+
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
4378
4488
|
vue.renderSlot(_ctx.$slots, "default")
|
|
4379
4489
|
], 512)) : vue.createCommentVNode("", true)
|
|
4380
4490
|
]),
|
|
@@ -4401,9 +4511,10 @@
|
|
|
4401
4511
|
size: {},
|
|
4402
4512
|
confirmText: { default: "确定" },
|
|
4403
4513
|
inline: { type: Boolean },
|
|
4404
|
-
labelPosition: {}
|
|
4514
|
+
labelPosition: {},
|
|
4515
|
+
preventSubmitDefault: { type: Boolean }
|
|
4405
4516
|
},
|
|
4406
|
-
emits: ["
|
|
4517
|
+
emits: ["change", "submit", "error"],
|
|
4407
4518
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4408
4519
|
const props = __props;
|
|
4409
4520
|
const emit = __emit;
|
|
@@ -4429,13 +4540,13 @@
|
|
|
4429
4540
|
const submitHandler = async () => {
|
|
4430
4541
|
try {
|
|
4431
4542
|
const values = await form.value?.submitForm();
|
|
4432
|
-
emit("submit", values);
|
|
4543
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4433
4544
|
} catch (e) {
|
|
4434
4545
|
emit("error", e);
|
|
4435
4546
|
}
|
|
4436
4547
|
};
|
|
4437
|
-
const changeHandler = (value) => {
|
|
4438
|
-
emit("change", value);
|
|
4548
|
+
const changeHandler = (value, eventData) => {
|
|
4549
|
+
emit("change", value, eventData);
|
|
4439
4550
|
};
|
|
4440
4551
|
const show = () => {
|
|
4441
4552
|
};
|
|
@@ -4469,8 +4580,9 @@
|
|
|
4469
4580
|
"label-width": _ctx.labelWidth,
|
|
4470
4581
|
"label-position": _ctx.labelPosition,
|
|
4471
4582
|
inline: _ctx.inline,
|
|
4583
|
+
"prevent-submit-default": _ctx.preventSubmitDefault,
|
|
4472
4584
|
onChange: changeHandler
|
|
4473
|
-
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline"]),
|
|
4585
|
+
}, null, 8, ["size", "disabled", "config", "init-values", "parent-values", "label-width", "label-position", "inline", "prevent-submit-default"]),
|
|
4474
4586
|
vue.renderSlot(_ctx.$slots, "default")
|
|
4475
4587
|
]),
|
|
4476
4588
|
_: 3
|
|
@@ -4508,8 +4620,8 @@
|
|
|
4508
4620
|
const createForm = (config) => config;
|
|
4509
4621
|
const defaultInstallOpt = {};
|
|
4510
4622
|
const index = {
|
|
4511
|
-
install(app, opt) {
|
|
4512
|
-
const option = Object.assign(defaultInstallOpt, opt
|
|
4623
|
+
install(app, opt = {}) {
|
|
4624
|
+
const option = Object.assign(defaultInstallOpt, opt);
|
|
4513
4625
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
4514
4626
|
setConfig(option);
|
|
4515
4627
|
app.component("m-form", _sfc_main$d);
|
|
@@ -4523,6 +4635,7 @@
|
|
|
4523
4635
|
app.component("m-form-table", _sfc_main$p);
|
|
4524
4636
|
app.component("m-form-tab", _sfc_main$o);
|
|
4525
4637
|
app.component("m-fields-text", _sfc_main$5);
|
|
4638
|
+
app.component("m-fields-img-upload", _sfc_main$5);
|
|
4526
4639
|
app.component("m-fields-number", _sfc_main$a);
|
|
4527
4640
|
app.component("m-fields-number-range", _sfc_main$9);
|
|
4528
4641
|
app.component("m-fields-textarea", _sfc_main$4);
|