@tmagic/form 1.0.0-rc.9 → 1.0.2

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.
@@ -27,7 +27,7 @@
27
27
  ].includes(type);
28
28
  const initItemsValue = (mForm, value, initValue2, { items, name, extensible }) => {
29
29
  if (Array.isArray(initValue2[name])) {
30
- value[name] = initValue2[name].map((v) => init(mForm, items, v));
30
+ value[name] = initValue2[name].map((v, index) => init(mForm, items, v, value[name]?.[index]));
31
31
  } else {
32
32
  value[name] = init(mForm, items, initValue2[name], value[name]);
33
33
  if (extensible) {
@@ -117,7 +117,8 @@
117
117
  model: props.model,
118
118
  parent: mForm?.parentValues || {},
119
119
  formValue: mForm?.values || props.model,
120
- prop: props.prop
120
+ prop: props.prop,
121
+ config: props.config
121
122
  });
122
123
  };
123
124
  const display = function(mForm, config, props) {
@@ -148,7 +149,8 @@
148
149
  model: props.model,
149
150
  parent: mForm?.parentValues || {},
150
151
  formValue: mForm?.values || props.model,
151
- prop: props.prop
152
+ prop: props.prop,
153
+ config: props.config
152
154
  }, mForm);
153
155
  }
154
156
  return item;
@@ -259,7 +261,8 @@
259
261
  model: props.model,
260
262
  values: mForm?.initValues,
261
263
  formValue: mForm?.values,
262
- prop: itemProp.value
264
+ prop: itemProp.value,
265
+ config: props.config
263
266
  });
264
267
  }
265
268
  if (filter === "number") {
@@ -273,7 +276,8 @@
273
276
  model: props.model,
274
277
  values: mForm?.initValues,
275
278
  formValue: mForm?.values,
276
- prop: itemProp.value
279
+ prop: itemProp.value,
280
+ config: props.config
277
281
  });
278
282
  }
279
283
  };
@@ -319,7 +323,7 @@
319
323
  };
320
324
  }
321
325
  });
322
- const _hoisted_1$f = ["innerHTML"];
326
+ const _hoisted_1$e = ["innerHTML"];
323
327
  const _hoisted_2$7 = ["innerHTML"];
324
328
  const _hoisted_3$7 = ["innerHTML"];
325
329
  const _hoisted_4$6 = ["innerHTML"];
@@ -369,7 +373,7 @@
369
373
  label: vue.withCtx(() => [
370
374
  vue.createElementVNode("span", {
371
375
  innerHTML: _ctx.type === "checkbox" ? "" : _ctx.config.text
372
- }, null, 8, _hoisted_1$f)
376
+ }, null, 8, _hoisted_1$e)
373
377
  ]),
374
378
  default: vue.withCtx(() => [
375
379
  _ctx.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, { key: 0 }, {
@@ -508,7 +512,7 @@
508
512
  };
509
513
  }
510
514
  });
511
- const _hoisted_1$e = ["innerHTML"];
515
+ const _hoisted_1$d = ["innerHTML"];
512
516
  const _hoisted_2$6 = ["innerHTML"];
513
517
  const _hoisted_3$6 = { key: 1 };
514
518
  const _hoisted_4$5 = ["innerHTML"];
@@ -542,7 +546,7 @@
542
546
  default: vue.withCtx(() => [
543
547
  vue.createElementVNode("span", {
544
548
  innerHTML: _ctx.config.legend
545
- }, null, 8, _hoisted_1$e),
549
+ }, null, 8, _hoisted_1$d),
546
550
  _ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
547
551
  key: 0,
548
552
  innerHTML: _ctx.config.extra,
@@ -700,7 +704,7 @@
700
704
  };
701
705
  }
702
706
  });
703
- const _hoisted_1$d = { class: "m-fields-group-list-item" };
707
+ const _hoisted_1$c = { class: "m-fields-group-list-item" };
704
708
  const _hoisted_2$5 = /* @__PURE__ */ vue.createTextVNode("\u4E0A\u79FB");
705
709
  const _hoisted_3$5 = /* @__PURE__ */ vue.createTextVNode("\u4E0B\u79FB");
706
710
  const _hoisted_4$4 = ["innerHTML"];
@@ -712,7 +716,7 @@
712
716
  const _component_CaretRight = vue.resolveComponent("CaretRight");
713
717
  const _component_CaretBottom = vue.resolveComponent("CaretBottom");
714
718
  const _component_m_form_container = vue.resolveComponent("m-form-container");
715
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
719
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
716
720
  vue.createElementVNode("div", null, [
717
721
  vue.createVNode(_component_el_icon, {
718
722
  style: { "margin-right": "7px" },
@@ -829,7 +833,9 @@
829
833
  if (typeof props.config.addable === "function") {
830
834
  return props.config.addable(mForm, {
831
835
  model: props.model[props.name],
832
- formValue: mForm?.values
836
+ formValue: mForm?.values,
837
+ prop: props.prop,
838
+ config: props.config
833
839
  });
834
840
  }
835
841
  return typeof props.config.addable === "undefined" ? true : props.config.addable;
@@ -846,7 +852,9 @@
846
852
  if (typeof props.config.defaultAdd === "function") {
847
853
  initValues = await props.config.defaultAdd(mForm, {
848
854
  model: props.model[props.name],
849
- formValue: mForm?.values
855
+ formValue: mForm?.values,
856
+ prop: props.prop,
857
+ config: props.config
850
858
  });
851
859
  } else if (props.config.defaultAdd) {
852
860
  initValues = props.config.defaultAdd;
@@ -889,7 +897,7 @@
889
897
  };
890
898
  }
891
899
  });
892
- const _hoisted_1$c = { class: "m-fields-group-list" };
900
+ const _hoisted_1$b = { class: "m-fields-group-list" };
893
901
  const _hoisted_2$4 = ["innerHTML"];
894
902
  const _hoisted_3$4 = {
895
903
  key: 1,
@@ -904,7 +912,7 @@
904
912
  function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
905
913
  const _component_m_fields_group_list_item = vue.resolveComponent("m-fields-group-list-item");
906
914
  const _component_el_button = vue.resolveComponent("el-button");
907
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
915
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
908
916
  _ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("div", {
909
917
  key: 0,
910
918
  innerHTML: _ctx.config.extra,
@@ -983,7 +991,7 @@
983
991
  };
984
992
  }
985
993
  });
986
- const _hoisted_1$b = { class: "clearfix" };
994
+ const _hoisted_1$a = { class: "clearfix" };
987
995
  const _hoisted_2$3 = ["innerHTML"];
988
996
  const _hoisted_3$3 = {
989
997
  key: 0,
@@ -1003,7 +1011,7 @@
1003
1011
  "body-style": { display: _ctx.expand ? "block" : "none" }
1004
1012
  }, {
1005
1013
  header: vue.withCtx(() => [
1006
- vue.createElementVNode("div", _hoisted_1$b, [
1014
+ vue.createElementVNode("div", _hoisted_1$a, [
1007
1015
  vue.createElementVNode("a", {
1008
1016
  href: "javascript:",
1009
1017
  style: { "width": "100%", "display": "block" },
@@ -1489,7 +1497,7 @@
1489
1497
  }
1490
1498
  emit("select", selection, row);
1491
1499
  if (typeof props.config.onSelect === "function") {
1492
- props.config.onSelect(mForm, { selection, row });
1500
+ props.config.onSelect(mForm, { selection, row, config: props.config });
1493
1501
  }
1494
1502
  },
1495
1503
  toggleRowSelection(row, selected) {
@@ -1615,7 +1623,7 @@
1615
1623
  };
1616
1624
  }
1617
1625
  });
1618
- const _hoisted_1$a = ["innerHTML"];
1626
+ const _hoisted_1$9 = ["innerHTML"];
1619
1627
  const _hoisted_2$2 = { class: "el-form-item__content" };
1620
1628
  const _hoisted_3$2 = ["innerHTML"];
1621
1629
  const _hoisted_4$1 = /* @__PURE__ */ vue.createTextVNode("\u6DFB\u52A0");
@@ -1644,7 +1652,7 @@
1644
1652
  key: 0,
1645
1653
  style: { "color": "rgba(0, 0, 0, 0.45)" },
1646
1654
  innerHTML: _ctx.config.extra
1647
- }, null, 8, _hoisted_1$a)) : vue.createCommentVNode("", true),
1655
+ }, null, 8, _hoisted_1$9)) : vue.createCommentVNode("", true),
1648
1656
  vue.createElementVNode("div", _hoisted_2$2, [
1649
1657
  vue.createVNode(_component_el_tooltip, {
1650
1658
  content: "\u62D6\u62FD\u53EF\u6392\u5E8F",
@@ -1894,11 +1902,11 @@
1894
1902
  const { config, model, prop } = props;
1895
1903
  tab.name = tab.paneName;
1896
1904
  if (typeof config.onTabClick === "function") {
1897
- config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
1905
+ config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
1898
1906
  }
1899
1907
  const tabConfig = config.items.find((item) => tab.name === item.status);
1900
1908
  if (tabConfig && typeof tabConfig.onTabClick === "function") {
1901
- tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
1909
+ tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
1902
1910
  }
1903
1911
  };
1904
1912
  const Tab = vue.defineComponent({
@@ -1953,7 +1961,11 @@
1953
1961
  if (!props.config.name)
1954
1962
  throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
1955
1963
  if (typeof props.config.onTabAdd === "function") {
1956
- props.config.onTabAdd(mForm, { model: props.model });
1964
+ props.config.onTabAdd(mForm, {
1965
+ model: props.model,
1966
+ prop: props.prop,
1967
+ config: props.config
1968
+ });
1957
1969
  } else if (tabs.value.length > 0) {
1958
1970
  const newObj = lodashEs.cloneDeep(tabs.value[0]);
1959
1971
  newObj.title = `\u6807\u7B7E${tabs.value.length + 1}`;
@@ -1966,7 +1978,11 @@
1966
1978
  if (!props.config.name)
1967
1979
  throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
1968
1980
  if (typeof props.config.onTabRemove === "function") {
1969
- props.config.onTabRemove(mForm, tabName, { model: props.model });
1981
+ props.config.onTabRemove(mForm, tabName, {
1982
+ model: props.model,
1983
+ prop: props.prop,
1984
+ config: props.config
1985
+ });
1970
1986
  } else {
1971
1987
  props.model[props.config.name].splice(+tabName, 1);
1972
1988
  if (tabName < activeTabName.value || activeTabName.value >= props.model[props.config.name].length) {
@@ -1981,7 +1997,7 @@
1981
1997
  changeHandler: () => {
1982
1998
  emit("change", props.model);
1983
1999
  if (typeof props.config.onChange === "function") {
1984
- props.config.onChange(mForm, { model: props.model });
2000
+ props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
1985
2001
  }
1986
2002
  }
1987
2003
  };
@@ -2170,13 +2186,13 @@
2170
2186
  };
2171
2187
  }
2172
2188
  });
2173
- const _hoisted_1$9 = {
2189
+ const _hoisted_1$8 = {
2174
2190
  class: "m-cascader",
2175
2191
  style: { "width": "100%" }
2176
2192
  };
2177
2193
  function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2178
2194
  const _component_el_cascader = vue.resolveComponent("el-cascader");
2179
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2195
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2180
2196
  vue.createVNode(_component_el_cascader, {
2181
2197
  modelValue: _ctx.model[_ctx.name],
2182
2198
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
@@ -2299,7 +2315,7 @@
2299
2315
  }
2300
2316
  var CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$e]]);
2301
2317
 
2302
- const _hoisted_1$8 = { key: 0 };
2318
+ const _hoisted_1$7 = { key: 0 };
2303
2319
  const __default__$2 = vue.defineComponent({
2304
2320
  name: "m-fields-color-picker"
2305
2321
  });
@@ -2319,7 +2335,7 @@
2319
2335
  const changeHandler = (value) => emit("change", value);
2320
2336
  return (_ctx, _cache) => {
2321
2337
  const _component_el_color_picker = vue.resolveComponent("el-color-picker");
2322
- return _ctx.model ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2338
+ return _ctx.model ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
2323
2339
  vue.createVNode(_component_el_color_picker, {
2324
2340
  modelValue: _ctx.model[_ctx.name],
2325
2341
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
@@ -2355,10 +2371,10 @@
2355
2371
  };
2356
2372
  }
2357
2373
  });
2358
- const _hoisted_1$7 = { key: 0 };
2374
+ const _hoisted_1$6 = { key: 0 };
2359
2375
  function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2360
2376
  const _component_el_date_picker = vue.resolveComponent("el-date-picker");
2361
- return _ctx.model ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
2377
+ return _ctx.model ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2362
2378
  vue.createVNode(_component_el_date_picker, {
2363
2379
  modelValue: _ctx.model[_ctx.modelName],
2364
2380
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.modelName] = $event),
@@ -2425,20 +2441,19 @@
2425
2441
  });
2426
2442
  function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2427
2443
  const _component_el_date_picker = vue.resolveComponent("el-date-picker");
2428
- return vue.openBlock(), vue.createElementBlock("div", null, [
2429
- vue.createVNode(_component_el_date_picker, {
2430
- modelValue: _ctx.value,
2431
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
2432
- type: "datetimerange",
2433
- "range-separator": "-",
2434
- "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2435
- "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2436
- size: _ctx.size,
2437
- "unlink-panels": true,
2438
- disabled: _ctx.disabled,
2439
- onChange: _ctx.changeHandler
2440
- }, null, 8, ["modelValue", "size", "disabled", "onChange"])
2441
- ]);
2444
+ return vue.openBlock(), vue.createBlock(_component_el_date_picker, {
2445
+ modelValue: _ctx.value,
2446
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
2447
+ type: "datetimerange",
2448
+ "range-separator": "-",
2449
+ "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2450
+ "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2451
+ size: _ctx.size,
2452
+ "unlink-panels": true,
2453
+ disabled: _ctx.disabled,
2454
+ "default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
2455
+ onChange: _ctx.changeHandler
2456
+ }, null, 8, ["modelValue", "size", "disabled", "default-time", "onChange"]);
2442
2457
  }
2443
2458
  var Daterange = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$c]]);
2444
2459
 
@@ -2470,23 +2485,21 @@
2470
2485
  };
2471
2486
  }
2472
2487
  });
2473
- const _hoisted_1$6 = { key: 0 };
2474
2488
  function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2475
2489
  const _component_el_date_picker = vue.resolveComponent("el-date-picker");
2476
- return _ctx.model ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2477
- vue.createVNode(_component_el_date_picker, {
2478
- modelValue: _ctx.model[_ctx.name],
2479
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
2480
- "popper-class": "magic-datetime-picker-popper",
2481
- type: "datetime",
2482
- size: _ctx.size,
2483
- placeholder: _ctx.config.placeholder,
2484
- disabled: _ctx.disabled,
2485
- format: _ctx.config.format || "YYYY-MM-DD HH:mm:ss",
2486
- "value-format": _ctx.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
2487
- onChange: _ctx.changeHandler
2488
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "onChange"])
2489
- ])) : vue.createCommentVNode("", true);
2490
+ return vue.openBlock(), vue.createBlock(_component_el_date_picker, {
2491
+ modelValue: _ctx.model[_ctx.name],
2492
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
2493
+ "popper-class": "magic-datetime-picker-popper",
2494
+ type: "datetime",
2495
+ size: _ctx.size,
2496
+ placeholder: _ctx.config.placeholder,
2497
+ disabled: _ctx.disabled,
2498
+ format: _ctx.config.format || "YYYY-MM-DD HH:mm:ss",
2499
+ "value-format": _ctx.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
2500
+ "default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
2501
+ onChange: _ctx.changeHandler
2502
+ }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time", "onChange"]);
2490
2503
  }
2491
2504
  var DateTime = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$b]]);
2492
2505
 
@@ -2908,7 +2921,8 @@
2908
2921
  body = body(mForm, {
2909
2922
  model: props.model,
2910
2923
  formValue: mForm?.values,
2911
- formValues: mForm?.values
2924
+ formValues: mForm?.values,
2925
+ config: props.config
2912
2926
  });
2913
2927
  }
2914
2928
  body.query = query.value;
@@ -2931,7 +2945,8 @@
2931
2945
  res = option.afterRequest(mForm, res, {
2932
2946
  model: props.model,
2933
2947
  formValue: mForm?.values,
2934
- formValues: mForm?.values
2948
+ formValues: mForm?.values,
2949
+ config: props.config
2935
2950
  });
2936
2951
  }
2937
2952
  const optionsData = res[option.root];
@@ -3023,7 +3038,8 @@
3023
3038
  model: props.model,
3024
3039
  prop: props.prop,
3025
3040
  formValues: mForm?.values,
3026
- formValue: mForm?.values
3041
+ formValue: mForm?.values,
3042
+ config: props.config
3027
3043
  })).then((data) => {
3028
3044
  options.value = data;
3029
3045
  });