@tmagic/form 1.0.2 → 1.0.5
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 +3 -0
- package/dist/tmagic-form.es.js +253 -267
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +255 -269
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/containers/Fieldset.vue.d.ts +54 -31
- package/dist/types/src/containers/Tabs.vue.d.ts +2 -0
- package/dist/types/src/fields/Date.vue.d.ts +1 -2
- package/dist/types/src/fields/SelectOptionGroups.vue.d.ts +13 -0
- package/dist/types/src/fields/SelectOptions.vue.d.ts +21 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/schema.d.ts +10 -1
- package/package.json +8 -9
- package/src/containers/Fieldset.vue +44 -73
- package/src/containers/Tabs.vue +11 -2
- package/src/fields/Cascader.vue +2 -1
- package/src/fields/Date.vue +12 -16
- package/src/fields/DateTime.vue +1 -1
- package/src/fields/Daterange.vue +1 -1
- package/src/fields/Select.vue +10 -23
- package/src/fields/SelectOptionGroups.vue +20 -0
- package/src/fields/SelectOptions.vue +18 -0
- package/src/fields/Time.vue +8 -10
- package/src/index.ts +1 -1
- package/src/schema.ts +10 -1
- package/src/theme/fieldset.scss +4 -0
- package/src/utils/form.ts +3 -12
|
@@ -1,56 +1,79 @@
|
|
|
1
|
-
import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes
|
|
1
|
+
import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
2
|
import { FieldsetConfig, FormState } from '../schema';
|
|
3
|
-
declare const
|
|
4
|
-
labelWidth:
|
|
3
|
+
declare const _sfc_main: DefineComponent<{
|
|
4
|
+
labelWidth: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
required: false;
|
|
7
|
+
};
|
|
8
|
+
prop: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
size: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
required: false;
|
|
16
|
+
};
|
|
5
17
|
model: {
|
|
6
18
|
type: ObjectConstructor;
|
|
7
|
-
|
|
19
|
+
required: true;
|
|
8
20
|
};
|
|
9
21
|
config: {
|
|
10
|
-
type:
|
|
11
|
-
|
|
22
|
+
type: null;
|
|
23
|
+
required: true;
|
|
12
24
|
};
|
|
13
25
|
rules: {
|
|
14
|
-
type:
|
|
15
|
-
|
|
26
|
+
type: null;
|
|
27
|
+
required: false;
|
|
28
|
+
default: {};
|
|
16
29
|
};
|
|
17
|
-
prop: {
|
|
18
|
-
type: StringConstructor;
|
|
19
|
-
default: () => string;
|
|
20
|
-
};
|
|
21
|
-
size: StringConstructor;
|
|
22
30
|
}, {
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
props: {
|
|
32
|
+
labelWidth?: string | undefined;
|
|
33
|
+
prop: string;
|
|
34
|
+
size?: string | undefined;
|
|
35
|
+
model: Record<string, any>;
|
|
36
|
+
config: FieldsetConfig;
|
|
37
|
+
rules: any;
|
|
38
|
+
};
|
|
39
|
+
emit: (event: "change", ...args: any[]) => void;
|
|
25
40
|
mForm: FormState | undefined;
|
|
41
|
+
name: ComputedRef<string | number>;
|
|
42
|
+
show: ComputedRef<any>;
|
|
26
43
|
lWidth: ComputedRef<string | null | undefined>;
|
|
27
|
-
key: (item: any, index: number) => any;
|
|
28
44
|
change: () => void;
|
|
45
|
+
key: (item: any, index: number) => any;
|
|
29
46
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "change"[], "change", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
30
|
-
labelWidth:
|
|
47
|
+
labelWidth: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
required: false;
|
|
50
|
+
};
|
|
51
|
+
prop: {
|
|
52
|
+
type: StringConstructor;
|
|
53
|
+
required: true;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
size: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
required: false;
|
|
59
|
+
};
|
|
31
60
|
model: {
|
|
32
61
|
type: ObjectConstructor;
|
|
33
|
-
|
|
62
|
+
required: true;
|
|
34
63
|
};
|
|
35
64
|
config: {
|
|
36
|
-
type:
|
|
37
|
-
|
|
65
|
+
type: null;
|
|
66
|
+
required: true;
|
|
38
67
|
};
|
|
39
68
|
rules: {
|
|
40
|
-
type:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
prop: {
|
|
44
|
-
type: StringConstructor;
|
|
45
|
-
default: () => string;
|
|
69
|
+
type: null;
|
|
70
|
+
required: false;
|
|
71
|
+
default: {};
|
|
46
72
|
};
|
|
47
|
-
size: StringConstructor;
|
|
48
73
|
}>> & {
|
|
49
74
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
50
75
|
}, {
|
|
51
|
-
|
|
52
|
-
model: Record<string, any>;
|
|
53
|
-
rules: Record<string, any>;
|
|
76
|
+
rules: any;
|
|
54
77
|
prop: string;
|
|
55
78
|
}>;
|
|
56
|
-
export default
|
|
79
|
+
export default _sfc_main;
|
|
@@ -12,6 +12,7 @@ declare const Tab: DefineComponent<{
|
|
|
12
12
|
default: () => {};
|
|
13
13
|
};
|
|
14
14
|
prop: StringConstructor;
|
|
15
|
+
name: StringConstructor;
|
|
15
16
|
size: StringConstructor;
|
|
16
17
|
}, {
|
|
17
18
|
mForm: FormState | undefined;
|
|
@@ -36,6 +37,7 @@ declare const Tab: DefineComponent<{
|
|
|
36
37
|
default: () => {};
|
|
37
38
|
};
|
|
38
39
|
prop: StringConstructor;
|
|
40
|
+
name: StringConstructor;
|
|
39
41
|
size: StringConstructor;
|
|
40
42
|
}>>, {
|
|
41
43
|
config: TabConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefineComponent,
|
|
1
|
+
import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import { DateConfig } from '../schema';
|
|
3
3
|
declare const _default: DefineComponent<{
|
|
4
4
|
config: {
|
|
@@ -23,7 +23,6 @@ declare const _default: DefineComponent<{
|
|
|
23
23
|
initValues: ObjectConstructor;
|
|
24
24
|
values: ObjectConstructor;
|
|
25
25
|
}, {
|
|
26
|
-
modelName: ComputedRef<string | number>;
|
|
27
26
|
changeHandler(v: string): void;
|
|
28
27
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "input")[], "change" | "input", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
29
28
|
config: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
|
+
declare const _sfc_main: DefineComponent<{
|
|
3
|
+
options: {
|
|
4
|
+
type: ArrayConstructor;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
}, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
8
|
+
options: {
|
|
9
|
+
type: ArrayConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
}>>, {}>;
|
|
13
|
+
export default _sfc_main;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
|
+
declare const _sfc_main: DefineComponent<{
|
|
3
|
+
options: {
|
|
4
|
+
type: ArrayConstructor;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
valueKey: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
required: false;
|
|
10
|
+
};
|
|
11
|
+
}, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
12
|
+
options: {
|
|
13
|
+
type: ArrayConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
valueKey: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
required: false;
|
|
19
|
+
};
|
|
20
|
+
}>>, {}>;
|
|
21
|
+
export default _sfc_main;
|
|
@@ -31,6 +31,6 @@ export { default as MSelect } from './fields/Select.vue';
|
|
|
31
31
|
export { default as MCascader } from './fields/Cascader.vue';
|
|
32
32
|
export { default as MDynamicField } from './fields/DynamicField.vue';
|
|
33
33
|
declare const _default: {
|
|
34
|
-
install: (app: App
|
|
34
|
+
install: (app: App<any>, opt: any) => void;
|
|
35
35
|
};
|
|
36
36
|
export default _default;
|
|
@@ -137,7 +137,14 @@ export interface SelectGroupOption {
|
|
|
137
137
|
label: string;
|
|
138
138
|
/** 是否禁用该选项组 */
|
|
139
139
|
disabled: boolean;
|
|
140
|
-
options:
|
|
140
|
+
options: {
|
|
141
|
+
/** 选项的标签 */
|
|
142
|
+
label: string | SelectOptionTextFunction;
|
|
143
|
+
/** 选项的值 */
|
|
144
|
+
value: any | SelectOptionValueFunction;
|
|
145
|
+
/** 是否禁用该选项 */
|
|
146
|
+
disabled?: boolean;
|
|
147
|
+
}[];
|
|
141
148
|
}
|
|
142
149
|
declare type SelectOptionFunction = (mForm: FormState | undefined, data: {
|
|
143
150
|
model: any;
|
|
@@ -404,6 +411,7 @@ export interface TabPaneConfig {
|
|
|
404
411
|
lazy?: boolean;
|
|
405
412
|
labelWidth?: string;
|
|
406
413
|
items: FormConfig;
|
|
414
|
+
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
|
|
407
415
|
[key: string]: any;
|
|
408
416
|
}
|
|
409
417
|
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
|
@@ -416,6 +424,7 @@ export interface TabConfig extends FormItem, ContainerCommonConfig {
|
|
|
416
424
|
onChange?: (mForm: FormState | undefined, data: any) => void;
|
|
417
425
|
onTabAdd?: (mForm: FormState | undefined, data: any) => void;
|
|
418
426
|
onTabRemove?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
|
427
|
+
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
|
|
419
428
|
activeChange?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
|
420
429
|
}
|
|
421
430
|
/**
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.5",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "vite build"
|
|
25
|
+
"build": "vue-tsc --noEmit && vite build"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=14"
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@element-plus/icons": "0.0.11",
|
|
36
|
-
"@tmagic/utils": "1.0.
|
|
37
|
-
"element-plus": "^2.2.
|
|
36
|
+
"@tmagic/utils": "1.0.5",
|
|
37
|
+
"element-plus": "^2.2.6",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
39
|
"moment": "^2.29.2",
|
|
40
40
|
"sortablejs": "^1.14.0",
|
|
41
41
|
"vue": "^3.2.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"element-plus": "^2.2.
|
|
44
|
+
"element-plus": "^2.2.6",
|
|
45
45
|
"vue": "^3.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
@@ -49,14 +49,13 @@
|
|
|
49
49
|
"@types/lodash-es": "^4.17.4",
|
|
50
50
|
"@types/node": "^15.12.4",
|
|
51
51
|
"@types/sortablejs": "^1.10.7",
|
|
52
|
-
"@vitejs/plugin-vue": "^
|
|
53
|
-
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
|
52
|
+
"@vitejs/plugin-vue": "^2.3.3",
|
|
54
53
|
"@vue/compiler-sfc": "^3.2.0",
|
|
55
54
|
"@vue/test-utils": "^2.0.0",
|
|
56
55
|
"sass": "^1.35.1",
|
|
57
56
|
"typescript": "^4.3.4",
|
|
58
|
-
"vite": "^2.
|
|
57
|
+
"vite": "^2.9.13",
|
|
59
58
|
"vite-plugin-dts": "^0.9.6",
|
|
60
|
-
"vue-tsc": "^0.
|
|
59
|
+
"vue-tsc": "^0.38.2"
|
|
61
60
|
}
|
|
62
61
|
}
|
|
@@ -4,25 +4,15 @@
|
|
|
4
4
|
class="m-fieldset"
|
|
5
5
|
:style="show ? 'padding: 15px 15px 0 5px;' : 'border: 0'"
|
|
6
6
|
>
|
|
7
|
-
<
|
|
8
|
-
v-if="!show && name"
|
|
9
|
-
v-model="model[name].value"
|
|
10
|
-
:prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
|
|
11
|
-
:true-label="1"
|
|
12
|
-
:false-label="0"
|
|
13
|
-
@change="change"
|
|
14
|
-
><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
|
|
15
|
-
></el-checkbox>
|
|
16
|
-
<legend v-else-if="config.checkbox && name">
|
|
7
|
+
<component v-if="name && config.checkbox" :is="!show ? 'div' : 'legend'">
|
|
17
8
|
<el-checkbox
|
|
18
9
|
v-model="model[name].value"
|
|
19
10
|
:prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
|
|
20
11
|
:true-label="1"
|
|
21
12
|
:false-label="0"
|
|
22
|
-
@change="change"
|
|
23
13
|
><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
|
|
24
14
|
></el-checkbox>
|
|
25
|
-
</
|
|
15
|
+
</component>
|
|
26
16
|
<legend v-else>
|
|
27
17
|
<span v-html="config.legend"></span>
|
|
28
18
|
<span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span>
|
|
@@ -62,77 +52,58 @@
|
|
|
62
52
|
</fieldset>
|
|
63
53
|
</template>
|
|
64
54
|
|
|
65
|
-
<script lang="ts">
|
|
66
|
-
import { computed,
|
|
55
|
+
<script lang="ts" setup>
|
|
56
|
+
import { computed, inject, watch } from 'vue';
|
|
67
57
|
|
|
68
58
|
import { FieldsetConfig, FormState } from '../schema';
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
type: Object as PropType<FieldsetConfig>,
|
|
83
|
-
default: () => ({}),
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
rules: {
|
|
87
|
-
type: Object,
|
|
88
|
-
default: () => ({}),
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
prop: {
|
|
92
|
-
type: String,
|
|
93
|
-
default: () => '',
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
size: String,
|
|
60
|
+
const props = withDefaults(
|
|
61
|
+
defineProps<{
|
|
62
|
+
labelWidth?: string;
|
|
63
|
+
prop: string;
|
|
64
|
+
size?: string;
|
|
65
|
+
model: Record<string, any>;
|
|
66
|
+
config: FieldsetConfig;
|
|
67
|
+
rules?: any;
|
|
68
|
+
}>(),
|
|
69
|
+
{
|
|
70
|
+
rules: {},
|
|
71
|
+
prop: '',
|
|
97
72
|
},
|
|
73
|
+
);
|
|
98
74
|
|
|
99
|
-
|
|
75
|
+
const emit = defineEmits(['change']);
|
|
100
76
|
|
|
101
|
-
|
|
102
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
77
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
103
78
|
|
|
104
|
-
|
|
79
|
+
const name = computed(() => props.config.name || '');
|
|
105
80
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
81
|
+
const show = computed(() => {
|
|
82
|
+
if (props.config.expand && name.value) {
|
|
83
|
+
return props.model[name.value]?.value;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
});
|
|
112
87
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
88
|
+
const lWidth = computed(() => {
|
|
89
|
+
if (props.config.items) {
|
|
90
|
+
return props.config.labelWidth || props.labelWidth;
|
|
91
|
+
}
|
|
92
|
+
return props.config.labelWidth || props.labelWidth || (props.config.text ? null : '0');
|
|
93
|
+
});
|
|
119
94
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
95
|
+
const change = () => {
|
|
96
|
+
emit('change', props.model);
|
|
97
|
+
};
|
|
123
98
|
|
|
124
|
-
|
|
99
|
+
const key = (item: any, index: number) => item[mForm?.keyProp || '__key'] ?? index;
|
|
125
100
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
});
|
|
101
|
+
if (props.config.checkbox && name.value) {
|
|
102
|
+
watch(
|
|
103
|
+
() => props.model[name.value]?.value,
|
|
104
|
+
() => {
|
|
105
|
+
emit('change', props.model);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
}
|
|
136
109
|
</script>
|
|
137
|
-
|
|
138
|
-
<style lang="scss"></style>
|
package/src/containers/Tabs.vue
CHANGED
|
@@ -21,7 +21,15 @@
|
|
|
21
21
|
v-for="item in tabItems(tab)"
|
|
22
22
|
:key="item[mForm?.keyProp || '__key']"
|
|
23
23
|
:config="item"
|
|
24
|
-
:model="
|
|
24
|
+
:model="
|
|
25
|
+
config.dynamic
|
|
26
|
+
? (name ? model[name] : model)[tabIndex]
|
|
27
|
+
: tab.name
|
|
28
|
+
? (name ? model[name] : model)[tab.name]
|
|
29
|
+
: name
|
|
30
|
+
? model[name]
|
|
31
|
+
: model
|
|
32
|
+
"
|
|
25
33
|
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
|
26
34
|
:size="size"
|
|
27
35
|
:label-width="tab.labelWidth || labelWidth"
|
|
@@ -34,7 +42,6 @@
|
|
|
34
42
|
</template>
|
|
35
43
|
|
|
36
44
|
<script lang="ts">
|
|
37
|
-
/* eslint-disable vue/no-mutating-props */
|
|
38
45
|
import { computed, defineComponent, inject, PropType, ref, watchEffect } from 'vue';
|
|
39
46
|
import { cloneDeep } from 'lodash-es';
|
|
40
47
|
|
|
@@ -87,6 +94,8 @@ const Tab = defineComponent({
|
|
|
87
94
|
|
|
88
95
|
prop: String,
|
|
89
96
|
|
|
97
|
+
name: String,
|
|
98
|
+
|
|
90
99
|
size: String,
|
|
91
100
|
},
|
|
92
101
|
|
package/src/fields/Cascader.vue
CHANGED
|
@@ -79,8 +79,9 @@ export default defineComponent({
|
|
|
79
79
|
if (typeof body === 'function' && props.model && mForm) {
|
|
80
80
|
body = body(mForm, {
|
|
81
81
|
model: props.model,
|
|
82
|
-
formValue:
|
|
82
|
+
formValue: mForm.values,
|
|
83
83
|
formValues: mForm.values,
|
|
84
|
+
config: props.config,
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
postOptions.data = body;
|
package/src/fields/Date.vue
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
></el-date-picker>
|
|
13
|
-
</div>
|
|
2
|
+
<el-date-picker
|
|
3
|
+
v-model="model[name]"
|
|
4
|
+
type="date"
|
|
5
|
+
:size="size"
|
|
6
|
+
:placeholder="config.placeholder"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:format="config.format"
|
|
9
|
+
:value-format="config.format || 'YYYY-MM-DD HH:mm:ss'"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
></el-date-picker>
|
|
14
12
|
</template>
|
|
15
13
|
|
|
16
14
|
<script lang="ts">
|
|
17
|
-
import {
|
|
15
|
+
import { defineComponent, PropType } from 'vue';
|
|
18
16
|
|
|
19
17
|
import { datetimeFormatter } from '@tmagic/utils';
|
|
20
18
|
|
|
@@ -38,10 +36,8 @@ export default defineComponent({
|
|
|
38
36
|
setup(props, { emit }) {
|
|
39
37
|
useAddField(props.prop);
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
props.model[modelName.value] = datetimeFormatter(props.model[modelName.value], '');
|
|
39
|
+
props.model[props.name] = datetimeFormatter(props.model[props.name], '');
|
|
43
40
|
return {
|
|
44
|
-
modelName,
|
|
45
41
|
changeHandler(v: string) {
|
|
46
42
|
emit('change', v);
|
|
47
43
|
},
|
package/src/fields/DateTime.vue
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:disabled="disabled"
|
|
9
9
|
:format="config.format || 'YYYY-MM-DD HH:mm:ss'"
|
|
10
10
|
:value-format="config.valueFormat || 'YYYY-MM-DD HH:mm:ss'"
|
|
11
|
-
:default-time="config.defaultTime
|
|
11
|
+
:default-time="config.defaultTime"
|
|
12
12
|
@change="changeHandler"
|
|
13
13
|
></el-date-picker>
|
|
14
14
|
</template>
|
package/src/fields/Daterange.vue
CHANGED
package/src/fields/Select.vue
CHANGED
|
@@ -19,33 +19,14 @@
|
|
|
19
19
|
@change="changeHandler"
|
|
20
20
|
@visible-change="visibleHandler"
|
|
21
21
|
>
|
|
22
|
-
<template v-if="config.group">
|
|
23
|
-
|
|
24
|
-
<el-option
|
|
25
|
-
v-for="(item, index) in group.options"
|
|
26
|
-
:key="index"
|
|
27
|
-
:label="item.label"
|
|
28
|
-
:value="item.value"
|
|
29
|
-
:disabled="item.disabled"
|
|
30
|
-
>
|
|
31
|
-
</el-option>
|
|
32
|
-
</el-option-group>
|
|
33
|
-
</template>
|
|
34
|
-
<template v-else>
|
|
35
|
-
<el-option
|
|
36
|
-
v-for="option in options"
|
|
37
|
-
:label="option.text"
|
|
38
|
-
:value="option.value"
|
|
39
|
-
:key="config.valueKey ? option.value[config.valueKey] : option.value"
|
|
40
|
-
:disabled="option.disabled"
|
|
41
|
-
></el-option>
|
|
42
|
-
</template>
|
|
22
|
+
<template v-if="config.group"><select-option-groups :options="groupOptions"></select-option-groups></template>
|
|
23
|
+
<template v-else><select-options :options="options"></select-options></template>
|
|
43
24
|
<div v-loading="true" v-if="moreLoadingVisible"></div>
|
|
44
25
|
</el-select>
|
|
45
26
|
</template>
|
|
46
27
|
|
|
47
28
|
<script lang="ts">
|
|
48
|
-
import { defineComponent, inject, onBeforeMount, onMounted, PropType, ref, watch } from 'vue';
|
|
29
|
+
import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref, watch } from 'vue';
|
|
49
30
|
import { ElSelect } from 'element-plus';
|
|
50
31
|
|
|
51
32
|
import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
|
|
@@ -53,9 +34,14 @@ import { getConfig } from '../utils/config';
|
|
|
53
34
|
import fieldProps from '../utils/fieldProps';
|
|
54
35
|
import { useAddField } from '../utils/useAddField';
|
|
55
36
|
|
|
37
|
+
import SelectOptionGroups from './SelectOptionGroups.vue';
|
|
38
|
+
import SelectOptions from './SelectOptions.vue';
|
|
39
|
+
|
|
56
40
|
export default defineComponent({
|
|
57
41
|
name: 'm-fields-select',
|
|
58
42
|
|
|
43
|
+
components: { SelectOptions, SelectOptionGroups },
|
|
44
|
+
|
|
59
45
|
props: {
|
|
60
46
|
...fieldProps,
|
|
61
47
|
config: {
|
|
@@ -344,7 +330,8 @@ export default defineComponent({
|
|
|
344
330
|
select,
|
|
345
331
|
loading,
|
|
346
332
|
remote,
|
|
347
|
-
options
|
|
333
|
+
options: options as Ref<SelectOption[]>,
|
|
334
|
+
groupOptions: options as Ref<SelectGroupOption[]>,
|
|
348
335
|
moreLoadingVisible,
|
|
349
336
|
popperClass: mForm?.popperClass,
|
|
350
337
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-option-group v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
|
3
|
+
<el-option
|
|
4
|
+
v-for="(item, index) in group.options"
|
|
5
|
+
:key="index"
|
|
6
|
+
:label="item.label"
|
|
7
|
+
:value="item.value"
|
|
8
|
+
:disabled="item.disabled"
|
|
9
|
+
>
|
|
10
|
+
</el-option>
|
|
11
|
+
</el-option-group>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { SelectGroupOption } from '../schema';
|
|
16
|
+
|
|
17
|
+
defineProps<{
|
|
18
|
+
options: SelectGroupOption[];
|
|
19
|
+
}>();
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-option
|
|
3
|
+
v-for="option in options"
|
|
4
|
+
:label="option.text"
|
|
5
|
+
:value="option.value"
|
|
6
|
+
:key="valueKey ? option.value[valueKey] : option.value"
|
|
7
|
+
:disabled="option.disabled"
|
|
8
|
+
></el-option>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import { SelectOption } from '../schema';
|
|
13
|
+
|
|
14
|
+
defineProps<{
|
|
15
|
+
options: SelectOption[];
|
|
16
|
+
valueKey?: string;
|
|
17
|
+
}>();
|
|
18
|
+
</script>
|
package/src/fields/Time.vue
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
></el-time-picker>
|
|
11
|
-
</div>
|
|
2
|
+
<el-time-picker
|
|
3
|
+
v-model="model[name]"
|
|
4
|
+
:size="size"
|
|
5
|
+
value-format="HH:mm:ss"
|
|
6
|
+
:placeholder="config.placeholder"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
@change="changeHandler"
|
|
9
|
+
></el-time-picker>
|
|
12
10
|
</template>
|
|
13
11
|
|
|
14
12
|
<script lang="ts">
|
package/src/index.ts
CHANGED
|
@@ -95,7 +95,7 @@ const install = (app: App, opt: any) => {
|
|
|
95
95
|
app.component(Form.name, Form);
|
|
96
96
|
app.component(FormDialog.name, FormDialog);
|
|
97
97
|
app.component(Container.name, Container);
|
|
98
|
-
app.component(
|
|
98
|
+
app.component('m-form-fieldset', Fieldset);
|
|
99
99
|
app.component(GroupList.name, GroupList);
|
|
100
100
|
app.component(Panel.name, Panel);
|
|
101
101
|
app.component(Row.name, Row);
|