@tmagic/form 1.3.0-alpha.2 → 1.3.0-alpha.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 +890 -904
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +888 -902
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +10 -11
- package/src/Form.vue +5 -1
- package/src/FormDialog.vue +5 -1
- package/src/containers/Col.vue +5 -1
- package/src/containers/Container.vue +5 -1
- package/src/containers/Fieldset.vue +5 -1
- package/src/containers/GroupList.vue +5 -1
- package/src/containers/GroupListItem.vue +6 -2
- package/src/containers/Panel.vue +5 -1
- package/src/containers/Row.vue +5 -1
- package/src/containers/Step.vue +5 -1
- package/src/containers/Table.vue +5 -1
- package/src/containers/Tabs.vue +14 -8
- package/src/fields/Cascader.vue +5 -1
- package/src/fields/Checkbox.vue +5 -1
- package/src/fields/CheckboxGroup.vue +6 -2
- package/src/fields/ColorPicker.vue +5 -1
- package/src/fields/Date.vue +5 -1
- package/src/fields/DateTime.vue +5 -1
- package/src/fields/Daterange.vue +5 -1
- package/src/fields/Display.vue +5 -1
- package/src/fields/DynamicField.vue +5 -1
- package/src/fields/Hidden.vue +5 -1
- package/src/fields/Link.vue +5 -1
- package/src/fields/Number.vue +5 -1
- package/src/fields/RadioGroup.vue +5 -1
- package/src/fields/Select.vue +9 -9
- package/src/fields/SelectOptionGroups.vue +7 -3
- package/src/fields/SelectOptions.vue +5 -1
- package/src/fields/Switch.vue +5 -1
- package/src/fields/Text.vue +5 -1
- package/src/fields/Textarea.vue +5 -1
- package/src/fields/Time.vue +5 -1
- package/src/index.ts +39 -37
- package/src/schema.ts +1 -0
- package/types/Form.vue.d.ts +7 -4
- package/types/FormDialog.vue.d.ts +76 -121
- package/types/containers/Col.vue.d.ts +1 -1
- package/types/containers/Container.vue.d.ts +6 -3
- package/types/containers/Fieldset.vue.d.ts +6 -3
- package/types/containers/GroupList.vue.d.ts +1 -1
- package/types/containers/GroupListItem.vue.d.ts +1 -1
- package/types/containers/Panel.vue.d.ts +3 -3
- package/types/containers/Row.vue.d.ts +1 -1
- package/types/containers/Step.vue.d.ts +6 -3
- package/types/containers/Table.vue.d.ts +9 -6
- package/types/containers/Tabs.vue.d.ts +6 -3
- package/types/fields/Cascader.vue.d.ts +1 -1
- package/types/fields/Checkbox.vue.d.ts +1 -1
- package/types/fields/CheckboxGroup.vue.d.ts +1 -1
- package/types/fields/ColorPicker.vue.d.ts +1 -1
- package/types/fields/Date.vue.d.ts +1 -1
- package/types/fields/DateTime.vue.d.ts +1 -1
- package/types/fields/Daterange.vue.d.ts +1 -1
- package/types/fields/Display.vue.d.ts +2 -2
- package/types/fields/DynamicField.vue.d.ts +1 -10
- package/types/fields/Hidden.vue.d.ts +2 -2
- package/types/fields/Link.vue.d.ts +1 -1
- package/types/fields/Number.vue.d.ts +1 -1
- package/types/fields/RadioGroup.vue.d.ts +1 -1
- package/types/fields/Select.vue.d.ts +1 -1
- package/types/fields/SelectOptionGroups.vue.d.ts +2 -2
- package/types/fields/SelectOptions.vue.d.ts +2 -2
- package/types/fields/Switch.vue.d.ts +1 -1
- package/types/fields/Text.vue.d.ts +1 -1
- package/types/fields/Textarea.vue.d.ts +1 -1
- package/types/fields/Time.vue.d.ts +1 -1
- package/types/index.d.ts +4 -1
- package/types/schema.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.4",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -36,28 +36,27 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@element-plus/icons-vue": "^2.0.9",
|
|
39
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
40
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
39
|
+
"@tmagic/design": "1.3.0-alpha.4",
|
|
40
|
+
"@tmagic/utils": "1.3.0-alpha.4",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
|
-
"vue": "^3.
|
|
43
|
+
"vue": "^3.3.4"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vue": "^3.
|
|
46
|
+
"vue": "^3.3.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/core": "^7.18.0",
|
|
50
50
|
"@types/lodash-es": "^4.17.4",
|
|
51
51
|
"@types/node": "^15.12.4",
|
|
52
52
|
"@types/sortablejs": "^1.10.7",
|
|
53
|
-
"@vitejs/plugin-vue": "^4.
|
|
54
|
-
"@vue/compiler-sfc": "^3.
|
|
55
|
-
"@vue/test-utils": "^2.
|
|
53
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
54
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
55
|
+
"@vue/test-utils": "^2.3.2",
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"sass": "^1.35.1",
|
|
58
58
|
"typescript": "^5.0.4",
|
|
59
|
-
"vite": "^4.
|
|
60
|
-
"
|
|
61
|
-
"vue-tsc": "^1.2.0"
|
|
59
|
+
"vite": "^4.3.8",
|
|
60
|
+
"vue-tsc": "^1.6.5"
|
|
62
61
|
}
|
|
63
62
|
}
|
package/src/Form.vue
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</TMagicForm>
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
|
-
<script setup lang="ts"
|
|
29
|
+
<script setup lang="ts">
|
|
30
30
|
import { provide, reactive, ref, toRaw, watch, watchEffect } from 'vue';
|
|
31
31
|
import { isEqual } from 'lodash-es';
|
|
32
32
|
import cloneDeep from 'lodash-es/cloneDeep';
|
|
@@ -38,6 +38,10 @@ import { getConfig } from './utils/config';
|
|
|
38
38
|
import { initValue } from './utils/form';
|
|
39
39
|
import type { FormConfig, FormState, FormValue, ValidateError } from './schema';
|
|
40
40
|
|
|
41
|
+
defineOptions({
|
|
42
|
+
name: 'MForm',
|
|
43
|
+
});
|
|
44
|
+
|
|
41
45
|
const props = withDefaults(
|
|
42
46
|
defineProps<{
|
|
43
47
|
/** 表单配置 */
|
package/src/FormDialog.vue
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
</TMagicDialog>
|
|
57
57
|
</template>
|
|
58
58
|
|
|
59
|
-
<script setup lang="ts"
|
|
59
|
+
<script setup lang="ts">
|
|
60
60
|
import { computed, ref } from 'vue';
|
|
61
61
|
|
|
62
62
|
import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design';
|
|
@@ -64,6 +64,10 @@ import { TMagicButton, TMagicCol, TMagicDialog, TMagicRow } from '@tmagic/design
|
|
|
64
64
|
import Form from './Form.vue';
|
|
65
65
|
import { FormConfig, StepConfig } from './schema';
|
|
66
66
|
|
|
67
|
+
defineOptions({
|
|
68
|
+
name: 'MFormDialog',
|
|
69
|
+
});
|
|
70
|
+
|
|
67
71
|
const props = withDefaults(
|
|
68
72
|
defineProps<{
|
|
69
73
|
config?: FormConfig;
|
package/src/containers/Col.vue
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</TMagicCol>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script setup lang="ts"
|
|
19
|
+
<script setup lang="ts">
|
|
20
20
|
import { computed, inject } from 'vue';
|
|
21
21
|
|
|
22
22
|
import { TMagicCol } from '@tmagic/design';
|
|
@@ -26,6 +26,10 @@ import { display as displayFunction } from '../utils/form';
|
|
|
26
26
|
|
|
27
27
|
import Container from './Container.vue';
|
|
28
28
|
|
|
29
|
+
defineOptions({
|
|
30
|
+
name: 'MFormCol',
|
|
31
|
+
});
|
|
32
|
+
|
|
29
33
|
const props = defineProps<{
|
|
30
34
|
model: any;
|
|
31
35
|
lastValues?: any;
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
</div>
|
|
219
219
|
</template>
|
|
220
220
|
|
|
221
|
-
<script setup lang="ts"
|
|
221
|
+
<script setup lang="ts">
|
|
222
222
|
import { computed, inject, ref, resolveComponent, watch, watchEffect } from 'vue';
|
|
223
223
|
import { WarningFilled } from '@element-plus/icons-vue';
|
|
224
224
|
import { isEqual } from 'lodash-es';
|
|
@@ -228,6 +228,10 @@ import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic
|
|
|
228
228
|
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
229
229
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
230
230
|
|
|
231
|
+
defineOptions({
|
|
232
|
+
name: 'MFormContainer',
|
|
233
|
+
});
|
|
234
|
+
|
|
231
235
|
const props = withDefaults(
|
|
232
236
|
defineProps<{
|
|
233
237
|
/** 表单值 */
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</fieldset>
|
|
62
62
|
</template>
|
|
63
63
|
|
|
64
|
-
<script lang="ts" setup
|
|
64
|
+
<script lang="ts" setup>
|
|
65
65
|
import { computed, inject } from 'vue';
|
|
66
66
|
|
|
67
67
|
import { TMagicCheckbox } from '@tmagic/design';
|
|
@@ -70,6 +70,10 @@ import { FieldsetConfig, FormState } from '../schema';
|
|
|
70
70
|
|
|
71
71
|
import Container from './Container.vue';
|
|
72
72
|
|
|
73
|
+
defineOptions({
|
|
74
|
+
name: 'MFormFieldset',
|
|
75
|
+
});
|
|
76
|
+
|
|
73
77
|
const props = withDefaults(
|
|
74
78
|
defineProps<{
|
|
75
79
|
labelWidth?: string;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
</div>
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
|
-
<script setup lang="ts"
|
|
34
|
+
<script setup lang="ts">
|
|
35
35
|
import { computed, inject } from 'vue';
|
|
36
36
|
import { Grid } from '@element-plus/icons-vue';
|
|
37
37
|
|
|
@@ -42,6 +42,10 @@ import { initValue } from '../utils/form';
|
|
|
42
42
|
|
|
43
43
|
import MFieldsGroupListItem from './GroupListItem.vue';
|
|
44
44
|
|
|
45
|
+
defineOptions({
|
|
46
|
+
name: 'MFormGroupList',
|
|
47
|
+
});
|
|
48
|
+
|
|
45
49
|
const props = defineProps<{
|
|
46
50
|
model: any;
|
|
47
51
|
lastValues?: any;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</div>
|
|
43
43
|
</template>
|
|
44
44
|
|
|
45
|
-
<script setup lang="ts"
|
|
45
|
+
<script setup lang="ts">
|
|
46
46
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
47
47
|
import { CaretBottom, CaretRight, CaretTop, Delete } from '@element-plus/icons-vue';
|
|
48
48
|
|
|
@@ -53,6 +53,10 @@ import { filterFunction } from '../utils/form';
|
|
|
53
53
|
|
|
54
54
|
import Container from './Container.vue';
|
|
55
55
|
|
|
56
|
+
defineOptions({
|
|
57
|
+
name: 'MFormGroupListItem',
|
|
58
|
+
});
|
|
59
|
+
|
|
56
60
|
const props = defineProps<{
|
|
57
61
|
model: any;
|
|
58
62
|
lastValues: any;
|
|
@@ -72,7 +76,7 @@ const mForm = inject<FormState | undefined>('mForm');
|
|
|
72
76
|
const expand = ref(false);
|
|
73
77
|
|
|
74
78
|
watchEffect(() => {
|
|
75
|
-
expand.value = !props.index;
|
|
79
|
+
expand.value = props.config.expandAll || !props.index;
|
|
76
80
|
});
|
|
77
81
|
|
|
78
82
|
const rowConfig = computed(() => ({
|
package/src/containers/Panel.vue
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
</TMagicCard>
|
|
58
58
|
</template>
|
|
59
59
|
|
|
60
|
-
<script setup lang="ts"
|
|
60
|
+
<script setup lang="ts">
|
|
61
61
|
import { computed, inject, ref } from 'vue';
|
|
62
62
|
import { CaretBottom, CaretRight } from '@element-plus/icons-vue';
|
|
63
63
|
|
|
@@ -68,6 +68,10 @@ import { filterFunction } from '../utils/form';
|
|
|
68
68
|
|
|
69
69
|
import Container from './Container.vue';
|
|
70
70
|
|
|
71
|
+
defineOptions({
|
|
72
|
+
name: 'MFormPanel',
|
|
73
|
+
});
|
|
74
|
+
|
|
71
75
|
const props = defineProps<{
|
|
72
76
|
model: any;
|
|
73
77
|
lastValues?: any;
|
package/src/containers/Row.vue
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</TMagicRow>
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
|
-
<script setup lang="ts"
|
|
22
|
+
<script setup lang="ts">
|
|
23
23
|
import { inject } from 'vue';
|
|
24
24
|
|
|
25
25
|
import { TMagicRow } from '@tmagic/design';
|
|
@@ -28,6 +28,10 @@ import { FormState, RowConfig } from '../schema';
|
|
|
28
28
|
|
|
29
29
|
import Col from './Col.vue';
|
|
30
30
|
|
|
31
|
+
defineOptions({
|
|
32
|
+
name: 'MFormRow',
|
|
33
|
+
});
|
|
34
|
+
|
|
31
35
|
const props = defineProps<{
|
|
32
36
|
model: any;
|
|
33
37
|
lastValues?: any;
|
package/src/containers/Step.vue
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</div>
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
|
-
<script setup lang="ts"
|
|
35
|
+
<script setup lang="ts">
|
|
36
36
|
import { inject, ref, watchEffect } from 'vue';
|
|
37
37
|
|
|
38
38
|
import { TMagicStep, TMagicSteps } from '@tmagic/design';
|
|
@@ -41,6 +41,10 @@ import { FormState, StepConfig } from '../schema';
|
|
|
41
41
|
|
|
42
42
|
import Container from './Container.vue';
|
|
43
43
|
|
|
44
|
+
defineOptions({
|
|
45
|
+
name: 'MFormStep',
|
|
46
|
+
});
|
|
47
|
+
|
|
44
48
|
const props = withDefaults(
|
|
45
49
|
defineProps<{
|
|
46
50
|
model: any;
|
package/src/containers/Table.vue
CHANGED
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
</div>
|
|
175
175
|
</template>
|
|
176
176
|
|
|
177
|
-
<script setup lang="ts"
|
|
177
|
+
<script setup lang="ts">
|
|
178
178
|
import { computed, inject, onMounted, ref, toRefs, watchEffect } from 'vue';
|
|
179
179
|
import { ArrowDown, ArrowUp, Delete, FullScreen, Grid } from '@element-plus/icons-vue';
|
|
180
180
|
import { cloneDeep } from 'lodash-es';
|
|
@@ -197,6 +197,10 @@ import { display as displayFunc, initValue } from '../utils/form';
|
|
|
197
197
|
|
|
198
198
|
import Container from './Container.vue';
|
|
199
199
|
|
|
200
|
+
defineOptions({
|
|
201
|
+
name: 'MFormTable',
|
|
202
|
+
});
|
|
203
|
+
|
|
200
204
|
const props = withDefaults(
|
|
201
205
|
defineProps<{
|
|
202
206
|
model: any;
|
package/src/containers/Tabs.vue
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
<component
|
|
3
3
|
v-model="activeTabName"
|
|
4
4
|
v-bind="
|
|
5
|
-
tabsComponent
|
|
5
|
+
tabsComponent?.props({
|
|
6
6
|
type: config.tabType,
|
|
7
7
|
editable: config.editable || false,
|
|
8
8
|
tabPosition: config.tabPosition || 'top',
|
|
9
|
-
})
|
|
9
|
+
}) || {}
|
|
10
10
|
"
|
|
11
|
-
:is="tabsComponent
|
|
11
|
+
:is="tabsComponent?.component || 'el-tabs'"
|
|
12
12
|
:class="`tmagic-design-tabs ${config.dynamic ? 'magic-form-dynamic-tab' : 'magic-form-tab'}`"
|
|
13
13
|
@tab-click="tabClickHandler"
|
|
14
14
|
@tab-add="onTabAdd"
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
>
|
|
17
17
|
<component
|
|
18
18
|
v-for="(tab, tabIndex) in tabs"
|
|
19
|
-
:is="tabPaneComponent
|
|
19
|
+
:is="tabPaneComponent?.component || 'el-tab-pane'"
|
|
20
20
|
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
|
|
21
|
-
v-bind="
|
|
21
|
+
v-bind="
|
|
22
|
+
tabPaneComponent?.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false }) || {}
|
|
23
|
+
"
|
|
22
24
|
>
|
|
23
25
|
<template #label>
|
|
24
26
|
<span>
|
|
@@ -67,7 +69,7 @@
|
|
|
67
69
|
</component>
|
|
68
70
|
</template>
|
|
69
71
|
|
|
70
|
-
<script setup lang="ts"
|
|
72
|
+
<script setup lang="ts">
|
|
71
73
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
72
74
|
import { cloneDeep, isEmpty } from 'lodash-es';
|
|
73
75
|
|
|
@@ -78,12 +80,16 @@ import { display as displayFunc, filterFunction } from '../utils/form';
|
|
|
78
80
|
|
|
79
81
|
import Container from './Container.vue';
|
|
80
82
|
|
|
83
|
+
defineOptions({
|
|
84
|
+
name: 'MFormTabs',
|
|
85
|
+
});
|
|
86
|
+
|
|
81
87
|
type DiffCount = {
|
|
82
88
|
[tabIndex: number]: number;
|
|
83
89
|
};
|
|
84
90
|
|
|
85
|
-
const tabPaneComponent = getConfig('components')
|
|
86
|
-
const tabsComponent = getConfig('components')
|
|
91
|
+
const tabPaneComponent = getConfig('components')?.tabPane;
|
|
92
|
+
const tabsComponent = getConfig('components')?.tabs;
|
|
87
93
|
|
|
88
94
|
const getActive = (mForm: FormState | undefined, props: any, activeTabName: string) => {
|
|
89
95
|
const { config, model, prop } = props;
|
package/src/fields/Cascader.vue
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
></TMagicCascader>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script setup lang="ts"
|
|
17
|
+
<script setup lang="ts">
|
|
18
18
|
import { inject, ref, watchEffect } from 'vue';
|
|
19
19
|
|
|
20
20
|
import { TMagicCascader } from '@tmagic/design';
|
|
@@ -23,6 +23,10 @@ import { CascaderConfig, FormState } from '../schema';
|
|
|
23
23
|
import { getConfig } from '../utils/config';
|
|
24
24
|
import { useAddField } from '../utils/useAddField';
|
|
25
25
|
|
|
26
|
+
defineOptions({
|
|
27
|
+
name: 'MFormCascader',
|
|
28
|
+
});
|
|
29
|
+
|
|
26
30
|
const props = defineProps<{
|
|
27
31
|
config: CascaderConfig;
|
|
28
32
|
model: any;
|
package/src/fields/Checkbox.vue
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script setup lang="ts"
|
|
13
|
+
<script setup lang="ts">
|
|
14
14
|
import { computed } from 'vue';
|
|
15
15
|
|
|
16
16
|
import { TMagicCheckbox } from '@tmagic/design';
|
|
@@ -18,6 +18,10 @@ import { TMagicCheckbox } from '@tmagic/design';
|
|
|
18
18
|
import { CheckboxConfig } from '../schema';
|
|
19
19
|
import { useAddField } from '../utils/useAddField';
|
|
20
20
|
|
|
21
|
+
defineOptions({
|
|
22
|
+
name: 'MFormCheckbox',
|
|
23
|
+
});
|
|
24
|
+
|
|
21
25
|
const props = defineProps<{
|
|
22
26
|
config: CheckboxConfig;
|
|
23
27
|
model: any;
|
|
@@ -11,14 +11,18 @@
|
|
|
11
11
|
</TMagicCheckboxGroup>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script lang="ts" setup
|
|
14
|
+
<script lang="ts" setup>
|
|
15
15
|
import { computed, inject } from 'vue';
|
|
16
16
|
|
|
17
17
|
import { TMagicCheckbox, TMagicCheckboxGroup } from '@tmagic/design';
|
|
18
18
|
|
|
19
19
|
import { CheckboxGroupConfig, FormState } from '../schema';
|
|
20
|
+
import { filterFunction } from '../utils/form';
|
|
20
21
|
import { useAddField } from '../utils/useAddField';
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
defineOptions({
|
|
24
|
+
name: 'MFormCheckGroup',
|
|
25
|
+
});
|
|
22
26
|
|
|
23
27
|
const props = defineProps<{
|
|
24
28
|
config: CheckboxGroupConfig;
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
></TMagicColorPicker>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script lang="ts" setup
|
|
11
|
+
<script lang="ts" setup>
|
|
12
12
|
import { TMagicColorPicker } from '@tmagic/design';
|
|
13
13
|
|
|
14
14
|
import { ColorPickConfig } from '../schema';
|
|
15
15
|
import { useAddField } from '../utils/useAddField';
|
|
16
16
|
|
|
17
|
+
defineOptions({
|
|
18
|
+
name: 'MFormColorPicker',
|
|
19
|
+
});
|
|
20
|
+
|
|
17
21
|
const props = defineProps<{
|
|
18
22
|
config: ColorPickConfig;
|
|
19
23
|
model: any;
|
package/src/fields/Date.vue
CHANGED
|
@@ -11,13 +11,17 @@
|
|
|
11
11
|
></TMagicDatePicker>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script lang="ts" setup
|
|
14
|
+
<script lang="ts" setup>
|
|
15
15
|
import { TMagicDatePicker } from '@tmagic/design';
|
|
16
16
|
import { datetimeFormatter } from '@tmagic/utils';
|
|
17
17
|
|
|
18
18
|
import { DateConfig } from '../schema';
|
|
19
19
|
import { useAddField } from '../utils/useAddField';
|
|
20
20
|
|
|
21
|
+
defineOptions({
|
|
22
|
+
name: 'MFormDate',
|
|
23
|
+
});
|
|
24
|
+
|
|
21
25
|
const props = defineProps<{
|
|
22
26
|
config: DateConfig;
|
|
23
27
|
model: any;
|
package/src/fields/DateTime.vue
CHANGED
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
></TMagicDatePicker>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
|
-
<script lang="ts" setup
|
|
16
|
+
<script lang="ts" setup>
|
|
17
17
|
import { TMagicDatePicker } from '@tmagic/design';
|
|
18
18
|
import { datetimeFormatter } from '@tmagic/utils';
|
|
19
19
|
|
|
20
20
|
import { DateTimeConfig } from '../schema';
|
|
21
21
|
import { useAddField } from '../utils/useAddField';
|
|
22
22
|
|
|
23
|
+
defineOptions({
|
|
24
|
+
name: 'MFormDateTime',
|
|
25
|
+
});
|
|
26
|
+
|
|
23
27
|
const props = defineProps<{
|
|
24
28
|
config: DateTimeConfig;
|
|
25
29
|
model: any;
|
package/src/fields/Daterange.vue
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
></TMagicDatePicker>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
|
-
<script lang="ts" setup
|
|
16
|
+
<script lang="ts" setup>
|
|
17
17
|
import { ref, watch } from 'vue';
|
|
18
18
|
|
|
19
19
|
import { TMagicDatePicker } from '@tmagic/design';
|
|
@@ -22,6 +22,10 @@ import { datetimeFormatter } from '@tmagic/utils';
|
|
|
22
22
|
import { DaterangeConfig } from '../schema';
|
|
23
23
|
import { useAddField } from '../utils/useAddField';
|
|
24
24
|
|
|
25
|
+
defineOptions({
|
|
26
|
+
name: 'MFormDateRange',
|
|
27
|
+
});
|
|
28
|
+
|
|
25
29
|
const props = defineProps<{
|
|
26
30
|
config: DaterangeConfig;
|
|
27
31
|
model: any;
|
package/src/fields/Display.vue
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
<span v-if="model">{{ model[name] }}</span>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script setup lang="ts"
|
|
5
|
+
<script setup lang="ts">
|
|
6
6
|
import { DisplayConfig } from '../schema';
|
|
7
7
|
import { useAddField } from '../utils/useAddField';
|
|
8
8
|
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: 'MFormDisplay',
|
|
11
|
+
});
|
|
12
|
+
|
|
9
13
|
const props = defineProps<{
|
|
10
14
|
config: DisplayConfig;
|
|
11
15
|
model: any;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts" setup
|
|
15
|
+
<script lang="ts" setup>
|
|
16
16
|
/**
|
|
17
17
|
* 动态表单,目前只支持input类型字段
|
|
18
18
|
* inputType: 'dynamic-field',
|
|
@@ -31,6 +31,10 @@ import { DynamicFieldConfig } from '../schema';
|
|
|
31
31
|
import { getConfig } from '../utils/config';
|
|
32
32
|
import { useAddField } from '../utils/useAddField';
|
|
33
33
|
|
|
34
|
+
defineOptions({
|
|
35
|
+
name: 'MFormDynamicField',
|
|
36
|
+
});
|
|
37
|
+
|
|
34
38
|
const props = defineProps<{
|
|
35
39
|
config: DynamicFieldConfig;
|
|
36
40
|
model: any;
|
package/src/fields/Hidden.vue
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
<input v-if="model" v-model="model[name]" type="hidden" />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script setup lang="ts"
|
|
5
|
+
<script setup lang="ts">
|
|
6
6
|
import { HiddenConfig } from '../schema';
|
|
7
7
|
import { useAddField } from '../utils/useAddField';
|
|
8
8
|
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: 'MFormHidden',
|
|
11
|
+
});
|
|
12
|
+
|
|
9
13
|
const props = defineProps<{
|
|
10
14
|
config: HiddenConfig;
|
|
11
15
|
model: any;
|
package/src/fields/Link.vue
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script lang="ts" setup
|
|
19
|
+
<script lang="ts" setup>
|
|
20
20
|
import { computed, inject, ref } from 'vue';
|
|
21
21
|
|
|
22
22
|
import { TMagicButton } from '@tmagic/design';
|
|
@@ -25,6 +25,10 @@ import FormDialog from '../FormDialog.vue';
|
|
|
25
25
|
import { FormState, LinkConfig } from '../schema';
|
|
26
26
|
import { useAddField } from '../utils/useAddField';
|
|
27
27
|
|
|
28
|
+
defineOptions({
|
|
29
|
+
name: 'MFormLink',
|
|
30
|
+
});
|
|
31
|
+
|
|
28
32
|
const props = defineProps<{
|
|
29
33
|
config: LinkConfig;
|
|
30
34
|
model: any;
|
package/src/fields/Number.vue
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
></TMagicInputNumber>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
|
-
<script lang="ts" setup
|
|
18
|
+
<script lang="ts" setup>
|
|
19
19
|
import { inject } from 'vue';
|
|
20
20
|
|
|
21
21
|
import { TMagicInputNumber } from '@tmagic/design';
|
|
@@ -23,6 +23,10 @@ import { TMagicInputNumber } from '@tmagic/design';
|
|
|
23
23
|
import { FormState, NumberConfig } from '../schema';
|
|
24
24
|
import { useAddField } from '../utils/useAddField';
|
|
25
25
|
|
|
26
|
+
defineOptions({
|
|
27
|
+
name: 'MFormNumber',
|
|
28
|
+
});
|
|
29
|
+
|
|
26
30
|
const props = defineProps<{
|
|
27
31
|
config: NumberConfig;
|
|
28
32
|
model: any;
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
</TMagicRadioGroup>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script lang="ts" setup
|
|
13
|
+
<script lang="ts" setup>
|
|
14
14
|
import { TMagicRadio, TMagicRadioGroup } from '@tmagic/design';
|
|
15
15
|
|
|
16
16
|
import { RadioGroupConfig } from '../schema';
|
|
17
17
|
import { useAddField } from '../utils/useAddField';
|
|
18
18
|
|
|
19
|
+
defineOptions({
|
|
20
|
+
name: 'MFormRadioGroup',
|
|
21
|
+
});
|
|
22
|
+
|
|
19
23
|
const props = defineProps<{
|
|
20
24
|
config: RadioGroupConfig;
|
|
21
25
|
model: any;
|
package/src/fields/Select.vue
CHANGED
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
</TMagicSelect>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
|
-
<script lang="ts" setup
|
|
28
|
+
<script lang="ts" setup>
|
|
29
29
|
import { inject, onBeforeMount, Ref, ref, watch, watchEffect } from 'vue';
|
|
30
30
|
|
|
31
31
|
import { TMagicSelect } from '@tmagic/design';
|
|
32
|
+
import { getValueByKeyPath } from '@tmagic/utils';
|
|
32
33
|
|
|
33
34
|
import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
|
|
34
35
|
import { getConfig } from '../utils/config';
|
|
@@ -37,6 +38,10 @@ import { useAddField } from '../utils/useAddField';
|
|
|
37
38
|
import SelectOptionGroups from './SelectOptionGroups.vue';
|
|
38
39
|
import SelectOptions from './SelectOptions.vue';
|
|
39
40
|
|
|
41
|
+
defineOptions({
|
|
42
|
+
name: 'MFormSelect',
|
|
43
|
+
});
|
|
44
|
+
|
|
40
45
|
const props = defineProps<{
|
|
41
46
|
config: SelectConfig;
|
|
42
47
|
model: any;
|
|
@@ -157,12 +162,9 @@ const getOptions = async () => {
|
|
|
157
162
|
});
|
|
158
163
|
}
|
|
159
164
|
|
|
160
|
-
const optionsData = root
|
|
165
|
+
const optionsData = getValueByKeyPath(root, res);
|
|
161
166
|
|
|
162
|
-
const resTotal = globalThis.parseInt(
|
|
163
|
-
totalKey.split('.').reduce((accumulator, currentValue: any) => accumulator[currentValue], res),
|
|
164
|
-
10,
|
|
165
|
-
);
|
|
167
|
+
const resTotal = globalThis.parseInt(getValueByKeyPath(totalKey, res), 10);
|
|
166
168
|
if (resTotal > 0) {
|
|
167
169
|
total.value = resTotal;
|
|
168
170
|
}
|
|
@@ -283,9 +285,7 @@ const getInitOption = async () => {
|
|
|
283
285
|
});
|
|
284
286
|
}
|
|
285
287
|
|
|
286
|
-
let initData = (initRoot || root)
|
|
287
|
-
.split('.')
|
|
288
|
-
.reduce((accumulator, currentValue: any) => accumulator[currentValue], res);
|
|
288
|
+
let initData = getValueByKeyPath(initRoot || root, res);
|
|
289
289
|
if (initData) {
|
|
290
290
|
if (!Array.isArray(initData)) {
|
|
291
291
|
initData = [initData];
|