@tmagic/form 1.3.0-beta.2 → 1.3.0-beta.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/tmagic-form.js +107 -99
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +106 -98
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/containers/Table.vue +49 -43
- package/src/fields/Cascader.vue +5 -1
- package/src/schema.ts +5 -6
- package/types/schema.d.ts +5 -6
package/dist/tmagic-form.js
CHANGED
|
@@ -3,7 +3,7 @@ import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp
|
|
|
3
3
|
import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
|
|
4
4
|
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicOptionGroup, TMagicOption, TMagicSelect, TMagicSwitch, TMagicTimePicker, TMagicDrawer } from '@tmagic/design';
|
|
5
5
|
import Sortable from 'sortablejs';
|
|
6
|
-
import {
|
|
6
|
+
import { sleep, asyncLoadJs, datetimeFormatter, getValueByKeyPath, isNumber } from '@tmagic/utils';
|
|
7
7
|
import cloneDeep$1 from 'lodash-es/cloneDeep';
|
|
8
8
|
|
|
9
9
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
@@ -170,8 +170,8 @@ const initValue = async (mForm, { initValues, config }) => {
|
|
|
170
170
|
const _hoisted_1$d = ["innerHTML"];
|
|
171
171
|
const _hoisted_2$7 = ["innerHTML"];
|
|
172
172
|
const _hoisted_3$4 = ["innerHTML"];
|
|
173
|
-
const _hoisted_4$
|
|
174
|
-
const _hoisted_5$
|
|
173
|
+
const _hoisted_4$4 = ["innerHTML"];
|
|
174
|
+
const _hoisted_5$4 = ["innerHTML"];
|
|
175
175
|
const _hoisted_6$1 = ["innerHTML"];
|
|
176
176
|
const _hoisted_7$1 = ["innerHTML"];
|
|
177
177
|
const _hoisted_8$1 = ["innerHTML"];
|
|
@@ -416,7 +416,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
416
416
|
content: withCtx(() => [
|
|
417
417
|
createElementVNode("div", {
|
|
418
418
|
innerHTML: _ctx.config.tip
|
|
419
|
-
}, null, 8, _hoisted_4$
|
|
419
|
+
}, null, 8, _hoisted_4$4)
|
|
420
420
|
]),
|
|
421
421
|
default: withCtx(() => [
|
|
422
422
|
createVNode(unref(TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
|
|
@@ -439,7 +439,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
439
439
|
label: withCtx(() => [
|
|
440
440
|
createElementVNode("span", {
|
|
441
441
|
innerHTML: type.value === "checkbox" ? "" : text.value
|
|
442
|
-
}, null, 8, _hoisted_5$
|
|
442
|
+
}, null, 8, _hoisted_5$4)
|
|
443
443
|
]),
|
|
444
444
|
default: withCtx(() => [
|
|
445
445
|
tooltip.value ? (openBlock(), createBlock(unref(TMagicTooltip), { key: 0 }, {
|
|
@@ -604,8 +604,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
604
604
|
const _hoisted_1$c = ["innerHTML"];
|
|
605
605
|
const _hoisted_2$6 = ["innerHTML"];
|
|
606
606
|
const _hoisted_3$3 = { key: 1 };
|
|
607
|
-
const _hoisted_4$
|
|
608
|
-
const _hoisted_5$
|
|
607
|
+
const _hoisted_4$3 = ["innerHTML"];
|
|
608
|
+
const _hoisted_5$3 = ["innerHTML"];
|
|
609
609
|
const _hoisted_6 = {
|
|
610
610
|
key: 2,
|
|
611
611
|
style: { "display": "flex" }
|
|
@@ -685,12 +685,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
685
685
|
})) : (openBlock(), createElementBlock("legend", _hoisted_3$3, [
|
|
686
686
|
createElementVNode("span", {
|
|
687
687
|
innerHTML: _ctx.config.legend
|
|
688
|
-
}, null, 8, _hoisted_4$
|
|
688
|
+
}, null, 8, _hoisted_4$3),
|
|
689
689
|
_ctx.config.extra ? (openBlock(), createElementBlock("span", {
|
|
690
690
|
key: 0,
|
|
691
691
|
innerHTML: _ctx.config.extra,
|
|
692
692
|
class: "m-form-tip"
|
|
693
|
-
}, null, 8, _hoisted_5$
|
|
693
|
+
}, null, 8, _hoisted_5$3)) : createCommentVNode("", true)
|
|
694
694
|
])),
|
|
695
695
|
_ctx.config.schematic && show.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
696
696
|
createElementVNode("div", _hoisted_7, [
|
|
@@ -895,9 +895,9 @@ const _hoisted_3$2 = {
|
|
|
895
895
|
key: 1,
|
|
896
896
|
class: "el-table__empty-block"
|
|
897
897
|
};
|
|
898
|
-
const _hoisted_4$
|
|
899
|
-
const _hoisted_5$
|
|
900
|
-
_hoisted_4$
|
|
898
|
+
const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
|
|
899
|
+
const _hoisted_5$2 = [
|
|
900
|
+
_hoisted_4$2
|
|
901
901
|
];
|
|
902
902
|
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
903
903
|
...{
|
|
@@ -988,7 +988,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
988
988
|
innerHTML: _ctx.config.extra,
|
|
989
989
|
style: { "color": "rgba(0, 0, 0, 0.45)" }
|
|
990
990
|
}, null, 8, _hoisted_2$4)) : createCommentVNode("", true),
|
|
991
|
-
!_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$2, _hoisted_5$
|
|
991
|
+
!_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$2, _hoisted_5$2)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.model[_ctx.name], (item, index) => {
|
|
992
992
|
return openBlock(), createBlock(_sfc_main$w, {
|
|
993
993
|
key: index,
|
|
994
994
|
model: item,
|
|
@@ -1040,8 +1040,8 @@ const _hoisted_3$1 = {
|
|
|
1040
1040
|
key: 0,
|
|
1041
1041
|
style: { "display": "flex" }
|
|
1042
1042
|
};
|
|
1043
|
-
const _hoisted_4 = { style: { "flex": "1" } };
|
|
1044
|
-
const _hoisted_5 = ["src"];
|
|
1043
|
+
const _hoisted_4$1 = { style: { "flex": "1" } };
|
|
1044
|
+
const _hoisted_5$1 = ["src"];
|
|
1045
1045
|
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
1046
1046
|
...{
|
|
1047
1047
|
name: "MFormPanel"
|
|
@@ -1095,7 +1095,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1095
1095
|
createElementVNode("div", null, [
|
|
1096
1096
|
renderSlot(_ctx.$slots, "default"),
|
|
1097
1097
|
_ctx.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
1098
|
-
createElementVNode("div", _hoisted_4, [
|
|
1098
|
+
createElementVNode("div", _hoisted_4$1, [
|
|
1099
1099
|
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
|
|
1100
1100
|
return openBlock(), createBlock(_sfc_main$y, {
|
|
1101
1101
|
key: item[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
@@ -1115,7 +1115,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1115
1115
|
createElementVNode("img", {
|
|
1116
1116
|
class: "m-form-schematic",
|
|
1117
1117
|
src: _ctx.config.schematic
|
|
1118
|
-
}, null, 8, _hoisted_5)
|
|
1118
|
+
}, null, 8, _hoisted_5$1)
|
|
1119
1119
|
])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(items.value, (item, index) => {
|
|
1120
1120
|
return openBlock(), createBlock(_sfc_main$y, {
|
|
1121
1121
|
key: item[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
@@ -1318,8 +1318,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1318
1318
|
|
|
1319
1319
|
const _hoisted_1$8 = ["innerHTML"];
|
|
1320
1320
|
const _hoisted_2$2 = ["innerHTML"];
|
|
1321
|
-
const _hoisted_3 = {
|
|
1322
|
-
|
|
1321
|
+
const _hoisted_3 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
1322
|
+
const _hoisted_4 = { style: { "display": "flex" } };
|
|
1323
|
+
const _hoisted_5 = {
|
|
1324
|
+
key: 1,
|
|
1323
1325
|
class: "bottom",
|
|
1324
1326
|
style: { "text-align": "right" }
|
|
1325
1327
|
};
|
|
@@ -1358,14 +1360,14 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1358
1360
|
const isFullscreen = ref(false);
|
|
1359
1361
|
const modelName = computed(() => props.name || props.config.name || "");
|
|
1360
1362
|
const data = computed(
|
|
1361
|
-
() => props.config.pagination ? props.model[modelName.value].filter(
|
|
1363
|
+
() => props.config.pagination ? (props.model[modelName.value] || []).filter(
|
|
1362
1364
|
(item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
|
|
1363
1365
|
) : props.model[modelName.value]
|
|
1364
1366
|
);
|
|
1365
1367
|
const lastData = computed(
|
|
1366
|
-
() => props.config.pagination ? props.lastValues[modelName.value].filter(
|
|
1368
|
+
() => props.config.pagination ? (props.lastValues[modelName.value] || []).filter(
|
|
1367
1369
|
(item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
|
|
1368
|
-
) : props.lastValues[modelName.value] ||
|
|
1370
|
+
) : props.lastValues[modelName.value] || []
|
|
1369
1371
|
);
|
|
1370
1372
|
const sortChange = ({ prop, order }) => {
|
|
1371
1373
|
if (order === "ascending") {
|
|
@@ -1466,9 +1468,6 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1466
1468
|
props.model[modelName.value].push(inputs);
|
|
1467
1469
|
emit("change", props.model[modelName.value]);
|
|
1468
1470
|
};
|
|
1469
|
-
if (!globalThis.XLSX) {
|
|
1470
|
-
asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
|
|
1471
|
-
}
|
|
1472
1471
|
onMounted(() => {
|
|
1473
1472
|
if (props.config.defautSort) {
|
|
1474
1473
|
sortChange(props.config.defautSort);
|
|
@@ -1600,10 +1599,13 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1600
1599
|
props.model[modelName.value].splice(0, len);
|
|
1601
1600
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1602
1601
|
};
|
|
1603
|
-
const excelHandler = (file) => {
|
|
1602
|
+
const excelHandler = async (file) => {
|
|
1604
1603
|
if (!file?.raw) {
|
|
1605
1604
|
return false;
|
|
1606
1605
|
}
|
|
1606
|
+
if (!globalThis.XLSX) {
|
|
1607
|
+
await asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
|
|
1608
|
+
}
|
|
1607
1609
|
const reader = new FileReader();
|
|
1608
1610
|
reader.onload = () => {
|
|
1609
1611
|
const data2 = reader.result;
|
|
@@ -1838,84 +1840,86 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1838
1840
|
_: 3
|
|
1839
1841
|
}, 8, ["disabled"]),
|
|
1840
1842
|
renderSlot(_ctx.$slots, "default"),
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
type: "primary",
|
|
1872
|
-
onClick: toggleFullscreen
|
|
1873
|
-
}, {
|
|
1874
|
-
default: withCtx(() => [
|
|
1875
|
-
createTextVNode(toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"), 1)
|
|
1876
|
-
]),
|
|
1877
|
-
_: 1
|
|
1878
|
-
}, 8, ["icon"])) : createCommentVNode("", true),
|
|
1879
|
-
importable.value ? (openBlock(), createBlock(unref(TMagicUpload), {
|
|
1880
|
-
key: 4,
|
|
1881
|
-
style: { "display": "inline-block" },
|
|
1882
|
-
ref_key: "excelBtn",
|
|
1883
|
-
ref: excelBtn,
|
|
1884
|
-
action: "/noop",
|
|
1885
|
-
disabled: _ctx.disabled,
|
|
1886
|
-
"on-change": excelHandler,
|
|
1887
|
-
"auto-upload": false
|
|
1888
|
-
}, {
|
|
1889
|
-
default: withCtx(() => [
|
|
1890
|
-
createVNode(unref(TMagicButton), {
|
|
1843
|
+
createElementVNode("div", _hoisted_3, [
|
|
1844
|
+
addable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1845
|
+
key: 0,
|
|
1846
|
+
size: "small",
|
|
1847
|
+
type: "primary",
|
|
1848
|
+
disabled: _ctx.disabled,
|
|
1849
|
+
plain: "",
|
|
1850
|
+
onClick: _cache[2] || (_cache[2] = ($event) => newHandler())
|
|
1851
|
+
}, {
|
|
1852
|
+
default: withCtx(() => [
|
|
1853
|
+
createTextVNode("新增一行")
|
|
1854
|
+
]),
|
|
1855
|
+
_: 1
|
|
1856
|
+
}, 8, ["disabled"])) : createCommentVNode("", true),
|
|
1857
|
+
createElementVNode("div", _hoisted_4, [
|
|
1858
|
+
_ctx.enableToggleMode && _ctx.config.enableToggleMode !== false && !isFullscreen.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1859
|
+
key: 0,
|
|
1860
|
+
icon: unref(Grid),
|
|
1861
|
+
size: "small",
|
|
1862
|
+
type: "primary",
|
|
1863
|
+
onClick: toggleMode
|
|
1864
|
+
}, {
|
|
1865
|
+
default: withCtx(() => [
|
|
1866
|
+
createTextVNode("展开配置")
|
|
1867
|
+
]),
|
|
1868
|
+
_: 1
|
|
1869
|
+
}, 8, ["icon"])) : createCommentVNode("", true),
|
|
1870
|
+
_ctx.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1871
|
+
key: 1,
|
|
1872
|
+
icon: unref(FullScreen),
|
|
1891
1873
|
size: "small",
|
|
1892
|
-
type: "
|
|
1874
|
+
type: "primary",
|
|
1875
|
+
onClick: toggleFullscreen
|
|
1876
|
+
}, {
|
|
1877
|
+
default: withCtx(() => [
|
|
1878
|
+
createTextVNode(toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"), 1)
|
|
1879
|
+
]),
|
|
1880
|
+
_: 1
|
|
1881
|
+
}, 8, ["icon"])) : createCommentVNode("", true),
|
|
1882
|
+
importable.value ? (openBlock(), createBlock(unref(TMagicUpload), {
|
|
1883
|
+
key: 2,
|
|
1884
|
+
style: { "display": "inline-block" },
|
|
1885
|
+
ref_key: "excelBtn",
|
|
1886
|
+
ref: excelBtn,
|
|
1887
|
+
action: "/noop",
|
|
1893
1888
|
disabled: _ctx.disabled,
|
|
1894
|
-
|
|
1889
|
+
"on-change": excelHandler,
|
|
1890
|
+
"auto-upload": false
|
|
1895
1891
|
}, {
|
|
1896
1892
|
default: withCtx(() => [
|
|
1897
|
-
|
|
1893
|
+
createVNode(unref(TMagicButton), {
|
|
1894
|
+
size: "small",
|
|
1895
|
+
type: "success",
|
|
1896
|
+
disabled: _ctx.disabled,
|
|
1897
|
+
plain: ""
|
|
1898
|
+
}, {
|
|
1899
|
+
default: withCtx(() => [
|
|
1900
|
+
createTextVNode("导入EXCEL")
|
|
1901
|
+
]),
|
|
1902
|
+
_: 1
|
|
1903
|
+
}, 8, ["disabled"])
|
|
1898
1904
|
]),
|
|
1899
1905
|
_: 1
|
|
1900
|
-
}, 8, ["disabled"])
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
}, 8, ["disabled"])) : createCommentVNode("", true),
|
|
1918
|
-
_ctx.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
1906
|
+
}, 8, ["disabled"])) : createCommentVNode("", true),
|
|
1907
|
+
importable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1908
|
+
key: 3,
|
|
1909
|
+
size: "small",
|
|
1910
|
+
type: "warning",
|
|
1911
|
+
disabled: _ctx.disabled,
|
|
1912
|
+
plain: "",
|
|
1913
|
+
onClick: _cache[3] || (_cache[3] = ($event) => clearHandler())
|
|
1914
|
+
}, {
|
|
1915
|
+
default: withCtx(() => [
|
|
1916
|
+
createTextVNode("清空")
|
|
1917
|
+
]),
|
|
1918
|
+
_: 1
|
|
1919
|
+
}, 8, ["disabled"])) : createCommentVNode("", true)
|
|
1920
|
+
])
|
|
1921
|
+
]),
|
|
1922
|
+
_ctx.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1919
1923
|
createVNode(unref(TMagicPagination), {
|
|
1920
1924
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
1921
1925
|
"hide-on-single-page": _ctx.model[modelName.value].length < pagesize.value,
|
|
@@ -2219,7 +2223,11 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
2219
2223
|
placeholder: _ctx.config.placeholder,
|
|
2220
2224
|
disabled: _ctx.disabled,
|
|
2221
2225
|
options: unref(options),
|
|
2222
|
-
props: {
|
|
2226
|
+
props: {
|
|
2227
|
+
multiple: _ctx.config.multiple ?? false,
|
|
2228
|
+
emitPath: _ctx.config.emitPath ?? true,
|
|
2229
|
+
checkStrictly: _ctx.config.checkStrictly ?? false
|
|
2230
|
+
},
|
|
2223
2231
|
onChange: changeHandler
|
|
2224
2232
|
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "props"]);
|
|
2225
2233
|
};
|