@tmagic/form 1.6.1 → 1.7.0-beta.1

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.
Files changed (42) hide show
  1. package/dist/style.css +23 -3
  2. package/dist/tmagic-form.js +1741 -1501
  3. package/dist/tmagic-form.umd.cjs +1774 -1530
  4. package/package.json +4 -4
  5. package/src/Form.vue +70 -9
  6. package/src/containers/Container.vue +109 -134
  7. package/src/containers/Fieldset.vue +31 -7
  8. package/src/containers/FlexLayout.vue +59 -0
  9. package/src/containers/Tabs.vue +11 -1
  10. package/src/fields/Cascader.vue +25 -16
  11. package/src/fields/Checkbox.vue +3 -3
  12. package/src/fields/CheckboxGroup.vue +1 -1
  13. package/src/fields/ColorPicker.vue +2 -2
  14. package/src/fields/Date.vue +2 -2
  15. package/src/fields/DateTime.vue +2 -2
  16. package/src/fields/Daterange.vue +2 -2
  17. package/src/fields/Number.vue +2 -2
  18. package/src/fields/NumberRange.vue +6 -6
  19. package/src/fields/RadioGroup.vue +7 -15
  20. package/src/fields/Select.vue +2 -2
  21. package/src/fields/Switch.vue +2 -2
  22. package/src/fields/Text.vue +20 -8
  23. package/src/fields/Textarea.vue +3 -2
  24. package/src/fields/Time.vue +2 -2
  25. package/src/fields/Timerange.vue +2 -2
  26. package/src/index.ts +5 -2
  27. package/src/table/ActionsColumn.vue +97 -0
  28. package/src/table/SortColumn.vue +101 -0
  29. package/src/table/Table.vue +170 -0
  30. package/src/table/type.ts +18 -0
  31. package/src/table/useAdd.ts +111 -0
  32. package/src/table/useFullscreen.ts +28 -0
  33. package/src/table/useImport.ts +68 -0
  34. package/src/table/usePagination.ts +30 -0
  35. package/src/table/useSelection.ts +34 -0
  36. package/src/table/useSortable.ts +48 -0
  37. package/src/table/useTableColumns.ts +194 -0
  38. package/src/theme/container.scss +17 -0
  39. package/src/theme/form.scss +15 -3
  40. package/src/utils/form.ts +56 -2
  41. package/types/index.d.ts +65 -36
  42. package/src/containers/Table.vue +0 -681
@@ -1,12 +1,12 @@
1
- import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, createElementBlock, createCommentVNode, openBlock, normalizeClass, normalizeStyle, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, shallowRef, withModifiers, onBeforeMount, nextTick, resolveDirective, createSlots } from 'vue';
1
+ import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, createElementBlock, openBlock, normalizeStyle, normalizeClass, createBlock, createCommentVNode, mergeProps, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, renderList, createTextVNode, toDisplayString, readonly, withDirectives, vShow, renderSlot, getCurrentInstance, createSlots, reactive, onBeforeUnmount, vModelText, useTemplateRef, provide, shallowRef, onBeforeMount, nextTick, resolveDirective, withModifiers, Teleport, h } from 'vue';
2
2
  import { WarningFilled, CaretBottom, CaretRight, Delete, DocumentCopy, CaretTop, Position, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
3
3
  import { cloneDeep, isEqual, isEmpty, debounce } from 'lodash-es';
4
- import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicPopover, TMagicInputNumber, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, tMagicMessageBox, TMagicDialog, TMagicRadioButton, TMagicRadio, TMagicRadioGroup, TMagicSelect, TMagicSwitch, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
5
- import { setValueByKeyPath, asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
4
+ import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicPopover, TMagicInputNumber, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, getDesignConfig, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, tMagicMessage, tMagicMessageBox, TMagicDialog, TMagicRadioButton, TMagicRadio, TMagicRadioGroup, TMagicSelect, TMagicSwitch, TMagicTimePicker, useZIndex, TMagicTable, TMagicUpload, TMagicPagination, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
5
+ import { getValueByKeyPath, setValueByKeyPath, isNumber, asyncLoadJs } from '@tmagic/utils';
6
6
  import dayjs from 'dayjs';
7
7
  import utc from 'dayjs/plugin/utc';
8
- import Sortable from 'sortablejs';
9
8
  import { createPopper } from '@popperjs/core';
9
+ import Sortable from 'sortablejs';
10
10
  export * from '@tmagic/form-schema';
11
11
 
12
12
  const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
@@ -38,8 +38,10 @@ const setValue = (mForm, value, initValue2, item) => {
38
38
  value[name] = getDefaultValue(mForm, item);
39
39
  }
40
40
  if (type === "fieldset" && checkbox) {
41
- if (typeof value[name] === "object") {
42
- value[name].value = typeof initValue2[name] === "object" ? initValue2[name].value || 0 : 0;
41
+ const checkboxName = typeof checkbox === "object" && typeof checkbox.name === "string" ? checkbox.name : "value";
42
+ const checkboxFalseValue = typeof checkbox === "object" && typeof checkbox.falseValue !== "undefined" ? checkbox.falseValue : 0;
43
+ if (name && typeof value[name] === "object") {
44
+ value[name][checkboxName] = typeof initValue2[name] === "object" ? initValue2[name][checkboxName] || checkboxFalseValue : checkboxFalseValue;
43
45
  }
44
46
  }
45
47
  };
@@ -69,6 +71,16 @@ const initValueItem = function(mForm, item, initValue2, value) {
69
71
  return createValues(mForm, items, initValue2, value);
70
72
  }
71
73
  setValue(mForm, value, initValue2, item);
74
+ if (type === "table") {
75
+ if (item.defautSort) {
76
+ sortChange(value[name], item.defautSort);
77
+ } else if (item.defaultSort) {
78
+ sortChange(value[name], item.defaultSort);
79
+ }
80
+ if (item.sort && item.sortKey) {
81
+ value[name].sort((a, b) => b[item.sortKey] - a[item.sortKey]);
82
+ }
83
+ }
72
84
  return value;
73
85
  };
74
86
  const createValues = function(mForm, config = [], initValue2 = {}, value = {}) {
@@ -109,7 +121,8 @@ const filterFunction = (mForm, config, props) => {
109
121
  formValue: mForm?.values || props.model,
110
122
  prop: props.prop,
111
123
  config: props.config,
112
- index: props.index
124
+ index: props.index,
125
+ getFormValue: (prop) => getValueByKeyPath(prop, mForm?.values || props.model)
113
126
  });
114
127
  }
115
128
  return config;
@@ -186,25 +199,47 @@ const datetimeFormatter = (v, defaultValue = "-", format = "YYYY-MM-DD HH:mm:ss"
186
199
  }
187
200
  return defaultValue;
188
201
  };
202
+ const getDataByPage = (data = [], pagecontext, pagesize) => data.filter(
203
+ (item, index) => index >= pagecontext * pagesize && index + 1 <= (pagecontext + 1) * pagesize
204
+ );
205
+ const sortArray = (data, newIndex, oldIndex, sortKey) => {
206
+ if (newIndex === oldIndex) {
207
+ return data;
208
+ }
209
+ if (newIndex < 0 || newIndex >= data.length || oldIndex < 0 || oldIndex >= data.length) {
210
+ return data;
211
+ }
212
+ const newData = data.toSpliced(newIndex, 0, ...data.splice(oldIndex, 1));
213
+ if (sortKey) {
214
+ for (let i = newData.length - 1, v = 0; i >= 0; i--, v++) {
215
+ newData[v][sortKey] = i;
216
+ }
217
+ }
218
+ return newData;
219
+ };
220
+ const sortChange = (data, { prop, order }) => {
221
+ if (order === "ascending") {
222
+ data = data.sort((a, b) => a[prop] - b[prop]);
223
+ } else if (order === "descending") {
224
+ data = data.sort((a, b) => b[prop] - a[prop]);
225
+ }
226
+ };
189
227
 
190
- const _hoisted_1$e = ["data-tmagic-id", "data-tmagic-form-item-prop"];
228
+ const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
191
229
  const _hoisted_2$7 = ["innerHTML", "title"];
192
- const _hoisted_3$5 = ["innerHTML"];
230
+ const _hoisted_3$6 = ["innerHTML"];
193
231
  const _hoisted_4$3 = ["innerHTML"];
194
- const _hoisted_5$3 = ["innerHTML"];
195
- const _hoisted_6$2 = ["innerHTML", "title"];
232
+ const _hoisted_5$3 = ["innerHTML", "title"];
233
+ const _hoisted_6$1 = ["innerHTML"];
196
234
  const _hoisted_7$1 = ["innerHTML"];
197
- const _hoisted_8$1 = ["innerHTML"];
235
+ const _hoisted_8$1 = ["innerHTML", "title"];
198
236
  const _hoisted_9 = ["innerHTML"];
199
- const _hoisted_10 = ["innerHTML", "title"];
200
- const _hoisted_11 = ["innerHTML"];
201
- const _hoisted_12 = ["innerHTML"];
202
- const _hoisted_13 = ["innerHTML"];
203
- const _hoisted_14 = {
237
+ const _hoisted_10 = ["innerHTML"];
238
+ const _hoisted_11 = {
204
239
  key: 5,
205
240
  style: { "text-align": "center" }
206
241
  };
207
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
242
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
208
243
  ...{
209
244
  name: "MFormContainer"
210
245
  },
@@ -258,8 +293,19 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
258
293
  });
259
294
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
260
295
  const text = computed(() => filterFunction(mForm, props.config.text, props));
261
- const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
262
- const extra = computed(() => filterFunction(mForm, props.config.extra, props));
296
+ const tooltip = computed(() => {
297
+ const config = filterFunction(mForm, props.config.tooltip, props);
298
+ if (typeof config === "string") {
299
+ return {
300
+ text: config,
301
+ placement: "top"
302
+ };
303
+ }
304
+ return {
305
+ text: config?.text,
306
+ placement: config?.placement || "top"
307
+ };
308
+ });
263
309
  const rule = computed(() => getRules(mForm, props.config.rules, props));
264
310
  const type = computed(() => {
265
311
  let { type: type2 } = props.config;
@@ -275,6 +321,22 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
275
321
  }
276
322
  return value;
277
323
  });
324
+ const fieldsProps = computed(() => ({
325
+ size: props.size,
326
+ config: props.config,
327
+ name: name.value,
328
+ disabled: disabled.value,
329
+ prop: itemProp.value,
330
+ key: props.config[mForm?.keyProps],
331
+ style: props.config.fieldStyle
332
+ }));
333
+ const formItemProps = computed(() => ({
334
+ prop: itemProp.value,
335
+ labelWidth: itemLabelWidth.value,
336
+ labelPosition: props.config.labelPosition,
337
+ rules: rule.value,
338
+ extra: filterFunction(mForm, props.config.extra, props)
339
+ }));
278
340
  const itemLabelWidth = computed(() => props.config.labelWidth ?? props.labelWidth);
279
341
  watchEffect(() => {
280
342
  expand.value = props.expandMore;
@@ -301,7 +363,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
301
363
  values: mForm?.initValues,
302
364
  formValue: mForm?.values,
303
365
  prop: itemProp.value,
304
- config: props.config
366
+ config: props.config,
367
+ getFormValue: (prop) => getValueByKeyPath(prop, mForm?.values || props.model)
305
368
  });
306
369
  }
307
370
  if (filter === "number") {
@@ -329,27 +392,50 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
329
392
  }
330
393
  return true;
331
394
  };
395
+ const createModelProxy = (target, setModelFn, pathPrefix = "") => {
396
+ return new Proxy(target, {
397
+ get: (obj, key2) => {
398
+ const value = obj[key2];
399
+ if (value && typeof value === "object") {
400
+ const newPath = pathPrefix ? `${pathPrefix}.${key2}` : key2;
401
+ return createModelProxy(value, setModelFn, newPath);
402
+ }
403
+ return value;
404
+ },
405
+ set: (obj, key2, value) => {
406
+ setModelFn(pathPrefix ? `${pathPrefix}.${key2}` : key2, value);
407
+ return true;
408
+ }
409
+ });
410
+ };
332
411
  const onChangeHandler = async function(v, eventData = {}) {
333
- const { filter, onChange, trim, dynamicKey } = props.config;
412
+ const { filter, onChange, trim } = props.config;
334
413
  let value = toRaw(v);
335
414
  const changeRecords = eventData.changeRecords || [];
336
415
  const newChangeRecords = [...changeRecords];
337
416
  try {
338
417
  value = filterHandler(filter, v);
339
418
  if (typeof onChange === "function") {
419
+ const setModel = (key2, value2) => {
420
+ if (props.config.name) {
421
+ newChangeRecords.push({ propPath: itemProp.value.replace(`${props.config.name}`, key2), value: value2 });
422
+ } else {
423
+ newChangeRecords.push({ propPath: itemProp.value, value: value2 });
424
+ }
425
+ };
426
+ const setFormValue = (key2, value2) => {
427
+ newChangeRecords.push({ propPath: key2, value: value2 });
428
+ };
340
429
  value = await onChange(mForm, value, {
341
- model: props.model,
342
- values: mForm?.initValues,
343
- formValue: mForm?.values,
430
+ model: createModelProxy(props.model, setModel),
431
+ values: mForm ? readonly(mForm.initValues) : null,
432
+ formValue: createModelProxy(mForm?.values || {}, setFormValue),
344
433
  prop: itemProp.value,
345
434
  config: props.config,
346
435
  changeRecords: newChangeRecords,
347
- setModel: (key2, value2) => {
348
- setValueByKeyPath(key2, value2, props.model);
349
- if (props.config.name) {
350
- newChangeRecords.push({ propPath: itemProp.value.replace(`${props.config.name}`, key2), value: value2 });
351
- }
352
- }
436
+ setModel,
437
+ setFormValue,
438
+ getFormValue: (prop) => getValueByKeyPath(prop, mForm?.values || props.model)
353
439
  }) ?? value;
354
440
  }
355
441
  value = trimHandler(trim, value) ?? value;
@@ -358,15 +444,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
358
444
  }
359
445
  let valueProp = itemProp.value;
360
446
  if (hasModifyKey(eventData)) {
361
- if (dynamicKey) {
362
- props.model[eventData.modifyKey] = value;
363
- } else if (isValidName()) {
364
- props.model[name.value][eventData.modifyKey] = value;
365
- }
366
447
  valueProp = valueProp ? `${valueProp}.${eventData.modifyKey}` : eventData.modifyKey;
367
448
  delete eventData.modifyKey;
368
- } else if (isValidName() && props.model !== value && (v !== value || props.model[name.value] !== value)) {
369
- props.model[name.value] = value;
370
449
  }
371
450
  if (changeRecords.length === 0) {
372
451
  newChangeRecords.push({
@@ -382,95 +461,65 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
382
461
  return (_ctx, _cache) => {
383
462
  const _component_m_fields_hidden = resolveComponent("m-fields-hidden");
384
463
  const _component_Container = resolveComponent("Container", true);
385
- return __props.config ? (openBlock(), createElementBlock("div", {
386
- key: 0,
464
+ return openBlock(), createElementBlock("div", {
387
465
  "data-tmagic-id": __props.config.id,
388
466
  "data-tmagic-form-item-prop": itemProp.value,
389
- style: normalizeStyle(__props.config.tip ? "display: flex;align-items: baseline;" : ""),
390
- class: normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}`)
467
+ class: normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}${__props.config.tip ? " has-tip" : ""}`),
468
+ style: normalizeStyle(__props.config.style)
391
469
  }, [
392
- type.value === "hidden" ? (openBlock(), createBlock(_component_m_fields_hidden, {
393
- key: 0,
394
- model: __props.model,
395
- config: __props.config,
396
- name: __props.config.name,
397
- disabled: disabled.value,
398
- prop: itemProp.value
399
- }, null, 8, ["model", "config", "name", "disabled", "prop"])) : items.value && !text.value && type.value && display$1.value ? (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
400
- key: key(__props.config),
401
- size: __props.size,
470
+ type.value === "hidden" ? (openBlock(), createBlock(_component_m_fields_hidden, mergeProps({ key: 0 }, fieldsProps.value, { model: __props.model }), null, 16, ["model"])) : items.value && !text.value && type.value && display$1.value ? (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
402
471
  model: __props.model,
403
472
  "last-values": __props.lastValues,
404
473
  "is-compare": __props.isCompare,
405
- config: __props.config,
406
- disabled: disabled.value,
407
- name: name.value,
408
- prop: itemProp.value,
409
474
  "step-active": __props.stepActive,
410
475
  "expand-more": expand.value,
411
476
  "label-width": itemLabelWidth.value,
477
+ style: __props.config.fieldStyle,
412
478
  onChange: onChangeHandler,
413
479
  onAddDiffCount
414
- }, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(
480
+ }), null, 16, ["model", "last-values", "is-compare", "step-active", "expand-more", "label-width", "style"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(
415
481
  Fragment,
416
482
  { key: 2 },
417
483
  [
418
- createVNode(unref(TMagicFormItem), {
419
- style: normalizeStyle(__props.config.tip ? "flex: 1" : ""),
420
- class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
421
- prop: itemProp.value,
422
- "label-width": itemLabelWidth.value,
423
- "label-position": __props.config.labelPosition,
424
- rules: rule.value
425
- }, {
484
+ createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
485
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }
486
+ }), {
426
487
  label: withCtx(() => [
427
488
  createElementVNode("span", {
428
- innerHTML: type.value === "checkbox" ? "" : text.value,
489
+ innerHTML: type.value === "checkbox" && !__props.config.useLabel ? "" : text.value,
429
490
  title: __props.config.labelTitle
430
491
  }, null, 8, _hoisted_2$7)
431
492
  ]),
432
493
  default: withCtx(() => [
433
- tooltip.value ? (openBlock(), createBlock(unref(TMagicTooltip), { key: 0 }, {
494
+ tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
495
+ key: 0,
496
+ placement: tooltip.value.placement
497
+ }, {
434
498
  content: withCtx(() => [
435
- createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$5)
499
+ createElementVNode("div", {
500
+ innerHTML: tooltip.value.text
501
+ }, null, 8, _hoisted_3$6)
436
502
  ]),
437
503
  default: withCtx(() => [
438
- (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
439
- key: key(__props.config),
440
- size: __props.size,
504
+ (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
441
505
  model: __props.model,
442
506
  "last-values": __props.lastValues,
443
- config: __props.config,
444
- name: name.value,
445
- disabled: disabled.value,
446
- prop: itemProp.value,
447
507
  onChange: onChangeHandler,
448
508
  onAddDiffCount
449
- }, null, 40, ["size", "model", "last-values", "config", "name", "disabled", "prop"]))
509
+ }), null, 16, ["model", "last-values"]))
450
510
  ]),
451
511
  _: 1
452
512
  /* STABLE */
453
- })) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
454
- key: key(__props.config),
455
- size: __props.size,
513
+ }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
456
514
  model: __props.model,
457
515
  "last-values": __props.lastValues,
458
- config: __props.config,
459
- name: name.value,
460
- disabled: disabled.value,
461
- prop: itemProp.value,
462
516
  onChange: onChangeHandler,
463
517
  onAddDiffCount
464
- }, null, 40, ["size", "model", "last-values", "config", "name", "disabled", "prop"])),
465
- extra.value && type.value !== "table" ? (openBlock(), createElementBlock("div", {
466
- key: 2,
467
- innerHTML: extra.value,
468
- class: "m-form-tip"
469
- }, null, 8, _hoisted_4$3)) : createCommentVNode("v-if", true)
518
+ }), null, 16, ["model", "last-values"]))
470
519
  ]),
471
520
  _: 1
472
521
  /* STABLE */
473
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
522
+ }, 16, ["class"]),
474
523
  __props.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
475
524
  key: 0,
476
525
  placement: "left"
@@ -478,7 +527,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
478
527
  content: withCtx(() => [
479
528
  createElementVNode("div", {
480
529
  innerHTML: __props.config.tip
481
- }, null, 8, _hoisted_5$3)
530
+ }, null, 8, _hoisted_4$3)
482
531
  ]),
483
532
  default: withCtx(() => [
484
533
  createVNode(unref(TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -501,58 +550,41 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
501
550
  [
502
551
  createCommentVNode(" 对比 "),
503
552
  createCommentVNode(" 上次内容 "),
504
- createVNode(unref(TMagicFormItem), {
505
- style: normalizeStyle([__props.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
506
- class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
507
- prop: itemProp.value,
508
- "label-width": itemLabelWidth.value,
509
- "label-position": __props.config.labelPosition,
510
- rules: rule.value
511
- }, {
553
+ createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
554
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value, "show-diff": true }
555
+ }), {
512
556
  label: withCtx(() => [
513
557
  createElementVNode("span", {
514
558
  innerHTML: type.value === "checkbox" ? "" : text.value,
515
559
  title: __props.config.labelTitle
516
- }, null, 8, _hoisted_6$2)
560
+ }, null, 8, _hoisted_5$3)
517
561
  ]),
518
562
  default: withCtx(() => [
519
- tooltip.value ? (openBlock(), createBlock(unref(TMagicTooltip), { key: 0 }, {
563
+ tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
564
+ key: 0,
565
+ placement: tooltip.value.placement
566
+ }, {
520
567
  content: withCtx(() => [
521
- createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_7$1)
568
+ createElementVNode("div", {
569
+ innerHTML: tooltip.value.text
570
+ }, null, 8, _hoisted_6$1)
522
571
  ]),
523
572
  default: withCtx(() => [
524
- (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
525
- key: key(__props.config),
526
- size: __props.size,
573
+ (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
527
574
  model: __props.lastValues,
528
- config: __props.config,
529
- name: name.value,
530
- disabled: disabled.value,
531
- prop: itemProp.value,
532
575
  onChange: onChangeHandler
533
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"]))
576
+ }), null, 16, ["model"]))
534
577
  ]),
535
578
  _: 1
536
579
  /* STABLE */
537
- })) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
538
- key: key(__props.config),
539
- size: __props.size,
580
+ }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
540
581
  model: __props.lastValues,
541
- config: __props.config,
542
- name: name.value,
543
- disabled: disabled.value,
544
- prop: itemProp.value,
545
582
  onChange: onChangeHandler
546
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"])),
547
- extra.value ? (openBlock(), createElementBlock("div", {
548
- key: 2,
549
- innerHTML: extra.value,
550
- class: "m-form-tip"
551
- }, null, 8, _hoisted_8$1)) : createCommentVNode("v-if", true)
583
+ }), null, 16, ["model"]))
552
584
  ]),
553
585
  _: 1
554
586
  /* STABLE */
555
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
587
+ }, 16, ["class"]),
556
588
  __props.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
557
589
  key: 0,
558
590
  placement: "left"
@@ -560,7 +592,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
560
592
  content: withCtx(() => [
561
593
  createElementVNode("div", {
562
594
  innerHTML: __props.config.tip
563
- }, null, 8, _hoisted_9)
595
+ }, null, 8, _hoisted_7$1)
564
596
  ]),
565
597
  default: withCtx(() => [
566
598
  createVNode(unref(TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -575,58 +607,42 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
575
607
  /* STABLE */
576
608
  })) : createCommentVNode("v-if", true),
577
609
  createCommentVNode(" 当前内容 "),
578
- createVNode(unref(TMagicFormItem), {
579
- style: normalizeStyle([__props.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
580
- class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
581
- prop: itemProp.value,
582
- "label-width": itemLabelWidth.value,
583
- "label-position": __props.config.labelPosition,
584
- rules: rule.value
585
- }, {
610
+ createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
611
+ style: __props.config.tip ? "flex: 1" : "",
612
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value, "show-diff": true }
613
+ }), {
586
614
  label: withCtx(() => [
587
615
  createElementVNode("span", {
588
616
  innerHTML: type.value === "checkbox" ? "" : text.value,
589
617
  title: __props.config.labelTitle
590
- }, null, 8, _hoisted_10)
618
+ }, null, 8, _hoisted_8$1)
591
619
  ]),
592
620
  default: withCtx(() => [
593
- tooltip.value ? (openBlock(), createBlock(unref(TMagicTooltip), { key: 0 }, {
621
+ tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
622
+ key: 0,
623
+ placement: tooltip.value.placement
624
+ }, {
594
625
  content: withCtx(() => [
595
- createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_11)
626
+ createElementVNode("div", {
627
+ innerHTML: tooltip.value.text
628
+ }, null, 8, _hoisted_9)
596
629
  ]),
597
630
  default: withCtx(() => [
598
- (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
599
- key: key(__props.config),
600
- size: __props.size,
631
+ (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
601
632
  model: __props.model,
602
- config: __props.config,
603
- name: name.value,
604
- disabled: disabled.value,
605
- prop: itemProp.value,
606
633
  onChange: onChangeHandler
607
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"]))
634
+ }), null, 16, ["model"]))
608
635
  ]),
609
636
  _: 1
610
637
  /* STABLE */
611
- })) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
612
- key: key(__props.config),
613
- size: __props.size,
638
+ }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
614
639
  model: __props.model,
615
- config: __props.config,
616
- name: name.value,
617
- disabled: disabled.value,
618
- prop: itemProp.value,
619
640
  onChange: onChangeHandler
620
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"])),
621
- extra.value ? (openBlock(), createElementBlock("div", {
622
- key: 2,
623
- innerHTML: extra.value,
624
- class: "m-form-tip"
625
- }, null, 8, _hoisted_12)) : createCommentVNode("v-if", true)
641
+ }), null, 16, ["model"]))
626
642
  ]),
627
643
  _: 1
628
644
  /* STABLE */
629
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
645
+ }, 16, ["style", "class"]),
630
646
  __props.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
631
647
  key: 1,
632
648
  placement: "left"
@@ -634,7 +650,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
634
650
  content: withCtx(() => [
635
651
  createElementVNode("div", {
636
652
  innerHTML: __props.config.tip
637
- }, null, 8, _hoisted_13)
653
+ }, null, 8, _hoisted_10)
638
654
  ]),
639
655
  default: withCtx(() => [
640
656
  createVNode(unref(TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -682,7 +698,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
682
698
  64
683
699
  /* STABLE_FRAGMENT */
684
700
  )) : createCommentVNode("v-if", true),
685
- __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_14, [
701
+ __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_11, [
686
702
  createVNode(unref(TMagicButton), {
687
703
  type: "primary",
688
704
  size: "small",
@@ -701,23 +717,23 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
701
717
  /* STABLE */
702
718
  })
703
719
  ])) : createCommentVNode("v-if", true)
704
- ], 14, _hoisted_1$e)) : createCommentVNode("v-if", true);
720
+ ], 14, _hoisted_1$d);
705
721
  };
706
722
  }
707
723
  });
708
724
 
709
- const _hoisted_1$d = ["innerHTML"];
725
+ const _hoisted_1$c = ["innerHTML"];
710
726
  const _hoisted_2$6 = ["innerHTML"];
711
- const _hoisted_3$4 = { key: 1 };
727
+ const _hoisted_3$5 = { key: 1 };
712
728
  const _hoisted_4$2 = ["innerHTML"];
713
729
  const _hoisted_5$2 = ["innerHTML"];
714
- const _hoisted_6$1 = {
730
+ const _hoisted_6 = {
715
731
  key: 2,
716
732
  style: { "display": "flex" }
717
733
  };
718
734
  const _hoisted_7 = { style: { "flex": "1" } };
719
735
  const _hoisted_8 = ["src"];
720
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
736
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
721
737
  ...{
722
738
  name: "MFormFieldset"
723
739
  },
@@ -739,9 +755,27 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
739
755
  const emit = __emit;
740
756
  const mForm = inject("mForm");
741
757
  const name = computed(() => props.config.name || "");
758
+ const checkboxName = computed(() => {
759
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.name === "string") {
760
+ return props.config.checkbox.name;
761
+ }
762
+ return "value";
763
+ });
764
+ const checkboxTrueValue = computed(() => {
765
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.trueValue !== "undefined") {
766
+ return props.config.checkbox.trueValue;
767
+ }
768
+ return 1;
769
+ });
770
+ const checkboxFalseValue = computed(() => {
771
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.falseValue !== "undefined") {
772
+ return props.config.checkbox.falseValue;
773
+ }
774
+ return 0;
775
+ });
742
776
  const show = computed(() => {
743
- if (props.config.expand && name.value) {
744
- return props.model[name.value]?.value;
777
+ if (props.config.expand && checkboxName.value) {
778
+ return (name.value ? props.model[name.value] : props.model)?.[checkboxName.value] === checkboxTrueValue.value;
745
779
  }
746
780
  return true;
747
781
  });
@@ -752,7 +786,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
752
786
  return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
753
787
  });
754
788
  const valueChangeHandler = (value) => {
755
- emit("change", value, { modifyKey: "value" });
789
+ emit("change", value, { modifyKey: checkboxName.value });
756
790
  };
757
791
  const changeHandler = (v, eventData) => emit("change", v, eventData);
758
792
  const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
@@ -769,19 +803,16 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
769
803
  name.value && __props.config.checkbox ? (openBlock(), createBlock(resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
770
804
  default: withCtx(() => [
771
805
  createVNode(unref(TMagicCheckbox), {
772
- modelValue: __props.model[name.value].value,
773
- "onUpdate:modelValue": [
774
- _cache[0] || (_cache[0] = ($event) => __props.model[name.value].value = $event),
775
- valueChangeHandler
776
- ],
777
- prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.value`,
778
- "true-value": 1,
779
- "false-value": 0
806
+ "model-value": (name.value ? __props.model[name.value] : __props.model)[checkboxName.value],
807
+ prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.${checkboxName.value}`,
808
+ "true-value": checkboxTrueValue.value,
809
+ "false-value": checkboxFalseValue.value,
810
+ "onUpdate:modelValue": valueChangeHandler
780
811
  }, {
781
812
  default: withCtx(() => [
782
813
  createElementVNode("span", {
783
814
  innerHTML: __props.config.legend
784
- }, null, 8, _hoisted_1$d),
815
+ }, null, 8, _hoisted_1$c),
785
816
  __props.config.extra ? (openBlock(), createElementBlock("span", {
786
817
  key: 0,
787
818
  innerHTML: __props.config.extra,
@@ -790,11 +821,11 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
790
821
  ]),
791
822
  _: 1
792
823
  /* STABLE */
793
- }, 8, ["modelValue", "prop"])
824
+ }, 8, ["model-value", "prop", "true-value", "false-value"])
794
825
  ]),
795
826
  _: 1
796
827
  /* STABLE */
797
- })) : (openBlock(), createElementBlock("legend", _hoisted_3$4, [
828
+ })) : (openBlock(), createElementBlock("legend", _hoisted_3$5, [
798
829
  createElementVNode("span", {
799
830
  innerHTML: __props.config.legend
800
831
  }, null, 8, _hoisted_4$2),
@@ -804,13 +835,13 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
804
835
  class: "m-form-tip"
805
836
  }, null, 8, _hoisted_5$2)) : createCommentVNode("v-if", true)
806
837
  ])),
807
- __props.config.schematic && show.value ? (openBlock(), createElementBlock("div", _hoisted_6$1, [
838
+ __props.config.schematic && show.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
808
839
  createElementVNode("div", _hoisted_7, [
809
840
  (openBlock(true), createElementBlock(
810
841
  Fragment,
811
842
  null,
812
843
  renderList(__props.config.items, (item, index) => {
813
- return openBlock(), createBlock(_sfc_main$x, {
844
+ return openBlock(), createBlock(_sfc_main$A, {
814
845
  key: key(item, index),
815
846
  model: name.value ? __props.model[name.value] : __props.model,
816
847
  lastValues: name.value ? __props.lastValues[name.value] : __props.lastValues,
@@ -822,7 +853,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
822
853
  labelWidth: lWidth.value,
823
854
  size: __props.size,
824
855
  onChange: changeHandler,
825
- onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
856
+ onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
826
857
  }, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
827
858
  }),
828
859
  128
@@ -837,7 +868,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
837
868
  Fragment,
838
869
  { key: 3 },
839
870
  renderList(__props.config.items, (item, index) => {
840
- return openBlock(), createBlock(_sfc_main$x, {
871
+ return openBlock(), createBlock(_sfc_main$A, {
841
872
  key: key(item, index),
842
873
  model: name.value ? __props.model[name.value] : __props.model,
843
874
  lastValues: name.value ? __props.lastValues[name.value] : __props.lastValues,
@@ -849,7 +880,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
849
880
  size: __props.size,
850
881
  disabled: __props.disabled,
851
882
  onChange: changeHandler,
852
- onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
883
+ onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
853
884
  }, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
854
885
  }),
855
886
  128
@@ -863,10 +894,73 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
863
894
  }
864
895
  });
865
896
 
866
- const _hoisted_1$c = { class: "m-fields-group-list-item" };
897
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
898
+ ...{
899
+ name: "MFormFlexLayout"
900
+ },
901
+ __name: "FlexLayout",
902
+ props: {
903
+ model: {},
904
+ lastValues: {},
905
+ isCompare: { type: Boolean },
906
+ config: {},
907
+ name: {},
908
+ labelWidth: {},
909
+ prop: {},
910
+ size: {},
911
+ disabled: { type: Boolean }
912
+ },
913
+ emits: ["change", "addDiffCount"],
914
+ setup(__props, { emit: __emit }) {
915
+ const props = __props;
916
+ const emit = __emit;
917
+ const mForm = inject("mForm");
918
+ const gap = computed(() => props.config.gap || "16px");
919
+ const changeHandler = (v, eventData) => {
920
+ emit("change", props.model, eventData);
921
+ };
922
+ const onAddDiffCount = () => emit("addDiffCount");
923
+ return (_ctx, _cache) => {
924
+ return openBlock(), createElementBlock(
925
+ "div",
926
+ {
927
+ class: "m-form-flex-layout",
928
+ style: normalizeStyle({ display: "flex", flexWrap: "wrap", gap: gap.value })
929
+ },
930
+ [
931
+ (openBlock(true), createElementBlock(
932
+ Fragment,
933
+ null,
934
+ renderList(__props.config.items, (item, index) => {
935
+ return openBlock(), createBlock(_sfc_main$A, {
936
+ key: item[unref(mForm)?.keyProp || "__key"] ?? index,
937
+ config: item,
938
+ model: __props.name ? __props.model[__props.name] : __props.model,
939
+ lastValues: __props.name ? __props.lastValues[__props.name] : __props.lastValues,
940
+ "is-compare": __props.isCompare,
941
+ prop: __props.prop,
942
+ size: __props.size,
943
+ disabled: __props.disabled,
944
+ "label-width": __props.config.labelWidth || __props.labelWidth,
945
+ onChange: changeHandler,
946
+ onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
947
+ }, null, 8, ["config", "model", "lastValues", "is-compare", "prop", "size", "disabled", "label-width"]);
948
+ }),
949
+ 128
950
+ /* KEYED_FRAGMENT */
951
+ ))
952
+ ],
953
+ 4
954
+ /* STYLE */
955
+ );
956
+ };
957
+ }
958
+ });
959
+
960
+ const _hoisted_1$b = { class: "m-fields-group-list-item" };
867
961
  const _hoisted_2$5 = { style: { "text-align": "right", "margin-top": "20px" } };
868
- const _hoisted_3$3 = ["innerHTML"];
869
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
962
+ const _hoisted_3$4 = ["innerHTML"];
963
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
870
964
  ...{
871
965
  name: "MFormGroupListItem"
872
966
  },
@@ -944,7 +1038,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
944
1038
  emit("swap-item", props.index, moveSpecifyLocationIndex.value - 1);
945
1039
  };
946
1040
  return (_ctx, _cache) => {
947
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
1041
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
948
1042
  createElementVNode("div", null, [
949
1043
  createVNode(unref(TMagicButton), {
950
1044
  link: "",
@@ -1133,9 +1227,9 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
1133
1227
  key: 3,
1134
1228
  innerHTML: itemExtra.value,
1135
1229
  class: "m-form-tip"
1136
- }, null, 8, _hoisted_3$3)) : createCommentVNode("v-if", true)
1230
+ }, null, 8, _hoisted_3$4)) : createCommentVNode("v-if", true)
1137
1231
  ]),
1138
- expand.value ? (openBlock(), createBlock(_sfc_main$x, {
1232
+ expand.value ? (openBlock(), createBlock(_sfc_main$A, {
1139
1233
  key: 0,
1140
1234
  config: rowConfig.value,
1141
1235
  model: __props.model,
@@ -1153,13 +1247,13 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
1153
1247
  }
1154
1248
  });
1155
1249
 
1156
- const _hoisted_1$b = { class: "m-fields-group-list" };
1250
+ const _hoisted_1$a = { class: "m-fields-group-list" };
1157
1251
  const _hoisted_2$4 = ["innerHTML"];
1158
- const _hoisted_3$2 = {
1252
+ const _hoisted_3$3 = {
1159
1253
  key: 1,
1160
1254
  class: "el-table__empty-block"
1161
1255
  };
1162
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
1256
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1163
1257
  ...{
1164
1258
  name: "MFormGroupList"
1165
1259
  },
@@ -1249,13 +1343,13 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1249
1343
  const onAddDiffCount = () => emit("addDiffCount");
1250
1344
  const getLastValues = (item, index) => item?.[index] || {};
1251
1345
  return (_ctx, _cache) => {
1252
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
1346
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1253
1347
  __props.config.extra ? (openBlock(), createElementBlock("div", {
1254
1348
  key: 0,
1255
1349
  innerHTML: __props.config.extra,
1256
1350
  style: { "color": "rgba(0, 0, 0, 0.45)" }
1257
1351
  }, null, 8, _hoisted_2$4)) : createCommentVNode("v-if", true),
1258
- !__props.model[__props.name] || !__props.model[__props.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$2, [..._cache[1] || (_cache[1] = [
1352
+ !__props.model[__props.name] || !__props.model[__props.name].length ? (openBlock(), createElementBlock("div", _hoisted_3$3, [..._cache[1] || (_cache[1] = [
1259
1353
  createElementVNode(
1260
1354
  "span",
1261
1355
  { class: "el-table__empty-text" },
@@ -1267,7 +1361,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1267
1361
  Fragment,
1268
1362
  { key: 2 },
1269
1363
  renderList(__props.model[__props.name], (item, index) => {
1270
- return openBlock(), createBlock(_sfc_main$v, {
1364
+ return openBlock(), createBlock(_sfc_main$x, {
1271
1365
  key: index,
1272
1366
  model: item,
1273
1367
  lastValues: getLastValues(__props.lastValues[__props.name], index),
@@ -1327,15 +1421,15 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1327
1421
  }
1328
1422
  });
1329
1423
 
1330
- const _hoisted_1$a = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
1424
+ const _hoisted_1$9 = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
1331
1425
  const _hoisted_2$3 = ["innerHTML"];
1332
- const _hoisted_3$1 = {
1426
+ const _hoisted_3$2 = {
1333
1427
  key: 0,
1334
1428
  style: { "display": "flex" }
1335
1429
  };
1336
1430
  const _hoisted_4$1 = { style: { "flex": "1" } };
1337
1431
  const _hoisted_5$1 = ["src"];
1338
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
1432
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
1339
1433
  ...{
1340
1434
  name: "MFormPanel"
1341
1435
  },
@@ -1370,7 +1464,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1370
1464
  "body-style": { display: expand.value ? "block" : "none" }
1371
1465
  }, {
1372
1466
  header: withCtx(() => [
1373
- createElementVNode("div", _hoisted_1$a, [
1467
+ createElementVNode("div", _hoisted_1$9, [
1374
1468
  createVNode(unref(TMagicButton), {
1375
1469
  style: { "padding": "0" },
1376
1470
  link: "",
@@ -1394,13 +1488,13 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1394
1488
  default: withCtx(() => [
1395
1489
  createElementVNode("div", null, [
1396
1490
  renderSlot(_ctx.$slots, "default"),
1397
- __props.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
1491
+ __props.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
1398
1492
  createElementVNode("div", _hoisted_4$1, [
1399
1493
  (openBlock(true), createElementBlock(
1400
1494
  Fragment,
1401
1495
  null,
1402
1496
  renderList(items.value, (item, index) => {
1403
- return openBlock(), createBlock(_sfc_main$x, {
1497
+ return openBlock(), createBlock(_sfc_main$A, {
1404
1498
  key: item[unref(mForm)?.keyProp || "__key"] ?? index,
1405
1499
  config: item,
1406
1500
  model: __props.name ? __props.model[__props.name] : __props.model,
@@ -1426,7 +1520,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1426
1520
  Fragment,
1427
1521
  { key: 1 },
1428
1522
  renderList(items.value, (item, index) => {
1429
- return openBlock(), createBlock(_sfc_main$x, {
1523
+ return openBlock(), createBlock(_sfc_main$A, {
1430
1524
  key: item[unref(mForm)?.keyProp || "__key"] ?? index,
1431
1525
  config: item,
1432
1526
  model: __props.name ? __props.model[__props.name] : __props.model,
@@ -1452,7 +1546,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1452
1546
  }
1453
1547
  });
1454
1548
 
1455
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
1549
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1456
1550
  ...{
1457
1551
  name: "MFormCol"
1458
1552
  },
@@ -1480,7 +1574,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1480
1574
  return (_ctx, _cache) => {
1481
1575
  return withDirectives((openBlock(), createBlock(unref(TMagicCol), { span: __props.span }, {
1482
1576
  default: withCtx(() => [
1483
- createVNode(_sfc_main$x, {
1577
+ createVNode(_sfc_main$A, {
1484
1578
  model: __props.model,
1485
1579
  lastValues: __props.lastValues,
1486
1580
  "is-compare": __props.isCompare,
@@ -1503,7 +1597,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1503
1597
  }
1504
1598
  });
1505
1599
 
1506
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
1600
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1507
1601
  ...{
1508
1602
  name: "MFormRow"
1509
1603
  },
@@ -1536,7 +1630,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
1536
1630
  Fragment,
1537
1631
  null,
1538
1632
  renderList(__props.config.items, (col, index) => {
1539
- return openBlock(), createBlock(_sfc_main$s, {
1633
+ return openBlock(), createBlock(_sfc_main$u, {
1540
1634
  key: col[unref(mForm)?.keyProp || "__key"] ?? index,
1541
1635
  span: col.span || __props.config.span || 24 / __props.config.items.length,
1542
1636
  config: col,
@@ -1563,7 +1657,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
1563
1657
  }
1564
1658
  });
1565
1659
 
1566
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
1660
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1567
1661
  ...{
1568
1662
  name: "MFormStep"
1569
1663
  },
@@ -1638,7 +1732,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
1638
1732
  Fragment,
1639
1733
  null,
1640
1734
  [
1641
- item ? withDirectives((openBlock(), createBlock(_sfc_main$x, {
1735
+ item ? withDirectives((openBlock(), createBlock(_sfc_main$A, {
1642
1736
  key: item[unref(mForm)?.keyProp || "__key"],
1643
1737
  config: item,
1644
1738
  model: step.name ? __props.model[step.name] : __props.model,
@@ -1674,1044 +1768,325 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
1674
1768
  }
1675
1769
  });
1676
1770
 
1677
- const _hoisted_1$9 = { class: "m-fields-table-wrap" };
1678
- const _hoisted_2$2 = ["innerHTML"];
1679
- const _hoisted_3 = ["innerHTML"];
1680
- const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
1681
- const _hoisted_5 = { style: { "display": "flex" } };
1682
- const _hoisted_6 = {
1683
- key: 1,
1684
- class: "bottom",
1685
- style: { "text-align": "right" }
1686
- };
1687
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
1771
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
1688
1772
  ...{
1689
- name: "MFormTable"
1773
+ name: "MFormTabs"
1690
1774
  },
1691
- __name: "Table",
1775
+ __name: "Tabs",
1692
1776
  props: {
1693
1777
  model: {},
1694
1778
  lastValues: { default: () => ({}) },
1695
1779
  isCompare: { type: Boolean, default: false },
1696
1780
  config: {},
1697
1781
  name: {},
1698
- prop: { default: "" },
1699
- labelWidth: {},
1700
- sort: { type: Boolean },
1701
- disabled: { type: Boolean },
1702
- sortKey: { default: "" },
1703
- text: {},
1704
1782
  size: {},
1705
- enableToggleMode: { type: Boolean, default: true },
1706
- showIndex: { type: Boolean, default: true }
1783
+ labelWidth: {},
1784
+ prop: {},
1785
+ expandMore: { type: Boolean },
1786
+ disabled: { type: Boolean }
1707
1787
  },
1708
- emits: ["change", "select", "addDiffCount"],
1709
- setup(__props, { expose: __expose, emit: __emit }) {
1710
- const props = __props;
1711
- const emit = __emit;
1712
- let timer = null;
1713
- const mForm = inject("mForm");
1714
- const { nextZIndex } = useZIndex();
1715
- const tMagicTable = ref();
1716
- const excelBtn = ref();
1717
- const mTable = ref();
1718
- const pagesize = ref(10);
1719
- const pagecontext = ref(0);
1720
- const updateKey = ref(1);
1721
- const isFullscreen = ref(false);
1722
- const modelName = computed(() => props.name || props.config.name || "");
1723
- const getDataByPage = (data2 = []) => data2.filter(
1724
- (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
1725
- );
1726
- const pageinationData = computed(() => getDataByPage(props.model[modelName.value]));
1727
- const data = computed(() => props.config.pagination ? pageinationData.value : props.model[modelName.value]);
1728
- const lastData = computed(
1729
- () => props.config.pagination ? getDataByPage(props.lastValues[modelName.value]) : props.lastValues[modelName.value] || []
1730
- );
1731
- const sortChange = ({ prop, order }) => {
1732
- if (order === "ascending") {
1733
- props.model[modelName.value] = props.model[modelName.value].sort((a, b) => a[prop] - b[prop]);
1734
- } else if (order === "descending") {
1735
- props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
1736
- }
1788
+ emits: ["change", "addDiffCount"],
1789
+ setup(__props, { emit: __emit }) {
1790
+ const tabPaneComponent = getDesignConfig("components")?.tabPane;
1791
+ const tabsComponent = getDesignConfig("components")?.tabs;
1792
+ const getActive = (mForm2, props2, activeTabName2) => {
1793
+ const { config, model, prop } = props2;
1794
+ const { active } = config;
1795
+ if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
1796
+ if (0 >= props2.config.items.length) return "0";
1797
+ if (typeof active !== "undefined") return active;
1798
+ return "0";
1737
1799
  };
1738
- const swapArray = (index1, index2) => {
1739
- props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
1740
- if (props.sortKey) {
1741
- for (let i = props.model[modelName.value].length - 1, v = 0; i >= 0; i--, v++) {
1742
- props.model[modelName.value][v][props.sortKey] = i;
1743
- }
1800
+ const tabClick = (mForm2, tab, props2) => {
1801
+ const { config, model, prop } = props2;
1802
+ tab.name = tab.paneName;
1803
+ if (typeof config.onTabClick === "function") {
1804
+ config.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
1744
1805
  }
1745
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1746
- };
1747
- let sortable;
1748
- const rowDrop = () => {
1749
- sortable?.destroy();
1750
- const tableEl = tMagicTable.value?.instance.$el;
1751
- const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
1752
- if (!tBodyEl) {
1753
- return;
1806
+ const tabConfig = config.items.find((item) => tab.name === item.status);
1807
+ if (tabConfig && typeof tabConfig.onTabClick === "function") {
1808
+ tabConfig.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
1754
1809
  }
1755
- sortable = Sortable.create(tBodyEl, {
1756
- draggable: ".tmagic-design-table-row",
1757
- filter: "input",
1758
- // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
1759
- preventOnFilter: false,
1760
- // 允许选字
1761
- direction: "vertical",
1762
- onEnd: ({ newIndex, oldIndex }) => {
1763
- if (typeof newIndex === "undefined") return;
1764
- if (typeof oldIndex === "undefined") return;
1765
- swapArray(newIndex, oldIndex);
1766
- emit("change", props.model[modelName.value]);
1767
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1768
- }
1769
- });
1770
1810
  };
1771
- const newHandler = async (row) => {
1772
- if (props.config.max && props.model[modelName.value].length >= props.config.max) {
1773
- tMagicMessage.error(`最多新增配置不能超过${props.config.max}条`);
1774
- return;
1811
+ const props = __props;
1812
+ const emit = __emit;
1813
+ const mForm = inject("mForm");
1814
+ const activeTabName = ref(getActive(mForm, props));
1815
+ const diffCount = ref({});
1816
+ const tabs = computed(() => {
1817
+ if (props.config.dynamic) {
1818
+ if (!props.config.name) throw new Error("dynamic tab 必须配置name");
1819
+ return props.model[props.config.name] || [];
1775
1820
  }
1776
- if (typeof props.config.beforeAddRow === "function") {
1777
- const beforeCheckRes = props.config.beforeAddRow(mForm, {
1778
- model: props.model[modelName.value],
1779
- formValue: mForm?.values,
1821
+ return props.config.items.filter((item) => display(mForm, item.display, props));
1822
+ });
1823
+ const filter = (config) => filterFunction(mForm, config, props);
1824
+ watchEffect(() => {
1825
+ if (typeof props.config.activeChange === "function") {
1826
+ props.config.activeChange(mForm, activeTabName.value, {
1827
+ model: props.model,
1780
1828
  prop: props.prop
1781
1829
  });
1782
- if (!beforeCheckRes) return;
1783
1830
  }
1784
- const columns = props.config.items;
1785
- const enumValues = props.config.enum || [];
1786
- let enumV = [];
1787
- const { length } = props.model[modelName.value];
1788
- const key = props.config.key || "id";
1789
- let inputs = {};
1790
- if (enumValues.length) {
1791
- if (length >= enumValues.length) {
1792
- return;
1793
- }
1794
- enumV = enumValues.filter((item) => {
1795
- let i = 0;
1796
- for (; i < length; i++) {
1797
- if (item[key] === props.model[modelName.value][i][key]) {
1798
- break;
1799
- }
1800
- }
1801
- return i === length;
1802
- });
1803
- if (enumV.length > 0) {
1804
- inputs = enumV[0];
1805
- }
1806
- } else if (Array.isArray(row)) {
1807
- columns.forEach((column, index) => {
1808
- column.name && (inputs[column.name] = row[index]);
1809
- });
1831
+ });
1832
+ const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
1833
+ const tabClickHandler = (tab) => {
1834
+ if (typeof tab === "object") {
1835
+ tabClick(mForm, tab, props);
1810
1836
  } else {
1811
- if (typeof props.config.defaultAdd === "function") {
1812
- inputs = await props.config.defaultAdd(mForm, {
1813
- model: props.model[modelName.value],
1814
- formValue: mForm?.values
1815
- });
1816
- } else if (props.config.defaultAdd) {
1817
- inputs = props.config.defaultAdd;
1837
+ let item = tabs.value.find((tab2) => tab2.status === tab2);
1838
+ if (!item) {
1839
+ item = tabs.value[tab];
1818
1840
  }
1819
- inputs = await initValue(mForm, {
1820
- config: columns,
1821
- initValues: inputs
1822
- });
1823
- }
1824
- if (props.sortKey && length) {
1825
- inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
1841
+ tabClick(mForm, item, props);
1826
1842
  }
1827
- props.model[modelName.value].push(inputs);
1828
- emit("change", props.model[modelName.value], {
1829
- changeRecords: [
1830
- {
1831
- propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
1832
- value: inputs
1833
- }
1834
- ]
1835
- });
1836
1843
  };
1837
- onMounted(() => {
1838
- if (props.config.defautSort) {
1839
- sortChange(props.config.defautSort);
1840
- } else if (props.config.defaultSort) {
1841
- sortChange(props.config.defaultSort);
1842
- }
1843
- if (props.sort && props.sortKey) {
1844
- props.model[modelName.value].sort((a, b) => b[props.sortKey] - a[props.sortKey]);
1845
- }
1846
- });
1847
- watchEffect(() => {
1848
- if (props.config.dropSort) {
1849
- rowDrop();
1850
- }
1851
- });
1852
- const addable = computed(() => {
1853
- if (!props.model[modelName.value].length) {
1854
- return true;
1855
- }
1856
- if (typeof props.config.addable === "function") {
1857
- return props.config.addable(mForm, {
1858
- model: props.model[modelName.value],
1859
- formValue: mForm?.values,
1860
- prop: props.prop
1844
+ const onTabAdd = async () => {
1845
+ if (!props.name) throw new Error("dynamic tab 必须配置name");
1846
+ if (typeof props.config.onTabAdd === "function") {
1847
+ props.config.onTabAdd(mForm, {
1848
+ model: props.model,
1849
+ prop: props.prop,
1850
+ config: props.config
1861
1851
  });
1862
- }
1863
- return typeof props.config.addable === "undefined" ? true : props.config.addable;
1864
- });
1865
- const selection = computed(() => {
1866
- if (typeof props.config.selection === "function") {
1867
- return props.config.selection(mForm, { model: props.model[modelName.value] });
1868
- }
1869
- return props.config.selection;
1870
- });
1871
- const importable = computed(() => {
1872
- if (typeof props.config.importable === "function") {
1873
- return props.config.importable(mForm, {
1874
- formValue: mForm?.values,
1875
- model: props.model[modelName.value]
1852
+ emit("change", props.model);
1853
+ } else {
1854
+ const newObj = await initValue(mForm, {
1855
+ config: props.config.items,
1856
+ initValues: {}
1857
+ });
1858
+ newObj.title = `标签${tabs.value.length + 1}`;
1859
+ props.model[props.name].push(newObj);
1860
+ emit("change", props.model[props.name], {
1861
+ changeRecords: [
1862
+ {
1863
+ propPath: `${props.prop}.${props.model[props.name].length - 1}`,
1864
+ value: newObj
1865
+ }
1866
+ ]
1876
1867
  });
1877
1868
  }
1878
- return typeof props.config.importable === "undefined" ? false : props.config.importable;
1879
- });
1880
- const display$1 = (fuc) => display(mForm, fuc, props);
1881
- const itemExtra = (fuc, index) => {
1882
- if (typeof fuc === "function") {
1883
- return fuc(mForm, {
1884
- values: mForm?.initValues,
1869
+ mForm?.$emit("field-change", props.prop, props.model[props.name]);
1870
+ };
1871
+ const onTabRemove = (tabName) => {
1872
+ if (!props.name) throw new Error("dynamic tab 必须配置name");
1873
+ if (typeof props.config.onTabRemove === "function") {
1874
+ props.config.onTabRemove(mForm, tabName, {
1885
1875
  model: props.model,
1886
- formValue: mForm ? mForm.values : props.model,
1887
1876
  prop: props.prop,
1888
- index
1877
+ config: props.config
1889
1878
  });
1879
+ } else {
1880
+ props.model[props.name].splice(+tabName, 1);
1881
+ if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
1882
+ activeTabName.value = (+activeTabName.value - 1).toString();
1883
+ tabClick(mForm, { name: activeTabName.value }, props);
1884
+ }
1890
1885
  }
1891
- return fuc;
1886
+ emit("change", props.model);
1887
+ mForm?.$emit("field-change", props.prop, props.model[props.name]);
1892
1888
  };
1893
- const removeHandler = (index) => {
1894
- if (props.disabled) return;
1895
- props.model[modelName.value].splice(index, 1);
1896
- emit("change", props.model[modelName.value]);
1889
+ const changeHandler = (v, eventData) => {
1890
+ emit("change", props.model, eventData);
1897
1891
  };
1898
- const selectHandle = (selection2, row) => {
1899
- if (typeof props.config.selection === "string" && props.config.selection === "single") {
1900
- tMagicTable.value?.clearSelection();
1901
- tMagicTable.value?.toggleRowSelection(row, true);
1902
- }
1903
- emit("select", selection2, row);
1904
- if (typeof props.config.onSelect === "function") {
1905
- props.config.onSelect(mForm, { selection: selection2, row, config: props.config });
1892
+ const onAddDiffCount = (tabIndex) => {
1893
+ if (!diffCount.value[tabIndex]) {
1894
+ diffCount.value[tabIndex] = 1;
1895
+ } else {
1896
+ diffCount.value[tabIndex] += 1;
1906
1897
  }
1898
+ emit("addDiffCount");
1907
1899
  };
1908
- const toggleRowSelection = (row, selected) => {
1909
- tMagicTable.value?.toggleRowSelection.call(tMagicTable.value, row, selected);
1910
- };
1911
- const makeConfig = (config, row) => {
1912
- const newConfig = cloneDeep(config);
1913
- if (typeof config.itemsFunction === "function") {
1914
- newConfig.items = config.itemsFunction(row);
1915
- }
1916
- delete newConfig.display;
1917
- return newConfig;
1900
+ return (_ctx, _cache) => {
1901
+ return openBlock(), createBlock(resolveDynamicComponent(unref(tabsComponent)?.component || "el-tabs"), mergeProps(
1902
+ {
1903
+ modelValue: activeTabName.value,
1904
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
1905
+ },
1906
+ unref(tabsComponent)?.props({
1907
+ type: __props.config.tabType,
1908
+ editable: __props.config.editable || false,
1909
+ tabPosition: __props.config.tabPosition || "top"
1910
+ }) || {},
1911
+ {
1912
+ class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
1913
+ onTabClick: tabClickHandler,
1914
+ onTabAdd,
1915
+ onTabRemove
1916
+ }
1917
+ ), {
1918
+ default: withCtx(() => [
1919
+ (openBlock(true), createElementBlock(
1920
+ Fragment,
1921
+ null,
1922
+ renderList(tabs.value, (tab, tabIndex) => {
1923
+ return openBlock(), createBlock(
1924
+ resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"),
1925
+ mergeProps(
1926
+ {
1927
+ key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex
1928
+ },
1929
+ { ref_for: true },
1930
+ unref(tabPaneComponent)?.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false }) || {}
1931
+ ),
1932
+ {
1933
+ label: withCtx(() => [
1934
+ createElementVNode("span", null, [
1935
+ createTextVNode(
1936
+ toDisplayString(filter(tab.title)),
1937
+ 1
1938
+ /* TEXT */
1939
+ ),
1940
+ createVNode(unref(TMagicBadge), {
1941
+ hidden: !diffCount.value[tabIndex],
1942
+ value: diffCount.value[tabIndex],
1943
+ class: "diff-count-badge"
1944
+ }, null, 8, ["hidden", "value"])
1945
+ ])
1946
+ ]),
1947
+ default: withCtx(() => [
1948
+ (openBlock(true), createElementBlock(
1949
+ Fragment,
1950
+ null,
1951
+ renderList(tabItems(tab), (item) => {
1952
+ return openBlock(), createBlock(_sfc_main$A, {
1953
+ key: item[unref(mForm)?.keyProp || "__key"],
1954
+ config: item,
1955
+ disabled: __props.disabled,
1956
+ model: __props.config.dynamic ? (__props.name ? __props.model[__props.name] : __props.model)[tabIndex] : tab.name ? (__props.name ? __props.model[__props.name] : __props.model)[tab.name] : __props.name ? __props.model[__props.name] : __props.model,
1957
+ "last-values": unref(isEmpty)(__props.lastValues) ? {} : __props.config.dynamic ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tabIndex] : tab.name ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tab.name] : __props.name ? __props.lastValues[__props.name] : __props.lastValues,
1958
+ "is-compare": __props.isCompare,
1959
+ prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
1960
+ size: __props.size,
1961
+ "label-width": tab.labelWidth || __props.labelWidth,
1962
+ "expand-more": __props.expandMore,
1963
+ onChange: changeHandler,
1964
+ onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
1965
+ }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
1966
+ }),
1967
+ 128
1968
+ /* KEYED_FRAGMENT */
1969
+ ))
1970
+ ]),
1971
+ _: 2
1972
+ /* DYNAMIC */
1973
+ },
1974
+ 1040
1975
+ /* FULL_PROPS, DYNAMIC_SLOTS */
1976
+ );
1977
+ }),
1978
+ 128
1979
+ /* KEYED_FRAGMENT */
1980
+ ))
1981
+ ]),
1982
+ _: 1
1983
+ /* STABLE */
1984
+ }, 16, ["modelValue", "class"]);
1918
1985
  };
1919
- const upHandler = (index) => {
1920
- if (timer) {
1921
- clearTimeout(timer);
1986
+ }
1987
+ });
1988
+
1989
+ let $MAGIC_FORM = {};
1990
+ const setConfig = (option) => {
1991
+ $MAGIC_FORM = option;
1992
+ };
1993
+ const getConfig = (key) => $MAGIC_FORM[key];
1994
+
1995
+ const useAddField = (prop) => {
1996
+ if (!prop) return;
1997
+ const mForm = inject("mForm");
1998
+ const instance = getCurrentInstance();
1999
+ watch(
2000
+ () => instance?.proxy,
2001
+ (vm) => {
2002
+ if (vm) {
2003
+ mForm?.setField(prop, vm);
2004
+ } else {
2005
+ mForm?.deleteField(prop);
1922
2006
  }
1923
- timer = setTimeout(() => {
1924
- swapArray(index, index - 1);
1925
- timer = void 0;
1926
- }, 300);
1927
- };
1928
- const topHandler = (index) => {
1929
- if (timer) {
1930
- clearTimeout(timer);
2007
+ },
2008
+ {
2009
+ immediate: true
2010
+ }
2011
+ );
2012
+ };
2013
+
2014
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
2015
+ ...{
2016
+ name: "MFormCascader"
2017
+ },
2018
+ __name: "Cascader",
2019
+ props: {
2020
+ config: {},
2021
+ model: {},
2022
+ initValues: {},
2023
+ values: {},
2024
+ name: {},
2025
+ prop: {},
2026
+ disabled: { type: Boolean },
2027
+ size: {},
2028
+ lastValues: {}
2029
+ },
2030
+ emits: ["change"],
2031
+ setup(__props, { emit: __emit }) {
2032
+ const props = __props;
2033
+ const emit = __emit;
2034
+ const mForm = inject("mForm");
2035
+ useAddField(props.prop);
2036
+ const requestFunc = getConfig("request");
2037
+ const tMagicCascader = ref();
2038
+ const options = ref([]);
2039
+ const remoteData = ref(null);
2040
+ const checkStrictly = computed(() => filterFunction(mForm, props.config.checkStrictly, props));
2041
+ const valueSeparator = computed(() => filterFunction(mForm, props.config.valueSeparator, props));
2042
+ const value = computed(() => {
2043
+ if (typeof props.model[props.name] === "string" && valueSeparator.value) {
2044
+ return props.model[props.name].split(valueSeparator.value);
1931
2045
  }
1932
- const moveNum = index;
1933
- for (let i = 0; i < moveNum; i++) {
1934
- swapArray(index, index - 1);
1935
- index -= 1;
2046
+ return props.model[props.name];
2047
+ });
2048
+ const updateModelValueHandler = (value2) => {
2049
+ let result = value2;
2050
+ if (valueSeparator.value) {
2051
+ result = value2.join(valueSeparator.value);
1936
2052
  }
1937
- };
1938
- const downHandler = (index) => {
1939
- if (timer) {
1940
- clearTimeout(timer);
2053
+ if (typeof result === "undefined") {
2054
+ if (Array.isArray(props.model[props.name])) {
2055
+ emit("change", []);
2056
+ } else if (typeof props.model[props.name] === "string") {
2057
+ emit("change", "");
2058
+ } else if (typeof props.model[props.name] === "object") {
2059
+ emit("change", null);
2060
+ }
1941
2061
  }
1942
- timer = setTimeout(() => {
1943
- swapArray(index, index + 1);
1944
- timer = void 0;
1945
- }, 300);
2062
+ emit("change", result);
1946
2063
  };
1947
- const bottomHandler = (index) => {
1948
- if (timer) {
1949
- clearTimeout(timer);
1950
- }
1951
- const moveNum = props.model[modelName.value].length - 1 - index;
1952
- for (let i = 0; i < moveNum; i++) {
1953
- swapArray(index, index + 1);
1954
- index += 1;
2064
+ const setRemoteOptions = async function() {
2065
+ const { config } = props;
2066
+ const { option } = config;
2067
+ if (!option) return;
2068
+ let { body } = option;
2069
+ const postOptions = {
2070
+ url: option.url,
2071
+ cache: option.cache,
2072
+ timeout: option.timeout,
2073
+ data: {}
2074
+ };
2075
+ if (body && mForm) {
2076
+ if (typeof body === "function" && props.model && mForm) {
2077
+ body = body(mForm, {
2078
+ model: props.model,
2079
+ formValue: mForm.values,
2080
+ formValues: mForm.values,
2081
+ config: props.config
2082
+ });
2083
+ }
2084
+ postOptions.data = body;
1955
2085
  }
1956
- };
1957
- const showDelete = (index) => {
1958
- const deleteFunc = props.config.delete;
1959
- if (deleteFunc && typeof deleteFunc === "function") {
1960
- return deleteFunc(props.model[modelName.value], index, mForm?.values);
1961
- }
1962
- return true;
1963
- };
1964
- const copyable = (index) => {
1965
- const copyableFunc = props.config.copyable;
1966
- if (copyableFunc && typeof copyableFunc === "function") {
1967
- return copyableFunc(mForm, {
1968
- values: mForm?.initValues || {},
1969
- model: props.model,
1970
- parent: mForm?.parentValues || {},
1971
- formValue: mForm?.values || props.model,
1972
- prop: props.prop,
1973
- config: props.config,
1974
- index
1975
- });
1976
- }
1977
- return true;
1978
- };
1979
- const clearHandler = () => {
1980
- const len = props.model[modelName.value].length;
1981
- props.model[modelName.value].splice(0, len);
1982
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
1983
- };
1984
- const excelHandler = async (file) => {
1985
- if (!file?.raw) {
1986
- return false;
1987
- }
1988
- if (!globalThis.XLSX) {
1989
- await asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
1990
- }
1991
- const reader = new FileReader();
1992
- reader.onload = () => {
1993
- const data2 = reader.result;
1994
- const pdata = globalThis.XLSX.read(data2, { type: "array" });
1995
- pdata.SheetNames.forEach((sheetName) => {
1996
- const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
1997
- if (arr?.[0]) {
1998
- arr.forEach((row) => {
1999
- newHandler(row);
2000
- });
2001
- }
2002
- setTimeout(() => {
2003
- excelBtn.value?.clearFiles();
2004
- }, 300);
2005
- });
2006
- };
2007
- reader.readAsArrayBuffer(file.raw);
2008
- return false;
2009
- };
2010
- const handleSizeChange = (val) => {
2011
- pagesize.value = val;
2012
- };
2013
- const handleCurrentChange = (val) => {
2014
- pagecontext.value = val - 1;
2015
- };
2016
- const copyHandler = (index) => {
2017
- props.model[modelName.value].push(cloneDeep(props.model[modelName.value][index]));
2018
- };
2019
- const toggleMode = () => {
2020
- const calcLabelWidth = (label) => {
2021
- if (!label) return "0px";
2022
- const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
2023
- const chLength = label.length - zhLength;
2024
- return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
2025
- };
2026
- props.config.type = "groupList";
2027
- props.config.enableToggleMode = true;
2028
- props.config.tableItems = props.config.items;
2029
- props.config.items = props.config.groupItems || props.config.items.map((item) => {
2030
- const text = item.text || item.label;
2031
- const labelWidth = calcLabelWidth(text);
2032
- return {
2033
- ...item,
2034
- text,
2035
- labelWidth,
2036
- span: item.span || 12
2037
- };
2038
- });
2039
- };
2040
- const toggleFullscreen = () => {
2041
- if (!mTable.value) return;
2042
- if (isFullscreen.value) {
2043
- mTable.value.classList.remove("fixed");
2044
- isFullscreen.value = false;
2045
- } else {
2046
- mTable.value.classList.add("fixed");
2047
- mTable.value.style.zIndex = `${nextZIndex()}`;
2048
- isFullscreen.value = true;
2049
- }
2050
- };
2051
- const getProp = (index) => {
2052
- const { prop } = toRefs(props);
2053
- return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
2054
- };
2055
- const onAddDiffCount = () => emit("addDiffCount");
2056
- const changeHandler = (v, eventData) => {
2057
- emit("change", props.model, eventData);
2058
- };
2059
- __expose({
2060
- toggleRowSelection
2061
- });
2062
- return (_ctx, _cache) => {
2063
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2064
- (openBlock(), createBlock(Teleport, {
2065
- to: "body",
2066
- disabled: !isFullscreen.value
2067
- }, [
2068
- createElementVNode(
2069
- "div",
2070
- {
2071
- ref_key: "mTable",
2072
- ref: mTable,
2073
- class: normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }])
2074
- },
2075
- [
2076
- __props.config.extra ? (openBlock(), createElementBlock("span", {
2077
- key: 0,
2078
- style: { "color": "rgba(0, 0, 0, 0.45)" },
2079
- innerHTML: __props.config.extra
2080
- }, null, 8, _hoisted_2$2)) : createCommentVNode("v-if", true),
2081
- createVNode(unref(TMagicTooltip), {
2082
- content: "拖拽可排序",
2083
- placement: "left-start",
2084
- disabled: __props.config.dropSort !== true
2085
- }, {
2086
- default: withCtx(() => [
2087
- __props.model[modelName.value] ? (openBlock(), createBlock(unref(TMagicTable), {
2088
- ref_key: "tMagicTable",
2089
- ref: tMagicTable,
2090
- style: { "width": "100%" },
2091
- "row-key": __props.config.rowKey || "id",
2092
- data: data.value,
2093
- lastData: lastData.value,
2094
- border: __props.config.border,
2095
- "max-height": __props.config.maxHeight,
2096
- "default-expand-all": true,
2097
- key: updateKey.value,
2098
- onSelect: selectHandle,
2099
- onSortChange: sortChange
2100
- }, {
2101
- default: withCtx(() => [
2102
- __props.config.itemExtra && !__props.config.dropSort ? (openBlock(), createBlock(unref(TMagicTableColumn), {
2103
- key: 0,
2104
- fixed: "left",
2105
- width: "30",
2106
- type: "expand"
2107
- }, {
2108
- default: withCtx((scope) => [
2109
- createElementVNode("span", {
2110
- innerHTML: itemExtra(__props.config.itemExtra, scope.$index),
2111
- class: "m-form-tip"
2112
- }, null, 8, _hoisted_3)
2113
- ]),
2114
- _: 1
2115
- /* STABLE */
2116
- })) : createCommentVNode("v-if", true),
2117
- createVNode(unref(TMagicTableColumn), {
2118
- label: "操作",
2119
- width: __props.config.operateColWidth || 100,
2120
- align: "center",
2121
- fixed: __props.config.fixed === false ? void 0 : "left"
2122
- }, {
2123
- default: withCtx((scope) => [
2124
- renderSlot(_ctx.$slots, "operateCol", { scope }),
2125
- withDirectives(createVNode(unref(TMagicButton), {
2126
- size: "small",
2127
- type: "danger",
2128
- link: "",
2129
- title: "删除",
2130
- icon: unref(Delete),
2131
- onClick: ($event) => removeHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
2132
- }, null, 8, ["icon", "onClick"]), [
2133
- [vShow, showDelete(scope.$index + 1 + pagecontext.value * pagesize.value - 1)]
2134
- ]),
2135
- copyable(scope.$index + 1 + pagecontext.value * pagesize.value - 1) ? (openBlock(), createBlock(unref(TMagicButton), {
2136
- key: 0,
2137
- link: "",
2138
- size: "small",
2139
- type: "primary",
2140
- title: "复制",
2141
- icon: unref(DocumentCopy),
2142
- disabled: __props.disabled,
2143
- onClick: ($event) => copyHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
2144
- }, null, 8, ["icon", "disabled", "onClick"])) : createCommentVNode("v-if", true)
2145
- ]),
2146
- _: 3
2147
- /* FORWARDED */
2148
- }, 8, ["width", "fixed"]),
2149
- __props.sort && __props.model[modelName.value] && __props.model[modelName.value].length > 1 ? (openBlock(), createBlock(unref(TMagicTableColumn), {
2150
- key: 1,
2151
- label: "排序",
2152
- width: "60"
2153
- }, {
2154
- default: withCtx((scope) => [
2155
- scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== 0 ? (openBlock(), createBlock(
2156
- unref(TMagicTooltip),
2157
- {
2158
- key: 0,
2159
- content: "点击上移,双击置顶",
2160
- placement: "top"
2161
- },
2162
- {
2163
- default: withCtx(() => [
2164
- createVNode(unref(TMagicButton), {
2165
- plain: "",
2166
- size: "small",
2167
- type: "primary",
2168
- icon: unref(ArrowUp),
2169
- disabled: __props.disabled,
2170
- link: "",
2171
- onClick: ($event) => upHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
2172
- onDblclick: ($event) => topHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
2173
- }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
2174
- ]),
2175
- _: 2
2176
- /* DYNAMIC */
2177
- },
2178
- 1024
2179
- /* DYNAMIC_SLOTS */
2180
- )) : createCommentVNode("v-if", true),
2181
- scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== __props.model[modelName.value].length - 1 ? (openBlock(), createBlock(
2182
- unref(TMagicTooltip),
2183
- {
2184
- key: 1,
2185
- content: "点击下移,双击置底",
2186
- placement: "top"
2187
- },
2188
- {
2189
- default: withCtx(() => [
2190
- createVNode(unref(TMagicButton), {
2191
- plain: "",
2192
- size: "small",
2193
- type: "primary",
2194
- icon: unref(ArrowDown),
2195
- disabled: __props.disabled,
2196
- link: "",
2197
- onClick: ($event) => downHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
2198
- onDblclick: ($event) => bottomHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
2199
- }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
2200
- ]),
2201
- _: 2
2202
- /* DYNAMIC */
2203
- },
2204
- 1024
2205
- /* DYNAMIC_SLOTS */
2206
- )) : createCommentVNode("v-if", true)
2207
- ]),
2208
- _: 1
2209
- /* STABLE */
2210
- })) : createCommentVNode("v-if", true),
2211
- selection.value ? (openBlock(), createBlock(unref(TMagicTableColumn), {
2212
- key: 2,
2213
- align: "center",
2214
- "header-align": "center",
2215
- type: "selection",
2216
- width: "45"
2217
- })) : createCommentVNode("v-if", true),
2218
- __props.showIndex && __props.config.showIndex ? (openBlock(), createBlock(unref(TMagicTableColumn), {
2219
- key: 3,
2220
- width: "60",
2221
- label: "序号"
2222
- }, {
2223
- default: withCtx((scope) => [
2224
- createTextVNode(
2225
- toDisplayString(scope.$index + 1 + pagecontext.value * pagesize.value),
2226
- 1
2227
- /* TEXT */
2228
- )
2229
- ]),
2230
- _: 1
2231
- /* STABLE */
2232
- })) : createCommentVNode("v-if", true),
2233
- (openBlock(true), createElementBlock(
2234
- Fragment,
2235
- null,
2236
- renderList(__props.config.items, (column, index) => {
2237
- return openBlock(), createElementBlock(
2238
- Fragment,
2239
- null,
2240
- [
2241
- column.type !== "hidden" && display$1(column.display) ? (openBlock(), createBlock(unref(TMagicTableColumn), {
2242
- prop: column.name,
2243
- width: column.width,
2244
- label: column.label,
2245
- sortable: column.sortable,
2246
- "sort-orders": ["ascending", "descending"],
2247
- key: column[unref(mForm)?.keyProp || "__key"] ?? index,
2248
- "class-name": __props.config.dropSort === true ? "el-table__column--dropable" : ""
2249
- }, {
2250
- default: withCtx((scope) => [
2251
- scope.$index > -1 ? (openBlock(), createBlock(_sfc_main$x, {
2252
- key: 0,
2253
- labelWidth: "0",
2254
- disabled: __props.disabled,
2255
- prop: getProp(scope.$index),
2256
- rules: column.rules,
2257
- config: makeConfig(column, scope.row),
2258
- model: scope.row,
2259
- lastValues: lastData.value[scope.$index],
2260
- "is-compare": __props.isCompare,
2261
- size: __props.size,
2262
- onChange: changeHandler,
2263
- onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
2264
- }, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : createCommentVNode("v-if", true)
2265
- ]),
2266
- _: 2
2267
- /* DYNAMIC */
2268
- }, 1032, ["prop", "width", "label", "sortable", "class-name"])) : createCommentVNode("v-if", true)
2269
- ],
2270
- 64
2271
- /* STABLE_FRAGMENT */
2272
- );
2273
- }),
2274
- 256
2275
- /* UNKEYED_FRAGMENT */
2276
- ))
2277
- ]),
2278
- _: 3
2279
- /* FORWARDED */
2280
- }, 8, ["row-key", "data", "lastData", "border", "max-height"])) : createCommentVNode("v-if", true)
2281
- ]),
2282
- _: 3
2283
- /* FORWARDED */
2284
- }, 8, ["disabled"]),
2285
- renderSlot(_ctx.$slots, "default"),
2286
- createElementVNode("div", _hoisted_4, [
2287
- addable.value ? (openBlock(), createBlock(unref(TMagicButton), {
2288
- key: 0,
2289
- size: "small",
2290
- type: "primary",
2291
- disabled: __props.disabled,
2292
- plain: "",
2293
- onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
2294
- }, {
2295
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
2296
- createTextVNode(
2297
- "新增一行",
2298
- -1
2299
- /* CACHED */
2300
- )
2301
- ])]),
2302
- _: 1
2303
- /* STABLE */
2304
- }, 8, ["disabled"])) : createCommentVNode("v-if", true),
2305
- createElementVNode("div", _hoisted_5, [
2306
- __props.enableToggleMode && __props.config.enableToggleMode !== false && !isFullscreen.value ? (openBlock(), createBlock(unref(TMagicButton), {
2307
- key: 0,
2308
- icon: unref(Grid),
2309
- size: "small",
2310
- type: "primary",
2311
- onClick: toggleMode
2312
- }, {
2313
- default: withCtx(() => [..._cache[4] || (_cache[4] = [
2314
- createTextVNode(
2315
- "展开配置",
2316
- -1
2317
- /* CACHED */
2318
- )
2319
- ])]),
2320
- _: 1
2321
- /* STABLE */
2322
- }, 8, ["icon"])) : createCommentVNode("v-if", true),
2323
- __props.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
2324
- key: 1,
2325
- icon: unref(FullScreen),
2326
- size: "small",
2327
- type: "primary",
2328
- onClick: toggleFullscreen
2329
- }, {
2330
- default: withCtx(() => [
2331
- createTextVNode(
2332
- toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"),
2333
- 1
2334
- /* TEXT */
2335
- )
2336
- ]),
2337
- _: 1
2338
- /* STABLE */
2339
- }, 8, ["icon"])) : createCommentVNode("v-if", true),
2340
- importable.value ? (openBlock(), createBlock(unref(TMagicUpload), {
2341
- key: 2,
2342
- style: { "display": "inline-block" },
2343
- ref_key: "excelBtn",
2344
- ref: excelBtn,
2345
- action: "/noop",
2346
- disabled: __props.disabled,
2347
- "on-change": excelHandler,
2348
- "auto-upload": false
2349
- }, {
2350
- default: withCtx(() => [
2351
- createVNode(unref(TMagicButton), {
2352
- size: "small",
2353
- type: "success",
2354
- disabled: __props.disabled,
2355
- plain: ""
2356
- }, {
2357
- default: withCtx(() => [..._cache[5] || (_cache[5] = [
2358
- createTextVNode(
2359
- "导入EXCEL",
2360
- -1
2361
- /* CACHED */
2362
- )
2363
- ])]),
2364
- _: 1
2365
- /* STABLE */
2366
- }, 8, ["disabled"])
2367
- ]),
2368
- _: 1
2369
- /* STABLE */
2370
- }, 8, ["disabled"])) : createCommentVNode("v-if", true),
2371
- importable.value ? (openBlock(), createBlock(unref(TMagicButton), {
2372
- key: 3,
2373
- size: "small",
2374
- type: "warning",
2375
- disabled: __props.disabled,
2376
- plain: "",
2377
- onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
2378
- }, {
2379
- default: withCtx(() => [..._cache[6] || (_cache[6] = [
2380
- createTextVNode(
2381
- "清空",
2382
- -1
2383
- /* CACHED */
2384
- )
2385
- ])]),
2386
- _: 1
2387
- /* STABLE */
2388
- }, 8, ["disabled"])) : createCommentVNode("v-if", true)
2389
- ])
2390
- ]),
2391
- __props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_6, [
2392
- createVNode(unref(TMagicPagination), {
2393
- layout: "total, sizes, prev, pager, next, jumper",
2394
- "hide-on-single-page": __props.model[modelName.value].length < pagesize.value,
2395
- "current-page": pagecontext.value + 1,
2396
- "page-sizes": [pagesize.value, 60, 120, 300],
2397
- "page-size": pagesize.value,
2398
- total: __props.model[modelName.value].length,
2399
- onSizeChange: handleSizeChange,
2400
- onCurrentChange: handleCurrentChange
2401
- }, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total"])
2402
- ])) : createCommentVNode("v-if", true)
2403
- ],
2404
- 2
2405
- /* CLASS */
2406
- )
2407
- ], 8, ["disabled"]))
2408
- ]);
2409
- };
2410
- }
2411
- });
2412
-
2413
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
2414
- ...{
2415
- name: "MFormTabs"
2416
- },
2417
- __name: "Tabs",
2418
- props: {
2419
- model: {},
2420
- lastValues: { default: () => ({}) },
2421
- isCompare: { type: Boolean, default: false },
2422
- config: {},
2423
- name: {},
2424
- size: {},
2425
- labelWidth: {},
2426
- prop: {},
2427
- expandMore: { type: Boolean },
2428
- disabled: { type: Boolean }
2429
- },
2430
- emits: ["change", "addDiffCount"],
2431
- setup(__props, { emit: __emit }) {
2432
- const tabPaneComponent = getDesignConfig("components")?.tabPane;
2433
- const tabsComponent = getDesignConfig("components")?.tabs;
2434
- const getActive = (mForm2, props2, activeTabName2) => {
2435
- const { config, model, prop } = props2;
2436
- const { active } = config;
2437
- if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
2438
- if (0 >= props2.config.items.length) return "0";
2439
- if (typeof active !== "undefined") return active;
2440
- return "0";
2441
- };
2442
- const tabClick = (mForm2, tab, props2) => {
2443
- const { config, model, prop } = props2;
2444
- tab.name = tab.paneName;
2445
- if (typeof config.onTabClick === "function") {
2446
- config.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
2447
- }
2448
- const tabConfig = config.items.find((item) => tab.name === item.status);
2449
- if (tabConfig && typeof tabConfig.onTabClick === "function") {
2450
- tabConfig.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
2451
- }
2452
- };
2453
- const props = __props;
2454
- const emit = __emit;
2455
- const mForm = inject("mForm");
2456
- const activeTabName = ref(getActive(mForm, props));
2457
- const diffCount = ref({});
2458
- const tabs = computed(() => {
2459
- if (props.config.dynamic) {
2460
- if (!props.config.name) throw new Error("dynamic tab 必须配置name");
2461
- return props.model[props.config.name] || [];
2462
- }
2463
- return props.config.items.filter((item) => display(mForm, item.display, props));
2464
- });
2465
- const filter = (config) => filterFunction(mForm, config, props);
2466
- watchEffect(() => {
2467
- if (typeof props.config.activeChange === "function") {
2468
- props.config.activeChange(mForm, activeTabName.value, {
2469
- model: props.model,
2470
- prop: props.prop
2471
- });
2472
- }
2473
- });
2474
- const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
2475
- const tabClickHandler = (tab) => tabClick(mForm, tab, props);
2476
- const onTabAdd = async () => {
2477
- if (!props.name) throw new Error("dynamic tab 必须配置name");
2478
- if (typeof props.config.onTabAdd === "function") {
2479
- props.config.onTabAdd(mForm, {
2480
- model: props.model,
2481
- prop: props.prop,
2482
- config: props.config
2483
- });
2484
- emit("change", props.model);
2485
- } else {
2486
- const newObj = await initValue(mForm, {
2487
- config: props.config.items,
2488
- initValues: {}
2489
- });
2490
- newObj.title = `标签${tabs.value.length + 1}`;
2491
- props.model[props.name].push(newObj);
2492
- emit("change", props.model[props.name], {
2493
- changeRecords: [
2494
- {
2495
- propPath: `${props.prop}.${props.model[props.name].length - 1}`,
2496
- value: newObj
2497
- }
2498
- ]
2499
- });
2500
- }
2501
- mForm?.$emit("field-change", props.prop, props.model[props.name]);
2502
- };
2503
- const onTabRemove = (tabName) => {
2504
- if (!props.name) throw new Error("dynamic tab 必须配置name");
2505
- if (typeof props.config.onTabRemove === "function") {
2506
- props.config.onTabRemove(mForm, tabName, {
2507
- model: props.model,
2508
- prop: props.prop,
2509
- config: props.config
2510
- });
2511
- } else {
2512
- props.model[props.name].splice(+tabName, 1);
2513
- if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
2514
- activeTabName.value = (+activeTabName.value - 1).toString();
2515
- tabClick(mForm, { name: activeTabName.value }, props);
2516
- }
2517
- }
2518
- emit("change", props.model);
2519
- mForm?.$emit("field-change", props.prop, props.model[props.name]);
2520
- };
2521
- const changeHandler = (v, eventData) => {
2522
- emit("change", props.model, eventData);
2523
- };
2524
- const onAddDiffCount = (tabIndex) => {
2525
- if (!diffCount.value[tabIndex]) {
2526
- diffCount.value[tabIndex] = 1;
2527
- } else {
2528
- diffCount.value[tabIndex] += 1;
2529
- }
2530
- emit("addDiffCount");
2531
- };
2532
- return (_ctx, _cache) => {
2533
- return openBlock(), createBlock(resolveDynamicComponent(unref(tabsComponent)?.component || "el-tabs"), mergeProps(
2534
- {
2535
- modelValue: activeTabName.value,
2536
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
2537
- },
2538
- unref(tabsComponent)?.props({
2539
- type: __props.config.tabType,
2540
- editable: __props.config.editable || false,
2541
- tabPosition: __props.config.tabPosition || "top"
2542
- }) || {},
2543
- {
2544
- class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
2545
- onTabClick: tabClickHandler,
2546
- onTabAdd,
2547
- onTabRemove
2548
- }
2549
- ), {
2550
- default: withCtx(() => [
2551
- (openBlock(true), createElementBlock(
2552
- Fragment,
2553
- null,
2554
- renderList(tabs.value, (tab, tabIndex) => {
2555
- return openBlock(), createBlock(
2556
- resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"),
2557
- mergeProps(
2558
- {
2559
- key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex
2560
- },
2561
- { ref_for: true },
2562
- unref(tabPaneComponent)?.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false }) || {}
2563
- ),
2564
- {
2565
- label: withCtx(() => [
2566
- createElementVNode("span", null, [
2567
- createTextVNode(
2568
- toDisplayString(filter(tab.title)),
2569
- 1
2570
- /* TEXT */
2571
- ),
2572
- createVNode(unref(TMagicBadge), {
2573
- hidden: !diffCount.value[tabIndex],
2574
- value: diffCount.value[tabIndex],
2575
- class: "diff-count-badge"
2576
- }, null, 8, ["hidden", "value"])
2577
- ])
2578
- ]),
2579
- default: withCtx(() => [
2580
- (openBlock(true), createElementBlock(
2581
- Fragment,
2582
- null,
2583
- renderList(tabItems(tab), (item) => {
2584
- return openBlock(), createBlock(_sfc_main$x, {
2585
- key: item[unref(mForm)?.keyProp || "__key"],
2586
- config: item,
2587
- disabled: __props.disabled,
2588
- model: __props.config.dynamic ? (__props.name ? __props.model[__props.name] : __props.model)[tabIndex] : tab.name ? (__props.name ? __props.model[__props.name] : __props.model)[tab.name] : __props.name ? __props.model[__props.name] : __props.model,
2589
- "last-values": unref(isEmpty)(__props.lastValues) ? {} : __props.config.dynamic ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tabIndex] : tab.name ? (__props.name ? __props.lastValues[__props.name] : __props.lastValues)[tab.name] : __props.name ? __props.lastValues[__props.name] : __props.lastValues,
2590
- "is-compare": __props.isCompare,
2591
- prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
2592
- size: __props.size,
2593
- "label-width": tab.labelWidth || __props.labelWidth,
2594
- "expand-more": __props.expandMore,
2595
- onChange: changeHandler,
2596
- onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
2597
- }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
2598
- }),
2599
- 128
2600
- /* KEYED_FRAGMENT */
2601
- ))
2602
- ]),
2603
- _: 2
2604
- /* DYNAMIC */
2605
- },
2606
- 1040
2607
- /* FULL_PROPS, DYNAMIC_SLOTS */
2608
- );
2609
- }),
2610
- 128
2611
- /* KEYED_FRAGMENT */
2612
- ))
2613
- ]),
2614
- _: 1
2615
- /* STABLE */
2616
- }, 16, ["modelValue", "class"]);
2617
- };
2618
- }
2619
- });
2620
-
2621
- let $MAGIC_FORM = {};
2622
- const setConfig = (option) => {
2623
- $MAGIC_FORM = option;
2624
- };
2625
- const getConfig = (key) => $MAGIC_FORM[key];
2626
-
2627
- const useAddField = (prop) => {
2628
- if (!prop) return;
2629
- const mForm = inject("mForm");
2630
- const instance = getCurrentInstance();
2631
- watch(
2632
- () => instance?.proxy,
2633
- (vm) => {
2634
- if (vm) {
2635
- mForm?.setField(prop, vm);
2636
- } else {
2637
- mForm?.deleteField(prop);
2638
- }
2639
- },
2640
- {
2641
- immediate: true
2642
- }
2643
- );
2644
- };
2645
-
2646
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
2647
- ...{
2648
- name: "MFormCascader"
2649
- },
2650
- __name: "Cascader",
2651
- props: {
2652
- config: {},
2653
- model: {},
2654
- initValues: {},
2655
- values: {},
2656
- name: {},
2657
- prop: {},
2658
- disabled: { type: Boolean },
2659
- size: {},
2660
- lastValues: {}
2661
- },
2662
- emits: ["change"],
2663
- setup(__props, { emit: __emit }) {
2664
- const props = __props;
2665
- const emit = __emit;
2666
- const mForm = inject("mForm");
2667
- useAddField(props.prop);
2668
- const requestFunc = getConfig("request");
2669
- const tMagicCascader = ref();
2670
- const options = ref([]);
2671
- const remoteData = ref(null);
2672
- const checkStrictly = computed(() => filterFunction(mForm, props.config.checkStrictly, props));
2673
- const valueSeparator = computed(() => filterFunction(mForm, props.config.valueSeparator, props));
2674
- const value = computed({
2675
- get() {
2676
- if (typeof props.model[props.name] === "string" && valueSeparator.value) {
2677
- return props.model[props.name].split(valueSeparator.value);
2678
- }
2679
- return props.model[props.name];
2680
- },
2681
- set(value2) {
2682
- let result = value2;
2683
- if (valueSeparator.value) {
2684
- result = value2.join(valueSeparator.value);
2685
- }
2686
- props.model[props.name] = result;
2687
- }
2688
- });
2689
- const setRemoteOptions = async function() {
2690
- const { config } = props;
2691
- const { option } = config;
2692
- if (!option) return;
2693
- let { body } = option;
2694
- const postOptions = {
2695
- url: option.url,
2696
- cache: option.cache,
2697
- timeout: option.timeout,
2698
- data: {}
2699
- };
2700
- if (body && mForm) {
2701
- if (typeof body === "function" && props.model && mForm) {
2702
- body = body(mForm, {
2703
- model: props.model,
2704
- formValue: mForm.values,
2705
- formValues: mForm.values,
2706
- config: props.config
2707
- });
2708
- }
2709
- postOptions.data = body;
2710
- }
2711
- const res = await requestFunc(postOptions);
2712
- remoteData.value = res[option.root];
2713
- if (remoteData.value && typeof option?.item === "function") {
2714
- options.value = option.item(res[option.root]);
2086
+ const res = await requestFunc(postOptions);
2087
+ remoteData.value = res[option.root];
2088
+ if (remoteData.value && typeof option?.item === "function") {
2089
+ options.value = option.item(res[option.root]);
2715
2090
  }
2716
2091
  };
2717
2092
  if (typeof props.config.options === "function" && props.model && mForm) {
@@ -2737,12 +2112,10 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2737
2112
  if (!tMagicCascader.value) return;
2738
2113
  tMagicCascader.value.setQuery("");
2739
2114
  tMagicCascader.value.setPreviousQuery(null);
2740
- emit("change", props.model[props.name]);
2741
2115
  };
2742
2116
  return (_ctx, _cache) => {
2743
2117
  return openBlock(), createBlock(unref(TMagicCascader), {
2744
- modelValue: value.value,
2745
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
2118
+ "model-value": value.value,
2746
2119
  ref_key: "tMagicCascader",
2747
2120
  ref: tMagicCascader,
2748
2121
  style: { "width": "100%" },
@@ -2758,13 +2131,14 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2758
2131
  emitPath: __props.config.emitPath ?? true,
2759
2132
  checkStrictly: checkStrictly.value ?? false
2760
2133
  },
2134
+ "onUpdate:modelValue": updateModelValueHandler,
2761
2135
  onChange: changeHandler
2762
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
2136
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
2763
2137
  };
2764
2138
  }
2765
2139
  });
2766
2140
 
2767
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
2141
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
2768
2142
  ...{
2769
2143
  name: "MFormCheckbox"
2770
2144
  },
@@ -2810,29 +2184,33 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2810
2184
  };
2811
2185
  return (_ctx, _cache) => {
2812
2186
  return openBlock(), createBlock(unref(TMagicCheckbox), {
2813
- modelValue: __props.model[__props.name],
2814
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2187
+ "model-value": __props.model[__props.name],
2815
2188
  size: __props.size,
2816
2189
  trueValue: activeValue.value,
2817
2190
  falseValue: inactiveValue.value,
2818
2191
  disabled: __props.disabled,
2819
- onChange: changeHandler
2820
- }, {
2821
- default: withCtx(() => [
2822
- createTextVNode(
2823
- toDisplayString(__props.config.text),
2824
- 1
2825
- /* TEXT */
2826
- )
2827
- ]),
2828
- _: 1
2829
- /* STABLE */
2830
- }, 8, ["modelValue", "size", "trueValue", "falseValue", "disabled"]);
2192
+ "onUpdate:modelValue": changeHandler
2193
+ }, createSlots({
2194
+ _: 2
2195
+ /* DYNAMIC */
2196
+ }, [
2197
+ !__props.config.useLabel ? {
2198
+ name: "default",
2199
+ fn: withCtx(() => [
2200
+ createTextVNode(
2201
+ toDisplayString(__props.config.text),
2202
+ 1
2203
+ /* TEXT */
2204
+ )
2205
+ ]),
2206
+ key: "0"
2207
+ } : void 0
2208
+ ]), 1032, ["model-value", "size", "trueValue", "falseValue", "disabled"]);
2831
2209
  };
2832
2210
  }
2833
2211
  });
2834
2212
 
2835
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
2213
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2836
2214
  ...{
2837
2215
  name: "MFormCheckGroup"
2838
2216
  },
@@ -2868,11 +2246,10 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2868
2246
  });
2869
2247
  return (_ctx, _cache) => {
2870
2248
  return openBlock(), createBlock(unref(TMagicCheckboxGroup), {
2871
- modelValue: __props.model[__props.name],
2872
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2249
+ "model-value": __props.model[__props.name],
2873
2250
  size: __props.size,
2874
2251
  disabled: __props.disabled,
2875
- onChange: changeHandler
2252
+ "onUpdate:modelValue": changeHandler
2876
2253
  }, {
2877
2254
  default: withCtx(() => [
2878
2255
  (openBlock(true), createElementBlock(
@@ -2901,12 +2278,12 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2901
2278
  ]),
2902
2279
  _: 1
2903
2280
  /* STABLE */
2904
- }, 8, ["modelValue", "size", "disabled"]);
2281
+ }, 8, ["model-value", "size", "disabled"]);
2905
2282
  };
2906
2283
  }
2907
2284
  });
2908
2285
 
2909
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
2286
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
2910
2287
  ...{
2911
2288
  name: "MFormColorPicker"
2912
2289
  },
@@ -2930,18 +2307,17 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
2930
2307
  const changeHandler = (value) => emit("change", value);
2931
2308
  return (_ctx, _cache) => {
2932
2309
  return openBlock(), createBlock(unref(TMagicColorPicker), {
2933
- modelValue: __props.model[__props.name],
2934
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2310
+ "model-value": __props.model[__props.name],
2935
2311
  size: __props.size,
2936
2312
  disabled: __props.disabled,
2937
2313
  showAlpha: true,
2938
- onChange: changeHandler
2939
- }, null, 8, ["modelValue", "size", "disabled"]);
2314
+ "onUpdate:modelValue": changeHandler
2315
+ }, null, 8, ["model-value", "size", "disabled"]);
2940
2316
  };
2941
2317
  }
2942
2318
  });
2943
2319
 
2944
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
2320
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
2945
2321
  ...{
2946
2322
  name: "MFormDate"
2947
2323
  },
@@ -2968,21 +2344,20 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2968
2344
  };
2969
2345
  return (_ctx, _cache) => {
2970
2346
  return openBlock(), createBlock(unref(TMagicDatePicker), {
2971
- modelValue: __props.model[__props.name],
2972
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2347
+ "model-value": __props.model[__props.name],
2973
2348
  type: "date",
2974
2349
  size: __props.size,
2975
2350
  placeholder: __props.config.placeholder,
2976
2351
  disabled: __props.disabled,
2977
2352
  format: __props.config.format || "YYYY/MM/DD",
2978
2353
  "value-format": __props.config.valueFormat || "YYYY/MM/DD",
2979
- onChange: changeHandler
2980
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
2354
+ "onUpdate:modelValue": changeHandler
2355
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "format", "value-format"]);
2981
2356
  };
2982
2357
  }
2983
2358
  });
2984
2359
 
2985
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
2360
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2986
2361
  ...{
2987
2362
  name: "MFormDateRange"
2988
2363
  },
@@ -3063,8 +2438,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3063
2438
  };
3064
2439
  return (_ctx, _cache) => {
3065
2440
  return openBlock(), createBlock(unref(TMagicDatePicker), {
3066
- modelValue: value.value,
3067
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
2441
+ "model-value": value.value,
3068
2442
  type: "datetimerange",
3069
2443
  "range-separator": "-",
3070
2444
  "start-placeholder": "开始日期",
@@ -3076,13 +2450,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3076
2450
  "value-format": __props.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
3077
2451
  "date-format": __props.config.dateFormat || "YYYY/MM/DD",
3078
2452
  "time-format": __props.config.timeFormat || "HH:mm:ss",
3079
- onChange: changeHandler
3080
- }, null, 8, ["modelValue", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
2453
+ "onUpdate:modelValue": changeHandler
2454
+ }, null, 8, ["model-value", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
3081
2455
  };
3082
2456
  }
3083
2457
  });
3084
2458
 
3085
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
2459
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
3086
2460
  ...{
3087
2461
  name: "MFormDateTime"
3088
2462
  },
@@ -3120,8 +2494,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3120
2494
  };
3121
2495
  return (_ctx, _cache) => {
3122
2496
  return openBlock(), createBlock(unref(TMagicDatePicker), {
3123
- modelValue: __props.model[__props.name],
3124
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
2497
+ "model-value": __props.model[__props.name],
3125
2498
  "popper-class": "magic-datetime-picker-popper",
3126
2499
  type: "datetime",
3127
2500
  size: __props.size,
@@ -3130,14 +2503,14 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3130
2503
  format: __props.config.format || "YYYY/MM/DD HH:mm:ss",
3131
2504
  "value-format": __props.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
3132
2505
  "default-time": __props.config.defaultTime,
3133
- onChange: changeHandler
3134
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time"]);
2506
+ "onUpdate:modelValue": changeHandler
2507
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "format", "value-format", "default-time"]);
3135
2508
  };
3136
2509
  }
3137
2510
  });
3138
2511
 
3139
2512
  const _hoisted_1$8 = { key: 0 };
3140
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
2513
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
3141
2514
  ...{
3142
2515
  name: "MFormDisplay"
3143
2516
  },
@@ -3172,7 +2545,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3172
2545
  });
3173
2546
 
3174
2547
  const _hoisted_1$7 = { class: "m-fields-dynamic-field" };
3175
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
2548
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3176
2549
  ...{
3177
2550
  name: "MFormDynamicField"
3178
2551
  },
@@ -3273,7 +2646,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3273
2646
  }
3274
2647
  });
3275
2648
 
3276
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
2649
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3277
2650
  ...{
3278
2651
  name: "MFormHidden"
3279
2652
  },
@@ -3310,7 +2683,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3310
2683
  }
3311
2684
  });
3312
2685
 
3313
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
2686
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3314
2687
  ...{
3315
2688
  name: "MForm"
3316
2689
  },
@@ -3337,7 +2710,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3337
2710
  setup(__props, { expose: __expose, emit: __emit }) {
3338
2711
  const props = __props;
3339
2712
  const emit = __emit;
3340
- const tMagicForm = ref();
2713
+ const tMagicFormRef = useTemplateRef("tMagicForm");
3341
2714
  const initialized = ref(false);
3342
2715
  const values = ref({});
3343
2716
  const lastValuesProcessed = ref({});
@@ -3414,7 +2787,17 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3414
2787
  );
3415
2788
  const changeHandler = (v, eventData) => {
3416
2789
  if (eventData.changeRecords?.length) {
3417
- changeRecords.value.push(...eventData.changeRecords);
2790
+ for (const record of eventData.changeRecords) {
2791
+ if (record.propPath) {
2792
+ const index = changeRecords.value.findIndex((item) => item.propPath === record.propPath);
2793
+ if (index > -1) {
2794
+ changeRecords.value[index] = record;
2795
+ } else {
2796
+ changeRecords.value.push(record);
2797
+ }
2798
+ setValueByKeyPath(record.propPath, record.value, values.value);
2799
+ }
2800
+ }
3418
2801
  }
3419
2802
  emit("change", values.value, eventData);
3420
2803
  };
@@ -3423,6 +2806,31 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3423
2806
  e.preventDefault();
3424
2807
  }
3425
2808
  };
2809
+ const getTextByName = (name, config = props.config) => {
2810
+ if (!name || !Array.isArray(config)) return void 0;
2811
+ const nameParts = name.split(".");
2812
+ const findInConfig = (configs, parts) => {
2813
+ if (parts.length === 0) return void 0;
2814
+ const [currentPart, ...remainingParts] = parts;
2815
+ for (const item of configs) {
2816
+ if (item.name === currentPart) {
2817
+ if (remainingParts.length === 0) {
2818
+ return typeof item.text === "string" ? item.text : void 0;
2819
+ }
2820
+ if (item.items && Array.isArray(item.items)) {
2821
+ const result = findInConfig(item.items, remainingParts);
2822
+ if (result !== void 0) return result;
2823
+ }
2824
+ }
2825
+ if (item.items && Array.isArray(item.items)) {
2826
+ const result = findInConfig(item.items, parts);
2827
+ if (result !== void 0) return result;
2828
+ }
2829
+ }
2830
+ return void 0;
2831
+ };
2832
+ return findInConfig(config, nameParts);
2833
+ };
3426
2834
  __expose({
3427
2835
  values,
3428
2836
  lastValuesProcessed,
@@ -3431,32 +2839,36 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3431
2839
  changeRecords,
3432
2840
  changeHandler,
3433
2841
  resetForm: () => {
3434
- tMagicForm.value?.resetFields();
2842
+ tMagicFormRef.value?.resetFields();
3435
2843
  changeRecords.value = [];
3436
2844
  },
3437
2845
  submitForm: async (native) => {
3438
2846
  try {
3439
- await tMagicForm.value?.validate();
2847
+ const result = await tMagicFormRef.value?.validate();
2848
+ if (result !== true) {
2849
+ throw result;
2850
+ }
2851
+ changeRecords.value = [];
3440
2852
  return native ? values.value : cloneDeep(toRaw(values.value));
3441
2853
  } catch (invalidFields) {
3442
2854
  emit("error", invalidFields);
3443
2855
  const error = [];
3444
- Object.entries(invalidFields).forEach(([, ValidateError]) => {
2856
+ Object.entries(invalidFields).forEach(([prop, ValidateError]) => {
3445
2857
  ValidateError.forEach(({ field, message }) => {
3446
- if (field && message) error.push(`${field} -> ${message}`);
3447
- if (field && !message) error.push(`${field} -> 出现错误`);
3448
- if (!field && message) error.push(`${message}`);
2858
+ const name = field || prop;
2859
+ const text = getTextByName(name, props.config) || name;
2860
+ error.push(`${text} -> ${message}`);
3449
2861
  });
3450
2862
  });
3451
2863
  throw new Error(error.join("<br>"));
3452
2864
  }
3453
- }
2865
+ },
2866
+ getTextByName
3454
2867
  });
3455
2868
  return (_ctx, _cache) => {
3456
2869
  return openBlock(), createBlock(unref(TMagicForm), {
3457
2870
  class: "m-form",
3458
- ref_key: "tMagicForm",
3459
- ref: tMagicForm,
2871
+ ref: "tMagicForm",
3460
2872
  model: values.value,
3461
2873
  "label-width": __props.labelWidth,
3462
2874
  style: normalizeStyle(`height: ${__props.height}`),
@@ -3469,7 +2881,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3469
2881
  Fragment,
3470
2882
  { key: 0 },
3471
2883
  renderList(__props.config, (item, index) => {
3472
- return openBlock(), createBlock(_sfc_main$x, {
2884
+ return openBlock(), createBlock(_sfc_main$A, {
3473
2885
  disabled: __props.disabled,
3474
2886
  key: item[__props.keyProp] ?? index,
3475
2887
  config: item,
@@ -3494,7 +2906,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3494
2906
  });
3495
2907
 
3496
2908
  const _hoisted_1$6 = { style: { "min-height": "1px" } };
3497
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
2909
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3498
2910
  ...{
3499
2911
  name: "MFormDialog"
3500
2912
  },
@@ -3695,7 +3107,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3695
3107
  style: normalizeStyle(`max-height: ${bodyHeight.value}; overflow-y: auto; overflow-x: hidden;`)
3696
3108
  },
3697
3109
  [
3698
- createVNode(_sfc_main$d, {
3110
+ createVNode(_sfc_main$g, {
3699
3111
  modelValue: stepActive.value,
3700
3112
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => stepActive.value = $event),
3701
3113
  ref_key: "form",
@@ -3725,11 +3137,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3725
3137
  });
3726
3138
 
3727
3139
  const _hoisted_1$5 = ["href"];
3728
- const _hoisted_2$1 = {
3140
+ const _hoisted_2$2 = {
3729
3141
  key: 2,
3730
3142
  class: "m-fields-link"
3731
3143
  };
3732
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
3144
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3733
3145
  ...{
3734
3146
  name: "MFormLink"
3735
3147
  },
@@ -3807,7 +3219,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3807
3219
  toDisplayString(displayText.value),
3808
3220
  5
3809
3221
  /* TEXT, STYLE */
3810
- )) : (openBlock(), createElementBlock("div", _hoisted_2$1, [
3222
+ )) : (openBlock(), createElementBlock("div", _hoisted_2$2, [
3811
3223
  createVNode(unref(TMagicButton), {
3812
3224
  link: "",
3813
3225
  type: "primary",
@@ -3823,7 +3235,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3823
3235
  _: 1
3824
3236
  /* STABLE */
3825
3237
  }),
3826
- createVNode(_sfc_main$c, {
3238
+ createVNode(_sfc_main$f, {
3827
3239
  ref_key: "editor",
3828
3240
  ref: editor,
3829
3241
  title: __props.config.formTitle || "编辑扩展配置",
@@ -3839,7 +3251,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3839
3251
  }
3840
3252
  });
3841
3253
 
3842
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
3254
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3843
3255
  ...{
3844
3256
  name: "MFormNumber"
3845
3257
  },
@@ -3871,8 +3283,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
3871
3283
  return (_ctx, _cache) => {
3872
3284
  return __props.model ? (openBlock(), createBlock(unref(TMagicInputNumber), {
3873
3285
  key: 0,
3874
- modelValue: __props.model[__props.name],
3875
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3286
+ "model-value": __props.model[__props.name],
3876
3287
  clearable: "",
3877
3288
  "controls-position": "right",
3878
3289
  size: __props.size,
@@ -3881,15 +3292,15 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
3881
3292
  step: __props.config.step,
3882
3293
  placeholder: __props.config.placeholder,
3883
3294
  disabled: __props.disabled,
3884
- onChange: changeHandler,
3295
+ "onUpdate:modelValue": changeHandler,
3885
3296
  onInput: inputHandler
3886
- }, null, 8, ["modelValue", "size", "max", "min", "step", "placeholder", "disabled"])) : createCommentVNode("v-if", true);
3297
+ }, null, 8, ["model-value", "size", "max", "min", "step", "placeholder", "disabled"])) : createCommentVNode("v-if", true);
3887
3298
  };
3888
3299
  }
3889
3300
  });
3890
3301
 
3891
3302
  const _hoisted_1$4 = { class: "m-fields-number-range" };
3892
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3303
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
3893
3304
  ...{
3894
3305
  name: "MFormNumberRange"
3895
3306
  },
@@ -3922,14 +3333,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3922
3333
  return (_ctx, _cache) => {
3923
3334
  return openBlock(), createElementBlock("div", _hoisted_1$4, [
3924
3335
  createVNode(unref(TMagicInput), {
3925
- modelValue: __props.model[__props.name][0],
3926
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name][0] = $event),
3927
- clearable: "",
3336
+ "model-value": __props.model[__props.name][0],
3337
+ clearable: __props.config.clearable ?? true,
3928
3338
  size: __props.size,
3929
3339
  disabled: __props.disabled,
3930
- onChange: minChangeHandler
3931
- }, null, 8, ["modelValue", "size", "disabled"]),
3932
- _cache[2] || (_cache[2] = createElementVNode(
3340
+ "onUpdate:modelValue": minChangeHandler
3341
+ }, null, 8, ["model-value", "clearable", "size", "disabled"]),
3342
+ _cache[0] || (_cache[0] = createElementVNode(
3933
3343
  "span",
3934
3344
  { class: "split-tag" },
3935
3345
  "-",
@@ -3937,20 +3347,18 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3937
3347
  /* CACHED */
3938
3348
  )),
3939
3349
  createVNode(unref(TMagicInput), {
3940
- modelValue: __props.model[__props.name][1],
3941
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => __props.model[__props.name][1] = $event),
3942
- clearable: "",
3350
+ "model-value": __props.model[__props.name][1],
3351
+ clearable: __props.config.clearable ?? true,
3943
3352
  size: __props.size,
3944
3353
  disabled: __props.disabled,
3945
- onChange: maxChangeHandler
3946
- }, null, 8, ["modelValue", "size", "disabled"])
3354
+ "onUpdate:modelValue": maxChangeHandler
3355
+ }, null, 8, ["model-value", "clearable", "size", "disabled"])
3947
3356
  ]);
3948
3357
  };
3949
3358
  }
3950
3359
  });
3951
3360
 
3952
- const _hoisted_1$3 = { key: 1 };
3953
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3361
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
3954
3362
  ...{
3955
3363
  name: "MFormRadioGroup"
3956
3364
  },
@@ -3971,12 +3379,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3971
3379
  const props = __props;
3972
3380
  const itemComponent = computed(() => props.config.childType === "button" ? TMagicRadioButton : TMagicRadio);
3973
3381
  const emit = __emit;
3974
- const changeHandler = (value) => {
3975
- emit("change", value);
3976
- };
3977
3382
  const clickHandler = (item) => {
3978
- props.model[props.name] = props.model[props.name] === item ? "" : item;
3979
- changeHandler(props.model[props.name]);
3383
+ emit("change", props.model[props.name] === item ? "" : item);
3980
3384
  };
3981
3385
  useAddField(props.prop);
3982
3386
  const iconSize = computed(() => {
@@ -3991,8 +3395,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3991
3395
  return (_ctx, _cache) => {
3992
3396
  return __props.model ? (openBlock(), createBlock(unref(TMagicRadioGroup), {
3993
3397
  key: 0,
3994
- modelValue: __props.model[__props.name],
3995
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3398
+ "model-value": __props.model[__props.name],
3996
3399
  size: __props.size,
3997
3400
  disabled: __props.disabled
3998
3401
  }, {
@@ -4004,11 +3407,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4004
3407
  return openBlock(), createBlock(resolveDynamicComponent(itemComponent.value), {
4005
3408
  value: option.value,
4006
3409
  key: `${option.value}`,
4007
- onClick: withModifiers(($event) => clickHandler(option.value), ["prevent"])
3410
+ onClick: ($event) => clickHandler(option.value)
4008
3411
  }, {
4009
3412
  default: withCtx(() => [
4010
- option.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
4011
- key: 0,
3413
+ createVNode(unref(TMagicTooltip), {
3414
+ disabled: !Boolean(option.tooltip),
4012
3415
  placement: "top-start",
4013
3416
  content: option.tooltip
4014
3417
  }, {
@@ -4035,25 +3438,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4035
3438
  ]),
4036
3439
  _: 2
4037
3440
  /* DYNAMIC */
4038
- }, 1032, ["content"])) : (openBlock(), createElementBlock("div", _hoisted_1$3, [
4039
- option.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
4040
- key: 0,
4041
- size: iconSize.value
4042
- }, {
4043
- default: withCtx(() => [
4044
- (openBlock(), createBlock(resolveDynamicComponent(option.icon)))
4045
- ]),
4046
- _: 2
4047
- /* DYNAMIC */
4048
- }, 1032, ["size"])) : createCommentVNode("v-if", true),
4049
- createElementVNode(
4050
- "span",
4051
- null,
4052
- toDisplayString(option.text),
4053
- 1
4054
- /* TEXT */
4055
- )
4056
- ]))
3441
+ }, 1032, ["disabled", "content"])
4057
3442
  ]),
4058
3443
  _: 2
4059
3444
  /* DYNAMIC */
@@ -4065,13 +3450,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4065
3450
  ]),
4066
3451
  _: 1
4067
3452
  /* STABLE */
4068
- }, 8, ["modelValue", "size", "disabled"])) : createCommentVNode("v-if", true);
3453
+ }, 8, ["model-value", "size", "disabled"])) : createCommentVNode("v-if", true);
4069
3454
  };
4070
3455
  }
4071
3456
  });
4072
3457
 
4073
- const _hoisted_1$2 = { key: 2 };
4074
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3458
+ const _hoisted_1$3 = { key: 2 };
3459
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4075
3460
  ...{
4076
3461
  name: "MFormSelect"
4077
3462
  },
@@ -4398,8 +3783,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4398
3783
  const _directive_loading = resolveDirective("loading");
4399
3784
  return __props.model ? withDirectives((openBlock(), createBlock(unref(TMagicSelect), {
4400
3785
  key: 0,
4401
- modelValue: __props.model[__props.name],
4402
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3786
+ "model-value": __props.model[__props.name],
4403
3787
  class: "m-select",
4404
3788
  ref_key: "tMagicSelect",
4405
3789
  ref: tMagicSelect,
@@ -4414,7 +3798,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4414
3798
  "allow-create": __props.config.allowCreate,
4415
3799
  disabled: __props.disabled,
4416
3800
  "remote-method": __props.config.remote && remoteMethod,
4417
- onChange: changeHandler,
3801
+ "onUpdate:modelValue": changeHandler,
4418
3802
  onVisibleChange: visibleHandler
4419
3803
  }, {
4420
3804
  default: withCtx(() => [
@@ -4506,7 +3890,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4506
3890
  )),
4507
3891
  moreLoadingVisible.value ? withDirectives((openBlock(), createElementBlock(
4508
3892
  "div",
4509
- _hoisted_1$2,
3893
+ _hoisted_1$3,
4510
3894
  null,
4511
3895
  512
4512
3896
  /* NEED_PATCH */
@@ -4516,14 +3900,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4516
3900
  ]),
4517
3901
  _: 1
4518
3902
  /* STABLE */
4519
- }, 8, ["modelValue", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
3903
+ }, 8, ["model-value", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
4520
3904
  [_directive_loading, loading.value]
4521
3905
  ]) : createCommentVNode("v-if", true);
4522
3906
  };
4523
3907
  }
4524
3908
  });
4525
3909
 
4526
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3910
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4527
3911
  ...{
4528
3912
  name: "MFormSwitch"
4529
3913
  },
@@ -4569,21 +3953,21 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4569
3953
  });
4570
3954
  return (_ctx, _cache) => {
4571
3955
  return openBlock(), createBlock(unref(TMagicSwitch), {
4572
- modelValue: __props.model[__props.name],
4573
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
3956
+ "model-value": __props.model[__props.name],
4574
3957
  size: __props.size,
4575
3958
  activeValue: activeValue.value,
4576
3959
  inactiveValue: inactiveValue.value,
4577
3960
  disabled: __props.disabled,
4578
- onChange: changeHandler
4579
- }, null, 8, ["modelValue", "size", "activeValue", "inactiveValue", "disabled"]);
3961
+ "onUpdate:modelValue": changeHandler
3962
+ }, null, 8, ["model-value", "size", "activeValue", "inactiveValue", "disabled"]);
4580
3963
  };
4581
3964
  }
4582
3965
  });
4583
3966
 
4584
- const _hoisted_1$1 = { class: "m-fields-text" };
4585
- const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
4586
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3967
+ const _hoisted_1$2 = { class: "m-fields-text" };
3968
+ const _hoisted_2$1 = { key: 1 };
3969
+ const _hoisted_3$1 = { style: { "display": "flex", "justify-content": "flex-end" } };
3970
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4587
3971
  ...{
4588
3972
  name: "MFormText"
4589
3973
  },
@@ -4608,16 +3992,25 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4608
3992
  const appendConfig = computed(() => {
4609
3993
  if (typeof props.config.append === "string") {
4610
3994
  return {
3995
+ type: "text",
4611
3996
  text: props.config.append,
4612
- type: "button",
4613
3997
  handler: void 0
4614
3998
  };
4615
3999
  }
4616
- if (props.config.append && typeof props.config.append === "object") {
4617
- if (props.config.append.value === 0) {
4618
- return false;
4000
+ if (typeof props.config.append === "object") {
4001
+ if (typeof props.config.append?.handler === "function") {
4002
+ return {
4003
+ type: "button",
4004
+ text: props.config.append.text,
4005
+ handler: props.config.append.handler
4006
+ };
4007
+ }
4008
+ if (props.config.append) {
4009
+ if (props.config.append.value === 0) {
4010
+ return false;
4011
+ }
4012
+ return props.config.append;
4619
4013
  }
4620
- return props.config.append;
4621
4014
  }
4622
4015
  return false;
4623
4016
  });
@@ -4722,23 +4115,35 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4722
4115
  instanceRef.value = void 0;
4723
4116
  };
4724
4117
  return (_ctx, _cache) => {
4725
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
4118
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
4726
4119
  createVNode(unref(TMagicInput), {
4727
- modelValue: __props.model[__props.name],
4728
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
4120
+ "model-value": __props.model[__props.name],
4729
4121
  ref_key: "input",
4730
4122
  ref: input,
4731
4123
  clearable: "",
4732
4124
  size: __props.size,
4733
4125
  placeholder: __props.config.placeholder,
4734
4126
  disabled: __props.disabled,
4735
- onChange: changeHandler,
4127
+ "onUpdate:modelValue": changeHandler,
4736
4128
  onInput: inputHandler,
4737
- onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
4129
+ onKeyup: _cache[0] || (_cache[0] = ($event) => keyUpHandler($event))
4738
4130
  }, createSlots({
4739
4131
  _: 2
4740
4132
  /* DYNAMIC */
4741
4133
  }, [
4134
+ __props.config.prepend ? {
4135
+ name: "prepend",
4136
+ fn: withCtx(() => [
4137
+ createElementVNode(
4138
+ "span",
4139
+ null,
4140
+ toDisplayString(__props.config.prepend),
4141
+ 1
4142
+ /* TEXT */
4143
+ )
4144
+ ]),
4145
+ key: "0"
4146
+ } : void 0,
4742
4147
  appendConfig.value ? {
4743
4148
  name: "append",
4744
4149
  fn: withCtx(() => [
@@ -4757,11 +4162,17 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4757
4162
  ]),
4758
4163
  _: 1
4759
4164
  /* STABLE */
4760
- }, 8, ["size"])) : createCommentVNode("v-if", true)
4165
+ }, 8, ["size"])) : (openBlock(), createElementBlock(
4166
+ "span",
4167
+ _hoisted_2$1,
4168
+ toDisplayString(appendConfig.value.text),
4169
+ 1
4170
+ /* TEXT */
4171
+ ))
4761
4172
  ]),
4762
- key: "0"
4173
+ key: "1"
4763
4174
  } : void 0
4764
- ]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
4175
+ ]), 1032, ["model-value", "size", "placeholder", "disabled"]),
4765
4176
  (openBlock(), createBlock(Teleport, { to: "body" }, [
4766
4177
  popoverVisible.value ? (openBlock(), createElementBlock(
4767
4178
  "div",
@@ -4772,20 +4183,20 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4772
4183
  ref: popoverEl
4773
4184
  },
4774
4185
  [
4775
- _cache[5] || (_cache[5] = createElementVNode(
4186
+ _cache[4] || (_cache[4] = createElementVNode(
4776
4187
  "div",
4777
4188
  { class: "m-form-validate__warning" },
4778
4189
  "输入内容前后有空格,是否移除空格?",
4779
4190
  -1
4780
4191
  /* CACHED */
4781
4192
  )),
4782
- createElementVNode("div", _hoisted_2, [
4193
+ createElementVNode("div", _hoisted_3$1, [
4783
4194
  createVNode(unref(TMagicButton), {
4784
4195
  link: "",
4785
4196
  size: "small",
4786
- onClick: _cache[2] || (_cache[2] = ($event) => popoverVisible.value = false)
4197
+ onClick: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
4787
4198
  }, {
4788
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
4199
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
4789
4200
  createTextVNode(
4790
4201
  "保持原样",
4791
4202
  -1
@@ -4800,7 +4211,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4800
4211
  size: "small",
4801
4212
  onClick: confirmTrimHandler
4802
4213
  }, {
4803
- default: withCtx(() => [..._cache[4] || (_cache[4] = [
4214
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
4804
4215
  createTextVNode(
4805
4216
  "移除空格",
4806
4217
  -1
@@ -4811,7 +4222,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4811
4222
  /* STABLE */
4812
4223
  })
4813
4224
  ]),
4814
- _cache[6] || (_cache[6] = createElementVNode(
4225
+ _cache[5] || (_cache[5] = createElementVNode(
4815
4226
  "span",
4816
4227
  {
4817
4228
  class: "tmagic-form-text-popper-arrow",
@@ -4831,162 +4242,990 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4831
4242
  }
4832
4243
  });
4833
4244
 
4245
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4246
+ ...{
4247
+ name: "MFormTextarea"
4248
+ },
4249
+ __name: "Textarea",
4250
+ props: {
4251
+ config: {},
4252
+ model: {},
4253
+ initValues: {},
4254
+ values: {},
4255
+ name: {},
4256
+ prop: {},
4257
+ disabled: { type: Boolean },
4258
+ size: {},
4259
+ lastValues: {}
4260
+ },
4261
+ emits: ["change", "input"],
4262
+ setup(__props, { emit: __emit }) {
4263
+ const props = __props;
4264
+ const emit = __emit;
4265
+ useAddField(props.prop);
4266
+ const mForm = inject("mForm");
4267
+ const changeHandler = (value) => {
4268
+ emit("change", value);
4269
+ };
4270
+ const inputHandler = (v) => {
4271
+ emit("input", v);
4272
+ mForm?.$emit("field-input", props.prop, v);
4273
+ };
4274
+ return (_ctx, _cache) => {
4275
+ return openBlock(), createBlock(unref(TMagicInput), {
4276
+ "model-value": __props.model[__props.name],
4277
+ type: "textarea",
4278
+ size: __props.size,
4279
+ clearable: "",
4280
+ placeholder: __props.config.placeholder,
4281
+ disabled: __props.disabled,
4282
+ rows: __props.config.rows,
4283
+ "onUpdate:modelValue": changeHandler,
4284
+ onInput: inputHandler
4285
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "rows"]);
4286
+ };
4287
+ }
4288
+ });
4289
+
4290
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4291
+ ...{
4292
+ name: "MFormTime"
4293
+ },
4294
+ __name: "Time",
4295
+ props: {
4296
+ config: {},
4297
+ model: {},
4298
+ initValues: {},
4299
+ values: {},
4300
+ name: {},
4301
+ prop: {},
4302
+ disabled: { type: Boolean },
4303
+ size: {},
4304
+ lastValues: {}
4305
+ },
4306
+ emits: ["change"],
4307
+ setup(__props, { emit: __emit }) {
4308
+ const props = __props;
4309
+ const emit = __emit;
4310
+ useAddField(props.prop);
4311
+ const changeHandler = (v) => {
4312
+ emit("change", v);
4313
+ };
4314
+ return (_ctx, _cache) => {
4315
+ return openBlock(), createBlock(unref(TMagicTimePicker), {
4316
+ "model-value": __props.model[__props.name],
4317
+ "value-format": __props.config.valueFormat || "HH:mm:ss",
4318
+ format: __props.config.format || "HH:mm:ss",
4319
+ size: __props.size,
4320
+ placeholder: __props.config.placeholder,
4321
+ disabled: __props.disabled,
4322
+ "onUpdate:modelValue": changeHandler
4323
+ }, null, 8, ["model-value", "value-format", "format", "size", "placeholder", "disabled"]);
4324
+ };
4325
+ }
4326
+ });
4327
+
4328
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4329
+ ...{
4330
+ name: "MFormTimeRange"
4331
+ },
4332
+ __name: "Timerange",
4333
+ props: {
4334
+ config: {},
4335
+ model: {},
4336
+ initValues: {},
4337
+ values: {},
4338
+ name: {},
4339
+ prop: {},
4340
+ disabled: { type: Boolean },
4341
+ size: {},
4342
+ lastValues: {}
4343
+ },
4344
+ emits: ["change"],
4345
+ setup(__props, { emit: __emit }) {
4346
+ const props = __props;
4347
+ const emit = __emit;
4348
+ useAddField(props.prop);
4349
+ const { names } = props.config;
4350
+ const value = ref([]);
4351
+ if (props.model !== void 0 && names?.length) {
4352
+ watch(
4353
+ [() => props.model[names[0]], () => props.model[names[1]]],
4354
+ ([start, end], [preStart, preEnd]) => {
4355
+ if (!value.value) {
4356
+ value.value = [];
4357
+ }
4358
+ if (!start || !end) value.value = [];
4359
+ if (start !== preStart) value.value[0] = start;
4360
+ if (end !== preEnd) value.value[1] = end;
4361
+ },
4362
+ {
4363
+ immediate: true
4364
+ }
4365
+ );
4366
+ }
4367
+ const setValue = (v) => {
4368
+ names?.forEach((item, index) => {
4369
+ if (!props.model) {
4370
+ return;
4371
+ }
4372
+ if (Array.isArray(v)) {
4373
+ props.model[item] = v[index];
4374
+ } else {
4375
+ props.model[item] = void 0;
4376
+ }
4377
+ });
4378
+ };
4379
+ const changeHandler = (v) => {
4380
+ const value2 = v || [];
4381
+ if (names?.length) {
4382
+ setValue(value2);
4383
+ }
4384
+ emit("change", value2);
4385
+ };
4386
+ return (_ctx, _cache) => {
4387
+ return openBlock(), createBlock(unref(TMagicTimePicker), {
4388
+ "model-value": value.value,
4389
+ "is-range": "",
4390
+ "range-separator": "-",
4391
+ "start-placeholder": "开始时间",
4392
+ "end-placeholder": "结束时间",
4393
+ size: __props.size,
4394
+ "unlink-panels": true,
4395
+ disabled: __props.disabled,
4396
+ "default-time": __props.config.defaultTime,
4397
+ "onUpdate:modelValue": changeHandler
4398
+ }, null, 8, ["model-value", "size", "disabled", "default-time"]);
4399
+ };
4400
+ }
4401
+ });
4402
+
4403
+ const useAdd = (props, emit) => {
4404
+ const mForm = inject("mForm");
4405
+ const addable = computed(() => {
4406
+ const modelName = props.name || props.config.name || "";
4407
+ if (!props.model[modelName].length) {
4408
+ return true;
4409
+ }
4410
+ if (typeof props.config.addable === "function") {
4411
+ return props.config.addable(mForm, {
4412
+ model: props.model[modelName],
4413
+ formValue: mForm?.values,
4414
+ prop: props.prop
4415
+ });
4416
+ }
4417
+ return typeof props.config.addable === "undefined" ? true : props.config.addable;
4418
+ });
4419
+ const newHandler = async (row) => {
4420
+ const modelName = props.name || props.config.name || "";
4421
+ if (props.config.max && props.model[modelName].length >= props.config.max) {
4422
+ tMagicMessage.error(`最多新增配置不能超过${props.config.max}条`);
4423
+ return;
4424
+ }
4425
+ if (typeof props.config.beforeAddRow === "function") {
4426
+ const beforeCheckRes = props.config.beforeAddRow(mForm, {
4427
+ model: props.model[modelName],
4428
+ formValue: mForm?.values,
4429
+ prop: props.prop
4430
+ });
4431
+ if (!beforeCheckRes) return;
4432
+ }
4433
+ const columns = props.config.items;
4434
+ const enumValues = props.config.enum || [];
4435
+ let enumV = [];
4436
+ const { length } = props.model[modelName];
4437
+ const key = props.config.key || "id";
4438
+ let inputs = {};
4439
+ if (enumValues.length) {
4440
+ if (length >= enumValues.length) {
4441
+ return;
4442
+ }
4443
+ enumV = enumValues.filter((item) => {
4444
+ let i = 0;
4445
+ for (; i < length; i++) {
4446
+ if (item[key] === props.model[modelName][i][key]) {
4447
+ break;
4448
+ }
4449
+ }
4450
+ return i === length;
4451
+ });
4452
+ if (enumV.length > 0) {
4453
+ inputs = enumV[0];
4454
+ }
4455
+ } else if (Array.isArray(row)) {
4456
+ columns.forEach((column, index) => {
4457
+ column.name && (inputs[column.name] = row[index]);
4458
+ });
4459
+ } else {
4460
+ if (typeof props.config.defaultAdd === "function") {
4461
+ inputs = await props.config.defaultAdd(mForm, {
4462
+ model: props.model[modelName],
4463
+ formValue: mForm?.values
4464
+ });
4465
+ } else if (props.config.defaultAdd) {
4466
+ inputs = props.config.defaultAdd;
4467
+ }
4468
+ inputs = await initValue(mForm, {
4469
+ config: columns,
4470
+ initValues: inputs
4471
+ });
4472
+ }
4473
+ if (props.sortKey && length) {
4474
+ inputs[props.sortKey] = props.model[modelName][length - 1][props.sortKey] - 1;
4475
+ }
4476
+ emit("change", [...props.model[modelName], inputs], {
4477
+ changeRecords: [
4478
+ {
4479
+ propPath: `${props.prop}.${props.model[modelName].length}`,
4480
+ value: inputs
4481
+ }
4482
+ ]
4483
+ });
4484
+ };
4485
+ return {
4486
+ addable,
4487
+ newHandler
4488
+ };
4489
+ };
4490
+
4491
+ const useFullscreen = () => {
4492
+ const isFullscreen = ref(false);
4493
+ const mTableEl = useTemplateRef("mTable");
4494
+ const { nextZIndex } = useZIndex();
4495
+ const toggleFullscreen = () => {
4496
+ if (!mTableEl.value) return;
4497
+ if (isFullscreen.value) {
4498
+ mTableEl.value.classList.remove("fixed");
4499
+ isFullscreen.value = false;
4500
+ } else {
4501
+ mTableEl.value.classList.add("fixed");
4502
+ mTableEl.value.style.zIndex = `${nextZIndex()}`;
4503
+ isFullscreen.value = true;
4504
+ }
4505
+ };
4506
+ return {
4507
+ isFullscreen,
4508
+ toggleFullscreen
4509
+ };
4510
+ };
4511
+
4512
+ const useImport = (props, emit, newHandler) => {
4513
+ const mForm = inject("mForm");
4514
+ const modelName = computed(() => props.name || props.config.name || "");
4515
+ const importable = computed(() => {
4516
+ if (typeof props.config.importable === "function") {
4517
+ return props.config.importable(mForm, {
4518
+ formValue: mForm?.values,
4519
+ model: props.model[modelName.value]
4520
+ });
4521
+ }
4522
+ return typeof props.config.importable === "undefined" ? false : props.config.importable;
4523
+ });
4524
+ const excelBtn = useTemplateRef("excelBtn");
4525
+ const excelHandler = async (file) => {
4526
+ if (!file?.raw) {
4527
+ return false;
4528
+ }
4529
+ if (!globalThis.XLSX) {
4530
+ await asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
4531
+ }
4532
+ const reader = new FileReader();
4533
+ reader.onload = () => {
4534
+ const data = reader.result;
4535
+ const pdata = globalThis.XLSX.read(data, { type: "array" });
4536
+ pdata.SheetNames.forEach((sheetName) => {
4537
+ const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
4538
+ if (arr?.[0]) {
4539
+ arr.forEach((row) => {
4540
+ newHandler(row);
4541
+ });
4542
+ }
4543
+ setTimeout(() => {
4544
+ excelBtn.value?.clearFiles();
4545
+ }, 300);
4546
+ });
4547
+ };
4548
+ reader.readAsArrayBuffer(file.raw);
4549
+ return false;
4550
+ };
4551
+ const clearHandler = () => {
4552
+ emit("change", []);
4553
+ mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
4554
+ };
4555
+ return {
4556
+ importable,
4557
+ excelHandler,
4558
+ clearHandler
4559
+ };
4560
+ };
4561
+
4562
+ const usePagination = (props, modelName) => {
4563
+ const pageSize = ref(10);
4564
+ const currentPage = ref(0);
4565
+ const paginationData = computed(() => getDataByPage(props.model[modelName.value], currentPage.value, pageSize.value));
4566
+ const handleSizeChange = (val) => {
4567
+ pageSize.value = val;
4568
+ };
4569
+ const handleCurrentChange = (val) => {
4570
+ currentPage.value = val - 1;
4571
+ };
4572
+ return {
4573
+ pageSize,
4574
+ currentPage,
4575
+ paginationData,
4576
+ handleSizeChange,
4577
+ handleCurrentChange
4578
+ };
4579
+ };
4580
+
4581
+ const useSelection = (props, emit, tMagicTableRef) => {
4582
+ const mForm = inject("mForm");
4583
+ const selectHandle = (selection, row) => {
4584
+ if (typeof props.config.selection === "string" && props.config.selection === "single") {
4585
+ tMagicTableRef.value?.clearSelection();
4586
+ tMagicTableRef.value?.toggleRowSelection(row, true);
4587
+ }
4588
+ emit("select", selection, row);
4589
+ if (typeof props.config.onSelect === "function") {
4590
+ props.config.onSelect(mForm, { selection, row, config: props.config });
4591
+ }
4592
+ };
4593
+ const toggleRowSelection = (row, selected) => {
4594
+ tMagicTableRef.value?.toggleRowSelection.call(tMagicTableRef.value?.getTableRef(), row, selected);
4595
+ };
4596
+ return {
4597
+ selectHandle,
4598
+ toggleRowSelection
4599
+ };
4600
+ };
4601
+
4602
+ const useSortable = (props, emit, tMagicTableRef, modelName) => {
4603
+ const mForm = inject("mForm");
4604
+ let sortable;
4605
+ const rowDrop = () => {
4606
+ sortable?.destroy();
4607
+ const tableEl = tMagicTableRef.value?.getEl();
4608
+ const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
4609
+ if (!tBodyEl) {
4610
+ return;
4611
+ }
4612
+ sortable = Sortable.create(tBodyEl, {
4613
+ draggable: ".tmagic-design-table-row",
4614
+ filter: "input",
4615
+ // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
4616
+ preventOnFilter: false,
4617
+ // 允许选字
4618
+ direction: "vertical",
4619
+ onEnd: ({ newIndex, oldIndex }) => {
4620
+ if (typeof newIndex === "undefined") return;
4621
+ if (typeof oldIndex === "undefined") return;
4622
+ const newData = sortArray(props.model[modelName.value], newIndex, oldIndex, props.sortKey);
4623
+ emit("change", newData);
4624
+ mForm?.$emit("field-change", newData);
4625
+ }
4626
+ });
4627
+ };
4628
+ watchEffect(() => {
4629
+ if (props.config.dropSort) {
4630
+ rowDrop();
4631
+ }
4632
+ });
4633
+ };
4634
+
4834
4635
  const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4835
- ...{
4836
- name: "MFormTextarea"
4837
- },
4838
- __name: "Textarea",
4636
+ __name: "ActionsColumn",
4839
4637
  props: {
4840
4638
  config: {},
4841
4639
  model: {},
4842
- initValues: {},
4843
- values: {},
4844
4640
  name: {},
4845
- prop: {},
4846
4641
  disabled: { type: Boolean },
4847
- size: {},
4848
- lastValues: {}
4642
+ currentPage: {},
4643
+ pageSize: {},
4644
+ index: {},
4645
+ row: {},
4646
+ prop: {},
4647
+ sortKey: {}
4849
4648
  },
4850
- emits: ["change", "input"],
4649
+ emits: ["change"],
4851
4650
  setup(__props, { emit: __emit }) {
4852
- const props = __props;
4853
4651
  const emit = __emit;
4854
- useAddField(props.prop);
4652
+ const props = __props;
4855
4653
  const mForm = inject("mForm");
4856
- const changeHandler = (value) => {
4857
- emit("change", value);
4654
+ const removeHandler = (index) => {
4655
+ if (props.disabled) return;
4656
+ emit("change", props.model[props.name].toSpliced(index, 1));
4858
4657
  };
4859
- const inputHandler = (v) => {
4860
- emit("input", v);
4861
- mForm?.$emit("field-input", props.prop, v);
4658
+ const copyHandler = (index) => {
4659
+ const inputs = cloneDeep(props.model[props.name][index]);
4660
+ const { length } = props.model[props.name];
4661
+ if (props.sortKey && length) {
4662
+ inputs[props.sortKey] = props.model[props.name][length - 1][props.sortKey] - 1;
4663
+ }
4664
+ emit("change", [...props.model[props.name], inputs], {
4665
+ changeRecords: [
4666
+ {
4667
+ propPath: `${props.prop}.${props.model[props.name].length}`,
4668
+ value: inputs
4669
+ }
4670
+ ]
4671
+ });
4672
+ };
4673
+ const showDelete = (index) => {
4674
+ const deleteFunc = props.config.delete;
4675
+ if (deleteFunc && typeof deleteFunc === "function") {
4676
+ return deleteFunc(props.model[props.name], index, mForm?.values);
4677
+ }
4678
+ return props.config.delete ?? true;
4679
+ };
4680
+ const copyable = (index) => {
4681
+ const copyableFunc = props.config.copyable;
4682
+ if (copyableFunc && typeof copyableFunc === "function") {
4683
+ return copyableFunc(mForm, {
4684
+ values: mForm?.initValues || {},
4685
+ model: props.model,
4686
+ parent: mForm?.parentValues || {},
4687
+ formValue: mForm?.values || props.model,
4688
+ prop: props.prop,
4689
+ config: props.config,
4690
+ index
4691
+ });
4692
+ }
4693
+ return props.config.copyable ?? true;
4862
4694
  };
4863
4695
  return (_ctx, _cache) => {
4864
- return openBlock(), createBlock(unref(TMagicInput), {
4865
- modelValue: __props.model[__props.name],
4866
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
4867
- type: "textarea",
4868
- size: __props.size,
4869
- clearable: "",
4870
- placeholder: __props.config.placeholder,
4871
- disabled: __props.disabled,
4872
- onChange: changeHandler,
4873
- onInput: inputHandler
4874
- }, null, 8, ["modelValue", "size", "placeholder", "disabled"]);
4696
+ return openBlock(), createElementBlock(
4697
+ Fragment,
4698
+ null,
4699
+ [
4700
+ renderSlot(_ctx.$slots, "operateCol", {
4701
+ scope: { $index: __props.index, row: __props.row }
4702
+ }),
4703
+ withDirectives(createVNode(unref(TMagicButton), {
4704
+ size: "small",
4705
+ type: "danger",
4706
+ link: "",
4707
+ title: "删除",
4708
+ icon: unref(Delete),
4709
+ onClick: _cache[0] || (_cache[0] = ($event) => removeHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
4710
+ }, null, 8, ["icon"]), [
4711
+ [vShow, showDelete(__props.index + 1 + __props.currentPage * __props.pageSize - 1)]
4712
+ ]),
4713
+ copyable(__props.index + 1 + __props.currentPage * __props.pageSize - 1) ? (openBlock(), createBlock(unref(TMagicButton), {
4714
+ key: 0,
4715
+ link: "",
4716
+ size: "small",
4717
+ type: "primary",
4718
+ title: "复制",
4719
+ icon: unref(DocumentCopy),
4720
+ disabled: __props.disabled,
4721
+ onClick: _cache[1] || (_cache[1] = ($event) => copyHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
4722
+ }, null, 8, ["icon", "disabled"])) : createCommentVNode("v-if", true)
4723
+ ],
4724
+ 64
4725
+ /* STABLE_FRAGMENT */
4726
+ );
4875
4727
  };
4876
4728
  }
4877
4729
  });
4878
4730
 
4879
4731
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
4880
- ...{
4881
- name: "MFormTime"
4882
- },
4883
- __name: "Time",
4732
+ __name: "SortColumn",
4884
4733
  props: {
4885
- config: {},
4886
- model: {},
4887
- initValues: {},
4888
- values: {},
4889
- name: {},
4890
- prop: {},
4734
+ index: {},
4891
4735
  disabled: { type: Boolean },
4892
- size: {},
4893
- lastValues: {}
4736
+ currentPage: {},
4737
+ pageSize: {},
4738
+ name: {},
4739
+ model: {}
4894
4740
  },
4895
- emits: ["change"],
4741
+ emits: ["swap"],
4896
4742
  setup(__props, { emit: __emit }) {
4897
4743
  const props = __props;
4898
4744
  const emit = __emit;
4899
- useAddField(props.prop);
4900
- const changeHandler = (v) => {
4901
- emit("change", v);
4745
+ let timer = null;
4746
+ const upHandler = (index) => {
4747
+ if (timer) {
4748
+ clearTimeout(timer);
4749
+ }
4750
+ timer = setTimeout(() => {
4751
+ emit("swap", index, index - 1);
4752
+ timer = null;
4753
+ }, 300);
4754
+ };
4755
+ const topHandler = (index) => {
4756
+ if (timer) {
4757
+ clearTimeout(timer);
4758
+ }
4759
+ const moveNum = index;
4760
+ for (let i = 0; i < moveNum; i++) {
4761
+ emit("swap", index, index - 1);
4762
+ index -= 1;
4763
+ }
4764
+ };
4765
+ const downHandler = (index) => {
4766
+ if (timer) {
4767
+ clearTimeout(timer);
4768
+ }
4769
+ timer = setTimeout(() => {
4770
+ emit("swap", index, index + 1);
4771
+ timer = null;
4772
+ }, 300);
4773
+ };
4774
+ const bottomHandler = (index) => {
4775
+ if (timer) {
4776
+ clearTimeout(timer);
4777
+ }
4778
+ const moveNum = props.model[props.name].length - 1 - index;
4779
+ for (let i = 0; i < moveNum; i++) {
4780
+ emit("swap", index, index + 1);
4781
+ index += 1;
4782
+ }
4902
4783
  };
4903
4784
  return (_ctx, _cache) => {
4904
- return openBlock(), createBlock(unref(TMagicTimePicker), {
4905
- modelValue: __props.model[__props.name],
4906
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
4907
- "value-format": __props.config.valueFormat || "HH:mm:ss",
4908
- format: __props.config.format || "HH:mm:ss",
4909
- size: __props.size,
4910
- placeholder: __props.config.placeholder,
4911
- disabled: __props.disabled,
4912
- onChange: changeHandler
4913
- }, null, 8, ["modelValue", "value-format", "format", "size", "placeholder", "disabled"]);
4785
+ return openBlock(), createElementBlock(
4786
+ Fragment,
4787
+ null,
4788
+ [
4789
+ __props.index + 1 + __props.currentPage * __props.pageSize - 1 !== 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
4790
+ key: 0,
4791
+ content: "点击上移,双击置顶",
4792
+ placement: "top"
4793
+ }, {
4794
+ default: withCtx(() => [
4795
+ createVNode(unref(TMagicButton), {
4796
+ plain: "",
4797
+ size: "small",
4798
+ type: "primary",
4799
+ icon: unref(ArrowUp),
4800
+ disabled: __props.disabled,
4801
+ link: "",
4802
+ onClick: _cache[0] || (_cache[0] = ($event) => upHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1)),
4803
+ onDblclick: _cache[1] || (_cache[1] = ($event) => topHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
4804
+ }, null, 8, ["icon", "disabled"])
4805
+ ]),
4806
+ _: 1
4807
+ /* STABLE */
4808
+ })) : createCommentVNode("v-if", true),
4809
+ __props.index + 1 + __props.currentPage * __props.pageSize - 1 !== __props.model[__props.name].length - 1 ? (openBlock(), createBlock(unref(TMagicTooltip), {
4810
+ key: 1,
4811
+ content: "点击下移,双击置底",
4812
+ placement: "top"
4813
+ }, {
4814
+ default: withCtx(() => [
4815
+ createVNode(unref(TMagicButton), {
4816
+ plain: "",
4817
+ size: "small",
4818
+ type: "primary",
4819
+ icon: unref(ArrowDown),
4820
+ disabled: __props.disabled,
4821
+ link: "",
4822
+ onClick: _cache[2] || (_cache[2] = ($event) => downHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1)),
4823
+ onDblclick: _cache[3] || (_cache[3] = ($event) => bottomHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
4824
+ }, null, 8, ["icon", "disabled"])
4825
+ ]),
4826
+ _: 1
4827
+ /* STABLE */
4828
+ })) : createCommentVNode("v-if", true)
4829
+ ],
4830
+ 64
4831
+ /* STABLE_FRAGMENT */
4832
+ );
4914
4833
  };
4915
4834
  }
4916
4835
  });
4917
4836
 
4837
+ const useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
4838
+ const mForm = inject("mForm");
4839
+ const display$1 = (fuc) => display(mForm, fuc, props);
4840
+ const lastData = computed(
4841
+ () => props.config.pagination ? getDataByPage(props.lastValues[modelName.value], currentPage.value, pageSize.value) : props.lastValues[modelName.value] || []
4842
+ );
4843
+ const itemExtra = (fuc, index) => {
4844
+ if (typeof fuc === "function") {
4845
+ return fuc(mForm, {
4846
+ values: mForm?.initValues,
4847
+ model: props.model,
4848
+ formValue: mForm ? mForm.values : props.model,
4849
+ prop: props.prop,
4850
+ index
4851
+ });
4852
+ }
4853
+ return fuc;
4854
+ };
4855
+ const selection = computed(() => {
4856
+ if (typeof props.config.selection === "function") {
4857
+ return props.config.selection(mForm, { model: props.model[modelName.value] });
4858
+ }
4859
+ return props.config.selection;
4860
+ });
4861
+ const getProp = (index) => {
4862
+ return `${props.prop}${props.prop ? "." : ""}${index + 1 + currentPage.value * pageSize.value - 1}`;
4863
+ };
4864
+ const makeConfig = (config, row) => {
4865
+ const newConfig = cloneDeep(config);
4866
+ if (typeof config.itemsFunction === "function") {
4867
+ newConfig.items = config.itemsFunction(row);
4868
+ }
4869
+ delete newConfig.display;
4870
+ return newConfig;
4871
+ };
4872
+ const changeHandler = (v, eventData) => {
4873
+ emit("change", props.model, eventData);
4874
+ };
4875
+ const onAddDiffCount = () => emit("addDiffCount");
4876
+ const columns = computed(() => {
4877
+ const columns2 = [];
4878
+ if (props.config.itemExtra && !props.config.dropSort) {
4879
+ columns2.push({
4880
+ props: {
4881
+ fixed: "left",
4882
+ width: 30,
4883
+ type: "expand"
4884
+ },
4885
+ cell: ({ $index }) => h("span", {
4886
+ innerHTML: itemExtra(props.config.itemExtra, $index),
4887
+ class: "m-form-tip"
4888
+ })
4889
+ });
4890
+ }
4891
+ columns2.push({
4892
+ props: {
4893
+ label: "操作",
4894
+ fixed: props.config.fixed === false ? void 0 : "left",
4895
+ width: props.config.operateColWidth || 112,
4896
+ align: "center"
4897
+ },
4898
+ cell: ({ row, $index }) => h(_sfc_main$4, {
4899
+ row,
4900
+ index: $index,
4901
+ model: props.model,
4902
+ config: props.config,
4903
+ prop: props.prop,
4904
+ disabled: props.disabled,
4905
+ sortKey: props.sortKey,
4906
+ name: modelName.value,
4907
+ currentPage: currentPage.value,
4908
+ pageSize: pageSize.value,
4909
+ onChange: (v) => {
4910
+ emit("change", v);
4911
+ }
4912
+ })
4913
+ });
4914
+ if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) {
4915
+ columns2.push({
4916
+ props: {
4917
+ label: "排序",
4918
+ width: 80
4919
+ },
4920
+ cell: ({ $index }) => h(_sfc_main$3, {
4921
+ index: $index,
4922
+ model: props.model,
4923
+ disabled: props.disabled,
4924
+ name: modelName.value,
4925
+ currentPage: currentPage.value,
4926
+ pageSize: pageSize.value,
4927
+ onSwap: (index1, index2) => {
4928
+ const newData = sortArray(props.model[modelName.value], index1, index2, props.sortKey);
4929
+ emit("change", newData);
4930
+ mForm?.$emit("field-change", newData);
4931
+ }
4932
+ })
4933
+ });
4934
+ }
4935
+ if (selection.value) {
4936
+ columns2.push({
4937
+ props: {
4938
+ align: "center",
4939
+ headerAlign: "center",
4940
+ type: "selection",
4941
+ width: 45
4942
+ }
4943
+ });
4944
+ }
4945
+ if (props.showIndex && props.config.showIndex) {
4946
+ columns2.push({
4947
+ props: {
4948
+ label: "序号",
4949
+ width: 60
4950
+ },
4951
+ cell: ({ $index }) => h("span", $index + 1 + currentPage.value * pageSize.value)
4952
+ });
4953
+ }
4954
+ for (const column of props.config.items) {
4955
+ if (column.type !== "hidden" && display$1(column.display)) {
4956
+ columns2.push({
4957
+ props: {
4958
+ prop: column.name,
4959
+ label: column.label,
4960
+ width: column.width,
4961
+ sortable: column.sortable,
4962
+ sortOrders: ["ascending", "descending"],
4963
+ class: props.config.dropSort === true ? "el-table__column--dropable" : ""
4964
+ },
4965
+ cell: ({ row, $index }) => h(_sfc_main$A, {
4966
+ labelWidth: "0",
4967
+ disabled: props.disabled,
4968
+ prop: getProp($index),
4969
+ rules: column.rules,
4970
+ config: makeConfig(column, row),
4971
+ model: row,
4972
+ lastValues: lastData.value[$index],
4973
+ isCompare: props.isCompare,
4974
+ size: props.size,
4975
+ onChange: changeHandler,
4976
+ onAddDiffCount
4977
+ })
4978
+ });
4979
+ }
4980
+ }
4981
+ return columns2;
4982
+ });
4983
+ return {
4984
+ columns
4985
+ };
4986
+ };
4987
+
4988
+ const _hoisted_1$1 = { class: "m-fields-table-wrap" };
4989
+ const _hoisted_2 = ["innerHTML"];
4990
+ const _hoisted_3 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
4991
+ const _hoisted_4 = { style: { "display": "flex" } };
4992
+ const _hoisted_5 = {
4993
+ key: 1,
4994
+ class: "bottom",
4995
+ style: { "text-align": "right" }
4996
+ };
4918
4997
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4919
4998
  ...{
4920
- name: "MFormTimeRange"
4999
+ name: "MFormTable"
4921
5000
  },
4922
- __name: "Timerange",
5001
+ __name: "Table",
4923
5002
  props: {
4924
- config: {},
4925
5003
  model: {},
4926
- initValues: {},
4927
- values: {},
5004
+ lastValues: { default: () => ({}) },
5005
+ isCompare: { type: Boolean, default: false },
5006
+ config: {},
4928
5007
  name: {},
4929
- prop: {},
5008
+ prop: { default: "" },
5009
+ labelWidth: {},
5010
+ sort: { type: Boolean },
4930
5011
  disabled: { type: Boolean },
5012
+ sortKey: { default: "" },
5013
+ text: {},
4931
5014
  size: {},
4932
- lastValues: {}
5015
+ enableToggleMode: { type: Boolean, default: true },
5016
+ showIndex: { type: Boolean, default: true }
4933
5017
  },
4934
- emits: ["change"],
4935
- setup(__props, { emit: __emit }) {
5018
+ emits: ["change", "select", "addDiffCount"],
5019
+ setup(__props, { expose: __expose, emit: __emit }) {
4936
5020
  const props = __props;
4937
5021
  const emit = __emit;
4938
- useAddField(props.prop);
4939
- const { names } = props.config;
4940
- const value = ref([]);
4941
- if (props.model !== void 0 && names?.length) {
4942
- watch(
4943
- [() => props.model[names[0]], () => props.model[names[1]]],
4944
- ([start, end], [preStart, preEnd]) => {
4945
- if (!value.value) {
4946
- value.value = [];
4947
- }
4948
- if (!start || !end) value.value = [];
4949
- if (start !== preStart) value.value[0] = start;
4950
- if (end !== preEnd) value.value[1] = end;
4951
- },
4952
- {
4953
- immediate: true
4954
- }
4955
- );
4956
- }
4957
- const setValue = (v) => {
4958
- names?.forEach((item, index) => {
4959
- if (!props.model) {
4960
- return;
4961
- }
4962
- if (Array.isArray(v)) {
4963
- props.model[item] = v[index];
4964
- } else {
4965
- props.model[item] = void 0;
4966
- }
5022
+ const modelName = computed(() => props.name || props.config.name || "");
5023
+ const tMagicTableRef = useTemplateRef("tMagicTable");
5024
+ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentChange } = usePagination(
5025
+ props,
5026
+ modelName
5027
+ );
5028
+ const { addable, newHandler } = useAdd(props, emit);
5029
+ const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
5030
+ useSortable(props, emit, tMagicTableRef, modelName);
5031
+ const { isFullscreen, toggleFullscreen } = useFullscreen();
5032
+ const { importable, excelHandler, clearHandler } = useImport(props, emit, newHandler);
5033
+ const { selectHandle, toggleRowSelection } = useSelection(props, emit, tMagicTableRef);
5034
+ const updateKey = ref(1);
5035
+ const data = computed(() => props.config.pagination ? paginationData.value : props.model[modelName.value]);
5036
+ const toggleMode = () => {
5037
+ const calcLabelWidth = (label) => {
5038
+ if (!label) return "0px";
5039
+ const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
5040
+ const chLength = label.length - zhLength;
5041
+ return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
5042
+ };
5043
+ props.config.type = "groupList";
5044
+ props.config.enableToggleMode = true;
5045
+ props.config.tableItems = props.config.items;
5046
+ props.config.items = props.config.groupItems || props.config.items.map((item) => {
5047
+ const text = item.text || item.label;
5048
+ const labelWidth = calcLabelWidth(text);
5049
+ return {
5050
+ ...item,
5051
+ text,
5052
+ labelWidth,
5053
+ span: item.span || 12
5054
+ };
4967
5055
  });
4968
5056
  };
4969
- const changeHandler = (v) => {
4970
- const value2 = v || [];
4971
- if (names?.length) {
4972
- setValue(value2);
4973
- }
4974
- emit("change", value2);
5057
+ const sortChangeHandler = (sortOptions) => {
5058
+ const modelName2 = props.name || props.config.name || "";
5059
+ sortChange(props.model[modelName2], sortOptions);
4975
5060
  };
5061
+ __expose({
5062
+ toggleRowSelection
5063
+ });
4976
5064
  return (_ctx, _cache) => {
4977
- return openBlock(), createBlock(unref(TMagicTimePicker), {
4978
- modelValue: value.value,
4979
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
4980
- "is-range": "",
4981
- "range-separator": "-",
4982
- "start-placeholder": "开始时间",
4983
- "end-placeholder": "结束时间",
4984
- size: __props.size,
4985
- "unlink-panels": true,
4986
- disabled: __props.disabled,
4987
- "default-time": __props.config.defaultTime,
4988
- onChange: changeHandler
4989
- }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
5065
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
5066
+ (openBlock(), createBlock(Teleport, {
5067
+ to: "body",
5068
+ disabled: !unref(isFullscreen)
5069
+ }, [
5070
+ createElementVNode(
5071
+ "div",
5072
+ {
5073
+ ref: "mTable",
5074
+ class: normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }])
5075
+ },
5076
+ [
5077
+ __props.config.extra ? (openBlock(), createElementBlock("span", {
5078
+ key: 0,
5079
+ style: { "color": "rgba(0, 0, 0, 0.45)" },
5080
+ innerHTML: __props.config.extra
5081
+ }, null, 8, _hoisted_2)) : createCommentVNode("v-if", true),
5082
+ createVNode(unref(TMagicTooltip), {
5083
+ content: "拖拽可排序",
5084
+ placement: "left-start",
5085
+ disabled: __props.config.dropSort !== true
5086
+ }, {
5087
+ default: withCtx(() => [
5088
+ __props.model[modelName.value] ? (openBlock(), createBlock(unref(TMagicTable), {
5089
+ ref: "tMagicTable",
5090
+ style: { "width": "100%" },
5091
+ "show-header": "",
5092
+ "row-key": __props.config.rowKey || "id",
5093
+ columns: unref(columns),
5094
+ data: data.value,
5095
+ border: __props.config.border,
5096
+ "max-height": __props.config.maxHeight,
5097
+ "default-expand-all": true,
5098
+ key: updateKey.value,
5099
+ onSelect: unref(selectHandle),
5100
+ onSortChange: sortChangeHandler
5101
+ }, null, 8, ["row-key", "columns", "data", "border", "max-height", "onSelect"])) : createCommentVNode("v-if", true)
5102
+ ]),
5103
+ _: 1
5104
+ /* STABLE */
5105
+ }, 8, ["disabled"]),
5106
+ renderSlot(_ctx.$slots, "default"),
5107
+ createElementVNode("div", _hoisted_3, [
5108
+ unref(addable) ? (openBlock(), createBlock(unref(TMagicButton), {
5109
+ key: 0,
5110
+ size: "small",
5111
+ type: "primary",
5112
+ disabled: __props.disabled,
5113
+ plain: "",
5114
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(newHandler)())
5115
+ }, {
5116
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
5117
+ createTextVNode(
5118
+ "新增一行",
5119
+ -1
5120
+ /* CACHED */
5121
+ )
5122
+ ])]),
5123
+ _: 1
5124
+ /* STABLE */
5125
+ }, 8, ["disabled"])) : createCommentVNode("v-if", true),
5126
+ createElementVNode("div", _hoisted_4, [
5127
+ __props.enableToggleMode && __props.config.enableToggleMode !== false && !unref(isFullscreen) ? (openBlock(), createBlock(unref(TMagicButton), {
5128
+ key: 0,
5129
+ icon: unref(Grid),
5130
+ size: "small",
5131
+ type: "primary",
5132
+ onClick: toggleMode
5133
+ }, {
5134
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
5135
+ createTextVNode(
5136
+ "展开配置",
5137
+ -1
5138
+ /* CACHED */
5139
+ )
5140
+ ])]),
5141
+ _: 1
5142
+ /* STABLE */
5143
+ }, 8, ["icon"])) : createCommentVNode("v-if", true),
5144
+ __props.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
5145
+ key: 1,
5146
+ icon: unref(FullScreen),
5147
+ size: "small",
5148
+ type: "primary",
5149
+ onClick: unref(toggleFullscreen)
5150
+ }, {
5151
+ default: withCtx(() => [
5152
+ createTextVNode(
5153
+ toDisplayString(unref(isFullscreen) ? "退出全屏" : "全屏编辑"),
5154
+ 1
5155
+ /* TEXT */
5156
+ )
5157
+ ]),
5158
+ _: 1
5159
+ /* STABLE */
5160
+ }, 8, ["icon", "onClick"])) : createCommentVNode("v-if", true),
5161
+ unref(importable) ? (openBlock(), createBlock(unref(TMagicUpload), {
5162
+ key: 2,
5163
+ style: { "display": "inline-block" },
5164
+ ref: "excelBtn",
5165
+ action: "/noop",
5166
+ disabled: __props.disabled,
5167
+ "on-change": unref(excelHandler),
5168
+ "auto-upload": false
5169
+ }, {
5170
+ default: withCtx(() => [
5171
+ createVNode(unref(TMagicButton), {
5172
+ size: "small",
5173
+ type: "success",
5174
+ disabled: __props.disabled,
5175
+ plain: ""
5176
+ }, {
5177
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
5178
+ createTextVNode(
5179
+ "导入EXCEL",
5180
+ -1
5181
+ /* CACHED */
5182
+ )
5183
+ ])]),
5184
+ _: 1
5185
+ /* STABLE */
5186
+ }, 8, ["disabled"])
5187
+ ]),
5188
+ _: 1
5189
+ /* STABLE */
5190
+ }, 8, ["disabled", "on-change"])) : createCommentVNode("v-if", true),
5191
+ unref(importable) ? (openBlock(), createBlock(unref(TMagicButton), {
5192
+ key: 3,
5193
+ size: "small",
5194
+ type: "warning",
5195
+ disabled: __props.disabled,
5196
+ plain: "",
5197
+ onClick: unref(clearHandler)
5198
+ }, {
5199
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [
5200
+ createTextVNode(
5201
+ "清空",
5202
+ -1
5203
+ /* CACHED */
5204
+ )
5205
+ ])]),
5206
+ _: 1
5207
+ /* STABLE */
5208
+ }, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true)
5209
+ ])
5210
+ ]),
5211
+ __props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_5, [
5212
+ createVNode(unref(TMagicPagination), {
5213
+ layout: "total, sizes, prev, pager, next, jumper",
5214
+ "hide-on-single-page": __props.model[modelName.value].length < unref(pageSize),
5215
+ "current-page": unref(currentPage) + 1,
5216
+ "page-sizes": [unref(pageSize), 60, 120, 300],
5217
+ "page-size": unref(pageSize),
5218
+ total: __props.model[modelName.value].length,
5219
+ onSizeChange: unref(handleSizeChange),
5220
+ onCurrentChange: unref(handleCurrentChange)
5221
+ }, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total", "onSizeChange", "onCurrentChange"])
5222
+ ])) : createCommentVNode("v-if", true)
5223
+ ],
5224
+ 2
5225
+ /* CLASS */
5226
+ )
5227
+ ], 8, ["disabled"]))
5228
+ ]);
4990
5229
  };
4991
5230
  }
4992
5231
  });
@@ -5153,7 +5392,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5153
5392
  class: "m-drawer-body"
5154
5393
  },
5155
5394
  [
5156
- createVNode(_sfc_main$d, {
5395
+ createVNode(_sfc_main$g, {
5157
5396
  ref_key: "form",
5158
5397
  ref: form,
5159
5398
  size: __props.size,
@@ -5261,7 +5500,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5261
5500
  [
5262
5501
  createVNode(unref(TMagicScrollbar), null, {
5263
5502
  default: withCtx(() => [
5264
- createVNode(_sfc_main$d, {
5503
+ createVNode(_sfc_main$g, {
5265
5504
  ref_key: "form",
5266
5505
  ref: form,
5267
5506
  size: __props.size,
@@ -5334,38 +5573,39 @@ const index = {
5334
5573
  const option = Object.assign(defaultInstallOpt, opt);
5335
5574
  app.config.globalProperties.$MAGIC_FORM = option;
5336
5575
  setConfig(option);
5337
- app.component("m-form", _sfc_main$d);
5338
- app.component("m-form-dialog", _sfc_main$c);
5339
- app.component("m-form-container", _sfc_main$x);
5340
- app.component("m-form-fieldset", _sfc_main$w);
5341
- app.component("m-form-group-list", _sfc_main$u);
5342
- app.component("m-form-panel", _sfc_main$t);
5343
- app.component("m-form-row", _sfc_main$r);
5344
- app.component("m-form-step", _sfc_main$q);
5345
- app.component("m-form-table", _sfc_main$p);
5346
- app.component("m-form-tab", _sfc_main$o);
5347
- app.component("m-fields-text", _sfc_main$5);
5348
- app.component("m-fields-img-upload", _sfc_main$5);
5349
- app.component("m-fields-number", _sfc_main$a);
5350
- app.component("m-fields-number-range", _sfc_main$9);
5351
- app.component("m-fields-textarea", _sfc_main$4);
5352
- app.component("m-fields-hidden", _sfc_main$e);
5353
- app.component("m-fields-date", _sfc_main$j);
5354
- app.component("m-fields-datetime", _sfc_main$h);
5355
- app.component("m-fields-daterange", _sfc_main$i);
5356
- app.component("m-fields-timerange", _sfc_main$2);
5357
- app.component("m-fields-time", _sfc_main$3);
5358
- app.component("m-fields-checkbox", _sfc_main$m);
5359
- app.component("m-fields-switch", _sfc_main$6);
5360
- app.component("m-fields-color-picker", _sfc_main$k);
5361
- app.component("m-fields-checkbox-group", _sfc_main$l);
5362
- app.component("m-fields-radio-group", _sfc_main$8);
5363
- app.component("m-fields-display", _sfc_main$g);
5364
- app.component("m-fields-link", _sfc_main$b);
5365
- app.component("m-fields-select", _sfc_main$7);
5366
- app.component("m-fields-cascader", _sfc_main$n);
5367
- app.component("m-fields-dynamic-field", _sfc_main$f);
5576
+ app.component("m-form", _sfc_main$g);
5577
+ app.component("m-form-dialog", _sfc_main$f);
5578
+ app.component("m-form-container", _sfc_main$A);
5579
+ app.component("m-form-fieldset", _sfc_main$z);
5580
+ app.component("m-form-group-list", _sfc_main$w);
5581
+ app.component("m-form-panel", _sfc_main$v);
5582
+ app.component("m-form-row", _sfc_main$t);
5583
+ app.component("m-form-step", _sfc_main$s);
5584
+ app.component("m-form-table", _sfc_main$2);
5585
+ app.component("m-form-tab", _sfc_main$r);
5586
+ app.component("m-form-flex-layout", _sfc_main$y);
5587
+ app.component("m-fields-text", _sfc_main$8);
5588
+ app.component("m-fields-img-upload", _sfc_main$8);
5589
+ app.component("m-fields-number", _sfc_main$d);
5590
+ app.component("m-fields-number-range", _sfc_main$c);
5591
+ app.component("m-fields-textarea", _sfc_main$7);
5592
+ app.component("m-fields-hidden", _sfc_main$h);
5593
+ app.component("m-fields-date", _sfc_main$m);
5594
+ app.component("m-fields-datetime", _sfc_main$k);
5595
+ app.component("m-fields-daterange", _sfc_main$l);
5596
+ app.component("m-fields-timerange", _sfc_main$5);
5597
+ app.component("m-fields-time", _sfc_main$6);
5598
+ app.component("m-fields-checkbox", _sfc_main$p);
5599
+ app.component("m-fields-switch", _sfc_main$9);
5600
+ app.component("m-fields-color-picker", _sfc_main$n);
5601
+ app.component("m-fields-checkbox-group", _sfc_main$o);
5602
+ app.component("m-fields-radio-group", _sfc_main$b);
5603
+ app.component("m-fields-display", _sfc_main$j);
5604
+ app.component("m-fields-link", _sfc_main$e);
5605
+ app.component("m-fields-select", _sfc_main$a);
5606
+ app.component("m-fields-cascader", _sfc_main$q);
5607
+ app.component("m-fields-dynamic-field", _sfc_main$i);
5368
5608
  }
5369
5609
  };
5370
5610
 
5371
- export { _sfc_main$n as MCascader, _sfc_main$m as MCheckbox, _sfc_main$l as MCheckboxGroup, _sfc_main$k as MColorPicker, _sfc_main$x as MContainer, _sfc_main$j as MDate, _sfc_main$h as MDateTime, _sfc_main$i as MDaterange, _sfc_main$g as MDisplay, _sfc_main$f as MDynamicField, _sfc_main$w as MFieldset, _sfc_main$d as MForm, _sfc_main as MFormBox, _sfc_main$c as MFormDialog, _sfc_main$1 as MFormDrawer, _sfc_main$u as MGroupList, _sfc_main$e as MHidden, _sfc_main$b as MLink, _sfc_main$a as MNumber, _sfc_main$9 as MNumberRange, _sfc_main$t as MPanel, _sfc_main$8 as MRadioGroup, _sfc_main$r as MRow, _sfc_main$7 as MSelect, _sfc_main$6 as MSwitch, _sfc_main$p as MTable, _sfc_main$o as MTabs, _sfc_main$5 as MText, _sfc_main$4 as MTextarea, _sfc_main$3 as MTime, _sfc_main$2 as MTimerange, createForm, createValues, datetimeFormatter, index as default, display, filterFunction, getRules, initValue, useAddField };
5611
+ export { _sfc_main$q as MCascader, _sfc_main$p as MCheckbox, _sfc_main$o as MCheckboxGroup, _sfc_main$n as MColorPicker, _sfc_main$A as MContainer, _sfc_main$m as MDate, _sfc_main$k as MDateTime, _sfc_main$l as MDaterange, _sfc_main$j as MDisplay, _sfc_main$i as MDynamicField, _sfc_main$z as MFieldset, _sfc_main$y as MFlexLayout, _sfc_main$g as MForm, _sfc_main as MFormBox, _sfc_main$f as MFormDialog, _sfc_main$1 as MFormDrawer, _sfc_main$w as MGroupList, _sfc_main$h as MHidden, _sfc_main$e as MLink, _sfc_main$d as MNumber, _sfc_main$c as MNumberRange, _sfc_main$v as MPanel, _sfc_main$b as MRadioGroup, _sfc_main$t as MRow, _sfc_main$a as MSelect, _sfc_main$9 as MSwitch, _sfc_main$2 as MTable, _sfc_main$r as MTabs, _sfc_main$8 as MText, _sfc_main$7 as MTextarea, _sfc_main$6 as MTime, _sfc_main$5 as MTimerange, createForm, createValues, datetimeFormatter, index as default, display, filterFunction, getDataByPage, getRules, initValue, sortArray, sortChange, useAddField };