@tmagic/form 1.6.1 → 1.7.0-beta.0

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 +1706 -1496
  3. package/dist/tmagic-form.umd.cjs +1739 -1525
  4. package/package.json +4 -4
  5. package/src/Form.vue +18 -5
  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 +2 -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 +52 -36
  42. package/src/containers/Table.vue +0 -681
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('@tmagic/design'), require('@tmagic/utils'), require('dayjs'), require('dayjs/plugin/utc'), require('sortablejs'), require('@popperjs/core'), require('@tmagic/form-schema')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', '@tmagic/design', '@tmagic/utils', 'dayjs', 'dayjs/plugin/utc', 'sortablejs', '@popperjs/core', '@tmagic/form-schema'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.design, global.utils, global.dayjs, global.utc, global.Sortable, global.core, global.formSchema));
5
- })(this, (function (exports, vue, iconsVue, design, utils, dayjs, utc, Sortable, core, formSchema) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('@tmagic/design'), require('@tmagic/utils'), require('dayjs'), require('dayjs/plugin/utc'), require('@popperjs/core'), require('sortablejs'), require('@tmagic/form-schema')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', '@tmagic/design', '@tmagic/utils', 'dayjs', 'dayjs/plugin/utc', '@popperjs/core', 'sortablejs', '@tmagic/form-schema'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.design, global.utils, global.dayjs, global.utc, global.core, global.Sortable, global.formSchema));
5
+ })(this, (function (exports, vue, iconsVue, design, utils, dayjs, utc, core, Sortable, formSchema) { 'use strict';
6
6
 
7
7
  /** Detect free variable `global` from Node.js. */
8
8
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
@@ -2968,8 +2968,10 @@
2968
2968
  value[name] = getDefaultValue(mForm, item);
2969
2969
  }
2970
2970
  if (type === "fieldset" && checkbox) {
2971
- if (typeof value[name] === "object") {
2972
- value[name].value = typeof initValue2[name] === "object" ? initValue2[name].value || 0 : 0;
2971
+ const checkboxName = typeof checkbox === "object" && typeof checkbox.name === "string" ? checkbox.name : "value";
2972
+ const checkboxFalseValue = typeof checkbox === "object" && typeof checkbox.falseValue !== "undefined" ? checkbox.falseValue : 0;
2973
+ if (name && typeof value[name] === "object") {
2974
+ value[name][checkboxName] = typeof initValue2[name] === "object" ? initValue2[name][checkboxName] || checkboxFalseValue : checkboxFalseValue;
2973
2975
  }
2974
2976
  }
2975
2977
  };
@@ -2999,6 +3001,16 @@
2999
3001
  return createValues(mForm, items, initValue2, value);
3000
3002
  }
3001
3003
  setValue(mForm, value, initValue2, item);
3004
+ if (type === "table") {
3005
+ if (item.defautSort) {
3006
+ sortChange(value[name], item.defautSort);
3007
+ } else if (item.defaultSort) {
3008
+ sortChange(value[name], item.defaultSort);
3009
+ }
3010
+ if (item.sort && item.sortKey) {
3011
+ value[name].sort((a, b) => b[item.sortKey] - a[item.sortKey]);
3012
+ }
3013
+ }
3002
3014
  return value;
3003
3015
  };
3004
3016
  const createValues = function(mForm, config = [], initValue2 = {}, value = {}) {
@@ -3039,7 +3051,8 @@
3039
3051
  formValue: mForm?.values || props.model,
3040
3052
  prop: props.prop,
3041
3053
  config: props.config,
3042
- index: props.index
3054
+ index: props.index,
3055
+ getFormValue: (prop) => utils.getValueByKeyPath(prop, mForm?.values || props.model)
3043
3056
  });
3044
3057
  }
3045
3058
  return config;
@@ -3116,25 +3129,47 @@
3116
3129
  }
3117
3130
  return defaultValue;
3118
3131
  };
3132
+ const getDataByPage = (data = [], pagecontext, pagesize) => data.filter(
3133
+ (item, index) => index >= pagecontext * pagesize && index + 1 <= (pagecontext + 1) * pagesize
3134
+ );
3135
+ const sortArray = (data, newIndex, oldIndex, sortKey) => {
3136
+ if (newIndex === oldIndex) {
3137
+ return data;
3138
+ }
3139
+ if (newIndex < 0 || newIndex >= data.length || oldIndex < 0 || oldIndex >= data.length) {
3140
+ return data;
3141
+ }
3142
+ const newData = data.toSpliced(newIndex, 0, ...data.splice(oldIndex, 1));
3143
+ if (sortKey) {
3144
+ for (let i = newData.length - 1, v = 0; i >= 0; i--, v++) {
3145
+ newData[v][sortKey] = i;
3146
+ }
3147
+ }
3148
+ return newData;
3149
+ };
3150
+ const sortChange = (data, { prop, order }) => {
3151
+ if (order === "ascending") {
3152
+ data = data.sort((a, b) => a[prop] - b[prop]);
3153
+ } else if (order === "descending") {
3154
+ data = data.sort((a, b) => b[prop] - a[prop]);
3155
+ }
3156
+ };
3119
3157
 
3120
- const _hoisted_1$e = ["data-tmagic-id", "data-tmagic-form-item-prop"];
3158
+ const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
3121
3159
  const _hoisted_2$7 = ["innerHTML", "title"];
3122
- const _hoisted_3$5 = ["innerHTML"];
3160
+ const _hoisted_3$6 = ["innerHTML"];
3123
3161
  const _hoisted_4$3 = ["innerHTML"];
3124
- const _hoisted_5$3 = ["innerHTML"];
3125
- const _hoisted_6$2 = ["innerHTML", "title"];
3162
+ const _hoisted_5$3 = ["innerHTML", "title"];
3163
+ const _hoisted_6$1 = ["innerHTML"];
3126
3164
  const _hoisted_7$1 = ["innerHTML"];
3127
- const _hoisted_8$1 = ["innerHTML"];
3165
+ const _hoisted_8$1 = ["innerHTML", "title"];
3128
3166
  const _hoisted_9 = ["innerHTML"];
3129
- const _hoisted_10 = ["innerHTML", "title"];
3130
- const _hoisted_11 = ["innerHTML"];
3131
- const _hoisted_12 = ["innerHTML"];
3132
- const _hoisted_13 = ["innerHTML"];
3133
- const _hoisted_14 = {
3167
+ const _hoisted_10 = ["innerHTML"];
3168
+ const _hoisted_11 = {
3134
3169
  key: 5,
3135
3170
  style: { "text-align": "center" }
3136
3171
  };
3137
- const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
3172
+ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
3138
3173
  ...{
3139
3174
  name: "MFormContainer"
3140
3175
  },
@@ -3188,8 +3223,19 @@
3188
3223
  });
3189
3224
  const disabled = vue.computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
3190
3225
  const text = vue.computed(() => filterFunction(mForm, props.config.text, props));
3191
- const tooltip = vue.computed(() => filterFunction(mForm, props.config.tooltip, props));
3192
- const extra = vue.computed(() => filterFunction(mForm, props.config.extra, props));
3226
+ const tooltip = vue.computed(() => {
3227
+ const config = filterFunction(mForm, props.config.tooltip, props);
3228
+ if (typeof config === "string") {
3229
+ return {
3230
+ text: config,
3231
+ placement: "top"
3232
+ };
3233
+ }
3234
+ return {
3235
+ text: config?.text,
3236
+ placement: config?.placement || "top"
3237
+ };
3238
+ });
3193
3239
  const rule = vue.computed(() => getRules(mForm, props.config.rules, props));
3194
3240
  const type = vue.computed(() => {
3195
3241
  let { type: type2 } = props.config;
@@ -3205,6 +3251,22 @@
3205
3251
  }
3206
3252
  return value;
3207
3253
  });
3254
+ const fieldsProps = vue.computed(() => ({
3255
+ size: props.size,
3256
+ config: props.config,
3257
+ name: name.value,
3258
+ disabled: disabled.value,
3259
+ prop: itemProp.value,
3260
+ key: props.config[mForm?.keyProps],
3261
+ style: props.config.fieldStyle
3262
+ }));
3263
+ const formItemProps = vue.computed(() => ({
3264
+ prop: itemProp.value,
3265
+ labelWidth: itemLabelWidth.value,
3266
+ labelPosition: props.config.labelPosition,
3267
+ rules: rule.value,
3268
+ extra: filterFunction(mForm, props.config.extra, props)
3269
+ }));
3208
3270
  const itemLabelWidth = vue.computed(() => props.config.labelWidth ?? props.labelWidth);
3209
3271
  vue.watchEffect(() => {
3210
3272
  expand.value = props.expandMore;
@@ -3231,7 +3293,8 @@
3231
3293
  values: mForm?.initValues,
3232
3294
  formValue: mForm?.values,
3233
3295
  prop: itemProp.value,
3234
- config: props.config
3296
+ config: props.config,
3297
+ getFormValue: (prop) => utils.getValueByKeyPath(prop, mForm?.values || props.model)
3235
3298
  });
3236
3299
  }
3237
3300
  if (filter === "number") {
@@ -3259,27 +3322,50 @@
3259
3322
  }
3260
3323
  return true;
3261
3324
  };
3325
+ const createModelProxy = (target, setModelFn, pathPrefix = "") => {
3326
+ return new Proxy(target, {
3327
+ get: (obj, key2) => {
3328
+ const value = obj[key2];
3329
+ if (value && typeof value === "object") {
3330
+ const newPath = pathPrefix ? `${pathPrefix}.${key2}` : key2;
3331
+ return createModelProxy(value, setModelFn, newPath);
3332
+ }
3333
+ return value;
3334
+ },
3335
+ set: (obj, key2, value) => {
3336
+ setModelFn(pathPrefix ? `${pathPrefix}.${key2}` : key2, value);
3337
+ return true;
3338
+ }
3339
+ });
3340
+ };
3262
3341
  const onChangeHandler = async function(v, eventData = {}) {
3263
- const { filter, onChange, trim, dynamicKey } = props.config;
3342
+ const { filter, onChange, trim } = props.config;
3264
3343
  let value = vue.toRaw(v);
3265
3344
  const changeRecords = eventData.changeRecords || [];
3266
3345
  const newChangeRecords = [...changeRecords];
3267
3346
  try {
3268
3347
  value = filterHandler(filter, v);
3269
3348
  if (typeof onChange === "function") {
3349
+ const setModel = (key2, value2) => {
3350
+ if (props.config.name) {
3351
+ newChangeRecords.push({ propPath: itemProp.value.replace(`${props.config.name}`, key2), value: value2 });
3352
+ } else {
3353
+ newChangeRecords.push({ propPath: itemProp.value, value: value2 });
3354
+ }
3355
+ };
3356
+ const setFormValue = (key2, value2) => {
3357
+ newChangeRecords.push({ propPath: key2, value: value2 });
3358
+ };
3270
3359
  value = await onChange(mForm, value, {
3271
- model: props.model,
3272
- values: mForm?.initValues,
3273
- formValue: mForm?.values,
3360
+ model: createModelProxy(props.model, setModel),
3361
+ values: mForm ? vue.readonly(mForm.initValues) : null,
3362
+ formValue: createModelProxy(mForm?.values || {}, setFormValue),
3274
3363
  prop: itemProp.value,
3275
3364
  config: props.config,
3276
3365
  changeRecords: newChangeRecords,
3277
- setModel: (key2, value2) => {
3278
- utils.setValueByKeyPath(key2, value2, props.model);
3279
- if (props.config.name) {
3280
- newChangeRecords.push({ propPath: itemProp.value.replace(`${props.config.name}`, key2), value: value2 });
3281
- }
3282
- }
3366
+ setModel,
3367
+ setFormValue,
3368
+ getFormValue: (prop) => utils.getValueByKeyPath(prop, mForm?.values || props.model)
3283
3369
  }) ?? value;
3284
3370
  }
3285
3371
  value = trimHandler(trim, value) ?? value;
@@ -3288,15 +3374,8 @@
3288
3374
  }
3289
3375
  let valueProp = itemProp.value;
3290
3376
  if (hasModifyKey(eventData)) {
3291
- if (dynamicKey) {
3292
- props.model[eventData.modifyKey] = value;
3293
- } else if (isValidName()) {
3294
- props.model[name.value][eventData.modifyKey] = value;
3295
- }
3296
3377
  valueProp = valueProp ? `${valueProp}.${eventData.modifyKey}` : eventData.modifyKey;
3297
3378
  delete eventData.modifyKey;
3298
- } else if (isValidName() && props.model !== value && (v !== value || props.model[name.value] !== value)) {
3299
- props.model[name.value] = value;
3300
3379
  }
3301
3380
  if (changeRecords.length === 0) {
3302
3381
  newChangeRecords.push({
@@ -3312,95 +3391,65 @@
3312
3391
  return (_ctx, _cache) => {
3313
3392
  const _component_m_fields_hidden = vue.resolveComponent("m-fields-hidden");
3314
3393
  const _component_Container = vue.resolveComponent("Container", true);
3315
- return __props.config ? (vue.openBlock(), vue.createElementBlock("div", {
3316
- key: 0,
3394
+ return vue.openBlock(), vue.createElementBlock("div", {
3317
3395
  "data-tmagic-id": __props.config.id,
3318
3396
  "data-tmagic-form-item-prop": itemProp.value,
3319
- style: vue.normalizeStyle(__props.config.tip ? "display: flex;align-items: baseline;" : ""),
3320
- class: vue.normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}`)
3397
+ class: vue.normalizeClass(`m-form-container m-container-${type.value || ""} ${__props.config.className || ""}${__props.config.tip ? " has-tip" : ""}`),
3398
+ style: vue.normalizeStyle(__props.config.style)
3321
3399
  }, [
3322
- type.value === "hidden" ? (vue.openBlock(), vue.createBlock(_component_m_fields_hidden, {
3323
- key: 0,
3324
- model: __props.model,
3325
- config: __props.config,
3326
- name: __props.config.name,
3327
- disabled: disabled.value,
3328
- prop: itemProp.value
3329
- }, null, 8, ["model", "config", "name", "disabled", "prop"])) : items.value && !text.value && type.value && display$1.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3330
- key: key(__props.config),
3331
- size: __props.size,
3400
+ type.value === "hidden" ? (vue.openBlock(), vue.createBlock(_component_m_fields_hidden, vue.mergeProps({ key: 0 }, fieldsProps.value, { model: __props.model }), null, 16, ["model"])) : items.value && !text.value && type.value && display$1.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps({ key: 1 }, fieldsProps.value, {
3332
3401
  model: __props.model,
3333
3402
  "last-values": __props.lastValues,
3334
3403
  "is-compare": __props.isCompare,
3335
- config: __props.config,
3336
- disabled: disabled.value,
3337
- name: name.value,
3338
- prop: itemProp.value,
3339
3404
  "step-active": __props.stepActive,
3340
3405
  "expand-more": expand.value,
3341
3406
  "label-width": itemLabelWidth.value,
3407
+ style: __props.config.fieldStyle,
3342
3408
  onChange: onChangeHandler,
3343
3409
  onAddDiffCount
3344
- }, 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 ? (vue.openBlock(), vue.createElementBlock(
3410
+ }), null, 16, ["model", "last-values", "is-compare", "step-active", "expand-more", "label-width", "style"])) : type.value && display$1.value && !showDiff.value ? (vue.openBlock(), vue.createElementBlock(
3345
3411
  vue.Fragment,
3346
3412
  { key: 2 },
3347
3413
  [
3348
- vue.createVNode(vue.unref(design.TMagicFormItem), {
3349
- style: vue.normalizeStyle(__props.config.tip ? "flex: 1" : ""),
3350
- class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
3351
- prop: itemProp.value,
3352
- "label-width": itemLabelWidth.value,
3353
- "label-position": __props.config.labelPosition,
3354
- rules: rule.value
3355
- }, {
3414
+ vue.createVNode(vue.unref(design.TMagicFormItem), vue.mergeProps(formItemProps.value, {
3415
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }
3416
+ }), {
3356
3417
  label: vue.withCtx(() => [
3357
3418
  vue.createElementVNode("span", {
3358
- innerHTML: type.value === "checkbox" ? "" : text.value,
3419
+ innerHTML: type.value === "checkbox" && !__props.config.useLabel ? "" : text.value,
3359
3420
  title: __props.config.labelTitle
3360
3421
  }, null, 8, _hoisted_2$7)
3361
3422
  ]),
3362
3423
  default: vue.withCtx(() => [
3363
- tooltip.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
3424
+ tooltip.value.text ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3425
+ key: 0,
3426
+ placement: tooltip.value.placement
3427
+ }, {
3364
3428
  content: vue.withCtx(() => [
3365
- vue.createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_3$5)
3429
+ vue.createElementVNode("div", {
3430
+ innerHTML: tooltip.value.text
3431
+ }, null, 8, _hoisted_3$6)
3366
3432
  ]),
3367
3433
  default: vue.withCtx(() => [
3368
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3369
- key: key(__props.config),
3370
- size: __props.size,
3434
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps(fieldsProps.value, {
3371
3435
  model: __props.model,
3372
3436
  "last-values": __props.lastValues,
3373
- config: __props.config,
3374
- name: name.value,
3375
- disabled: disabled.value,
3376
- prop: itemProp.value,
3377
3437
  onChange: onChangeHandler,
3378
3438
  onAddDiffCount
3379
- }, null, 40, ["size", "model", "last-values", "config", "name", "disabled", "prop"]))
3439
+ }), null, 16, ["model", "last-values"]))
3380
3440
  ]),
3381
3441
  _: 1
3382
3442
  /* STABLE */
3383
- })) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3384
- key: key(__props.config),
3385
- size: __props.size,
3443
+ }, 8, ["placement"])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps({ key: 1 }, fieldsProps.value, {
3386
3444
  model: __props.model,
3387
3445
  "last-values": __props.lastValues,
3388
- config: __props.config,
3389
- name: name.value,
3390
- disabled: disabled.value,
3391
- prop: itemProp.value,
3392
3446
  onChange: onChangeHandler,
3393
3447
  onAddDiffCount
3394
- }, null, 40, ["size", "model", "last-values", "config", "name", "disabled", "prop"])),
3395
- extra.value && type.value !== "table" ? (vue.openBlock(), vue.createElementBlock("div", {
3396
- key: 2,
3397
- innerHTML: extra.value,
3398
- class: "m-form-tip"
3399
- }, null, 8, _hoisted_4$3)) : vue.createCommentVNode("v-if", true)
3448
+ }), null, 16, ["model", "last-values"]))
3400
3449
  ]),
3401
3450
  _: 1
3402
3451
  /* STABLE */
3403
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
3452
+ }, 16, ["class"]),
3404
3453
  __props.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3405
3454
  key: 0,
3406
3455
  placement: "left"
@@ -3408,7 +3457,7 @@
3408
3457
  content: vue.withCtx(() => [
3409
3458
  vue.createElementVNode("div", {
3410
3459
  innerHTML: __props.config.tip
3411
- }, null, 8, _hoisted_5$3)
3460
+ }, null, 8, _hoisted_4$3)
3412
3461
  ]),
3413
3462
  default: vue.withCtx(() => [
3414
3463
  vue.createVNode(vue.unref(design.TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -3431,58 +3480,41 @@
3431
3480
  [
3432
3481
  vue.createCommentVNode(" 对比 "),
3433
3482
  vue.createCommentVNode(" 上次内容 "),
3434
- vue.createVNode(vue.unref(design.TMagicFormItem), {
3435
- style: vue.normalizeStyle([__props.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
3436
- class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
3437
- prop: itemProp.value,
3438
- "label-width": itemLabelWidth.value,
3439
- "label-position": __props.config.labelPosition,
3440
- rules: rule.value
3441
- }, {
3483
+ vue.createVNode(vue.unref(design.TMagicFormItem), vue.mergeProps(formItemProps.value, {
3484
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value, "show-diff": true }
3485
+ }), {
3442
3486
  label: vue.withCtx(() => [
3443
3487
  vue.createElementVNode("span", {
3444
3488
  innerHTML: type.value === "checkbox" ? "" : text.value,
3445
3489
  title: __props.config.labelTitle
3446
- }, null, 8, _hoisted_6$2)
3490
+ }, null, 8, _hoisted_5$3)
3447
3491
  ]),
3448
3492
  default: vue.withCtx(() => [
3449
- tooltip.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
3493
+ tooltip.value.text ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3494
+ key: 0,
3495
+ placement: tooltip.value.placement
3496
+ }, {
3450
3497
  content: vue.withCtx(() => [
3451
- vue.createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_7$1)
3498
+ vue.createElementVNode("div", {
3499
+ innerHTML: tooltip.value.text
3500
+ }, null, 8, _hoisted_6$1)
3452
3501
  ]),
3453
3502
  default: vue.withCtx(() => [
3454
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3455
- key: key(__props.config),
3456
- size: __props.size,
3503
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps(fieldsProps.value, {
3457
3504
  model: __props.lastValues,
3458
- config: __props.config,
3459
- name: name.value,
3460
- disabled: disabled.value,
3461
- prop: itemProp.value,
3462
3505
  onChange: onChangeHandler
3463
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"]))
3506
+ }), null, 16, ["model"]))
3464
3507
  ]),
3465
3508
  _: 1
3466
3509
  /* STABLE */
3467
- })) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3468
- key: key(__props.config),
3469
- size: __props.size,
3510
+ }, 8, ["placement"])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps({ key: 1 }, fieldsProps.value, {
3470
3511
  model: __props.lastValues,
3471
- config: __props.config,
3472
- name: name.value,
3473
- disabled: disabled.value,
3474
- prop: itemProp.value,
3475
3512
  onChange: onChangeHandler
3476
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"])),
3477
- extra.value ? (vue.openBlock(), vue.createElementBlock("div", {
3478
- key: 2,
3479
- innerHTML: extra.value,
3480
- class: "m-form-tip"
3481
- }, null, 8, _hoisted_8$1)) : vue.createCommentVNode("v-if", true)
3513
+ }), null, 16, ["model"]))
3482
3514
  ]),
3483
3515
  _: 1
3484
3516
  /* STABLE */
3485
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
3517
+ }, 16, ["class"]),
3486
3518
  __props.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3487
3519
  key: 0,
3488
3520
  placement: "left"
@@ -3490,7 +3522,7 @@
3490
3522
  content: vue.withCtx(() => [
3491
3523
  vue.createElementVNode("div", {
3492
3524
  innerHTML: __props.config.tip
3493
- }, null, 8, _hoisted_9)
3525
+ }, null, 8, _hoisted_7$1)
3494
3526
  ]),
3495
3527
  default: vue.withCtx(() => [
3496
3528
  vue.createVNode(vue.unref(design.TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -3505,58 +3537,42 @@
3505
3537
  /* STABLE */
3506
3538
  })) : vue.createCommentVNode("v-if", true),
3507
3539
  vue.createCommentVNode(" 当前内容 "),
3508
- vue.createVNode(vue.unref(design.TMagicFormItem), {
3509
- style: vue.normalizeStyle([__props.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
3510
- class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
3511
- prop: itemProp.value,
3512
- "label-width": itemLabelWidth.value,
3513
- "label-position": __props.config.labelPosition,
3514
- rules: rule.value
3515
- }, {
3540
+ vue.createVNode(vue.unref(design.TMagicFormItem), vue.mergeProps(formItemProps.value, {
3541
+ style: __props.config.tip ? "flex: 1" : "",
3542
+ class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value, "show-diff": true }
3543
+ }), {
3516
3544
  label: vue.withCtx(() => [
3517
3545
  vue.createElementVNode("span", {
3518
3546
  innerHTML: type.value === "checkbox" ? "" : text.value,
3519
3547
  title: __props.config.labelTitle
3520
- }, null, 8, _hoisted_10)
3548
+ }, null, 8, _hoisted_8$1)
3521
3549
  ]),
3522
3550
  default: vue.withCtx(() => [
3523
- tooltip.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
3551
+ tooltip.value.text ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3552
+ key: 0,
3553
+ placement: tooltip.value.placement
3554
+ }, {
3524
3555
  content: vue.withCtx(() => [
3525
- vue.createElementVNode("div", { innerHTML: tooltip.value }, null, 8, _hoisted_11)
3556
+ vue.createElementVNode("div", {
3557
+ innerHTML: tooltip.value.text
3558
+ }, null, 8, _hoisted_9)
3526
3559
  ]),
3527
3560
  default: vue.withCtx(() => [
3528
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3529
- key: key(__props.config),
3530
- size: __props.size,
3561
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps(fieldsProps.value, {
3531
3562
  model: __props.model,
3532
- config: __props.config,
3533
- name: name.value,
3534
- disabled: disabled.value,
3535
- prop: itemProp.value,
3536
3563
  onChange: onChangeHandler
3537
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"]))
3564
+ }), null, 16, ["model"]))
3538
3565
  ]),
3539
3566
  _: 1
3540
3567
  /* STABLE */
3541
- })) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
3542
- key: key(__props.config),
3543
- size: __props.size,
3568
+ }, 8, ["placement"])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), vue.mergeProps({ key: 1 }, fieldsProps.value, {
3544
3569
  model: __props.model,
3545
- config: __props.config,
3546
- name: name.value,
3547
- disabled: disabled.value,
3548
- prop: itemProp.value,
3549
3570
  onChange: onChangeHandler
3550
- }, null, 40, ["size", "model", "config", "name", "disabled", "prop"])),
3551
- extra.value ? (vue.openBlock(), vue.createElementBlock("div", {
3552
- key: 2,
3553
- innerHTML: extra.value,
3554
- class: "m-form-tip"
3555
- }, null, 8, _hoisted_12)) : vue.createCommentVNode("v-if", true)
3571
+ }), null, 16, ["model"]))
3556
3572
  ]),
3557
3573
  _: 1
3558
3574
  /* STABLE */
3559
- }, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
3575
+ }, 16, ["style", "class"]),
3560
3576
  __props.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3561
3577
  key: 1,
3562
3578
  placement: "left"
@@ -3564,7 +3580,7 @@
3564
3580
  content: vue.withCtx(() => [
3565
3581
  vue.createElementVNode("div", {
3566
3582
  innerHTML: __props.config.tip
3567
- }, null, 8, _hoisted_13)
3583
+ }, null, 8, _hoisted_10)
3568
3584
  ]),
3569
3585
  default: vue.withCtx(() => [
3570
3586
  vue.createVNode(vue.unref(design.TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
@@ -3612,7 +3628,7 @@
3612
3628
  64
3613
3629
  /* STABLE_FRAGMENT */
3614
3630
  )) : vue.createCommentVNode("v-if", true),
3615
- __props.config.expand && type.value !== "fieldset" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_14, [
3631
+ __props.config.expand && type.value !== "fieldset" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, [
3616
3632
  vue.createVNode(vue.unref(design.TMagicButton), {
3617
3633
  type: "primary",
3618
3634
  size: "small",
@@ -3631,23 +3647,23 @@
3631
3647
  /* STABLE */
3632
3648
  })
3633
3649
  ])) : vue.createCommentVNode("v-if", true)
3634
- ], 14, _hoisted_1$e)) : vue.createCommentVNode("v-if", true);
3650
+ ], 14, _hoisted_1$d);
3635
3651
  };
3636
3652
  }
3637
3653
  });
3638
3654
 
3639
- const _hoisted_1$d = ["innerHTML"];
3655
+ const _hoisted_1$c = ["innerHTML"];
3640
3656
  const _hoisted_2$6 = ["innerHTML"];
3641
- const _hoisted_3$4 = { key: 1 };
3657
+ const _hoisted_3$5 = { key: 1 };
3642
3658
  const _hoisted_4$2 = ["innerHTML"];
3643
3659
  const _hoisted_5$2 = ["innerHTML"];
3644
- const _hoisted_6$1 = {
3660
+ const _hoisted_6 = {
3645
3661
  key: 2,
3646
3662
  style: { "display": "flex" }
3647
3663
  };
3648
3664
  const _hoisted_7 = { style: { "flex": "1" } };
3649
3665
  const _hoisted_8 = ["src"];
3650
- const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
3666
+ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
3651
3667
  ...{
3652
3668
  name: "MFormFieldset"
3653
3669
  },
@@ -3669,9 +3685,27 @@
3669
3685
  const emit = __emit;
3670
3686
  const mForm = vue.inject("mForm");
3671
3687
  const name = vue.computed(() => props.config.name || "");
3688
+ const checkboxName = vue.computed(() => {
3689
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.name === "string") {
3690
+ return props.config.checkbox.name;
3691
+ }
3692
+ return "value";
3693
+ });
3694
+ const checkboxTrueValue = vue.computed(() => {
3695
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.trueValue !== "undefined") {
3696
+ return props.config.checkbox.trueValue;
3697
+ }
3698
+ return 1;
3699
+ });
3700
+ const checkboxFalseValue = vue.computed(() => {
3701
+ if (typeof props.config.checkbox === "object" && typeof props.config.checkbox.falseValue !== "undefined") {
3702
+ return props.config.checkbox.falseValue;
3703
+ }
3704
+ return 0;
3705
+ });
3672
3706
  const show = vue.computed(() => {
3673
- if (props.config.expand && name.value) {
3674
- return props.model[name.value]?.value;
3707
+ if (props.config.expand && checkboxName.value) {
3708
+ return (name.value ? props.model[name.value] : props.model)?.[checkboxName.value] === checkboxTrueValue.value;
3675
3709
  }
3676
3710
  return true;
3677
3711
  });
@@ -3682,7 +3716,7 @@
3682
3716
  return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
3683
3717
  });
3684
3718
  const valueChangeHandler = (value) => {
3685
- emit("change", value, { modifyKey: "value" });
3719
+ emit("change", value, { modifyKey: checkboxName.value });
3686
3720
  };
3687
3721
  const changeHandler = (v, eventData) => emit("change", v, eventData);
3688
3722
  const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
@@ -3699,19 +3733,16 @@
3699
3733
  name.value && __props.config.checkbox ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!show.value ? "div" : "legend"), { key: 0 }, {
3700
3734
  default: vue.withCtx(() => [
3701
3735
  vue.createVNode(vue.unref(design.TMagicCheckbox), {
3702
- modelValue: __props.model[name.value].value,
3703
- "onUpdate:modelValue": [
3704
- _cache[0] || (_cache[0] = ($event) => __props.model[name.value].value = $event),
3705
- valueChangeHandler
3706
- ],
3707
- prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.value`,
3708
- "true-value": 1,
3709
- "false-value": 0
3736
+ "model-value": (name.value ? __props.model[name.value] : __props.model)[checkboxName.value],
3737
+ prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.${checkboxName.value}`,
3738
+ "true-value": checkboxTrueValue.value,
3739
+ "false-value": checkboxFalseValue.value,
3740
+ "onUpdate:modelValue": valueChangeHandler
3710
3741
  }, {
3711
3742
  default: vue.withCtx(() => [
3712
3743
  vue.createElementVNode("span", {
3713
3744
  innerHTML: __props.config.legend
3714
- }, null, 8, _hoisted_1$d),
3745
+ }, null, 8, _hoisted_1$c),
3715
3746
  __props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
3716
3747
  key: 0,
3717
3748
  innerHTML: __props.config.extra,
@@ -3720,11 +3751,11 @@
3720
3751
  ]),
3721
3752
  _: 1
3722
3753
  /* STABLE */
3723
- }, 8, ["modelValue", "prop"])
3754
+ }, 8, ["model-value", "prop", "true-value", "false-value"])
3724
3755
  ]),
3725
3756
  _: 1
3726
3757
  /* STABLE */
3727
- })) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$4, [
3758
+ })) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$5, [
3728
3759
  vue.createElementVNode("span", {
3729
3760
  innerHTML: __props.config.legend
3730
3761
  }, null, 8, _hoisted_4$2),
@@ -3734,13 +3765,13 @@
3734
3765
  class: "m-form-tip"
3735
3766
  }, null, 8, _hoisted_5$2)) : vue.createCommentVNode("v-if", true)
3736
3767
  ])),
3737
- __props.config.schematic && show.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$1, [
3768
+ __props.config.schematic && show.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, [
3738
3769
  vue.createElementVNode("div", _hoisted_7, [
3739
3770
  (vue.openBlock(true), vue.createElementBlock(
3740
3771
  vue.Fragment,
3741
3772
  null,
3742
3773
  vue.renderList(__props.config.items, (item, index) => {
3743
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
3774
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
3744
3775
  key: key(item, index),
3745
3776
  model: name.value ? __props.model[name.value] : __props.model,
3746
3777
  lastValues: name.value ? __props.lastValues[name.value] : __props.lastValues,
@@ -3752,7 +3783,7 @@
3752
3783
  labelWidth: lWidth.value,
3753
3784
  size: __props.size,
3754
3785
  onChange: changeHandler,
3755
- onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
3786
+ onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
3756
3787
  }, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
3757
3788
  }),
3758
3789
  128
@@ -3767,7 +3798,7 @@
3767
3798
  vue.Fragment,
3768
3799
  { key: 3 },
3769
3800
  vue.renderList(__props.config.items, (item, index) => {
3770
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
3801
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
3771
3802
  key: key(item, index),
3772
3803
  model: name.value ? __props.model[name.value] : __props.model,
3773
3804
  lastValues: name.value ? __props.lastValues[name.value] : __props.lastValues,
@@ -3779,7 +3810,7 @@
3779
3810
  size: __props.size,
3780
3811
  disabled: __props.disabled,
3781
3812
  onChange: changeHandler,
3782
- onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
3813
+ onAddDiffCount: _cache[1] || (_cache[1] = ($event) => onAddDiffCount())
3783
3814
  }, null, 8, ["model", "lastValues", "is-compare", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
3784
3815
  }),
3785
3816
  128
@@ -3793,10 +3824,73 @@
3793
3824
  }
3794
3825
  });
3795
3826
 
3796
- const _hoisted_1$c = { class: "m-fields-group-list-item" };
3827
+ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
3828
+ ...{
3829
+ name: "MFormFlexLayout"
3830
+ },
3831
+ __name: "FlexLayout",
3832
+ props: {
3833
+ model: {},
3834
+ lastValues: {},
3835
+ isCompare: { type: Boolean },
3836
+ config: {},
3837
+ name: {},
3838
+ labelWidth: {},
3839
+ prop: {},
3840
+ size: {},
3841
+ disabled: { type: Boolean }
3842
+ },
3843
+ emits: ["change", "addDiffCount"],
3844
+ setup(__props, { emit: __emit }) {
3845
+ const props = __props;
3846
+ const emit = __emit;
3847
+ const mForm = vue.inject("mForm");
3848
+ const gap = vue.computed(() => props.config.gap || "16px");
3849
+ const changeHandler = (v, eventData) => {
3850
+ emit("change", props.model, eventData);
3851
+ };
3852
+ const onAddDiffCount = () => emit("addDiffCount");
3853
+ return (_ctx, _cache) => {
3854
+ return vue.openBlock(), vue.createElementBlock(
3855
+ "div",
3856
+ {
3857
+ class: "m-form-flex-layout",
3858
+ style: vue.normalizeStyle({ display: "flex", flexWrap: "wrap", gap: gap.value })
3859
+ },
3860
+ [
3861
+ (vue.openBlock(true), vue.createElementBlock(
3862
+ vue.Fragment,
3863
+ null,
3864
+ vue.renderList(__props.config.items, (item, index) => {
3865
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
3866
+ key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
3867
+ config: item,
3868
+ model: __props.name ? __props.model[__props.name] : __props.model,
3869
+ lastValues: __props.name ? __props.lastValues[__props.name] : __props.lastValues,
3870
+ "is-compare": __props.isCompare,
3871
+ prop: __props.prop,
3872
+ size: __props.size,
3873
+ disabled: __props.disabled,
3874
+ "label-width": __props.config.labelWidth || __props.labelWidth,
3875
+ onChange: changeHandler,
3876
+ onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
3877
+ }, null, 8, ["config", "model", "lastValues", "is-compare", "prop", "size", "disabled", "label-width"]);
3878
+ }),
3879
+ 128
3880
+ /* KEYED_FRAGMENT */
3881
+ ))
3882
+ ],
3883
+ 4
3884
+ /* STYLE */
3885
+ );
3886
+ };
3887
+ }
3888
+ });
3889
+
3890
+ const _hoisted_1$b = { class: "m-fields-group-list-item" };
3797
3891
  const _hoisted_2$5 = { style: { "text-align": "right", "margin-top": "20px" } };
3798
- const _hoisted_3$3 = ["innerHTML"];
3799
- const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
3892
+ const _hoisted_3$4 = ["innerHTML"];
3893
+ const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
3800
3894
  ...{
3801
3895
  name: "MFormGroupListItem"
3802
3896
  },
@@ -3874,7 +3968,7 @@
3874
3968
  emit("swap-item", props.index, moveSpecifyLocationIndex.value - 1);
3875
3969
  };
3876
3970
  return (_ctx, _cache) => {
3877
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
3971
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
3878
3972
  vue.createElementVNode("div", null, [
3879
3973
  vue.createVNode(vue.unref(design.TMagicButton), {
3880
3974
  link: "",
@@ -4063,9 +4157,9 @@
4063
4157
  key: 3,
4064
4158
  innerHTML: itemExtra.value,
4065
4159
  class: "m-form-tip"
4066
- }, null, 8, _hoisted_3$3)) : vue.createCommentVNode("v-if", true)
4160
+ }, null, 8, _hoisted_3$4)) : vue.createCommentVNode("v-if", true)
4067
4161
  ]),
4068
- expand.value ? (vue.openBlock(), vue.createBlock(_sfc_main$x, {
4162
+ expand.value ? (vue.openBlock(), vue.createBlock(_sfc_main$A, {
4069
4163
  key: 0,
4070
4164
  config: rowConfig.value,
4071
4165
  model: __props.model,
@@ -4083,13 +4177,13 @@
4083
4177
  }
4084
4178
  });
4085
4179
 
4086
- const _hoisted_1$b = { class: "m-fields-group-list" };
4180
+ const _hoisted_1$a = { class: "m-fields-group-list" };
4087
4181
  const _hoisted_2$4 = ["innerHTML"];
4088
- const _hoisted_3$2 = {
4182
+ const _hoisted_3$3 = {
4089
4183
  key: 1,
4090
4184
  class: "el-table__empty-block"
4091
4185
  };
4092
- const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
4186
+ const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
4093
4187
  ...{
4094
4188
  name: "MFormGroupList"
4095
4189
  },
@@ -4179,13 +4273,13 @@
4179
4273
  const onAddDiffCount = () => emit("addDiffCount");
4180
4274
  const getLastValues = (item, index) => item?.[index] || {};
4181
4275
  return (_ctx, _cache) => {
4182
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
4276
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
4183
4277
  __props.config.extra ? (vue.openBlock(), vue.createElementBlock("div", {
4184
4278
  key: 0,
4185
4279
  innerHTML: __props.config.extra,
4186
4280
  style: { "color": "rgba(0, 0, 0, 0.45)" }
4187
4281
  }, null, 8, _hoisted_2$4)) : vue.createCommentVNode("v-if", true),
4188
- !__props.model[__props.name] || !__props.model[__props.name].length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, [..._cache[1] || (_cache[1] = [
4282
+ !__props.model[__props.name] || !__props.model[__props.name].length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$3, [..._cache[1] || (_cache[1] = [
4189
4283
  vue.createElementVNode(
4190
4284
  "span",
4191
4285
  { class: "el-table__empty-text" },
@@ -4197,7 +4291,7 @@
4197
4291
  vue.Fragment,
4198
4292
  { key: 2 },
4199
4293
  vue.renderList(__props.model[__props.name], (item, index) => {
4200
- return vue.openBlock(), vue.createBlock(_sfc_main$v, {
4294
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, {
4201
4295
  key: index,
4202
4296
  model: item,
4203
4297
  lastValues: getLastValues(__props.lastValues[__props.name], index),
@@ -4257,15 +4351,15 @@
4257
4351
  }
4258
4352
  });
4259
4353
 
4260
- const _hoisted_1$a = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
4354
+ const _hoisted_1$9 = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
4261
4355
  const _hoisted_2$3 = ["innerHTML"];
4262
- const _hoisted_3$1 = {
4356
+ const _hoisted_3$2 = {
4263
4357
  key: 0,
4264
4358
  style: { "display": "flex" }
4265
4359
  };
4266
4360
  const _hoisted_4$1 = { style: { "flex": "1" } };
4267
4361
  const _hoisted_5$1 = ["src"];
4268
- const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
4362
+ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
4269
4363
  ...{
4270
4364
  name: "MFormPanel"
4271
4365
  },
@@ -4300,7 +4394,7 @@
4300
4394
  "body-style": { display: expand.value ? "block" : "none" }
4301
4395
  }, {
4302
4396
  header: vue.withCtx(() => [
4303
- vue.createElementVNode("div", _hoisted_1$a, [
4397
+ vue.createElementVNode("div", _hoisted_1$9, [
4304
4398
  vue.createVNode(vue.unref(design.TMagicButton), {
4305
4399
  style: { "padding": "0" },
4306
4400
  link: "",
@@ -4324,13 +4418,13 @@
4324
4418
  default: vue.withCtx(() => [
4325
4419
  vue.createElementVNode("div", null, [
4326
4420
  vue.renderSlot(_ctx.$slots, "default"),
4327
- __props.config.schematic ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$1, [
4421
+ __props.config.schematic ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, [
4328
4422
  vue.createElementVNode("div", _hoisted_4$1, [
4329
4423
  (vue.openBlock(true), vue.createElementBlock(
4330
4424
  vue.Fragment,
4331
4425
  null,
4332
4426
  vue.renderList(items.value, (item, index) => {
4333
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
4427
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
4334
4428
  key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
4335
4429
  config: item,
4336
4430
  model: __props.name ? __props.model[__props.name] : __props.model,
@@ -4356,7 +4450,7 @@
4356
4450
  vue.Fragment,
4357
4451
  { key: 1 },
4358
4452
  vue.renderList(items.value, (item, index) => {
4359
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
4453
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
4360
4454
  key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
4361
4455
  config: item,
4362
4456
  model: __props.name ? __props.model[__props.name] : __props.model,
@@ -4382,7 +4476,7 @@
4382
4476
  }
4383
4477
  });
4384
4478
 
4385
- const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
4479
+ const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
4386
4480
  ...{
4387
4481
  name: "MFormCol"
4388
4482
  },
@@ -4410,7 +4504,7 @@
4410
4504
  return (_ctx, _cache) => {
4411
4505
  return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCol), { span: __props.span }, {
4412
4506
  default: vue.withCtx(() => [
4413
- vue.createVNode(_sfc_main$x, {
4507
+ vue.createVNode(_sfc_main$A, {
4414
4508
  model: __props.model,
4415
4509
  lastValues: __props.lastValues,
4416
4510
  "is-compare": __props.isCompare,
@@ -4433,7 +4527,7 @@
4433
4527
  }
4434
4528
  });
4435
4529
 
4436
- const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
4530
+ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
4437
4531
  ...{
4438
4532
  name: "MFormRow"
4439
4533
  },
@@ -4466,7 +4560,7 @@
4466
4560
  vue.Fragment,
4467
4561
  null,
4468
4562
  vue.renderList(__props.config.items, (col, index) => {
4469
- return vue.openBlock(), vue.createBlock(_sfc_main$s, {
4563
+ return vue.openBlock(), vue.createBlock(_sfc_main$u, {
4470
4564
  key: col[vue.unref(mForm)?.keyProp || "__key"] ?? index,
4471
4565
  span: col.span || __props.config.span || 24 / __props.config.items.length,
4472
4566
  config: col,
@@ -4493,7 +4587,7 @@
4493
4587
  }
4494
4588
  });
4495
4589
 
4496
- const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
4590
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
4497
4591
  ...{
4498
4592
  name: "MFormStep"
4499
4593
  },
@@ -4568,7 +4662,7 @@
4568
4662
  vue.Fragment,
4569
4663
  null,
4570
4664
  [
4571
- item ? vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$x, {
4665
+ item ? vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$A, {
4572
4666
  key: item[vue.unref(mForm)?.keyProp || "__key"],
4573
4667
  config: item,
4574
4668
  model: step.name ? __props.model[step.name] : __props.model,
@@ -4604,1044 +4698,325 @@
4604
4698
  }
4605
4699
  });
4606
4700
 
4607
- const _hoisted_1$9 = { class: "m-fields-table-wrap" };
4608
- const _hoisted_2$2 = ["innerHTML"];
4609
- const _hoisted_3 = ["innerHTML"];
4610
- const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
4611
- const _hoisted_5 = { style: { "display": "flex" } };
4612
- const _hoisted_6 = {
4613
- key: 1,
4614
- class: "bottom",
4615
- style: { "text-align": "right" }
4616
- };
4617
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
4701
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
4618
4702
  ...{
4619
- name: "MFormTable"
4703
+ name: "MFormTabs"
4620
4704
  },
4621
- __name: "Table",
4705
+ __name: "Tabs",
4622
4706
  props: {
4623
4707
  model: {},
4624
4708
  lastValues: { default: () => ({}) },
4625
4709
  isCompare: { type: Boolean, default: false },
4626
4710
  config: {},
4627
4711
  name: {},
4628
- prop: { default: "" },
4629
- labelWidth: {},
4630
- sort: { type: Boolean },
4631
- disabled: { type: Boolean },
4632
- sortKey: { default: "" },
4633
- text: {},
4634
4712
  size: {},
4635
- enableToggleMode: { type: Boolean, default: true },
4636
- showIndex: { type: Boolean, default: true }
4713
+ labelWidth: {},
4714
+ prop: {},
4715
+ expandMore: { type: Boolean },
4716
+ disabled: { type: Boolean }
4637
4717
  },
4638
- emits: ["change", "select", "addDiffCount"],
4639
- setup(__props, { expose: __expose, emit: __emit }) {
4640
- const props = __props;
4641
- const emit = __emit;
4642
- let timer = null;
4643
- const mForm = vue.inject("mForm");
4644
- const { nextZIndex } = design.useZIndex();
4645
- const tMagicTable = vue.ref();
4646
- const excelBtn = vue.ref();
4647
- const mTable = vue.ref();
4648
- const pagesize = vue.ref(10);
4649
- const pagecontext = vue.ref(0);
4650
- const updateKey = vue.ref(1);
4651
- const isFullscreen = vue.ref(false);
4652
- const modelName = vue.computed(() => props.name || props.config.name || "");
4653
- const getDataByPage = (data2 = []) => data2.filter(
4654
- (item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
4655
- );
4656
- const pageinationData = vue.computed(() => getDataByPage(props.model[modelName.value]));
4657
- const data = vue.computed(() => props.config.pagination ? pageinationData.value : props.model[modelName.value]);
4658
- const lastData = vue.computed(
4659
- () => props.config.pagination ? getDataByPage(props.lastValues[modelName.value]) : props.lastValues[modelName.value] || []
4660
- );
4661
- const sortChange = ({ prop, order }) => {
4662
- if (order === "ascending") {
4663
- props.model[modelName.value] = props.model[modelName.value].sort((a, b) => a[prop] - b[prop]);
4664
- } else if (order === "descending") {
4665
- props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
4666
- }
4718
+ emits: ["change", "addDiffCount"],
4719
+ setup(__props, { emit: __emit }) {
4720
+ const tabPaneComponent = design.getDesignConfig("components")?.tabPane;
4721
+ const tabsComponent = design.getDesignConfig("components")?.tabs;
4722
+ const getActive = (mForm2, props2, activeTabName2) => {
4723
+ const { config, model, prop } = props2;
4724
+ const { active } = config;
4725
+ if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
4726
+ if (0 >= props2.config.items.length) return "0";
4727
+ if (typeof active !== "undefined") return active;
4728
+ return "0";
4667
4729
  };
4668
- const swapArray = (index1, index2) => {
4669
- props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
4670
- if (props.sortKey) {
4671
- for (let i = props.model[modelName.value].length - 1, v = 0; i >= 0; i--, v++) {
4672
- props.model[modelName.value][v][props.sortKey] = i;
4673
- }
4730
+ const tabClick = (mForm2, tab, props2) => {
4731
+ const { config, model, prop } = props2;
4732
+ tab.name = tab.paneName;
4733
+ if (typeof config.onTabClick === "function") {
4734
+ config.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
4674
4735
  }
4675
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
4676
- };
4677
- let sortable;
4678
- const rowDrop = () => {
4679
- sortable?.destroy();
4680
- const tableEl = tMagicTable.value?.instance.$el;
4681
- const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
4682
- if (!tBodyEl) {
4683
- return;
4736
+ const tabConfig = config.items.find((item) => tab.name === item.status);
4737
+ if (tabConfig && typeof tabConfig.onTabClick === "function") {
4738
+ tabConfig.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
4684
4739
  }
4685
- sortable = Sortable.create(tBodyEl, {
4686
- draggable: ".tmagic-design-table-row",
4687
- filter: "input",
4688
- // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
4689
- preventOnFilter: false,
4690
- // 允许选字
4691
- direction: "vertical",
4692
- onEnd: ({ newIndex, oldIndex }) => {
4693
- if (typeof newIndex === "undefined") return;
4694
- if (typeof oldIndex === "undefined") return;
4695
- swapArray(newIndex, oldIndex);
4696
- emit("change", props.model[modelName.value]);
4697
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
4698
- }
4699
- });
4700
4740
  };
4701
- const newHandler = async (row) => {
4702
- if (props.config.max && props.model[modelName.value].length >= props.config.max) {
4703
- design.tMagicMessage.error(`最多新增配置不能超过${props.config.max}条`);
4704
- return;
4741
+ const props = __props;
4742
+ const emit = __emit;
4743
+ const mForm = vue.inject("mForm");
4744
+ const activeTabName = vue.ref(getActive(mForm, props));
4745
+ const diffCount = vue.ref({});
4746
+ const tabs = vue.computed(() => {
4747
+ if (props.config.dynamic) {
4748
+ if (!props.config.name) throw new Error("dynamic tab 必须配置name");
4749
+ return props.model[props.config.name] || [];
4705
4750
  }
4706
- if (typeof props.config.beforeAddRow === "function") {
4707
- const beforeCheckRes = props.config.beforeAddRow(mForm, {
4708
- model: props.model[modelName.value],
4709
- formValue: mForm?.values,
4751
+ return props.config.items.filter((item) => display(mForm, item.display, props));
4752
+ });
4753
+ const filter = (config) => filterFunction(mForm, config, props);
4754
+ vue.watchEffect(() => {
4755
+ if (typeof props.config.activeChange === "function") {
4756
+ props.config.activeChange(mForm, activeTabName.value, {
4757
+ model: props.model,
4710
4758
  prop: props.prop
4711
4759
  });
4712
- if (!beforeCheckRes) return;
4713
4760
  }
4714
- const columns = props.config.items;
4715
- const enumValues = props.config.enum || [];
4716
- let enumV = [];
4717
- const { length } = props.model[modelName.value];
4718
- const key = props.config.key || "id";
4719
- let inputs = {};
4720
- if (enumValues.length) {
4721
- if (length >= enumValues.length) {
4722
- return;
4723
- }
4724
- enumV = enumValues.filter((item) => {
4725
- let i = 0;
4726
- for (; i < length; i++) {
4727
- if (item[key] === props.model[modelName.value][i][key]) {
4728
- break;
4729
- }
4730
- }
4731
- return i === length;
4732
- });
4733
- if (enumV.length > 0) {
4734
- inputs = enumV[0];
4735
- }
4736
- } else if (Array.isArray(row)) {
4737
- columns.forEach((column, index) => {
4738
- column.name && (inputs[column.name] = row[index]);
4739
- });
4761
+ });
4762
+ const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
4763
+ const tabClickHandler = (tab) => {
4764
+ if (typeof tab === "object") {
4765
+ tabClick(mForm, tab, props);
4740
4766
  } else {
4741
- if (typeof props.config.defaultAdd === "function") {
4742
- inputs = await props.config.defaultAdd(mForm, {
4743
- model: props.model[modelName.value],
4744
- formValue: mForm?.values
4745
- });
4746
- } else if (props.config.defaultAdd) {
4747
- inputs = props.config.defaultAdd;
4767
+ let item = tabs.value.find((tab2) => tab2.status === tab2);
4768
+ if (!item) {
4769
+ item = tabs.value[tab];
4748
4770
  }
4749
- inputs = await initValue(mForm, {
4750
- config: columns,
4751
- initValues: inputs
4752
- });
4771
+ tabClick(mForm, item, props);
4753
4772
  }
4754
- if (props.sortKey && length) {
4755
- inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
4756
- }
4757
- props.model[modelName.value].push(inputs);
4758
- emit("change", props.model[modelName.value], {
4759
- changeRecords: [
4760
- {
4761
- propPath: `${props.prop}.${props.model[modelName.value].length - 1}`,
4762
- value: inputs
4763
- }
4764
- ]
4765
- });
4766
4773
  };
4767
- vue.onMounted(() => {
4768
- if (props.config.defautSort) {
4769
- sortChange(props.config.defautSort);
4770
- } else if (props.config.defaultSort) {
4771
- sortChange(props.config.defaultSort);
4772
- }
4773
- if (props.sort && props.sortKey) {
4774
- props.model[modelName.value].sort((a, b) => b[props.sortKey] - a[props.sortKey]);
4775
- }
4776
- });
4777
- vue.watchEffect(() => {
4778
- if (props.config.dropSort) {
4779
- rowDrop();
4780
- }
4781
- });
4782
- const addable = vue.computed(() => {
4783
- if (!props.model[modelName.value].length) {
4784
- return true;
4785
- }
4786
- if (typeof props.config.addable === "function") {
4787
- return props.config.addable(mForm, {
4788
- model: props.model[modelName.value],
4789
- formValue: mForm?.values,
4790
- prop: props.prop
4774
+ const onTabAdd = async () => {
4775
+ if (!props.name) throw new Error("dynamic tab 必须配置name");
4776
+ if (typeof props.config.onTabAdd === "function") {
4777
+ props.config.onTabAdd(mForm, {
4778
+ model: props.model,
4779
+ prop: props.prop,
4780
+ config: props.config
4791
4781
  });
4792
- }
4793
- return typeof props.config.addable === "undefined" ? true : props.config.addable;
4794
- });
4795
- const selection = vue.computed(() => {
4796
- if (typeof props.config.selection === "function") {
4797
- return props.config.selection(mForm, { model: props.model[modelName.value] });
4798
- }
4799
- return props.config.selection;
4800
- });
4801
- const importable = vue.computed(() => {
4802
- if (typeof props.config.importable === "function") {
4803
- return props.config.importable(mForm, {
4804
- formValue: mForm?.values,
4805
- model: props.model[modelName.value]
4782
+ emit("change", props.model);
4783
+ } else {
4784
+ const newObj = await initValue(mForm, {
4785
+ config: props.config.items,
4786
+ initValues: {}
4787
+ });
4788
+ newObj.title = `标签${tabs.value.length + 1}`;
4789
+ props.model[props.name].push(newObj);
4790
+ emit("change", props.model[props.name], {
4791
+ changeRecords: [
4792
+ {
4793
+ propPath: `${props.prop}.${props.model[props.name].length - 1}`,
4794
+ value: newObj
4795
+ }
4796
+ ]
4806
4797
  });
4807
4798
  }
4808
- return typeof props.config.importable === "undefined" ? false : props.config.importable;
4809
- });
4810
- const display$1 = (fuc) => display(mForm, fuc, props);
4811
- const itemExtra = (fuc, index) => {
4812
- if (typeof fuc === "function") {
4813
- return fuc(mForm, {
4814
- values: mForm?.initValues,
4799
+ mForm?.$emit("field-change", props.prop, props.model[props.name]);
4800
+ };
4801
+ const onTabRemove = (tabName) => {
4802
+ if (!props.name) throw new Error("dynamic tab 必须配置name");
4803
+ if (typeof props.config.onTabRemove === "function") {
4804
+ props.config.onTabRemove(mForm, tabName, {
4815
4805
  model: props.model,
4816
- formValue: mForm ? mForm.values : props.model,
4817
4806
  prop: props.prop,
4818
- index
4807
+ config: props.config
4819
4808
  });
4809
+ } else {
4810
+ props.model[props.name].splice(+tabName, 1);
4811
+ if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
4812
+ activeTabName.value = (+activeTabName.value - 1).toString();
4813
+ tabClick(mForm, { name: activeTabName.value }, props);
4814
+ }
4820
4815
  }
4821
- return fuc;
4822
- };
4823
- const removeHandler = (index) => {
4824
- if (props.disabled) return;
4825
- props.model[modelName.value].splice(index, 1);
4826
- emit("change", props.model[modelName.value]);
4827
- };
4828
- const selectHandle = (selection2, row) => {
4829
- if (typeof props.config.selection === "string" && props.config.selection === "single") {
4830
- tMagicTable.value?.clearSelection();
4831
- tMagicTable.value?.toggleRowSelection(row, true);
4832
- }
4833
- emit("select", selection2, row);
4834
- if (typeof props.config.onSelect === "function") {
4835
- props.config.onSelect(mForm, { selection: selection2, row, config: props.config });
4836
- }
4816
+ emit("change", props.model);
4817
+ mForm?.$emit("field-change", props.prop, props.model[props.name]);
4837
4818
  };
4838
- const toggleRowSelection = (row, selected) => {
4839
- tMagicTable.value?.toggleRowSelection.call(tMagicTable.value, row, selected);
4819
+ const changeHandler = (v, eventData) => {
4820
+ emit("change", props.model, eventData);
4840
4821
  };
4841
- const makeConfig = (config, row) => {
4842
- const newConfig = cloneDeep(config);
4843
- if (typeof config.itemsFunction === "function") {
4844
- newConfig.items = config.itemsFunction(row);
4822
+ const onAddDiffCount = (tabIndex) => {
4823
+ if (!diffCount.value[tabIndex]) {
4824
+ diffCount.value[tabIndex] = 1;
4825
+ } else {
4826
+ diffCount.value[tabIndex] += 1;
4845
4827
  }
4846
- delete newConfig.display;
4847
- return newConfig;
4828
+ emit("addDiffCount");
4848
4829
  };
4849
- const upHandler = (index) => {
4850
- if (timer) {
4851
- clearTimeout(timer);
4852
- }
4853
- timer = setTimeout(() => {
4854
- swapArray(index, index - 1);
4855
- timer = void 0;
4856
- }, 300);
4830
+ return (_ctx, _cache) => {
4831
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tabsComponent)?.component || "el-tabs"), vue.mergeProps(
4832
+ {
4833
+ modelValue: activeTabName.value,
4834
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
4835
+ },
4836
+ vue.unref(tabsComponent)?.props({
4837
+ type: __props.config.tabType,
4838
+ editable: __props.config.editable || false,
4839
+ tabPosition: __props.config.tabPosition || "top"
4840
+ }) || {},
4841
+ {
4842
+ class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
4843
+ onTabClick: tabClickHandler,
4844
+ onTabAdd,
4845
+ onTabRemove
4846
+ }
4847
+ ), {
4848
+ default: vue.withCtx(() => [
4849
+ (vue.openBlock(true), vue.createElementBlock(
4850
+ vue.Fragment,
4851
+ null,
4852
+ vue.renderList(tabs.value, (tab, tabIndex) => {
4853
+ return vue.openBlock(), vue.createBlock(
4854
+ vue.resolveDynamicComponent(vue.unref(tabPaneComponent)?.component || "el-tab-pane"),
4855
+ vue.mergeProps(
4856
+ {
4857
+ key: tab[vue.unref(mForm)?.keyProp || "__key"] ?? tabIndex
4858
+ },
4859
+ { ref_for: true },
4860
+ vue.unref(tabPaneComponent)?.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false }) || {}
4861
+ ),
4862
+ {
4863
+ label: vue.withCtx(() => [
4864
+ vue.createElementVNode("span", null, [
4865
+ vue.createTextVNode(
4866
+ vue.toDisplayString(filter(tab.title)),
4867
+ 1
4868
+ /* TEXT */
4869
+ ),
4870
+ vue.createVNode(vue.unref(design.TMagicBadge), {
4871
+ hidden: !diffCount.value[tabIndex],
4872
+ value: diffCount.value[tabIndex],
4873
+ class: "diff-count-badge"
4874
+ }, null, 8, ["hidden", "value"])
4875
+ ])
4876
+ ]),
4877
+ default: vue.withCtx(() => [
4878
+ (vue.openBlock(true), vue.createElementBlock(
4879
+ vue.Fragment,
4880
+ null,
4881
+ vue.renderList(tabItems(tab), (item) => {
4882
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
4883
+ key: item[vue.unref(mForm)?.keyProp || "__key"],
4884
+ config: item,
4885
+ disabled: __props.disabled,
4886
+ 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,
4887
+ "last-values": vue.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,
4888
+ "is-compare": __props.isCompare,
4889
+ prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
4890
+ size: __props.size,
4891
+ "label-width": tab.labelWidth || __props.labelWidth,
4892
+ "expand-more": __props.expandMore,
4893
+ onChange: changeHandler,
4894
+ onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
4895
+ }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
4896
+ }),
4897
+ 128
4898
+ /* KEYED_FRAGMENT */
4899
+ ))
4900
+ ]),
4901
+ _: 2
4902
+ /* DYNAMIC */
4903
+ },
4904
+ 1040
4905
+ /* FULL_PROPS, DYNAMIC_SLOTS */
4906
+ );
4907
+ }),
4908
+ 128
4909
+ /* KEYED_FRAGMENT */
4910
+ ))
4911
+ ]),
4912
+ _: 1
4913
+ /* STABLE */
4914
+ }, 16, ["modelValue", "class"]);
4857
4915
  };
4858
- const topHandler = (index) => {
4859
- if (timer) {
4860
- clearTimeout(timer);
4916
+ }
4917
+ });
4918
+
4919
+ let $MAGIC_FORM = {};
4920
+ const setConfig = (option) => {
4921
+ $MAGIC_FORM = option;
4922
+ };
4923
+ const getConfig = (key) => $MAGIC_FORM[key];
4924
+
4925
+ const useAddField = (prop) => {
4926
+ if (!prop) return;
4927
+ const mForm = vue.inject("mForm");
4928
+ const instance = vue.getCurrentInstance();
4929
+ vue.watch(
4930
+ () => instance?.proxy,
4931
+ (vm) => {
4932
+ if (vm) {
4933
+ mForm?.setField(prop, vm);
4934
+ } else {
4935
+ mForm?.deleteField(prop);
4861
4936
  }
4862
- const moveNum = index;
4863
- for (let i = 0; i < moveNum; i++) {
4864
- swapArray(index, index - 1);
4865
- index -= 1;
4937
+ },
4938
+ {
4939
+ immediate: true
4940
+ }
4941
+ );
4942
+ };
4943
+
4944
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
4945
+ ...{
4946
+ name: "MFormCascader"
4947
+ },
4948
+ __name: "Cascader",
4949
+ props: {
4950
+ config: {},
4951
+ model: {},
4952
+ initValues: {},
4953
+ values: {},
4954
+ name: {},
4955
+ prop: {},
4956
+ disabled: { type: Boolean },
4957
+ size: {},
4958
+ lastValues: {}
4959
+ },
4960
+ emits: ["change"],
4961
+ setup(__props, { emit: __emit }) {
4962
+ const props = __props;
4963
+ const emit = __emit;
4964
+ const mForm = vue.inject("mForm");
4965
+ useAddField(props.prop);
4966
+ const requestFunc = getConfig("request");
4967
+ const tMagicCascader = vue.ref();
4968
+ const options = vue.ref([]);
4969
+ const remoteData = vue.ref(null);
4970
+ const checkStrictly = vue.computed(() => filterFunction(mForm, props.config.checkStrictly, props));
4971
+ const valueSeparator = vue.computed(() => filterFunction(mForm, props.config.valueSeparator, props));
4972
+ const value = vue.computed(() => {
4973
+ if (typeof props.model[props.name] === "string" && valueSeparator.value) {
4974
+ return props.model[props.name].split(valueSeparator.value);
4866
4975
  }
4867
- };
4868
- const downHandler = (index) => {
4869
- if (timer) {
4870
- clearTimeout(timer);
4976
+ return props.model[props.name];
4977
+ });
4978
+ const updateModelValueHandler = (value2) => {
4979
+ let result = value2;
4980
+ if (valueSeparator.value) {
4981
+ result = value2.join(valueSeparator.value);
4982
+ }
4983
+ if (typeof result === "undefined") {
4984
+ if (Array.isArray(props.model[props.name])) {
4985
+ emit("change", []);
4986
+ } else if (typeof props.model[props.name] === "string") {
4987
+ emit("change", "");
4988
+ } else if (typeof props.model[props.name] === "object") {
4989
+ emit("change", null);
4990
+ }
4871
4991
  }
4872
- timer = setTimeout(() => {
4873
- swapArray(index, index + 1);
4874
- timer = void 0;
4875
- }, 300);
4992
+ emit("change", result);
4876
4993
  };
4877
- const bottomHandler = (index) => {
4878
- if (timer) {
4879
- clearTimeout(timer);
4880
- }
4881
- const moveNum = props.model[modelName.value].length - 1 - index;
4882
- for (let i = 0; i < moveNum; i++) {
4883
- swapArray(index, index + 1);
4884
- index += 1;
4994
+ const setRemoteOptions = async function() {
4995
+ const { config } = props;
4996
+ const { option } = config;
4997
+ if (!option) return;
4998
+ let { body } = option;
4999
+ const postOptions = {
5000
+ url: option.url,
5001
+ cache: option.cache,
5002
+ timeout: option.timeout,
5003
+ data: {}
5004
+ };
5005
+ if (body && mForm) {
5006
+ if (typeof body === "function" && props.model && mForm) {
5007
+ body = body(mForm, {
5008
+ model: props.model,
5009
+ formValue: mForm.values,
5010
+ formValues: mForm.values,
5011
+ config: props.config
5012
+ });
5013
+ }
5014
+ postOptions.data = body;
4885
5015
  }
4886
- };
4887
- const showDelete = (index) => {
4888
- const deleteFunc = props.config.delete;
4889
- if (deleteFunc && typeof deleteFunc === "function") {
4890
- return deleteFunc(props.model[modelName.value], index, mForm?.values);
4891
- }
4892
- return true;
4893
- };
4894
- const copyable = (index) => {
4895
- const copyableFunc = props.config.copyable;
4896
- if (copyableFunc && typeof copyableFunc === "function") {
4897
- return copyableFunc(mForm, {
4898
- values: mForm?.initValues || {},
4899
- model: props.model,
4900
- parent: mForm?.parentValues || {},
4901
- formValue: mForm?.values || props.model,
4902
- prop: props.prop,
4903
- config: props.config,
4904
- index
4905
- });
4906
- }
4907
- return true;
4908
- };
4909
- const clearHandler = () => {
4910
- const len = props.model[modelName.value].length;
4911
- props.model[modelName.value].splice(0, len);
4912
- mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
4913
- };
4914
- const excelHandler = async (file) => {
4915
- if (!file?.raw) {
4916
- return false;
4917
- }
4918
- if (!globalThis.XLSX) {
4919
- await utils.asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
4920
- }
4921
- const reader = new FileReader();
4922
- reader.onload = () => {
4923
- const data2 = reader.result;
4924
- const pdata = globalThis.XLSX.read(data2, { type: "array" });
4925
- pdata.SheetNames.forEach((sheetName) => {
4926
- const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
4927
- if (arr?.[0]) {
4928
- arr.forEach((row) => {
4929
- newHandler(row);
4930
- });
4931
- }
4932
- setTimeout(() => {
4933
- excelBtn.value?.clearFiles();
4934
- }, 300);
4935
- });
4936
- };
4937
- reader.readAsArrayBuffer(file.raw);
4938
- return false;
4939
- };
4940
- const handleSizeChange = (val) => {
4941
- pagesize.value = val;
4942
- };
4943
- const handleCurrentChange = (val) => {
4944
- pagecontext.value = val - 1;
4945
- };
4946
- const copyHandler = (index) => {
4947
- props.model[modelName.value].push(cloneDeep(props.model[modelName.value][index]));
4948
- };
4949
- const toggleMode = () => {
4950
- const calcLabelWidth = (label) => {
4951
- if (!label) return "0px";
4952
- const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
4953
- const chLength = label.length - zhLength;
4954
- return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
4955
- };
4956
- props.config.type = "groupList";
4957
- props.config.enableToggleMode = true;
4958
- props.config.tableItems = props.config.items;
4959
- props.config.items = props.config.groupItems || props.config.items.map((item) => {
4960
- const text = item.text || item.label;
4961
- const labelWidth = calcLabelWidth(text);
4962
- return {
4963
- ...item,
4964
- text,
4965
- labelWidth,
4966
- span: item.span || 12
4967
- };
4968
- });
4969
- };
4970
- const toggleFullscreen = () => {
4971
- if (!mTable.value) return;
4972
- if (isFullscreen.value) {
4973
- mTable.value.classList.remove("fixed");
4974
- isFullscreen.value = false;
4975
- } else {
4976
- mTable.value.classList.add("fixed");
4977
- mTable.value.style.zIndex = `${nextZIndex()}`;
4978
- isFullscreen.value = true;
4979
- }
4980
- };
4981
- const getProp = (index) => {
4982
- const { prop } = vue.toRefs(props);
4983
- return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
4984
- };
4985
- const onAddDiffCount = () => emit("addDiffCount");
4986
- const changeHandler = (v, eventData) => {
4987
- emit("change", props.model, eventData);
4988
- };
4989
- __expose({
4990
- toggleRowSelection
4991
- });
4992
- return (_ctx, _cache) => {
4993
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
4994
- (vue.openBlock(), vue.createBlock(vue.Teleport, {
4995
- to: "body",
4996
- disabled: !isFullscreen.value
4997
- }, [
4998
- vue.createElementVNode(
4999
- "div",
5000
- {
5001
- ref_key: "mTable",
5002
- ref: mTable,
5003
- class: vue.normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }])
5004
- },
5005
- [
5006
- __props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
5007
- key: 0,
5008
- style: { "color": "rgba(0, 0, 0, 0.45)" },
5009
- innerHTML: __props.config.extra
5010
- }, null, 8, _hoisted_2$2)) : vue.createCommentVNode("v-if", true),
5011
- vue.createVNode(vue.unref(design.TMagicTooltip), {
5012
- content: "拖拽可排序",
5013
- placement: "left-start",
5014
- disabled: __props.config.dropSort !== true
5015
- }, {
5016
- default: vue.withCtx(() => [
5017
- __props.model[modelName.value] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTable), {
5018
- ref_key: "tMagicTable",
5019
- ref: tMagicTable,
5020
- style: { "width": "100%" },
5021
- "row-key": __props.config.rowKey || "id",
5022
- data: data.value,
5023
- lastData: lastData.value,
5024
- border: __props.config.border,
5025
- "max-height": __props.config.maxHeight,
5026
- "default-expand-all": true,
5027
- key: updateKey.value,
5028
- onSelect: selectHandle,
5029
- onSortChange: sortChange
5030
- }, {
5031
- default: vue.withCtx(() => [
5032
- __props.config.itemExtra && !__props.config.dropSort ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
5033
- key: 0,
5034
- fixed: "left",
5035
- width: "30",
5036
- type: "expand"
5037
- }, {
5038
- default: vue.withCtx((scope) => [
5039
- vue.createElementVNode("span", {
5040
- innerHTML: itemExtra(__props.config.itemExtra, scope.$index),
5041
- class: "m-form-tip"
5042
- }, null, 8, _hoisted_3)
5043
- ]),
5044
- _: 1
5045
- /* STABLE */
5046
- })) : vue.createCommentVNode("v-if", true),
5047
- vue.createVNode(vue.unref(design.TMagicTableColumn), {
5048
- label: "操作",
5049
- width: __props.config.operateColWidth || 100,
5050
- align: "center",
5051
- fixed: __props.config.fixed === false ? void 0 : "left"
5052
- }, {
5053
- default: vue.withCtx((scope) => [
5054
- vue.renderSlot(_ctx.$slots, "operateCol", { scope }),
5055
- vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
5056
- size: "small",
5057
- type: "danger",
5058
- link: "",
5059
- title: "删除",
5060
- icon: vue.unref(iconsVue.Delete),
5061
- onClick: ($event) => removeHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
5062
- }, null, 8, ["icon", "onClick"]), [
5063
- [vue.vShow, showDelete(scope.$index + 1 + pagecontext.value * pagesize.value - 1)]
5064
- ]),
5065
- copyable(scope.$index + 1 + pagecontext.value * pagesize.value - 1) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5066
- key: 0,
5067
- link: "",
5068
- size: "small",
5069
- type: "primary",
5070
- title: "复制",
5071
- icon: vue.unref(iconsVue.DocumentCopy),
5072
- disabled: __props.disabled,
5073
- onClick: ($event) => copyHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
5074
- }, null, 8, ["icon", "disabled", "onClick"])) : vue.createCommentVNode("v-if", true)
5075
- ]),
5076
- _: 3
5077
- /* FORWARDED */
5078
- }, 8, ["width", "fixed"]),
5079
- __props.sort && __props.model[modelName.value] && __props.model[modelName.value].length > 1 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
5080
- key: 1,
5081
- label: "排序",
5082
- width: "60"
5083
- }, {
5084
- default: vue.withCtx((scope) => [
5085
- scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== 0 ? (vue.openBlock(), vue.createBlock(
5086
- vue.unref(design.TMagicTooltip),
5087
- {
5088
- key: 0,
5089
- content: "点击上移,双击置顶",
5090
- placement: "top"
5091
- },
5092
- {
5093
- default: vue.withCtx(() => [
5094
- vue.createVNode(vue.unref(design.TMagicButton), {
5095
- plain: "",
5096
- size: "small",
5097
- type: "primary",
5098
- icon: vue.unref(iconsVue.ArrowUp),
5099
- disabled: __props.disabled,
5100
- link: "",
5101
- onClick: ($event) => upHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
5102
- onDblclick: ($event) => topHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
5103
- }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
5104
- ]),
5105
- _: 2
5106
- /* DYNAMIC */
5107
- },
5108
- 1024
5109
- /* DYNAMIC_SLOTS */
5110
- )) : vue.createCommentVNode("v-if", true),
5111
- scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== __props.model[modelName.value].length - 1 ? (vue.openBlock(), vue.createBlock(
5112
- vue.unref(design.TMagicTooltip),
5113
- {
5114
- key: 1,
5115
- content: "点击下移,双击置底",
5116
- placement: "top"
5117
- },
5118
- {
5119
- default: vue.withCtx(() => [
5120
- vue.createVNode(vue.unref(design.TMagicButton), {
5121
- plain: "",
5122
- size: "small",
5123
- type: "primary",
5124
- icon: vue.unref(iconsVue.ArrowDown),
5125
- disabled: __props.disabled,
5126
- link: "",
5127
- onClick: ($event) => downHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
5128
- onDblclick: ($event) => bottomHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
5129
- }, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
5130
- ]),
5131
- _: 2
5132
- /* DYNAMIC */
5133
- },
5134
- 1024
5135
- /* DYNAMIC_SLOTS */
5136
- )) : vue.createCommentVNode("v-if", true)
5137
- ]),
5138
- _: 1
5139
- /* STABLE */
5140
- })) : vue.createCommentVNode("v-if", true),
5141
- selection.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
5142
- key: 2,
5143
- align: "center",
5144
- "header-align": "center",
5145
- type: "selection",
5146
- width: "45"
5147
- })) : vue.createCommentVNode("v-if", true),
5148
- __props.showIndex && __props.config.showIndex ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
5149
- key: 3,
5150
- width: "60",
5151
- label: "序号"
5152
- }, {
5153
- default: vue.withCtx((scope) => [
5154
- vue.createTextVNode(
5155
- vue.toDisplayString(scope.$index + 1 + pagecontext.value * pagesize.value),
5156
- 1
5157
- /* TEXT */
5158
- )
5159
- ]),
5160
- _: 1
5161
- /* STABLE */
5162
- })) : vue.createCommentVNode("v-if", true),
5163
- (vue.openBlock(true), vue.createElementBlock(
5164
- vue.Fragment,
5165
- null,
5166
- vue.renderList(__props.config.items, (column, index) => {
5167
- return vue.openBlock(), vue.createElementBlock(
5168
- vue.Fragment,
5169
- null,
5170
- [
5171
- column.type !== "hidden" && display$1(column.display) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
5172
- prop: column.name,
5173
- width: column.width,
5174
- label: column.label,
5175
- sortable: column.sortable,
5176
- "sort-orders": ["ascending", "descending"],
5177
- key: column[vue.unref(mForm)?.keyProp || "__key"] ?? index,
5178
- "class-name": __props.config.dropSort === true ? "el-table__column--dropable" : ""
5179
- }, {
5180
- default: vue.withCtx((scope) => [
5181
- scope.$index > -1 ? (vue.openBlock(), vue.createBlock(_sfc_main$x, {
5182
- key: 0,
5183
- labelWidth: "0",
5184
- disabled: __props.disabled,
5185
- prop: getProp(scope.$index),
5186
- rules: column.rules,
5187
- config: makeConfig(column, scope.row),
5188
- model: scope.row,
5189
- lastValues: lastData.value[scope.$index],
5190
- "is-compare": __props.isCompare,
5191
- size: __props.size,
5192
- onChange: changeHandler,
5193
- onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
5194
- }, null, 8, ["disabled", "prop", "rules", "config", "model", "lastValues", "is-compare", "size"])) : vue.createCommentVNode("v-if", true)
5195
- ]),
5196
- _: 2
5197
- /* DYNAMIC */
5198
- }, 1032, ["prop", "width", "label", "sortable", "class-name"])) : vue.createCommentVNode("v-if", true)
5199
- ],
5200
- 64
5201
- /* STABLE_FRAGMENT */
5202
- );
5203
- }),
5204
- 256
5205
- /* UNKEYED_FRAGMENT */
5206
- ))
5207
- ]),
5208
- _: 3
5209
- /* FORWARDED */
5210
- }, 8, ["row-key", "data", "lastData", "border", "max-height"])) : vue.createCommentVNode("v-if", true)
5211
- ]),
5212
- _: 3
5213
- /* FORWARDED */
5214
- }, 8, ["disabled"]),
5215
- vue.renderSlot(_ctx.$slots, "default"),
5216
- vue.createElementVNode("div", _hoisted_4, [
5217
- addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5218
- key: 0,
5219
- size: "small",
5220
- type: "primary",
5221
- disabled: __props.disabled,
5222
- plain: "",
5223
- onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
5224
- }, {
5225
- default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
5226
- vue.createTextVNode(
5227
- "新增一行",
5228
- -1
5229
- /* CACHED */
5230
- )
5231
- ])]),
5232
- _: 1
5233
- /* STABLE */
5234
- }, 8, ["disabled"])) : vue.createCommentVNode("v-if", true),
5235
- vue.createElementVNode("div", _hoisted_5, [
5236
- __props.enableToggleMode && __props.config.enableToggleMode !== false && !isFullscreen.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5237
- key: 0,
5238
- icon: vue.unref(iconsVue.Grid),
5239
- size: "small",
5240
- type: "primary",
5241
- onClick: toggleMode
5242
- }, {
5243
- default: vue.withCtx(() => [..._cache[4] || (_cache[4] = [
5244
- vue.createTextVNode(
5245
- "展开配置",
5246
- -1
5247
- /* CACHED */
5248
- )
5249
- ])]),
5250
- _: 1
5251
- /* STABLE */
5252
- }, 8, ["icon"])) : vue.createCommentVNode("v-if", true),
5253
- __props.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5254
- key: 1,
5255
- icon: vue.unref(iconsVue.FullScreen),
5256
- size: "small",
5257
- type: "primary",
5258
- onClick: toggleFullscreen
5259
- }, {
5260
- default: vue.withCtx(() => [
5261
- vue.createTextVNode(
5262
- vue.toDisplayString(isFullscreen.value ? "退出全屏" : "全屏编辑"),
5263
- 1
5264
- /* TEXT */
5265
- )
5266
- ]),
5267
- _: 1
5268
- /* STABLE */
5269
- }, 8, ["icon"])) : vue.createCommentVNode("v-if", true),
5270
- importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicUpload), {
5271
- key: 2,
5272
- style: { "display": "inline-block" },
5273
- ref_key: "excelBtn",
5274
- ref: excelBtn,
5275
- action: "/noop",
5276
- disabled: __props.disabled,
5277
- "on-change": excelHandler,
5278
- "auto-upload": false
5279
- }, {
5280
- default: vue.withCtx(() => [
5281
- vue.createVNode(vue.unref(design.TMagicButton), {
5282
- size: "small",
5283
- type: "success",
5284
- disabled: __props.disabled,
5285
- plain: ""
5286
- }, {
5287
- default: vue.withCtx(() => [..._cache[5] || (_cache[5] = [
5288
- vue.createTextVNode(
5289
- "导入EXCEL",
5290
- -1
5291
- /* CACHED */
5292
- )
5293
- ])]),
5294
- _: 1
5295
- /* STABLE */
5296
- }, 8, ["disabled"])
5297
- ]),
5298
- _: 1
5299
- /* STABLE */
5300
- }, 8, ["disabled"])) : vue.createCommentVNode("v-if", true),
5301
- importable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5302
- key: 3,
5303
- size: "small",
5304
- type: "warning",
5305
- disabled: __props.disabled,
5306
- plain: "",
5307
- onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
5308
- }, {
5309
- default: vue.withCtx(() => [..._cache[6] || (_cache[6] = [
5310
- vue.createTextVNode(
5311
- "清空",
5312
- -1
5313
- /* CACHED */
5314
- )
5315
- ])]),
5316
- _: 1
5317
- /* STABLE */
5318
- }, 8, ["disabled"])) : vue.createCommentVNode("v-if", true)
5319
- ])
5320
- ]),
5321
- __props.config.pagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, [
5322
- vue.createVNode(vue.unref(design.TMagicPagination), {
5323
- layout: "total, sizes, prev, pager, next, jumper",
5324
- "hide-on-single-page": __props.model[modelName.value].length < pagesize.value,
5325
- "current-page": pagecontext.value + 1,
5326
- "page-sizes": [pagesize.value, 60, 120, 300],
5327
- "page-size": pagesize.value,
5328
- total: __props.model[modelName.value].length,
5329
- onSizeChange: handleSizeChange,
5330
- onCurrentChange: handleCurrentChange
5331
- }, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total"])
5332
- ])) : vue.createCommentVNode("v-if", true)
5333
- ],
5334
- 2
5335
- /* CLASS */
5336
- )
5337
- ], 8, ["disabled"]))
5338
- ]);
5339
- };
5340
- }
5341
- });
5342
-
5343
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
5344
- ...{
5345
- name: "MFormTabs"
5346
- },
5347
- __name: "Tabs",
5348
- props: {
5349
- model: {},
5350
- lastValues: { default: () => ({}) },
5351
- isCompare: { type: Boolean, default: false },
5352
- config: {},
5353
- name: {},
5354
- size: {},
5355
- labelWidth: {},
5356
- prop: {},
5357
- expandMore: { type: Boolean },
5358
- disabled: { type: Boolean }
5359
- },
5360
- emits: ["change", "addDiffCount"],
5361
- setup(__props, { emit: __emit }) {
5362
- const tabPaneComponent = design.getDesignConfig("components")?.tabPane;
5363
- const tabsComponent = design.getDesignConfig("components")?.tabs;
5364
- const getActive = (mForm2, props2, activeTabName2) => {
5365
- const { config, model, prop } = props2;
5366
- const { active } = config;
5367
- if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
5368
- if (0 >= props2.config.items.length) return "0";
5369
- if (typeof active !== "undefined") return active;
5370
- return "0";
5371
- };
5372
- const tabClick = (mForm2, tab, props2) => {
5373
- const { config, model, prop } = props2;
5374
- tab.name = tab.paneName;
5375
- if (typeof config.onTabClick === "function") {
5376
- config.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
5377
- }
5378
- const tabConfig = config.items.find((item) => tab.name === item.status);
5379
- if (tabConfig && typeof tabConfig.onTabClick === "function") {
5380
- tabConfig.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
5381
- }
5382
- };
5383
- const props = __props;
5384
- const emit = __emit;
5385
- const mForm = vue.inject("mForm");
5386
- const activeTabName = vue.ref(getActive(mForm, props));
5387
- const diffCount = vue.ref({});
5388
- const tabs = vue.computed(() => {
5389
- if (props.config.dynamic) {
5390
- if (!props.config.name) throw new Error("dynamic tab 必须配置name");
5391
- return props.model[props.config.name] || [];
5392
- }
5393
- return props.config.items.filter((item) => display(mForm, item.display, props));
5394
- });
5395
- const filter = (config) => filterFunction(mForm, config, props);
5396
- vue.watchEffect(() => {
5397
- if (typeof props.config.activeChange === "function") {
5398
- props.config.activeChange(mForm, activeTabName.value, {
5399
- model: props.model,
5400
- prop: props.prop
5401
- });
5402
- }
5403
- });
5404
- const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
5405
- const tabClickHandler = (tab) => tabClick(mForm, tab, props);
5406
- const onTabAdd = async () => {
5407
- if (!props.name) throw new Error("dynamic tab 必须配置name");
5408
- if (typeof props.config.onTabAdd === "function") {
5409
- props.config.onTabAdd(mForm, {
5410
- model: props.model,
5411
- prop: props.prop,
5412
- config: props.config
5413
- });
5414
- emit("change", props.model);
5415
- } else {
5416
- const newObj = await initValue(mForm, {
5417
- config: props.config.items,
5418
- initValues: {}
5419
- });
5420
- newObj.title = `标签${tabs.value.length + 1}`;
5421
- props.model[props.name].push(newObj);
5422
- emit("change", props.model[props.name], {
5423
- changeRecords: [
5424
- {
5425
- propPath: `${props.prop}.${props.model[props.name].length - 1}`,
5426
- value: newObj
5427
- }
5428
- ]
5429
- });
5430
- }
5431
- mForm?.$emit("field-change", props.prop, props.model[props.name]);
5432
- };
5433
- const onTabRemove = (tabName) => {
5434
- if (!props.name) throw new Error("dynamic tab 必须配置name");
5435
- if (typeof props.config.onTabRemove === "function") {
5436
- props.config.onTabRemove(mForm, tabName, {
5437
- model: props.model,
5438
- prop: props.prop,
5439
- config: props.config
5440
- });
5441
- } else {
5442
- props.model[props.name].splice(+tabName, 1);
5443
- if (tabName < activeTabName.value || activeTabName.value >= props.model[props.name].length) {
5444
- activeTabName.value = (+activeTabName.value - 1).toString();
5445
- tabClick(mForm, { name: activeTabName.value }, props);
5446
- }
5447
- }
5448
- emit("change", props.model);
5449
- mForm?.$emit("field-change", props.prop, props.model[props.name]);
5450
- };
5451
- const changeHandler = (v, eventData) => {
5452
- emit("change", props.model, eventData);
5453
- };
5454
- const onAddDiffCount = (tabIndex) => {
5455
- if (!diffCount.value[tabIndex]) {
5456
- diffCount.value[tabIndex] = 1;
5457
- } else {
5458
- diffCount.value[tabIndex] += 1;
5459
- }
5460
- emit("addDiffCount");
5461
- };
5462
- return (_ctx, _cache) => {
5463
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tabsComponent)?.component || "el-tabs"), vue.mergeProps(
5464
- {
5465
- modelValue: activeTabName.value,
5466
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event)
5467
- },
5468
- vue.unref(tabsComponent)?.props({
5469
- type: __props.config.tabType,
5470
- editable: __props.config.editable || false,
5471
- tabPosition: __props.config.tabPosition || "top"
5472
- }) || {},
5473
- {
5474
- class: `tmagic-design-tabs ${__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"}`,
5475
- onTabClick: tabClickHandler,
5476
- onTabAdd,
5477
- onTabRemove
5478
- }
5479
- ), {
5480
- default: vue.withCtx(() => [
5481
- (vue.openBlock(true), vue.createElementBlock(
5482
- vue.Fragment,
5483
- null,
5484
- vue.renderList(tabs.value, (tab, tabIndex) => {
5485
- return vue.openBlock(), vue.createBlock(
5486
- vue.resolveDynamicComponent(vue.unref(tabPaneComponent)?.component || "el-tab-pane"),
5487
- vue.mergeProps(
5488
- {
5489
- key: tab[vue.unref(mForm)?.keyProp || "__key"] ?? tabIndex
5490
- },
5491
- { ref_for: true },
5492
- vue.unref(tabPaneComponent)?.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false }) || {}
5493
- ),
5494
- {
5495
- label: vue.withCtx(() => [
5496
- vue.createElementVNode("span", null, [
5497
- vue.createTextVNode(
5498
- vue.toDisplayString(filter(tab.title)),
5499
- 1
5500
- /* TEXT */
5501
- ),
5502
- vue.createVNode(vue.unref(design.TMagicBadge), {
5503
- hidden: !diffCount.value[tabIndex],
5504
- value: diffCount.value[tabIndex],
5505
- class: "diff-count-badge"
5506
- }, null, 8, ["hidden", "value"])
5507
- ])
5508
- ]),
5509
- default: vue.withCtx(() => [
5510
- (vue.openBlock(true), vue.createElementBlock(
5511
- vue.Fragment,
5512
- null,
5513
- vue.renderList(tabItems(tab), (item) => {
5514
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
5515
- key: item[vue.unref(mForm)?.keyProp || "__key"],
5516
- config: item,
5517
- disabled: __props.disabled,
5518
- 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,
5519
- "last-values": vue.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,
5520
- "is-compare": __props.isCompare,
5521
- prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
5522
- size: __props.size,
5523
- "label-width": tab.labelWidth || __props.labelWidth,
5524
- "expand-more": __props.expandMore,
5525
- onChange: changeHandler,
5526
- onAddDiffCount: ($event) => onAddDiffCount(tabIndex)
5527
- }, null, 8, ["config", "disabled", "model", "last-values", "is-compare", "prop", "size", "label-width", "expand-more", "onAddDiffCount"]);
5528
- }),
5529
- 128
5530
- /* KEYED_FRAGMENT */
5531
- ))
5532
- ]),
5533
- _: 2
5534
- /* DYNAMIC */
5535
- },
5536
- 1040
5537
- /* FULL_PROPS, DYNAMIC_SLOTS */
5538
- );
5539
- }),
5540
- 128
5541
- /* KEYED_FRAGMENT */
5542
- ))
5543
- ]),
5544
- _: 1
5545
- /* STABLE */
5546
- }, 16, ["modelValue", "class"]);
5547
- };
5548
- }
5549
- });
5550
-
5551
- let $MAGIC_FORM = {};
5552
- const setConfig = (option) => {
5553
- $MAGIC_FORM = option;
5554
- };
5555
- const getConfig = (key) => $MAGIC_FORM[key];
5556
-
5557
- const useAddField = (prop) => {
5558
- if (!prop) return;
5559
- const mForm = vue.inject("mForm");
5560
- const instance = vue.getCurrentInstance();
5561
- vue.watch(
5562
- () => instance?.proxy,
5563
- (vm) => {
5564
- if (vm) {
5565
- mForm?.setField(prop, vm);
5566
- } else {
5567
- mForm?.deleteField(prop);
5568
- }
5569
- },
5570
- {
5571
- immediate: true
5572
- }
5573
- );
5574
- };
5575
-
5576
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
5577
- ...{
5578
- name: "MFormCascader"
5579
- },
5580
- __name: "Cascader",
5581
- props: {
5582
- config: {},
5583
- model: {},
5584
- initValues: {},
5585
- values: {},
5586
- name: {},
5587
- prop: {},
5588
- disabled: { type: Boolean },
5589
- size: {},
5590
- lastValues: {}
5591
- },
5592
- emits: ["change"],
5593
- setup(__props, { emit: __emit }) {
5594
- const props = __props;
5595
- const emit = __emit;
5596
- const mForm = vue.inject("mForm");
5597
- useAddField(props.prop);
5598
- const requestFunc = getConfig("request");
5599
- const tMagicCascader = vue.ref();
5600
- const options = vue.ref([]);
5601
- const remoteData = vue.ref(null);
5602
- const checkStrictly = vue.computed(() => filterFunction(mForm, props.config.checkStrictly, props));
5603
- const valueSeparator = vue.computed(() => filterFunction(mForm, props.config.valueSeparator, props));
5604
- const value = vue.computed({
5605
- get() {
5606
- if (typeof props.model[props.name] === "string" && valueSeparator.value) {
5607
- return props.model[props.name].split(valueSeparator.value);
5608
- }
5609
- return props.model[props.name];
5610
- },
5611
- set(value2) {
5612
- let result = value2;
5613
- if (valueSeparator.value) {
5614
- result = value2.join(valueSeparator.value);
5615
- }
5616
- props.model[props.name] = result;
5617
- }
5618
- });
5619
- const setRemoteOptions = async function() {
5620
- const { config } = props;
5621
- const { option } = config;
5622
- if (!option) return;
5623
- let { body } = option;
5624
- const postOptions = {
5625
- url: option.url,
5626
- cache: option.cache,
5627
- timeout: option.timeout,
5628
- data: {}
5629
- };
5630
- if (body && mForm) {
5631
- if (typeof body === "function" && props.model && mForm) {
5632
- body = body(mForm, {
5633
- model: props.model,
5634
- formValue: mForm.values,
5635
- formValues: mForm.values,
5636
- config: props.config
5637
- });
5638
- }
5639
- postOptions.data = body;
5640
- }
5641
- const res = await requestFunc(postOptions);
5642
- remoteData.value = res[option.root];
5643
- if (remoteData.value && typeof option?.item === "function") {
5644
- options.value = option.item(res[option.root]);
5016
+ const res = await requestFunc(postOptions);
5017
+ remoteData.value = res[option.root];
5018
+ if (remoteData.value && typeof option?.item === "function") {
5019
+ options.value = option.item(res[option.root]);
5645
5020
  }
5646
5021
  };
5647
5022
  if (typeof props.config.options === "function" && props.model && mForm) {
@@ -5667,12 +5042,10 @@
5667
5042
  if (!tMagicCascader.value) return;
5668
5043
  tMagicCascader.value.setQuery("");
5669
5044
  tMagicCascader.value.setPreviousQuery(null);
5670
- emit("change", props.model[props.name]);
5671
5045
  };
5672
5046
  return (_ctx, _cache) => {
5673
5047
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCascader), {
5674
- modelValue: value.value,
5675
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
5048
+ "model-value": value.value,
5676
5049
  ref_key: "tMagicCascader",
5677
5050
  ref: tMagicCascader,
5678
5051
  style: { "width": "100%" },
@@ -5688,13 +5061,14 @@
5688
5061
  emitPath: __props.config.emitPath ?? true,
5689
5062
  checkStrictly: checkStrictly.value ?? false
5690
5063
  },
5064
+ "onUpdate:modelValue": updateModelValueHandler,
5691
5065
  onChange: changeHandler
5692
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
5066
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
5693
5067
  };
5694
5068
  }
5695
5069
  });
5696
5070
 
5697
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
5071
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
5698
5072
  ...{
5699
5073
  name: "MFormCheckbox"
5700
5074
  },
@@ -5740,29 +5114,33 @@
5740
5114
  };
5741
5115
  return (_ctx, _cache) => {
5742
5116
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCheckbox), {
5743
- modelValue: __props.model[__props.name],
5744
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
5117
+ "model-value": __props.model[__props.name],
5745
5118
  size: __props.size,
5746
5119
  trueValue: activeValue.value,
5747
5120
  falseValue: inactiveValue.value,
5748
5121
  disabled: __props.disabled,
5749
- onChange: changeHandler
5750
- }, {
5751
- default: vue.withCtx(() => [
5752
- vue.createTextVNode(
5753
- vue.toDisplayString(__props.config.text),
5754
- 1
5755
- /* TEXT */
5756
- )
5757
- ]),
5758
- _: 1
5759
- /* STABLE */
5760
- }, 8, ["modelValue", "size", "trueValue", "falseValue", "disabled"]);
5122
+ "onUpdate:modelValue": changeHandler
5123
+ }, vue.createSlots({
5124
+ _: 2
5125
+ /* DYNAMIC */
5126
+ }, [
5127
+ !__props.config.useLabel ? {
5128
+ name: "default",
5129
+ fn: vue.withCtx(() => [
5130
+ vue.createTextVNode(
5131
+ vue.toDisplayString(__props.config.text),
5132
+ 1
5133
+ /* TEXT */
5134
+ )
5135
+ ]),
5136
+ key: "0"
5137
+ } : void 0
5138
+ ]), 1032, ["model-value", "size", "trueValue", "falseValue", "disabled"]);
5761
5139
  };
5762
5140
  }
5763
5141
  });
5764
5142
 
5765
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
5143
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
5766
5144
  ...{
5767
5145
  name: "MFormCheckGroup"
5768
5146
  },
@@ -5798,11 +5176,10 @@
5798
5176
  });
5799
5177
  return (_ctx, _cache) => {
5800
5178
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCheckboxGroup), {
5801
- modelValue: __props.model[__props.name],
5802
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
5179
+ "model-value": __props.model[__props.name],
5803
5180
  size: __props.size,
5804
5181
  disabled: __props.disabled,
5805
- onChange: changeHandler
5182
+ "onUpdate:modelValue": changeHandler
5806
5183
  }, {
5807
5184
  default: vue.withCtx(() => [
5808
5185
  (vue.openBlock(true), vue.createElementBlock(
@@ -5831,12 +5208,12 @@
5831
5208
  ]),
5832
5209
  _: 1
5833
5210
  /* STABLE */
5834
- }, 8, ["modelValue", "size", "disabled"]);
5211
+ }, 8, ["model-value", "size", "disabled"]);
5835
5212
  };
5836
5213
  }
5837
5214
  });
5838
5215
 
5839
- const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
5216
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
5840
5217
  ...{
5841
5218
  name: "MFormColorPicker"
5842
5219
  },
@@ -5860,18 +5237,17 @@
5860
5237
  const changeHandler = (value) => emit("change", value);
5861
5238
  return (_ctx, _cache) => {
5862
5239
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicColorPicker), {
5863
- modelValue: __props.model[__props.name],
5864
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
5240
+ "model-value": __props.model[__props.name],
5865
5241
  size: __props.size,
5866
5242
  disabled: __props.disabled,
5867
5243
  showAlpha: true,
5868
- onChange: changeHandler
5869
- }, null, 8, ["modelValue", "size", "disabled"]);
5244
+ "onUpdate:modelValue": changeHandler
5245
+ }, null, 8, ["model-value", "size", "disabled"]);
5870
5246
  };
5871
5247
  }
5872
5248
  });
5873
5249
 
5874
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
5250
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
5875
5251
  ...{
5876
5252
  name: "MFormDate"
5877
5253
  },
@@ -5898,21 +5274,20 @@
5898
5274
  };
5899
5275
  return (_ctx, _cache) => {
5900
5276
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
5901
- modelValue: __props.model[__props.name],
5902
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
5277
+ "model-value": __props.model[__props.name],
5903
5278
  type: "date",
5904
5279
  size: __props.size,
5905
5280
  placeholder: __props.config.placeholder,
5906
5281
  disabled: __props.disabled,
5907
5282
  format: __props.config.format || "YYYY/MM/DD",
5908
5283
  "value-format": __props.config.valueFormat || "YYYY/MM/DD",
5909
- onChange: changeHandler
5910
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
5284
+ "onUpdate:modelValue": changeHandler
5285
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "format", "value-format"]);
5911
5286
  };
5912
5287
  }
5913
5288
  });
5914
5289
 
5915
- const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
5290
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
5916
5291
  ...{
5917
5292
  name: "MFormDateRange"
5918
5293
  },
@@ -5993,8 +5368,7 @@
5993
5368
  };
5994
5369
  return (_ctx, _cache) => {
5995
5370
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
5996
- modelValue: value.value,
5997
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
5371
+ "model-value": value.value,
5998
5372
  type: "datetimerange",
5999
5373
  "range-separator": "-",
6000
5374
  "start-placeholder": "开始日期",
@@ -6006,13 +5380,13 @@
6006
5380
  "value-format": __props.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
6007
5381
  "date-format": __props.config.dateFormat || "YYYY/MM/DD",
6008
5382
  "time-format": __props.config.timeFormat || "HH:mm:ss",
6009
- onChange: changeHandler
6010
- }, null, 8, ["modelValue", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
5383
+ "onUpdate:modelValue": changeHandler
5384
+ }, null, 8, ["model-value", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
6011
5385
  };
6012
5386
  }
6013
5387
  });
6014
5388
 
6015
- const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
5389
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
6016
5390
  ...{
6017
5391
  name: "MFormDateTime"
6018
5392
  },
@@ -6050,8 +5424,7 @@
6050
5424
  };
6051
5425
  return (_ctx, _cache) => {
6052
5426
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
6053
- modelValue: __props.model[__props.name],
6054
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
5427
+ "model-value": __props.model[__props.name],
6055
5428
  "popper-class": "magic-datetime-picker-popper",
6056
5429
  type: "datetime",
6057
5430
  size: __props.size,
@@ -6060,14 +5433,14 @@
6060
5433
  format: __props.config.format || "YYYY/MM/DD HH:mm:ss",
6061
5434
  "value-format": __props.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
6062
5435
  "default-time": __props.config.defaultTime,
6063
- onChange: changeHandler
6064
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time"]);
5436
+ "onUpdate:modelValue": changeHandler
5437
+ }, null, 8, ["model-value", "size", "placeholder", "disabled", "format", "value-format", "default-time"]);
6065
5438
  };
6066
5439
  }
6067
5440
  });
6068
5441
 
6069
5442
  const _hoisted_1$8 = { key: 0 };
6070
- const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
5443
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
6071
5444
  ...{
6072
5445
  name: "MFormDisplay"
6073
5446
  },
@@ -6102,7 +5475,7 @@
6102
5475
  });
6103
5476
 
6104
5477
  const _hoisted_1$7 = { class: "m-fields-dynamic-field" };
6105
- const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
5478
+ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
6106
5479
  ...{
6107
5480
  name: "MFormDynamicField"
6108
5481
  },
@@ -6203,7 +5576,7 @@
6203
5576
  }
6204
5577
  });
6205
5578
 
6206
- const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
5579
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
6207
5580
  ...{
6208
5581
  name: "MFormHidden"
6209
5582
  },
@@ -6240,7 +5613,7 @@
6240
5613
  }
6241
5614
  });
6242
5615
 
6243
- const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
5616
+ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
6244
5617
  ...{
6245
5618
  name: "MForm"
6246
5619
  },
@@ -6267,7 +5640,7 @@
6267
5640
  setup(__props, { expose: __expose, emit: __emit }) {
6268
5641
  const props = __props;
6269
5642
  const emit = __emit;
6270
- const tMagicForm = vue.ref();
5643
+ const tMagicFormRef = vue.useTemplateRef("tMagicForm");
6271
5644
  const initialized = vue.ref(false);
6272
5645
  const values = vue.ref({});
6273
5646
  const lastValuesProcessed = vue.ref({});
@@ -6344,7 +5717,17 @@
6344
5717
  );
6345
5718
  const changeHandler = (v, eventData) => {
6346
5719
  if (eventData.changeRecords?.length) {
6347
- changeRecords.value.push(...eventData.changeRecords);
5720
+ for (const record of eventData.changeRecords) {
5721
+ if (record.propPath) {
5722
+ const index = changeRecords.value.findIndex((item) => item.propPath === record.propPath);
5723
+ if (index > -1) {
5724
+ changeRecords.value[index] = record;
5725
+ } else {
5726
+ changeRecords.value.push(record);
5727
+ }
5728
+ utils.setValueByKeyPath(record.propPath, record.value, values.value);
5729
+ }
5730
+ }
6348
5731
  }
6349
5732
  emit("change", values.value, eventData);
6350
5733
  };
@@ -6361,12 +5744,13 @@
6361
5744
  changeRecords,
6362
5745
  changeHandler,
6363
5746
  resetForm: () => {
6364
- tMagicForm.value?.resetFields();
5747
+ tMagicFormRef.value?.resetFields();
6365
5748
  changeRecords.value = [];
6366
5749
  },
6367
5750
  submitForm: async (native) => {
6368
5751
  try {
6369
- await tMagicForm.value?.validate();
5752
+ await tMagicFormRef.value?.validate();
5753
+ changeRecords.value = [];
6370
5754
  return native ? values.value : cloneDeep(vue.toRaw(values.value));
6371
5755
  } catch (invalidFields) {
6372
5756
  emit("error", invalidFields);
@@ -6385,8 +5769,7 @@
6385
5769
  return (_ctx, _cache) => {
6386
5770
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicForm), {
6387
5771
  class: "m-form",
6388
- ref_key: "tMagicForm",
6389
- ref: tMagicForm,
5772
+ ref: "tMagicForm",
6390
5773
  model: values.value,
6391
5774
  "label-width": __props.labelWidth,
6392
5775
  style: vue.normalizeStyle(`height: ${__props.height}`),
@@ -6399,7 +5782,7 @@
6399
5782
  vue.Fragment,
6400
5783
  { key: 0 },
6401
5784
  vue.renderList(__props.config, (item, index) => {
6402
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
5785
+ return vue.openBlock(), vue.createBlock(_sfc_main$A, {
6403
5786
  disabled: __props.disabled,
6404
5787
  key: item[__props.keyProp] ?? index,
6405
5788
  config: item,
@@ -6424,7 +5807,7 @@
6424
5807
  });
6425
5808
 
6426
5809
  const _hoisted_1$6 = { style: { "min-height": "1px" } };
6427
- const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
5810
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
6428
5811
  ...{
6429
5812
  name: "MFormDialog"
6430
5813
  },
@@ -6625,7 +6008,7 @@
6625
6008
  style: vue.normalizeStyle(`max-height: ${bodyHeight.value}; overflow-y: auto; overflow-x: hidden;`)
6626
6009
  },
6627
6010
  [
6628
- vue.createVNode(_sfc_main$d, {
6011
+ vue.createVNode(_sfc_main$g, {
6629
6012
  modelValue: stepActive.value,
6630
6013
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => stepActive.value = $event),
6631
6014
  ref_key: "form",
@@ -6655,11 +6038,11 @@
6655
6038
  });
6656
6039
 
6657
6040
  const _hoisted_1$5 = ["href"];
6658
- const _hoisted_2$1 = {
6041
+ const _hoisted_2$2 = {
6659
6042
  key: 2,
6660
6043
  class: "m-fields-link"
6661
6044
  };
6662
- const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
6045
+ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
6663
6046
  ...{
6664
6047
  name: "MFormLink"
6665
6048
  },
@@ -6737,7 +6120,7 @@
6737
6120
  vue.toDisplayString(displayText.value),
6738
6121
  5
6739
6122
  /* TEXT, STYLE */
6740
- )) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$1, [
6123
+ )) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$2, [
6741
6124
  vue.createVNode(vue.unref(design.TMagicButton), {
6742
6125
  link: "",
6743
6126
  type: "primary",
@@ -6753,7 +6136,7 @@
6753
6136
  _: 1
6754
6137
  /* STABLE */
6755
6138
  }),
6756
- vue.createVNode(_sfc_main$c, {
6139
+ vue.createVNode(_sfc_main$f, {
6757
6140
  ref_key: "editor",
6758
6141
  ref: editor,
6759
6142
  title: __props.config.formTitle || "编辑扩展配置",
@@ -6769,7 +6152,7 @@
6769
6152
  }
6770
6153
  });
6771
6154
 
6772
- const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
6155
+ const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
6773
6156
  ...{
6774
6157
  name: "MFormNumber"
6775
6158
  },
@@ -6801,8 +6184,7 @@
6801
6184
  return (_ctx, _cache) => {
6802
6185
  return __props.model ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInputNumber), {
6803
6186
  key: 0,
6804
- modelValue: __props.model[__props.name],
6805
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
6187
+ "model-value": __props.model[__props.name],
6806
6188
  clearable: "",
6807
6189
  "controls-position": "right",
6808
6190
  size: __props.size,
@@ -6811,15 +6193,15 @@
6811
6193
  step: __props.config.step,
6812
6194
  placeholder: __props.config.placeholder,
6813
6195
  disabled: __props.disabled,
6814
- onChange: changeHandler,
6196
+ "onUpdate:modelValue": changeHandler,
6815
6197
  onInput: inputHandler
6816
- }, null, 8, ["modelValue", "size", "max", "min", "step", "placeholder", "disabled"])) : vue.createCommentVNode("v-if", true);
6198
+ }, null, 8, ["model-value", "size", "max", "min", "step", "placeholder", "disabled"])) : vue.createCommentVNode("v-if", true);
6817
6199
  };
6818
6200
  }
6819
6201
  });
6820
6202
 
6821
6203
  const _hoisted_1$4 = { class: "m-fields-number-range" };
6822
- const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
6204
+ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
6823
6205
  ...{
6824
6206
  name: "MFormNumberRange"
6825
6207
  },
@@ -6852,14 +6234,13 @@
6852
6234
  return (_ctx, _cache) => {
6853
6235
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
6854
6236
  vue.createVNode(vue.unref(design.TMagicInput), {
6855
- modelValue: __props.model[__props.name][0],
6856
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name][0] = $event),
6857
- clearable: "",
6237
+ "model-value": __props.model[__props.name][0],
6238
+ clearable: __props.config.clearable ?? true,
6858
6239
  size: __props.size,
6859
6240
  disabled: __props.disabled,
6860
- onChange: minChangeHandler
6861
- }, null, 8, ["modelValue", "size", "disabled"]),
6862
- _cache[2] || (_cache[2] = vue.createElementVNode(
6241
+ "onUpdate:modelValue": minChangeHandler
6242
+ }, null, 8, ["model-value", "clearable", "size", "disabled"]),
6243
+ _cache[0] || (_cache[0] = vue.createElementVNode(
6863
6244
  "span",
6864
6245
  { class: "split-tag" },
6865
6246
  "-",
@@ -6867,20 +6248,18 @@
6867
6248
  /* CACHED */
6868
6249
  )),
6869
6250
  vue.createVNode(vue.unref(design.TMagicInput), {
6870
- modelValue: __props.model[__props.name][1],
6871
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => __props.model[__props.name][1] = $event),
6872
- clearable: "",
6251
+ "model-value": __props.model[__props.name][1],
6252
+ clearable: __props.config.clearable ?? true,
6873
6253
  size: __props.size,
6874
6254
  disabled: __props.disabled,
6875
- onChange: maxChangeHandler
6876
- }, null, 8, ["modelValue", "size", "disabled"])
6255
+ "onUpdate:modelValue": maxChangeHandler
6256
+ }, null, 8, ["model-value", "clearable", "size", "disabled"])
6877
6257
  ]);
6878
6258
  };
6879
6259
  }
6880
6260
  });
6881
6261
 
6882
- const _hoisted_1$3 = { key: 1 };
6883
- const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
6262
+ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
6884
6263
  ...{
6885
6264
  name: "MFormRadioGroup"
6886
6265
  },
@@ -6901,12 +6280,8 @@
6901
6280
  const props = __props;
6902
6281
  const itemComponent = vue.computed(() => props.config.childType === "button" ? design.TMagicRadioButton : design.TMagicRadio);
6903
6282
  const emit = __emit;
6904
- const changeHandler = (value) => {
6905
- emit("change", value);
6906
- };
6907
6283
  const clickHandler = (item) => {
6908
- props.model[props.name] = props.model[props.name] === item ? "" : item;
6909
- changeHandler(props.model[props.name]);
6284
+ emit("change", props.model[props.name] === item ? "" : item);
6910
6285
  };
6911
6286
  useAddField(props.prop);
6912
6287
  const iconSize = vue.computed(() => {
@@ -6921,8 +6296,7 @@
6921
6296
  return (_ctx, _cache) => {
6922
6297
  return __props.model ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRadioGroup), {
6923
6298
  key: 0,
6924
- modelValue: __props.model[__props.name],
6925
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
6299
+ "model-value": __props.model[__props.name],
6926
6300
  size: __props.size,
6927
6301
  disabled: __props.disabled
6928
6302
  }, {
@@ -6934,11 +6308,11 @@
6934
6308
  return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(itemComponent.value), {
6935
6309
  value: option.value,
6936
6310
  key: `${option.value}`,
6937
- onClick: vue.withModifiers(($event) => clickHandler(option.value), ["prevent"])
6311
+ onClick: ($event) => clickHandler(option.value)
6938
6312
  }, {
6939
6313
  default: vue.withCtx(() => [
6940
- option.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
6941
- key: 0,
6314
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
6315
+ disabled: !Boolean(option.tooltip),
6942
6316
  placement: "top-start",
6943
6317
  content: option.tooltip
6944
6318
  }, {
@@ -6965,25 +6339,7 @@
6965
6339
  ]),
6966
6340
  _: 2
6967
6341
  /* DYNAMIC */
6968
- }, 1032, ["content"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
6969
- option.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
6970
- key: 0,
6971
- size: iconSize.value
6972
- }, {
6973
- default: vue.withCtx(() => [
6974
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(option.icon)))
6975
- ]),
6976
- _: 2
6977
- /* DYNAMIC */
6978
- }, 1032, ["size"])) : vue.createCommentVNode("v-if", true),
6979
- vue.createElementVNode(
6980
- "span",
6981
- null,
6982
- vue.toDisplayString(option.text),
6983
- 1
6984
- /* TEXT */
6985
- )
6986
- ]))
6342
+ }, 1032, ["disabled", "content"])
6987
6343
  ]),
6988
6344
  _: 2
6989
6345
  /* DYNAMIC */
@@ -6995,13 +6351,13 @@
6995
6351
  ]),
6996
6352
  _: 1
6997
6353
  /* STABLE */
6998
- }, 8, ["modelValue", "size", "disabled"])) : vue.createCommentVNode("v-if", true);
6354
+ }, 8, ["model-value", "size", "disabled"])) : vue.createCommentVNode("v-if", true);
6999
6355
  };
7000
6356
  }
7001
6357
  });
7002
6358
 
7003
- const _hoisted_1$2 = { key: 2 };
7004
- const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
6359
+ const _hoisted_1$3 = { key: 2 };
6360
+ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
7005
6361
  ...{
7006
6362
  name: "MFormSelect"
7007
6363
  },
@@ -7328,8 +6684,7 @@
7328
6684
  const _directive_loading = vue.resolveDirective("loading");
7329
6685
  return __props.model ? vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicSelect), {
7330
6686
  key: 0,
7331
- modelValue: __props.model[__props.name],
7332
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
6687
+ "model-value": __props.model[__props.name],
7333
6688
  class: "m-select",
7334
6689
  ref_key: "tMagicSelect",
7335
6690
  ref: tMagicSelect,
@@ -7344,7 +6699,7 @@
7344
6699
  "allow-create": __props.config.allowCreate,
7345
6700
  disabled: __props.disabled,
7346
6701
  "remote-method": __props.config.remote && remoteMethod,
7347
- onChange: changeHandler,
6702
+ "onUpdate:modelValue": changeHandler,
7348
6703
  onVisibleChange: visibleHandler
7349
6704
  }, {
7350
6705
  default: vue.withCtx(() => [
@@ -7436,7 +6791,7 @@
7436
6791
  )),
7437
6792
  moreLoadingVisible.value ? vue.withDirectives((vue.openBlock(), vue.createElementBlock(
7438
6793
  "div",
7439
- _hoisted_1$2,
6794
+ _hoisted_1$3,
7440
6795
  null,
7441
6796
  512
7442
6797
  /* NEED_PATCH */
@@ -7446,14 +6801,14 @@
7446
6801
  ]),
7447
6802
  _: 1
7448
6803
  /* STABLE */
7449
- }, 8, ["modelValue", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
6804
+ }, 8, ["model-value", "clearable", "filterable", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
7450
6805
  [_directive_loading, loading.value]
7451
6806
  ]) : vue.createCommentVNode("v-if", true);
7452
6807
  };
7453
6808
  }
7454
6809
  });
7455
6810
 
7456
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
6811
+ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
7457
6812
  ...{
7458
6813
  name: "MFormSwitch"
7459
6814
  },
@@ -7499,21 +6854,21 @@
7499
6854
  });
7500
6855
  return (_ctx, _cache) => {
7501
6856
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicSwitch), {
7502
- modelValue: __props.model[__props.name],
7503
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
6857
+ "model-value": __props.model[__props.name],
7504
6858
  size: __props.size,
7505
6859
  activeValue: activeValue.value,
7506
6860
  inactiveValue: inactiveValue.value,
7507
6861
  disabled: __props.disabled,
7508
- onChange: changeHandler
7509
- }, null, 8, ["modelValue", "size", "activeValue", "inactiveValue", "disabled"]);
6862
+ "onUpdate:modelValue": changeHandler
6863
+ }, null, 8, ["model-value", "size", "activeValue", "inactiveValue", "disabled"]);
7510
6864
  };
7511
6865
  }
7512
6866
  });
7513
6867
 
7514
- const _hoisted_1$1 = { class: "m-fields-text" };
7515
- const _hoisted_2 = { style: { "display": "flex", "justify-content": "flex-end" } };
7516
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
6868
+ const _hoisted_1$2 = { class: "m-fields-text" };
6869
+ const _hoisted_2$1 = { key: 1 };
6870
+ const _hoisted_3$1 = { style: { "display": "flex", "justify-content": "flex-end" } };
6871
+ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
7517
6872
  ...{
7518
6873
  name: "MFormText"
7519
6874
  },
@@ -7538,16 +6893,25 @@
7538
6893
  const appendConfig = vue.computed(() => {
7539
6894
  if (typeof props.config.append === "string") {
7540
6895
  return {
6896
+ type: "text",
7541
6897
  text: props.config.append,
7542
- type: "button",
7543
6898
  handler: void 0
7544
6899
  };
7545
6900
  }
7546
- if (props.config.append && typeof props.config.append === "object") {
7547
- if (props.config.append.value === 0) {
7548
- return false;
6901
+ if (typeof props.config.append === "object") {
6902
+ if (typeof props.config.append?.handler === "function") {
6903
+ return {
6904
+ type: "button",
6905
+ text: props.config.append.text,
6906
+ handler: props.config.append.handler
6907
+ };
6908
+ }
6909
+ if (props.config.append) {
6910
+ if (props.config.append.value === 0) {
6911
+ return false;
6912
+ }
6913
+ return props.config.append;
7549
6914
  }
7550
- return props.config.append;
7551
6915
  }
7552
6916
  return false;
7553
6917
  });
@@ -7652,23 +7016,35 @@
7652
7016
  instanceRef.value = void 0;
7653
7017
  };
7654
7018
  return (_ctx, _cache) => {
7655
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
7019
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
7656
7020
  vue.createVNode(vue.unref(design.TMagicInput), {
7657
- modelValue: __props.model[__props.name],
7658
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
7021
+ "model-value": __props.model[__props.name],
7659
7022
  ref_key: "input",
7660
7023
  ref: input,
7661
7024
  clearable: "",
7662
7025
  size: __props.size,
7663
7026
  placeholder: __props.config.placeholder,
7664
7027
  disabled: __props.disabled,
7665
- onChange: changeHandler,
7028
+ "onUpdate:modelValue": changeHandler,
7666
7029
  onInput: inputHandler,
7667
- onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
7030
+ onKeyup: _cache[0] || (_cache[0] = ($event) => keyUpHandler($event))
7668
7031
  }, vue.createSlots({
7669
7032
  _: 2
7670
7033
  /* DYNAMIC */
7671
7034
  }, [
7035
+ __props.config.prepend ? {
7036
+ name: "prepend",
7037
+ fn: vue.withCtx(() => [
7038
+ vue.createElementVNode(
7039
+ "span",
7040
+ null,
7041
+ vue.toDisplayString(__props.config.prepend),
7042
+ 1
7043
+ /* TEXT */
7044
+ )
7045
+ ]),
7046
+ key: "0"
7047
+ } : void 0,
7672
7048
  appendConfig.value ? {
7673
7049
  name: "append",
7674
7050
  fn: vue.withCtx(() => [
@@ -7687,11 +7063,17 @@
7687
7063
  ]),
7688
7064
  _: 1
7689
7065
  /* STABLE */
7690
- }, 8, ["size"])) : vue.createCommentVNode("v-if", true)
7066
+ }, 8, ["size"])) : (vue.openBlock(), vue.createElementBlock(
7067
+ "span",
7068
+ _hoisted_2$1,
7069
+ vue.toDisplayString(appendConfig.value.text),
7070
+ 1
7071
+ /* TEXT */
7072
+ ))
7691
7073
  ]),
7692
- key: "0"
7074
+ key: "1"
7693
7075
  } : void 0
7694
- ]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
7076
+ ]), 1032, ["model-value", "size", "placeholder", "disabled"]),
7695
7077
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
7696
7078
  popoverVisible.value ? (vue.openBlock(), vue.createElementBlock(
7697
7079
  "div",
@@ -7702,20 +7084,20 @@
7702
7084
  ref: popoverEl
7703
7085
  },
7704
7086
  [
7705
- _cache[5] || (_cache[5] = vue.createElementVNode(
7087
+ _cache[4] || (_cache[4] = vue.createElementVNode(
7706
7088
  "div",
7707
7089
  { class: "m-form-validate__warning" },
7708
7090
  "输入内容前后有空格,是否移除空格?",
7709
7091
  -1
7710
7092
  /* CACHED */
7711
7093
  )),
7712
- vue.createElementVNode("div", _hoisted_2, [
7094
+ vue.createElementVNode("div", _hoisted_3$1, [
7713
7095
  vue.createVNode(vue.unref(design.TMagicButton), {
7714
7096
  link: "",
7715
7097
  size: "small",
7716
- onClick: _cache[2] || (_cache[2] = ($event) => popoverVisible.value = false)
7098
+ onClick: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
7717
7099
  }, {
7718
- default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
7100
+ default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
7719
7101
  vue.createTextVNode(
7720
7102
  "保持原样",
7721
7103
  -1
@@ -7730,7 +7112,7 @@
7730
7112
  size: "small",
7731
7113
  onClick: confirmTrimHandler
7732
7114
  }, {
7733
- default: vue.withCtx(() => [..._cache[4] || (_cache[4] = [
7115
+ default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
7734
7116
  vue.createTextVNode(
7735
7117
  "移除空格",
7736
7118
  -1
@@ -7741,7 +7123,7 @@
7741
7123
  /* STABLE */
7742
7124
  })
7743
7125
  ]),
7744
- _cache[6] || (_cache[6] = vue.createElementVNode(
7126
+ _cache[5] || (_cache[5] = vue.createElementVNode(
7745
7127
  "span",
7746
7128
  {
7747
7129
  class: "tmagic-form-text-popper-arrow",
@@ -7761,162 +7143,989 @@
7761
7143
  }
7762
7144
  });
7763
7145
 
7146
+ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
7147
+ ...{
7148
+ name: "MFormTextarea"
7149
+ },
7150
+ __name: "Textarea",
7151
+ props: {
7152
+ config: {},
7153
+ model: {},
7154
+ initValues: {},
7155
+ values: {},
7156
+ name: {},
7157
+ prop: {},
7158
+ disabled: { type: Boolean },
7159
+ size: {},
7160
+ lastValues: {}
7161
+ },
7162
+ emits: ["change", "input"],
7163
+ setup(__props, { emit: __emit }) {
7164
+ const props = __props;
7165
+ const emit = __emit;
7166
+ useAddField(props.prop);
7167
+ const mForm = vue.inject("mForm");
7168
+ const changeHandler = (value) => {
7169
+ emit("change", value);
7170
+ };
7171
+ const inputHandler = (v) => {
7172
+ emit("input", v);
7173
+ mForm?.$emit("field-input", props.prop, v);
7174
+ };
7175
+ return (_ctx, _cache) => {
7176
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
7177
+ "model-value": __props.model[__props.name],
7178
+ type: "textarea",
7179
+ size: __props.size,
7180
+ clearable: "",
7181
+ placeholder: __props.config.placeholder,
7182
+ disabled: __props.disabled,
7183
+ "onUpdate:modelValue": changeHandler,
7184
+ onInput: inputHandler
7185
+ }, null, 8, ["model-value", "size", "placeholder", "disabled"]);
7186
+ };
7187
+ }
7188
+ });
7189
+
7190
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7191
+ ...{
7192
+ name: "MFormTime"
7193
+ },
7194
+ __name: "Time",
7195
+ props: {
7196
+ config: {},
7197
+ model: {},
7198
+ initValues: {},
7199
+ values: {},
7200
+ name: {},
7201
+ prop: {},
7202
+ disabled: { type: Boolean },
7203
+ size: {},
7204
+ lastValues: {}
7205
+ },
7206
+ emits: ["change"],
7207
+ setup(__props, { emit: __emit }) {
7208
+ const props = __props;
7209
+ const emit = __emit;
7210
+ useAddField(props.prop);
7211
+ const changeHandler = (v) => {
7212
+ emit("change", v);
7213
+ };
7214
+ return (_ctx, _cache) => {
7215
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTimePicker), {
7216
+ "model-value": __props.model[__props.name],
7217
+ "value-format": __props.config.valueFormat || "HH:mm:ss",
7218
+ format: __props.config.format || "HH:mm:ss",
7219
+ size: __props.size,
7220
+ placeholder: __props.config.placeholder,
7221
+ disabled: __props.disabled,
7222
+ "onUpdate:modelValue": changeHandler
7223
+ }, null, 8, ["model-value", "value-format", "format", "size", "placeholder", "disabled"]);
7224
+ };
7225
+ }
7226
+ });
7227
+
7228
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
7229
+ ...{
7230
+ name: "MFormTimeRange"
7231
+ },
7232
+ __name: "Timerange",
7233
+ props: {
7234
+ config: {},
7235
+ model: {},
7236
+ initValues: {},
7237
+ values: {},
7238
+ name: {},
7239
+ prop: {},
7240
+ disabled: { type: Boolean },
7241
+ size: {},
7242
+ lastValues: {}
7243
+ },
7244
+ emits: ["change"],
7245
+ setup(__props, { emit: __emit }) {
7246
+ const props = __props;
7247
+ const emit = __emit;
7248
+ useAddField(props.prop);
7249
+ const { names } = props.config;
7250
+ const value = vue.ref([]);
7251
+ if (props.model !== void 0 && names?.length) {
7252
+ vue.watch(
7253
+ [() => props.model[names[0]], () => props.model[names[1]]],
7254
+ ([start, end], [preStart, preEnd]) => {
7255
+ if (!value.value) {
7256
+ value.value = [];
7257
+ }
7258
+ if (!start || !end) value.value = [];
7259
+ if (start !== preStart) value.value[0] = start;
7260
+ if (end !== preEnd) value.value[1] = end;
7261
+ },
7262
+ {
7263
+ immediate: true
7264
+ }
7265
+ );
7266
+ }
7267
+ const setValue = (v) => {
7268
+ names?.forEach((item, index) => {
7269
+ if (!props.model) {
7270
+ return;
7271
+ }
7272
+ if (Array.isArray(v)) {
7273
+ props.model[item] = v[index];
7274
+ } else {
7275
+ props.model[item] = void 0;
7276
+ }
7277
+ });
7278
+ };
7279
+ const changeHandler = (v) => {
7280
+ const value2 = v || [];
7281
+ if (names?.length) {
7282
+ setValue(value2);
7283
+ }
7284
+ emit("change", value2);
7285
+ };
7286
+ return (_ctx, _cache) => {
7287
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTimePicker), {
7288
+ "model-value": value.value,
7289
+ "is-range": "",
7290
+ "range-separator": "-",
7291
+ "start-placeholder": "开始时间",
7292
+ "end-placeholder": "结束时间",
7293
+ size: __props.size,
7294
+ "unlink-panels": true,
7295
+ disabled: __props.disabled,
7296
+ "default-time": __props.config.defaultTime,
7297
+ "onUpdate:modelValue": changeHandler
7298
+ }, null, 8, ["model-value", "size", "disabled", "default-time"]);
7299
+ };
7300
+ }
7301
+ });
7302
+
7303
+ const useAdd = (props, emit) => {
7304
+ const mForm = vue.inject("mForm");
7305
+ const addable = vue.computed(() => {
7306
+ const modelName = props.name || props.config.name || "";
7307
+ if (!props.model[modelName].length) {
7308
+ return true;
7309
+ }
7310
+ if (typeof props.config.addable === "function") {
7311
+ return props.config.addable(mForm, {
7312
+ model: props.model[modelName],
7313
+ formValue: mForm?.values,
7314
+ prop: props.prop
7315
+ });
7316
+ }
7317
+ return typeof props.config.addable === "undefined" ? true : props.config.addable;
7318
+ });
7319
+ const newHandler = async (row) => {
7320
+ const modelName = props.name || props.config.name || "";
7321
+ if (props.config.max && props.model[modelName].length >= props.config.max) {
7322
+ design.tMagicMessage.error(`最多新增配置不能超过${props.config.max}条`);
7323
+ return;
7324
+ }
7325
+ if (typeof props.config.beforeAddRow === "function") {
7326
+ const beforeCheckRes = props.config.beforeAddRow(mForm, {
7327
+ model: props.model[modelName],
7328
+ formValue: mForm?.values,
7329
+ prop: props.prop
7330
+ });
7331
+ if (!beforeCheckRes) return;
7332
+ }
7333
+ const columns = props.config.items;
7334
+ const enumValues = props.config.enum || [];
7335
+ let enumV = [];
7336
+ const { length } = props.model[modelName];
7337
+ const key = props.config.key || "id";
7338
+ let inputs = {};
7339
+ if (enumValues.length) {
7340
+ if (length >= enumValues.length) {
7341
+ return;
7342
+ }
7343
+ enumV = enumValues.filter((item) => {
7344
+ let i = 0;
7345
+ for (; i < length; i++) {
7346
+ if (item[key] === props.model[modelName][i][key]) {
7347
+ break;
7348
+ }
7349
+ }
7350
+ return i === length;
7351
+ });
7352
+ if (enumV.length > 0) {
7353
+ inputs = enumV[0];
7354
+ }
7355
+ } else if (Array.isArray(row)) {
7356
+ columns.forEach((column, index) => {
7357
+ column.name && (inputs[column.name] = row[index]);
7358
+ });
7359
+ } else {
7360
+ if (typeof props.config.defaultAdd === "function") {
7361
+ inputs = await props.config.defaultAdd(mForm, {
7362
+ model: props.model[modelName],
7363
+ formValue: mForm?.values
7364
+ });
7365
+ } else if (props.config.defaultAdd) {
7366
+ inputs = props.config.defaultAdd;
7367
+ }
7368
+ inputs = await initValue(mForm, {
7369
+ config: columns,
7370
+ initValues: inputs
7371
+ });
7372
+ }
7373
+ if (props.sortKey && length) {
7374
+ inputs[props.sortKey] = props.model[modelName][length - 1][props.sortKey] - 1;
7375
+ }
7376
+ emit("change", [...props.model[modelName], inputs], {
7377
+ changeRecords: [
7378
+ {
7379
+ propPath: `${props.prop}.${props.model[modelName].length}`,
7380
+ value: inputs
7381
+ }
7382
+ ]
7383
+ });
7384
+ };
7385
+ return {
7386
+ addable,
7387
+ newHandler
7388
+ };
7389
+ };
7390
+
7391
+ const useFullscreen = () => {
7392
+ const isFullscreen = vue.ref(false);
7393
+ const mTableEl = vue.useTemplateRef("mTable");
7394
+ const { nextZIndex } = design.useZIndex();
7395
+ const toggleFullscreen = () => {
7396
+ if (!mTableEl.value) return;
7397
+ if (isFullscreen.value) {
7398
+ mTableEl.value.classList.remove("fixed");
7399
+ isFullscreen.value = false;
7400
+ } else {
7401
+ mTableEl.value.classList.add("fixed");
7402
+ mTableEl.value.style.zIndex = `${nextZIndex()}`;
7403
+ isFullscreen.value = true;
7404
+ }
7405
+ };
7406
+ return {
7407
+ isFullscreen,
7408
+ toggleFullscreen
7409
+ };
7410
+ };
7411
+
7412
+ const useImport = (props, emit, newHandler) => {
7413
+ const mForm = vue.inject("mForm");
7414
+ const modelName = vue.computed(() => props.name || props.config.name || "");
7415
+ const importable = vue.computed(() => {
7416
+ if (typeof props.config.importable === "function") {
7417
+ return props.config.importable(mForm, {
7418
+ formValue: mForm?.values,
7419
+ model: props.model[modelName.value]
7420
+ });
7421
+ }
7422
+ return typeof props.config.importable === "undefined" ? false : props.config.importable;
7423
+ });
7424
+ const excelBtn = vue.useTemplateRef("excelBtn");
7425
+ const excelHandler = async (file) => {
7426
+ if (!file?.raw) {
7427
+ return false;
7428
+ }
7429
+ if (!globalThis.XLSX) {
7430
+ await utils.asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
7431
+ }
7432
+ const reader = new FileReader();
7433
+ reader.onload = () => {
7434
+ const data = reader.result;
7435
+ const pdata = globalThis.XLSX.read(data, { type: "array" });
7436
+ pdata.SheetNames.forEach((sheetName) => {
7437
+ const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
7438
+ if (arr?.[0]) {
7439
+ arr.forEach((row) => {
7440
+ newHandler(row);
7441
+ });
7442
+ }
7443
+ setTimeout(() => {
7444
+ excelBtn.value?.clearFiles();
7445
+ }, 300);
7446
+ });
7447
+ };
7448
+ reader.readAsArrayBuffer(file.raw);
7449
+ return false;
7450
+ };
7451
+ const clearHandler = () => {
7452
+ emit("change", []);
7453
+ mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
7454
+ };
7455
+ return {
7456
+ importable,
7457
+ excelHandler,
7458
+ clearHandler
7459
+ };
7460
+ };
7461
+
7462
+ const usePagination = (props, modelName) => {
7463
+ const pageSize = vue.ref(10);
7464
+ const currentPage = vue.ref(0);
7465
+ const paginationData = vue.computed(() => getDataByPage(props.model[modelName.value], currentPage.value, pageSize.value));
7466
+ const handleSizeChange = (val) => {
7467
+ pageSize.value = val;
7468
+ };
7469
+ const handleCurrentChange = (val) => {
7470
+ currentPage.value = val - 1;
7471
+ };
7472
+ return {
7473
+ pageSize,
7474
+ currentPage,
7475
+ paginationData,
7476
+ handleSizeChange,
7477
+ handleCurrentChange
7478
+ };
7479
+ };
7480
+
7481
+ const useSelection = (props, emit, tMagicTableRef) => {
7482
+ const mForm = vue.inject("mForm");
7483
+ const selectHandle = (selection, row) => {
7484
+ if (typeof props.config.selection === "string" && props.config.selection === "single") {
7485
+ tMagicTableRef.value?.clearSelection();
7486
+ tMagicTableRef.value?.toggleRowSelection(row, true);
7487
+ }
7488
+ emit("select", selection, row);
7489
+ if (typeof props.config.onSelect === "function") {
7490
+ props.config.onSelect(mForm, { selection, row, config: props.config });
7491
+ }
7492
+ };
7493
+ const toggleRowSelection = (row, selected) => {
7494
+ tMagicTableRef.value?.toggleRowSelection.call(tMagicTableRef.value?.getTableRef(), row, selected);
7495
+ };
7496
+ return {
7497
+ selectHandle,
7498
+ toggleRowSelection
7499
+ };
7500
+ };
7501
+
7502
+ const useSortable = (props, emit, tMagicTableRef, modelName) => {
7503
+ const mForm = vue.inject("mForm");
7504
+ let sortable;
7505
+ const rowDrop = () => {
7506
+ sortable?.destroy();
7507
+ const tableEl = tMagicTableRef.value?.getEl();
7508
+ const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
7509
+ if (!tBodyEl) {
7510
+ return;
7511
+ }
7512
+ sortable = Sortable.create(tBodyEl, {
7513
+ draggable: ".tmagic-design-table-row",
7514
+ filter: "input",
7515
+ // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
7516
+ preventOnFilter: false,
7517
+ // 允许选字
7518
+ direction: "vertical",
7519
+ onEnd: ({ newIndex, oldIndex }) => {
7520
+ if (typeof newIndex === "undefined") return;
7521
+ if (typeof oldIndex === "undefined") return;
7522
+ const newData = sortArray(props.model[modelName.value], newIndex, oldIndex, props.sortKey);
7523
+ emit("change", newData);
7524
+ mForm?.$emit("field-change", newData);
7525
+ }
7526
+ });
7527
+ };
7528
+ vue.watchEffect(() => {
7529
+ if (props.config.dropSort) {
7530
+ rowDrop();
7531
+ }
7532
+ });
7533
+ };
7534
+
7764
7535
  const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
7765
- ...{
7766
- name: "MFormTextarea"
7767
- },
7768
- __name: "Textarea",
7536
+ __name: "ActionsColumn",
7769
7537
  props: {
7770
7538
  config: {},
7771
7539
  model: {},
7772
- initValues: {},
7773
- values: {},
7774
7540
  name: {},
7775
- prop: {},
7776
7541
  disabled: { type: Boolean },
7777
- size: {},
7778
- lastValues: {}
7542
+ currentPage: {},
7543
+ pageSize: {},
7544
+ index: {},
7545
+ row: {},
7546
+ prop: {},
7547
+ sortKey: {}
7779
7548
  },
7780
- emits: ["change", "input"],
7549
+ emits: ["change"],
7781
7550
  setup(__props, { emit: __emit }) {
7782
- const props = __props;
7783
7551
  const emit = __emit;
7784
- useAddField(props.prop);
7552
+ const props = __props;
7785
7553
  const mForm = vue.inject("mForm");
7786
- const changeHandler = (value) => {
7787
- emit("change", value);
7554
+ const removeHandler = (index) => {
7555
+ if (props.disabled) return;
7556
+ emit("change", props.model[props.name].toSpliced(index, 1));
7788
7557
  };
7789
- const inputHandler = (v) => {
7790
- emit("input", v);
7791
- mForm?.$emit("field-input", props.prop, v);
7558
+ const copyHandler = (index) => {
7559
+ const inputs = cloneDeep(props.model[props.name][index]);
7560
+ const { length } = props.model[props.name];
7561
+ if (props.sortKey && length) {
7562
+ inputs[props.sortKey] = props.model[props.name][length - 1][props.sortKey] - 1;
7563
+ }
7564
+ emit("change", [...props.model[props.name], inputs], {
7565
+ changeRecords: [
7566
+ {
7567
+ propPath: `${props.prop}.${props.model[props.name].length}`,
7568
+ value: inputs
7569
+ }
7570
+ ]
7571
+ });
7572
+ };
7573
+ const showDelete = (index) => {
7574
+ const deleteFunc = props.config.delete;
7575
+ if (deleteFunc && typeof deleteFunc === "function") {
7576
+ return deleteFunc(props.model[props.name], index, mForm?.values);
7577
+ }
7578
+ return props.config.delete ?? true;
7579
+ };
7580
+ const copyable = (index) => {
7581
+ const copyableFunc = props.config.copyable;
7582
+ if (copyableFunc && typeof copyableFunc === "function") {
7583
+ return copyableFunc(mForm, {
7584
+ values: mForm?.initValues || {},
7585
+ model: props.model,
7586
+ parent: mForm?.parentValues || {},
7587
+ formValue: mForm?.values || props.model,
7588
+ prop: props.prop,
7589
+ config: props.config,
7590
+ index
7591
+ });
7592
+ }
7593
+ return props.config.copyable ?? true;
7792
7594
  };
7793
7595
  return (_ctx, _cache) => {
7794
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
7795
- modelValue: __props.model[__props.name],
7796
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
7797
- type: "textarea",
7798
- size: __props.size,
7799
- clearable: "",
7800
- placeholder: __props.config.placeholder,
7801
- disabled: __props.disabled,
7802
- onChange: changeHandler,
7803
- onInput: inputHandler
7804
- }, null, 8, ["modelValue", "size", "placeholder", "disabled"]);
7596
+ return vue.openBlock(), vue.createElementBlock(
7597
+ vue.Fragment,
7598
+ null,
7599
+ [
7600
+ vue.renderSlot(_ctx.$slots, "operateCol", {
7601
+ scope: { $index: __props.index, row: __props.row }
7602
+ }),
7603
+ vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
7604
+ size: "small",
7605
+ type: "danger",
7606
+ link: "",
7607
+ title: "删除",
7608
+ icon: vue.unref(iconsVue.Delete),
7609
+ onClick: _cache[0] || (_cache[0] = ($event) => removeHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
7610
+ }, null, 8, ["icon"]), [
7611
+ [vue.vShow, showDelete(__props.index + 1 + __props.currentPage * __props.pageSize - 1)]
7612
+ ]),
7613
+ copyable(__props.index + 1 + __props.currentPage * __props.pageSize - 1) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
7614
+ key: 0,
7615
+ link: "",
7616
+ size: "small",
7617
+ type: "primary",
7618
+ title: "复制",
7619
+ icon: vue.unref(iconsVue.DocumentCopy),
7620
+ disabled: __props.disabled,
7621
+ onClick: _cache[1] || (_cache[1] = ($event) => copyHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
7622
+ }, null, 8, ["icon", "disabled"])) : vue.createCommentVNode("v-if", true)
7623
+ ],
7624
+ 64
7625
+ /* STABLE_FRAGMENT */
7626
+ );
7805
7627
  };
7806
7628
  }
7807
7629
  });
7808
7630
 
7809
7631
  const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
7810
- ...{
7811
- name: "MFormTime"
7812
- },
7813
- __name: "Time",
7632
+ __name: "SortColumn",
7814
7633
  props: {
7815
- config: {},
7816
- model: {},
7817
- initValues: {},
7818
- values: {},
7819
- name: {},
7820
- prop: {},
7634
+ index: {},
7821
7635
  disabled: { type: Boolean },
7822
- size: {},
7823
- lastValues: {}
7636
+ currentPage: {},
7637
+ pageSize: {},
7638
+ name: {},
7639
+ model: {}
7824
7640
  },
7825
- emits: ["change"],
7641
+ emits: ["swap"],
7826
7642
  setup(__props, { emit: __emit }) {
7827
7643
  const props = __props;
7828
7644
  const emit = __emit;
7829
- useAddField(props.prop);
7830
- const changeHandler = (v) => {
7831
- emit("change", v);
7645
+ let timer = null;
7646
+ const upHandler = (index) => {
7647
+ if (timer) {
7648
+ clearTimeout(timer);
7649
+ }
7650
+ timer = setTimeout(() => {
7651
+ emit("swap", index, index - 1);
7652
+ timer = null;
7653
+ }, 300);
7654
+ };
7655
+ const topHandler = (index) => {
7656
+ if (timer) {
7657
+ clearTimeout(timer);
7658
+ }
7659
+ const moveNum = index;
7660
+ for (let i = 0; i < moveNum; i++) {
7661
+ emit("swap", index, index - 1);
7662
+ index -= 1;
7663
+ }
7664
+ };
7665
+ const downHandler = (index) => {
7666
+ if (timer) {
7667
+ clearTimeout(timer);
7668
+ }
7669
+ timer = setTimeout(() => {
7670
+ emit("swap", index, index + 1);
7671
+ timer = null;
7672
+ }, 300);
7673
+ };
7674
+ const bottomHandler = (index) => {
7675
+ if (timer) {
7676
+ clearTimeout(timer);
7677
+ }
7678
+ const moveNum = props.model[props.name].length - 1 - index;
7679
+ for (let i = 0; i < moveNum; i++) {
7680
+ emit("swap", index, index + 1);
7681
+ index += 1;
7682
+ }
7832
7683
  };
7833
7684
  return (_ctx, _cache) => {
7834
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTimePicker), {
7835
- modelValue: __props.model[__props.name],
7836
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
7837
- "value-format": __props.config.valueFormat || "HH:mm:ss",
7838
- format: __props.config.format || "HH:mm:ss",
7839
- size: __props.size,
7840
- placeholder: __props.config.placeholder,
7841
- disabled: __props.disabled,
7842
- onChange: changeHandler
7843
- }, null, 8, ["modelValue", "value-format", "format", "size", "placeholder", "disabled"]);
7685
+ return vue.openBlock(), vue.createElementBlock(
7686
+ vue.Fragment,
7687
+ null,
7688
+ [
7689
+ __props.index + 1 + __props.currentPage * __props.pageSize - 1 !== 0 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
7690
+ key: 0,
7691
+ content: "点击上移,双击置顶",
7692
+ placement: "top"
7693
+ }, {
7694
+ default: vue.withCtx(() => [
7695
+ vue.createVNode(vue.unref(design.TMagicButton), {
7696
+ plain: "",
7697
+ size: "small",
7698
+ type: "primary",
7699
+ icon: vue.unref(iconsVue.ArrowUp),
7700
+ disabled: __props.disabled,
7701
+ link: "",
7702
+ onClick: _cache[0] || (_cache[0] = ($event) => upHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1)),
7703
+ onDblclick: _cache[1] || (_cache[1] = ($event) => topHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
7704
+ }, null, 8, ["icon", "disabled"])
7705
+ ]),
7706
+ _: 1
7707
+ /* STABLE */
7708
+ })) : vue.createCommentVNode("v-if", true),
7709
+ __props.index + 1 + __props.currentPage * __props.pageSize - 1 !== __props.model[__props.name].length - 1 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
7710
+ key: 1,
7711
+ content: "点击下移,双击置底",
7712
+ placement: "top"
7713
+ }, {
7714
+ default: vue.withCtx(() => [
7715
+ vue.createVNode(vue.unref(design.TMagicButton), {
7716
+ plain: "",
7717
+ size: "small",
7718
+ type: "primary",
7719
+ icon: vue.unref(iconsVue.ArrowDown),
7720
+ disabled: __props.disabled,
7721
+ link: "",
7722
+ onClick: _cache[2] || (_cache[2] = ($event) => downHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1)),
7723
+ onDblclick: _cache[3] || (_cache[3] = ($event) => bottomHandler(__props.index + 1 + __props.currentPage * __props.pageSize - 1))
7724
+ }, null, 8, ["icon", "disabled"])
7725
+ ]),
7726
+ _: 1
7727
+ /* STABLE */
7728
+ })) : vue.createCommentVNode("v-if", true)
7729
+ ],
7730
+ 64
7731
+ /* STABLE_FRAGMENT */
7732
+ );
7844
7733
  };
7845
7734
  }
7846
7735
  });
7847
7736
 
7737
+ const useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
7738
+ const mForm = vue.inject("mForm");
7739
+ const display$1 = (fuc) => display(mForm, fuc, props);
7740
+ const lastData = vue.computed(
7741
+ () => props.config.pagination ? getDataByPage(props.lastValues[modelName.value], currentPage.value, pageSize.value) : props.lastValues[modelName.value] || []
7742
+ );
7743
+ const itemExtra = (fuc, index) => {
7744
+ if (typeof fuc === "function") {
7745
+ return fuc(mForm, {
7746
+ values: mForm?.initValues,
7747
+ model: props.model,
7748
+ formValue: mForm ? mForm.values : props.model,
7749
+ prop: props.prop,
7750
+ index
7751
+ });
7752
+ }
7753
+ return fuc;
7754
+ };
7755
+ const selection = vue.computed(() => {
7756
+ if (typeof props.config.selection === "function") {
7757
+ return props.config.selection(mForm, { model: props.model[modelName.value] });
7758
+ }
7759
+ return props.config.selection;
7760
+ });
7761
+ const getProp = (index) => {
7762
+ return `${props.prop}${props.prop ? "." : ""}${index + 1 + currentPage.value * pageSize.value - 1}`;
7763
+ };
7764
+ const makeConfig = (config, row) => {
7765
+ const newConfig = cloneDeep(config);
7766
+ if (typeof config.itemsFunction === "function") {
7767
+ newConfig.items = config.itemsFunction(row);
7768
+ }
7769
+ delete newConfig.display;
7770
+ return newConfig;
7771
+ };
7772
+ const changeHandler = (v, eventData) => {
7773
+ emit("change", props.model, eventData);
7774
+ };
7775
+ const onAddDiffCount = () => emit("addDiffCount");
7776
+ const columns = vue.computed(() => {
7777
+ const columns2 = [];
7778
+ if (props.config.itemExtra && !props.config.dropSort) {
7779
+ columns2.push({
7780
+ props: {
7781
+ fixed: "left",
7782
+ width: 30,
7783
+ type: "expand"
7784
+ },
7785
+ cell: ({ $index }) => vue.h("span", {
7786
+ innerHTML: itemExtra(props.config.itemExtra, $index),
7787
+ class: "m-form-tip"
7788
+ })
7789
+ });
7790
+ }
7791
+ columns2.push({
7792
+ props: {
7793
+ label: "操作",
7794
+ fixed: props.config.fixed === false ? void 0 : "left",
7795
+ width: props.config.operateColWidth || 112,
7796
+ align: "center"
7797
+ },
7798
+ cell: ({ row, $index }) => vue.h(_sfc_main$4, {
7799
+ row,
7800
+ index: $index,
7801
+ model: props.model,
7802
+ config: props.config,
7803
+ prop: props.prop,
7804
+ disabled: props.disabled,
7805
+ sortKey: props.sortKey,
7806
+ name: modelName.value,
7807
+ currentPage: currentPage.value,
7808
+ pageSize: pageSize.value,
7809
+ onChange: (v) => {
7810
+ emit("change", v);
7811
+ }
7812
+ })
7813
+ });
7814
+ if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) {
7815
+ columns2.push({
7816
+ props: {
7817
+ label: "排序",
7818
+ width: 80
7819
+ },
7820
+ cell: ({ $index }) => vue.h(_sfc_main$3, {
7821
+ index: $index,
7822
+ model: props.model,
7823
+ disabled: props.disabled,
7824
+ name: modelName.value,
7825
+ currentPage: currentPage.value,
7826
+ pageSize: pageSize.value,
7827
+ onSwap: (index1, index2) => {
7828
+ const newData = sortArray(props.model[modelName.value], index1, index2, props.sortKey);
7829
+ emit("change", newData);
7830
+ mForm?.$emit("field-change", newData);
7831
+ }
7832
+ })
7833
+ });
7834
+ }
7835
+ if (selection.value) {
7836
+ columns2.push({
7837
+ props: {
7838
+ align: "center",
7839
+ headerAlign: "center",
7840
+ type: "selection",
7841
+ width: 45
7842
+ }
7843
+ });
7844
+ }
7845
+ if (props.showIndex && props.config.showIndex) {
7846
+ columns2.push({
7847
+ props: {
7848
+ label: "序号",
7849
+ width: 60
7850
+ },
7851
+ cell: ({ $index }) => vue.h("span", $index + 1 + currentPage.value * pageSize.value)
7852
+ });
7853
+ }
7854
+ for (const column of props.config.items) {
7855
+ if (column.type !== "hidden" && display$1(column.display)) {
7856
+ columns2.push({
7857
+ props: {
7858
+ prop: column.name,
7859
+ label: column.label,
7860
+ width: column.width,
7861
+ sortable: column.sortable,
7862
+ sortOrders: ["ascending", "descending"],
7863
+ class: props.config.dropSort === true ? "el-table__column--dropable" : ""
7864
+ },
7865
+ cell: ({ row, $index }) => vue.h(_sfc_main$A, {
7866
+ labelWidth: "0",
7867
+ disabled: props.disabled,
7868
+ prop: getProp($index),
7869
+ rules: column.rules,
7870
+ config: makeConfig(column, row),
7871
+ model: row,
7872
+ lastValues: lastData.value[$index],
7873
+ isCompare: props.isCompare,
7874
+ size: props.size,
7875
+ onChange: changeHandler,
7876
+ onAddDiffCount
7877
+ })
7878
+ });
7879
+ }
7880
+ }
7881
+ return columns2;
7882
+ });
7883
+ return {
7884
+ columns
7885
+ };
7886
+ };
7887
+
7888
+ const _hoisted_1$1 = { class: "m-fields-table-wrap" };
7889
+ const _hoisted_2 = ["innerHTML"];
7890
+ const _hoisted_3 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
7891
+ const _hoisted_4 = { style: { "display": "flex" } };
7892
+ const _hoisted_5 = {
7893
+ key: 1,
7894
+ class: "bottom",
7895
+ style: { "text-align": "right" }
7896
+ };
7848
7897
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
7849
7898
  ...{
7850
- name: "MFormTimeRange"
7899
+ name: "MFormTable"
7851
7900
  },
7852
- __name: "Timerange",
7901
+ __name: "Table",
7853
7902
  props: {
7854
- config: {},
7855
7903
  model: {},
7856
- initValues: {},
7857
- values: {},
7904
+ lastValues: { default: () => ({}) },
7905
+ isCompare: { type: Boolean, default: false },
7906
+ config: {},
7858
7907
  name: {},
7859
- prop: {},
7908
+ prop: { default: "" },
7909
+ labelWidth: {},
7910
+ sort: { type: Boolean },
7860
7911
  disabled: { type: Boolean },
7912
+ sortKey: { default: "" },
7913
+ text: {},
7861
7914
  size: {},
7862
- lastValues: {}
7915
+ enableToggleMode: { type: Boolean, default: true },
7916
+ showIndex: { type: Boolean, default: true }
7863
7917
  },
7864
- emits: ["change"],
7865
- setup(__props, { emit: __emit }) {
7918
+ emits: ["change", "select", "addDiffCount"],
7919
+ setup(__props, { expose: __expose, emit: __emit }) {
7866
7920
  const props = __props;
7867
7921
  const emit = __emit;
7868
- useAddField(props.prop);
7869
- const { names } = props.config;
7870
- const value = vue.ref([]);
7871
- if (props.model !== void 0 && names?.length) {
7872
- vue.watch(
7873
- [() => props.model[names[0]], () => props.model[names[1]]],
7874
- ([start, end], [preStart, preEnd]) => {
7875
- if (!value.value) {
7876
- value.value = [];
7877
- }
7878
- if (!start || !end) value.value = [];
7879
- if (start !== preStart) value.value[0] = start;
7880
- if (end !== preEnd) value.value[1] = end;
7881
- },
7882
- {
7883
- immediate: true
7884
- }
7885
- );
7886
- }
7887
- const setValue = (v) => {
7888
- names?.forEach((item, index) => {
7889
- if (!props.model) {
7890
- return;
7891
- }
7892
- if (Array.isArray(v)) {
7893
- props.model[item] = v[index];
7894
- } else {
7895
- props.model[item] = void 0;
7896
- }
7922
+ const modelName = vue.computed(() => props.name || props.config.name || "");
7923
+ const tMagicTableRef = vue.useTemplateRef("tMagicTable");
7924
+ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentChange } = usePagination(
7925
+ props,
7926
+ modelName
7927
+ );
7928
+ const { addable, newHandler } = useAdd(props, emit);
7929
+ const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
7930
+ useSortable(props, emit, tMagicTableRef, modelName);
7931
+ const { isFullscreen, toggleFullscreen } = useFullscreen();
7932
+ const { importable, excelHandler, clearHandler } = useImport(props, emit, newHandler);
7933
+ const { selectHandle, toggleRowSelection } = useSelection(props, emit, tMagicTableRef);
7934
+ const updateKey = vue.ref(1);
7935
+ const data = vue.computed(() => props.config.pagination ? paginationData.value : props.model[modelName.value]);
7936
+ const toggleMode = () => {
7937
+ const calcLabelWidth = (label) => {
7938
+ if (!label) return "0px";
7939
+ const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
7940
+ const chLength = label.length - zhLength;
7941
+ return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
7942
+ };
7943
+ props.config.type = "groupList";
7944
+ props.config.enableToggleMode = true;
7945
+ props.config.tableItems = props.config.items;
7946
+ props.config.items = props.config.groupItems || props.config.items.map((item) => {
7947
+ const text = item.text || item.label;
7948
+ const labelWidth = calcLabelWidth(text);
7949
+ return {
7950
+ ...item,
7951
+ text,
7952
+ labelWidth,
7953
+ span: item.span || 12
7954
+ };
7897
7955
  });
7898
7956
  };
7899
- const changeHandler = (v) => {
7900
- const value2 = v || [];
7901
- if (names?.length) {
7902
- setValue(value2);
7903
- }
7904
- emit("change", value2);
7957
+ const sortChangeHandler = (sortOptions) => {
7958
+ const modelName2 = props.name || props.config.name || "";
7959
+ sortChange(props.model[modelName2], sortOptions);
7905
7960
  };
7961
+ __expose({
7962
+ toggleRowSelection
7963
+ });
7906
7964
  return (_ctx, _cache) => {
7907
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTimePicker), {
7908
- modelValue: value.value,
7909
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
7910
- "is-range": "",
7911
- "range-separator": "-",
7912
- "start-placeholder": "开始时间",
7913
- "end-placeholder": "结束时间",
7914
- size: __props.size,
7915
- "unlink-panels": true,
7916
- disabled: __props.disabled,
7917
- "default-time": __props.config.defaultTime,
7918
- onChange: changeHandler
7919
- }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
7965
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
7966
+ (vue.openBlock(), vue.createBlock(vue.Teleport, {
7967
+ to: "body",
7968
+ disabled: !vue.unref(isFullscreen)
7969
+ }, [
7970
+ vue.createElementVNode(
7971
+ "div",
7972
+ {
7973
+ ref: "mTable",
7974
+ class: vue.normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }])
7975
+ },
7976
+ [
7977
+ __props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
7978
+ key: 0,
7979
+ style: { "color": "rgba(0, 0, 0, 0.45)" },
7980
+ innerHTML: __props.config.extra
7981
+ }, null, 8, _hoisted_2)) : vue.createCommentVNode("v-if", true),
7982
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
7983
+ content: "拖拽可排序",
7984
+ placement: "left-start",
7985
+ disabled: __props.config.dropSort !== true
7986
+ }, {
7987
+ default: vue.withCtx(() => [
7988
+ __props.model[modelName.value] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTable), {
7989
+ ref: "tMagicTable",
7990
+ style: { "width": "100%" },
7991
+ "show-header": "",
7992
+ "row-key": __props.config.rowKey || "id",
7993
+ columns: vue.unref(columns),
7994
+ data: data.value,
7995
+ border: __props.config.border,
7996
+ "max-height": __props.config.maxHeight,
7997
+ "default-expand-all": true,
7998
+ key: updateKey.value,
7999
+ onSelect: vue.unref(selectHandle),
8000
+ onSortChange: sortChangeHandler
8001
+ }, null, 8, ["row-key", "columns", "data", "border", "max-height", "onSelect"])) : vue.createCommentVNode("v-if", true)
8002
+ ]),
8003
+ _: 1
8004
+ /* STABLE */
8005
+ }, 8, ["disabled"]),
8006
+ vue.renderSlot(_ctx.$slots, "default"),
8007
+ vue.createElementVNode("div", _hoisted_3, [
8008
+ vue.unref(addable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
8009
+ key: 0,
8010
+ size: "small",
8011
+ type: "primary",
8012
+ disabled: __props.disabled,
8013
+ plain: "",
8014
+ onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(newHandler)())
8015
+ }, {
8016
+ default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
8017
+ vue.createTextVNode(
8018
+ "新增一行",
8019
+ -1
8020
+ /* CACHED */
8021
+ )
8022
+ ])]),
8023
+ _: 1
8024
+ /* STABLE */
8025
+ }, 8, ["disabled"])) : vue.createCommentVNode("v-if", true),
8026
+ vue.createElementVNode("div", _hoisted_4, [
8027
+ __props.enableToggleMode && __props.config.enableToggleMode !== false && !vue.unref(isFullscreen) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
8028
+ key: 0,
8029
+ icon: vue.unref(iconsVue.Grid),
8030
+ size: "small",
8031
+ type: "primary",
8032
+ onClick: toggleMode
8033
+ }, {
8034
+ default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
8035
+ vue.createTextVNode(
8036
+ "展开配置",
8037
+ -1
8038
+ /* CACHED */
8039
+ )
8040
+ ])]),
8041
+ _: 1
8042
+ /* STABLE */
8043
+ }, 8, ["icon"])) : vue.createCommentVNode("v-if", true),
8044
+ __props.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
8045
+ key: 1,
8046
+ icon: vue.unref(iconsVue.FullScreen),
8047
+ size: "small",
8048
+ type: "primary",
8049
+ onClick: vue.unref(toggleFullscreen)
8050
+ }, {
8051
+ default: vue.withCtx(() => [
8052
+ vue.createTextVNode(
8053
+ vue.toDisplayString(vue.unref(isFullscreen) ? "退出全屏" : "全屏编辑"),
8054
+ 1
8055
+ /* TEXT */
8056
+ )
8057
+ ]),
8058
+ _: 1
8059
+ /* STABLE */
8060
+ }, 8, ["icon", "onClick"])) : vue.createCommentVNode("v-if", true),
8061
+ vue.unref(importable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicUpload), {
8062
+ key: 2,
8063
+ style: { "display": "inline-block" },
8064
+ ref: "excelBtn",
8065
+ action: "/noop",
8066
+ disabled: __props.disabled,
8067
+ "on-change": vue.unref(excelHandler),
8068
+ "auto-upload": false
8069
+ }, {
8070
+ default: vue.withCtx(() => [
8071
+ vue.createVNode(vue.unref(design.TMagicButton), {
8072
+ size: "small",
8073
+ type: "success",
8074
+ disabled: __props.disabled,
8075
+ plain: ""
8076
+ }, {
8077
+ default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
8078
+ vue.createTextVNode(
8079
+ "导入EXCEL",
8080
+ -1
8081
+ /* CACHED */
8082
+ )
8083
+ ])]),
8084
+ _: 1
8085
+ /* STABLE */
8086
+ }, 8, ["disabled"])
8087
+ ]),
8088
+ _: 1
8089
+ /* STABLE */
8090
+ }, 8, ["disabled", "on-change"])) : vue.createCommentVNode("v-if", true),
8091
+ vue.unref(importable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
8092
+ key: 3,
8093
+ size: "small",
8094
+ type: "warning",
8095
+ disabled: __props.disabled,
8096
+ plain: "",
8097
+ onClick: vue.unref(clearHandler)
8098
+ }, {
8099
+ default: vue.withCtx(() => [..._cache[4] || (_cache[4] = [
8100
+ vue.createTextVNode(
8101
+ "清空",
8102
+ -1
8103
+ /* CACHED */
8104
+ )
8105
+ ])]),
8106
+ _: 1
8107
+ /* STABLE */
8108
+ }, 8, ["disabled", "onClick"])) : vue.createCommentVNode("v-if", true)
8109
+ ])
8110
+ ]),
8111
+ __props.config.pagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
8112
+ vue.createVNode(vue.unref(design.TMagicPagination), {
8113
+ layout: "total, sizes, prev, pager, next, jumper",
8114
+ "hide-on-single-page": __props.model[modelName.value].length < vue.unref(pageSize),
8115
+ "current-page": vue.unref(currentPage) + 1,
8116
+ "page-sizes": [vue.unref(pageSize), 60, 120, 300],
8117
+ "page-size": vue.unref(pageSize),
8118
+ total: __props.model[modelName.value].length,
8119
+ onSizeChange: vue.unref(handleSizeChange),
8120
+ onCurrentChange: vue.unref(handleCurrentChange)
8121
+ }, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total", "onSizeChange", "onCurrentChange"])
8122
+ ])) : vue.createCommentVNode("v-if", true)
8123
+ ],
8124
+ 2
8125
+ /* CLASS */
8126
+ )
8127
+ ], 8, ["disabled"]))
8128
+ ]);
7920
8129
  };
7921
8130
  }
7922
8131
  });
@@ -8083,7 +8292,7 @@
8083
8292
  class: "m-drawer-body"
8084
8293
  },
8085
8294
  [
8086
- vue.createVNode(_sfc_main$d, {
8295
+ vue.createVNode(_sfc_main$g, {
8087
8296
  ref_key: "form",
8088
8297
  ref: form,
8089
8298
  size: __props.size,
@@ -8191,7 +8400,7 @@
8191
8400
  [
8192
8401
  vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
8193
8402
  default: vue.withCtx(() => [
8194
- vue.createVNode(_sfc_main$d, {
8403
+ vue.createVNode(_sfc_main$g, {
8195
8404
  ref_key: "form",
8196
8405
  ref: form,
8197
8406
  size: __props.size,
@@ -8264,79 +8473,84 @@
8264
8473
  const option = Object.assign(defaultInstallOpt, opt);
8265
8474
  app.config.globalProperties.$MAGIC_FORM = option;
8266
8475
  setConfig(option);
8267
- app.component("m-form", _sfc_main$d);
8268
- app.component("m-form-dialog", _sfc_main$c);
8269
- app.component("m-form-container", _sfc_main$x);
8270
- app.component("m-form-fieldset", _sfc_main$w);
8271
- app.component("m-form-group-list", _sfc_main$u);
8272
- app.component("m-form-panel", _sfc_main$t);
8273
- app.component("m-form-row", _sfc_main$r);
8274
- app.component("m-form-step", _sfc_main$q);
8275
- app.component("m-form-table", _sfc_main$p);
8276
- app.component("m-form-tab", _sfc_main$o);
8277
- app.component("m-fields-text", _sfc_main$5);
8278
- app.component("m-fields-img-upload", _sfc_main$5);
8279
- app.component("m-fields-number", _sfc_main$a);
8280
- app.component("m-fields-number-range", _sfc_main$9);
8281
- app.component("m-fields-textarea", _sfc_main$4);
8282
- app.component("m-fields-hidden", _sfc_main$e);
8283
- app.component("m-fields-date", _sfc_main$j);
8284
- app.component("m-fields-datetime", _sfc_main$h);
8285
- app.component("m-fields-daterange", _sfc_main$i);
8286
- app.component("m-fields-timerange", _sfc_main$2);
8287
- app.component("m-fields-time", _sfc_main$3);
8288
- app.component("m-fields-checkbox", _sfc_main$m);
8289
- app.component("m-fields-switch", _sfc_main$6);
8290
- app.component("m-fields-color-picker", _sfc_main$k);
8291
- app.component("m-fields-checkbox-group", _sfc_main$l);
8292
- app.component("m-fields-radio-group", _sfc_main$8);
8293
- app.component("m-fields-display", _sfc_main$g);
8294
- app.component("m-fields-link", _sfc_main$b);
8295
- app.component("m-fields-select", _sfc_main$7);
8296
- app.component("m-fields-cascader", _sfc_main$n);
8297
- app.component("m-fields-dynamic-field", _sfc_main$f);
8476
+ app.component("m-form", _sfc_main$g);
8477
+ app.component("m-form-dialog", _sfc_main$f);
8478
+ app.component("m-form-container", _sfc_main$A);
8479
+ app.component("m-form-fieldset", _sfc_main$z);
8480
+ app.component("m-form-group-list", _sfc_main$w);
8481
+ app.component("m-form-panel", _sfc_main$v);
8482
+ app.component("m-form-row", _sfc_main$t);
8483
+ app.component("m-form-step", _sfc_main$s);
8484
+ app.component("m-form-table", _sfc_main$2);
8485
+ app.component("m-form-tab", _sfc_main$r);
8486
+ app.component("m-form-flex-layout", _sfc_main$y);
8487
+ app.component("m-fields-text", _sfc_main$8);
8488
+ app.component("m-fields-img-upload", _sfc_main$8);
8489
+ app.component("m-fields-number", _sfc_main$d);
8490
+ app.component("m-fields-number-range", _sfc_main$c);
8491
+ app.component("m-fields-textarea", _sfc_main$7);
8492
+ app.component("m-fields-hidden", _sfc_main$h);
8493
+ app.component("m-fields-date", _sfc_main$m);
8494
+ app.component("m-fields-datetime", _sfc_main$k);
8495
+ app.component("m-fields-daterange", _sfc_main$l);
8496
+ app.component("m-fields-timerange", _sfc_main$5);
8497
+ app.component("m-fields-time", _sfc_main$6);
8498
+ app.component("m-fields-checkbox", _sfc_main$p);
8499
+ app.component("m-fields-switch", _sfc_main$9);
8500
+ app.component("m-fields-color-picker", _sfc_main$n);
8501
+ app.component("m-fields-checkbox-group", _sfc_main$o);
8502
+ app.component("m-fields-radio-group", _sfc_main$b);
8503
+ app.component("m-fields-display", _sfc_main$j);
8504
+ app.component("m-fields-link", _sfc_main$e);
8505
+ app.component("m-fields-select", _sfc_main$a);
8506
+ app.component("m-fields-cascader", _sfc_main$q);
8507
+ app.component("m-fields-dynamic-field", _sfc_main$i);
8298
8508
  }
8299
8509
  };
8300
8510
 
8301
- exports.MCascader = _sfc_main$n;
8302
- exports.MCheckbox = _sfc_main$m;
8303
- exports.MCheckboxGroup = _sfc_main$l;
8304
- exports.MColorPicker = _sfc_main$k;
8305
- exports.MContainer = _sfc_main$x;
8306
- exports.MDate = _sfc_main$j;
8307
- exports.MDateTime = _sfc_main$h;
8308
- exports.MDaterange = _sfc_main$i;
8309
- exports.MDisplay = _sfc_main$g;
8310
- exports.MDynamicField = _sfc_main$f;
8311
- exports.MFieldset = _sfc_main$w;
8312
- exports.MForm = _sfc_main$d;
8511
+ exports.MCascader = _sfc_main$q;
8512
+ exports.MCheckbox = _sfc_main$p;
8513
+ exports.MCheckboxGroup = _sfc_main$o;
8514
+ exports.MColorPicker = _sfc_main$n;
8515
+ exports.MContainer = _sfc_main$A;
8516
+ exports.MDate = _sfc_main$m;
8517
+ exports.MDateTime = _sfc_main$k;
8518
+ exports.MDaterange = _sfc_main$l;
8519
+ exports.MDisplay = _sfc_main$j;
8520
+ exports.MDynamicField = _sfc_main$i;
8521
+ exports.MFieldset = _sfc_main$z;
8522
+ exports.MFlexLayout = _sfc_main$y;
8523
+ exports.MForm = _sfc_main$g;
8313
8524
  exports.MFormBox = _sfc_main;
8314
- exports.MFormDialog = _sfc_main$c;
8525
+ exports.MFormDialog = _sfc_main$f;
8315
8526
  exports.MFormDrawer = _sfc_main$1;
8316
- exports.MGroupList = _sfc_main$u;
8317
- exports.MHidden = _sfc_main$e;
8318
- exports.MLink = _sfc_main$b;
8319
- exports.MNumber = _sfc_main$a;
8320
- exports.MNumberRange = _sfc_main$9;
8321
- exports.MPanel = _sfc_main$t;
8322
- exports.MRadioGroup = _sfc_main$8;
8323
- exports.MRow = _sfc_main$r;
8324
- exports.MSelect = _sfc_main$7;
8325
- exports.MSwitch = _sfc_main$6;
8326
- exports.MTable = _sfc_main$p;
8327
- exports.MTabs = _sfc_main$o;
8328
- exports.MText = _sfc_main$5;
8329
- exports.MTextarea = _sfc_main$4;
8330
- exports.MTime = _sfc_main$3;
8331
- exports.MTimerange = _sfc_main$2;
8527
+ exports.MGroupList = _sfc_main$w;
8528
+ exports.MHidden = _sfc_main$h;
8529
+ exports.MLink = _sfc_main$e;
8530
+ exports.MNumber = _sfc_main$d;
8531
+ exports.MNumberRange = _sfc_main$c;
8532
+ exports.MPanel = _sfc_main$v;
8533
+ exports.MRadioGroup = _sfc_main$b;
8534
+ exports.MRow = _sfc_main$t;
8535
+ exports.MSelect = _sfc_main$a;
8536
+ exports.MSwitch = _sfc_main$9;
8537
+ exports.MTable = _sfc_main$2;
8538
+ exports.MTabs = _sfc_main$r;
8539
+ exports.MText = _sfc_main$8;
8540
+ exports.MTextarea = _sfc_main$7;
8541
+ exports.MTime = _sfc_main$6;
8542
+ exports.MTimerange = _sfc_main$5;
8332
8543
  exports.createForm = createForm;
8333
8544
  exports.createValues = createValues;
8334
8545
  exports.datetimeFormatter = datetimeFormatter;
8335
8546
  exports.default = index;
8336
8547
  exports.display = display;
8337
8548
  exports.filterFunction = filterFunction;
8549
+ exports.getDataByPage = getDataByPage;
8338
8550
  exports.getRules = getRules;
8339
8551
  exports.initValue = initValue;
8552
+ exports.sortArray = sortArray;
8553
+ exports.sortChange = sortChange;
8340
8554
  exports.useAddField = useAddField;
8341
8555
  Object.keys(formSchema).forEach(k => {
8342
8556
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {