@tmagic/form 1.7.6 → 1.7.8-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +235 -164
- package/dist/es/Form.js +5 -0
- package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +234 -0
- package/dist/es/FormBox.js +5 -0
- package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/es/FormDialog.js +5 -0
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +222 -0
- package/dist/es/FormDrawer.js +5 -0
- package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +176 -0
- package/dist/es/_virtual/_rolldown/runtime.js +27 -0
- package/dist/es/containers/Col.js +5 -0
- package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/containers/Container.js +5 -0
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +439 -0
- package/dist/es/containers/Fieldset.js +5 -0
- package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +153 -0
- package/dist/es/containers/FlexLayout.js +5 -0
- package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/es/containers/FormLabel.js +5 -0
- package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/es/containers/GroupList.js +5 -0
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/es/containers/GroupListItem.js +5 -0
- package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +221 -0
- package/dist/es/containers/Panel.js +5 -0
- package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/es/containers/Row.js +5 -0
- package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/es/containers/Step.js +5 -0
- package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +85 -0
- package/dist/es/containers/Tabs.js +5 -0
- package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +194 -0
- package/dist/es/fields/Cascader.js +5 -0
- package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +123 -0
- package/dist/es/fields/Checkbox.js +5 -0
- package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/es/fields/CheckboxGroup.js +5 -0
- package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/es/fields/ColorPicker.js +5 -0
- package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/es/fields/Date.js +5 -0
- package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/es/fields/DateTime.js +5 -0
- package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/es/fields/Daterange.js +5 -0
- package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +99 -0
- package/dist/es/fields/Display.js +5 -0
- package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/es/fields/DynamicField.js +5 -0
- package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +91 -0
- package/dist/es/fields/Hidden.js +5 -0
- package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/es/fields/Link.js +5 -0
- package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/es/fields/Number.js +5 -0
- package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/es/fields/NumberRange.js +5 -0
- package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/es/fields/RadioGroup.js +5 -0
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/es/fields/Select.js +5 -0
- package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +337 -0
- package/dist/es/fields/Switch.js +5 -0
- package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/es/fields/Text.js +5 -0
- package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +215 -0
- package/dist/es/fields/Textarea.js +5 -0
- package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/fields/Time.js +5 -0
- package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/es/fields/Timerange.js +5 -0
- package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/es/index.js +41 -0
- package/dist/es/plugin.js +74 -0
- package/dist/es/schema.js +2 -0
- package/dist/es/style.css +325 -0
- package/dist/es/table/ActionsColumn.js +5 -0
- package/dist/es/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/es/table/SortColumn.js +5 -0
- package/dist/es/table/SortColumn.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/es/table/Table.js +5 -0
- package/dist/es/table/Table.vue_vue_type_script_setup_true_lang.js +232 -0
- package/dist/es/table/useAdd.js +71 -0
- package/dist/es/table/useFullscreen.js +15 -0
- package/dist/es/table/useImport.js +46 -0
- package/dist/es/table/usePagination.js +26 -0
- package/dist/es/table/useSelection.js +26 -0
- package/dist/es/table/useSortable.js +39 -0
- package/dist/es/table/useTableColumns.js +160 -0
- package/dist/es/utils/config.js +15 -0
- package/dist/es/utils/form.js +173 -0
- package/dist/es/utils/useAddField.js +13 -0
- package/dist/style.css +1 -1
- package/dist/tmagic-form.umd.cjs +7693 -8885
- package/package.json +7 -6
- package/src/containers/Container.vue +16 -10
- package/src/fields/Hidden.vue +6 -2
- package/src/fields/Timerange.vue +80 -36
- package/src/index.ts +8 -82
- package/src/plugin.ts +102 -0
- package/src/table/useSortable.ts +8 -4
- package/src/utils/config.ts +16 -1
- package/types/index.d.ts +1264 -1226
- package/dist/tmagic-form.js +0 -5901
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
|
|
2
|
+
import { TMagicIcon, TMagicTooltip } from "@tmagic/design";
|
|
3
|
+
import { WarningFilled } from "@element-plus/icons-vue";
|
|
4
|
+
//#region packages/form/src/containers/FormLabel.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _hoisted_1 = {
|
|
6
|
+
key: 0,
|
|
7
|
+
style: {
|
|
8
|
+
"display": "inline-flex",
|
|
9
|
+
"align-items": "center"
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var _hoisted_2 = ["innerHTML", "title"];
|
|
13
|
+
var _hoisted_3 = ["innerHTML"];
|
|
14
|
+
var _hoisted_4 = ["innerHTML", "title"];
|
|
15
|
+
var FormLabel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
16
|
+
__name: "FormLabel",
|
|
17
|
+
props: {
|
|
18
|
+
tip: {},
|
|
19
|
+
type: {},
|
|
20
|
+
useLabel: { type: Boolean },
|
|
21
|
+
text: {},
|
|
22
|
+
labelTitle: {}
|
|
23
|
+
},
|
|
24
|
+
setup(__props) {
|
|
25
|
+
return (_ctx, _cache) => {
|
|
26
|
+
return __props.tip ? (openBlock(), createElementBlock("span", _hoisted_1, [createElementVNode("span", {
|
|
27
|
+
innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
|
|
28
|
+
title: __props.labelTitle
|
|
29
|
+
}, null, 8, _hoisted_2), __props.tip && (__props.type !== "checkbox" || __props.useLabel) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
30
|
+
key: 0,
|
|
31
|
+
placement: "top"
|
|
32
|
+
}, {
|
|
33
|
+
content: withCtx(() => [createElementVNode("div", { innerHTML: __props.tip }, null, 8, _hoisted_3)]),
|
|
34
|
+
default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
|
|
35
|
+
"margin-left": "5px",
|
|
36
|
+
"display": "flex"
|
|
37
|
+
} }, {
|
|
38
|
+
default: withCtx(() => [createVNode(unref(WarningFilled))]),
|
|
39
|
+
_: 1
|
|
40
|
+
})]),
|
|
41
|
+
_: 1
|
|
42
|
+
})) : createCommentVNode("v-if", true)])) : (openBlock(), createElementBlock("span", {
|
|
43
|
+
key: 1,
|
|
44
|
+
innerHTML: __props.type === "checkbox" && !__props.useLabel ? "" : __props.text,
|
|
45
|
+
title: __props.labelTitle
|
|
46
|
+
}, null, 8, _hoisted_4));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { FormLabel_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import GroupList_vue_vue_type_script_setup_true_lang_default from "./GroupList.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/GroupList.vue
|
|
3
|
+
var GroupList_default = GroupList_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { GroupList_default as default };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { initValue } from "../utils/form.js";
|
|
2
|
+
import GroupListItem_default from "./GroupListItem.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, inject, mergeProps, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
4
|
+
import { cloneDeep } from "lodash-es";
|
|
5
|
+
import { TMagicButton } from "@tmagic/design";
|
|
6
|
+
import { Grid, Plus } from "@element-plus/icons-vue";
|
|
7
|
+
//#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
var _hoisted_1 = { class: "m-fields-group-list" };
|
|
9
|
+
var _hoisted_2 = ["innerHTML"];
|
|
10
|
+
var _hoisted_3 = {
|
|
11
|
+
key: 1,
|
|
12
|
+
class: "el-table__empty-block"
|
|
13
|
+
};
|
|
14
|
+
var _hoisted_4 = { class: "m-fields-group-list-footer" };
|
|
15
|
+
var _hoisted_5 = { style: {
|
|
16
|
+
"display": "flex",
|
|
17
|
+
"justify-content": "flex-end",
|
|
18
|
+
"flex": "1"
|
|
19
|
+
} };
|
|
20
|
+
var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
21
|
+
name: "MFormGroupList",
|
|
22
|
+
__name: "GroupList",
|
|
23
|
+
props: {
|
|
24
|
+
model: {},
|
|
25
|
+
lastValues: {},
|
|
26
|
+
isCompare: { type: Boolean },
|
|
27
|
+
config: {},
|
|
28
|
+
name: {},
|
|
29
|
+
labelWidth: {},
|
|
30
|
+
prop: {},
|
|
31
|
+
size: {},
|
|
32
|
+
disabled: { type: Boolean }
|
|
33
|
+
},
|
|
34
|
+
emits: ["change", "addDiffCount"],
|
|
35
|
+
setup(__props, { emit: __emit }) {
|
|
36
|
+
const props = __props;
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const mForm = inject("mForm");
|
|
39
|
+
const addable = computed(() => {
|
|
40
|
+
if (!props.name) return false;
|
|
41
|
+
if (typeof props.config.addable === "function") return props.config.addable(mForm, {
|
|
42
|
+
model: props.model[props.name],
|
|
43
|
+
formValue: mForm?.values,
|
|
44
|
+
prop: props.prop,
|
|
45
|
+
config: props.config
|
|
46
|
+
});
|
|
47
|
+
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
48
|
+
});
|
|
49
|
+
const changeHandler = (v, eventData) => {
|
|
50
|
+
emit("change", props.model, eventData);
|
|
51
|
+
};
|
|
52
|
+
const addHandler = async () => {
|
|
53
|
+
if (!props.name) return false;
|
|
54
|
+
let initValues = {};
|
|
55
|
+
if (typeof props.config.defaultAdd === "function") initValues = await props.config.defaultAdd(mForm, {
|
|
56
|
+
model: props.model[props.name],
|
|
57
|
+
formValue: mForm?.values,
|
|
58
|
+
prop: props.prop,
|
|
59
|
+
config: props.config
|
|
60
|
+
});
|
|
61
|
+
else if (props.config.defaultAdd) initValues = props.config.defaultAdd;
|
|
62
|
+
const groupValue = await initValue(mForm, {
|
|
63
|
+
config: props.config.items,
|
|
64
|
+
initValues
|
|
65
|
+
});
|
|
66
|
+
props.model[props.name].push(groupValue);
|
|
67
|
+
emit("change", props.model[props.name], { changeRecords: [{
|
|
68
|
+
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
69
|
+
value: groupValue
|
|
70
|
+
}] });
|
|
71
|
+
};
|
|
72
|
+
const removeHandler = (index) => {
|
|
73
|
+
if (!props.name) return false;
|
|
74
|
+
props.model[props.name].splice(index, 1);
|
|
75
|
+
emit("change", props.model[props.name]);
|
|
76
|
+
};
|
|
77
|
+
const copyHandler = (index) => {
|
|
78
|
+
props.model[props.name].push(cloneDeep(props.model[props.name][index]));
|
|
79
|
+
};
|
|
80
|
+
const swapHandler = (idx1, idx2) => {
|
|
81
|
+
if (!props.name) return false;
|
|
82
|
+
const { length } = props.model[props.name];
|
|
83
|
+
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
84
|
+
props.model[props.name].splice(Math.min(Math.max(idx2, 0), length - 1), 0, currRow);
|
|
85
|
+
emit("change", props.model[props.name]);
|
|
86
|
+
};
|
|
87
|
+
const toggleMode = () => {
|
|
88
|
+
props.config.type = "table";
|
|
89
|
+
props.config.groupItems = props.config.items;
|
|
90
|
+
props.config.items = props.config.tableItems || props.config.items.map((item) => ({
|
|
91
|
+
...item,
|
|
92
|
+
label: item.label || item.text,
|
|
93
|
+
text: null
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
const onAddDiffCount = () => emit("addDiffCount");
|
|
97
|
+
const getLastValues = (item, index) => item?.[index] || {};
|
|
98
|
+
return (_ctx, _cache) => {
|
|
99
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
100
|
+
__props.config.extra ? (openBlock(), createElementBlock("div", {
|
|
101
|
+
key: 0,
|
|
102
|
+
innerHTML: __props.config.extra,
|
|
103
|
+
style: { "color": "rgba(0, 0, 0, 0.45)" }
|
|
104
|
+
}, null, 8, _hoisted_2)) : createCommentVNode("v-if", true),
|
|
105
|
+
!__props.model[__props.name] || !__props.model[__props.name].length ? (openBlock(), createElementBlock("div", _hoisted_3, [..._cache[1] || (_cache[1] = [createElementVNode("span", { class: "el-table__empty-text t-table__empty" }, "暂无数据", -1)])])) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(__props.model[__props.name], (item, index) => {
|
|
106
|
+
return openBlock(), createBlock(GroupListItem_default, {
|
|
107
|
+
key: index,
|
|
108
|
+
model: item,
|
|
109
|
+
lastValues: getLastValues(__props.lastValues[__props.name], Number(index)),
|
|
110
|
+
"is-compare": __props.isCompare,
|
|
111
|
+
config: __props.config,
|
|
112
|
+
prop: __props.prop,
|
|
113
|
+
index: Number(index),
|
|
114
|
+
"label-width": __props.labelWidth,
|
|
115
|
+
size: __props.size,
|
|
116
|
+
disabled: __props.disabled,
|
|
117
|
+
"group-model": __props.model[__props.name],
|
|
118
|
+
onRemoveItem: removeHandler,
|
|
119
|
+
onCopyItem: copyHandler,
|
|
120
|
+
onSwapItem: swapHandler,
|
|
121
|
+
onChange: changeHandler,
|
|
122
|
+
onAddDiffCount: _cache[0] || (_cache[0] = ($event) => onAddDiffCount())
|
|
123
|
+
}, null, 8, [
|
|
124
|
+
"model",
|
|
125
|
+
"lastValues",
|
|
126
|
+
"is-compare",
|
|
127
|
+
"config",
|
|
128
|
+
"prop",
|
|
129
|
+
"index",
|
|
130
|
+
"label-width",
|
|
131
|
+
"size",
|
|
132
|
+
"disabled",
|
|
133
|
+
"group-model"
|
|
134
|
+
]);
|
|
135
|
+
}), 128)),
|
|
136
|
+
createElementVNode("div", _hoisted_4, [__props.config.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
137
|
+
key: 0,
|
|
138
|
+
icon: unref(Grid),
|
|
139
|
+
size: "small",
|
|
140
|
+
onClick: toggleMode
|
|
141
|
+
}, {
|
|
142
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("切换为表格", -1)])]),
|
|
143
|
+
_: 1
|
|
144
|
+
}, 8, ["icon"])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_5, [addable.value ? (openBlock(), createBlock(unref(TMagicButton), mergeProps({
|
|
145
|
+
key: 0,
|
|
146
|
+
size: __props.config.enableToggleMode ? "small" : "default",
|
|
147
|
+
icon: unref(Plus)
|
|
148
|
+
}, __props.config.addButtonConfig?.props || { type: "primary" }, {
|
|
149
|
+
disabled: __props.disabled,
|
|
150
|
+
onClick: addHandler
|
|
151
|
+
}), {
|
|
152
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.config.addButtonConfig?.text || "新增"), 1)]),
|
|
153
|
+
_: 1
|
|
154
|
+
}, 16, [
|
|
155
|
+
"size",
|
|
156
|
+
"icon",
|
|
157
|
+
"disabled"
|
|
158
|
+
])) : createCommentVNode("v-if", true)])])
|
|
159
|
+
]);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
//#endregion
|
|
164
|
+
export { GroupList_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import GroupListItem_vue_vue_type_script_setup_true_lang_default from "./GroupListItem.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/GroupListItem.vue
|
|
3
|
+
var GroupListItem_default = GroupListItem_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { GroupListItem_default as default };
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { filterFunction } from "../utils/form.js";
|
|
2
|
+
import Container_default from "./Container.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, openBlock, ref, unref, vShow, withCtx, withDirectives } from "vue";
|
|
4
|
+
import { TMagicButton, TMagicCard, TMagicIcon, TMagicInputNumber, TMagicPopover } from "@tmagic/design";
|
|
5
|
+
import { CaretBottom, CaretRight, CaretTop, Delete, DocumentCopy, Position } from "@element-plus/icons-vue";
|
|
6
|
+
//#region packages/form/src/containers/GroupListItem.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var _hoisted_1 = ["innerHTML"];
|
|
8
|
+
var _hoisted_2 = { style: {
|
|
9
|
+
"text-align": "right",
|
|
10
|
+
"margin-top": "20px"
|
|
11
|
+
} };
|
|
12
|
+
var _hoisted_3 = ["innerHTML"];
|
|
13
|
+
var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
14
|
+
name: "MFormGroupListItem",
|
|
15
|
+
__name: "GroupListItem",
|
|
16
|
+
props: {
|
|
17
|
+
model: {},
|
|
18
|
+
lastValues: {},
|
|
19
|
+
isCompare: { type: Boolean },
|
|
20
|
+
groupModel: {},
|
|
21
|
+
config: {},
|
|
22
|
+
labelWidth: {},
|
|
23
|
+
prop: {},
|
|
24
|
+
size: {},
|
|
25
|
+
index: {},
|
|
26
|
+
disabled: { type: Boolean }
|
|
27
|
+
},
|
|
28
|
+
emits: [
|
|
29
|
+
"swap-item",
|
|
30
|
+
"remove-item",
|
|
31
|
+
"change",
|
|
32
|
+
"addDiffCount",
|
|
33
|
+
"copy-item"
|
|
34
|
+
],
|
|
35
|
+
setup(__props, { emit: __emit }) {
|
|
36
|
+
const props = __props;
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const mForm = inject("mForm");
|
|
39
|
+
const defaultExpandQuantity = props.config.defaultExpandQuantity ?? 7;
|
|
40
|
+
const expand = ref(props.config.expandAll || defaultExpandQuantity > props.index);
|
|
41
|
+
const rowConfig = computed(() => ({
|
|
42
|
+
type: "row",
|
|
43
|
+
span: props.config.span || 24,
|
|
44
|
+
items: props.config.items,
|
|
45
|
+
labelWidth: props.config.labelWidth,
|
|
46
|
+
[mForm?.keyProp || "__key"]: `${props.config[mForm?.keyProp || "__key"]}${String(props.index)}`
|
|
47
|
+
}));
|
|
48
|
+
const title = computed(() => {
|
|
49
|
+
if (props.config.titleKey && props.model[props.config.titleKey]) return props.model[props.config.titleKey];
|
|
50
|
+
if (props.config.title) return filterFunction(mForm, props.config.title, props);
|
|
51
|
+
return `${props.config.titlePrefix || "组"} ${String(props.index + 1)}`;
|
|
52
|
+
});
|
|
53
|
+
const length = computed(() => props.groupModel?.length || 0);
|
|
54
|
+
const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
55
|
+
const removeHandler = () => emit("remove-item", props.index);
|
|
56
|
+
const changeHandler = (v, eventData) => {
|
|
57
|
+
emit("change", props.model, eventData);
|
|
58
|
+
};
|
|
59
|
+
const expandHandler = () => {
|
|
60
|
+
expand.value = !expand.value;
|
|
61
|
+
};
|
|
62
|
+
const showDelete = computed(() => {
|
|
63
|
+
const deleteFunc = props.config.delete;
|
|
64
|
+
if (deleteFunc && typeof deleteFunc === "function") return deleteFunc(props.model, props.index, mForm?.values);
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
const changeOrder = (offset = 0) => emit("swap-item", props.index, props.index + offset);
|
|
68
|
+
const movable = computed(() => {
|
|
69
|
+
const { movable } = props.config;
|
|
70
|
+
if (movable === void 0) return true;
|
|
71
|
+
if (typeof movable === "function") return movable(mForm, props.index || 0, props.model, props.groupModel);
|
|
72
|
+
return movable;
|
|
73
|
+
});
|
|
74
|
+
const copyable = computed(() => filterFunction(mForm, props.config.copyable, props));
|
|
75
|
+
const onAddDiffCount = () => emit("addDiffCount");
|
|
76
|
+
const copyHandler = () => {
|
|
77
|
+
emit("copy-item", props.index);
|
|
78
|
+
};
|
|
79
|
+
const moveSpecifyLocationVisible = ref(false);
|
|
80
|
+
const moveSpecifyLocationIndex = ref(1);
|
|
81
|
+
const moveSpecifyLocationHandler = () => {
|
|
82
|
+
moveSpecifyLocationVisible.value = false;
|
|
83
|
+
emit("swap-item", props.index, moveSpecifyLocationIndex.value - 1);
|
|
84
|
+
};
|
|
85
|
+
return (_ctx, _cache) => {
|
|
86
|
+
return openBlock(), createBlock(unref(TMagicCard), {
|
|
87
|
+
class: "m-fields-group-list-item",
|
|
88
|
+
"body-style": { display: expand.value ? "block" : "none" }
|
|
89
|
+
}, {
|
|
90
|
+
header: withCtx(() => [createElementVNode("div", null, [
|
|
91
|
+
createVNode(unref(TMagicButton), {
|
|
92
|
+
link: "",
|
|
93
|
+
disabled: __props.disabled,
|
|
94
|
+
onClick: expandHandler
|
|
95
|
+
}, {
|
|
96
|
+
default: withCtx(() => [createVNode(unref(TMagicIcon), null, {
|
|
97
|
+
default: withCtx(() => [expand.value ? (openBlock(), createBlock(unref(CaretBottom), { key: 0 })) : (openBlock(), createBlock(unref(CaretRight), { key: 1 }))]),
|
|
98
|
+
_: 1
|
|
99
|
+
}), createElementVNode("span", { innerHTML: title.value }, null, 8, _hoisted_1)]),
|
|
100
|
+
_: 1
|
|
101
|
+
}, 8, ["disabled"]),
|
|
102
|
+
withDirectives(createVNode(unref(TMagicButton), {
|
|
103
|
+
type: "danger",
|
|
104
|
+
size: "small",
|
|
105
|
+
link: "",
|
|
106
|
+
icon: unref(Delete),
|
|
107
|
+
disabled: __props.disabled,
|
|
108
|
+
onClick: removeHandler
|
|
109
|
+
}, null, 8, ["icon", "disabled"]), [[vShow, showDelete.value]]),
|
|
110
|
+
copyable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
111
|
+
key: 0,
|
|
112
|
+
link: "",
|
|
113
|
+
size: "small",
|
|
114
|
+
type: "primary",
|
|
115
|
+
icon: unref(DocumentCopy),
|
|
116
|
+
disabled: __props.disabled,
|
|
117
|
+
onClick: copyHandler
|
|
118
|
+
}, {
|
|
119
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("复制", -1)])]),
|
|
120
|
+
_: 1
|
|
121
|
+
}, 8, ["icon", "disabled"])) : createCommentVNode("v-if", true),
|
|
122
|
+
movable.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [withDirectives(createVNode(unref(TMagicButton), {
|
|
123
|
+
link: "",
|
|
124
|
+
size: "small",
|
|
125
|
+
disabled: __props.disabled,
|
|
126
|
+
icon: unref(CaretTop),
|
|
127
|
+
onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
|
|
128
|
+
}, {
|
|
129
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("上移", -1)])]),
|
|
130
|
+
_: 1
|
|
131
|
+
}, 8, ["disabled", "icon"]), [[vShow, __props.index !== 0]]), withDirectives(createVNode(unref(TMagicButton), {
|
|
132
|
+
link: "",
|
|
133
|
+
size: "small",
|
|
134
|
+
disabled: __props.disabled,
|
|
135
|
+
icon: unref(CaretBottom),
|
|
136
|
+
onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
|
|
137
|
+
}, {
|
|
138
|
+
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("下移", -1)])]),
|
|
139
|
+
_: 1
|
|
140
|
+
}, 8, ["disabled", "icon"]), [[vShow, __props.index !== length.value - 1]])], 64)) : createCommentVNode("v-if", true),
|
|
141
|
+
__props.config.moveSpecifyLocation ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
142
|
+
key: 2,
|
|
143
|
+
trigger: "click",
|
|
144
|
+
placement: "top",
|
|
145
|
+
width: "200",
|
|
146
|
+
visible: moveSpecifyLocationVisible.value
|
|
147
|
+
}, {
|
|
148
|
+
reference: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
149
|
+
link: "",
|
|
150
|
+
size: "small",
|
|
151
|
+
type: "primary",
|
|
152
|
+
icon: unref(Position),
|
|
153
|
+
disabled: __props.disabled,
|
|
154
|
+
onClick: _cache[2] || (_cache[2] = ($event) => moveSpecifyLocationVisible.value = true)
|
|
155
|
+
}, {
|
|
156
|
+
default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode("移动至", -1)])]),
|
|
157
|
+
_: 1
|
|
158
|
+
}, 8, ["icon", "disabled"])]),
|
|
159
|
+
default: withCtx(() => [createElementVNode("div", null, [createElementVNode("div", null, [
|
|
160
|
+
_cache[10] || (_cache[10] = createTextVNode(" 第", -1)),
|
|
161
|
+
createVNode(unref(TMagicInputNumber), {
|
|
162
|
+
style: { "margin": "0 5px" },
|
|
163
|
+
modelValue: moveSpecifyLocationIndex.value,
|
|
164
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => moveSpecifyLocationIndex.value = $event),
|
|
165
|
+
size: "small",
|
|
166
|
+
min: 1,
|
|
167
|
+
disabled: __props.disabled
|
|
168
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
169
|
+
_cache[11] || (_cache[11] = createTextVNode("行 ", -1))
|
|
170
|
+
]), createElementVNode("div", _hoisted_2, [createVNode(unref(TMagicButton), {
|
|
171
|
+
size: "small",
|
|
172
|
+
text: "",
|
|
173
|
+
onClick: _cache[4] || (_cache[4] = ($event) => moveSpecifyLocationVisible.value = false)
|
|
174
|
+
}, {
|
|
175
|
+
default: withCtx(() => [..._cache[12] || (_cache[12] = [createTextVNode("取消", -1)])]),
|
|
176
|
+
_: 1
|
|
177
|
+
}), createVNode(unref(TMagicButton), {
|
|
178
|
+
size: "small",
|
|
179
|
+
type: "primary",
|
|
180
|
+
onClick: moveSpecifyLocationHandler
|
|
181
|
+
}, {
|
|
182
|
+
default: withCtx(() => [..._cache[13] || (_cache[13] = [createTextVNode("确认", -1)])]),
|
|
183
|
+
_: 1
|
|
184
|
+
})])])]),
|
|
185
|
+
_: 1
|
|
186
|
+
}, 8, ["visible"])) : createCommentVNode("v-if", true),
|
|
187
|
+
itemExtra.value ? (openBlock(), createElementBlock("span", {
|
|
188
|
+
key: 3,
|
|
189
|
+
innerHTML: itemExtra.value,
|
|
190
|
+
class: "m-form-tip"
|
|
191
|
+
}, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
192
|
+
])]),
|
|
193
|
+
default: withCtx(() => [expand.value ? (openBlock(), createBlock(Container_default, {
|
|
194
|
+
key: 0,
|
|
195
|
+
config: rowConfig.value,
|
|
196
|
+
model: __props.model,
|
|
197
|
+
lastValues: __props.lastValues,
|
|
198
|
+
"is-compare": __props.isCompare,
|
|
199
|
+
labelWidth: __props.labelWidth,
|
|
200
|
+
prop: `${__props.prop}${__props.prop ? "." : ""}${String(__props.index)}`,
|
|
201
|
+
size: __props.size,
|
|
202
|
+
disabled: __props.disabled,
|
|
203
|
+
onChange: changeHandler,
|
|
204
|
+
onAddDiffCount: _cache[5] || (_cache[5] = ($event) => onAddDiffCount())
|
|
205
|
+
}, null, 8, [
|
|
206
|
+
"config",
|
|
207
|
+
"model",
|
|
208
|
+
"lastValues",
|
|
209
|
+
"is-compare",
|
|
210
|
+
"labelWidth",
|
|
211
|
+
"prop",
|
|
212
|
+
"size",
|
|
213
|
+
"disabled"
|
|
214
|
+
])) : createCommentVNode("v-if", true)]),
|
|
215
|
+
_: 1
|
|
216
|
+
}, 8, ["body-style"]);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
//#endregion
|
|
221
|
+
export { GroupListItem_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Panel_vue_vue_type_script_setup_true_lang_default from "./Panel.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/Panel.vue
|
|
3
|
+
var Panel_default = Panel_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Panel_default as default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { filterFunction } from "../utils/form.js";
|
|
2
|
+
import Container_default from "./Container.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, openBlock, ref, renderList, renderSlot, toDisplayString, unref, withCtx } from "vue";
|
|
4
|
+
import { TMagicButton, TMagicCard } from "@tmagic/design";
|
|
5
|
+
import { CaretBottom, CaretRight } from "@element-plus/icons-vue";
|
|
6
|
+
//#region packages/form/src/containers/Panel.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var _hoisted_1 = { style: {
|
|
8
|
+
"width": "100%",
|
|
9
|
+
"display": "flex",
|
|
10
|
+
"align-items": "center"
|
|
11
|
+
} };
|
|
12
|
+
var _hoisted_2 = ["innerHTML"];
|
|
13
|
+
var _hoisted_3 = {
|
|
14
|
+
key: 0,
|
|
15
|
+
style: { "display": "flex" }
|
|
16
|
+
};
|
|
17
|
+
var _hoisted_4 = { style: { "flex": "1" } };
|
|
18
|
+
var _hoisted_5 = ["src"];
|
|
19
|
+
var Panel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
20
|
+
name: "MFormPanel",
|
|
21
|
+
__name: "Panel",
|
|
22
|
+
props: {
|
|
23
|
+
model: {},
|
|
24
|
+
lastValues: {},
|
|
25
|
+
isCompare: { type: Boolean },
|
|
26
|
+
config: {},
|
|
27
|
+
name: {},
|
|
28
|
+
labelWidth: {},
|
|
29
|
+
prop: {},
|
|
30
|
+
size: {},
|
|
31
|
+
disabled: { type: Boolean }
|
|
32
|
+
},
|
|
33
|
+
emits: ["change", "addDiffCount"],
|
|
34
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
35
|
+
const props = __props;
|
|
36
|
+
const emit = __emit;
|
|
37
|
+
const mForm = inject("mForm");
|
|
38
|
+
const expand = ref(props.config.expand !== false);
|
|
39
|
+
const items = computed(() => props.config.items);
|
|
40
|
+
const filter = (config) => filterFunction(mForm, config, props);
|
|
41
|
+
const changeHandler = (v, eventData) => {
|
|
42
|
+
emit("change", props.model, eventData);
|
|
43
|
+
};
|
|
44
|
+
const onAddDiffCount = () => emit("addDiffCount");
|
|
45
|
+
__expose({
|
|
46
|
+
getExpand: () => expand.value,
|
|
47
|
+
setExpand: (v) => {
|
|
48
|
+
expand.value = v;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return (_ctx, _cache) => {
|
|
52
|
+
return items.value && items.value.length ? (openBlock(), createBlock(unref(TMagicCard), {
|
|
53
|
+
key: 0,
|
|
54
|
+
class: "box-card m-form-panel",
|
|
55
|
+
"body-style": { display: expand.value ? "block" : "none" }
|
|
56
|
+
}, {
|
|
57
|
+
header: withCtx(() => [createElementVNode("div", _hoisted_1, [
|
|
58
|
+
createVNode(unref(TMagicButton), {
|
|
59
|
+
style: { "padding": "0" },
|
|
60
|
+
link: "",
|
|
61
|
+
icon: expand.value ? unref(CaretBottom) : unref(CaretRight),
|
|
62
|
+
onClick: _cache[0] || (_cache[0] = ($event) => expand.value = !expand.value)
|
|
63
|
+
}, null, 8, ["icon"]),
|
|
64
|
+
renderSlot(_ctx.$slots, "header", {}, () => [createElementVNode("span", {
|
|
65
|
+
style: { "cursor": "pointer" },
|
|
66
|
+
onClick: _cache[1] || (_cache[1] = ($event) => expand.value = !expand.value)
|
|
67
|
+
}, toDisplayString(filter(__props.config.title)), 1)]),
|
|
68
|
+
__props.config && __props.config.extra ? (openBlock(), createElementBlock("span", {
|
|
69
|
+
key: 0,
|
|
70
|
+
innerHTML: __props.config.extra,
|
|
71
|
+
class: "m-form-tip"
|
|
72
|
+
}, null, 8, _hoisted_2)) : createCommentVNode("v-if", true)
|
|
73
|
+
])]),
|
|
74
|
+
default: withCtx(() => [createElementVNode("div", null, [renderSlot(_ctx.$slots, "default"), __props.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3, [createElementVNode("div", _hoisted_4, [(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
|
|
75
|
+
return openBlock(), createBlock(Container_default, {
|
|
76
|
+
key: item[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
77
|
+
config: item,
|
|
78
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
79
|
+
lastValues: __props.name ? __props.lastValues[__props.name] : __props.lastValues,
|
|
80
|
+
"is-compare": __props.isCompare,
|
|
81
|
+
prop: __props.prop,
|
|
82
|
+
size: __props.size,
|
|
83
|
+
disabled: __props.disabled,
|
|
84
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
85
|
+
onChange: changeHandler,
|
|
86
|
+
onAddDiffCount: _cache[2] || (_cache[2] = ($event) => onAddDiffCount())
|
|
87
|
+
}, null, 8, [
|
|
88
|
+
"config",
|
|
89
|
+
"model",
|
|
90
|
+
"lastValues",
|
|
91
|
+
"is-compare",
|
|
92
|
+
"prop",
|
|
93
|
+
"size",
|
|
94
|
+
"disabled",
|
|
95
|
+
"label-width"
|
|
96
|
+
]);
|
|
97
|
+
}), 128))]), createElementVNode("img", {
|
|
98
|
+
class: "m-form-schematic",
|
|
99
|
+
src: __props.config.schematic
|
|
100
|
+
}, null, 8, _hoisted_5)])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(items.value, (item, index) => {
|
|
101
|
+
return openBlock(), createBlock(Container_default, {
|
|
102
|
+
key: item[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
103
|
+
config: item,
|
|
104
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
105
|
+
lastValues: __props.name ? __props.lastValues[__props.name] : __props.lastValues,
|
|
106
|
+
"is-compare": __props.isCompare,
|
|
107
|
+
prop: __props.prop,
|
|
108
|
+
size: __props.size,
|
|
109
|
+
disabled: __props.disabled,
|
|
110
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
111
|
+
onChange: changeHandler,
|
|
112
|
+
onAddDiffCount: _cache[3] || (_cache[3] = ($event) => onAddDiffCount())
|
|
113
|
+
}, null, 8, [
|
|
114
|
+
"config",
|
|
115
|
+
"model",
|
|
116
|
+
"lastValues",
|
|
117
|
+
"is-compare",
|
|
118
|
+
"prop",
|
|
119
|
+
"size",
|
|
120
|
+
"disabled",
|
|
121
|
+
"label-width"
|
|
122
|
+
]);
|
|
123
|
+
}), 128))])]),
|
|
124
|
+
_: 3
|
|
125
|
+
}, 8, ["body-style"])) : createCommentVNode("v-if", true);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Panel_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Row_vue_vue_type_script_setup_true_lang_default from "./Row.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/Row.vue
|
|
3
|
+
var Row_default = Row_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Row_default as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Col_default from "./Col.js";
|
|
2
|
+
import { Fragment, createBlock, createElementBlock, defineComponent, inject, openBlock, renderList, unref, withCtx } from "vue";
|
|
3
|
+
import { TMagicRow } from "@tmagic/design";
|
|
4
|
+
//#region packages/form/src/containers/Row.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var Row_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "MFormRow",
|
|
7
|
+
__name: "Row",
|
|
8
|
+
props: {
|
|
9
|
+
model: {},
|
|
10
|
+
lastValues: {},
|
|
11
|
+
isCompare: { type: Boolean },
|
|
12
|
+
config: {},
|
|
13
|
+
name: {},
|
|
14
|
+
labelWidth: {},
|
|
15
|
+
prop: {},
|
|
16
|
+
size: {},
|
|
17
|
+
expandMore: { type: Boolean },
|
|
18
|
+
disabled: { type: Boolean }
|
|
19
|
+
},
|
|
20
|
+
emits: ["change", "addDiffCount"],
|
|
21
|
+
setup(__props, { emit: __emit }) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
const emit = __emit;
|
|
24
|
+
const mForm = inject("mForm");
|
|
25
|
+
const changeHandler = (v, eventData) => {
|
|
26
|
+
emit("change", props.name ? props.model[props.name] : props.model, eventData);
|
|
27
|
+
};
|
|
28
|
+
const onAddDiffCount = () => emit("addDiffCount");
|
|
29
|
+
return (_ctx, _cache) => {
|
|
30
|
+
return openBlock(), createBlock(unref(TMagicRow), { gutter: 10 }, {
|
|
31
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.items, (col, index) => {
|
|
32
|
+
return openBlock(), createBlock(Col_default, {
|
|
33
|
+
key: col[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
34
|
+
span: col.span || __props.config.span || 24 / __props.config.items.length,
|
|
35
|
+
config: col,
|
|
36
|
+
labelWidth: __props.config.labelWidth || __props.labelWidth,
|
|
37
|
+
expandMore: __props.expandMore,
|
|
38
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
39
|
+
lastValues: __props.name ? __props.lastValues[__props.name] : __props.lastValues,
|
|
40
|
+
"is-compare": __props.isCompare,
|
|
41
|
+
prop: __props.prop,
|
|
42
|
+
size: __props.size,
|
|
43
|
+
disabled: __props.disabled,
|
|
44
|
+
onChange: changeHandler,
|
|
45
|
+
onAddDiffCount
|
|
46
|
+
}, null, 8, [
|
|
47
|
+
"span",
|
|
48
|
+
"config",
|
|
49
|
+
"labelWidth",
|
|
50
|
+
"expandMore",
|
|
51
|
+
"model",
|
|
52
|
+
"lastValues",
|
|
53
|
+
"is-compare",
|
|
54
|
+
"prop",
|
|
55
|
+
"size",
|
|
56
|
+
"disabled"
|
|
57
|
+
]);
|
|
58
|
+
}), 128))]),
|
|
59
|
+
_: 1
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Row_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Step_vue_vue_type_script_setup_true_lang_default from "./Step.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/Step.vue
|
|
3
|
+
var Step_default = Step_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Step_default as default };
|