@tmagic/form 1.2.0-beta.2 → 1.2.0-beta.3
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.mjs +2081 -2500
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +2104 -2524
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +3 -4
- package/src/Form.vue +116 -159
- package/src/FormDialog.vue +104 -126
- package/src/containers/Col.vue +22 -38
- package/src/containers/Container.vue +135 -171
- package/src/containers/Fieldset.vue +11 -7
- package/src/containers/GroupList.vue +80 -112
- package/src/containers/GroupListItem.vue +87 -124
- package/src/containers/Panel.vue +26 -49
- package/src/containers/Row.vue +18 -40
- package/src/containers/Step.vue +36 -48
- package/src/containers/Table.vue +437 -478
- package/src/containers/Tabs.vue +89 -118
- package/src/fields/Cascader.vue +88 -136
- package/src/fields/Checkbox.vue +46 -50
- package/src/fields/CheckboxGroup.vue +39 -35
- package/src/fields/ColorPicker.vue +4 -2
- package/src/fields/Date.vue +20 -26
- package/src/fields/DateTime.vue +31 -39
- package/src/fields/Daterange.vue +3 -2
- package/src/fields/DynamicField.vue +63 -77
- package/src/fields/Link.vue +65 -86
- package/src/fields/Number.vue +32 -34
- package/src/fields/RadioGroup.vue +23 -23
- package/src/fields/Select.vue +294 -310
- package/src/fields/SelectOptionGroups.vue +10 -5
- package/src/fields/SelectOptions.vue +4 -2
- package/src/fields/Switch.vue +46 -49
- package/src/fields/Text.vue +99 -107
- package/src/fields/Textarea.vue +32 -44
- package/src/fields/Time.vue +19 -30
- package/src/index.ts +22 -23
- package/src/schema.ts +45 -12
- package/types/Form.vue.d.ts +213 -111
- package/types/FormDialog.vue.d.ts +812 -155
- package/types/containers/Col.vue.d.ts +94 -40
- package/types/containers/Container.vue.d.ts +124 -65
- package/types/containers/GroupList.vue.d.ts +88 -53
- package/types/containers/GroupListItem.vue.d.ts +99 -67
- package/types/containers/Panel.vue.d.ts +92 -39
- package/types/containers/Row.vue.d.ts +94 -39
- package/types/containers/Step.vue.d.ts +104 -42
- package/types/containers/Table.vue.d.ts +157 -130
- package/types/containers/Tabs.vue.d.ts +95 -50
- package/types/fields/Cascader.vue.d.ts +97 -71
- package/types/fields/Checkbox.vue.d.ts +97 -56
- package/types/fields/CheckboxGroup.vue.d.ts +97 -53
- package/types/fields/Date.vue.d.ts +97 -54
- package/types/fields/DateTime.vue.d.ts +97 -54
- package/types/fields/DynamicField.vue.d.ts +97 -64
- package/types/fields/Link.vue.d.ts +62 -657
- package/types/fields/Number.vue.d.ts +101 -56
- package/types/fields/RadioGroup.vue.d.ts +98 -52
- package/types/fields/Select.vue.d.ts +99 -65
- package/types/fields/Switch.vue.d.ts +97 -56
- package/types/fields/Text.vue.d.ts +100 -57
- package/types/fields/Textarea.vue.d.ts +102 -60
- package/types/fields/Time.vue.d.ts +97 -55
- package/types/index.d.ts +0 -1
- package/types/schema.d.ts +37 -9
- package/src/utils/fieldProps.ts +0 -39
- package/types/utils/fieldProps.d.ts +0 -21
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-group-list-item">
|
|
3
3
|
<div>
|
|
4
|
-
<
|
|
4
|
+
<TMagicIcon style="margin-right: 7px" @click="expandHandler"
|
|
5
5
|
><CaretBottom v-if="expand" /><CaretRight v-else
|
|
6
|
-
/></
|
|
6
|
+
/></TMagicIcon>
|
|
7
7
|
|
|
8
|
-
<
|
|
8
|
+
<TMagicButton text @click="expandHandler">{{ title }}</TMagicButton>
|
|
9
9
|
|
|
10
|
-
<
|
|
10
|
+
<TMagicButton
|
|
11
11
|
v-show="showDelete(parseInt(String(index)))"
|
|
12
12
|
text
|
|
13
13
|
:icon="Delete"
|
|
14
14
|
style="color: #f56c6c"
|
|
15
15
|
@click="removeHandler"
|
|
16
|
-
></
|
|
16
|
+
></TMagicButton>
|
|
17
17
|
|
|
18
18
|
<template v-if="movable()">
|
|
19
|
-
<
|
|
20
|
-
>上移<
|
|
21
|
-
></
|
|
22
|
-
<
|
|
23
|
-
>下移<
|
|
24
|
-
></
|
|
19
|
+
<TMagicButton v-show="index !== 0" text size="small" @click="changeOrder(-1)"
|
|
20
|
+
>上移<TMagicIcon><CaretTop /></TMagicIcon
|
|
21
|
+
></TMagicButton>
|
|
22
|
+
<TMagicButton v-show="index !== length - 1" text size="small" @click="changeOrder(1)"
|
|
23
|
+
>下移<TMagicIcon><CaretBottom /></TMagicIcon
|
|
24
|
+
></TMagicButton>
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<span v-if="itemExtra" v-html="itemExtra" class="m-form-tip"></span>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<Container
|
|
31
31
|
v-if="expand"
|
|
32
32
|
:config="rowConfig"
|
|
33
33
|
:model="model"
|
|
@@ -35,125 +35,88 @@
|
|
|
35
35
|
:prop="`${prop}${prop ? '.' : ''}${String(index)}`"
|
|
36
36
|
:size="size"
|
|
37
37
|
@change="changeHandler"
|
|
38
|
-
></
|
|
38
|
+
></Container>
|
|
39
39
|
</div>
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
|
-
<script lang="ts">
|
|
43
|
-
import { computed,
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { computed, inject, ref, watchEffect } from 'vue';
|
|
44
44
|
import { CaretBottom, CaretRight, CaretTop, Delete } from '@element-plus/icons-vue';
|
|
45
45
|
|
|
46
|
+
import { TMagicButton, TMagicIcon } from '@tmagic/design';
|
|
47
|
+
|
|
46
48
|
import { FormState, GroupListConfig } from '../schema';
|
|
47
49
|
import { filterFunction } from '../utils/form';
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setup(props, { emit }) {
|
|
85
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
86
|
-
const expand = ref(false);
|
|
87
|
-
|
|
88
|
-
watchEffect(() => {
|
|
89
|
-
expand.value = !props.index;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const rowConfig = computed(() => ({
|
|
93
|
-
type: 'row',
|
|
94
|
-
span: props.config.span || 24,
|
|
95
|
-
items: props.config.items,
|
|
96
|
-
labelWidth: props.config.labelWidth,
|
|
97
|
-
[mForm?.keyProp || '__key']: `${props.config[mForm?.keyProp || '__key']}${String(props.index)}`,
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
const title = computed(() => {
|
|
101
|
-
if (props.config.titleKey && props.model[props.config.titleKey]) {
|
|
102
|
-
return props.model[props.config.titleKey];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return `组 ${String(props.index)}`;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const length = computed(() => props.groupModel?.length || 0);
|
|
109
|
-
|
|
110
|
-
const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
111
|
-
|
|
112
|
-
const removeHandler = () => emit('remove-item', props.index);
|
|
113
|
-
|
|
114
|
-
const changeHandler = () => emit('change');
|
|
115
|
-
|
|
116
|
-
const expandHandler = () => {
|
|
117
|
-
expand.value = !expand.value;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// 希望支持单行可控制是否显示删除按钮,不会影响现有逻辑
|
|
121
|
-
const showDelete = (index: number) => {
|
|
122
|
-
const deleteFunc = props.config.delete;
|
|
123
|
-
if (deleteFunc && typeof deleteFunc === 'function') {
|
|
124
|
-
return deleteFunc(props.model, index, mForm?.values);
|
|
125
|
-
}
|
|
126
|
-
return true;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// 调换顺序
|
|
130
|
-
const changeOrder = (offset = 0) => emit('swap-item', props.index, `${String(props.index)}${offset}`);
|
|
131
|
-
|
|
132
|
-
const movable = () => {
|
|
133
|
-
const { movable } = props.config;
|
|
134
|
-
|
|
135
|
-
// 没有设置时,默认可移动
|
|
136
|
-
if (movable === undefined) return true;
|
|
137
|
-
if (typeof movable === 'function') {
|
|
138
|
-
return movable(mForm, props.index || 0, props.model, props.groupModel);
|
|
139
|
-
}
|
|
140
|
-
return movable;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
expand,
|
|
145
|
-
expandHandler,
|
|
146
|
-
title,
|
|
147
|
-
showDelete,
|
|
148
|
-
removeHandler,
|
|
149
|
-
movable,
|
|
150
|
-
changeOrder,
|
|
151
|
-
itemExtra,
|
|
152
|
-
rowConfig,
|
|
153
|
-
changeHandler,
|
|
154
|
-
length,
|
|
155
|
-
Delete,
|
|
156
|
-
};
|
|
157
|
-
},
|
|
51
|
+
import Container from './Container.vue';
|
|
52
|
+
|
|
53
|
+
const props = defineProps<{
|
|
54
|
+
model: any;
|
|
55
|
+
groupModel: any[];
|
|
56
|
+
config: GroupListConfig;
|
|
57
|
+
labelWidth?: string;
|
|
58
|
+
prop?: string;
|
|
59
|
+
size?: string;
|
|
60
|
+
index: number;
|
|
61
|
+
}>();
|
|
62
|
+
|
|
63
|
+
const emit = defineEmits(['swap-item', 'remove-item', 'change']);
|
|
64
|
+
|
|
65
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
66
|
+
const expand = ref(false);
|
|
67
|
+
|
|
68
|
+
watchEffect(() => {
|
|
69
|
+
expand.value = !props.index;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const rowConfig = computed(() => ({
|
|
73
|
+
type: 'row',
|
|
74
|
+
span: props.config.span || 24,
|
|
75
|
+
items: props.config.items,
|
|
76
|
+
labelWidth: props.config.labelWidth,
|
|
77
|
+
[mForm?.keyProp || '__key']: `${props.config[mForm?.keyProp || '__key']}${String(props.index)}`,
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
const title = computed(() => {
|
|
81
|
+
if (props.config.titleKey && props.model[props.config.titleKey]) {
|
|
82
|
+
return props.model[props.config.titleKey];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return `组 ${String(props.index)}`;
|
|
158
86
|
});
|
|
87
|
+
|
|
88
|
+
const length = computed(() => props.groupModel?.length || 0);
|
|
89
|
+
|
|
90
|
+
const itemExtra = computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
91
|
+
|
|
92
|
+
const removeHandler = () => emit('remove-item', props.index);
|
|
93
|
+
|
|
94
|
+
const changeHandler = () => emit('change');
|
|
95
|
+
|
|
96
|
+
const expandHandler = () => {
|
|
97
|
+
expand.value = !expand.value;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 希望支持单行可控制是否显示删除按钮,不会影响现有逻辑
|
|
101
|
+
const showDelete = (index: number) => {
|
|
102
|
+
const deleteFunc = props.config.delete;
|
|
103
|
+
if (deleteFunc && typeof deleteFunc === 'function') {
|
|
104
|
+
return deleteFunc(props.model, index, mForm?.values);
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// 调换顺序
|
|
110
|
+
const changeOrder = (offset = 0) => emit('swap-item', props.index, `${String(props.index)}${offset}`);
|
|
111
|
+
|
|
112
|
+
const movable = () => {
|
|
113
|
+
const { movable } = props.config;
|
|
114
|
+
|
|
115
|
+
// 没有设置时,默认可移动
|
|
116
|
+
if (movable === undefined) return true;
|
|
117
|
+
if (typeof movable === 'function') {
|
|
118
|
+
return movable(mForm, props.index || 0, props.model, props.groupModel);
|
|
119
|
+
}
|
|
120
|
+
return movable;
|
|
121
|
+
};
|
|
159
122
|
</script>
|
package/src/containers/Panel.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicCard
|
|
3
3
|
v-if="items && items.length"
|
|
4
4
|
class="box-card m-form-panel"
|
|
5
5
|
:body-style="{ display: expand ? 'block' : 'none' }"
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<template #header>
|
|
8
8
|
<div class="clearfix">
|
|
9
9
|
<a href="javascript:" style="width: 100%; display: block" @click="expand = !expand">
|
|
10
|
-
<
|
|
10
|
+
<TMagicIcon><CaretBottom v-if="expand" /><CaretRight v-else /></TMagicIcon> {{ filter(config.title) }}
|
|
11
11
|
<span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
|
|
12
12
|
</a>
|
|
13
13
|
</div>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<div v-if="config.schematic" style="display: flex">
|
|
20
20
|
<div style="flex: 1">
|
|
21
|
-
<
|
|
21
|
+
<Container
|
|
22
22
|
v-for="(item, index) in items"
|
|
23
23
|
:key="item[mForm?.keyProp || '__key'] ?? index"
|
|
24
24
|
:config="item"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
:size="size"
|
|
28
28
|
:label-width="config.labelWidth || labelWidth"
|
|
29
29
|
@change="changeHandler"
|
|
30
|
-
></
|
|
30
|
+
></Container>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
33
|
<img class="m-form-schematic" :src="config.schematic" />
|
|
34
34
|
</div>
|
|
35
35
|
|
|
36
36
|
<template v-else>
|
|
37
|
-
<
|
|
37
|
+
<Container
|
|
38
38
|
v-for="(item, index) in items"
|
|
39
39
|
:key="item[mForm?.keyProp || '__key'] ?? index"
|
|
40
40
|
:config="item"
|
|
@@ -43,64 +43,41 @@
|
|
|
43
43
|
:size="size"
|
|
44
44
|
:label-width="config.labelWidth || labelWidth"
|
|
45
45
|
@change="changeHandler"
|
|
46
|
-
></
|
|
46
|
+
></Container>
|
|
47
47
|
</template>
|
|
48
48
|
</div>
|
|
49
|
-
</
|
|
49
|
+
</TMagicCard>
|
|
50
50
|
</template>
|
|
51
51
|
|
|
52
|
-
<script lang="ts">
|
|
53
|
-
import { computed,
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { computed, inject, ref } from 'vue';
|
|
54
54
|
import { CaretBottom, CaretRight } from '@element-plus/icons-vue';
|
|
55
55
|
|
|
56
|
+
import { TMagicCard, TMagicIcon } from '@tmagic/design';
|
|
57
|
+
|
|
56
58
|
import { FormState, PanelConfig } from '../schema';
|
|
57
59
|
import { filterFunction } from '../utils/form';
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
name: 'm-form-panel',
|
|
61
|
-
|
|
62
|
-
components: { CaretBottom, CaretRight },
|
|
63
|
-
|
|
64
|
-
props: {
|
|
65
|
-
labelWidth: String,
|
|
66
|
-
|
|
67
|
-
model: {
|
|
68
|
-
type: Object,
|
|
69
|
-
default: () => ({}),
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
config: {
|
|
73
|
-
type: Object as PropType<PanelConfig>,
|
|
74
|
-
default: () => ({}),
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
prop: String,
|
|
78
|
-
|
|
79
|
-
size: String,
|
|
80
|
-
|
|
81
|
-
name: String,
|
|
82
|
-
},
|
|
61
|
+
import Container from './Container.vue';
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
const props = defineProps<{
|
|
64
|
+
model: any;
|
|
65
|
+
config: PanelConfig;
|
|
66
|
+
name: string;
|
|
67
|
+
labelWidth?: string;
|
|
68
|
+
prop?: string;
|
|
69
|
+
size?: string;
|
|
70
|
+
}>();
|
|
85
71
|
|
|
86
|
-
|
|
87
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
72
|
+
const emit = defineEmits(['change']);
|
|
88
73
|
|
|
89
|
-
|
|
74
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
90
75
|
|
|
91
|
-
|
|
76
|
+
const expand = ref(props.config.expand !== false);
|
|
92
77
|
|
|
93
|
-
|
|
78
|
+
const items = computed(() => props.config.items);
|
|
94
79
|
|
|
95
|
-
|
|
80
|
+
const filter = (config: any) => filterFunction(mForm, config, props);
|
|
96
81
|
|
|
97
|
-
|
|
98
|
-
mForm,
|
|
99
|
-
expand,
|
|
100
|
-
items,
|
|
101
|
-
filter,
|
|
102
|
-
changeHandler,
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
});
|
|
82
|
+
const changeHandler = () => emit('change', props.model);
|
|
106
83
|
</script>
|
package/src/containers/Row.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicRow :gutter="10">
|
|
3
3
|
<Col
|
|
4
4
|
v-for="(col, index) in config.items"
|
|
5
5
|
:key="col[mForm?.keyProp || '__key'] ?? index"
|
|
@@ -12,53 +12,31 @@
|
|
|
12
12
|
:size="size"
|
|
13
13
|
@change="changeHandler"
|
|
14
14
|
/>
|
|
15
|
-
</
|
|
15
|
+
</TMagicRow>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
|
-
<script lang="ts">
|
|
19
|
-
import {
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { inject } from 'vue';
|
|
20
|
+
|
|
21
|
+
import { TMagicRow } from '@tmagic/design';
|
|
20
22
|
|
|
21
23
|
import { FormState, RowConfig } from '../schema';
|
|
22
24
|
|
|
23
25
|
import Col from './Col.vue';
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
model: {
|
|
35
|
-
type: Object,
|
|
36
|
-
default: () => ({}),
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
config: {
|
|
40
|
-
type: Object as PropType<RowConfig>,
|
|
41
|
-
default: () => ({}),
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
prop: String,
|
|
45
|
-
|
|
46
|
-
name: String,
|
|
47
|
-
|
|
48
|
-
size: String,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
emits: ['change'],
|
|
27
|
+
const props = defineProps<{
|
|
28
|
+
model: any;
|
|
29
|
+
config: RowConfig;
|
|
30
|
+
name: string;
|
|
31
|
+
labelWidth?: string;
|
|
32
|
+
prop?: string;
|
|
33
|
+
size?: string;
|
|
34
|
+
expandMore?: boolean;
|
|
35
|
+
}>();
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
37
|
+
const emit = defineEmits(['change']);
|
|
55
38
|
|
|
56
|
-
|
|
39
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
mForm,
|
|
60
|
-
changeHandler,
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
});
|
|
41
|
+
const changeHandler = () => emit('change', props.name ? props.model[props.name] : props.model);
|
|
64
42
|
</script>
|
package/src/containers/Step.vue
CHANGED
|
@@ -1,82 +1,70 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<
|
|
4
|
-
<
|
|
3
|
+
<TMagicSteps :active="active" align-center :space="config.space">
|
|
4
|
+
<TMagicStep
|
|
5
5
|
v-for="(item, index) in config.items"
|
|
6
6
|
:key="item.__key"
|
|
7
7
|
:title="item.title"
|
|
8
8
|
:active="active"
|
|
9
9
|
@click="stepClick(index)"
|
|
10
|
-
></
|
|
11
|
-
</
|
|
10
|
+
></TMagicStep>
|
|
11
|
+
</TMagicSteps>
|
|
12
12
|
|
|
13
13
|
<template v-for="(step, index) in config.items">
|
|
14
14
|
<template v-for="item in step.items">
|
|
15
|
-
<
|
|
15
|
+
<Container
|
|
16
16
|
v-if="item"
|
|
17
17
|
v-show="active - 1 === index"
|
|
18
18
|
:key="item[mForm?.keyProp || '__key']"
|
|
19
19
|
:config="item"
|
|
20
20
|
:model="step.name ? model[step.name] : model"
|
|
21
|
-
:prop="step.name"
|
|
21
|
+
:prop="`${step.name}`"
|
|
22
22
|
:size="size"
|
|
23
23
|
:label-width="config.labelWidth || labelWidth"
|
|
24
24
|
@change="changeHandler"
|
|
25
|
-
></
|
|
25
|
+
></Container>
|
|
26
26
|
</template>
|
|
27
27
|
</template>
|
|
28
28
|
</div>
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
|
-
<script lang="ts">
|
|
32
|
-
import {
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { inject, ref, watchEffect } from 'vue';
|
|
33
33
|
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
export default defineComponent({
|
|
37
|
-
name: 'm-form-step',
|
|
38
|
-
|
|
39
|
-
props: {
|
|
40
|
-
model: {
|
|
41
|
-
type: Object,
|
|
42
|
-
default: () => ({}),
|
|
43
|
-
},
|
|
34
|
+
import { TMagicStep, TMagicSteps } from '@tmagic/design';
|
|
44
35
|
|
|
45
|
-
|
|
46
|
-
type: Object as PropType<StepConfig>,
|
|
47
|
-
default: () => ({}),
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
stepActive: {
|
|
51
|
-
type: Number,
|
|
52
|
-
default: () => 1,
|
|
53
|
-
},
|
|
36
|
+
import { FormState, StepConfig } from '../schema';
|
|
54
37
|
|
|
55
|
-
|
|
38
|
+
import Container from './Container.vue';
|
|
56
39
|
|
|
57
|
-
|
|
40
|
+
const props = withDefaults(
|
|
41
|
+
defineProps<{
|
|
42
|
+
model: any;
|
|
43
|
+
config: StepConfig;
|
|
44
|
+
stepActive?: number;
|
|
45
|
+
labelWidth?: string;
|
|
46
|
+
size?: string;
|
|
47
|
+
}>(),
|
|
48
|
+
{
|
|
49
|
+
stepActive: 1,
|
|
58
50
|
},
|
|
51
|
+
);
|
|
59
52
|
|
|
60
|
-
|
|
53
|
+
const emit = defineEmits(['change']);
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const active = ref(1);
|
|
55
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
56
|
+
const active = ref(1);
|
|
65
57
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const stepClick = (index: number) => {
|
|
71
|
-
active.value = index + 1;
|
|
72
|
-
mForm?.$emit('update:stepActive', active.value);
|
|
73
|
-
};
|
|
58
|
+
watchEffect(() => {
|
|
59
|
+
active.value = props.stepActive;
|
|
60
|
+
});
|
|
74
61
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
const stepClick = (index: number) => {
|
|
63
|
+
active.value = index + 1;
|
|
64
|
+
mForm?.$emit('update:stepActive', active.value);
|
|
65
|
+
};
|
|
78
66
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
67
|
+
const changeHandler = () => {
|
|
68
|
+
emit('change', props.model);
|
|
69
|
+
};
|
|
82
70
|
</script>
|