@tmagic/form 1.2.14 → 1.2.15
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 +66 -71
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +64 -69
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/containers/Fieldset.vue +2 -9
- package/src/containers/Table.vue +1 -1
- package/src/containers/Tabs.vue +65 -60
- package/src/fields/Select.vue +2 -2
- package/src/fields/Text.vue +3 -3
- package/src/schema.ts +1 -0
- package/types/schema.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.15",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@element-plus/icons-vue": "^2.0.9",
|
|
39
|
-
"@tmagic/design": "1.2.
|
|
40
|
-
"@tmagic/utils": "1.2.
|
|
39
|
+
"@tmagic/design": "1.2.15",
|
|
40
|
+
"@tmagic/utils": "1.2.15",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
43
|
"vue": "^3.2.37"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
:prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
|
|
11
11
|
:true-label="1"
|
|
12
12
|
:false-label="0"
|
|
13
|
+
@update:modelValue="change"
|
|
13
14
|
><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
|
|
14
15
|
></TMagicCheckbox>
|
|
15
16
|
</component>
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
</template>
|
|
62
63
|
|
|
63
64
|
<script lang="ts" setup name="MFormFieldset">
|
|
64
|
-
import { computed, inject
|
|
65
|
+
import { computed, inject } from 'vue';
|
|
65
66
|
|
|
66
67
|
import { TMagicCheckbox } from '@tmagic/design';
|
|
67
68
|
|
|
@@ -115,13 +116,5 @@ const change = () => {
|
|
|
115
116
|
|
|
116
117
|
const key = (item: any, index: number) => item[mForm?.keyProp || '__key'] ?? index;
|
|
117
118
|
|
|
118
|
-
if (props.config.checkbox && name.value) {
|
|
119
|
-
watch(
|
|
120
|
-
() => props.model[name.value]?.value,
|
|
121
|
-
() => {
|
|
122
|
-
emit('change', props.model);
|
|
123
|
-
},
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
119
|
const onAddDiffCount = () => emit('addDiffCount');
|
|
127
120
|
</script>
|
package/src/containers/Table.vue
CHANGED
package/src/containers/Tabs.vue
CHANGED
|
@@ -1,71 +1,77 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<component
|
|
3
3
|
v-model="activeTabName"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
v-bind="
|
|
5
|
+
tabsComponent.props({
|
|
6
|
+
type: config.tabType,
|
|
7
|
+
editable: config.editable || false,
|
|
8
|
+
tabPosition: config.tabPosition || 'top',
|
|
9
|
+
})
|
|
10
|
+
"
|
|
11
|
+
:is="tabsComponent.component"
|
|
12
|
+
:class="`tmagic-design-tabs ${config.dynamic ? 'magic-form-dynamic-tab' : 'magic-form-tab'}`"
|
|
8
13
|
@tab-click="tabClickHandler"
|
|
9
14
|
@tab-add="onTabAdd"
|
|
10
15
|
@tab-remove="onTabRemove"
|
|
11
16
|
>
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
17
|
+
<component
|
|
18
|
+
v-for="(tab, tabIndex) in tabs"
|
|
19
|
+
:is="tabPaneComponent.component"
|
|
20
|
+
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
|
|
21
|
+
v-bind="tabPaneComponent.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false })"
|
|
22
|
+
>
|
|
23
|
+
<template #label>
|
|
24
|
+
<span>
|
|
25
|
+
{{ filter(tab.title)
|
|
26
|
+
}}<TMagicBadge
|
|
27
|
+
:hidden="!diffCount[tabIndex]"
|
|
28
|
+
:value="diffCount[tabIndex]"
|
|
29
|
+
class="diff-count-badge"
|
|
30
|
+
></TMagicBadge>
|
|
31
|
+
</span>
|
|
32
|
+
</template>
|
|
33
|
+
<Container
|
|
34
|
+
v-for="item in tabItems(tab)"
|
|
35
|
+
:key="item[mForm?.keyProp || '__key']"
|
|
36
|
+
:config="item"
|
|
37
|
+
:disabled="disabled"
|
|
38
|
+
:model="
|
|
39
|
+
config.dynamic
|
|
40
|
+
? (name ? model[name] : model)[tabIndex]
|
|
41
|
+
: tab.name
|
|
42
|
+
? (name ? model[name] : model)[tab.name]
|
|
43
|
+
: name
|
|
44
|
+
? model[name]
|
|
45
|
+
: model
|
|
46
|
+
"
|
|
47
|
+
:last-values="
|
|
48
|
+
isEmpty(lastValues)
|
|
49
|
+
? {}
|
|
50
|
+
: config.dynamic
|
|
51
|
+
? (name ? lastValues[name] : lastValues)[tabIndex]
|
|
52
|
+
: tab.name
|
|
53
|
+
? (name ? lastValues[name] : lastValues)[tab.name]
|
|
54
|
+
: name
|
|
55
|
+
? lastValues[name]
|
|
56
|
+
: lastValues
|
|
57
|
+
"
|
|
58
|
+
:is-compare="isCompare"
|
|
59
|
+
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
|
60
|
+
:size="size"
|
|
61
|
+
:label-width="tab.labelWidth || labelWidth"
|
|
62
|
+
:expand-more="expandMore"
|
|
63
|
+
@change="changeHandler"
|
|
64
|
+
@addDiffCount="onAddDiffCount(tabIndex)"
|
|
65
|
+
></Container>
|
|
66
|
+
</component>
|
|
67
|
+
</component>
|
|
62
68
|
</template>
|
|
63
69
|
|
|
64
70
|
<script setup lang="ts" name="MFormTabs">
|
|
65
71
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
66
72
|
import { cloneDeep, isEmpty } from 'lodash-es';
|
|
67
73
|
|
|
68
|
-
import { getConfig,
|
|
74
|
+
import { getConfig, TMagicBadge } from '@tmagic/design';
|
|
69
75
|
|
|
70
76
|
import { FormState, TabConfig, TabPaneConfig } from '../schema';
|
|
71
77
|
import { display as displayFunc, filterFunction } from '../utils/form';
|
|
@@ -76,7 +82,8 @@ type DiffCount = {
|
|
|
76
82
|
[tabIndex: number]: number;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
|
-
const
|
|
85
|
+
const tabPaneComponent = getConfig('components').tabPane;
|
|
86
|
+
const tabsComponent = getConfig('components').tabs;
|
|
80
87
|
|
|
81
88
|
const getActive = (mForm: FormState | undefined, props: any, activeTabName: string) => {
|
|
82
89
|
const { config, model, prop } = props;
|
|
@@ -135,7 +142,7 @@ const tabs = computed(() => {
|
|
|
135
142
|
if (!props.config.name) throw new Error('dynamic tab 必须配置name');
|
|
136
143
|
return props.model[props.config.name] || [];
|
|
137
144
|
}
|
|
138
|
-
return props.config.items;
|
|
145
|
+
return props.config.items.filter((item) => displayFunc(mForm, item.display, props));
|
|
139
146
|
});
|
|
140
147
|
|
|
141
148
|
const filter = (config: any) => filterFunction(mForm, config, props);
|
|
@@ -193,8 +200,6 @@ const onTabRemove = (tabName: string) => {
|
|
|
193
200
|
mForm?.$emit('field-change', props.prop, props.model[props.config.name]);
|
|
194
201
|
};
|
|
195
202
|
|
|
196
|
-
const display = (displayConfig: any) => displayFunc(mForm, displayConfig, props);
|
|
197
|
-
|
|
198
203
|
const changeHandler = () => {
|
|
199
204
|
emit('change', props.model);
|
|
200
205
|
if (typeof props.config.onChange === 'function') {
|
package/src/fields/Select.vue
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
v-loading="loading"
|
|
6
6
|
class="m-select"
|
|
7
7
|
ref="tMagicSelect"
|
|
8
|
-
clearable
|
|
9
|
-
filterable
|
|
8
|
+
:clearable="typeof config.clearable !== 'undefined' ? config.clearable : true"
|
|
9
|
+
:filterable="typeof config.filterable !== 'undefined' ? config.filterable : true"
|
|
10
10
|
:popper-class="`m-select-popper ${popperClass}`"
|
|
11
11
|
:size="size"
|
|
12
12
|
:remote="remote"
|
package/src/fields/Text.vue
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
>
|
|
12
12
|
<template #append v-if="config.append">
|
|
13
13
|
<span v-if="typeof config.append === 'string'">{{ config.append }}</span>
|
|
14
|
-
<
|
|
14
|
+
<TMagicButton
|
|
15
15
|
v-if="typeof config.append === 'object' && config.append.type === 'button'"
|
|
16
16
|
style="color: #409eff"
|
|
17
17
|
:size="size"
|
|
18
18
|
@click.prevent="buttonClickHandler"
|
|
19
19
|
>
|
|
20
20
|
{{ config.append.text }}
|
|
21
|
-
</
|
|
21
|
+
</TMagicButton>
|
|
22
22
|
</template>
|
|
23
23
|
</TMagicInput>
|
|
24
24
|
</template>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<script lang="ts" setup name="MFormText">
|
|
27
27
|
import { inject } from 'vue';
|
|
28
28
|
|
|
29
|
-
import { TMagicInput } from '@tmagic/design';
|
|
29
|
+
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
30
30
|
import { isNumber } from '@tmagic/utils';
|
|
31
31
|
|
|
32
32
|
import { FormState, TextConfig } from '../schema';
|
package/src/schema.ts
CHANGED
|
@@ -432,6 +432,7 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
432
432
|
multiple?: boolean;
|
|
433
433
|
valueKey?: string;
|
|
434
434
|
allowCreate?: boolean;
|
|
435
|
+
filterable?: boolean;
|
|
435
436
|
group?: boolean;
|
|
436
437
|
options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
437
438
|
remote: true;
|
package/types/schema.d.ts
CHANGED
|
@@ -344,6 +344,7 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
344
344
|
multiple?: boolean;
|
|
345
345
|
valueKey?: string;
|
|
346
346
|
allowCreate?: boolean;
|
|
347
|
+
filterable?: boolean;
|
|
347
348
|
group?: boolean;
|
|
348
349
|
options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
349
350
|
remote: true;
|