@tmagic/form 1.7.0-beta.3 → 1.7.0-beta.4
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/tmagic-form.js +330 -138
- package/dist/tmagic-form.umd.cjs +327 -135
- package/package.json +9 -9
- package/src/FormDialog.vue +15 -2
- package/src/containers/Container.vue +35 -8
- package/src/containers/FormLabel.vue +26 -0
- package/src/containers/GroupList.vue +4 -3
- package/src/containers/Panel.vue +12 -1
- package/src/fields/Number.vue +15 -3
- package/src/fields/NumberRange.vue +21 -4
- package/src/fields/Text.vue +14 -2
- package/src/fields/Textarea.vue +15 -3
- package/src/table/Table.vue +11 -3
- package/src/table/useSortable.ts +1 -1
- package/src/table/useTableColumns.ts +59 -4
- package/src/utils/form.ts +1 -1
- package/types/index.d.ts +14 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.0-beta.
|
|
2
|
+
"version": "1.7.0-beta.4",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@element-plus/icons-vue": "^2.3.
|
|
40
|
+
"@element-plus/icons-vue": "^2.3.2",
|
|
41
41
|
"@popperjs/core": "^2.11.8",
|
|
42
|
-
"dayjs": "^1.11.
|
|
42
|
+
"dayjs": "^1.11.19",
|
|
43
43
|
"lodash-es": "^4.17.21",
|
|
44
|
-
"sortablejs": "^1.15.
|
|
44
|
+
"sortablejs": "^1.15.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/lodash-es": "^4.17.4",
|
|
48
|
-
"@types/sortablejs": "^1.15.
|
|
48
|
+
"@types/sortablejs": "^1.15.9",
|
|
49
49
|
"@vue/test-utils": "^2.4.6"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"vue": "^3.5.
|
|
52
|
+
"vue": "^3.5.24",
|
|
53
53
|
"typescript": "^5.9.3",
|
|
54
|
-
"@tmagic/design": "1.7.0-beta.
|
|
55
|
-
"@tmagic/utils": "1.7.0-beta.
|
|
56
|
-
"@tmagic/form-schema": "1.7.0-beta.
|
|
54
|
+
"@tmagic/design": "1.7.0-beta.4",
|
|
55
|
+
"@tmagic/utils": "1.7.0-beta.4",
|
|
56
|
+
"@tmagic/form-schema": "1.7.0-beta.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"typescript": {
|
package/src/FormDialog.vue
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
:width="width"
|
|
9
9
|
:zIndex="zIndex"
|
|
10
10
|
:fullscreen="fullscreen"
|
|
11
|
-
:close-on-click-modal="
|
|
11
|
+
:close-on-click-modal="closeOnClickModal"
|
|
12
|
+
:close-on-press-escape="closeOnPressEscape"
|
|
13
|
+
:destroy-on-close="destroyOnClose"
|
|
14
|
+
:show-close="showClose"
|
|
12
15
|
@close="closeHandler"
|
|
13
16
|
>
|
|
14
17
|
<div
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
</TMagicCol>
|
|
43
46
|
<TMagicCol :span="12">
|
|
44
47
|
<slot name="footer">
|
|
45
|
-
<TMagicButton @click="cancel" size="small">取 消</TMagicButton>
|
|
48
|
+
<TMagicButton v-if="showCancel" @click="cancel" size="small">取 消</TMagicButton>
|
|
46
49
|
<TMagicButton v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep"
|
|
47
50
|
>上一步</TMagicButton
|
|
48
51
|
>
|
|
@@ -87,11 +90,21 @@ const props = withDefaults(
|
|
|
87
90
|
size?: 'small' | 'default' | 'large';
|
|
88
91
|
confirmText?: string;
|
|
89
92
|
preventSubmitDefault?: boolean;
|
|
93
|
+
closeOnClickModal?: boolean;
|
|
94
|
+
closeOnPressEscape?: boolean;
|
|
95
|
+
destroyOnClose?: boolean;
|
|
96
|
+
showClose?: boolean;
|
|
97
|
+
showCancel?: boolean;
|
|
90
98
|
}>(),
|
|
91
99
|
{
|
|
92
100
|
config: () => [],
|
|
93
101
|
values: () => ({}),
|
|
94
102
|
confirmText: '确定',
|
|
103
|
+
closeOnClickModal: false,
|
|
104
|
+
closeOnPressEscape: false,
|
|
105
|
+
destroyOnClose: false,
|
|
106
|
+
showClose: true,
|
|
107
|
+
showCancel: true,
|
|
95
108
|
},
|
|
96
109
|
);
|
|
97
110
|
|
|
@@ -24,15 +24,23 @@
|
|
|
24
24
|
|
|
25
25
|
<template v-else-if="type && display && !showDiff">
|
|
26
26
|
<TMagicFormItem v-bind="formItemProps" :class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }">
|
|
27
|
-
<template #label
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
<template #label>
|
|
28
|
+
<FormLabel
|
|
29
|
+
:tip="config.tip"
|
|
30
|
+
:type="type"
|
|
31
|
+
:use-label="config.useLabel"
|
|
32
|
+
:label-title="config.labelTitle"
|
|
33
|
+
:text="text"
|
|
34
|
+
></FormLabel>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
30
37
|
<TMagicTooltip v-if="tooltip.text" :placement="tooltip.placement">
|
|
31
38
|
<component
|
|
32
39
|
v-bind="fieldsProps"
|
|
33
40
|
:is="tagName"
|
|
34
41
|
:model="model"
|
|
35
42
|
:last-values="lastValues"
|
|
43
|
+
:is-compare="isCompare"
|
|
36
44
|
@change="onChangeHandler"
|
|
37
45
|
@addDiffCount="onAddDiffCount"
|
|
38
46
|
></component>
|
|
@@ -47,12 +55,13 @@
|
|
|
47
55
|
:is="tagName"
|
|
48
56
|
:model="model"
|
|
49
57
|
:last-values="lastValues"
|
|
58
|
+
:is-compare="isCompare"
|
|
50
59
|
@change="onChangeHandler"
|
|
51
60
|
@addDiffCount="onAddDiffCount"
|
|
52
61
|
></component>
|
|
53
62
|
</TMagicFormItem>
|
|
54
63
|
|
|
55
|
-
<TMagicTooltip v-if="config.tip" placement="
|
|
64
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
56
65
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
57
66
|
<template #content>
|
|
58
67
|
<div v-html="config.tip"></div>
|
|
@@ -67,7 +76,15 @@
|
|
|
67
76
|
v-bind="formItemProps"
|
|
68
77
|
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text, 'show-diff': true }"
|
|
69
78
|
>
|
|
70
|
-
<template #label
|
|
79
|
+
<template #label>
|
|
80
|
+
<FormLabel
|
|
81
|
+
:tip="config.tip"
|
|
82
|
+
:type="type"
|
|
83
|
+
:use-label="config.useLabel"
|
|
84
|
+
:label-title="config.labelTitle"
|
|
85
|
+
:text="text"
|
|
86
|
+
></FormLabel>
|
|
87
|
+
</template>
|
|
71
88
|
<TMagicTooltip v-if="tooltip.text" :placement="tooltip.placement">
|
|
72
89
|
<component v-bind="fieldsProps" :is="tagName" :model="lastValues" @change="onChangeHandler"></component>
|
|
73
90
|
<template #content>
|
|
@@ -78,7 +95,7 @@
|
|
|
78
95
|
<component v-else v-bind="fieldsProps" :is="tagName" :model="lastValues" @change="onChangeHandler"></component>
|
|
79
96
|
</TMagicFormItem>
|
|
80
97
|
|
|
81
|
-
<TMagicTooltip v-if="config.tip" placement="
|
|
98
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
82
99
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
83
100
|
<template #content>
|
|
84
101
|
<div v-html="config.tip"></div>
|
|
@@ -91,7 +108,15 @@
|
|
|
91
108
|
:style="config.tip ? 'flex: 1' : ''"
|
|
92
109
|
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text, 'show-diff': true }"
|
|
93
110
|
>
|
|
94
|
-
<template #label
|
|
111
|
+
<template #label>
|
|
112
|
+
<FormLabel
|
|
113
|
+
:tip="config.tip"
|
|
114
|
+
:type="type"
|
|
115
|
+
:use-label="config.useLabel"
|
|
116
|
+
:label-title="config.labelTitle"
|
|
117
|
+
:text="text"
|
|
118
|
+
></FormLabel>
|
|
119
|
+
</template>
|
|
95
120
|
<TMagicTooltip v-if="tooltip.text" :placement="tooltip.placement">
|
|
96
121
|
<component v-bind="fieldsProps" :is="tagName" :model="model" @change="onChangeHandler"></component>
|
|
97
122
|
<template #content>
|
|
@@ -102,7 +127,7 @@
|
|
|
102
127
|
<component v-else v-bind="fieldsProps" :is="tagName" :model="model" @change="onChangeHandler"></component>
|
|
103
128
|
</TMagicFormItem>
|
|
104
129
|
|
|
105
|
-
<TMagicTooltip v-if="config.tip" placement="
|
|
130
|
+
<TMagicTooltip v-if="config.tip && type === 'checkbox' && !config.useLabel" placement="top">
|
|
106
131
|
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
107
132
|
<template #content>
|
|
108
133
|
<div v-html="config.tip"></div>
|
|
@@ -157,6 +182,8 @@ import type {
|
|
|
157
182
|
} from '../schema';
|
|
158
183
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
159
184
|
|
|
185
|
+
import FormLabel from './FormLabel.vue';
|
|
186
|
+
|
|
160
187
|
defineOptions({
|
|
161
188
|
name: 'MFormContainer',
|
|
162
189
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span v-if="tip" style="display: inline-flex; align-items: center">
|
|
3
|
+
<span v-html="type === 'checkbox' && !useLabel ? '' : text" :title="labelTitle"></span>
|
|
4
|
+
<TMagicTooltip v-if="tip && (type !== 'checkbox' || useLabel)" placement="top">
|
|
5
|
+
<TMagicIcon style="margin-left: 5px; display: flex"><warning-filled /></TMagicIcon>
|
|
6
|
+
<template #content>
|
|
7
|
+
<div v-html="tip"></div>
|
|
8
|
+
</template>
|
|
9
|
+
</TMagicTooltip>
|
|
10
|
+
</span>
|
|
11
|
+
<span v-else v-html="type === 'checkbox' && !useLabel ? '' : text" :title="labelTitle"></span>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { WarningFilled } from '@element-plus/icons-vue';
|
|
16
|
+
|
|
17
|
+
import { TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
18
|
+
|
|
19
|
+
defineProps<{
|
|
20
|
+
tip?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
useLabel?: boolean;
|
|
23
|
+
text?: string;
|
|
24
|
+
labelTitle?: string;
|
|
25
|
+
}>();
|
|
26
|
+
</script>
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
<div style="display: flex; justify-content: flex-end; flex: 1">
|
|
34
34
|
<TMagicButton
|
|
35
35
|
v-if="addable"
|
|
36
|
-
type="primary"
|
|
37
36
|
:size="config.enableToggleMode ? 'small' : 'default'"
|
|
37
|
+
:icon="Plus"
|
|
38
|
+
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
|
|
38
39
|
:disabled="disabled"
|
|
39
40
|
@click="addHandler"
|
|
40
|
-
|
|
41
|
+
>{{ config.addButtonConfig?.text || '新增' }}</TMagicButton
|
|
41
42
|
>
|
|
42
43
|
</div>
|
|
43
44
|
</div>
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
|
|
47
48
|
<script setup lang="ts">
|
|
48
49
|
import { computed, inject } from 'vue';
|
|
49
|
-
import { Grid } from '@element-plus/icons-vue';
|
|
50
|
+
import { Grid, Plus } from '@element-plus/icons-vue';
|
|
50
51
|
import { cloneDeep } from 'lodash-es';
|
|
51
52
|
|
|
52
53
|
import { TMagicButton } from '@tmagic/design';
|
package/src/containers/Panel.vue
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
<div style="width: 100%; display: flex; align-items: center">
|
|
9
9
|
<TMagicButton style="padding: 0" link :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand">
|
|
10
10
|
</TMagicButton>
|
|
11
|
+
<slot name="header">
|
|
12
|
+
<span style="cursor: pointer" @click="expand = !expand">{{ filter(config.title) }}</span>
|
|
13
|
+
</slot>
|
|
14
|
+
|
|
11
15
|
<span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
|
|
12
|
-
<slot name="header">{{ filter(config.title) }}</slot>
|
|
13
16
|
</div>
|
|
14
17
|
</template>
|
|
15
18
|
|
|
@@ -101,4 +104,12 @@ const changeHandler = (v: any, eventData: ContainerChangeEventData) => {
|
|
|
101
104
|
emit('change', props.model, eventData);
|
|
102
105
|
};
|
|
103
106
|
const onAddDiffCount = () => emit('addDiffCount');
|
|
107
|
+
|
|
108
|
+
defineExpose({
|
|
109
|
+
getExpand: () => expand.value,
|
|
110
|
+
|
|
111
|
+
setExpand: (v: boolean) => {
|
|
112
|
+
expand.value = v;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
104
115
|
</script>
|
package/src/fields/Number.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TMagicInputNumber
|
|
3
3
|
v-if="model"
|
|
4
|
-
|
|
4
|
+
v-model="value"
|
|
5
5
|
clearable
|
|
6
6
|
controls-position="right"
|
|
7
7
|
:size="size"
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
:step="config.step"
|
|
11
11
|
:placeholder="config.placeholder"
|
|
12
12
|
:disabled="disabled"
|
|
13
|
-
@
|
|
13
|
+
@change="changeHandler"
|
|
14
14
|
@input="inputHandler"
|
|
15
15
|
></TMagicInputNumber>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script lang="ts" setup>
|
|
19
|
-
import { inject } from 'vue';
|
|
19
|
+
import { inject, ref, watch } from 'vue';
|
|
20
20
|
|
|
21
21
|
import { TMagicInputNumber } from '@tmagic/design';
|
|
22
22
|
|
|
@@ -34,6 +34,18 @@ const emit = defineEmits<{
|
|
|
34
34
|
input: [values: number];
|
|
35
35
|
}>();
|
|
36
36
|
|
|
37
|
+
const value = ref<number>();
|
|
38
|
+
|
|
39
|
+
watch(
|
|
40
|
+
() => props.model[props.name],
|
|
41
|
+
(v) => {
|
|
42
|
+
value.value = v;
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
immediate: true,
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
|
|
37
49
|
useAddField(props.prop);
|
|
38
50
|
|
|
39
51
|
const mForm = inject<FormState | null>('mForm');
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-number-range">
|
|
3
3
|
<TMagicInput
|
|
4
|
-
|
|
4
|
+
v-model="firstValue"
|
|
5
5
|
:clearable="config.clearable ?? true"
|
|
6
6
|
:size="size"
|
|
7
7
|
:disabled="disabled"
|
|
8
|
-
@
|
|
8
|
+
@change="minChangeHandler"
|
|
9
9
|
></TMagicInput>
|
|
10
10
|
<span class="split-tag">-</span>
|
|
11
11
|
<TMagicInput
|
|
12
|
-
|
|
12
|
+
v-model="secondValue"
|
|
13
13
|
:clearable="config.clearable ?? true"
|
|
14
14
|
:size="size"
|
|
15
15
|
:disabled="disabled"
|
|
16
|
-
@
|
|
16
|
+
@change="maxChangeHandler"
|
|
17
17
|
></TMagicInput>
|
|
18
18
|
</div>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script lang="ts" setup>
|
|
22
|
+
import { ref, watch } from 'vue';
|
|
23
|
+
|
|
22
24
|
import { TMagicInput } from '@tmagic/design';
|
|
23
25
|
|
|
24
26
|
import type { FieldProps, NumberRangeConfig } from '../schema';
|
|
@@ -34,6 +36,21 @@ const emit = defineEmits<{
|
|
|
34
36
|
change: [values: [number, number]];
|
|
35
37
|
}>();
|
|
36
38
|
|
|
39
|
+
const firstValue = ref<number>();
|
|
40
|
+
const secondValue = ref<number>();
|
|
41
|
+
|
|
42
|
+
watch(
|
|
43
|
+
() => props.model[props.name],
|
|
44
|
+
([first, second]) => {
|
|
45
|
+
firstValue.value = first;
|
|
46
|
+
secondValue.value = second;
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
immediate: true,
|
|
50
|
+
deep: true,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
37
54
|
useAddField(props.prop);
|
|
38
55
|
|
|
39
56
|
if (!Array.isArray(props.model[props.name])) {
|
package/src/fields/Text.vue
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-text">
|
|
3
3
|
<TMagicInput
|
|
4
|
-
|
|
4
|
+
v-model="value"
|
|
5
5
|
ref="input"
|
|
6
6
|
clearable
|
|
7
7
|
:size="size"
|
|
8
8
|
:placeholder="config.placeholder"
|
|
9
9
|
:disabled="disabled"
|
|
10
|
-
@
|
|
10
|
+
@change="changeHandler"
|
|
11
11
|
@input="inputHandler"
|
|
12
12
|
@keyup="keyUpHandler($event)"
|
|
13
13
|
>
|
|
@@ -67,6 +67,18 @@ useAddField(props.prop);
|
|
|
67
67
|
|
|
68
68
|
const mForm = inject<FormState | undefined>('mForm');
|
|
69
69
|
|
|
70
|
+
const value = ref('');
|
|
71
|
+
|
|
72
|
+
watch(
|
|
73
|
+
() => props.model[props.name],
|
|
74
|
+
(v) => {
|
|
75
|
+
value.value = v;
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
immediate: true,
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
70
82
|
const appendConfig = computed(() => {
|
|
71
83
|
if (typeof props.config.append === 'string') {
|
|
72
84
|
return {
|
package/src/fields/Textarea.vue
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TMagicInput
|
|
3
|
-
|
|
3
|
+
v-model="value"
|
|
4
4
|
type="textarea"
|
|
5
5
|
:size="size"
|
|
6
6
|
clearable
|
|
7
7
|
:placeholder="config.placeholder"
|
|
8
8
|
:disabled="disabled"
|
|
9
9
|
:rows="config.rows"
|
|
10
|
-
@
|
|
10
|
+
@change="changeHandler"
|
|
11
11
|
@input="inputHandler"
|
|
12
12
|
>
|
|
13
13
|
</TMagicInput>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script lang="ts" setup>
|
|
17
|
-
import { inject } from 'vue';
|
|
17
|
+
import { inject, ref, watch } from 'vue';
|
|
18
18
|
|
|
19
19
|
import { TMagicInput } from '@tmagic/design';
|
|
20
20
|
|
|
@@ -32,6 +32,18 @@ const emit = defineEmits<{
|
|
|
32
32
|
input: [value: string];
|
|
33
33
|
}>();
|
|
34
34
|
|
|
35
|
+
const value = ref('');
|
|
36
|
+
|
|
37
|
+
watch(
|
|
38
|
+
() => props.model[props.name],
|
|
39
|
+
(v) => {
|
|
40
|
+
value.value = v;
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
immediate: true,
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
35
47
|
useAddField(props.prop);
|
|
36
48
|
|
|
37
49
|
const mForm = inject<FormState | null>('mForm');
|
package/src/table/Table.vue
CHANGED
|
@@ -60,8 +60,16 @@
|
|
|
60
60
|
>清空</TMagicButton
|
|
61
61
|
>
|
|
62
62
|
</div>
|
|
63
|
-
<TMagicButton
|
|
64
|
-
|
|
63
|
+
<TMagicButton
|
|
64
|
+
v-if="addable"
|
|
65
|
+
class="m-form-table-add-button"
|
|
66
|
+
size="small"
|
|
67
|
+
plain
|
|
68
|
+
:icon="Plus"
|
|
69
|
+
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
|
|
70
|
+
:disabled="disabled"
|
|
71
|
+
@click="newHandler()"
|
|
72
|
+
>{{ config.addButtonConfig?.text || '新增一行' }}</TMagicButton
|
|
65
73
|
>
|
|
66
74
|
</div>
|
|
67
75
|
|
|
@@ -85,7 +93,7 @@
|
|
|
85
93
|
|
|
86
94
|
<script setup lang="ts">
|
|
87
95
|
import { computed, ref, useTemplateRef } from 'vue';
|
|
88
|
-
import { FullScreen, Grid } from '@element-plus/icons-vue';
|
|
96
|
+
import { FullScreen, Grid, Plus } from '@element-plus/icons-vue';
|
|
89
97
|
|
|
90
98
|
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload, useZIndex } from '@tmagic/design';
|
|
91
99
|
|
package/src/table/useSortable.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const useSortable = (
|
|
|
20
20
|
const rowDrop = () => {
|
|
21
21
|
sortable?.destroy();
|
|
22
22
|
const tableEl = tMagicTableRef.value?.getEl();
|
|
23
|
-
const tBodyEl = tableEl?.querySelector('.el-table__body > tbody');
|
|
23
|
+
const tBodyEl = tableEl?.querySelector('.el-table__body > tbody') || tableEl?.querySelector('.t-table__body');
|
|
24
24
|
if (!tBodyEl) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { computed, h, inject, type Ref } from 'vue';
|
|
2
|
+
import { WarningFilled } from '@element-plus/icons-vue';
|
|
2
3
|
import { cloneDeep } from 'lodash-es';
|
|
3
4
|
|
|
4
|
-
import type
|
|
5
|
+
import { type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
5
6
|
import type { FormState, TableColumnConfig } from '@tmagic/form-schema';
|
|
6
7
|
|
|
7
8
|
import Container from '../containers/Container.vue';
|
|
@@ -43,6 +44,19 @@ export const useTableColumns = (
|
|
|
43
44
|
return fuc;
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
const titleTip = (fuc: any) => {
|
|
48
|
+
if (typeof fuc === 'function') {
|
|
49
|
+
return fuc(mForm, {
|
|
50
|
+
values: mForm?.initValues,
|
|
51
|
+
model: props.model,
|
|
52
|
+
formValue: mForm ? mForm.values : props.model,
|
|
53
|
+
prop: props.prop,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return fuc;
|
|
58
|
+
};
|
|
59
|
+
|
|
46
60
|
const selection = computed(() => {
|
|
47
61
|
if (typeof props.config.selection === 'function') {
|
|
48
62
|
return props.config.selection(mForm, { model: props.model[modelName.value] });
|
|
@@ -87,10 +101,16 @@ export const useTableColumns = (
|
|
|
87
101
|
});
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
let actionFixed: 'left' | 'right' | undefined = props.config.fixed === false ? undefined : 'left';
|
|
105
|
+
|
|
106
|
+
if (typeof props.config.fixed === 'string' && ['left', 'right'].includes(props.config.fixed)) {
|
|
107
|
+
actionFixed = props.config.fixed;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const actionClumn = {
|
|
91
111
|
props: {
|
|
92
112
|
label: '操作',
|
|
93
|
-
fixed:
|
|
113
|
+
fixed: actionFixed,
|
|
94
114
|
width: props.config.operateColWidth || 112,
|
|
95
115
|
align: 'center',
|
|
96
116
|
},
|
|
@@ -110,7 +130,11 @@ export const useTableColumns = (
|
|
|
110
130
|
emit('change', v);
|
|
111
131
|
},
|
|
112
132
|
}),
|
|
113
|
-
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if (actionFixed !== 'right') {
|
|
136
|
+
columns.push(actionClumn);
|
|
137
|
+
}
|
|
114
138
|
|
|
115
139
|
if (props.sort && props.model[modelName.value] && props.model[modelName.value].length > 1) {
|
|
116
140
|
columns.push({
|
|
@@ -158,6 +182,8 @@ export const useTableColumns = (
|
|
|
158
182
|
|
|
159
183
|
for (const column of props.config.items) {
|
|
160
184
|
if (column.type !== 'hidden' && display(column.display)) {
|
|
185
|
+
const titleTipValue = titleTip(column.titleTip);
|
|
186
|
+
|
|
161
187
|
columns.push({
|
|
162
188
|
props: {
|
|
163
189
|
prop: column.name,
|
|
@@ -181,10 +207,39 @@ export const useTableColumns = (
|
|
|
181
207
|
onChange: changeHandler,
|
|
182
208
|
onAddDiffCount,
|
|
183
209
|
}),
|
|
210
|
+
title: titleTipValue
|
|
211
|
+
? () =>
|
|
212
|
+
h(
|
|
213
|
+
TMagicTooltip,
|
|
214
|
+
{ placement: 'top' },
|
|
215
|
+
{
|
|
216
|
+
default: () =>
|
|
217
|
+
h(
|
|
218
|
+
'span',
|
|
219
|
+
{
|
|
220
|
+
style: {
|
|
221
|
+
display: 'inline-flex',
|
|
222
|
+
alignItems: 'center',
|
|
223
|
+
gap: '5px',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
[h('span', column.label), h(TMagicIcon, {}, { default: () => h(WarningFilled) })],
|
|
227
|
+
),
|
|
228
|
+
content: () =>
|
|
229
|
+
h('div', {
|
|
230
|
+
innerHTML: titleTipValue,
|
|
231
|
+
}),
|
|
232
|
+
},
|
|
233
|
+
)
|
|
234
|
+
: undefined,
|
|
184
235
|
});
|
|
185
236
|
}
|
|
186
237
|
}
|
|
187
238
|
|
|
239
|
+
if (actionFixed === 'right') {
|
|
240
|
+
columns.push(actionClumn);
|
|
241
|
+
}
|
|
242
|
+
|
|
188
243
|
return columns;
|
|
189
244
|
});
|
|
190
245
|
|
package/src/utils/form.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -109,6 +109,11 @@ type __VLS_Props$t = {
|
|
|
109
109
|
size?: 'small' | 'default' | 'large';
|
|
110
110
|
confirmText?: string;
|
|
111
111
|
preventSubmitDefault?: boolean;
|
|
112
|
+
closeOnClickModal?: boolean;
|
|
113
|
+
closeOnPressEscape?: boolean;
|
|
114
|
+
destroyOnClose?: boolean;
|
|
115
|
+
showClose?: boolean;
|
|
116
|
+
showCancel?: boolean;
|
|
112
117
|
};
|
|
113
118
|
declare var __VLS_19$1: {};
|
|
114
119
|
declare var __VLS_32: {};
|
|
@@ -350,8 +355,13 @@ declare const __VLS_base$4: _vue_runtime_core.DefineComponent<__VLS_Props$t, {
|
|
|
350
355
|
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
351
356
|
}>, {
|
|
352
357
|
values: Object;
|
|
358
|
+
closeOnClickModal: boolean;
|
|
359
|
+
closeOnPressEscape: boolean;
|
|
360
|
+
destroyOnClose: boolean;
|
|
361
|
+
showClose: boolean;
|
|
353
362
|
config: FormConfig;
|
|
354
363
|
confirmText: string;
|
|
364
|
+
showCancel: boolean;
|
|
355
365
|
}, {}, {}, {}, string, _vue_runtime_core.ComponentProvideOptions, false, {}, any>;
|
|
356
366
|
declare const __VLS_export$u: __VLS_WithSlots$4<typeof __VLS_base$4, __VLS_Slots$4>;
|
|
357
367
|
declare const _default$v: typeof __VLS_export$u;
|
|
@@ -992,7 +1002,10 @@ type __VLS_Slots$1 = {} & {
|
|
|
992
1002
|
} & {
|
|
993
1003
|
default?: (props: typeof __VLS_18) => any;
|
|
994
1004
|
};
|
|
995
|
-
declare const __VLS_base$1: _vue_runtime_core.DefineComponent<__VLS_Props$n, {
|
|
1005
|
+
declare const __VLS_base$1: _vue_runtime_core.DefineComponent<__VLS_Props$n, {
|
|
1006
|
+
getExpand: () => boolean;
|
|
1007
|
+
setExpand: (v: boolean) => void;
|
|
1008
|
+
}, {}, {}, {}, _vue_runtime_core.ComponentOptionsMixin, _vue_runtime_core.ComponentOptionsMixin, {
|
|
996
1009
|
change: (v: any, eventData: ContainerChangeEventData) => any;
|
|
997
1010
|
addDiffCount: () => any;
|
|
998
1011
|
}, string, _vue_runtime_core.PublicProps, Readonly<__VLS_Props$n> & Readonly<{
|