@tmagic/form 1.7.10 → 1.7.12
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/containers/GroupList.vue_vue_type_script_setup_true_lang.js +5 -69
- package/dist/es/{table → containers/table}/ActionsColumn.js +1 -1
- package/dist/es/{table → containers/table}/ActionsColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/{table → containers/table}/SortColumn.js +1 -1
- package/dist/es/{table → containers/table}/SortColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/{table → containers/table}/Table.js +1 -1
- package/dist/es/{table → containers/table}/Table.vue_vue_type_script_setup_true_lang.js +13 -60
- package/dist/es/containers/table/useFullscreen.js +22 -0
- package/dist/es/{table → containers/table}/useImport.js +3 -5
- package/dist/es/{table → containers/table}/usePagination.js +2 -2
- package/dist/es/{table → containers/table}/useSelection.js +1 -1
- package/dist/es/{table → containers/table}/useSortable.js +2 -2
- package/dist/es/{table → containers/table}/useTableColumns.js +5 -5
- package/dist/es/containers/table-group-list/TableGroupList.js +5 -0
- package/dist/es/containers/table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/es/{table → containers/table-group-list}/useAdd.js +6 -4
- package/dist/es/index.js +2 -3
- package/dist/es/plugin.js +3 -4
- package/dist/tmagic-form.umd.cjs +732 -677
- package/package.json +6 -6
- package/src/containers/GroupList.vue +5 -80
- package/src/{table → containers/table}/ActionsColumn.vue +1 -1
- package/src/{table → containers/table}/Table.vue +11 -56
- package/src/{table → containers/table}/type.ts +0 -1
- package/src/containers/table/useFullscreen.ts +31 -0
- package/src/{table → containers/table}/useImport.ts +2 -5
- package/src/{table → containers/table}/usePagination.ts +1 -1
- package/src/{table → containers/table}/useSortable.ts +1 -1
- package/src/{table → containers/table}/useTableColumns.ts +8 -5
- package/src/containers/table-group-list/TableGroupList.vue +173 -0
- package/src/{table → containers/table-group-list}/useAdd.ts +17 -7
- package/src/index.ts +3 -2
- package/src/plugin.ts +3 -4
- package/types/index.d.ts +245 -286
- package/dist/es/table/useFullscreen.js +0 -15
- package/src/table/useFullscreen.ts +0 -18
- /package/src/{table → containers/table}/SortColumn.vue +0 -0
- /package/src/{table → containers/table}/useSelection.ts +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { initValue } from "../utils/form.js";
|
|
2
1
|
import GroupListItem_default from "./GroupListItem.js";
|
|
3
|
-
import { Fragment,
|
|
2
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, openBlock, renderList, renderSlot } from "vue";
|
|
4
3
|
import { cloneDeep } from "lodash-es";
|
|
5
|
-
import { TMagicButton } from "@tmagic/design";
|
|
6
|
-
import { Grid, Plus } from "@element-plus/icons-vue";
|
|
7
4
|
//#region packages/form/src/containers/GroupList.vue?vue&type=script&setup=true&lang.ts
|
|
8
5
|
var _hoisted_1 = { class: "m-fields-group-list" };
|
|
9
6
|
var _hoisted_2 = ["innerHTML"];
|
|
@@ -29,46 +26,16 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
29
26
|
labelWidth: {},
|
|
30
27
|
prop: {},
|
|
31
28
|
size: {},
|
|
32
|
-
disabled: { type: Boolean }
|
|
29
|
+
disabled: { type: Boolean },
|
|
30
|
+
showIndex: { type: Boolean }
|
|
33
31
|
},
|
|
34
32
|
emits: ["change", "addDiffCount"],
|
|
35
33
|
setup(__props, { emit: __emit }) {
|
|
36
34
|
const props = __props;
|
|
37
35
|
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
36
|
const changeHandler = (v, eventData) => {
|
|
50
37
|
emit("change", props.model, eventData);
|
|
51
38
|
};
|
|
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
39
|
const removeHandler = (index) => {
|
|
73
40
|
if (!props.name) return false;
|
|
74
41
|
props.model[props.name].splice(index, 1);
|
|
@@ -84,15 +51,6 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
84
51
|
props.model[props.name].splice(Math.min(Math.max(idx2, 0), length - 1), 0, currRow);
|
|
85
52
|
emit("change", props.model[props.name]);
|
|
86
53
|
};
|
|
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
54
|
const onAddDiffCount = () => emit("addDiffCount");
|
|
97
55
|
const getLastValues = (item, index) => item?.[index] || {};
|
|
98
56
|
return (_ctx, _cache) => {
|
|
@@ -106,7 +64,7 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
106
64
|
return openBlock(), createBlock(GroupListItem_default, {
|
|
107
65
|
key: index,
|
|
108
66
|
model: item,
|
|
109
|
-
lastValues: getLastValues(__props.lastValues[__props.name], Number(index)),
|
|
67
|
+
lastValues: getLastValues(__props.lastValues?.[__props.name], Number(index)),
|
|
110
68
|
"is-compare": __props.isCompare,
|
|
111
69
|
config: __props.config,
|
|
112
70
|
prop: __props.prop,
|
|
@@ -133,29 +91,7 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
133
91
|
"group-model"
|
|
134
92
|
]);
|
|
135
93
|
}), 128)),
|
|
136
|
-
createElementVNode("div", _hoisted_4, [
|
|
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)])])
|
|
94
|
+
createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "toggle-button"), createElementVNode("div", _hoisted_5, [renderSlot(_ctx.$slots, "add-button")])])
|
|
159
95
|
]);
|
|
160
96
|
};
|
|
161
97
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ActionsColumn_vue_vue_type_script_setup_true_lang_default from "./ActionsColumn.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
-
//#region packages/form/src/table/ActionsColumn.vue
|
|
2
|
+
//#region packages/form/src/containers/table/ActionsColumn.vue
|
|
3
3
|
var ActionsColumn_default = ActionsColumn_vue_vue_type_script_setup_true_lang_default;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { ActionsColumn_default as default };
|
package/dist/es/{table → containers/table}/ActionsColumn.vue_vue_type_script_setup_true_lang.js
RENAMED
|
@@ -2,7 +2,7 @@ import { Fragment, createBlock, createCommentVNode, createElementBlock, createVN
|
|
|
2
2
|
import { cloneDeep } from "lodash-es";
|
|
3
3
|
import { TMagicButton, TMagicTooltip } from "@tmagic/design";
|
|
4
4
|
import { Delete, DocumentCopy, Sort } from "@element-plus/icons-vue";
|
|
5
|
-
//#region packages/form/src/table/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
//#region packages/form/src/containers/table/ActionsColumn.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
var ActionsColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "ActionsColumn",
|
|
8
8
|
props: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SortColumn_vue_vue_type_script_setup_true_lang_default from "./SortColumn.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
-
//#region packages/form/src/table/SortColumn.vue
|
|
2
|
+
//#region packages/form/src/containers/table/SortColumn.vue
|
|
3
3
|
var SortColumn_default = SortColumn_vue_vue_type_script_setup_true_lang_default;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { SortColumn_default as default };
|
package/dist/es/{table → containers/table}/SortColumn.vue_vue_type_script_setup_true_lang.js
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
|
|
2
2
|
import { TMagicButton, TMagicTooltip } from "@tmagic/design";
|
|
3
3
|
import { ArrowDown, ArrowUp } from "@element-plus/icons-vue";
|
|
4
|
-
//#region packages/form/src/table/SortColumn.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
//#region packages/form/src/containers/table/SortColumn.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var SortColumn_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
6
|
__name: "SortColumn",
|
|
7
7
|
props: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Table_vue_vue_type_script_setup_true_lang_default from "./Table.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
-
//#region packages/form/src/table/Table.vue
|
|
2
|
+
//#region packages/form/src/containers/table/Table.vue
|
|
3
3
|
var Table_default = Table_vue_vue_type_script_setup_true_lang_default;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { Table_default as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { sortChange } from "
|
|
2
|
-
import { useAdd } from "./useAdd.js";
|
|
1
|
+
import { sortChange } from "../../utils/form.js";
|
|
3
2
|
import { useFullscreen } from "./useFullscreen.js";
|
|
4
3
|
import { useImport } from "./useImport.js";
|
|
5
4
|
import { usePagination } from "./usePagination.js";
|
|
@@ -7,9 +6,9 @@ import { useSelection } from "./useSelection.js";
|
|
|
7
6
|
import { useSortable } from "./useSortable.js";
|
|
8
7
|
import { useTableColumns } from "./useTableColumns.js";
|
|
9
8
|
import { Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, ref, renderSlot, toDisplayString, unref, useTemplateRef, withCtx } from "vue";
|
|
10
|
-
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload
|
|
11
|
-
import { FullScreen
|
|
12
|
-
//#region packages/form/src/table/Table.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
+
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload } from "@tmagic/design";
|
|
10
|
+
import { FullScreen } from "@element-plus/icons-vue";
|
|
11
|
+
//#region packages/form/src/containers/table/Table.vue?vue&type=script&setup=true&lang.ts
|
|
13
12
|
var _hoisted_1 = ["innerHTML"];
|
|
14
13
|
var _hoisted_2 = { style: {
|
|
15
14
|
"display": "flex",
|
|
@@ -41,10 +40,6 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
41
40
|
sortKey: { default: "" },
|
|
42
41
|
text: {},
|
|
43
42
|
size: {},
|
|
44
|
-
enableToggleMode: {
|
|
45
|
-
type: Boolean,
|
|
46
|
-
default: true
|
|
47
|
-
},
|
|
48
43
|
showIndex: {
|
|
49
44
|
type: Boolean,
|
|
50
45
|
default: true
|
|
@@ -53,7 +48,8 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
53
48
|
emits: [
|
|
54
49
|
"change",
|
|
55
50
|
"select",
|
|
56
|
-
"addDiffCount"
|
|
51
|
+
"addDiffCount",
|
|
52
|
+
"add"
|
|
57
53
|
],
|
|
58
54
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
59
55
|
const props = __props;
|
|
@@ -61,36 +57,13 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
61
57
|
const modelName = computed(() => props.name || props.config.name || "");
|
|
62
58
|
const tMagicTableRef = useTemplateRef("tMagicTable");
|
|
63
59
|
const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentChange } = usePagination(props, modelName);
|
|
64
|
-
const { nextZIndex } = useZIndex();
|
|
65
60
|
const updateKey = ref(1);
|
|
66
|
-
const { addable, newHandler } = useAdd(props, emit);
|
|
67
61
|
const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
|
|
68
62
|
useSortable(props, emit, tMagicTableRef, modelName, updateKey);
|
|
69
|
-
const { isFullscreen, toggleFullscreen } = useFullscreen();
|
|
70
|
-
const { importable, excelHandler, clearHandler } = useImport(props, emit
|
|
63
|
+
const { isFullscreen, fullscreenZIndex, toggleFullscreen } = useFullscreen();
|
|
64
|
+
const { importable, excelHandler, clearHandler } = useImport(props, emit);
|
|
71
65
|
const { selectHandle, toggleRowSelection } = useSelection(props, emit, tMagicTableRef);
|
|
72
66
|
const data = computed(() => props.config.pagination ? paginationData.value : props.model[modelName.value]);
|
|
73
|
-
const toggleMode = () => {
|
|
74
|
-
const calcLabelWidth = (label) => {
|
|
75
|
-
if (!label) return "0px";
|
|
76
|
-
const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
|
|
77
|
-
const chLength = label.length - zhLength;
|
|
78
|
-
return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
|
|
79
|
-
};
|
|
80
|
-
props.config.type = "groupList";
|
|
81
|
-
props.config.enableToggleMode = true;
|
|
82
|
-
props.config.tableItems = props.config.items;
|
|
83
|
-
props.config.items = props.config.groupItems || props.config.items.map((item) => {
|
|
84
|
-
const text = item.text || item.label;
|
|
85
|
-
const labelWidth = calcLabelWidth(text);
|
|
86
|
-
return {
|
|
87
|
-
...item,
|
|
88
|
-
text,
|
|
89
|
-
labelWidth,
|
|
90
|
-
span: item.span || 12
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
67
|
const sortChangeHandler = (sortOptions) => {
|
|
95
68
|
const modelName = props.name || props.config.name || "";
|
|
96
69
|
sortChange(props.model[modelName], sortOptions);
|
|
@@ -102,7 +75,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
102
75
|
disabled: !unref(isFullscreen)
|
|
103
76
|
}, [createElementVNode("div", mergeProps(_ctx.$attrs, {
|
|
104
77
|
class: ["m-fields-table-wrap", { fixed: unref(isFullscreen) }],
|
|
105
|
-
style: unref(isFullscreen) ? `z-index: ${unref(
|
|
78
|
+
style: unref(isFullscreen) ? `z-index: ${unref(fullscreenZIndex)}` : ""
|
|
106
79
|
}), [createElementVNode("div", { class: normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }]) }, [
|
|
107
80
|
__props.config.extra ? (openBlock(), createElementBlock("span", {
|
|
108
81
|
key: 0,
|
|
@@ -139,15 +112,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
139
112
|
}, 8, ["disabled"]),
|
|
140
113
|
renderSlot(_ctx.$slots, "default"),
|
|
141
114
|
createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [
|
|
142
|
-
|
|
143
|
-
key: 0,
|
|
144
|
-
icon: unref(Grid),
|
|
145
|
-
size: "small",
|
|
146
|
-
onClick: toggleMode
|
|
147
|
-
}, {
|
|
148
|
-
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("展开配置", -1)])]),
|
|
149
|
-
_: 1
|
|
150
|
-
}, 8, ["icon"])) : createCommentVNode("v-if", true),
|
|
115
|
+
!unref(isFullscreen) ? renderSlot(_ctx.$slots, "toggle-button", { key: 0 }) : createCommentVNode("v-if", true),
|
|
151
116
|
__props.config.enableFullscreen !== false ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
152
117
|
key: 1,
|
|
153
118
|
icon: unref(FullScreen),
|
|
@@ -172,7 +137,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
172
137
|
disabled: __props.disabled,
|
|
173
138
|
plain: ""
|
|
174
139
|
}, {
|
|
175
|
-
default: withCtx(() => [..._cache[
|
|
140
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("导入EXCEL", -1)])]),
|
|
176
141
|
_: 1
|
|
177
142
|
}, 8, ["disabled"])]),
|
|
178
143
|
_: 1
|
|
@@ -185,22 +150,10 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
185
150
|
plain: "",
|
|
186
151
|
onClick: unref(clearHandler)
|
|
187
152
|
}, {
|
|
188
|
-
default: withCtx(() => [..._cache[
|
|
153
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("清空", -1)])]),
|
|
189
154
|
_: 1
|
|
190
155
|
}, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true)
|
|
191
|
-
]),
|
|
192
|
-
key: 0,
|
|
193
|
-
class: "m-form-table-add-button",
|
|
194
|
-
size: "small",
|
|
195
|
-
plain: "",
|
|
196
|
-
icon: unref(Plus)
|
|
197
|
-
}, __props.config.addButtonConfig?.props || { type: "primary" }, {
|
|
198
|
-
disabled: __props.disabled,
|
|
199
|
-
onClick: _cache[0] || (_cache[0] = ($event) => unref(newHandler)())
|
|
200
|
-
}), {
|
|
201
|
-
default: withCtx(() => [createTextVNode(toDisplayString(__props.config.addButtonConfig?.text || "新增一行"), 1)]),
|
|
202
|
-
_: 1
|
|
203
|
-
}, 16, ["icon", "disabled"])) : createCommentVNode("v-if", true)]),
|
|
156
|
+
]), renderSlot(_ctx.$slots, "add-button")]),
|
|
204
157
|
__props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(unref(TMagicPagination), {
|
|
205
158
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
206
159
|
"hide-on-single-page": __props.model[modelName.value].length < unref(pageSize),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ref, watch } from "vue";
|
|
2
|
+
import { useZIndex } from "@tmagic/design";
|
|
3
|
+
//#region packages/form/src/containers/table/useFullscreen.ts
|
|
4
|
+
var useFullscreen = () => {
|
|
5
|
+
const { nextZIndex } = useZIndex();
|
|
6
|
+
const fullscreenZIndex = ref(nextZIndex());
|
|
7
|
+
const isFullscreen = ref(false);
|
|
8
|
+
const toggleFullscreen = () => {
|
|
9
|
+
if (isFullscreen.value) isFullscreen.value = false;
|
|
10
|
+
else isFullscreen.value = true;
|
|
11
|
+
};
|
|
12
|
+
watch(isFullscreen, (value) => {
|
|
13
|
+
if (value) fullscreenZIndex.value = nextZIndex();
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
isFullscreen,
|
|
17
|
+
fullscreenZIndex,
|
|
18
|
+
toggleFullscreen
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useFullscreen };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, inject, useTemplateRef } from "vue";
|
|
2
2
|
import { asyncLoadJs } from "@tmagic/utils";
|
|
3
|
-
//#region packages/form/src/table/useImport.ts
|
|
4
|
-
var useImport = (props, emit
|
|
3
|
+
//#region packages/form/src/containers/table/useImport.ts
|
|
4
|
+
var useImport = (props, emit) => {
|
|
5
5
|
const mForm = inject("mForm");
|
|
6
6
|
const modelName = computed(() => props.name || props.config.name || "");
|
|
7
7
|
const importable = computed(() => {
|
|
@@ -21,9 +21,7 @@ var useImport = (props, emit, newHandler) => {
|
|
|
21
21
|
const pdata = globalThis.XLSX.read(data, { type: "array" });
|
|
22
22
|
pdata.SheetNames.forEach((sheetName) => {
|
|
23
23
|
const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
|
|
24
|
-
if (arr?.[0]) arr
|
|
25
|
-
newHandler(row);
|
|
26
|
-
});
|
|
24
|
+
if (arr?.[0]) emit("add", arr);
|
|
27
25
|
setTimeout(() => {
|
|
28
26
|
excelBtn.value?.clearFiles();
|
|
29
27
|
}, 300);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getDataByPage } from "
|
|
1
|
+
import { getDataByPage } from "../../utils/form.js";
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
|
-
//#region packages/form/src/table/usePagination.ts
|
|
3
|
+
//#region packages/form/src/containers/table/usePagination.ts
|
|
4
4
|
var usePagination = (props, modelName) => {
|
|
5
5
|
const pageSize = ref(10);
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inject } from "vue";
|
|
2
|
-
//#region packages/form/src/table/useSelection.ts
|
|
2
|
+
//#region packages/form/src/containers/table/useSelection.ts
|
|
3
3
|
var useSelection = (props, emit, tMagicTableRef) => {
|
|
4
4
|
const mForm = inject("mForm");
|
|
5
5
|
const selectHandle = (selection, row) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { sortArray } from "
|
|
1
|
+
import { sortArray } from "../../utils/form.js";
|
|
2
2
|
import { inject, nextTick, watchEffect } from "vue";
|
|
3
|
-
//#region packages/form/src/table/useSortable.ts
|
|
3
|
+
//#region packages/form/src/containers/table/useSortable.ts
|
|
4
4
|
var SortablePromise;
|
|
5
5
|
var loadSortable = () => SortablePromise ??= import("sortablejs").then((m) => m.default);
|
|
6
6
|
var useSortable = (props, emit, tMagicTableRef, modelName, updateKey) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { display, getDataByPage, sortArray } from "
|
|
2
|
-
import Container_default from "../
|
|
1
|
+
import { display, getDataByPage, sortArray } from "../../utils/form.js";
|
|
2
|
+
import Container_default from "../Container.js";
|
|
3
3
|
import ActionsColumn_default from "./ActionsColumn.js";
|
|
4
4
|
import SortColumn_default from "./SortColumn.js";
|
|
5
5
|
import { computed, h, inject } from "vue";
|
|
6
6
|
import { cloneDeep } from "lodash-es";
|
|
7
7
|
import { TMagicIcon, TMagicTooltip } from "@tmagic/design";
|
|
8
8
|
import { WarningFilled } from "@element-plus/icons-vue";
|
|
9
|
-
//#region packages/form/src/table/useTableColumns.ts
|
|
9
|
+
//#region packages/form/src/containers/table/useTableColumns.ts
|
|
10
10
|
var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
|
|
11
11
|
const mForm = inject("mForm");
|
|
12
12
|
const display$1 = (fuc) => display(mForm, fuc, props);
|
|
@@ -123,7 +123,7 @@ var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
|
|
|
123
123
|
columns.push({
|
|
124
124
|
props: {
|
|
125
125
|
prop: column.name,
|
|
126
|
-
label: column.label,
|
|
126
|
+
label: column.label || column.text,
|
|
127
127
|
width: column.width,
|
|
128
128
|
sortable: column.sortable,
|
|
129
129
|
sortOrders: ["ascending", "descending"],
|
|
@@ -147,7 +147,7 @@ var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
|
|
|
147
147
|
display: "inline-flex",
|
|
148
148
|
alignItems: "center",
|
|
149
149
|
gap: "5px"
|
|
150
|
-
} }, [h("span", column.label), h(TMagicIcon, {}, { default: () => h(WarningFilled) })]),
|
|
150
|
+
} }, [h("span", column.label || column.text), h(TMagicIcon, {}, { default: () => h(WarningFilled) })]),
|
|
151
151
|
content: () => h("div", { innerHTML: titleTipValue })
|
|
152
152
|
}) : void 0
|
|
153
153
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import TableGroupList_vue_vue_type_script_setup_true_lang_default from "./TableGroupList.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/form/src/containers/table-group-list/TableGroupList.vue
|
|
3
|
+
var TableGroupList_default = TableGroupList_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { TableGroupList_default as default };
|
package/dist/es/containers/table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import GroupList_default from "../GroupList.js";
|
|
2
|
+
import Table_default from "../table/Table.js";
|
|
3
|
+
import { useAdd } from "./useAdd.js";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, ref, resolveDynamicComponent, toDisplayString, unref, useTemplateRef, withCtx } from "vue";
|
|
5
|
+
import { TMagicButton } from "@tmagic/design";
|
|
6
|
+
import { Grid, Plus } from "@element-plus/icons-vue";
|
|
7
|
+
//#region packages/form/src/containers/table-group-list/TableGroupList.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
var TableGroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "MFormTableGroupList",
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
__name: "TableGroupList",
|
|
12
|
+
props: {
|
|
13
|
+
model: {},
|
|
14
|
+
lastValues: {},
|
|
15
|
+
isCompare: { type: Boolean },
|
|
16
|
+
config: {},
|
|
17
|
+
name: {},
|
|
18
|
+
prop: {},
|
|
19
|
+
labelWidth: {},
|
|
20
|
+
disabled: { type: Boolean },
|
|
21
|
+
size: {},
|
|
22
|
+
enableToggleMode: { type: Boolean },
|
|
23
|
+
showIndex: { type: Boolean },
|
|
24
|
+
sortKey: {},
|
|
25
|
+
sort: { type: Boolean }
|
|
26
|
+
},
|
|
27
|
+
emits: [
|
|
28
|
+
"change",
|
|
29
|
+
"select",
|
|
30
|
+
"addDiffCount"
|
|
31
|
+
],
|
|
32
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
33
|
+
const props = __props;
|
|
34
|
+
const emit = __emit;
|
|
35
|
+
const { addable, newHandler } = useAdd(props, emit);
|
|
36
|
+
const isGroupListType = (type) => type === "groupList" || type === "group-list";
|
|
37
|
+
const displayMode = ref(isGroupListType(props.config.type) ? "groupList" : "table");
|
|
38
|
+
const calcLabelWidth = (label) => {
|
|
39
|
+
if (!label) return "0px";
|
|
40
|
+
const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
|
|
41
|
+
const chLength = label.length - zhLength;
|
|
42
|
+
return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
|
|
43
|
+
};
|
|
44
|
+
const tableConfig = computed(() => {
|
|
45
|
+
if (!isGroupListType(props.config.type)) return props.config;
|
|
46
|
+
const source = props.config;
|
|
47
|
+
return {
|
|
48
|
+
...props.config,
|
|
49
|
+
type: "table",
|
|
50
|
+
groupItems: source.items,
|
|
51
|
+
items: source.tableItems || source.items.map((item) => ({
|
|
52
|
+
...item,
|
|
53
|
+
label: item.label || item.text,
|
|
54
|
+
text: null
|
|
55
|
+
}))
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const groupListConfig = computed(() => {
|
|
59
|
+
if (isGroupListType(props.config.type)) return props.config;
|
|
60
|
+
const source = props.config;
|
|
61
|
+
return {
|
|
62
|
+
...props.config,
|
|
63
|
+
type: "groupList",
|
|
64
|
+
tableItems: source.items,
|
|
65
|
+
items: source.groupItems || source.items.map((item) => {
|
|
66
|
+
const text = item.text || item.label;
|
|
67
|
+
return {
|
|
68
|
+
...item,
|
|
69
|
+
text,
|
|
70
|
+
labelWidth: calcLabelWidth(text),
|
|
71
|
+
span: item.span || 12
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
const currentConfig = computed(() => displayMode.value === "table" ? tableConfig.value : groupListConfig.value);
|
|
77
|
+
const addButtonSize = computed(() => {
|
|
78
|
+
if (displayMode.value === "table") return "small";
|
|
79
|
+
return props.config.enableToggleMode !== false ? "small" : "default";
|
|
80
|
+
});
|
|
81
|
+
const toggleDisplayMode = () => {
|
|
82
|
+
displayMode.value = displayMode.value === "table" ? "groupList" : "table";
|
|
83
|
+
};
|
|
84
|
+
const onChange = (v, eventData) => emit("change", v, eventData);
|
|
85
|
+
const onSelect = (...args) => emit("select", ...args);
|
|
86
|
+
const onAddDiffCount = () => emit("addDiffCount");
|
|
87
|
+
const onAdd = (rows) => {
|
|
88
|
+
rows.forEach((row) => {
|
|
89
|
+
newHandler(row);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const tableGroupListRef = useTemplateRef("tableGroupList");
|
|
93
|
+
__expose({ toggleRowSelection: (row, selected) => tableGroupListRef.value?.toggleRowSelection?.(row, selected) });
|
|
94
|
+
return (_ctx, _cache) => {
|
|
95
|
+
return openBlock(), createBlock(resolveDynamicComponent(displayMode.value === "table" ? Table_default : GroupList_default), mergeProps({ ref: "tableGroupList" }, _ctx.$attrs, {
|
|
96
|
+
model: __props.model,
|
|
97
|
+
name: `${__props.name}`,
|
|
98
|
+
config: currentConfig.value,
|
|
99
|
+
disabled: __props.disabled,
|
|
100
|
+
size: __props.size,
|
|
101
|
+
"is-compare": __props.isCompare,
|
|
102
|
+
"last-values": __props.lastValues,
|
|
103
|
+
prop: __props.prop,
|
|
104
|
+
"label-width": __props.labelWidth,
|
|
105
|
+
"show-index": __props.showIndex,
|
|
106
|
+
"sort-key": __props.sortKey,
|
|
107
|
+
sort: __props.sort,
|
|
108
|
+
onChange,
|
|
109
|
+
onSelect,
|
|
110
|
+
onAddDiffCount,
|
|
111
|
+
onAdd
|
|
112
|
+
}), createSlots({
|
|
113
|
+
"toggle-button": withCtx(() => [__props.config.enableToggleMode || __props.enableToggleMode ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
114
|
+
key: 0,
|
|
115
|
+
icon: unref(Grid),
|
|
116
|
+
size: "small",
|
|
117
|
+
onClick: toggleDisplayMode
|
|
118
|
+
}, {
|
|
119
|
+
default: withCtx(() => [createTextVNode(toDisplayString(displayMode.value === "table" ? "展开配置" : "切换为表格"), 1)]),
|
|
120
|
+
_: 1
|
|
121
|
+
}, 8, ["icon"])) : createCommentVNode("v-if", true)]),
|
|
122
|
+
_: 2
|
|
123
|
+
}, [unref(addable) ? {
|
|
124
|
+
name: "add-button",
|
|
125
|
+
fn: withCtx(() => [createVNode(unref(TMagicButton), mergeProps({
|
|
126
|
+
class: displayMode.value === "table" ? "m-form-table-add-button" : "",
|
|
127
|
+
size: addButtonSize.value,
|
|
128
|
+
plain: displayMode.value === "table",
|
|
129
|
+
icon: unref(Plus),
|
|
130
|
+
disabled: __props.disabled
|
|
131
|
+
}, currentConfig.value.addButtonConfig?.props || { type: "primary" }, { onClick: unref(newHandler) }), {
|
|
132
|
+
default: withCtx(() => [createTextVNode(toDisplayString(currentConfig.value.addButtonConfig?.text || (displayMode.value === "table" ? "新增一行" : "新增")), 1)]),
|
|
133
|
+
_: 1
|
|
134
|
+
}, 16, [
|
|
135
|
+
"class",
|
|
136
|
+
"size",
|
|
137
|
+
"plain",
|
|
138
|
+
"icon",
|
|
139
|
+
"disabled",
|
|
140
|
+
"onClick"
|
|
141
|
+
])]),
|
|
142
|
+
key: "0"
|
|
143
|
+
} : void 0]), 1040, [
|
|
144
|
+
"model",
|
|
145
|
+
"name",
|
|
146
|
+
"config",
|
|
147
|
+
"disabled",
|
|
148
|
+
"size",
|
|
149
|
+
"is-compare",
|
|
150
|
+
"last-values",
|
|
151
|
+
"prop",
|
|
152
|
+
"label-width",
|
|
153
|
+
"show-index",
|
|
154
|
+
"sort-key",
|
|
155
|
+
"sort"
|
|
156
|
+
]);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
//#endregion
|
|
161
|
+
export { TableGroupList_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { initValue } from "
|
|
1
|
+
import { initValue } from "../../utils/form.js";
|
|
2
2
|
import { computed, inject } from "vue";
|
|
3
3
|
import { tMagicMessage } from "@tmagic/design";
|
|
4
|
-
//#region packages/form/src/table/useAdd.ts
|
|
4
|
+
//#region packages/form/src/containers/table-group-list/useAdd.ts
|
|
5
5
|
var useAdd = (props, emit) => {
|
|
6
6
|
const mForm = inject("mForm");
|
|
7
7
|
const addable = computed(() => {
|
|
8
8
|
const modelName = props.name || props.config.name || "";
|
|
9
|
+
if (!modelName) return false;
|
|
9
10
|
if (!props.model[modelName].length) return true;
|
|
10
11
|
if (typeof props.config.addable === "function") return props.config.addable(mForm, {
|
|
11
12
|
model: props.model[modelName],
|
|
12
13
|
formValue: mForm?.values,
|
|
13
|
-
prop: props.prop
|
|
14
|
+
prop: props.prop,
|
|
15
|
+
config: props.config
|
|
14
16
|
});
|
|
15
17
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
16
18
|
});
|
|
@@ -21,7 +23,7 @@ var useAdd = (props, emit) => {
|
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
25
|
if (typeof props.config.beforeAddRow === "function") {
|
|
24
|
-
if (!props.config.beforeAddRow(mForm, {
|
|
26
|
+
if (!await props.config.beforeAddRow(mForm, {
|
|
25
27
|
model: props.model[modelName],
|
|
26
28
|
formValue: mForm?.values,
|
|
27
29
|
prop: props.prop
|
package/dist/es/index.js
CHANGED
|
@@ -13,8 +13,7 @@ import FlexLayout_default from "./containers/FlexLayout.js";
|
|
|
13
13
|
import Panel_default from "./containers/Panel.js";
|
|
14
14
|
import Row_default from "./containers/Row.js";
|
|
15
15
|
import Tabs_default from "./containers/Tabs.js";
|
|
16
|
-
import
|
|
17
|
-
import GroupList_default from "./containers/GroupList.js";
|
|
16
|
+
import TableGroupList_default from "./containers/table-group-list/TableGroupList.js";
|
|
18
17
|
import Text_default from "./fields/Text.js";
|
|
19
18
|
import Number_default from "./fields/Number.js";
|
|
20
19
|
import NumberRange_default from "./fields/NumberRange.js";
|
|
@@ -38,4 +37,4 @@ import plugin_default from "./plugin.js";
|
|
|
38
37
|
export * from "@tmagic/form-schema";
|
|
39
38
|
var createForm = (config) => config;
|
|
40
39
|
//#endregion
|
|
41
|
-
export { Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer,
|
|
40
|
+
export { Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer, TableGroupList_default as MGroupList, Hidden_default as MHidden, Link_default as MLink, Number_default as MNumber, NumberRange_default as MNumberRange, Panel_default as MPanel, RadioGroup_default as MRadioGroup, Row_default as MRow, Select_default as MSelect, Switch_default as MSwitch, TableGroupList_default as MTable, TableGroupList_default as MTableGroupList, Tabs_default as MTabs, Text_default as MText, Textarea_default as MTextarea, Time_default as MTime, Timerange_default as MTimerange, createForm, createObjectProp, createValues, datetimeFormatter, plugin_default as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, useAddField };
|
package/dist/es/plugin.js
CHANGED
|
@@ -8,8 +8,7 @@ import FlexLayout_default from "./containers/FlexLayout.js";
|
|
|
8
8
|
import Panel_default from "./containers/Panel.js";
|
|
9
9
|
import Row_default from "./containers/Row.js";
|
|
10
10
|
import Tabs_default from "./containers/Tabs.js";
|
|
11
|
-
import
|
|
12
|
-
import GroupList_default from "./containers/GroupList.js";
|
|
11
|
+
import TableGroupList_default from "./containers/table-group-list/TableGroupList.js";
|
|
13
12
|
import Text_default from "./fields/Text.js";
|
|
14
13
|
import Number_default from "./fields/Number.js";
|
|
15
14
|
import NumberRange_default from "./fields/NumberRange.js";
|
|
@@ -41,11 +40,11 @@ var plugin_default = { install(app, opt = {}) {
|
|
|
41
40
|
app.component("m-form-dialog", FormDialog_default);
|
|
42
41
|
app.component("m-form-container", Container_default);
|
|
43
42
|
app.component("m-form-fieldset", Fieldset_default);
|
|
44
|
-
app.component("m-form-group-list",
|
|
43
|
+
app.component("m-form-group-list", TableGroupList_default);
|
|
45
44
|
app.component("m-form-panel", Panel_default);
|
|
46
45
|
app.component("m-form-row", Row_default);
|
|
47
46
|
app.component("m-form-step", Step_default);
|
|
48
|
-
app.component("m-form-table",
|
|
47
|
+
app.component("m-form-table", TableGroupList_default);
|
|
49
48
|
app.component("m-form-tab", Tabs_default);
|
|
50
49
|
app.component("m-form-flex-layout", FlexLayout_default);
|
|
51
50
|
app.component("m-fields-text", Text_default);
|