@tmagic/form 1.5.2 → 1.5.3
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 +0 -4
- package/dist/tmagic-form.js +234 -82
- package/dist/tmagic-form.umd.cjs +231 -79
- package/package.json +3 -3
- package/src/containers/Container.vue +8 -10
- package/src/containers/GroupList.vue +9 -1
- package/src/containers/GroupListItem.vue +91 -17
- package/src/containers/Table.vue +40 -7
- package/src/fields/RadioGroup.vue +29 -5
- package/src/schema.ts +6 -0
- package/src/theme/table.scss +0 -5
- package/types/index.d.ts +6 -0
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -182,9 +182,9 @@
|
|
|
182
182
|
return defaultValue;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
const _hoisted_1$
|
|
185
|
+
const _hoisted_1$e = ["data-tmagic-id", "data-tmagic-form-item-prop"];
|
|
186
186
|
const _hoisted_2$7 = ["innerHTML", "title"];
|
|
187
|
-
const _hoisted_3$
|
|
187
|
+
const _hoisted_3$5 = ["innerHTML"];
|
|
188
188
|
const _hoisted_4$3 = ["innerHTML"];
|
|
189
189
|
const _hoisted_5$3 = ["innerHTML"];
|
|
190
190
|
const _hoisted_6$2 = ["innerHTML", "title"];
|
|
@@ -245,7 +245,12 @@
|
|
|
245
245
|
}
|
|
246
246
|
return `${n}`;
|
|
247
247
|
});
|
|
248
|
-
const tagName = vue.computed(() =>
|
|
248
|
+
const tagName = vue.computed(() => {
|
|
249
|
+
if (type.value === "component" && props.config.component) {
|
|
250
|
+
return props.config.component;
|
|
251
|
+
}
|
|
252
|
+
return `m-${items.value ? "form" : "fields"}-${type.value}`;
|
|
253
|
+
});
|
|
249
254
|
const disabled = vue.computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
250
255
|
const text = vue.computed(() => filterFunction(mForm, props.config.text, props));
|
|
251
256
|
const tooltip = vue.computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
@@ -413,7 +418,7 @@
|
|
|
413
418
|
default: vue.withCtx(() => [
|
|
414
419
|
tooltip.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
|
|
415
420
|
content: vue.withCtx(() => [
|
|
416
|
-
vue.createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$
|
|
421
|
+
vue.createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$5)
|
|
417
422
|
]),
|
|
418
423
|
default: vue.withCtx(() => [
|
|
419
424
|
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
|
|
@@ -641,14 +646,14 @@
|
|
|
641
646
|
_: 1
|
|
642
647
|
})
|
|
643
648
|
])) : vue.createCommentVNode("", true)
|
|
644
|
-
], 14, _hoisted_1$
|
|
649
|
+
], 14, _hoisted_1$e)) : vue.createCommentVNode("", true);
|
|
645
650
|
};
|
|
646
651
|
}
|
|
647
652
|
});
|
|
648
653
|
|
|
649
|
-
const _hoisted_1$
|
|
654
|
+
const _hoisted_1$d = ["innerHTML"];
|
|
650
655
|
const _hoisted_2$6 = ["innerHTML"];
|
|
651
|
-
const _hoisted_3$
|
|
656
|
+
const _hoisted_3$4 = { key: 1 };
|
|
652
657
|
const _hoisted_4$2 = ["innerHTML"];
|
|
653
658
|
const _hoisted_5$2 = ["innerHTML"];
|
|
654
659
|
const _hoisted_6$1 = {
|
|
@@ -718,7 +723,7 @@
|
|
|
718
723
|
default: vue.withCtx(() => [
|
|
719
724
|
vue.createElementVNode("span", {
|
|
720
725
|
innerHTML: _ctx.config.legend
|
|
721
|
-
}, null, 8, _hoisted_1$
|
|
726
|
+
}, null, 8, _hoisted_1$d),
|
|
722
727
|
_ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
723
728
|
key: 0,
|
|
724
729
|
innerHTML: _ctx.config.extra,
|
|
@@ -729,7 +734,7 @@
|
|
|
729
734
|
}, 8, ["modelValue", "prop"])
|
|
730
735
|
]),
|
|
731
736
|
_: 1
|
|
732
|
-
})) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$
|
|
737
|
+
})) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$4, [
|
|
733
738
|
vue.createElementVNode("span", {
|
|
734
739
|
innerHTML: _ctx.config.legend
|
|
735
740
|
}, null, 8, _hoisted_4$2),
|
|
@@ -783,8 +788,9 @@
|
|
|
783
788
|
}
|
|
784
789
|
});
|
|
785
790
|
|
|
786
|
-
const _hoisted_1$
|
|
787
|
-
const _hoisted_2$5 =
|
|
791
|
+
const _hoisted_1$c = { class: "m-fields-group-list-item" };
|
|
792
|
+
const _hoisted_2$5 = { style: { "text-align": "right", "margin-top": "20px" } };
|
|
793
|
+
const _hoisted_3$3 = ["innerHTML"];
|
|
788
794
|
const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
|
|
789
795
|
...{
|
|
790
796
|
name: "MFormGroupListItem"
|
|
@@ -802,7 +808,7 @@
|
|
|
802
808
|
index: {},
|
|
803
809
|
disabled: { type: Boolean }
|
|
804
810
|
},
|
|
805
|
-
emits: ["swap-item", "remove-item", "change", "addDiffCount"],
|
|
811
|
+
emits: ["swap-item", "remove-item", "change", "addDiffCount", "copy-item"],
|
|
806
812
|
setup(__props, { emit: __emit }) {
|
|
807
813
|
const props = __props;
|
|
808
814
|
const emit = __emit;
|
|
@@ -834,25 +840,35 @@
|
|
|
834
840
|
const expandHandler = () => {
|
|
835
841
|
expand.value = !expand.value;
|
|
836
842
|
};
|
|
837
|
-
const showDelete = (
|
|
843
|
+
const showDelete = vue.computed(() => {
|
|
838
844
|
const deleteFunc = props.config.delete;
|
|
839
845
|
if (deleteFunc && typeof deleteFunc === "function") {
|
|
840
|
-
return deleteFunc(props.model, index, mForm?.values);
|
|
846
|
+
return deleteFunc(props.model, props.index, mForm?.values);
|
|
841
847
|
}
|
|
842
848
|
return true;
|
|
843
|
-
};
|
|
849
|
+
});
|
|
844
850
|
const changeOrder = (offset = 0) => emit("swap-item", props.index, props.index + offset);
|
|
845
|
-
const movable = () => {
|
|
851
|
+
const movable = vue.computed(() => {
|
|
846
852
|
const { movable: movable2 } = props.config;
|
|
847
853
|
if (movable2 === void 0) return true;
|
|
848
854
|
if (typeof movable2 === "function") {
|
|
849
855
|
return movable2(mForm, props.index || 0, props.model, props.groupModel);
|
|
850
856
|
}
|
|
851
857
|
return movable2;
|
|
852
|
-
};
|
|
858
|
+
});
|
|
859
|
+
const copyable = vue.computed(() => filterFunction(mForm, props.config.copyable, props));
|
|
853
860
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
861
|
+
const copyHandler = () => {
|
|
862
|
+
emit("copy-item", props.index);
|
|
863
|
+
};
|
|
864
|
+
const moveSpecifyLocationVisible = vue.ref(false);
|
|
865
|
+
const moveSpecifyLocationIndex = vue.ref(1);
|
|
866
|
+
const moveSpecifyLocationHandler = () => {
|
|
867
|
+
moveSpecifyLocationVisible.value = false;
|
|
868
|
+
emit("swap-item", props.index, moveSpecifyLocationIndex.value - 1);
|
|
869
|
+
};
|
|
854
870
|
return (_ctx, _cache) => {
|
|
855
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
871
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
|
|
856
872
|
vue.createElementVNode("div", null, [
|
|
857
873
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
858
874
|
link: "",
|
|
@@ -871,59 +887,126 @@
|
|
|
871
887
|
_: 1
|
|
872
888
|
}, 8, ["disabled"]),
|
|
873
889
|
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
874
|
-
|
|
890
|
+
type: "danger",
|
|
891
|
+
size: "small",
|
|
875
892
|
link: "",
|
|
876
893
|
icon: vue.unref(iconsVue.Delete),
|
|
877
894
|
disabled: _ctx.disabled,
|
|
878
895
|
onClick: removeHandler
|
|
879
896
|
}, null, 8, ["icon", "disabled"]), [
|
|
880
|
-
[vue.vShow, showDelete
|
|
897
|
+
[vue.vShow, showDelete.value]
|
|
881
898
|
]),
|
|
882
|
-
|
|
899
|
+
copyable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
900
|
+
key: 0,
|
|
901
|
+
link: "",
|
|
902
|
+
size: "small",
|
|
903
|
+
type: "primary",
|
|
904
|
+
icon: vue.unref(iconsVue.DocumentCopy),
|
|
905
|
+
disabled: _ctx.disabled,
|
|
906
|
+
onClick: copyHandler
|
|
907
|
+
}, {
|
|
908
|
+
default: vue.withCtx(() => _cache[6] || (_cache[6] = [
|
|
909
|
+
vue.createTextVNode("复制")
|
|
910
|
+
])),
|
|
911
|
+
_: 1
|
|
912
|
+
}, 8, ["icon", "disabled"])) : vue.createCommentVNode("", true),
|
|
913
|
+
movable.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
|
|
883
914
|
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
884
915
|
link: "",
|
|
885
|
-
disabled: _ctx.disabled,
|
|
886
916
|
size: "small",
|
|
917
|
+
disabled: _ctx.disabled,
|
|
918
|
+
icon: vue.unref(iconsVue.CaretTop),
|
|
887
919
|
onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
|
|
888
920
|
}, {
|
|
889
|
-
default: vue.withCtx(() => [
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
default: vue.withCtx(() => [
|
|
893
|
-
vue.createVNode(vue.unref(iconsVue.CaretTop))
|
|
894
|
-
]),
|
|
895
|
-
_: 1
|
|
896
|
-
})
|
|
897
|
-
]),
|
|
921
|
+
default: vue.withCtx(() => _cache[7] || (_cache[7] = [
|
|
922
|
+
vue.createTextVNode("上移")
|
|
923
|
+
])),
|
|
898
924
|
_: 1
|
|
899
|
-
}, 8, ["disabled"]), [
|
|
925
|
+
}, 8, ["disabled", "icon"]), [
|
|
900
926
|
[vue.vShow, _ctx.index !== 0]
|
|
901
927
|
]),
|
|
902
928
|
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
903
|
-
disabled: _ctx.disabled,
|
|
904
929
|
link: "",
|
|
905
930
|
size: "small",
|
|
931
|
+
disabled: _ctx.disabled,
|
|
932
|
+
icon: vue.unref(iconsVue.CaretBottom),
|
|
906
933
|
onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
|
|
907
934
|
}, {
|
|
908
|
-
default: vue.withCtx(() => [
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
default: vue.withCtx(() => [
|
|
912
|
-
vue.createVNode(vue.unref(iconsVue.CaretBottom))
|
|
913
|
-
]),
|
|
914
|
-
_: 1
|
|
915
|
-
})
|
|
916
|
-
]),
|
|
935
|
+
default: vue.withCtx(() => _cache[8] || (_cache[8] = [
|
|
936
|
+
vue.createTextVNode("下移")
|
|
937
|
+
])),
|
|
917
938
|
_: 1
|
|
918
|
-
}, 8, ["disabled"]), [
|
|
939
|
+
}, 8, ["disabled", "icon"]), [
|
|
919
940
|
[vue.vShow, _ctx.index !== length.value - 1]
|
|
920
941
|
])
|
|
921
942
|
], 64)) : vue.createCommentVNode("", true),
|
|
943
|
+
_ctx.config.moveSpecifyLocation ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
|
|
944
|
+
key: 2,
|
|
945
|
+
trigger: "click",
|
|
946
|
+
placement: "top",
|
|
947
|
+
width: "200",
|
|
948
|
+
visible: moveSpecifyLocationVisible.value
|
|
949
|
+
}, {
|
|
950
|
+
reference: vue.withCtx(() => [
|
|
951
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
952
|
+
link: "",
|
|
953
|
+
size: "small",
|
|
954
|
+
type: "primary",
|
|
955
|
+
icon: vue.unref(iconsVue.Position),
|
|
956
|
+
disabled: _ctx.disabled,
|
|
957
|
+
onClick: _cache[2] || (_cache[2] = ($event) => moveSpecifyLocationVisible.value = true)
|
|
958
|
+
}, {
|
|
959
|
+
default: vue.withCtx(() => _cache[9] || (_cache[9] = [
|
|
960
|
+
vue.createTextVNode("移动至")
|
|
961
|
+
])),
|
|
962
|
+
_: 1
|
|
963
|
+
}, 8, ["icon", "disabled"])
|
|
964
|
+
]),
|
|
965
|
+
default: vue.withCtx(() => [
|
|
966
|
+
vue.createElementVNode("div", null, [
|
|
967
|
+
vue.createElementVNode("div", null, [
|
|
968
|
+
_cache[10] || (_cache[10] = vue.createTextVNode(" 第")),
|
|
969
|
+
vue.createVNode(vue.unref(design.TMagicInputNumber), {
|
|
970
|
+
style: { "margin": "0 5px" },
|
|
971
|
+
modelValue: moveSpecifyLocationIndex.value,
|
|
972
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => moveSpecifyLocationIndex.value = $event),
|
|
973
|
+
size: "small",
|
|
974
|
+
min: 1,
|
|
975
|
+
disabled: _ctx.disabled
|
|
976
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
977
|
+
_cache[11] || (_cache[11] = vue.createTextVNode("行 "))
|
|
978
|
+
]),
|
|
979
|
+
vue.createElementVNode("div", _hoisted_2$5, [
|
|
980
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
981
|
+
size: "small",
|
|
982
|
+
text: "",
|
|
983
|
+
onClick: _cache[4] || (_cache[4] = ($event) => moveSpecifyLocationVisible.value = false)
|
|
984
|
+
}, {
|
|
985
|
+
default: vue.withCtx(() => _cache[12] || (_cache[12] = [
|
|
986
|
+
vue.createTextVNode("取消")
|
|
987
|
+
])),
|
|
988
|
+
_: 1
|
|
989
|
+
}),
|
|
990
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
991
|
+
size: "small",
|
|
992
|
+
type: "primary",
|
|
993
|
+
onClick: moveSpecifyLocationHandler
|
|
994
|
+
}, {
|
|
995
|
+
default: vue.withCtx(() => _cache[13] || (_cache[13] = [
|
|
996
|
+
vue.createTextVNode("确认")
|
|
997
|
+
])),
|
|
998
|
+
_: 1
|
|
999
|
+
})
|
|
1000
|
+
])
|
|
1001
|
+
])
|
|
1002
|
+
]),
|
|
1003
|
+
_: 1
|
|
1004
|
+
}, 8, ["visible"])) : vue.createCommentVNode("", true),
|
|
922
1005
|
itemExtra.value ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
923
|
-
key:
|
|
1006
|
+
key: 3,
|
|
924
1007
|
innerHTML: itemExtra.value,
|
|
925
1008
|
class: "m-form-tip"
|
|
926
|
-
}, null, 8,
|
|
1009
|
+
}, null, 8, _hoisted_3$3)) : vue.createCommentVNode("", true)
|
|
927
1010
|
]),
|
|
928
1011
|
expand.value ? (vue.openBlock(), vue.createBlock(_sfc_main$x, {
|
|
929
1012
|
key: 0,
|
|
@@ -936,14 +1019,14 @@
|
|
|
936
1019
|
size: _ctx.size,
|
|
937
1020
|
disabled: _ctx.disabled,
|
|
938
1021
|
onChange: changeHandler,
|
|
939
|
-
onAddDiffCount: _cache[
|
|
1022
|
+
onAddDiffCount: _cache[5] || (_cache[5] = ($event) => onAddDiffCount())
|
|
940
1023
|
}, null, 8, ["config", "model", "lastValues", "is-compare", "labelWidth", "prop", "size", "disabled"])) : vue.createCommentVNode("", true)
|
|
941
1024
|
]);
|
|
942
1025
|
};
|
|
943
1026
|
}
|
|
944
1027
|
});
|
|
945
1028
|
|
|
946
|
-
const _hoisted_1$
|
|
1029
|
+
const _hoisted_1$b = { class: "m-fields-group-list" };
|
|
947
1030
|
const _hoisted_2$4 = ["innerHTML"];
|
|
948
1031
|
const _hoisted_3$2 = {
|
|
949
1032
|
key: 1,
|
|
@@ -1017,10 +1100,14 @@
|
|
|
1017
1100
|
props.model[props.name].splice(index, 1);
|
|
1018
1101
|
emit("change", props.model[props.name]);
|
|
1019
1102
|
};
|
|
1103
|
+
const copyHandler = (index) => {
|
|
1104
|
+
props.model[props.name].push(lodashEs.cloneDeep(props.model[props.name][index]));
|
|
1105
|
+
};
|
|
1020
1106
|
const swapHandler = (idx1, idx2) => {
|
|
1021
1107
|
if (!props.name) return false;
|
|
1108
|
+
const { length } = props.model[props.name];
|
|
1022
1109
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
1023
|
-
props.model[props.name].splice(idx2, 0, currRow);
|
|
1110
|
+
props.model[props.name].splice(Math.min(Math.max(idx2, 0), length - 1), 0, currRow);
|
|
1024
1111
|
emit("change", props.model[props.name]);
|
|
1025
1112
|
};
|
|
1026
1113
|
const toggleMode = () => {
|
|
@@ -1035,7 +1122,7 @@
|
|
|
1035
1122
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
1036
1123
|
const getLastValues = (item, index) => item?.[index] || {};
|
|
1037
1124
|
return (_ctx, _cache) => {
|
|
1038
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1125
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
1039
1126
|
_ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
1040
1127
|
key: 0,
|
|
1041
1128
|
innerHTML: _ctx.config.extra,
|
|
@@ -1057,6 +1144,7 @@
|
|
|
1057
1144
|
disabled: _ctx.disabled,
|
|
1058
1145
|
"group-model": _ctx.model[_ctx.name],
|
|
1059
1146
|
onRemoveItem: removeHandler,
|
|
1147
|
+
onCopyItem: copyHandler,
|
|
1060
1148
|
onSwapItem: swapHandler,
|
|
1061
1149
|
onChange: changeHandler,
|
|
1062
1150
|
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
@@ -1090,7 +1178,7 @@
|
|
|
1090
1178
|
}
|
|
1091
1179
|
});
|
|
1092
1180
|
|
|
1093
|
-
const _hoisted_1$
|
|
1181
|
+
const _hoisted_1$a = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
|
|
1094
1182
|
const _hoisted_2$3 = ["innerHTML"];
|
|
1095
1183
|
const _hoisted_3$1 = {
|
|
1096
1184
|
key: 0,
|
|
@@ -1133,7 +1221,7 @@
|
|
|
1133
1221
|
"body-style": { display: expand.value ? "block" : "none" }
|
|
1134
1222
|
}, {
|
|
1135
1223
|
header: vue.withCtx(() => [
|
|
1136
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
1224
|
+
vue.createElementVNode("div", _hoisted_1$a, [
|
|
1137
1225
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
1138
1226
|
style: { "padding": "0" },
|
|
1139
1227
|
link: "",
|
|
@@ -1381,7 +1469,7 @@
|
|
|
1381
1469
|
}
|
|
1382
1470
|
});
|
|
1383
1471
|
|
|
1384
|
-
const _hoisted_1$
|
|
1472
|
+
const _hoisted_1$9 = { class: "m-fields-table-wrap" };
|
|
1385
1473
|
const _hoisted_2$2 = ["innerHTML"];
|
|
1386
1474
|
const _hoisted_3 = ["innerHTML"];
|
|
1387
1475
|
const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
@@ -1666,6 +1754,21 @@
|
|
|
1666
1754
|
}
|
|
1667
1755
|
return true;
|
|
1668
1756
|
};
|
|
1757
|
+
const copyable = (index) => {
|
|
1758
|
+
const copyableFunc = props.config.copyable;
|
|
1759
|
+
if (copyableFunc && typeof copyableFunc === "function") {
|
|
1760
|
+
return copyableFunc(mForm, {
|
|
1761
|
+
values: mForm?.initValues || {},
|
|
1762
|
+
model: props.model,
|
|
1763
|
+
parent: mForm?.parentValues || {},
|
|
1764
|
+
formValue: mForm?.values || props.model,
|
|
1765
|
+
prop: props.prop,
|
|
1766
|
+
config: props.config,
|
|
1767
|
+
index
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
return true;
|
|
1771
|
+
};
|
|
1669
1772
|
const clearHandler = () => {
|
|
1670
1773
|
const len = props.model[modelName.value].length;
|
|
1671
1774
|
props.model[modelName.value].splice(0, len);
|
|
@@ -1703,6 +1806,9 @@
|
|
|
1703
1806
|
const handleCurrentChange = (val) => {
|
|
1704
1807
|
pagecontext.value = val - 1;
|
|
1705
1808
|
};
|
|
1809
|
+
const copyHandler = (index) => {
|
|
1810
|
+
props.model[modelName.value].push(lodashEs.cloneDeep(props.model[modelName.value][index]));
|
|
1811
|
+
};
|
|
1706
1812
|
const toggleMode = () => {
|
|
1707
1813
|
const calcLabelWidth = (label) => {
|
|
1708
1814
|
if (!label) return "0px";
|
|
@@ -1747,7 +1853,7 @@
|
|
|
1747
1853
|
toggleRowSelection
|
|
1748
1854
|
});
|
|
1749
1855
|
return (_ctx, _cache) => {
|
|
1750
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1856
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
1751
1857
|
(vue.openBlock(), vue.createBlock(vue.Teleport, {
|
|
1752
1858
|
to: "body",
|
|
1753
1859
|
disabled: !isFullscreen.value
|
|
@@ -1799,23 +1905,32 @@
|
|
|
1799
1905
|
})) : vue.createCommentVNode("", true),
|
|
1800
1906
|
vue.createVNode(vue.unref(design.TMagicTableColumn), {
|
|
1801
1907
|
label: "操作",
|
|
1802
|
-
width: _ctx.config.operateColWidth ||
|
|
1908
|
+
width: _ctx.config.operateColWidth || 100,
|
|
1803
1909
|
align: "center",
|
|
1804
1910
|
fixed: _ctx.config.fixed === false ? void 0 : "left"
|
|
1805
1911
|
}, {
|
|
1806
1912
|
default: vue.withCtx((scope) => [
|
|
1807
1913
|
vue.renderSlot(_ctx.$slots, "operateCol", { scope }),
|
|
1808
|
-
vue.withDirectives(vue.createVNode(vue.unref(design.
|
|
1809
|
-
|
|
1914
|
+
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
1915
|
+
size: "small",
|
|
1916
|
+
type: "danger",
|
|
1917
|
+
link: "",
|
|
1918
|
+
title: "删除",
|
|
1919
|
+
icon: vue.unref(iconsVue.Delete),
|
|
1810
1920
|
onClick: ($event) => removeHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
|
|
1811
|
-
},
|
|
1812
|
-
default: vue.withCtx(() => [
|
|
1813
|
-
vue.createVNode(vue.unref(iconsVue.Delete))
|
|
1814
|
-
]),
|
|
1815
|
-
_: 2
|
|
1816
|
-
}, 1032, ["onClick"]), [
|
|
1921
|
+
}, null, 8, ["icon", "onClick"]), [
|
|
1817
1922
|
[vue.vShow, showDelete(scope.$index + 1 + pagecontext.value * pagesize.value - 1)]
|
|
1818
|
-
])
|
|
1923
|
+
]),
|
|
1924
|
+
copyable(scope.$index + 1 + pagecontext.value * pagesize.value - 1) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1925
|
+
key: 0,
|
|
1926
|
+
link: "",
|
|
1927
|
+
size: "small",
|
|
1928
|
+
type: "primary",
|
|
1929
|
+
title: "复制",
|
|
1930
|
+
icon: vue.unref(iconsVue.DocumentCopy),
|
|
1931
|
+
disabled: _ctx.disabled,
|
|
1932
|
+
onClick: ($event) => copyHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
|
|
1933
|
+
}, null, 8, ["icon", "disabled", "onClick"])) : vue.createCommentVNode("", true)
|
|
1819
1934
|
]),
|
|
1820
1935
|
_: 3
|
|
1821
1936
|
}, 8, ["width", "fixed"]),
|
|
@@ -2704,7 +2819,7 @@
|
|
|
2704
2819
|
}
|
|
2705
2820
|
});
|
|
2706
2821
|
|
|
2707
|
-
const _hoisted_1$
|
|
2822
|
+
const _hoisted_1$8 = { key: 0 };
|
|
2708
2823
|
const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
2709
2824
|
...{
|
|
2710
2825
|
name: "MFormDisplay"
|
|
@@ -2728,12 +2843,12 @@
|
|
|
2728
2843
|
}
|
|
2729
2844
|
useAddField(props.prop);
|
|
2730
2845
|
return (_ctx, _cache) => {
|
|
2731
|
-
return _ctx.model ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1$
|
|
2846
|
+
return _ctx.model ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1$8, vue.toDisplayString(_ctx.model[_ctx.name]), 1)) : vue.createCommentVNode("", true);
|
|
2732
2847
|
};
|
|
2733
2848
|
}
|
|
2734
2849
|
});
|
|
2735
2850
|
|
|
2736
|
-
const _hoisted_1$
|
|
2851
|
+
const _hoisted_1$7 = { class: "m-fields-dynamic-field" };
|
|
2737
2852
|
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2738
2853
|
...{
|
|
2739
2854
|
name: "MFormDynamicField"
|
|
@@ -2800,7 +2915,7 @@
|
|
|
2800
2915
|
});
|
|
2801
2916
|
};
|
|
2802
2917
|
return (_ctx, _cache) => {
|
|
2803
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2918
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
|
|
2804
2919
|
vue.createVNode(vue.unref(design.TMagicForm), { size: "small" }, {
|
|
2805
2920
|
default: vue.withCtx(() => [
|
|
2806
2921
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(Object.keys(fieldMap.value), (key) => {
|
|
@@ -3034,7 +3149,7 @@
|
|
|
3034
3149
|
}
|
|
3035
3150
|
});
|
|
3036
3151
|
|
|
3037
|
-
const _hoisted_1$
|
|
3152
|
+
const _hoisted_1$6 = { style: { "min-height": "1px" } };
|
|
3038
3153
|
const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
3039
3154
|
...{
|
|
3040
3155
|
name: "MFormDialog"
|
|
@@ -3144,7 +3259,7 @@
|
|
|
3144
3259
|
style: { "text-align": "left" }
|
|
3145
3260
|
}, {
|
|
3146
3261
|
default: vue.withCtx(() => [
|
|
3147
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
3262
|
+
vue.createElementVNode("div", _hoisted_1$6, [
|
|
3148
3263
|
vue.renderSlot(_ctx.$slots, "left")
|
|
3149
3264
|
])
|
|
3150
3265
|
]),
|
|
@@ -3235,7 +3350,7 @@
|
|
|
3235
3350
|
}
|
|
3236
3351
|
});
|
|
3237
3352
|
|
|
3238
|
-
const _hoisted_1$
|
|
3353
|
+
const _hoisted_1$5 = ["href"];
|
|
3239
3354
|
const _hoisted_2$1 = {
|
|
3240
3355
|
key: 2,
|
|
3241
3356
|
class: "m-fields-link"
|
|
@@ -3309,7 +3424,7 @@
|
|
|
3309
3424
|
target: "_blank",
|
|
3310
3425
|
href: href.value,
|
|
3311
3426
|
style: vue.normalizeStyle(_ctx.config.css || {})
|
|
3312
|
-
}, vue.toDisplayString(displayText.value), 13, _hoisted_1$
|
|
3427
|
+
}, vue.toDisplayString(displayText.value), 13, _hoisted_1$5)) : _ctx.config.href && _ctx.disabled ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
3313
3428
|
key: 1,
|
|
3314
3429
|
style: vue.normalizeStyle(_ctx.config.disabledCss || {})
|
|
3315
3430
|
}, vue.toDisplayString(displayText.value), 5)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$1, [
|
|
@@ -3388,7 +3503,7 @@
|
|
|
3388
3503
|
}
|
|
3389
3504
|
});
|
|
3390
3505
|
|
|
3391
|
-
const _hoisted_1$
|
|
3506
|
+
const _hoisted_1$4 = { class: "m-fields-number-range" };
|
|
3392
3507
|
const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
3393
3508
|
...{
|
|
3394
3509
|
name: "MFormNumberRange"
|
|
@@ -3420,7 +3535,7 @@
|
|
|
3420
3535
|
emit("change", [props.model[props.name][0], Number(v)]);
|
|
3421
3536
|
};
|
|
3422
3537
|
return (_ctx, _cache) => {
|
|
3423
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3538
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
|
|
3424
3539
|
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
3425
3540
|
modelValue: _ctx.model[_ctx.name][0],
|
|
3426
3541
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name][0] = $event),
|
|
@@ -3443,6 +3558,7 @@
|
|
|
3443
3558
|
}
|
|
3444
3559
|
});
|
|
3445
3560
|
|
|
3561
|
+
const _hoisted_1$3 = { key: 1 };
|
|
3446
3562
|
const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
3447
3563
|
...{
|
|
3448
3564
|
name: "MFormRadioGroup"
|
|
@@ -3462,10 +3578,15 @@
|
|
|
3462
3578
|
emits: ["change"],
|
|
3463
3579
|
setup(__props, { emit: __emit }) {
|
|
3464
3580
|
const props = __props;
|
|
3581
|
+
const itemComponent = vue.computed(() => props.config.childType === "button" ? design.TMagicRadioButton : design.TMagicRadio);
|
|
3465
3582
|
const emit = __emit;
|
|
3466
3583
|
const changeHandler = (value) => {
|
|
3467
3584
|
emit("change", value);
|
|
3468
3585
|
};
|
|
3586
|
+
const clickHandler = (item) => {
|
|
3587
|
+
props.model[props.name] = props.model[props.name] === item ? "" : item;
|
|
3588
|
+
changeHandler(props.model[props.name]);
|
|
3589
|
+
};
|
|
3469
3590
|
useAddField(props.prop);
|
|
3470
3591
|
return (_ctx, _cache) => {
|
|
3471
3592
|
return _ctx.model ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRadioGroup), {
|
|
@@ -3473,20 +3594,51 @@
|
|
|
3473
3594
|
modelValue: _ctx.model[_ctx.name],
|
|
3474
3595
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
3475
3596
|
size: _ctx.size,
|
|
3476
|
-
disabled: _ctx.disabled
|
|
3477
|
-
onChange: changeHandler
|
|
3597
|
+
disabled: _ctx.disabled
|
|
3478
3598
|
}, {
|
|
3479
3599
|
default: vue.withCtx(() => [
|
|
3480
3600
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.config.options, (option) => {
|
|
3481
|
-
return vue.openBlock(), vue.createBlock(vue.
|
|
3601
|
+
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(itemComponent.value), {
|
|
3482
3602
|
value: option.value,
|
|
3483
|
-
key: `${option.value}
|
|
3603
|
+
key: `${option.value}`,
|
|
3604
|
+
onClick: vue.withModifiers(($event) => clickHandler(option.value), ["prevent"])
|
|
3484
3605
|
}, {
|
|
3485
3606
|
default: vue.withCtx(() => [
|
|
3486
|
-
vue.
|
|
3607
|
+
option.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3608
|
+
key: 0,
|
|
3609
|
+
placement: "top-start",
|
|
3610
|
+
content: option.tooltip
|
|
3611
|
+
}, {
|
|
3612
|
+
default: vue.withCtx(() => [
|
|
3613
|
+
vue.createElementVNode("div", null, [
|
|
3614
|
+
option.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
3615
|
+
key: 0,
|
|
3616
|
+
size: "16"
|
|
3617
|
+
}, {
|
|
3618
|
+
default: vue.withCtx(() => [
|
|
3619
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(option.icon)))
|
|
3620
|
+
]),
|
|
3621
|
+
_: 2
|
|
3622
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
3623
|
+
vue.createElementVNode("span", null, vue.toDisplayString(option.text), 1)
|
|
3624
|
+
])
|
|
3625
|
+
]),
|
|
3626
|
+
_: 2
|
|
3627
|
+
}, 1032, ["content"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
|
|
3628
|
+
option.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
3629
|
+
key: 0,
|
|
3630
|
+
size: "16"
|
|
3631
|
+
}, {
|
|
3632
|
+
default: vue.withCtx(() => [
|
|
3633
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(option.icon)))
|
|
3634
|
+
]),
|
|
3635
|
+
_: 2
|
|
3636
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
3637
|
+
vue.createElementVNode("span", null, vue.toDisplayString(option.text), 1)
|
|
3638
|
+
]))
|
|
3487
3639
|
]),
|
|
3488
3640
|
_: 2
|
|
3489
|
-
}, 1032, ["value"]);
|
|
3641
|
+
}, 1032, ["value", "onClick"]);
|
|
3490
3642
|
}), 128))
|
|
3491
3643
|
]),
|
|
3492
3644
|
_: 1
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.3",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"vue": ">=3.5.0",
|
|
59
59
|
"typescript": "*",
|
|
60
|
-
"@tmagic/design": "1.5.
|
|
61
|
-
"@tmagic/utils": "1.5.
|
|
60
|
+
"@tmagic/design": "1.5.3",
|
|
61
|
+
"@tmagic/utils": "1.5.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"typescript": {
|
|
@@ -229,14 +229,7 @@ import { isEqual } from 'lodash-es';
|
|
|
229
229
|
|
|
230
230
|
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
231
231
|
|
|
232
|
-
import type {
|
|
233
|
-
ChildConfig,
|
|
234
|
-
ContainerChangeEventData,
|
|
235
|
-
ContainerCommonConfig,
|
|
236
|
-
FormState,
|
|
237
|
-
FormValue,
|
|
238
|
-
TypeFunction,
|
|
239
|
-
} from '../schema';
|
|
232
|
+
import type { ChildConfig, ContainerChangeEventData, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
240
233
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
241
234
|
|
|
242
235
|
defineOptions({
|
|
@@ -306,7 +299,12 @@ const itemProp = computed(() => {
|
|
|
306
299
|
return `${n}`;
|
|
307
300
|
});
|
|
308
301
|
|
|
309
|
-
const tagName = computed(() =>
|
|
302
|
+
const tagName = computed(() => {
|
|
303
|
+
if (type.value === 'component' && props.config.component) {
|
|
304
|
+
return props.config.component;
|
|
305
|
+
}
|
|
306
|
+
return `m-${items.value ? 'form' : 'fields'}-${type.value}`;
|
|
307
|
+
});
|
|
310
308
|
|
|
311
309
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
312
310
|
|
|
@@ -320,7 +318,7 @@ const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
|
320
318
|
|
|
321
319
|
const type = computed((): string => {
|
|
322
320
|
let { type } = props.config;
|
|
323
|
-
type = type &&
|
|
321
|
+
type = type && filterFunction<string>(mForm, type, props);
|
|
324
322
|
if (type === 'form') return '';
|
|
325
323
|
if (type === 'container') return '';
|
|
326
324
|
return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
|