@tmagic/form 1.7.0-beta.2 → 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/style.css +20 -7
- package/dist/tmagic-form.js +754 -535
- package/dist/tmagic-form.umd.cjs +751 -532
- package/package.json +9 -9
- package/src/FormDialog.vue +15 -2
- package/src/FormDrawer.vue +1 -1
- package/src/containers/Container.vue +35 -8
- package/src/containers/FormLabel.vue +26 -0
- package/src/containers/GroupList.vue +18 -12
- package/src/containers/GroupListItem.vue +72 -70
- package/src/containers/Panel.vue +12 -1
- package/src/fields/Link.vue +3 -2
- package/src/fields/Number.vue +15 -3
- package/src/fields/NumberRange.vue +21 -4
- package/src/fields/Text.vue +36 -6
- package/src/fields/Textarea.vue +15 -3
- package/src/table/Table.vue +24 -11
- package/src/table/useAdd.ts +1 -0
- package/src/table/useFullscreen.ts +1 -11
- package/src/table/useSortable.ts +1 -1
- package/src/table/useTableColumns.ts +59 -4
- package/src/theme/group-list.scss +15 -0
- package/src/theme/table.scss +6 -3
- package/src/utils/form.ts +1 -1
- package/types/index.d.ts +16 -3
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/
|
|
55
|
-
"@tmagic/
|
|
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
|
|
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
|
|
package/src/FormDrawer.vue
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</TMagicCol>
|
|
43
43
|
<TMagicCol :span="12">
|
|
44
44
|
<slot name="footer">
|
|
45
|
-
<TMagicButton
|
|
45
|
+
<TMagicButton @click="handleClose">关闭</TMagicButton>
|
|
46
46
|
<TMagicButton type="primary" :disabled="disabled" :loading="saveFetch" @click="submitHandler">{{
|
|
47
47
|
confirmText
|
|
48
48
|
}}</TMagicButton>
|
|
@@ -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>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="m-fields-group-list">
|
|
3
3
|
<div v-if="config.extra" v-html="config.extra" style="color: rgba(0, 0, 0, 0.45)"></div>
|
|
4
4
|
<div v-if="!model[name] || !model[name].length" class="el-table__empty-block">
|
|
5
|
-
<span class="el-table__empty-text">暂无数据</span>
|
|
5
|
+
<span class="el-table__empty-text t-table__empty">暂无数据</span>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<MFieldsGroupListItem
|
|
@@ -26,22 +26,28 @@
|
|
|
26
26
|
@addDiffCount="onAddDiffCount()"
|
|
27
27
|
></MFieldsGroupListItem>
|
|
28
28
|
|
|
29
|
-
<
|
|
30
|
-
v-if="
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
<div class="m-fields-group-list-footer">
|
|
30
|
+
<TMagicButton v-if="config.enableToggleMode" :icon="Grid" size="small" @click="toggleMode"
|
|
31
|
+
>切换为表格</TMagicButton
|
|
32
|
+
>
|
|
33
|
+
<div style="display: flex; justify-content: flex-end; flex: 1">
|
|
34
|
+
<TMagicButton
|
|
35
|
+
v-if="addable"
|
|
36
|
+
:size="config.enableToggleMode ? 'small' : 'default'"
|
|
37
|
+
:icon="Plus"
|
|
38
|
+
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
|
|
39
|
+
:disabled="disabled"
|
|
40
|
+
@click="addHandler"
|
|
41
|
+
>{{ config.addButtonConfig?.text || '新增' }}</TMagicButton
|
|
42
|
+
>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
39
45
|
</div>
|
|
40
46
|
</template>
|
|
41
47
|
|
|
42
48
|
<script setup lang="ts">
|
|
43
49
|
import { computed, inject } from 'vue';
|
|
44
|
-
import { Grid } from '@element-plus/icons-vue';
|
|
50
|
+
import { Grid, Plus } from '@element-plus/icons-vue';
|
|
45
51
|
import { cloneDeep } from 'lodash-es';
|
|
46
52
|
|
|
47
53
|
import { TMagicButton } from '@tmagic/design';
|
|
@@ -1,90 +1,92 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
v-show="showDelete"
|
|
10
|
-
type="danger"
|
|
11
|
-
size="small"
|
|
12
|
-
link
|
|
13
|
-
:icon="Delete"
|
|
14
|
-
:disabled="disabled"
|
|
15
|
-
@click="removeHandler"
|
|
16
|
-
></TMagicButton>
|
|
17
|
-
|
|
18
|
-
<TMagicButton
|
|
19
|
-
v-if="copyable"
|
|
20
|
-
link
|
|
21
|
-
size="small"
|
|
22
|
-
type="primary"
|
|
23
|
-
:icon="DocumentCopy"
|
|
24
|
-
:disabled="disabled"
|
|
25
|
-
@click="copyHandler"
|
|
26
|
-
>复制</TMagicButton
|
|
27
|
-
>
|
|
28
|
-
|
|
29
|
-
<template v-if="movable">
|
|
2
|
+
<TMagicCard class="m-fields-group-list-item" :body-style="{ display: expand ? 'block' : 'none' }">
|
|
3
|
+
<template #header>
|
|
4
|
+
<div>
|
|
5
|
+
<TMagicButton link :disabled="disabled" @click="expandHandler">
|
|
6
|
+
<TMagicIcon><CaretBottom v-if="expand" /><CaretRight v-else /></TMagicIcon>{{ title }}
|
|
7
|
+
</TMagicButton>
|
|
8
|
+
|
|
30
9
|
<TMagicButton
|
|
31
|
-
v-show="
|
|
32
|
-
|
|
10
|
+
v-show="showDelete"
|
|
11
|
+
type="danger"
|
|
33
12
|
size="small"
|
|
13
|
+
link
|
|
14
|
+
:icon="Delete"
|
|
34
15
|
:disabled="disabled"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
>
|
|
16
|
+
@click="removeHandler"
|
|
17
|
+
></TMagicButton>
|
|
18
|
+
|
|
39
19
|
<TMagicButton
|
|
40
|
-
v-
|
|
20
|
+
v-if="copyable"
|
|
41
21
|
link
|
|
42
22
|
size="small"
|
|
23
|
+
type="primary"
|
|
24
|
+
:icon="DocumentCopy"
|
|
43
25
|
:disabled="disabled"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
>下移</TMagicButton
|
|
26
|
+
@click="copyHandler"
|
|
27
|
+
>复制</TMagicButton
|
|
47
28
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
|
|
30
|
+
<template v-if="movable">
|
|
31
|
+
<TMagicButton
|
|
32
|
+
v-show="index !== 0"
|
|
33
|
+
link
|
|
34
|
+
size="small"
|
|
35
|
+
:disabled="disabled"
|
|
36
|
+
:icon="CaretTop"
|
|
37
|
+
@click="changeOrder(-1)"
|
|
38
|
+
>上移</TMagicButton
|
|
39
|
+
>
|
|
58
40
|
<TMagicButton
|
|
41
|
+
v-show="index !== length - 1"
|
|
59
42
|
link
|
|
60
43
|
size="small"
|
|
61
|
-
type="primary"
|
|
62
|
-
:icon="Position"
|
|
63
44
|
:disabled="disabled"
|
|
64
|
-
|
|
65
|
-
|
|
45
|
+
:icon="CaretBottom"
|
|
46
|
+
@click="changeOrder(1)"
|
|
47
|
+
>下移</TMagicButton
|
|
66
48
|
>
|
|
67
49
|
</template>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
|
|
51
|
+
<TMagicPopover
|
|
52
|
+
v-if="config.moveSpecifyLocation"
|
|
53
|
+
trigger="click"
|
|
54
|
+
placement="top"
|
|
55
|
+
width="200"
|
|
56
|
+
:visible="moveSpecifyLocationVisible"
|
|
57
|
+
>
|
|
58
|
+
<template #reference>
|
|
59
|
+
<TMagicButton
|
|
60
|
+
link
|
|
73
61
|
size="small"
|
|
74
|
-
|
|
62
|
+
type="primary"
|
|
63
|
+
:icon="Position"
|
|
75
64
|
:disabled="disabled"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<
|
|
65
|
+
@click="moveSpecifyLocationVisible = true"
|
|
66
|
+
>移动至</TMagicButton
|
|
67
|
+
>
|
|
68
|
+
</template>
|
|
69
|
+
<div>
|
|
70
|
+
<div>
|
|
71
|
+
第<TMagicInputNumber
|
|
72
|
+
style="margin: 0 5px"
|
|
73
|
+
v-model="moveSpecifyLocationIndex"
|
|
74
|
+
size="small"
|
|
75
|
+
:min="1"
|
|
76
|
+
:disabled="disabled"
|
|
77
|
+
></TMagicInputNumber
|
|
78
|
+
>行
|
|
79
|
+
</div>
|
|
80
|
+
<div style="text-align: right; margin-top: 20px">
|
|
81
|
+
<TMagicButton size="small" text @click="moveSpecifyLocationVisible = false">取消</TMagicButton>
|
|
82
|
+
<TMagicButton size="small" type="primary" @click="moveSpecifyLocationHandler">确认</TMagicButton>
|
|
83
|
+
</div>
|
|
82
84
|
</div>
|
|
83
|
-
</
|
|
84
|
-
</TMagicPopover>
|
|
85
|
+
</TMagicPopover>
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
<span v-if="itemExtra" v-html="itemExtra" class="m-form-tip"></span>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
88
90
|
|
|
89
91
|
<Container
|
|
90
92
|
v-if="expand"
|
|
@@ -99,14 +101,14 @@
|
|
|
99
101
|
@change="changeHandler"
|
|
100
102
|
@addDiffCount="onAddDiffCount()"
|
|
101
103
|
></Container>
|
|
102
|
-
</
|
|
104
|
+
</TMagicCard>
|
|
103
105
|
</template>
|
|
104
106
|
|
|
105
107
|
<script setup lang="ts">
|
|
106
108
|
import { computed, inject, ref } from 'vue';
|
|
107
109
|
import { CaretBottom, CaretRight, CaretTop, Delete, DocumentCopy, Position } from '@element-plus/icons-vue';
|
|
108
110
|
|
|
109
|
-
import { TMagicButton, TMagicIcon, TMagicInputNumber, TMagicPopover } from '@tmagic/design';
|
|
111
|
+
import { TMagicButton, TMagicCard, TMagicIcon, TMagicInputNumber, TMagicPopover } from '@tmagic/design';
|
|
110
112
|
|
|
111
113
|
import type { ContainerChangeEventData, FormState, GroupListConfig } from '../schema';
|
|
112
114
|
import { filterFunction } from '../utils/form';
|
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/Link.vue
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script lang="ts" setup>
|
|
20
|
-
import { computed, inject, ref } from 'vue';
|
|
20
|
+
import { computed, inject, readonly, ref } from 'vue';
|
|
21
21
|
|
|
22
22
|
import { TMagicButton } from '@tmagic/design';
|
|
23
23
|
|
|
@@ -54,7 +54,8 @@ const formConfig = computed(() => {
|
|
|
54
54
|
if (typeof props.config.form === 'function') {
|
|
55
55
|
return props.config.form(mForm, {
|
|
56
56
|
model: props.model || {},
|
|
57
|
-
values:
|
|
57
|
+
values: mForm ? readonly(mForm.initValues) : null,
|
|
58
|
+
formValue: props.values || {},
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
return props.config.form;
|
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])) {
|