@tmagic/form 1.7.11 → 1.7.13-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +2 -36
- 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 +10 -16
- 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/{TableGroupList.js → table-group-list/TableGroupList.js} +1 -1
- package/dist/es/containers/{TableGroupList.vue_vue_type_script_setup_true_lang.js → table-group-list/TableGroupList.vue_vue_type_script_setup_true_lang.js} +25 -26
- package/dist/es/{table → containers/table-group-list}/useAdd.js +19 -4
- package/dist/es/index.js +1 -1
- package/dist/es/plugin.js +1 -1
- package/dist/tmagic-form.umd.cjs +645 -665
- package/package.json +4 -4
- package/src/FormDialog.vue +1 -1
- package/src/containers/GroupList.vue +2 -55
- package/src/{table → containers/table}/ActionsColumn.vue +1 -1
- package/src/{table → containers/table}/Table.vue +8 -18
- 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/{TableGroupList.vue → table-group-list/TableGroupList.vue} +21 -29
- package/src/{table → containers/table-group-list}/useAdd.ts +33 -7
- package/src/index.ts +3 -3
- package/src/plugin.ts +1 -1
- package/types/index.d.ts +4 -2
- 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}/type.ts +0 -0
- /package/src/{table → containers/table}/useSelection.ts +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.13-beta.0",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vue": "^3.5.33",
|
|
54
54
|
"typescript": "^6.0.3",
|
|
55
|
-
"@tmagic/
|
|
56
|
-
"@tmagic/
|
|
57
|
-
"@tmagic/utils": "1.7.
|
|
55
|
+
"@tmagic/design": "1.7.13-beta.0",
|
|
56
|
+
"@tmagic/form-schema": "1.7.13-beta.0",
|
|
57
|
+
"@tmagic/utils": "1.7.13-beta.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"typescript": {
|
package/src/FormDialog.vue
CHANGED
|
@@ -150,7 +150,7 @@ const closeHandler = () => {
|
|
|
150
150
|
|
|
151
151
|
const save = async () => {
|
|
152
152
|
try {
|
|
153
|
-
const changeRecords = form.value?.changeRecords;
|
|
153
|
+
const changeRecords = [...(form.value?.changeRecords || [])];
|
|
154
154
|
const values = await form.value?.submitForm();
|
|
155
155
|
emit('submit', values, { changeRecords });
|
|
156
156
|
} catch (e) {
|
|
@@ -29,20 +29,16 @@
|
|
|
29
29
|
<div class="m-fields-group-list-footer">
|
|
30
30
|
<slot name="toggle-button"></slot>
|
|
31
31
|
<div style="display: flex; justify-content: flex-end; flex: 1">
|
|
32
|
-
<slot name="add-button"
|
|
32
|
+
<slot name="add-button"></slot>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
38
|
<script setup lang="ts">
|
|
39
|
-
import { inject } from 'vue';
|
|
40
39
|
import { cloneDeep } from 'lodash-es';
|
|
41
40
|
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
import type { ContainerChangeEventData, FormState, GroupListConfig } from '../schema';
|
|
45
|
-
import { initValue } from '../utils/form';
|
|
41
|
+
import type { ContainerChangeEventData, GroupListConfig } from '../schema';
|
|
46
42
|
|
|
47
43
|
import MFieldsGroupListItem from './GroupListItem.vue';
|
|
48
44
|
|
|
@@ -68,59 +64,10 @@ const emit = defineEmits<{
|
|
|
68
64
|
addDiffCount: [];
|
|
69
65
|
}>();
|
|
70
66
|
|
|
71
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
72
|
-
|
|
73
67
|
const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
|
|
74
68
|
emit('change', props.model, eventData);
|
|
75
69
|
};
|
|
76
70
|
|
|
77
|
-
const addHandler = async () => {
|
|
78
|
-
if (!props.name) return false;
|
|
79
|
-
|
|
80
|
-
if (props.config.max && props.model[props.name].length >= props.config.max) {
|
|
81
|
-
tMagicMessage.error(`最多新增配置不能超过${props.config.max}条`);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (typeof props.config.beforeAddRow === 'function') {
|
|
86
|
-
const beforeCheckRes = await props.config.beforeAddRow(mForm, {
|
|
87
|
-
model: props.model[props.name],
|
|
88
|
-
formValue: mForm?.values,
|
|
89
|
-
prop: props.prop,
|
|
90
|
-
});
|
|
91
|
-
if (!beforeCheckRes) return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let initValues = {};
|
|
95
|
-
|
|
96
|
-
if (typeof props.config.defaultAdd === 'function') {
|
|
97
|
-
initValues = await props.config.defaultAdd(mForm, {
|
|
98
|
-
model: props.model[props.name],
|
|
99
|
-
formValue: mForm?.values,
|
|
100
|
-
prop: props.prop,
|
|
101
|
-
config: props.config,
|
|
102
|
-
});
|
|
103
|
-
} else if (props.config.defaultAdd) {
|
|
104
|
-
initValues = props.config.defaultAdd;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const groupValue = await initValue(mForm, {
|
|
108
|
-
config: props.config.items,
|
|
109
|
-
initValues,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
props.model[props.name].push(groupValue);
|
|
113
|
-
|
|
114
|
-
emit('change', props.model[props.name], {
|
|
115
|
-
changeRecords: [
|
|
116
|
-
{
|
|
117
|
-
propPath: `${props.prop}.${props.model[props.name].length - 1}`,
|
|
118
|
-
value: groupValue,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
71
|
const removeHandler = (index: number) => {
|
|
125
72
|
if (!props.name) return false;
|
|
126
73
|
|
|
@@ -38,7 +38,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
38
38
|
|
|
39
39
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
40
40
|
|
|
41
|
-
import type { FormState, TableConfig } from '
|
|
41
|
+
import type { FormState, TableConfig } from '../../schema';
|
|
42
42
|
|
|
43
43
|
const emit = defineEmits(['change']);
|
|
44
44
|
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
>清空</TMagicButton
|
|
59
59
|
>
|
|
60
60
|
</div>
|
|
61
|
-
<slot name="add-button"
|
|
61
|
+
<slot name="add-button"></slot>
|
|
62
62
|
</div>
|
|
63
63
|
|
|
64
64
|
<div class="bottom" style="text-align: right" v-if="config.pagination">
|
|
@@ -80,16 +80,15 @@
|
|
|
80
80
|
</template>
|
|
81
81
|
|
|
82
82
|
<script setup lang="ts">
|
|
83
|
-
import { computed, ref, useTemplateRef
|
|
83
|
+
import { computed, ref, useTemplateRef } from 'vue';
|
|
84
84
|
import { FullScreen } from '@element-plus/icons-vue';
|
|
85
85
|
|
|
86
|
-
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload
|
|
86
|
+
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload } from '@tmagic/design';
|
|
87
87
|
|
|
88
|
-
import type { SortProp } from '
|
|
89
|
-
import { sortChange } from '
|
|
88
|
+
import type { SortProp } from '../../schema';
|
|
89
|
+
import { sortChange } from '../../utils/form';
|
|
90
90
|
|
|
91
91
|
import type { TableProps } from './type';
|
|
92
|
-
import { useAdd } from './useAdd';
|
|
93
92
|
import { useFullscreen } from './useFullscreen';
|
|
94
93
|
import { useImport } from './useImport';
|
|
95
94
|
import { usePagination } from './usePagination';
|
|
@@ -109,7 +108,7 @@ const props = withDefaults(defineProps<TableProps>(), {
|
|
|
109
108
|
isCompare: false,
|
|
110
109
|
});
|
|
111
110
|
|
|
112
|
-
const emit = defineEmits(['change', 'select', 'addDiffCount']);
|
|
111
|
+
const emit = defineEmits(['change', 'select', 'addDiffCount', 'add']);
|
|
113
112
|
|
|
114
113
|
const modelName = computed(() => props.name || props.config.name || '');
|
|
115
114
|
const tMagicTableRef = useTemplateRef<InstanceType<typeof TMagicTable>>('tMagicTable');
|
|
@@ -119,22 +118,13 @@ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentCh
|
|
|
119
118
|
modelName,
|
|
120
119
|
);
|
|
121
120
|
|
|
122
|
-
const { nextZIndex } = useZIndex();
|
|
123
121
|
const updateKey = ref(1);
|
|
124
|
-
const fullscreenZIndex = ref(nextZIndex());
|
|
125
122
|
|
|
126
|
-
const { newHandler } = useAdd(props, emit);
|
|
127
123
|
const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
|
|
128
124
|
useSortable(props, emit, tMagicTableRef, modelName, updateKey);
|
|
129
|
-
const { isFullscreen, toggleFullscreen } = useFullscreen();
|
|
125
|
+
const { isFullscreen, fullscreenZIndex, toggleFullscreen } = useFullscreen();
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
if (value) {
|
|
133
|
-
fullscreenZIndex.value = nextZIndex();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const { importable, excelHandler, clearHandler } = useImport(props, emit, newHandler);
|
|
127
|
+
const { importable, excelHandler, clearHandler } = useImport(props, emit);
|
|
138
128
|
const { selectHandle, toggleRowSelection } = useSelection(props, emit, tMagicTableRef);
|
|
139
129
|
|
|
140
130
|
const data = computed(() => (props.config.pagination ? paginationData.value : props.model[modelName.value]));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { useZIndex } from '@tmagic/design';
|
|
4
|
+
|
|
5
|
+
export const useFullscreen = () => {
|
|
6
|
+
const { nextZIndex } = useZIndex();
|
|
7
|
+
|
|
8
|
+
const fullscreenZIndex = ref(nextZIndex());
|
|
9
|
+
|
|
10
|
+
const isFullscreen = ref(false);
|
|
11
|
+
|
|
12
|
+
const toggleFullscreen = () => {
|
|
13
|
+
if (isFullscreen.value) {
|
|
14
|
+
isFullscreen.value = false;
|
|
15
|
+
} else {
|
|
16
|
+
isFullscreen.value = true;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
watch(isFullscreen, (value) => {
|
|
21
|
+
if (value) {
|
|
22
|
+
fullscreenZIndex.value = nextZIndex();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
isFullscreen,
|
|
28
|
+
fullscreenZIndex,
|
|
29
|
+
toggleFullscreen,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -8,8 +8,7 @@ import type { TableProps } from './type';
|
|
|
8
8
|
|
|
9
9
|
export const useImport = (
|
|
10
10
|
props: TableProps,
|
|
11
|
-
emit: (event: 'select' | 'change' | 'addDiffCount', ...args: any[]) => void,
|
|
12
|
-
newHandler: (row: any) => void,
|
|
11
|
+
emit: (event: 'select' | 'change' | 'addDiffCount' | 'add', ...args: any[]) => void,
|
|
13
12
|
) => {
|
|
14
13
|
const mForm = inject<FormState | undefined>('mForm');
|
|
15
14
|
const modelName = computed(() => props.name || props.config.name || '');
|
|
@@ -41,9 +40,7 @@ export const useImport = (
|
|
|
41
40
|
pdata.SheetNames.forEach((sheetName: string) => {
|
|
42
41
|
const arr = (globalThis as any).XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
|
|
43
42
|
if (arr?.[0]) {
|
|
44
|
-
|
|
45
|
-
newHandler(row);
|
|
46
|
-
});
|
|
43
|
+
emit('add', arr);
|
|
47
44
|
}
|
|
48
45
|
setTimeout(() => {
|
|
49
46
|
excelBtn.value?.clearFiles();
|
|
@@ -4,7 +4,7 @@ import type { default as SortableType, SortableEvent } from 'sortablejs';
|
|
|
4
4
|
import { type TMagicTable } from '@tmagic/design';
|
|
5
5
|
import type { FormState } from '@tmagic/form-schema';
|
|
6
6
|
|
|
7
|
-
import { sortArray } from '
|
|
7
|
+
import { sortArray } from '../../utils/form';
|
|
8
8
|
|
|
9
9
|
import type { TableProps } from './type';
|
|
10
10
|
|
|
@@ -5,9 +5,9 @@ import { cloneDeep } from 'lodash-es';
|
|
|
5
5
|
import { type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
6
6
|
import type { FormItemConfig, FormState, TableColumnConfig } from '@tmagic/form-schema';
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import type { ContainerChangeEventData } from '../../schema';
|
|
9
|
+
import { display as displayFunc, getDataByPage, sortArray } from '../../utils/form';
|
|
10
|
+
import Container from '../Container.vue';
|
|
11
11
|
|
|
12
12
|
import ActionsColumn from './ActionsColumn.vue';
|
|
13
13
|
import SortColumn from './SortColumn.vue';
|
|
@@ -187,7 +187,7 @@ export const useTableColumns = (
|
|
|
187
187
|
columns.push({
|
|
188
188
|
props: {
|
|
189
189
|
prop: column.name,
|
|
190
|
-
label: column.label,
|
|
190
|
+
label: column.label || column.text,
|
|
191
191
|
width: column.width,
|
|
192
192
|
sortable: column.sortable,
|
|
193
193
|
sortOrders: ['ascending', 'descending'],
|
|
@@ -223,7 +223,10 @@ export const useTableColumns = (
|
|
|
223
223
|
gap: '5px',
|
|
224
224
|
},
|
|
225
225
|
},
|
|
226
|
-
[
|
|
226
|
+
[
|
|
227
|
+
h('span', column.label || column.text),
|
|
228
|
+
h(TMagicIcon, {}, { default: () => h(WarningFilled) }),
|
|
229
|
+
],
|
|
227
230
|
),
|
|
228
231
|
content: () =>
|
|
229
232
|
h('div', {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component
|
|
3
3
|
:is="displayMode === 'table' ? MFormTable : MFormGroupList"
|
|
4
|
+
ref="tableGroupList"
|
|
4
5
|
v-bind="$attrs"
|
|
5
6
|
:model="model"
|
|
6
7
|
:name="`${name}`"
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
@change="onChange"
|
|
18
19
|
@select="onSelect"
|
|
19
20
|
@addDiffCount="onAddDiffCount"
|
|
21
|
+
@add="onAdd"
|
|
20
22
|
>
|
|
21
23
|
<template #toggle-button>
|
|
22
24
|
<TMagicButton
|
|
@@ -29,16 +31,15 @@
|
|
|
29
31
|
</TMagicButton>
|
|
30
32
|
</template>
|
|
31
33
|
|
|
32
|
-
<template #add-button="
|
|
34
|
+
<template #add-button v-if="addable">
|
|
33
35
|
<TMagicButton
|
|
34
|
-
v-if="addable"
|
|
35
36
|
:class="displayMode === 'table' ? 'm-form-table-add-button' : ''"
|
|
36
37
|
:size="addButtonSize"
|
|
37
38
|
:plain="displayMode === 'table'"
|
|
38
39
|
:icon="Plus"
|
|
39
40
|
:disabled="disabled"
|
|
40
41
|
v-bind="currentConfig.addButtonConfig?.props || { type: 'primary' }"
|
|
41
|
-
@click="
|
|
42
|
+
@click="newHandler"
|
|
42
43
|
>
|
|
43
44
|
{{ currentConfig.addButtonConfig?.text || (displayMode === 'table' ? '新增一行' : '新增') }}
|
|
44
45
|
</TMagicButton>
|
|
@@ -47,16 +48,17 @@
|
|
|
47
48
|
</template>
|
|
48
49
|
|
|
49
50
|
<script setup lang="ts">
|
|
50
|
-
import { computed,
|
|
51
|
+
import { computed, ref, useTemplateRef } from 'vue';
|
|
51
52
|
import { Grid, Plus } from '@element-plus/icons-vue';
|
|
52
53
|
|
|
53
54
|
import { TMagicButton } from '@tmagic/design';
|
|
54
|
-
import type {
|
|
55
|
+
import type { GroupListConfig, TableConfig } from '@tmagic/form-schema';
|
|
55
56
|
|
|
56
|
-
import type { ContainerChangeEventData } from '
|
|
57
|
+
import type { ContainerChangeEventData } from '../../schema';
|
|
58
|
+
import MFormGroupList from '../GroupList.vue';
|
|
57
59
|
import MFormTable from '../table/Table.vue';
|
|
58
60
|
|
|
59
|
-
import
|
|
61
|
+
import { useAdd } from './useAdd';
|
|
60
62
|
|
|
61
63
|
defineOptions({
|
|
62
64
|
name: 'MFormTableGroupList',
|
|
@@ -81,28 +83,7 @@ const props = defineProps<{
|
|
|
81
83
|
|
|
82
84
|
const emit = defineEmits(['change', 'select', 'addDiffCount']);
|
|
83
85
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const addable = computed(() => {
|
|
87
|
-
const modelName = props.name || props.config.name || '';
|
|
88
|
-
|
|
89
|
-
if (!modelName) return false;
|
|
90
|
-
|
|
91
|
-
if (!props.model[modelName].length) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (typeof props.config.addable === 'function') {
|
|
96
|
-
return props.config.addable(mForm, {
|
|
97
|
-
model: props.model[modelName],
|
|
98
|
-
formValue: mForm?.values,
|
|
99
|
-
prop: props.prop,
|
|
100
|
-
config: props.config,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return typeof props.config.addable === 'undefined' ? true : props.config.addable;
|
|
105
|
-
});
|
|
86
|
+
const { addable, newHandler } = useAdd(props, emit);
|
|
106
87
|
|
|
107
88
|
const isGroupListType = (type: string | undefined) => type === 'groupList' || type === 'group-list';
|
|
108
89
|
|
|
@@ -178,4 +159,15 @@ const toggleDisplayMode = () => {
|
|
|
178
159
|
const onChange = (v: any, eventData?: ContainerChangeEventData) => emit('change', v, eventData);
|
|
179
160
|
const onSelect = (...args: any[]) => emit('select', ...args);
|
|
180
161
|
const onAddDiffCount = () => emit('addDiffCount');
|
|
162
|
+
const onAdd = (rows: any[]) => {
|
|
163
|
+
rows.forEach((row: any) => {
|
|
164
|
+
newHandler(row);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const tableGroupListRef = useTemplateRef<InstanceType<typeof MFormTable>>('tableGroupList');
|
|
169
|
+
|
|
170
|
+
defineExpose({
|
|
171
|
+
toggleRowSelection: (row: any, selected: boolean) => tableGroupListRef.value?.toggleRowSelection?.(row, selected),
|
|
172
|
+
});
|
|
181
173
|
</script>
|
|
@@ -1,18 +1,43 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
1
|
+
import { computed, inject } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { tMagicMessage } from '@tmagic/design';
|
|
4
|
-
import type { FormConfig, FormState } from '@tmagic/form-schema';
|
|
4
|
+
import type { FormConfig, FormState, TableConfig, TableGroupListCommonConfig } from '@tmagic/form-schema';
|
|
5
5
|
|
|
6
|
-
import { initValue } from '
|
|
7
|
-
|
|
8
|
-
import type { TableProps } from './type';
|
|
6
|
+
import { initValue } from '../../utils/form';
|
|
7
|
+
import type { TableProps } from '../table/type';
|
|
9
8
|
|
|
10
9
|
export const useAdd = (
|
|
11
|
-
props: TableProps,
|
|
12
|
-
|
|
10
|
+
props: Pick<TableProps, 'name' | 'model' | 'prop' | 'sortKey'> & {
|
|
11
|
+
config: Pick<TableGroupListCommonConfig, 'addable' | 'max' | 'beforeAddRow' | 'defaultAdd' | 'enum'> &
|
|
12
|
+
Pick<TableConfig, 'key' | 'name'> & {
|
|
13
|
+
items: { name?: string | number }[];
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
emit: (event: 'change', ...args: any[]) => void,
|
|
13
17
|
) => {
|
|
14
18
|
const mForm = inject<FormState | undefined>('mForm');
|
|
15
19
|
|
|
20
|
+
const addable = computed(() => {
|
|
21
|
+
const modelName = props.name || props.config.name || '';
|
|
22
|
+
|
|
23
|
+
if (!modelName) return false;
|
|
24
|
+
|
|
25
|
+
if (!props.model[modelName].length) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof props.config.addable === 'function') {
|
|
30
|
+
return props.config.addable(mForm, {
|
|
31
|
+
model: props.model[modelName],
|
|
32
|
+
formValue: mForm?.values,
|
|
33
|
+
prop: props.prop,
|
|
34
|
+
config: props.config,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return typeof props.config.addable === 'undefined' ? true : props.config.addable;
|
|
39
|
+
});
|
|
40
|
+
|
|
16
41
|
const newHandler = async (row?: any) => {
|
|
17
42
|
const modelName = props.name || props.config.name || '';
|
|
18
43
|
|
|
@@ -91,6 +116,7 @@ export const useAdd = (
|
|
|
91
116
|
};
|
|
92
117
|
|
|
93
118
|
return {
|
|
119
|
+
addable,
|
|
94
120
|
newHandler,
|
|
95
121
|
};
|
|
96
122
|
};
|
package/src/index.ts
CHANGED
|
@@ -32,9 +32,9 @@ export { default as MFlexLayout } from './containers/FlexLayout.vue';
|
|
|
32
32
|
export { default as MPanel } from './containers/Panel.vue';
|
|
33
33
|
export { default as MRow } from './containers/Row.vue';
|
|
34
34
|
export { default as MTabs } from './containers/Tabs.vue';
|
|
35
|
-
export { default as MTable } from './containers/TableGroupList.vue';
|
|
36
|
-
export { default as MGroupList } from './containers/TableGroupList.vue';
|
|
37
|
-
export { default as MTableGroupList } from './containers/TableGroupList.vue';
|
|
35
|
+
export { default as MTable } from './containers/table-group-list/TableGroupList.vue';
|
|
36
|
+
export { default as MGroupList } from './containers/table-group-list/TableGroupList.vue';
|
|
37
|
+
export { default as MTableGroupList } from './containers/table-group-list/TableGroupList.vue';
|
|
38
38
|
export { default as MText } from './fields/Text.vue';
|
|
39
39
|
export { default as MNumber } from './fields/Number.vue';
|
|
40
40
|
export { default as MNumberRange } from './fields/NumberRange.vue';
|
package/src/plugin.ts
CHANGED
|
@@ -24,7 +24,7 @@ import FlexLayout from './containers/FlexLayout.vue';
|
|
|
24
24
|
import Panel from './containers/Panel.vue';
|
|
25
25
|
import Row from './containers/Row.vue';
|
|
26
26
|
import MStep from './containers/Step.vue';
|
|
27
|
-
import TableGroupList from './containers/TableGroupList.vue';
|
|
27
|
+
import TableGroupList from './containers/table-group-list/TableGroupList.vue';
|
|
28
28
|
import Tabs from './containers/Tabs.vue';
|
|
29
29
|
import Cascader from './fields/Cascader.vue';
|
|
30
30
|
import Checkbox from './fields/Checkbox.vue';
|
package/types/index.d.ts
CHANGED
|
@@ -1072,7 +1072,7 @@ declare const __VLS_export$21: _$_vue_runtime_core0.DefineComponent<__VLS_Props$
|
|
|
1072
1072
|
}, {}, {}, {}, string, _$_vue_runtime_core0.ComponentProvideOptions, false, {}, any>;
|
|
1073
1073
|
declare const _default$26: typeof __VLS_export$21;
|
|
1074
1074
|
//#endregion
|
|
1075
|
-
//#region temp/packages/form/src/containers/TableGroupList.vue.d.ts
|
|
1075
|
+
//#region temp/packages/form/src/containers/table-group-list/TableGroupList.vue.d.ts
|
|
1076
1076
|
type __VLS_Props$20 = {
|
|
1077
1077
|
model: any;
|
|
1078
1078
|
lastValues?: any;
|
|
@@ -1088,7 +1088,9 @@ type __VLS_Props$20 = {
|
|
|
1088
1088
|
sortKey?: string;
|
|
1089
1089
|
sort?: boolean;
|
|
1090
1090
|
};
|
|
1091
|
-
declare const __VLS_export$20: _$_vue_runtime_core0.DefineComponent<__VLS_Props$20, {
|
|
1091
|
+
declare const __VLS_export$20: _$_vue_runtime_core0.DefineComponent<__VLS_Props$20, {
|
|
1092
|
+
toggleRowSelection: (row: any, selected: boolean) => void | undefined;
|
|
1093
|
+
}, {}, {}, {}, _$_vue_runtime_core0.ComponentOptionsMixin, _$_vue_runtime_core0.ComponentOptionsMixin, {
|
|
1092
1094
|
change: (...args: any[]) => void;
|
|
1093
1095
|
select: (...args: any[]) => void;
|
|
1094
1096
|
addDiffCount: (...args: any[]) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ref } from "vue";
|
|
2
|
-
//#region packages/form/src/table/useFullscreen.ts
|
|
3
|
-
var useFullscreen = () => {
|
|
4
|
-
const isFullscreen = ref(false);
|
|
5
|
-
const toggleFullscreen = () => {
|
|
6
|
-
if (isFullscreen.value) isFullscreen.value = false;
|
|
7
|
-
else isFullscreen.value = true;
|
|
8
|
-
};
|
|
9
|
-
return {
|
|
10
|
-
isFullscreen,
|
|
11
|
-
toggleFullscreen
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { useFullscreen };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
export const useFullscreen = () => {
|
|
4
|
-
const isFullscreen = ref(false);
|
|
5
|
-
|
|
6
|
-
const toggleFullscreen = () => {
|
|
7
|
-
if (isFullscreen.value) {
|
|
8
|
-
isFullscreen.value = false;
|
|
9
|
-
} else {
|
|
10
|
-
isFullscreen.value = true;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
isFullscreen,
|
|
16
|
-
toggleFullscreen,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|