@tmagic/form 1.5.0-beta.13 → 1.5.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +51 -0
- package/dist/tmagic-form.js +245 -140
- package/dist/tmagic-form.umd.cjs +245 -141
- package/package.json +8 -6
- package/src/Form.vue +17 -6
- package/src/FormBox.vue +9 -5
- package/src/FormDialog.vue +4 -4
- package/src/FormDrawer.vue +4 -4
- package/src/containers/Col.vue +6 -3
- package/src/containers/Container.vue +86 -31
- package/src/containers/Fieldset.vue +13 -12
- package/src/containers/GroupList.vue +26 -10
- package/src/containers/GroupListItem.vue +4 -2
- package/src/containers/Panel.vue +8 -3
- package/src/containers/Row.vue +8 -3
- package/src/containers/Step.vue +9 -4
- package/src/containers/Table.vue +15 -3
- package/src/containers/Tabs.vue +35 -20
- package/src/fields/DateTime.vue +2 -2
- package/src/fields/DynamicField.vue +4 -2
- package/src/fields/Text.vue +71 -36
- package/src/index.ts +2 -2
- package/src/schema.ts +26 -16
- package/src/theme/text.scss +56 -0
- package/types/index.d.ts +410 -672
package/dist/tmagic-form.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");
|
|
@@ -574,11 +606,11 @@
|
|
|
574
606
|
_: 1
|
|
575
607
|
})) : vue.createCommentVNode("", true)
|
|
576
608
|
], 64)) : items.value && display$1.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 4 }, [
|
|
577
|
-
(
|
|
609
|
+
(isValidName() ? _ctx.model[name.value] : _ctx.model) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(items.value, (item) => {
|
|
578
610
|
return vue.openBlock(), vue.createBlock(_component_Container, {
|
|
579
611
|
key: key(item),
|
|
580
|
-
model:
|
|
581
|
-
"last-values":
|
|
612
|
+
model: isValidName() ? _ctx.model[name.value] : _ctx.model,
|
|
613
|
+
"last-values": isValidName() ? _ctx.lastValues[name.value] || {} : _ctx.lastValues,
|
|
582
614
|
"is-compare": _ctx.isCompare,
|
|
583
615
|
config: item,
|
|
584
616
|
size: _ctx.size,
|
|
@@ -656,16 +688,17 @@
|
|
|
656
688
|
}
|
|
657
689
|
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
658
690
|
});
|
|
659
|
-
const
|
|
660
|
-
emit("change",
|
|
691
|
+
const valueChangeHandler = (value) => {
|
|
692
|
+
emit("change", value, { modifyKey: "value" });
|
|
661
693
|
};
|
|
694
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
662
695
|
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
663
696
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
664
697
|
return (_ctx, _cache) => {
|
|
665
698
|
return (name.value ? _ctx.model[name.value] : _ctx.model) ? (vue.openBlock(), vue.createElementBlock("fieldset", {
|
|
666
699
|
key: 0,
|
|
667
700
|
class: "m-fieldset",
|
|
668
|
-
style: vue.normalizeStyle(show.value ? "padding: 15px
|
|
701
|
+
style: vue.normalizeStyle(show.value ? "padding: 15px" : "border: 0")
|
|
669
702
|
}, [
|
|
670
703
|
name.value && _ctx.config.checkbox ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
|
|
671
704
|
default: vue.withCtx(() => [
|
|
@@ -673,7 +706,7 @@
|
|
|
673
706
|
modelValue: _ctx.model[name.value].value,
|
|
674
707
|
"onUpdate:modelValue": [
|
|
675
708
|
_cache[0] || (_cache[0] = ($event) => _ctx.model[name.value].value = $event),
|
|
676
|
-
|
|
709
|
+
valueChangeHandler
|
|
677
710
|
],
|
|
678
711
|
prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.config.name}.value`,
|
|
679
712
|
"true-value": 1,
|
|
@@ -717,7 +750,7 @@
|
|
|
717
750
|
disabled: _ctx.disabled,
|
|
718
751
|
labelWidth: lWidth.value,
|
|
719
752
|
size: _ctx.size,
|
|
720
|
-
onChange:
|
|
753
|
+
onChange: changeHandler,
|
|
721
754
|
onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
|
|
722
755
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
|
|
723
756
|
}), 128))
|
|
@@ -738,7 +771,7 @@
|
|
|
738
771
|
labelWidth: lWidth.value,
|
|
739
772
|
size: _ctx.size,
|
|
740
773
|
disabled: _ctx.disabled,
|
|
741
|
-
onChange:
|
|
774
|
+
onChange: changeHandler,
|
|
742
775
|
onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
|
|
743
776
|
}, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
|
|
744
777
|
}), 128)) : vue.createCommentVNode("", true)
|
|
@@ -792,7 +825,9 @@
|
|
|
792
825
|
const length = vue.computed(() => props.groupModel?.length || 0);
|
|
793
826
|
const itemExtra = vue.computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
794
827
|
const removeHandler = () => emit("remove-item", props.index);
|
|
795
|
-
const changeHandler = () =>
|
|
828
|
+
const changeHandler = (v, eventData) => {
|
|
829
|
+
emit("change", props.model, eventData);
|
|
830
|
+
};
|
|
796
831
|
const expandHandler = () => {
|
|
797
832
|
expand.value = !expand.value;
|
|
798
833
|
};
|
|
@@ -944,9 +979,8 @@
|
|
|
944
979
|
}
|
|
945
980
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
946
981
|
});
|
|
947
|
-
const changeHandler = () => {
|
|
948
|
-
|
|
949
|
-
emit("change", props.model[props.name]);
|
|
982
|
+
const changeHandler = (v, eventData) => {
|
|
983
|
+
emit("change", props.model, eventData);
|
|
950
984
|
};
|
|
951
985
|
const addHandler = async () => {
|
|
952
986
|
if (!props.name) return false;
|
|
@@ -966,18 +1000,25 @@
|
|
|
966
1000
|
initValues
|
|
967
1001
|
});
|
|
968
1002
|
props.model[props.name].push(groupValue);
|
|
969
|
-
|
|
1003
|
+
emit("change", props.model[props.name], {
|
|
1004
|
+
changeRecords: [
|
|
1005
|
+
{
|
|
1006
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
1007
|
+
value: groupValue
|
|
1008
|
+
}
|
|
1009
|
+
]
|
|
1010
|
+
});
|
|
970
1011
|
};
|
|
971
1012
|
const removeHandler = (index) => {
|
|
972
1013
|
if (!props.name) return false;
|
|
973
1014
|
props.model[props.name].splice(index, 1);
|
|
974
|
-
|
|
1015
|
+
emit("change", props.model[props.name]);
|
|
975
1016
|
};
|
|
976
1017
|
const swapHandler = (idx1, idx2) => {
|
|
977
1018
|
if (!props.name) return false;
|
|
978
1019
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
979
1020
|
props.model[props.name].splice(idx2, 0, currRow);
|
|
980
|
-
|
|
1021
|
+
emit("change", props.model[props.name]);
|
|
981
1022
|
};
|
|
982
1023
|
const toggleMode = () => {
|
|
983
1024
|
props.config.type = "table";
|
|
@@ -1020,15 +1061,16 @@
|
|
|
1020
1061
|
}), 128)),
|
|
1021
1062
|
addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1022
1063
|
key: 3,
|
|
1023
|
-
|
|
1024
|
-
size: "small",
|
|
1025
|
-
disabled: _ctx.disabled
|
|
1064
|
+
type: "primary",
|
|
1065
|
+
size: _ctx.config.enableToggleMode ? "small" : "default",
|
|
1066
|
+
disabled: _ctx.disabled,
|
|
1067
|
+
onClick: addHandler
|
|
1026
1068
|
}, {
|
|
1027
1069
|
default: vue.withCtx(() => _cache[2] || (_cache[2] = [
|
|
1028
1070
|
vue.createTextVNode("新增")
|
|
1029
1071
|
])),
|
|
1030
1072
|
_: 1
|
|
1031
|
-
}, 8, ["disabled"])) : vue.createCommentVNode("", true),
|
|
1073
|
+
}, 8, ["size", "disabled"])) : vue.createCommentVNode("", true),
|
|
1032
1074
|
_ctx.config.enableToggleMode ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1033
1075
|
key: 4,
|
|
1034
1076
|
icon: vue.unref(iconsVue.Grid),
|
|
@@ -1077,7 +1119,9 @@
|
|
|
1077
1119
|
const expand = vue.ref(props.config.expand !== false);
|
|
1078
1120
|
const items = vue.computed(() => props.config.items);
|
|
1079
1121
|
const filter = (config) => filterFunction(mForm, config, props);
|
|
1080
|
-
const changeHandler = () =>
|
|
1122
|
+
const changeHandler = (v, eventData) => {
|
|
1123
|
+
emit("change", props.model, eventData);
|
|
1124
|
+
};
|
|
1081
1125
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1082
1126
|
return (_ctx, _cache) => {
|
|
1083
1127
|
return items.value && items.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), {
|
|
@@ -1174,7 +1218,7 @@
|
|
|
1174
1218
|
const emit = __emit;
|
|
1175
1219
|
const mForm = vue.inject("mForm");
|
|
1176
1220
|
const display$1 = vue.computed(() => display(mForm, props.config.display, props));
|
|
1177
|
-
const changeHandler = () => emit("change",
|
|
1221
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
1178
1222
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1179
1223
|
return (_ctx, _cache) => {
|
|
1180
1224
|
return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCol), { span: _ctx.span }, {
|
|
@@ -1223,7 +1267,9 @@
|
|
|
1223
1267
|
const props = __props;
|
|
1224
1268
|
const emit = __emit;
|
|
1225
1269
|
const mForm = vue.inject("mForm");
|
|
1226
|
-
const changeHandler = () =>
|
|
1270
|
+
const changeHandler = (v, eventData) => {
|
|
1271
|
+
emit("change", props.name ? props.model[props.name] : props.model, eventData);
|
|
1272
|
+
};
|
|
1227
1273
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1228
1274
|
return (_ctx, _cache) => {
|
|
1229
1275
|
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRow), { gutter: 10 }, {
|
|
@@ -1259,6 +1305,7 @@
|
|
|
1259
1305
|
__name: "Step",
|
|
1260
1306
|
props: {
|
|
1261
1307
|
model: {},
|
|
1308
|
+
name: {},
|
|
1262
1309
|
lastValues: {},
|
|
1263
1310
|
isCompare: { type: Boolean },
|
|
1264
1311
|
config: {},
|
|
@@ -1280,8 +1327,8 @@
|
|
|
1280
1327
|
active.value = index + 1;
|
|
1281
1328
|
mForm?.$emit("update:stepActive", active.value);
|
|
1282
1329
|
};
|
|
1283
|
-
const changeHandler = () => {
|
|
1284
|
-
emit("change", props.model);
|
|
1330
|
+
const changeHandler = (v, eventData) => {
|
|
1331
|
+
emit("change", props.model, eventData);
|
|
1285
1332
|
};
|
|
1286
1333
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1287
1334
|
return (_ctx, _cache) => {
|
|
@@ -1490,7 +1537,14 @@
|
|
|
1490
1537
|
inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
|
|
1491
1538
|
}
|
|
1492
1539
|
props.model[modelName.value].push(inputs);
|
|
1493
|
-
emit("change", props.model[modelName.value]
|
|
1540
|
+
emit("change", props.model[modelName.value], {
|
|
1541
|
+
changeRecords: [
|
|
1542
|
+
{
|
|
1543
|
+
propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
|
|
1544
|
+
value: inputs
|
|
1545
|
+
}
|
|
1546
|
+
]
|
|
1547
|
+
});
|
|
1494
1548
|
};
|
|
1495
1549
|
vue.onMounted(() => {
|
|
1496
1550
|
if (props.config.defautSort) {
|
|
@@ -1693,6 +1747,9 @@
|
|
|
1693
1747
|
return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
|
|
1694
1748
|
};
|
|
1695
1749
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1750
|
+
const changeHandler = (v, eventData) => {
|
|
1751
|
+
emit("change", props.model, eventData);
|
|
1752
|
+
};
|
|
1696
1753
|
__expose({
|
|
1697
1754
|
toggleRowSelection
|
|
1698
1755
|
});
|
|
@@ -1856,8 +1913,8 @@
|
|
|
1856
1913
|
lastValues: lastData.value[scope.$index],
|
|
1857
1914
|
"is-compare": _ctx.isCompare,
|
|
1858
1915
|
size: _ctx.size,
|
|
1859
|
-
onChange:
|
|
1860
|
-
onAddDiffCount: _cache[
|
|
1916
|
+
onChange: changeHandler,
|
|
1917
|
+
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
1861
1918
|
}, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : vue.createCommentVNode("", true)
|
|
1862
1919
|
]),
|
|
1863
1920
|
_: 2
|
|
@@ -1878,9 +1935,9 @@
|
|
|
1878
1935
|
type: "primary",
|
|
1879
1936
|
disabled: _ctx.disabled,
|
|
1880
1937
|
plain: "",
|
|
1881
|
-
onClick: _cache[
|
|
1938
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
1882
1939
|
}, {
|
|
1883
|
-
default: vue.withCtx(() => _cache[
|
|
1940
|
+
default: vue.withCtx(() => _cache[3] || (_cache[3] = [
|
|
1884
1941
|
vue.createTextVNode("新增一行")
|
|
1885
1942
|
])),
|
|
1886
1943
|
_: 1
|
|
@@ -1893,7 +1950,7 @@
|
|
|
1893
1950
|
type: "primary",
|
|
1894
1951
|
onClick: toggleMode
|
|
1895
1952
|
}, {
|
|
1896
|
-
default: vue.withCtx(() => _cache[
|
|
1953
|
+
default: vue.withCtx(() => _cache[4] || (_cache[4] = [
|
|
1897
1954
|
vue.createTextVNode("展开配置")
|
|
1898
1955
|
])),
|
|
1899
1956
|
_: 1
|
|
@@ -1927,7 +1984,7 @@
|
|
|
1927
1984
|
disabled: _ctx.disabled,
|
|
1928
1985
|
plain: ""
|
|
1929
1986
|
}, {
|
|
1930
|
-
default: vue.withCtx(() => _cache[
|
|
1987
|
+
default: vue.withCtx(() => _cache[5] || (_cache[5] = [
|
|
1931
1988
|
vue.createTextVNode("导入EXCEL")
|
|
1932
1989
|
])),
|
|
1933
1990
|
_: 1
|
|
@@ -1941,9 +1998,9 @@
|
|
|
1941
1998
|
type: "warning",
|
|
1942
1999
|
disabled: _ctx.disabled,
|
|
1943
2000
|
plain: "",
|
|
1944
|
-
onClick: _cache[
|
|
2001
|
+
onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
|
|
1945
2002
|
}, {
|
|
1946
|
-
default: vue.withCtx(() => _cache[
|
|
2003
|
+
default: vue.withCtx(() => _cache[6] || (_cache[6] = [
|
|
1947
2004
|
vue.createTextVNode("清空")
|
|
1948
2005
|
])),
|
|
1949
2006
|
_: 1
|
|
@@ -2032,24 +2089,35 @@
|
|
|
2032
2089
|
});
|
|
2033
2090
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
2034
2091
|
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
2035
|
-
const onTabAdd = () => {
|
|
2036
|
-
if (!props.
|
|
2092
|
+
const onTabAdd = async () => {
|
|
2093
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2037
2094
|
if (typeof props.config.onTabAdd === "function") {
|
|
2038
2095
|
props.config.onTabAdd(mForm, {
|
|
2039
2096
|
model: props.model,
|
|
2040
2097
|
prop: props.prop,
|
|
2041
2098
|
config: props.config
|
|
2042
2099
|
});
|
|
2043
|
-
|
|
2044
|
-
|
|
2100
|
+
emit("change", props.model);
|
|
2101
|
+
} else {
|
|
2102
|
+
const newObj = await initValue(mForm, {
|
|
2103
|
+
config: props.config.items,
|
|
2104
|
+
initValues: {}
|
|
2105
|
+
});
|
|
2045
2106
|
newObj.title = `标签${tabs.value.length + 1}`;
|
|
2046
|
-
props.model[props.
|
|
2107
|
+
props.model[props.name].push(newObj);
|
|
2108
|
+
emit("change", props.model[props.name], {
|
|
2109
|
+
changeRecords: [
|
|
2110
|
+
{
|
|
2111
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
2112
|
+
value: newObj
|
|
2113
|
+
}
|
|
2114
|
+
]
|
|
2115
|
+
});
|
|
2047
2116
|
}
|
|
2048
|
-
emit("change", props.model);
|
|
2049
|
-
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2117
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2050
2118
|
};
|
|
2051
2119
|
const onTabRemove = (tabName) => {
|
|
2052
|
-
if (!props.
|
|
2120
|
+
if (!props.name) throw new Error("dynamic tab 必须配置name");
|
|
2053
2121
|
if (typeof props.config.onTabRemove === "function") {
|
|
2054
2122
|
props.config.onTabRemove(mForm, tabName, {
|
|
2055
2123
|
model: props.model,
|
|
@@ -2057,20 +2125,17 @@
|
|
|
2057
2125
|
config: props.config
|
|
2058
2126
|
});
|
|
2059
2127
|
} else {
|
|
2060
|
-
props.model[props.
|
|
2061
|
-
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.
|
|
2128
|
+
props.model[props.name].splice(+tabName, 1);
|
|
2129
|
+
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
|
|
2062
2130
|
activeTabName.value = (+activeTabName.value - 1).toString();
|
|
2063
2131
|
tabClick(mForm, { name: activeTabName.value }, props);
|
|
2064
2132
|
}
|
|
2065
2133
|
}
|
|
2066
2134
|
emit("change", props.model);
|
|
2067
|
-
mForm?.$emit("field-change", props.prop, props.model[props.
|
|
2135
|
+
mForm?.$emit("field-change", props.prop, props.model[props.name]);
|
|
2068
2136
|
};
|
|
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
|
-
}
|
|
2137
|
+
const changeHandler = (v, eventData) => {
|
|
2138
|
+
emit("change", props.model, eventData);
|
|
2074
2139
|
};
|
|
2075
2140
|
const onAddDiffCount = (tabIndex) => {
|
|
2076
2141
|
if (!diffCount.value[tabIndex]) {
|
|
@@ -2613,9 +2678,9 @@
|
|
|
2613
2678
|
const props = __props;
|
|
2614
2679
|
const emit = __emit;
|
|
2615
2680
|
useAddField(props.prop);
|
|
2616
|
-
const value = props.model?.[props.name]
|
|
2681
|
+
const value = props.model?.[props.name]?.toString();
|
|
2617
2682
|
if (props.model) {
|
|
2618
|
-
if (value === "Invalid Date") {
|
|
2683
|
+
if (!value || value === "Invalid Date") {
|
|
2619
2684
|
props.model[props.name] = "";
|
|
2620
2685
|
} else {
|
|
2621
2686
|
props.model[props.name] = datetimeFormatter(
|
|
@@ -2714,7 +2779,7 @@
|
|
|
2714
2779
|
let oldVal = props.model?.[v.name] || "";
|
|
2715
2780
|
if (!oldVal && v.defaultValue !== void 0) {
|
|
2716
2781
|
oldVal = v.defaultValue;
|
|
2717
|
-
emit("change", oldVal, v.name);
|
|
2782
|
+
emit("change", oldVal, { modifyKey: v.name });
|
|
2718
2783
|
}
|
|
2719
2784
|
fieldMap.value[v.name] = oldVal;
|
|
2720
2785
|
fieldLabelMap.value[v.name] = v.label || "";
|
|
@@ -2737,7 +2802,9 @@
|
|
|
2737
2802
|
}
|
|
2738
2803
|
});
|
|
2739
2804
|
const inputChangeHandler = (key) => {
|
|
2740
|
-
emit("change", fieldMap.value[key],
|
|
2805
|
+
emit("change", fieldMap.value[key], {
|
|
2806
|
+
modifyKey: key
|
|
2807
|
+
});
|
|
2741
2808
|
};
|
|
2742
2809
|
return (_ctx, _cache) => {
|
|
2743
2810
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
@@ -2821,7 +2888,7 @@
|
|
|
2821
2888
|
preventSubmitDefault: { type: Boolean },
|
|
2822
2889
|
extendState: {}
|
|
2823
2890
|
},
|
|
2824
|
-
emits: ["change", "error", "field-input", "field-change"],
|
|
2891
|
+
emits: ["change", "error", "field-input", "field-change", "update:stepActive"],
|
|
2825
2892
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2826
2893
|
const props = __props;
|
|
2827
2894
|
const emit = __emit;
|
|
@@ -2871,9 +2938,11 @@
|
|
|
2871
2938
|
}
|
|
2872
2939
|
});
|
|
2873
2940
|
vue.provide("mForm", formState);
|
|
2941
|
+
const changeRecords = vue.shallowRef([]);
|
|
2874
2942
|
vue.watch(
|
|
2875
2943
|
[() => props.config, () => props.initValues],
|
|
2876
2944
|
([config], [preConfig]) => {
|
|
2945
|
+
changeRecords.value = [];
|
|
2877
2946
|
if (!lodashEs.isEqual(vue.toRaw(config), vue.toRaw(preConfig))) {
|
|
2878
2947
|
initialized.value = false;
|
|
2879
2948
|
}
|
|
@@ -2896,8 +2965,11 @@
|
|
|
2896
2965
|
},
|
|
2897
2966
|
{ immediate: true }
|
|
2898
2967
|
);
|
|
2899
|
-
const changeHandler = () => {
|
|
2900
|
-
|
|
2968
|
+
const changeHandler = (v, eventData) => {
|
|
2969
|
+
if (eventData.changeRecords?.length) {
|
|
2970
|
+
changeRecords.value.push(...eventData.changeRecords);
|
|
2971
|
+
}
|
|
2972
|
+
emit("change", values.value, eventData);
|
|
2901
2973
|
};
|
|
2902
2974
|
const submitHandler = (e) => {
|
|
2903
2975
|
if (props.preventSubmitDefault) {
|
|
@@ -2909,8 +2981,12 @@
|
|
|
2909
2981
|
lastValuesProcessed,
|
|
2910
2982
|
formState,
|
|
2911
2983
|
initialized,
|
|
2984
|
+
changeRecords,
|
|
2912
2985
|
changeHandler,
|
|
2913
|
-
resetForm: () =>
|
|
2986
|
+
resetForm: () => {
|
|
2987
|
+
tMagicForm.value?.resetFields();
|
|
2988
|
+
changeRecords.value = [];
|
|
2989
|
+
},
|
|
2914
2990
|
submitForm: async (native) => {
|
|
2915
2991
|
try {
|
|
2916
2992
|
await tMagicForm.value?.validate();
|
|
@@ -3019,7 +3095,7 @@
|
|
|
3019
3095
|
const save = async () => {
|
|
3020
3096
|
try {
|
|
3021
3097
|
const values = await form.value?.submitForm();
|
|
3022
|
-
emit("submit", values);
|
|
3098
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
3023
3099
|
} catch (e) {
|
|
3024
3100
|
emit("error", e);
|
|
3025
3101
|
}
|
|
@@ -3030,8 +3106,8 @@
|
|
|
3030
3106
|
const nextStep = () => {
|
|
3031
3107
|
stepActive.value += 1;
|
|
3032
3108
|
};
|
|
3033
|
-
const changeHandler = (value) => {
|
|
3034
|
-
emit("change", value);
|
|
3109
|
+
const changeHandler = (value, eventData) => {
|
|
3110
|
+
emit("change", value, eventData);
|
|
3035
3111
|
};
|
|
3036
3112
|
const show = () => {
|
|
3037
3113
|
dialogVisible.value = true;
|
|
@@ -3880,7 +3956,7 @@
|
|
|
3880
3956
|
}
|
|
3881
3957
|
});
|
|
3882
3958
|
|
|
3883
|
-
const _hoisted_1$1 = {
|
|
3959
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3884
3960
|
const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3885
3961
|
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3886
3962
|
...{
|
|
@@ -3925,11 +4001,11 @@
|
|
|
3925
4001
|
emit("change", props.model[props.name].trim() || "");
|
|
3926
4002
|
popoverVisible.value = false;
|
|
3927
4003
|
};
|
|
3928
|
-
const checkWhiteSpace = (value) => {
|
|
4004
|
+
const checkWhiteSpace = lodashEs.debounce((value) => {
|
|
3929
4005
|
if (typeof value === "string" && !props.config.trim) {
|
|
3930
4006
|
popoverVisible.value = value.trim() !== value;
|
|
3931
4007
|
}
|
|
3932
|
-
};
|
|
4008
|
+
}, 300);
|
|
3933
4009
|
const changeHandler = (value) => {
|
|
3934
4010
|
emit("change", value);
|
|
3935
4011
|
};
|
|
@@ -3996,45 +4072,70 @@
|
|
|
3996
4072
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
3997
4073
|
emit("change", props.model[props.name]);
|
|
3998
4074
|
};
|
|
4075
|
+
const popoverEl = vue.ref();
|
|
4076
|
+
const input = vue.ref();
|
|
4077
|
+
const instanceRef = vue.shallowRef();
|
|
4078
|
+
vue.watch(popoverEl, (el) => {
|
|
4079
|
+
destroyPopover();
|
|
4080
|
+
if (!input.value?.$el || !el) return;
|
|
4081
|
+
instanceRef.value = core.createPopper(input.value.$el, el, {
|
|
4082
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
4083
|
+
strategy: "absolute",
|
|
4084
|
+
modifiers: [
|
|
4085
|
+
{
|
|
4086
|
+
name: "offset",
|
|
4087
|
+
options: {
|
|
4088
|
+
offset: [0, 10]
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
]
|
|
4092
|
+
});
|
|
4093
|
+
});
|
|
4094
|
+
const destroyPopover = () => {
|
|
4095
|
+
if (!instanceRef.value) return;
|
|
4096
|
+
instanceRef.value.destroy();
|
|
4097
|
+
instanceRef.value = void 0;
|
|
4098
|
+
};
|
|
3999
4099
|
return (_ctx, _cache) => {
|
|
4000
|
-
return vue.openBlock(), vue.
|
|
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
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4100
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
4101
|
+
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
4102
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4103
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4104
|
+
ref_key: "input",
|
|
4105
|
+
ref: input,
|
|
4106
|
+
clearable: "",
|
|
4107
|
+
size: _ctx.size,
|
|
4108
|
+
placeholder: _ctx.config.placeholder,
|
|
4109
|
+
disabled: _ctx.disabled,
|
|
4110
|
+
onChange: changeHandler,
|
|
4111
|
+
onInput: inputHandler,
|
|
4112
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4113
|
+
}, vue.createSlots({ _: 2 }, [
|
|
4114
|
+
appendConfig.value ? {
|
|
4115
|
+
name: "append",
|
|
4116
|
+
fn: vue.withCtx(() => [
|
|
4117
|
+
appendConfig.value.type === "button" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
4118
|
+
key: 0,
|
|
4119
|
+
style: { "color": "#409eff" },
|
|
4120
|
+
size: _ctx.size,
|
|
4121
|
+
onClick: vue.withModifiers(buttonClickHandler, ["prevent"])
|
|
4122
|
+
}, {
|
|
4123
|
+
default: vue.withCtx(() => [
|
|
4124
|
+
vue.createTextVNode(vue.toDisplayString(appendConfig.value.text), 1)
|
|
4125
|
+
]),
|
|
4126
|
+
_: 1
|
|
4127
|
+
}, 8, ["size"])) : vue.createCommentVNode("", true)
|
|
4128
|
+
]),
|
|
4129
|
+
key: "0"
|
|
4130
|
+
} : void 0
|
|
4131
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4132
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4133
|
+
popoverVisible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4134
|
+
key: 0,
|
|
4135
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4136
|
+
ref_key: "popoverEl",
|
|
4137
|
+
ref: popoverEl
|
|
4138
|
+
}, [
|
|
4038
4139
|
_cache[5] || (_cache[5] = vue.createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1)),
|
|
4039
4140
|
vue.createElementVNode("div", _hoisted_2, [
|
|
4040
4141
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
@@ -4057,11 +4158,14 @@
|
|
|
4057
4158
|
])),
|
|
4058
4159
|
_: 1
|
|
4059
4160
|
})
|
|
4060
|
-
])
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4161
|
+
]),
|
|
4162
|
+
_cache[6] || (_cache[6] = vue.createElementVNode("span", {
|
|
4163
|
+
class: "tmagic-form-text-popper-arrow",
|
|
4164
|
+
"data-popper-arrow": ""
|
|
4165
|
+
}, null, -1))
|
|
4166
|
+
], 512)) : vue.createCommentVNode("", true)
|
|
4167
|
+
]))
|
|
4168
|
+
]);
|
|
4065
4169
|
};
|
|
4066
4170
|
}
|
|
4067
4171
|
});
|
|
@@ -4266,13 +4370,13 @@
|
|
|
4266
4370
|
const submitHandler = async () => {
|
|
4267
4371
|
try {
|
|
4268
4372
|
const values = await form.value?.submitForm();
|
|
4269
|
-
emit("submit", values);
|
|
4373
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4270
4374
|
} catch (e) {
|
|
4271
4375
|
emit("error", e);
|
|
4272
4376
|
}
|
|
4273
4377
|
};
|
|
4274
|
-
const changeHandler = (value) => {
|
|
4275
|
-
emit("change", value);
|
|
4378
|
+
const changeHandler = (value, eventData) => {
|
|
4379
|
+
emit("change", value, eventData);
|
|
4276
4380
|
};
|
|
4277
4381
|
const openHandler = () => {
|
|
4278
4382
|
emit("open");
|
|
@@ -4415,7 +4519,7 @@
|
|
|
4415
4519
|
labelPosition: {},
|
|
4416
4520
|
preventSubmitDefault: { type: Boolean }
|
|
4417
4521
|
},
|
|
4418
|
-
emits: ["
|
|
4522
|
+
emits: ["change", "submit", "error"],
|
|
4419
4523
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4420
4524
|
const props = __props;
|
|
4421
4525
|
const emit = __emit;
|
|
@@ -4441,13 +4545,13 @@
|
|
|
4441
4545
|
const submitHandler = async () => {
|
|
4442
4546
|
try {
|
|
4443
4547
|
const values = await form.value?.submitForm();
|
|
4444
|
-
emit("submit", values);
|
|
4548
|
+
emit("submit", values, { changeRecords: form.value?.changeRecords });
|
|
4445
4549
|
} catch (e) {
|
|
4446
4550
|
emit("error", e);
|
|
4447
4551
|
}
|
|
4448
4552
|
};
|
|
4449
|
-
const changeHandler = (value) => {
|
|
4450
|
-
emit("change", value);
|
|
4553
|
+
const changeHandler = (value, eventData) => {
|
|
4554
|
+
emit("change", value, eventData);
|
|
4451
4555
|
};
|
|
4452
4556
|
const show = () => {
|
|
4453
4557
|
};
|
|
@@ -4521,8 +4625,8 @@
|
|
|
4521
4625
|
const createForm = (config) => config;
|
|
4522
4626
|
const defaultInstallOpt = {};
|
|
4523
4627
|
const index = {
|
|
4524
|
-
install(app, opt) {
|
|
4525
|
-
const option = Object.assign(defaultInstallOpt, opt
|
|
4628
|
+
install(app, opt = {}) {
|
|
4629
|
+
const option = Object.assign(defaultInstallOpt, opt);
|
|
4526
4630
|
app.config.globalProperties.$MAGIC_FORM = option;
|
|
4527
4631
|
setConfig(option);
|
|
4528
4632
|
app.component("m-form", _sfc_main$d);
|