@tmagic/form 1.3.0-beta.2 → 1.3.0-beta.4

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.
@@ -168,8 +168,8 @@
168
168
  const _hoisted_1$d = ["innerHTML"];
169
169
  const _hoisted_2$7 = ["innerHTML"];
170
170
  const _hoisted_3$4 = ["innerHTML"];
171
- const _hoisted_4$3 = ["innerHTML"];
172
- const _hoisted_5$3 = ["innerHTML"];
171
+ const _hoisted_4$4 = ["innerHTML"];
172
+ const _hoisted_5$4 = ["innerHTML"];
173
173
  const _hoisted_6$1 = ["innerHTML"];
174
174
  const _hoisted_7$1 = ["innerHTML"];
175
175
  const _hoisted_8$1 = ["innerHTML"];
@@ -414,7 +414,7 @@
414
414
  content: vue.withCtx(() => [
415
415
  vue.createElementVNode("div", {
416
416
  innerHTML: _ctx.config.tip
417
- }, null, 8, _hoisted_4$3)
417
+ }, null, 8, _hoisted_4$4)
418
418
  ]),
419
419
  default: vue.withCtx(() => [
420
420
  vue.createVNode(vue.unref(design.TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -437,7 +437,7 @@
437
437
  label: vue.withCtx(() => [
438
438
  vue.createElementVNode("span", {
439
439
  innerHTML: type.value === "checkbox" ? "" : text.value
440
- }, null, 8, _hoisted_5$3)
440
+ }, null, 8, _hoisted_5$4)
441
441
  ]),
442
442
  default: vue.withCtx(() => [
443
443
  tooltip.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
@@ -602,8 +602,8 @@
602
602
  const _hoisted_1$c = ["innerHTML"];
603
603
  const _hoisted_2$6 = ["innerHTML"];
604
604
  const _hoisted_3$3 = { key: 1 };
605
- const _hoisted_4$2 = ["innerHTML"];
606
- const _hoisted_5$2 = ["innerHTML"];
605
+ const _hoisted_4$3 = ["innerHTML"];
606
+ const _hoisted_5$3 = ["innerHTML"];
607
607
  const _hoisted_6 = {
608
608
  key: 2,
609
609
  style: { "display": "flex" }
@@ -683,12 +683,12 @@
683
683
  })) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$3, [
684
684
  vue.createElementVNode("span", {
685
685
  innerHTML: _ctx.config.legend
686
- }, null, 8, _hoisted_4$2),
686
+ }, null, 8, _hoisted_4$3),
687
687
  _ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
688
688
  key: 0,
689
689
  innerHTML: _ctx.config.extra,
690
690
  class: "m-form-tip"
691
- }, null, 8, _hoisted_5$2)) : vue.createCommentVNode("", true)
691
+ }, null, 8, _hoisted_5$3)) : vue.createCommentVNode("", true)
692
692
  ])),
693
693
  _ctx.config.schematic && show.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, [
694
694
  vue.createElementVNode("div", _hoisted_7, [
@@ -893,9 +893,9 @@
893
893
  key: 1,
894
894
  class: "el-table__empty-block"
895
895
  };
896
- const _hoisted_4$1 = /* @__PURE__ */ vue.createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
897
- const _hoisted_5$1 = [
898
- _hoisted_4$1
896
+ const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
897
+ const _hoisted_5$2 = [
898
+ _hoisted_4$2
899
899
  ];
900
900
  const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
901
901
  ...{
@@ -986,7 +986,7 @@
986
986
  innerHTML: _ctx.config.extra,
987
987
  style: { "color": "rgba(0, 0, 0, 0.45)" }
988
988
  }, null, 8, _hoisted_2$4)) : vue.createCommentVNode("", true),
989
- !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, _hoisted_5$1)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 2 }, vue.renderList(_ctx.model[_ctx.name], (item, index) => {
989
+ !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, _hoisted_5$2)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 2 }, vue.renderList(_ctx.model[_ctx.name], (item, index) => {
990
990
  return vue.openBlock(), vue.createBlock(_sfc_main$w, {
991
991
  key: index,
992
992
  model: item,
@@ -1038,8 +1038,8 @@
1038
1038
  key: 0,
1039
1039
  style: { "display": "flex" }
1040
1040
  };
1041
- const _hoisted_4 = { style: { "flex": "1" } };
1042
- const _hoisted_5 = ["src"];
1041
+ const _hoisted_4$1 = { style: { "flex": "1" } };
1042
+ const _hoisted_5$1 = ["src"];
1043
1043
  const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
1044
1044
  ...{
1045
1045
  name: "MFormPanel"
@@ -1093,7 +1093,7 @@
1093
1093
  vue.createElementVNode("div", null, [
1094
1094
  vue.renderSlot(_ctx.$slots, "default"),
1095
1095
  _ctx.config.schematic ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$1, [
1096
- vue.createElementVNode("div", _hoisted_4, [
1096
+ vue.createElementVNode("div", _hoisted_4$1, [
1097
1097
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(items.value, (item, index) => {
1098
1098
  return vue.openBlock(), vue.createBlock(_sfc_main$y, {
1099
1099
  key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
@@ -1113,7 +1113,7 @@
1113
1113
  vue.createElementVNode("img", {
1114
1114
  class: "m-form-schematic",
1115
1115
  src: _ctx.config.schematic
1116
- }, null, 8, _hoisted_5)
1116
+ }, null, 8, _hoisted_5$1)
1117
1117
  ])) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(items.value, (item, index) => {
1118
1118
  return vue.openBlock(), vue.createBlock(_sfc_main$y, {
1119
1119
  key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
@@ -1316,8 +1316,10 @@
1316
1316
 
1317
1317
  const _hoisted_1$8 = ["innerHTML"];
1318
1318
  const _hoisted_2$2 = ["innerHTML"];
1319
- const _hoisted_3 = {
1320
- key: 6,
1319
+ const _hoisted_3 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
1320
+ const _hoisted_4 = { style: { "display": "flex" } };
1321
+ const _hoisted_5 = {
1322
+ key: 1,
1321
1323
  class: "bottom",
1322
1324
  style: { "text-align": "right" }
1323
1325
  };
@@ -1356,14 +1358,14 @@
1356
1358
  const isFullscreen = vue.ref(false);
1357
1359
  const modelName = vue.computed(() => props.name || props.config.name || "");
1358
1360
  const data = vue.computed(
1359
- () => props.config.pagination ? props.model[modelName.value].filter(
1361
+ () => props.config.pagination ? (props.model[modelName.value] || []).filter(
1360
1362
  (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1361
1363
  ) : props.model[modelName.value]
1362
1364
  );
1363
1365
  const lastData = vue.computed(
1364
- () => props.config.pagination ? props.lastValues[modelName.value].filter(
1366
+ () => props.config.pagination ? (props.lastValues[modelName.value] || []).filter(
1365
1367
  (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1366
- ) : props.lastValues[modelName.value] || {}
1368
+ ) : props.lastValues[modelName.value] || []
1367
1369
  );
1368
1370
  const sortChange = ({ prop, order }) => {
1369
1371
  if (order === "ascending") {
@@ -1464,9 +1466,6 @@
1464
1466
  props.model[modelName.value].push(inputs);
1465
1467
  emit("change", props.model[modelName.value]);
1466
1468
  };
1467
- if (!globalThis.XLSX) {
1468
- utils.asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
1469
- }
1470
1469
  vue.onMounted(() => {
1471
1470
  if (props.config.defautSort) {
1472
1471
  sortChange(props.config.defautSort);
@@ -1598,10 +1597,13 @@
1598
1597
  props.model[modelName.value].splice(0, len);
1599
1598
  mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1600
1599
  };
1601
- const excelHandler = (file) => {
1600
+ const excelHandler = async (file) => {
1602
1601
  if (!file?.raw) {
1603
1602
  return false;
1604
1603
  }
1604
+ if (!globalThis.XLSX) {
1605
+ await utils.asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
1606
+ }
1605
1607
  const reader = new FileReader();
1606
1608
  reader.onload = () => {
1607
1609
  const data2 = reader.result;
@@ -1836,84 +1838,86 @@
1836
1838
  _: 3
1837
1839
  }, 8, ["disabled"]),
1838
1840
  vue.renderSlot(_ctx.$slots, "default"),
1839
- addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1840
- key: 1,
1841
- size: "small",
1842
- type: "primary",
1843
- disabled: _ctx.disabled,
1844
- plain: "",
1845
- onClick: _cache[2] || (_cache[2] = ($event) => newHandler())
1846
- }, {
1847
- default: vue.withCtx(() => [
1848
- vue.createTextVNode("新增一行")
1849
- ]),
1850
- _: 1
1851
- }, 8, ["disabled"])) : vue.createCommentVNode("", true),
1852
- vue.createTextVNode("   "),
1853
- _ctx.enableToggleMode && _ctx.config.enableToggleMode !== false && !isFullscreen.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1854
- key: 2,
1855
- icon: vue.unref(iconsVue.Grid),
1856
- size: "small",
1857
- type: "primary",
1858
- onClick: toggleMode
1859
- }, {
1860
- default: vue.withCtx(() => [
1861
- vue.createTextVNode("展开配置")
1862
- ]),
1863
- _: 1
1864
- }, 8, ["icon"])) : vue.createCommentVNode("", true),
1865
- _ctx.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1866
- key: 3,
1867
- icon: vue.unref(iconsVue.FullScreen),
1868
- size: "small",
1869
- type: "primary",
1870
- onClick: toggleFullscreen
1871
- }, {
1872
- default: vue.withCtx(() => [
1873
- vue.createTextVNode(vue.toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"), 1)
1874
- ]),
1875
- _: 1
1876
- }, 8, ["icon"])) : vue.createCommentVNode("", true),
1877
- importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicUpload), {
1878
- key: 4,
1879
- style: { "display": "inline-block" },
1880
- ref_key: "excelBtn",
1881
- ref: excelBtn,
1882
- action: "/noop",
1883
- disabled: _ctx.disabled,
1884
- "on-change": excelHandler,
1885
- "auto-upload": false
1886
- }, {
1887
- default: vue.withCtx(() => [
1888
- vue.createVNode(vue.unref(design.TMagicButton), {
1841
+ vue.createElementVNode("div", _hoisted_3, [
1842
+ addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1843
+ key: 0,
1844
+ size: "small",
1845
+ type: "primary",
1846
+ disabled: _ctx.disabled,
1847
+ plain: "",
1848
+ onClick: _cache[2] || (_cache[2] = ($event) => newHandler())
1849
+ }, {
1850
+ default: vue.withCtx(() => [
1851
+ vue.createTextVNode("新增一行")
1852
+ ]),
1853
+ _: 1
1854
+ }, 8, ["disabled"])) : vue.createCommentVNode("", true),
1855
+ vue.createElementVNode("div", _hoisted_4, [
1856
+ _ctx.enableToggleMode && _ctx.config.enableToggleMode !== false && !isFullscreen.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1857
+ key: 0,
1858
+ icon: vue.unref(iconsVue.Grid),
1859
+ size: "small",
1860
+ type: "primary",
1861
+ onClick: toggleMode
1862
+ }, {
1863
+ default: vue.withCtx(() => [
1864
+ vue.createTextVNode("展开配置")
1865
+ ]),
1866
+ _: 1
1867
+ }, 8, ["icon"])) : vue.createCommentVNode("", true),
1868
+ _ctx.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1869
+ key: 1,
1870
+ icon: vue.unref(iconsVue.FullScreen),
1889
1871
  size: "small",
1890
- type: "success",
1872
+ type: "primary",
1873
+ onClick: toggleFullscreen
1874
+ }, {
1875
+ default: vue.withCtx(() => [
1876
+ vue.createTextVNode(vue.toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"), 1)
1877
+ ]),
1878
+ _: 1
1879
+ }, 8, ["icon"])) : vue.createCommentVNode("", true),
1880
+ importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicUpload), {
1881
+ key: 2,
1882
+ style: { "display": "inline-block" },
1883
+ ref_key: "excelBtn",
1884
+ ref: excelBtn,
1885
+ action: "/noop",
1891
1886
  disabled: _ctx.disabled,
1892
- plain: ""
1887
+ "on-change": excelHandler,
1888
+ "auto-upload": false
1893
1889
  }, {
1894
1890
  default: vue.withCtx(() => [
1895
- vue.createTextVNode("导入EXCEL")
1891
+ vue.createVNode(vue.unref(design.TMagicButton), {
1892
+ size: "small",
1893
+ type: "success",
1894
+ disabled: _ctx.disabled,
1895
+ plain: ""
1896
+ }, {
1897
+ default: vue.withCtx(() => [
1898
+ vue.createTextVNode("导入EXCEL")
1899
+ ]),
1900
+ _: 1
1901
+ }, 8, ["disabled"])
1896
1902
  ]),
1897
1903
  _: 1
1898
- }, 8, ["disabled"])
1899
- ]),
1900
- _: 1
1901
- }, 8, ["disabled"])) : vue.createCommentVNode("", true),
1902
- vue.createTextVNode("  "),
1903
- importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1904
- key: 5,
1905
- size: "small",
1906
- type: "warning",
1907
- disabled: _ctx.disabled,
1908
- plain: "",
1909
- onClick: _cache[3] || (_cache[3] = ($event) => clearHandler())
1910
- }, {
1911
- default: vue.withCtx(() => [
1912
- vue.createTextVNode("清空")
1913
- ]),
1914
- _: 1
1915
- }, 8, ["disabled"])) : vue.createCommentVNode("", true),
1916
- _ctx.config.pagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
1904
+ }, 8, ["disabled"])) : vue.createCommentVNode("", true),
1905
+ importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
1906
+ key: 3,
1907
+ size: "small",
1908
+ type: "warning",
1909
+ disabled: _ctx.disabled,
1910
+ plain: "",
1911
+ onClick: _cache[3] || (_cache[3] = ($event) => clearHandler())
1912
+ }, {
1913
+ default: vue.withCtx(() => [
1914
+ vue.createTextVNode("清空")
1915
+ ]),
1916
+ _: 1
1917
+ }, 8, ["disabled"])) : vue.createCommentVNode("", true)
1918
+ ])
1919
+ ]),
1920
+ _ctx.config.pagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
1917
1921
  vue.createVNode(vue.unref(design.TMagicPagination), {
1918
1922
  layout: "total, sizes, prev, pager, next, jumper",
1919
1923
  "hide-on-single-page": _ctx.model[modelName.value].length < pagesize.value,
@@ -2217,7 +2221,11 @@
2217
2221
  placeholder: _ctx.config.placeholder,
2218
2222
  disabled: _ctx.disabled,
2219
2223
  options: vue.unref(options),
2220
- props: { multiple: _ctx.config.multiple },
2224
+ props: {
2225
+ multiple: _ctx.config.multiple ?? false,
2226
+ emitPath: _ctx.config.emitPath ?? true,
2227
+ checkStrictly: _ctx.config.checkStrictly ?? false
2228
+ },
2221
2229
  onChange: changeHandler
2222
2230
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "props"]);
2223
2231
  };