@tmagic/form 1.1.4 → 1.1.6

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.
@@ -1,5 +1,5 @@
1
- import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, watch, unref, withDirectives, vShow, renderSlot, onMounted, toRefs, getCurrentInstance, reactive, onBeforeUnmount, vModelText, onBeforeMount, resolveDirective, createSlots, withModifiers, provide } from 'vue';
2
- import { WarningFilled, CaretBottom, CaretRight, CaretTop, Delete, ArrowDown, ArrowUp, FullScreen, Grid } from '@element-plus/icons-vue';
1
+ import { toRaw, defineComponent, inject, ref, computed, resolveComponent, watchEffect, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, watch, unref, withDirectives, vShow, renderSlot, onMounted, toRefs, getCurrentInstance, reactive, onBeforeUnmount, vModelText, onBeforeMount, resolveDirective, createSlots, withModifiers, provide, Teleport } from 'vue';
2
+ import { WarningFilled, CaretBottom, CaretRight, CaretTop, Delete, Grid, ArrowDown, ArrowUp, FullScreen } from '@element-plus/icons-vue';
3
3
  import { cloneDeep, isEqual } from 'lodash-es';
4
4
  import { ElMessage } from 'element-plus';
5
5
  import Sortable from 'sortablejs';
@@ -126,20 +126,24 @@ const getRules = function(mForm, rules = [], props) {
126
126
  return rules.map((item) => {
127
127
  if (typeof item.validator === "function") {
128
128
  const fnc = item.validator;
129
- item.validator = (rule, value, callback, source, options) => fnc({
130
- rule,
131
- value: props.config.names ? props.model : value,
132
- callback,
133
- source,
134
- options
135
- }, {
136
- values: mForm?.initValues || {},
137
- model: props.model,
138
- parent: mForm?.parentValues || {},
139
- formValue: mForm?.values || props.model,
140
- prop: props.prop,
141
- config: props.config
142
- }, mForm);
129
+ item.validator = (rule, value, callback, source, options) => fnc(
130
+ {
131
+ rule,
132
+ value: props.config.names ? props.model : value,
133
+ callback,
134
+ source,
135
+ options
136
+ },
137
+ {
138
+ values: mForm?.initValues || {},
139
+ model: props.model,
140
+ parent: mForm?.parentValues || {},
141
+ formValue: mForm?.values || props.model,
142
+ prop: props.prop,
143
+ config: props.config
144
+ },
145
+ mForm
146
+ );
143
147
  }
144
148
  return item;
145
149
  });
@@ -316,7 +320,7 @@ const _hoisted_1$c = ["innerHTML"];
316
320
  const _hoisted_2$7 = ["innerHTML"];
317
321
  const _hoisted_3$7 = ["innerHTML"];
318
322
  const _hoisted_4$6 = ["innerHTML"];
319
- const _hoisted_5$4 = {
323
+ const _hoisted_5$5 = {
320
324
  key: 4,
321
325
  style: { "text-align": "center" }
322
326
  };
@@ -434,7 +438,7 @@ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
434
438
  }, null, 8, ["model", "config", "size", "step-active", "expand-more", "label-width", "prop", "onChange"]);
435
439
  }), 128)) : createCommentVNode("", true)
436
440
  ], 64)) : createCommentVNode("", true),
437
- _ctx.config.expand && _ctx.type !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_5$4, [
441
+ _ctx.config.expand && _ctx.type !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_5$5, [
438
442
  createVNode(_component_el_button, {
439
443
  text: "",
440
444
  onClick: _ctx.expandHandler
@@ -453,7 +457,7 @@ const _hoisted_1$b = ["innerHTML"];
453
457
  const _hoisted_2$6 = ["innerHTML"];
454
458
  const _hoisted_3$6 = { key: 1 };
455
459
  const _hoisted_4$5 = ["innerHTML"];
456
- const _hoisted_5$3 = ["innerHTML"];
460
+ const _hoisted_5$4 = ["innerHTML"];
457
461
  const _hoisted_6$2 = {
458
462
  key: 2,
459
463
  style: { "display": "flex" }
@@ -492,9 +496,12 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
492
496
  };
493
497
  const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
494
498
  if (props.config.checkbox && name.value) {
495
- watch(() => props.model[name.value]?.value, () => {
496
- emit("change", props.model);
497
- });
499
+ watch(
500
+ () => props.model[name.value]?.value,
501
+ () => {
502
+ emit("change", props.model);
503
+ }
504
+ );
498
505
  }
499
506
  return (_ctx, _cache) => {
500
507
  const _component_el_checkbox = resolveComponent("el-checkbox");
@@ -535,7 +542,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
535
542
  key: 0,
536
543
  innerHTML: __props.config.extra,
537
544
  class: "m-form-tip"
538
- }, null, 8, _hoisted_5$3)) : createCommentVNode("", true)
545
+ }, null, 8, _hoisted_5$4)) : createCommentVNode("", true)
539
546
  ])),
540
547
  __props.config.schematic && unref(show) ? (openBlock(), createElementBlock("div", _hoisted_6$2, [
541
548
  createElementVNode("div", _hoisted_7$2, [
@@ -841,6 +848,7 @@ const _sfc_main$r = defineComponent({
841
848
  }));
842
849
  };
843
850
  return {
851
+ Grid,
844
852
  addable,
845
853
  toggleMode,
846
854
  removeHandler,
@@ -858,7 +866,7 @@ const _hoisted_3$4 = {
858
866
  class: "el-table__empty-block"
859
867
  };
860
868
  const _hoisted_4$3 = /* @__PURE__ */ createElementVNode("span", { class: "el-table__empty-text" }, "\u6682\u65E0\u6570\u636E", -1);
861
- const _hoisted_5$2 = [
869
+ const _hoisted_5$3 = [
862
870
  _hoisted_4$3
863
871
  ];
864
872
  const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0\u7EC4");
@@ -872,7 +880,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
872
880
  innerHTML: _ctx.config.extra,
873
881
  style: { "color": "rgba(0, 0, 0, 0.45)" }
874
882
  }, null, 8, _hoisted_2$4)) : createCommentVNode("", true),
875
- !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$4, _hoisted_5$2)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.model[_ctx.name], (item, index) => {
883
+ !_ctx.model[_ctx.name] || !_ctx.model[_ctx.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$4, _hoisted_5$3)) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.model[_ctx.name], (item, index) => {
876
884
  return openBlock(), createBlock(_component_m_fields_group_list_item, {
877
885
  key: index,
878
886
  model: item,
@@ -899,7 +907,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
899
907
  }, 8, ["onClick"])) : createCommentVNode("", true),
900
908
  _ctx.config.enableToggleMode ? (openBlock(), createBlock(_component_el_button, {
901
909
  key: 4,
902
- icon: "el-icon-s-grid",
910
+ icon: _ctx.Grid,
903
911
  size: "small",
904
912
  onClick: _ctx.toggleMode
905
913
  }, {
@@ -907,7 +915,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
907
915
  _hoisted_7$1
908
916
  ]),
909
917
  _: 1
910
- }, 8, ["onClick"])) : createCommentVNode("", true)
918
+ }, 8, ["icon", "onClick"])) : createCommentVNode("", true)
911
919
  ]);
912
920
  }
913
921
  const GroupList = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["render", _sfc_render$m]]);
@@ -953,7 +961,7 @@ const _hoisted_3$3 = {
953
961
  style: { "display": "flex" }
954
962
  };
955
963
  const _hoisted_4$2 = { style: { "flex": "1" } };
956
- const _hoisted_5$1 = ["src"];
964
+ const _hoisted_5$2 = ["src"];
957
965
  function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
958
966
  const _component_caret_bottom = resolveComponent("caret-bottom");
959
967
  const _component_caret_right = resolveComponent("caret-right");
@@ -1007,7 +1015,7 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
1007
1015
  createElementVNode("img", {
1008
1016
  class: "m-form-schematic",
1009
1017
  src: _ctx.config.schematic
1010
- }, null, 8, _hoisted_5$1)
1018
+ }, null, 8, _hoisted_5$2)
1011
1019
  ])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.items, (item, index) => {
1012
1020
  return openBlock(), createBlock(_component_m_form_container, {
1013
1021
  key: item[_ctx.mForm?.keyProp || "__key"] ?? index,
@@ -1210,10 +1218,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1210
1218
  }
1211
1219
  const MStep = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$i]]);
1212
1220
 
1213
- let loadedAMapJS = false;
1214
- let firstLoadingAMapJS = true;
1215
1221
  const _sfc_main$m = defineComponent({
1216
- name: "m-form-table",
1217
1222
  props: {
1218
1223
  name: {
1219
1224
  type: String,
@@ -1250,9 +1255,14 @@ const _sfc_main$m = defineComponent({
1250
1255
  enableToggleMode: {
1251
1256
  type: Boolean,
1252
1257
  default: true
1258
+ },
1259
+ showIndex: {
1260
+ type: Boolean,
1261
+ default: true
1253
1262
  }
1254
1263
  },
1255
1264
  emits: ["change", "select"],
1265
+ components: { Delete },
1256
1266
  setup(props, { emit }) {
1257
1267
  let timer = null;
1258
1268
  const mForm = inject("mForm");
@@ -1276,7 +1286,11 @@ const _sfc_main$m = defineComponent({
1276
1286
  setTimeout(() => rowDrop());
1277
1287
  };
1278
1288
  const swapArray = (index1, index2) => {
1279
- [props.model[modelName.value][index1]] = props.model[modelName.value].splice(index2, 1, props.model[modelName.value][index1]);
1289
+ [props.model[modelName.value][index1]] = props.model[modelName.value].splice(
1290
+ index2,
1291
+ 1,
1292
+ props.model[modelName.value][index1]
1293
+ );
1280
1294
  if (props.sortKey) {
1281
1295
  for (let i = props.model[modelName.value].length - 1, v = 0; i >= 0; i--, v++) {
1282
1296
  props.model[modelName.value][v][props.sortKey] = i;
@@ -1363,17 +1377,14 @@ const _sfc_main$m = defineComponent({
1363
1377
  props.model[modelName.value].push(inputs);
1364
1378
  emit("change", props.model[modelName.value]);
1365
1379
  };
1366
- if (!loadedAMapJS && firstLoadingAMapJS && !globalThis.XLSX) {
1367
- firstLoadingAMapJS = false;
1368
- asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js").then(() => {
1369
- loadedAMapJS = true;
1370
- }).catch(() => {
1371
- firstLoadingAMapJS = true;
1372
- });
1380
+ if (!globalThis.XLSX) {
1381
+ asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
1373
1382
  }
1374
1383
  onMounted(() => {
1375
1384
  if (props.config.defautSort) {
1376
1385
  sortChange(props.config.defautSort);
1386
+ } else if (props.config.defaultSort) {
1387
+ sortChange(props.config.defaultSort);
1377
1388
  }
1378
1389
  if (props.sort && props.sortKey) {
1379
1390
  props.model[modelName.value].sort((a, b) => b[props.sortKey] - a[props.sortKey]);
@@ -1398,7 +1409,11 @@ const _sfc_main$m = defineComponent({
1398
1409
  Delete,
1399
1410
  FullScreen,
1400
1411
  Grid,
1401
- data: computed(() => props.model[modelName.value].filter((item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value)),
1412
+ data: computed(
1413
+ () => props.model[modelName.value].filter(
1414
+ (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1415
+ )
1416
+ ),
1402
1417
  addable: computed(() => {
1403
1418
  if (!props.model[modelName.value].length) {
1404
1419
  return true;
@@ -1586,7 +1601,7 @@ const _hoisted_1$7 = ["innerHTML"];
1586
1601
  const _hoisted_2$2 = { class: "el-form-item__content" };
1587
1602
  const _hoisted_3$2 = ["innerHTML"];
1588
1603
  const _hoisted_4$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0");
1589
- const _hoisted_5 = /* @__PURE__ */ createTextVNode(" \xA0 ");
1604
+ const _hoisted_5$1 = /* @__PURE__ */ createTextVNode(" \xA0 ");
1590
1605
  const _hoisted_6 = /* @__PURE__ */ createTextVNode("\u5C55\u5F00\u914D\u7F6E");
1591
1606
  const _hoisted_7 = /* @__PURE__ */ createTextVNode("\u5BFC\u5165EXCEL");
1592
1607
  const _hoisted_8 = /* @__PURE__ */ createTextVNode("\xA0 ");
@@ -1597,6 +1612,8 @@ const _hoisted_10 = {
1597
1612
  };
1598
1613
  function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1599
1614
  const _component_el_table_column = resolveComponent("el-table-column");
1615
+ const _component_Delete = resolveComponent("Delete");
1616
+ const _component_el_icon = resolveComponent("el-icon");
1600
1617
  const _component_el_button = resolveComponent("el-button");
1601
1618
  const _component_el_tooltip = resolveComponent("el-tooltip");
1602
1619
  const _component_m_form_container = resolveComponent("m-form-container");
@@ -1647,16 +1664,20 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1647
1664
  })) : createCommentVNode("", true),
1648
1665
  createVNode(_component_el_table_column, {
1649
1666
  label: "\u64CD\u4F5C",
1650
- width: "60",
1667
+ width: "55",
1668
+ align: "center",
1651
1669
  fixed: _ctx.config.fixed === false ? void 0 : "left"
1652
1670
  }, {
1653
1671
  default: withCtx((scope) => [
1654
- withDirectives(createVNode(_component_el_button, {
1655
- type: "danger",
1656
- text: "",
1657
- icon: _ctx.Delete,
1672
+ withDirectives(createVNode(_component_el_icon, {
1673
+ class: "m-table-delete-icon",
1658
1674
  onClick: ($event) => _ctx.removeHandler(scope.$index + 1 + _ctx.pagecontext * _ctx.pagesize - 1)
1659
- }, null, 8, ["icon", "onClick"]), [
1675
+ }, {
1676
+ default: withCtx(() => [
1677
+ createVNode(_component_Delete)
1678
+ ]),
1679
+ _: 2
1680
+ }, 1032, ["onClick"]), [
1660
1681
  [vShow, _ctx.showDelete(scope.$index + 1 + _ctx.pagecontext * _ctx.pagesize - 1)]
1661
1682
  ])
1662
1683
  ]),
@@ -1714,7 +1735,8 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1714
1735
  type: "selection",
1715
1736
  width: "45"
1716
1737
  })) : createCommentVNode("", true),
1717
- createVNode(_component_el_table_column, {
1738
+ _ctx.showIndex && _ctx.config.showIndex ? (openBlock(), createBlock(_component_el_table_column, {
1739
+ key: 3,
1718
1740
  width: "60",
1719
1741
  label: "\u5E8F\u53F7"
1720
1742
  }, {
@@ -1722,7 +1744,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1722
1744
  createTextVNode(toDisplayString(scope.$index + 1 + _ctx.pagecontext * _ctx.pagesize), 1)
1723
1745
  ]),
1724
1746
  _: 1
1725
- }),
1747
+ })) : createCommentVNode("", true),
1726
1748
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.config.items, (column, index) => {
1727
1749
  return openBlock(), createElementBlock(Fragment, null, [
1728
1750
  column.type !== "hidden" && _ctx.display(column.display) ? (openBlock(), createBlock(_component_el_table_column, {
@@ -1769,7 +1791,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1769
1791
  ]),
1770
1792
  _: 1
1771
1793
  })) : createCommentVNode("", true),
1772
- _hoisted_5,
1794
+ _hoisted_5$1,
1773
1795
  _ctx.enableToggleMode && !_ctx.isFullscreen ? (openBlock(), createBlock(_component_el_button, {
1774
1796
  key: 1,
1775
1797
  icon: _ctx.Grid,
@@ -2043,15 +2065,19 @@ const useAddField = (prop) => {
2043
2065
  return;
2044
2066
  const mForm = inject("mForm");
2045
2067
  const instance = getCurrentInstance();
2046
- watch(() => instance?.proxy, (vm) => {
2047
- if (vm) {
2048
- mForm?.setField(prop, vm);
2049
- } else {
2050
- mForm?.deleteField(prop);
2068
+ watch(
2069
+ () => instance?.proxy,
2070
+ (vm) => {
2071
+ if (vm) {
2072
+ mForm?.setField(prop, vm);
2073
+ } else {
2074
+ mForm?.deleteField(prop);
2075
+ }
2076
+ },
2077
+ {
2078
+ immediate: true
2051
2079
  }
2052
- }, {
2053
- immediate: true
2054
- });
2080
+ );
2055
2081
  };
2056
2082
 
2057
2083
  const _sfc_main$l = defineComponent({
@@ -2103,7 +2129,9 @@ const _sfc_main$l = defineComponent({
2103
2129
  }
2104
2130
  };
2105
2131
  if (typeof props.config.options === "function" && props.model && mForm) {
2106
- watchEffect(() => options.value = props.config.options(vm, { model: props.model, formValues: mForm.values }));
2132
+ watchEffect(
2133
+ () => options.value = props.config.options(vm, { model: props.model, formValues: mForm.values })
2134
+ );
2107
2135
  } else if (!props.config.options || !props.config.options.length || props.config.remote) {
2108
2136
  Promise.resolve(setRemoteOptions());
2109
2137
  }
@@ -2367,26 +2395,34 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2367
2395
  const value = ref([]);
2368
2396
  if (props.model !== void 0) {
2369
2397
  if (names?.length) {
2370
- watch([() => props.model[names[0]], () => props.model[names[1]]], ([start, end], [preStart, preEnd]) => {
2371
- if (!value.value) {
2372
- value.value = [];
2398
+ watch(
2399
+ [() => props.model[names[0]], () => props.model[names[1]]],
2400
+ ([start, end], [preStart, preEnd]) => {
2401
+ if (!value.value) {
2402
+ value.value = [];
2403
+ }
2404
+ if (!start || !end)
2405
+ value.value = [];
2406
+ if (start !== preStart)
2407
+ value.value[0] = new Date(start);
2408
+ if (end !== preEnd)
2409
+ value.value[1] = new Date(end);
2410
+ },
2411
+ {
2412
+ immediate: true
2373
2413
  }
2374
- if (!start || !end)
2375
- value.value = [];
2376
- if (start !== preStart)
2377
- value.value[0] = new Date(start);
2378
- if (end !== preEnd)
2379
- value.value[1] = new Date(end);
2380
- }, {
2381
- immediate: true
2382
- });
2414
+ );
2383
2415
  } else if (props.name && props.model[props.name]) {
2384
- watch(() => props.model[props.name], (start, preStart) => {
2385
- if (start !== preStart)
2386
- value.value = start.map((item) => item ? new Date(item) : void 0);
2387
- }, {
2388
- immediate: true
2389
- });
2416
+ watch(
2417
+ () => props.model[props.name],
2418
+ (start, preStart) => {
2419
+ if (start !== preStart)
2420
+ value.value = start.map((item) => item ? new Date(item) : void 0);
2421
+ },
2422
+ {
2423
+ immediate: true
2424
+ }
2425
+ );
2390
2426
  }
2391
2427
  }
2392
2428
  const setValue = (v) => {
@@ -2404,11 +2440,14 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2404
2440
  const changeHandler = (v) => {
2405
2441
  const value2 = v || [];
2406
2442
  if (props.name) {
2407
- emit("change", value2.map((item) => {
2408
- if (item)
2409
- return datetimeFormatter(item, "");
2410
- return void 0;
2411
- }));
2443
+ emit(
2444
+ "change",
2445
+ value2.map((item) => {
2446
+ if (item)
2447
+ return datetimeFormatter(item, "");
2448
+ return void 0;
2449
+ })
2450
+ );
2412
2451
  } else {
2413
2452
  if (names?.length) {
2414
2453
  setValue(value2);
@@ -2542,13 +2581,17 @@ const _sfc_main$d = defineComponent({
2542
2581
  fieldLabelMap.value[v.name] = v.label || "";
2543
2582
  });
2544
2583
  };
2545
- const unwatch = watch(() => props.model?.[props.config.dynamicKey], (val) => {
2546
- if (val !== "") {
2547
- changeFieldMap();
2584
+ const unwatch = watch(
2585
+ () => props.model?.[props.config.dynamicKey],
2586
+ (val) => {
2587
+ if (val !== "") {
2588
+ changeFieldMap();
2589
+ }
2590
+ },
2591
+ {
2592
+ immediate: true
2548
2593
  }
2549
- }, {
2550
- immediate: true
2551
- });
2594
+ );
2552
2595
  onBeforeUnmount(() => {
2553
2596
  if (typeof unwatch === "function") {
2554
2597
  unwatch();
@@ -3013,12 +3056,18 @@ const _sfc_main$6 = defineComponent({
3013
3056
  remote.value = false;
3014
3057
  if (config.group) {
3015
3058
  if (config.multiple && value.findIndex) {
3016
- return localOptions.value.filter((group) => group.options.findIndex((item) => value.find((v) => equalValue(item.value, v)) > -1) > -1);
3059
+ return localOptions.value.filter(
3060
+ (group) => group.options.findIndex((item) => value.find((v) => equalValue(item.value, v)) > -1) > -1
3061
+ );
3017
3062
  }
3018
- return localOptions.value.filter((group) => group.options.findIndex((item) => equalValue(item.value, value)) > -1);
3063
+ return localOptions.value.filter(
3064
+ (group) => group.options.findIndex((item) => equalValue(item.value, value)) > -1
3065
+ );
3019
3066
  }
3020
3067
  if (config.multiple && value.findIndex) {
3021
- return localOptions.value.filter((item) => value.findIndex((v) => equalValue(item.value, v)) > -1);
3068
+ return localOptions.value.filter(
3069
+ (item) => value.findIndex((v) => equalValue(item.value, v)) > -1
3070
+ );
3022
3071
  }
3023
3072
  return localOptions.value.filter((item) => equalValue(item.value, value));
3024
3073
  };
@@ -3064,24 +3113,34 @@ const _sfc_main$6 = defineComponent({
3064
3113
  return options2;
3065
3114
  };
3066
3115
  if (typeof props.config.options === "function") {
3067
- watch(() => mForm?.values, () => {
3068
- typeof props.config.options === "function" && Promise.resolve(props.config.options(mForm, {
3069
- model: props.model,
3070
- prop: props.prop,
3071
- formValues: mForm?.values,
3072
- formValue: mForm?.values,
3073
- config: props.config
3074
- })).then((data) => {
3075
- options.value = data;
3076
- });
3077
- }, {
3078
- deep: true,
3079
- immediate: true
3080
- });
3116
+ watch(
3117
+ () => mForm?.values,
3118
+ () => {
3119
+ typeof props.config.options === "function" && Promise.resolve(
3120
+ props.config.options(mForm, {
3121
+ model: props.model,
3122
+ prop: props.prop,
3123
+ formValues: mForm?.values,
3124
+ formValue: mForm?.values,
3125
+ config: props.config
3126
+ })
3127
+ ).then((data) => {
3128
+ options.value = data;
3129
+ });
3130
+ },
3131
+ {
3132
+ deep: true,
3133
+ immediate: true
3134
+ }
3135
+ );
3081
3136
  } else if (Array.isArray(props.config.options)) {
3082
- watch(() => props.config.options, () => {
3083
- options.value = props.config.options;
3084
- }, { immediate: true });
3137
+ watch(
3138
+ () => props.config.options,
3139
+ () => {
3140
+ options.value = props.config.options;
3141
+ },
3142
+ { immediate: true }
3143
+ );
3085
3144
  } else if (props.config.option) {
3086
3145
  onBeforeMount(() => {
3087
3146
  if (!props.model)
@@ -3548,18 +3607,22 @@ const _sfc_main$1 = defineComponent({
3548
3607
  }
3549
3608
  });
3550
3609
  provide("mForm", formState);
3551
- watch([() => props.config, () => props.initValues], ([config], [preConfig]) => {
3552
- if (!isEqual(toRaw(config), toRaw(preConfig))) {
3553
- initialized.value = false;
3554
- }
3555
- initValue(formState, {
3556
- initValues: props.initValues,
3557
- config: props.config
3558
- }).then((value) => {
3559
- values.value = value;
3560
- initialized.value = true;
3561
- });
3562
- }, { immediate: true });
3610
+ watch(
3611
+ [() => props.config, () => props.initValues],
3612
+ ([config], [preConfig]) => {
3613
+ if (!isEqual(toRaw(config), toRaw(preConfig))) {
3614
+ initialized.value = false;
3615
+ }
3616
+ initValue(formState, {
3617
+ initValues: props.initValues,
3618
+ config: props.config
3619
+ }).then((value) => {
3620
+ values.value = value;
3621
+ initialized.value = true;
3622
+ });
3623
+ },
3624
+ { immediate: true }
3625
+ );
3563
3626
  return {
3564
3627
  initialized,
3565
3628
  values,
@@ -3630,6 +3693,9 @@ const _sfc_main = defineComponent({
3630
3693
  type: Object,
3631
3694
  default: () => ({})
3632
3695
  },
3696
+ parentValues: {
3697
+ type: Object
3698
+ },
3633
3699
  width: [Number, String],
3634
3700
  fullscreen: Boolean,
3635
3701
  title: String,
@@ -3712,116 +3778,120 @@ const _sfc_main = defineComponent({
3712
3778
  }
3713
3779
  });
3714
3780
 
3715
- const _hoisted_1 = { style: { "min-height": "1px" } };
3716
- const _hoisted_2 = /* @__PURE__ */ createTextVNode("\u53D6 \u6D88");
3717
- const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u4E0A\u4E00\u6B65");
3718
- const _hoisted_4 = /* @__PURE__ */ createTextVNode("\u4E0B\u4E00\u6B65");
3781
+ const _hoisted_1 = { class: "m-form-dialog" };
3782
+ const _hoisted_2 = { style: { "min-height": "1px" } };
3783
+ const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u53D6 \u6D88");
3784
+ const _hoisted_4 = /* @__PURE__ */ createTextVNode("\u4E0A\u4E00\u6B65");
3785
+ const _hoisted_5 = /* @__PURE__ */ createTextVNode("\u4E0B\u4E00\u6B65");
3719
3786
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
3720
3787
  const _component_m_form = resolveComponent("m-form");
3721
3788
  const _component_el_col = resolveComponent("el-col");
3722
3789
  const _component_el_button = resolveComponent("el-button");
3723
3790
  const _component_el_row = resolveComponent("el-row");
3724
3791
  const _component_el_dialog = resolveComponent("el-dialog");
3725
- return openBlock(), createElementBlock("div", null, [
3726
- createVNode(_component_el_dialog, {
3727
- modelValue: _ctx.dialogVisible,
3728
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.dialogVisible = $event),
3729
- class: "m-form-dialog",
3730
- top: "20px",
3731
- title: _ctx.title,
3732
- appendToBody: true,
3733
- width: _ctx.width,
3734
- fullscreen: _ctx.fullscreen,
3735
- "close-on-click-modal": false,
3736
- onClose: _ctx.closeHandler
3737
- }, {
3738
- footer: withCtx(() => [
3739
- createVNode(_component_el_row, { class: "dialog-footer" }, {
3740
- default: withCtx(() => [
3741
- createVNode(_component_el_col, {
3742
- span: 12,
3743
- style: { "text-align": "left" }
3744
- }, {
3745
- default: withCtx(() => [
3746
- createElementVNode("div", _hoisted_1, [
3747
- renderSlot(_ctx.$slots, "left")
3748
- ])
3749
- ]),
3750
- _: 3
3751
- }),
3752
- createVNode(_component_el_col, { span: 12 }, {
3753
- default: withCtx(() => [
3754
- renderSlot(_ctx.$slots, "footer", {}, () => [
3755
- createVNode(_component_el_button, {
3756
- onClick: _ctx.cancel,
3757
- size: "small"
3758
- }, {
3759
- default: withCtx(() => [
3760
- _hoisted_2
3761
- ]),
3762
- _: 1
3763
- }, 8, ["onClick"]),
3764
- _ctx.hasStep && _ctx.stepActive > 1 ? (openBlock(), createBlock(_component_el_button, {
3765
- key: 0,
3766
- type: "info",
3767
- size: "small",
3768
- onClick: _ctx.preStep
3769
- }, {
3770
- default: withCtx(() => [
3771
- _hoisted_3
3772
- ]),
3773
- _: 1
3774
- }, 8, ["onClick"])) : createCommentVNode("", true),
3775
- _ctx.hasStep && _ctx.stepCount > _ctx.stepActive ? (openBlock(), createBlock(_component_el_button, {
3776
- key: 1,
3777
- type: "info",
3778
- size: "small",
3779
- onClick: _ctx.nextStep
3780
- }, {
3781
- default: withCtx(() => [
3782
- _hoisted_4
3783
- ]),
3784
- _: 1
3785
- }, 8, ["onClick"])) : (openBlock(), createBlock(_component_el_button, {
3786
- key: 2,
3787
- type: "primary",
3788
- size: "small",
3789
- loading: _ctx.saveFetch,
3790
- onClick: _ctx.save
3791
- }, {
3792
- default: withCtx(() => [
3793
- createTextVNode(toDisplayString(_ctx.confirmText), 1)
3794
- ]),
3795
- _: 1
3796
- }, 8, ["loading", "onClick"]))
3797
- ])
3798
- ]),
3799
- _: 3
3800
- })
3801
- ]),
3802
- _: 3
3803
- })
3804
- ]),
3805
- default: withCtx(() => [
3806
- createElementVNode("div", {
3807
- class: "m-dialog-body",
3808
- style: normalizeStyle(`max-height: ${_ctx.bodyHeight}; overflow-y: auto; overflow-x: hidden;`)
3809
- }, [
3810
- createVNode(_component_m_form, {
3811
- modelValue: _ctx.stepActive,
3812
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.stepActive = $event),
3813
- ref: "form",
3814
- size: _ctx.size,
3815
- config: _ctx.config,
3816
- "init-values": _ctx.values,
3817
- "label-width": _ctx.labelWidth,
3818
- onChange: _ctx.changeHandler
3819
- }, null, 8, ["modelValue", "size", "config", "init-values", "label-width", "onChange"]),
3820
- renderSlot(_ctx.$slots, "default")
3821
- ], 4)
3822
- ]),
3823
- _: 3
3824
- }, 8, ["modelValue", "title", "width", "fullscreen", "onClose"])
3792
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
3793
+ withDirectives(createElementVNode("div", _hoisted_1, [
3794
+ createVNode(_component_el_dialog, {
3795
+ modelValue: _ctx.dialogVisible,
3796
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.dialogVisible = $event),
3797
+ top: "20px",
3798
+ title: _ctx.title,
3799
+ width: _ctx.width,
3800
+ fullscreen: _ctx.fullscreen,
3801
+ "close-on-click-modal": false,
3802
+ onClose: _ctx.closeHandler
3803
+ }, {
3804
+ footer: withCtx(() => [
3805
+ createVNode(_component_el_row, { class: "dialog-footer" }, {
3806
+ default: withCtx(() => [
3807
+ createVNode(_component_el_col, {
3808
+ span: 12,
3809
+ style: { "text-align": "left" }
3810
+ }, {
3811
+ default: withCtx(() => [
3812
+ createElementVNode("div", _hoisted_2, [
3813
+ renderSlot(_ctx.$slots, "left")
3814
+ ])
3815
+ ]),
3816
+ _: 3
3817
+ }),
3818
+ createVNode(_component_el_col, { span: 12 }, {
3819
+ default: withCtx(() => [
3820
+ renderSlot(_ctx.$slots, "footer", {}, () => [
3821
+ createVNode(_component_el_button, {
3822
+ onClick: _ctx.cancel,
3823
+ size: "small"
3824
+ }, {
3825
+ default: withCtx(() => [
3826
+ _hoisted_3
3827
+ ]),
3828
+ _: 1
3829
+ }, 8, ["onClick"]),
3830
+ _ctx.hasStep && _ctx.stepActive > 1 ? (openBlock(), createBlock(_component_el_button, {
3831
+ key: 0,
3832
+ type: "info",
3833
+ size: "small",
3834
+ onClick: _ctx.preStep
3835
+ }, {
3836
+ default: withCtx(() => [
3837
+ _hoisted_4
3838
+ ]),
3839
+ _: 1
3840
+ }, 8, ["onClick"])) : createCommentVNode("", true),
3841
+ _ctx.hasStep && _ctx.stepCount > _ctx.stepActive ? (openBlock(), createBlock(_component_el_button, {
3842
+ key: 1,
3843
+ type: "info",
3844
+ size: "small",
3845
+ onClick: _ctx.nextStep
3846
+ }, {
3847
+ default: withCtx(() => [
3848
+ _hoisted_5
3849
+ ]),
3850
+ _: 1
3851
+ }, 8, ["onClick"])) : (openBlock(), createBlock(_component_el_button, {
3852
+ key: 2,
3853
+ type: "primary",
3854
+ size: "small",
3855
+ loading: _ctx.saveFetch,
3856
+ onClick: _ctx.save
3857
+ }, {
3858
+ default: withCtx(() => [
3859
+ createTextVNode(toDisplayString(_ctx.confirmText), 1)
3860
+ ]),
3861
+ _: 1
3862
+ }, 8, ["loading", "onClick"]))
3863
+ ])
3864
+ ]),
3865
+ _: 3
3866
+ })
3867
+ ]),
3868
+ _: 3
3869
+ })
3870
+ ]),
3871
+ default: withCtx(() => [
3872
+ createElementVNode("div", {
3873
+ class: "m-dialog-body",
3874
+ style: normalizeStyle(`max-height: ${_ctx.bodyHeight}; overflow-y: auto; overflow-x: hidden;`)
3875
+ }, [
3876
+ createVNode(_component_m_form, {
3877
+ modelValue: _ctx.stepActive,
3878
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.stepActive = $event),
3879
+ ref: "form",
3880
+ size: _ctx.size,
3881
+ config: _ctx.config,
3882
+ "init-values": _ctx.values,
3883
+ "parent-values": _ctx.parentValues,
3884
+ "label-width": _ctx.labelWidth,
3885
+ onChange: _ctx.changeHandler
3886
+ }, null, 8, ["modelValue", "size", "config", "init-values", "parent-values", "label-width", "onChange"]),
3887
+ renderSlot(_ctx.$slots, "default")
3888
+ ], 4)
3889
+ ]),
3890
+ _: 3
3891
+ }, 8, ["modelValue", "title", "width", "fullscreen", "onClose"])
3892
+ ], 512), [
3893
+ [vShow, _ctx.dialogVisible]
3894
+ ])
3825
3895
  ]);
3826
3896
  }
3827
3897
  const FormDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
@@ -3841,7 +3911,7 @@ const install = (app, opt) => {
3841
3911
  app.component(Panel.name, Panel);
3842
3912
  app.component(Row.name, Row);
3843
3913
  app.component(MStep.name, MStep);
3844
- app.component(Table.name, Table);
3914
+ app.component("m-form-table", Table);
3845
3915
  app.component(Tabs.name, Tabs);
3846
3916
  app.component(Text.name, Text);
3847
3917
  app.component(Number$1.name, Number$1);