@tmagic/form 1.7.8-beta.1 → 1.7.8-beta.3
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.
- package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/es/utils/form.js +6 -4
- package/dist/tmagic-form.umd.cjs +40 -36
- package/package.json +4 -4
- package/src/Form.vue +2 -2
- package/src/FormDialog.vue +13 -7
- package/src/containers/Col.vue +4 -4
- package/src/containers/Container.vue +16 -17
- package/src/containers/GroupListItem.vue +3 -1
- package/src/fields/RadioGroup.vue +1 -1
- package/src/fields/Timerange.vue +2 -2
- package/src/table/useAdd.ts +2 -2
- package/src/table/useTableColumns.ts +3 -3
- package/src/utils/form.ts +13 -10
- package/types/index.d.ts +3 -3
|
@@ -140,12 +140,12 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
140
140
|
for (const item of configs) {
|
|
141
141
|
if (item.name === currentPart) {
|
|
142
142
|
if (remainingParts.length === 0) return typeof item.text === "string" ? item.text : void 0;
|
|
143
|
-
if (
|
|
143
|
+
if ("items" in item && Array.isArray(item.items)) {
|
|
144
144
|
const result = findInConfig(item.items, remainingParts);
|
|
145
145
|
if (result !== void 0) return result;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
if (
|
|
148
|
+
if ("items" in item && Array.isArray(item.items)) {
|
|
149
149
|
const result = findInConfig(item.items, parts);
|
|
150
150
|
if (result !== void 0) return result;
|
|
151
151
|
}
|
|
@@ -57,13 +57,13 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
57
57
|
const stepActive = ref(1);
|
|
58
58
|
const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
|
|
59
59
|
const stepCount = computed(() => {
|
|
60
|
-
|
|
61
|
-
for (
|
|
60
|
+
if (!Array.isArray(props.config)) return 0;
|
|
61
|
+
for (const item of props.config) if ("type" in item && item.type === "step") return item.items.length;
|
|
62
62
|
return 0;
|
|
63
63
|
});
|
|
64
64
|
const hasStep = computed(() => {
|
|
65
|
-
|
|
66
|
-
for (
|
|
65
|
+
if (!Array.isArray(props.config)) return false;
|
|
66
|
+
for (const item of props.config) if ("type" in item && item.type === "step") return true;
|
|
67
67
|
return false;
|
|
68
68
|
});
|
|
69
69
|
const closeHandler = () => {
|
|
@@ -52,7 +52,7 @@ var Col_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
52
52
|
"disabled"
|
|
53
53
|
])]),
|
|
54
54
|
_: 1
|
|
55
|
-
}, 8, ["span"])), [[vShow, display$1.value && __props.config.type !== "hidden"]]);
|
|
55
|
+
}, 8, ["span"])), [[vShow, display$1.value && "type" in __props.config && __props.config.type !== "hidden"]]);
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -60,7 +60,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
60
60
|
return `${n}`;
|
|
61
61
|
});
|
|
62
62
|
const type = computed(() => {
|
|
63
|
-
let
|
|
63
|
+
let type = "type" in props.config ? props.config.type : "";
|
|
64
64
|
type = type && filterFunction(mForm, type, props);
|
|
65
65
|
if (type === "form") return "";
|
|
66
66
|
if (type === "container") return "";
|
|
@@ -68,7 +68,6 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
68
68
|
});
|
|
69
69
|
const tagName = computed(() => {
|
|
70
70
|
if (type.value === "component" && props.config.component) return props.config.component;
|
|
71
|
-
if (!getField(type.value || "container")) console.log(type.value, "type.value");
|
|
72
71
|
return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
|
|
73
72
|
});
|
|
74
73
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
@@ -2,6 +2,7 @@ import { useAddField } from "../utils/useAddField.js";
|
|
|
2
2
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
3
3
|
import { TMagicIcon, TMagicRadio, TMagicRadioButton, TMagicRadioGroup, TMagicTooltip } from "@tmagic/design";
|
|
4
4
|
//#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _hoisted_1 = { key: 1 };
|
|
5
6
|
var RadioGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
7
|
name: "MFormRadioGroup",
|
|
7
8
|
__name: "RadioGroup",
|
|
@@ -55,7 +56,7 @@ var RadioGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
55
56
|
}, {
|
|
56
57
|
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(option.icon)))]),
|
|
57
58
|
_: 2
|
|
58
|
-
}, 1032, ["size"])) : createCommentVNode("v-if", true),
|
|
59
|
+
}, 1032, ["size"])) : createCommentVNode("v-if", true), option.text ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(option.text), 1)) : createCommentVNode("v-if", true)])]),
|
|
59
60
|
_: 2
|
|
60
61
|
}, 1032, ["disabled", "content"])]),
|
|
61
62
|
_: 2
|
package/dist/es/utils/form.js
CHANGED
|
@@ -42,7 +42,8 @@ var setValue = (mForm, value, initValue, item) => {
|
|
|
42
42
|
var initValueItem = function(mForm, item, initValue, value) {
|
|
43
43
|
const { items } = item;
|
|
44
44
|
const { names } = item;
|
|
45
|
-
const
|
|
45
|
+
const type = "type" in item ? item.type : "";
|
|
46
|
+
const { name } = item;
|
|
46
47
|
if (isTableSelect(type) && name) {
|
|
47
48
|
value[name] = initValue[name] ?? "";
|
|
48
49
|
return value;
|
|
@@ -56,9 +57,10 @@ var initValueItem = function(mForm, item, initValue, value) {
|
|
|
56
57
|
if (!name) return createValues(mForm, items, initValue, value);
|
|
57
58
|
setValue(mForm, value, initValue, item);
|
|
58
59
|
if (type === "table") {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
60
|
+
const tableConfig = item;
|
|
61
|
+
if (tableConfig.defautSort) sortChange(value[name], tableConfig.defautSort);
|
|
62
|
+
else if (tableConfig.defaultSort) sortChange(value[name], tableConfig.defaultSort);
|
|
63
|
+
if (tableConfig.sort && tableConfig.sortKey) value[name].sort((a, b) => b[tableConfig.sortKey] - a[tableConfig.sortKey]);
|
|
62
64
|
}
|
|
63
65
|
return value;
|
|
64
66
|
};
|
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -2655,7 +2655,8 @@
|
|
|
2655
2655
|
var initValueItem = function(mForm, item, initValue, value) {
|
|
2656
2656
|
const { items } = item;
|
|
2657
2657
|
const { names } = item;
|
|
2658
|
-
const
|
|
2658
|
+
const type = "type" in item ? item.type : "";
|
|
2659
|
+
const { name } = item;
|
|
2659
2660
|
if (isTableSelect(type) && name) {
|
|
2660
2661
|
value[name] = initValue[name] ?? "";
|
|
2661
2662
|
return value;
|
|
@@ -2669,9 +2670,10 @@
|
|
|
2669
2670
|
if (!name) return createValues(mForm, items, initValue, value);
|
|
2670
2671
|
setValue(mForm, value, initValue, item);
|
|
2671
2672
|
if (type === "table") {
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
if (
|
|
2673
|
+
const tableConfig = item;
|
|
2674
|
+
if (tableConfig.defautSort) sortChange(value[name], tableConfig.defautSort);
|
|
2675
|
+
else if (tableConfig.defaultSort) sortChange(value[name], tableConfig.defaultSort);
|
|
2676
|
+
if (tableConfig.sort && tableConfig.sortKey) value[name].sort((a, b) => b[tableConfig.sortKey] - a[tableConfig.sortKey]);
|
|
2675
2677
|
}
|
|
2676
2678
|
return value;
|
|
2677
2679
|
};
|
|
@@ -2830,7 +2832,7 @@
|
|
|
2830
2832
|
var deleteField = (tagName) => fieldRegistry.delete(tagName);
|
|
2831
2833
|
//#endregion
|
|
2832
2834
|
//#region packages/form/src/containers/FormLabel.vue?vue&type=script&setup=true&lang.ts
|
|
2833
|
-
var _hoisted_1$
|
|
2835
|
+
var _hoisted_1$15 = {
|
|
2834
2836
|
key: 0,
|
|
2835
2837
|
style: {
|
|
2836
2838
|
"display": "inline-flex",
|
|
@@ -2853,7 +2855,7 @@
|
|
|
2853
2855
|
},
|
|
2854
2856
|
setup(__props) {
|
|
2855
2857
|
return (_ctx, _cache) => {
|
|
2856
|
-
return __props.tip ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$
|
|
2858
|
+
return __props.tip ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$15, [(0, vue.createElementVNode)("span", {
|
|
2857
2859
|
innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
|
|
2858
2860
|
title: __props.labelTitle
|
|
2859
2861
|
}, null, 8, _hoisted_2$8), __props.tip && (__props.type !== "checkbox" || __props.useLabel) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
|
|
@@ -2879,7 +2881,7 @@
|
|
|
2879
2881
|
});
|
|
2880
2882
|
//#endregion
|
|
2881
2883
|
//#region packages/form/src/containers/Container.vue?vue&type=script&setup=true&lang.ts
|
|
2882
|
-
var _hoisted_1$
|
|
2884
|
+
var _hoisted_1$14 = ["data-tmagic-id", "data-tmagic-form-item-prop"];
|
|
2883
2885
|
var _hoisted_2$7 = ["innerHTML"];
|
|
2884
2886
|
var _hoisted_3$6 = ["innerHTML"];
|
|
2885
2887
|
var _hoisted_4$4 = ["innerHTML"];
|
|
@@ -2933,7 +2935,7 @@
|
|
|
2933
2935
|
return `${n}`;
|
|
2934
2936
|
});
|
|
2935
2937
|
const type = (0, vue.computed)(() => {
|
|
2936
|
-
let
|
|
2938
|
+
let type = "type" in props.config ? props.config.type : "";
|
|
2937
2939
|
type = type && filterFunction(mForm, type, props);
|
|
2938
2940
|
if (type === "form") return "";
|
|
2939
2941
|
if (type === "container") return "";
|
|
@@ -2941,7 +2943,6 @@
|
|
|
2941
2943
|
});
|
|
2942
2944
|
const tagName = (0, vue.computed)(() => {
|
|
2943
2945
|
if (type.value === "component" && props.config.component) return props.config.component;
|
|
2944
|
-
if (!getField(type.value || "container")) console.log(type.value, "type.value");
|
|
2945
2946
|
return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
|
|
2946
2947
|
});
|
|
2947
2948
|
const disabled = (0, vue.computed)(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
@@ -3304,7 +3305,7 @@
|
|
|
3304
3305
|
}, {
|
|
3305
3306
|
default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(expand.value ? "收起配置" : "展开更多配置"), 1)]),
|
|
3306
3307
|
_: 1
|
|
3307
|
-
})])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$
|
|
3308
|
+
})])) : (0, vue.createCommentVNode)("v-if", true)], 14, _hoisted_1$14);
|
|
3308
3309
|
};
|
|
3309
3310
|
}
|
|
3310
3311
|
});
|
|
@@ -3444,12 +3445,12 @@
|
|
|
3444
3445
|
for (const item of configs) {
|
|
3445
3446
|
if (item.name === currentPart) {
|
|
3446
3447
|
if (remainingParts.length === 0) return typeof item.text === "string" ? item.text : void 0;
|
|
3447
|
-
if (
|
|
3448
|
+
if ("items" in item && Array.isArray(item.items)) {
|
|
3448
3449
|
const result = findInConfig(item.items, remainingParts);
|
|
3449
3450
|
if (result !== void 0) return result;
|
|
3450
3451
|
}
|
|
3451
3452
|
}
|
|
3452
|
-
if (
|
|
3453
|
+
if ("items" in item && Array.isArray(item.items)) {
|
|
3453
3454
|
const result = findInConfig(item.items, parts);
|
|
3454
3455
|
if (result !== void 0) return result;
|
|
3455
3456
|
}
|
|
@@ -3536,7 +3537,7 @@
|
|
|
3536
3537
|
});
|
|
3537
3538
|
//#endregion
|
|
3538
3539
|
//#region packages/form/src/FormDialog.vue?vue&type=script&setup=true&lang.ts
|
|
3539
|
-
var _hoisted_1$
|
|
3540
|
+
var _hoisted_1$13 = { style: { "min-height": "1px" } };
|
|
3540
3541
|
//#endregion
|
|
3541
3542
|
//#region packages/form/src/FormDialog.vue
|
|
3542
3543
|
var FormDialog_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
@@ -3593,13 +3594,13 @@
|
|
|
3593
3594
|
const stepActive = (0, vue.ref)(1);
|
|
3594
3595
|
const bodyHeight = (0, vue.ref)(`${document.body.clientHeight - 194}px`);
|
|
3595
3596
|
const stepCount = (0, vue.computed)(() => {
|
|
3596
|
-
|
|
3597
|
-
for (
|
|
3597
|
+
if (!Array.isArray(props.config)) return 0;
|
|
3598
|
+
for (const item of props.config) if ("type" in item && item.type === "step") return item.items.length;
|
|
3598
3599
|
return 0;
|
|
3599
3600
|
});
|
|
3600
3601
|
const hasStep = (0, vue.computed)(() => {
|
|
3601
|
-
|
|
3602
|
-
for (
|
|
3602
|
+
if (!Array.isArray(props.config)) return false;
|
|
3603
|
+
for (const item of props.config) if ("type" in item && item.type === "step") return true;
|
|
3603
3604
|
return false;
|
|
3604
3605
|
});
|
|
3605
3606
|
const closeHandler = () => {
|
|
@@ -3663,7 +3664,7 @@
|
|
|
3663
3664
|
span: 12,
|
|
3664
3665
|
style: { "text-align": "left" }
|
|
3665
3666
|
}, {
|
|
3666
|
-
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$
|
|
3667
|
+
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$13, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
|
|
3667
3668
|
_: 3
|
|
3668
3669
|
}), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicCol), { span: 12 }, {
|
|
3669
3670
|
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "footer", {}, () => [
|
|
@@ -3756,7 +3757,7 @@
|
|
|
3756
3757
|
});
|
|
3757
3758
|
//#endregion
|
|
3758
3759
|
//#region packages/form/src/FormDrawer.vue?vue&type=script&setup=true&lang.ts
|
|
3759
|
-
var _hoisted_1$
|
|
3760
|
+
var _hoisted_1$12 = { style: { "min-height": "1px" } };
|
|
3760
3761
|
//#endregion
|
|
3761
3762
|
//#region packages/form/src/FormDrawer.vue
|
|
3762
3763
|
var FormDrawer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
@@ -3868,7 +3869,7 @@
|
|
|
3868
3869
|
span: 12,
|
|
3869
3870
|
style: { "text-align": "left" }
|
|
3870
3871
|
}, {
|
|
3871
|
-
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$
|
|
3872
|
+
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$12, [(0, vue.renderSlot)(_ctx.$slots, "left")])]),
|
|
3872
3873
|
_: 3
|
|
3873
3874
|
}), (0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicCol), { span: 12 }, {
|
|
3874
3875
|
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "footer", {}, () => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), { onClick: handleClose }, {
|
|
@@ -4045,7 +4046,7 @@
|
|
|
4045
4046
|
});
|
|
4046
4047
|
//#endregion
|
|
4047
4048
|
//#region packages/form/src/containers/Fieldset.vue?vue&type=script&setup=true&lang.ts
|
|
4048
|
-
var _hoisted_1$
|
|
4049
|
+
var _hoisted_1$11 = ["innerHTML"];
|
|
4049
4050
|
var _hoisted_2$6 = ["innerHTML"];
|
|
4050
4051
|
var _hoisted_3$5 = { key: 1 };
|
|
4051
4052
|
var _hoisted_4$3 = ["innerHTML"];
|
|
@@ -4120,7 +4121,7 @@
|
|
|
4120
4121
|
"false-value": checkboxFalseValue.value,
|
|
4121
4122
|
"onUpdate:modelValue": valueChangeHandler
|
|
4122
4123
|
}, {
|
|
4123
|
-
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: __props.config.legend }, null, 8, _hoisted_1$
|
|
4124
|
+
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("span", { innerHTML: __props.config.legend }, null, 8, _hoisted_1$11), __props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
|
|
4124
4125
|
key: 0,
|
|
4125
4126
|
innerHTML: __props.config.extra,
|
|
4126
4127
|
class: "m-form-tip"
|
|
@@ -4257,7 +4258,7 @@
|
|
|
4257
4258
|
});
|
|
4258
4259
|
//#endregion
|
|
4259
4260
|
//#region packages/form/src/containers/Panel.vue?vue&type=script&setup=true&lang.ts
|
|
4260
|
-
var _hoisted_1$
|
|
4261
|
+
var _hoisted_1$10 = { style: {
|
|
4261
4262
|
"width": "100%",
|
|
4262
4263
|
"display": "flex",
|
|
4263
4264
|
"align-items": "center"
|
|
@@ -4309,7 +4310,7 @@
|
|
|
4309
4310
|
class: "box-card m-form-panel",
|
|
4310
4311
|
"body-style": { display: expand.value ? "block" : "none" }
|
|
4311
4312
|
}, {
|
|
4312
|
-
header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$
|
|
4313
|
+
header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_1$10, [
|
|
4313
4314
|
(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
|
|
4314
4315
|
style: { "padding": "0" },
|
|
4315
4316
|
link: "",
|
|
@@ -4432,7 +4433,7 @@
|
|
|
4432
4433
|
"disabled"
|
|
4433
4434
|
])]),
|
|
4434
4435
|
_: 1
|
|
4435
|
-
}, 8, ["span"])), [[vue.vShow, display$2.value && __props.config.type !== "hidden"]]);
|
|
4436
|
+
}, 8, ["span"])), [[vue.vShow, display$2.value && "type" in __props.config && __props.config.type !== "hidden"]]);
|
|
4436
4437
|
};
|
|
4437
4438
|
}
|
|
4438
4439
|
});
|
|
@@ -5230,7 +5231,7 @@
|
|
|
5230
5231
|
};
|
|
5231
5232
|
//#endregion
|
|
5232
5233
|
//#region packages/form/src/table/Table.vue?vue&type=script&setup=true&lang.ts
|
|
5233
|
-
var _hoisted_1$
|
|
5234
|
+
var _hoisted_1$9 = ["innerHTML"];
|
|
5234
5235
|
var _hoisted_2$4 = { style: {
|
|
5235
5236
|
"display": "flex",
|
|
5236
5237
|
"justify-content": "space-between",
|
|
@@ -5330,7 +5331,7 @@
|
|
|
5330
5331
|
key: 0,
|
|
5331
5332
|
style: { "color": "rgba(0, 0, 0, 0.45)" },
|
|
5332
5333
|
innerHTML: __props.config.extra
|
|
5333
|
-
}, null, 8, _hoisted_1$
|
|
5334
|
+
}, null, 8, _hoisted_1$9)) : (0, vue.createCommentVNode)("v-if", true),
|
|
5334
5335
|
(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicTooltip), {
|
|
5335
5336
|
content: "拖拽可排序",
|
|
5336
5337
|
placement: "left-start",
|
|
@@ -5452,7 +5453,7 @@
|
|
|
5452
5453
|
});
|
|
5453
5454
|
//#endregion
|
|
5454
5455
|
//#region packages/form/src/containers/GroupListItem.vue?vue&type=script&setup=true&lang.ts
|
|
5455
|
-
var _hoisted_1$
|
|
5456
|
+
var _hoisted_1$8 = ["innerHTML"];
|
|
5456
5457
|
var _hoisted_2$3 = { style: {
|
|
5457
5458
|
"text-align": "right",
|
|
5458
5459
|
"margin-top": "20px"
|
|
@@ -5546,7 +5547,7 @@
|
|
|
5546
5547
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicIcon), null, {
|
|
5547
5548
|
default: (0, vue.withCtx)(() => [expand.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.CaretBottom), { key: 0 })) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_element_plus_icons_vue.CaretRight), { key: 1 }))]),
|
|
5548
5549
|
_: 1
|
|
5549
|
-
}), (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_1$
|
|
5550
|
+
}), (0, vue.createElementVNode)("span", { innerHTML: title.value }, null, 8, _hoisted_1$8)]),
|
|
5550
5551
|
_: 1
|
|
5551
5552
|
}, 8, ["disabled"]),
|
|
5552
5553
|
(0, vue.withDirectives)((0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicButton), {
|
|
@@ -5669,7 +5670,7 @@
|
|
|
5669
5670
|
});
|
|
5670
5671
|
//#endregion
|
|
5671
5672
|
//#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
|
|
5672
|
-
var _hoisted_1$
|
|
5673
|
+
var _hoisted_1$7 = { class: "m-fields-group-list" };
|
|
5673
5674
|
var _hoisted_2$2 = ["innerHTML"];
|
|
5674
5675
|
var _hoisted_3$1 = {
|
|
5675
5676
|
key: 1,
|
|
@@ -5762,7 +5763,7 @@
|
|
|
5762
5763
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
5763
5764
|
const getLastValues = (item, index) => item?.[index] || {};
|
|
5764
5765
|
return (_ctx, _cache) => {
|
|
5765
|
-
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$
|
|
5766
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$7, [
|
|
5766
5767
|
__props.config.extra ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
5767
5768
|
key: 0,
|
|
5768
5769
|
innerHTML: __props.config.extra,
|
|
@@ -5828,7 +5829,7 @@
|
|
|
5828
5829
|
});
|
|
5829
5830
|
//#endregion
|
|
5830
5831
|
//#region packages/form/src/fields/Text.vue?vue&type=script&setup=true&lang.ts
|
|
5831
|
-
var _hoisted_1$
|
|
5832
|
+
var _hoisted_1$6 = { class: "m-fields-text" };
|
|
5832
5833
|
var _hoisted_2$1 = { key: 1 };
|
|
5833
5834
|
var _hoisted_3 = { style: {
|
|
5834
5835
|
"display": "flex",
|
|
@@ -5972,7 +5973,7 @@
|
|
|
5972
5973
|
instanceRef.value = void 0;
|
|
5973
5974
|
};
|
|
5974
5975
|
return (_ctx, _cache) => {
|
|
5975
|
-
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$
|
|
5976
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
|
|
5976
5977
|
modelValue: value.value,
|
|
5977
5978
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
|
|
5978
5979
|
ref_key: "input",
|
|
@@ -6099,7 +6100,7 @@
|
|
|
6099
6100
|
});
|
|
6100
6101
|
//#endregion
|
|
6101
6102
|
//#region packages/form/src/fields/NumberRange.vue?vue&type=script&setup=true&lang.ts
|
|
6102
|
-
var _hoisted_1$
|
|
6103
|
+
var _hoisted_1$5 = { class: "m-fields-number-range" };
|
|
6103
6104
|
//#endregion
|
|
6104
6105
|
//#region packages/form/src/fields/NumberRange.vue
|
|
6105
6106
|
var NumberRange_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
@@ -6139,7 +6140,7 @@
|
|
|
6139
6140
|
emit("change", [props.model[props.name][0], Number(v)]);
|
|
6140
6141
|
};
|
|
6141
6142
|
return (_ctx, _cache) => {
|
|
6142
|
-
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$
|
|
6143
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$5, [
|
|
6143
6144
|
(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicInput), {
|
|
6144
6145
|
modelValue: firstValue.value,
|
|
6145
6146
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => firstValue.value = $event),
|
|
@@ -6768,6 +6769,9 @@
|
|
|
6768
6769
|
}
|
|
6769
6770
|
});
|
|
6770
6771
|
//#endregion
|
|
6772
|
+
//#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
|
|
6773
|
+
var _hoisted_1$4 = { key: 1 };
|
|
6774
|
+
//#endregion
|
|
6771
6775
|
//#region packages/form/src/fields/RadioGroup.vue
|
|
6772
6776
|
var RadioGroup_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
6773
6777
|
name: "MFormRadioGroup",
|
|
@@ -6822,7 +6826,7 @@
|
|
|
6822
6826
|
}, {
|
|
6823
6827
|
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(option.icon)))]),
|
|
6824
6828
|
_: 2
|
|
6825
|
-
}, 1032, ["size"])) : (0, vue.createCommentVNode)("v-if", true), (0, vue.
|
|
6829
|
+
}, 1032, ["size"])) : (0, vue.createCommentVNode)("v-if", true), option.text ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$4, (0, vue.toDisplayString)(option.text), 1)) : (0, vue.createCommentVNode)("v-if", true)])]),
|
|
6826
6830
|
_: 2
|
|
6827
6831
|
}, 1032, ["disabled", "content"])]),
|
|
6828
6832
|
_: 2
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.8-beta.
|
|
2
|
+
"version": "1.7.8-beta.3",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vue": "^3.5.24",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"@tmagic/
|
|
56
|
-
"@tmagic/
|
|
57
|
-
"@tmagic/
|
|
55
|
+
"@tmagic/design": "1.7.8-beta.3",
|
|
56
|
+
"@tmagic/utils": "1.7.8-beta.3",
|
|
57
|
+
"@tmagic/form-schema": "1.7.8-beta.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"typescript": {
|
package/src/Form.vue
CHANGED
|
@@ -218,13 +218,13 @@ const getTextByName = (name: string, config: FormConfig = props.config): string
|
|
|
218
218
|
return typeof item.text === 'string' ? item.text : undefined;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
if (
|
|
221
|
+
if ('items' in item && Array.isArray(item.items)) {
|
|
222
222
|
const result = findInConfig(item.items, remainingParts);
|
|
223
223
|
if (result !== undefined) return result;
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
if (
|
|
227
|
+
if ('items' in item && Array.isArray(item.items)) {
|
|
228
228
|
const result = findInConfig(item.items, parts);
|
|
229
229
|
if (result !== undefined) return result;
|
|
230
230
|
}
|
package/src/FormDialog.vue
CHANGED
|
@@ -117,19 +117,25 @@ const stepActive = ref(1);
|
|
|
117
117
|
const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
|
|
118
118
|
|
|
119
119
|
const stepCount = computed(() => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
if (!Array.isArray(props.config)) {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (const item of props.config) {
|
|
125
|
+
if ('type' in item && item.type === 'step') {
|
|
126
|
+
return (item as StepConfig).items.length;
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
return 0;
|
|
127
130
|
});
|
|
128
131
|
|
|
129
132
|
const hasStep = computed(() => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
if (!Array.isArray(props.config)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const item of props.config) {
|
|
138
|
+
if ('type' in item && item.type === 'step') {
|
|
133
139
|
return true;
|
|
134
140
|
}
|
|
135
141
|
}
|
package/src/containers/Col.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<TMagicCol v-show="display && config.type !== 'hidden'" :span="span">
|
|
2
|
+
<TMagicCol v-show="display && 'type' in config && config.type !== 'hidden'" :span="span">
|
|
3
3
|
<Container
|
|
4
4
|
:model="model"
|
|
5
5
|
:lastValues="lastValues"
|
|
@@ -21,7 +21,7 @@ import { computed, inject } from 'vue';
|
|
|
21
21
|
|
|
22
22
|
import { TMagicCol } from '@tmagic/design';
|
|
23
23
|
|
|
24
|
-
import type {
|
|
24
|
+
import type { ContainerChangeEventData, FormItemConfig, FormState } from '../schema';
|
|
25
25
|
import { display as displayFunction } from '../utils/form';
|
|
26
26
|
|
|
27
27
|
import Container from './Container.vue';
|
|
@@ -34,8 +34,8 @@ const props = defineProps<{
|
|
|
34
34
|
model: any;
|
|
35
35
|
lastValues?: any;
|
|
36
36
|
isCompare?: boolean;
|
|
37
|
-
config:
|
|
38
|
-
labelWidth?: string;
|
|
37
|
+
config: FormItemConfig;
|
|
38
|
+
labelWidth?: string | number;
|
|
39
39
|
expandMore?: boolean;
|
|
40
40
|
span?: number;
|
|
41
41
|
size?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:data-tmagic-id="config.id"
|
|
3
|
+
:data-tmagic-id="(config as Record<string, any>).id"
|
|
4
4
|
:data-tmagic-form-item-prop="itemProp"
|
|
5
5
|
:class="`m-form-container m-container-${type || ''} ${config.className || ''}${config.tip ? ' has-tip' : ''}`"
|
|
6
6
|
:style="config.style"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<FormLabel
|
|
29
29
|
:tip="config.tip"
|
|
30
30
|
:type="type"
|
|
31
|
-
:use-label="config.useLabel"
|
|
31
|
+
:use-label="(config as CheckboxConfig).useLabel"
|
|
32
32
|
:label-title="config.labelTitle"
|
|
33
33
|
:text="text"
|
|
34
34
|
></FormLabel>
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
></component>
|
|
62
62
|
</TMagicFormItem>
|
|
63
63
|
|
|
64
|
-
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
64
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
|
|
65
65
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
66
66
|
<template #content>
|
|
67
67
|
<div v-html="config.tip"></div>
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
<FormLabel
|
|
81
81
|
:tip="config.tip"
|
|
82
82
|
:type="type"
|
|
83
|
-
:use-label="config.useLabel"
|
|
83
|
+
:use-label="(config as CheckboxConfig).useLabel"
|
|
84
84
|
:label-title="config.labelTitle"
|
|
85
85
|
:text="text"
|
|
86
86
|
></FormLabel>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<component v-else v-bind="fieldsProps" :is="tagName" :model="lastValues" @change="onChangeHandler"></component>
|
|
96
96
|
</TMagicFormItem>
|
|
97
97
|
|
|
98
|
-
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
98
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
|
|
99
99
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
100
100
|
<template #content>
|
|
101
101
|
<div v-html="config.tip"></div>
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
<FormLabel
|
|
113
113
|
:tip="config.tip"
|
|
114
114
|
:type="type"
|
|
115
|
-
:use-label="config.useLabel"
|
|
115
|
+
:use-label="(config as CheckboxConfig).useLabel"
|
|
116
116
|
:label-title="config.labelTitle"
|
|
117
117
|
:text="text"
|
|
118
118
|
></FormLabel>
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
<component v-else v-bind="fieldsProps" :is="tagName" :model="model" @change="onChangeHandler"></component>
|
|
128
128
|
</TMagicFormItem>
|
|
129
129
|
|
|
130
|
-
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
130
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !(config as CheckboxConfig).useLabel" placement="top">
|
|
131
131
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
132
132
|
<template #content>
|
|
133
133
|
<div v-html="config.tip"></div>
|
|
@@ -174,9 +174,11 @@ import { getValueByKeyPath } from '@tmagic/utils';
|
|
|
174
174
|
|
|
175
175
|
import MHidden from '../fields/Hidden.vue';
|
|
176
176
|
import type {
|
|
177
|
-
|
|
177
|
+
CheckboxConfig,
|
|
178
|
+
ComponentConfig,
|
|
178
179
|
ContainerChangeEventData,
|
|
179
180
|
ContainerCommonConfig,
|
|
181
|
+
FormItemConfig,
|
|
180
182
|
FormState,
|
|
181
183
|
FormValue,
|
|
182
184
|
ToolTipConfigType,
|
|
@@ -196,10 +198,10 @@ const props = withDefaults(
|
|
|
196
198
|
model: FormValue;
|
|
197
199
|
/** 需对比的值(开启对比模式时传入) */
|
|
198
200
|
lastValues?: FormValue;
|
|
199
|
-
config:
|
|
201
|
+
config: FormItemConfig;
|
|
200
202
|
prop?: string;
|
|
201
203
|
disabled?: boolean;
|
|
202
|
-
labelWidth?: string;
|
|
204
|
+
labelWidth?: string | number;
|
|
203
205
|
expandMore?: boolean;
|
|
204
206
|
stepActive?: string | number;
|
|
205
207
|
size?: string;
|
|
@@ -251,7 +253,7 @@ const itemProp = computed(() => {
|
|
|
251
253
|
});
|
|
252
254
|
|
|
253
255
|
const type = computed((): string => {
|
|
254
|
-
let
|
|
256
|
+
let type = 'type' in props.config ? props.config.type : '';
|
|
255
257
|
type = type && filterFunction<string>(mForm, type, props);
|
|
256
258
|
if (type === 'form') return '';
|
|
257
259
|
if (type === 'container') return '';
|
|
@@ -259,13 +261,10 @@ const type = computed((): string => {
|
|
|
259
261
|
});
|
|
260
262
|
|
|
261
263
|
const tagName = computed(() => {
|
|
262
|
-
if (type.value === 'component' && props.config.component) {
|
|
263
|
-
return props.config.component;
|
|
264
|
+
if (type.value === 'component' && (props.config as ComponentConfig).component) {
|
|
265
|
+
return (props.config as ComponentConfig).component;
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
if (!getField(type.value || 'container')) {
|
|
267
|
-
console.log(type.value, 'type.value');
|
|
268
|
-
}
|
|
269
268
|
return getField(type.value || 'container') || `m-${items.value ? 'form' : 'fields'}-${type.value}`;
|
|
270
269
|
});
|
|
271
270
|
|
|
@@ -305,7 +304,7 @@ const fieldsProps = computed(() => ({
|
|
|
305
304
|
name: name.value,
|
|
306
305
|
disabled: disabled.value,
|
|
307
306
|
prop: itemProp.value,
|
|
308
|
-
key: props.config[mForm?.keyProps],
|
|
307
|
+
key: (props.config as Record<string, any>)[mForm?.keyProps],
|
|
309
308
|
style: props.config.fieldStyle,
|
|
310
309
|
}));
|
|
311
310
|
|
|
@@ -144,7 +144,9 @@ const rowConfig = computed(() => ({
|
|
|
144
144
|
span: props.config.span || 24,
|
|
145
145
|
items: props.config.items,
|
|
146
146
|
labelWidth: props.config.labelWidth,
|
|
147
|
-
[mForm?.keyProp || '__key']: `${props.config[mForm?.keyProp || '__key']}${String(
|
|
147
|
+
[mForm?.keyProp || '__key']: `${(props.config as Record<string, any>)[mForm?.keyProp || '__key']}${String(
|
|
148
|
+
props.index,
|
|
149
|
+
)}`,
|
|
148
150
|
}));
|
|
149
151
|
|
|
150
152
|
const title = computed(() => {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<TMagicTooltip :disabled="!Boolean(option.tooltip)" placement="top-start" :content="option.tooltip">
|
|
11
11
|
<div>
|
|
12
12
|
<TMagicIcon v-if="option.icon" :size="iconSize"><component :is="option.icon"></component></TMagicIcon>
|
|
13
|
-
<span>{{ option.text }}</span>
|
|
13
|
+
<span v-if="option.text">{{ option.text }}</span>
|
|
14
14
|
</div>
|
|
15
15
|
</TMagicTooltip>
|
|
16
16
|
</component>
|
package/src/fields/Timerange.vue
CHANGED
|
@@ -21,7 +21,7 @@ import dayjs from 'dayjs';
|
|
|
21
21
|
|
|
22
22
|
import { TMagicTimePicker } from '@tmagic/design';
|
|
23
23
|
|
|
24
|
-
import type { ChangeRecord,
|
|
24
|
+
import type { ChangeRecord, FieldProps, TimerangeConfig } from '../schema';
|
|
25
25
|
import { datetimeFormatter } from '../utils/form';
|
|
26
26
|
import { useAddField } from '../utils/useAddField';
|
|
27
27
|
|
|
@@ -29,7 +29,7 @@ defineOptions({
|
|
|
29
29
|
name: 'MFormTimeRange',
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
const props = defineProps<FieldProps<
|
|
32
|
+
const props = defineProps<FieldProps<TimerangeConfig>>();
|
|
33
33
|
|
|
34
34
|
const emit = defineEmits(['change']);
|
|
35
35
|
|
package/src/table/useAdd.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, inject } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { tMagicMessage } from '@tmagic/design';
|
|
4
|
-
import type { FormState } from '@tmagic/form-schema';
|
|
4
|
+
import type { FormConfig, FormState } from '@tmagic/form-schema';
|
|
5
5
|
|
|
6
6
|
import { initValue } from '../utils/form';
|
|
7
7
|
|
|
@@ -86,7 +86,7 @@ export const useAdd = (
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
inputs = await initValue(mForm, {
|
|
89
|
-
config: columns,
|
|
89
|
+
config: columns as FormConfig,
|
|
90
90
|
initValues: inputs,
|
|
91
91
|
});
|
|
92
92
|
}
|
|
@@ -3,7 +3,7 @@ import { WarningFilled } from '@element-plus/icons-vue';
|
|
|
3
3
|
import { cloneDeep } from 'lodash-es';
|
|
4
4
|
|
|
5
5
|
import { type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
6
|
-
import type { FormState, TableColumnConfig } from '@tmagic/form-schema';
|
|
6
|
+
import type { FormItemConfig, FormState, TableColumnConfig } from '@tmagic/form-schema';
|
|
7
7
|
|
|
8
8
|
import Container from '../containers/Container.vue';
|
|
9
9
|
import type { ContainerChangeEventData } from '../schema';
|
|
@@ -68,7 +68,7 @@ export const useTableColumns = (
|
|
|
68
68
|
return `${props.prop}${props.prop ? '.' : ''}${index + 1 + currentPage.value * pageSize.value - 1}`;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
const makeConfig = (config: TableColumnConfig, row: any) => {
|
|
71
|
+
const makeConfig = (config: TableColumnConfig, row: any): TableColumnConfig => {
|
|
72
72
|
const newConfig = cloneDeep(config);
|
|
73
73
|
if (typeof config.itemsFunction === 'function') {
|
|
74
74
|
newConfig.items = config.itemsFunction(row);
|
|
@@ -199,7 +199,7 @@ export const useTableColumns = (
|
|
|
199
199
|
disabled: props.disabled,
|
|
200
200
|
prop: getProp($index),
|
|
201
201
|
rules: column.rules,
|
|
202
|
-
config: makeConfig(column, row),
|
|
202
|
+
config: makeConfig(column, row) as FormItemConfig,
|
|
203
203
|
model: row,
|
|
204
204
|
lastValues: lastData.value[$index],
|
|
205
205
|
isCompare: props.isCompare,
|
package/src/utils/form.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
23
23
|
|
|
24
24
|
import { getValueByKeyPath } from '@tmagic/utils';
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import type {
|
|
27
27
|
ChildConfig,
|
|
28
28
|
ContainerCommonConfig,
|
|
29
29
|
DaterangeConfig,
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
HtmlField,
|
|
35
35
|
Rule,
|
|
36
36
|
SortProp,
|
|
37
|
+
TableConfig,
|
|
37
38
|
TabPaneConfig,
|
|
38
39
|
TypeFunction,
|
|
39
40
|
} from '../schema';
|
|
@@ -118,7 +119,8 @@ const initValueItem = function (
|
|
|
118
119
|
) {
|
|
119
120
|
const { items } = item as ContainerCommonConfig;
|
|
120
121
|
const { names } = item as DaterangeConfig;
|
|
121
|
-
const
|
|
122
|
+
const type = 'type' in item ? item.type : '';
|
|
123
|
+
const { name } = item;
|
|
122
124
|
|
|
123
125
|
if (isTableSelect(type) && name) {
|
|
124
126
|
value[name] = initValue[name] ?? '';
|
|
@@ -148,14 +150,15 @@ const initValueItem = function (
|
|
|
148
150
|
setValue(mForm, value, initValue, item);
|
|
149
151
|
|
|
150
152
|
if (type === 'table') {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const tableConfig = item as TableConfig;
|
|
154
|
+
if (tableConfig.defautSort) {
|
|
155
|
+
sortChange(value[name], tableConfig.defautSort);
|
|
156
|
+
} else if (tableConfig.defaultSort) {
|
|
157
|
+
sortChange(value[name], tableConfig.defaultSort);
|
|
155
158
|
}
|
|
156
159
|
|
|
157
|
-
if (
|
|
158
|
-
value[name].sort((a: any, b: any) => b[
|
|
160
|
+
if (tableConfig.sort && tableConfig.sortKey) {
|
|
161
|
+
value[name].sort((a: any, b: any) => b[tableConfig.sortKey!] - a[tableConfig.sortKey!]);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
|
|
@@ -169,8 +172,8 @@ export const createValues = function (
|
|
|
169
172
|
value: FormValue = {},
|
|
170
173
|
) {
|
|
171
174
|
if (Array.isArray(config)) {
|
|
172
|
-
config.forEach((item
|
|
173
|
-
initValueItem(mForm, item, initValue, value);
|
|
175
|
+
config.forEach((item) => {
|
|
176
|
+
initValueItem(mForm, item as ChildConfig | TabPaneConfig, initValue, value);
|
|
174
177
|
});
|
|
175
178
|
}
|
|
176
179
|
|
package/types/index.d.ts
CHANGED
|
@@ -917,10 +917,10 @@ type __VLS_WithSlots$2<T, S> = T & {
|
|
|
917
917
|
type __VLS_Props$26 = {
|
|
918
918
|
/** 表单值 */model: schema_d_exports.FormValue; /** 需对比的值(开启对比模式时传入) */
|
|
919
919
|
lastValues?: schema_d_exports.FormValue;
|
|
920
|
-
config: schema_d_exports.
|
|
920
|
+
config: schema_d_exports.FormItemConfig;
|
|
921
921
|
prop?: string;
|
|
922
922
|
disabled?: boolean;
|
|
923
|
-
labelWidth?: string;
|
|
923
|
+
labelWidth?: string | number;
|
|
924
924
|
expandMore?: boolean;
|
|
925
925
|
stepActive?: string | number;
|
|
926
926
|
size?: string; /** 是否开启对比模式 */
|
|
@@ -1248,7 +1248,7 @@ declare const __VLS_export$9: _vue_runtime_core0.DefineComponent<__VLS_Props$9,
|
|
|
1248
1248
|
declare const _default$7: typeof __VLS_export$9;
|
|
1249
1249
|
//#endregion
|
|
1250
1250
|
//#region temp/packages/form/src/fields/Timerange.vue.d.ts
|
|
1251
|
-
type __VLS_Props$8 = schema_d_exports.FieldProps<schema_d_exports.
|
|
1251
|
+
type __VLS_Props$8 = schema_d_exports.FieldProps<schema_d_exports.TimerangeConfig>;
|
|
1252
1252
|
declare const __VLS_export$8: _vue_runtime_core0.DefineComponent<__VLS_Props$8, {}, {}, {}, {}, _vue_runtime_core0.ComponentOptionsMixin, _vue_runtime_core0.ComponentOptionsMixin, {
|
|
1253
1253
|
change: (...args: any[]) => void;
|
|
1254
1254
|
}, string, _vue_runtime_core0.PublicProps, Readonly<__VLS_Props$8> & Readonly<{
|