@tmagic/form 1.0.0-beta.1 → 1.0.0-beta.12
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/LICENSE +5432 -0
- package/README.md +1 -0
- package/dist/style.css +0 -1
- package/dist/tmagic-form.es.js +71 -47
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +71 -47
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/containers/Container.vue.d.ts +1 -1
- package/dist/types/src/containers/Fieldset.vue.d.ts +1 -1
- package/dist/types/src/containers/GroupList.vue.d.ts +1 -1
- package/dist/types/src/containers/GroupListItem.vue.d.ts +1 -1
- package/dist/types/src/containers/Panel.vue.d.ts +1 -1
- package/dist/types/src/containers/Row.vue.d.ts +1 -1
- package/dist/types/src/containers/Step.vue.d.ts +1 -1
- package/dist/types/src/containers/Tabs.vue.d.ts +2 -2
- package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
- package/dist/types/src/fields/CheckboxGroup.vue.d.ts +2 -2
- package/dist/types/src/fields/Date.vue.d.ts +2 -2
- package/dist/types/src/fields/DateTime.vue.d.ts +2 -2
- package/dist/types/src/fields/Daterange.vue.d.ts +2 -2
- package/dist/types/src/fields/DynamicField.vue.d.ts +2 -2
- package/dist/types/src/fields/Number.vue.d.ts +2 -2
- package/dist/types/src/fields/RadioGroup.vue.d.ts +2 -2
- package/dist/types/src/fields/Switch.vue.d.ts +2 -2
- package/dist/types/src/fields/Text.vue.d.ts +2 -2
- package/dist/types/src/fields/Textarea.vue.d.ts +2 -2
- package/dist/types/src/fields/Time.vue.d.ts +2 -2
- package/dist/types/src/schema.d.ts +2 -0
- package/package.json +10 -8
- package/src/Form.vue +39 -30
- package/src/FormDialog.vue +3 -0
- package/src/containers/Container.vue +20 -7
- package/src/containers/Table.vue +8 -6
- package/src/containers/Tabs.vue +4 -0
- package/src/fields/Select.vue +4 -3
- package/src/fields/Text.vue +4 -4
- package/src/schema.ts +2 -0
- package/src/theme/table.scss +0 -1
- package/src/utils/form.ts +5 -1
- package/dist/types/src/Form.vue.d.ts +0 -304
- package/dist/types/src/FormDialog.vue.d.ts +0 -641
- package/dist/types/src/containers/Table.vue.d.ts +0 -1401
- package/dist/types/src/fields/Cascader.vue.d.ts +0 -1748
- package/dist/types/src/fields/Link.vue.d.ts +0 -1365
- package/dist/types/src/fields/Select.vue.d.ts +0 -975
|
@@ -48,9 +48,9 @@ declare const _default: DefineComponent<{
|
|
|
48
48
|
}>> & {
|
|
49
49
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
50
50
|
}, {
|
|
51
|
+
config: FieldsetConfig;
|
|
51
52
|
model: Record<string, any>;
|
|
52
53
|
rules: Record<string, any>;
|
|
53
|
-
config: FieldsetConfig;
|
|
54
54
|
prop: string;
|
|
55
55
|
}>;
|
|
56
56
|
export default _default;
|
|
@@ -48,9 +48,9 @@ declare const _default: DefineComponent<{
|
|
|
48
48
|
}>> & {
|
|
49
49
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
50
50
|
}, {
|
|
51
|
-
model: Record<string, any>;
|
|
52
51
|
name: string;
|
|
53
52
|
config: GroupListConfig;
|
|
53
|
+
model: Record<string, any>;
|
|
54
54
|
prop: string;
|
|
55
55
|
}>;
|
|
56
56
|
export default _default;
|
|
@@ -64,8 +64,8 @@ declare const _default: DefineComponent<{
|
|
|
64
64
|
"onSwap-item"?: ((...args: any[]) => any) | undefined;
|
|
65
65
|
"onRemove-item"?: ((...args: any[]) => any) | undefined;
|
|
66
66
|
}, {
|
|
67
|
-
model: Record<string, any>;
|
|
68
67
|
config: GroupListConfig;
|
|
68
|
+
model: Record<string, any>;
|
|
69
69
|
index: string | number | symbol;
|
|
70
70
|
groupModel: unknown[];
|
|
71
71
|
}>;
|
|
@@ -18,7 +18,7 @@ declare const Tab: DefineComponent<{
|
|
|
18
18
|
activeTabName: any;
|
|
19
19
|
tabs: ComputedRef<any>;
|
|
20
20
|
filter: (config: any) => any;
|
|
21
|
-
tabItems: (tab: TabPaneConfig) => TabPaneConfig[]
|
|
21
|
+
tabItems: (tab: TabPaneConfig) => FormConfig | TabPaneConfig[];
|
|
22
22
|
tabClickHandler: (tab: any) => void;
|
|
23
23
|
onTabAdd: () => void;
|
|
24
24
|
onTabRemove: (tabName: string) => void;
|
|
@@ -38,8 +38,8 @@ declare const Tab: DefineComponent<{
|
|
|
38
38
|
prop: StringConstructor;
|
|
39
39
|
size: StringConstructor;
|
|
40
40
|
}>>, {
|
|
41
|
+
config: TabConfig;
|
|
41
42
|
model: Record<string, any>;
|
|
42
43
|
expandMore: boolean;
|
|
43
|
-
config: TabConfig;
|
|
44
44
|
}>;
|
|
45
45
|
export default Tab;
|
|
@@ -52,8 +52,8 @@ declare const _default: DefineComponent<{
|
|
|
52
52
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
53
53
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
54
54
|
}, {
|
|
55
|
-
model: Record<string, any>;
|
|
56
|
-
disabled: boolean;
|
|
57
55
|
name: string;
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
model: Record<string, any>;
|
|
58
58
|
}>;
|
|
59
59
|
export default _default;
|
|
@@ -49,8 +49,8 @@ declare const _default: DefineComponent<{
|
|
|
49
49
|
}>> & {
|
|
50
50
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
51
51
|
}, {
|
|
52
|
-
model: Record<string, any>;
|
|
53
|
-
disabled: boolean;
|
|
54
52
|
name: string;
|
|
53
|
+
disabled: boolean;
|
|
54
|
+
model: Record<string, any>;
|
|
55
55
|
}>;
|
|
56
56
|
export default _default;
|
|
@@ -51,8 +51,8 @@ declare const _default: DefineComponent<{
|
|
|
51
51
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
52
52
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
53
53
|
}, {
|
|
54
|
-
model: Record<string, any>;
|
|
55
|
-
disabled: boolean;
|
|
56
54
|
name: string;
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
model: Record<string, any>;
|
|
57
57
|
}>;
|
|
58
58
|
export default _default;
|
|
@@ -50,8 +50,8 @@ declare const _default: DefineComponent<{
|
|
|
50
50
|
}>> & {
|
|
51
51
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
52
52
|
}, {
|
|
53
|
-
model: Record<string, any>;
|
|
54
|
-
disabled: boolean;
|
|
55
53
|
name: string;
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
model: Record<string, any>;
|
|
56
56
|
}>;
|
|
57
57
|
export default _default;
|
|
@@ -50,8 +50,8 @@ declare const _default: DefineComponent<{
|
|
|
50
50
|
}>> & {
|
|
51
51
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
52
52
|
}, {
|
|
53
|
-
model: Record<string, any>;
|
|
54
|
-
disabled: boolean;
|
|
55
53
|
name: string;
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
model: Record<string, any>;
|
|
56
56
|
}>;
|
|
57
57
|
export default _default;
|
|
@@ -69,8 +69,8 @@ declare const _default: DefineComponent<{
|
|
|
69
69
|
}>> & {
|
|
70
70
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
71
71
|
}, {
|
|
72
|
-
model: Record<string, any>;
|
|
73
|
-
disabled: boolean;
|
|
74
72
|
name: string;
|
|
73
|
+
disabled: boolean;
|
|
74
|
+
model: Record<string, any>;
|
|
75
75
|
}>;
|
|
76
76
|
export default _default;
|
|
@@ -52,8 +52,8 @@ declare const _default: DefineComponent<{
|
|
|
52
52
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
53
53
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
54
54
|
}, {
|
|
55
|
-
model: Record<string, any>;
|
|
56
|
-
disabled: boolean;
|
|
57
55
|
name: string;
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
model: Record<string, any>;
|
|
58
58
|
}>;
|
|
59
59
|
export default _default;
|
|
@@ -48,8 +48,8 @@ declare const _default: DefineComponent<{
|
|
|
48
48
|
}>> & {
|
|
49
49
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
50
50
|
}, {
|
|
51
|
-
model: Record<string, any>;
|
|
52
|
-
disabled: boolean;
|
|
53
51
|
name: string;
|
|
52
|
+
disabled: boolean;
|
|
53
|
+
model: Record<string, any>;
|
|
54
54
|
}>;
|
|
55
55
|
export default _default;
|
|
@@ -52,8 +52,8 @@ declare const _default: DefineComponent<{
|
|
|
52
52
|
}>> & {
|
|
53
53
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
54
54
|
}, {
|
|
55
|
-
model: Record<string, any>;
|
|
56
|
-
disabled: boolean;
|
|
57
55
|
name: string;
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
model: Record<string, any>;
|
|
58
58
|
}>;
|
|
59
59
|
export default _default;
|
|
@@ -54,8 +54,8 @@ declare const _default: DefineComponent<{
|
|
|
54
54
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
55
55
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
56
56
|
}, {
|
|
57
|
-
model: Record<string, any>;
|
|
58
|
-
disabled: boolean;
|
|
59
57
|
name: string;
|
|
58
|
+
disabled: boolean;
|
|
59
|
+
model: Record<string, any>;
|
|
60
60
|
}>;
|
|
61
61
|
export default _default;
|
|
@@ -49,8 +49,8 @@ declare const _default: DefineComponent<{
|
|
|
49
49
|
initValues: ObjectConstructor;
|
|
50
50
|
values: ObjectConstructor;
|
|
51
51
|
}>>, {
|
|
52
|
-
model: Record<string, any>;
|
|
53
|
-
disabled: boolean;
|
|
54
52
|
name: string;
|
|
53
|
+
disabled: boolean;
|
|
54
|
+
model: Record<string, any>;
|
|
55
55
|
}>;
|
|
56
56
|
export default _default;
|
|
@@ -47,8 +47,8 @@ declare const _default: DefineComponent<{
|
|
|
47
47
|
initValues: ObjectConstructor;
|
|
48
48
|
values: ObjectConstructor;
|
|
49
49
|
}>>, {
|
|
50
|
-
model: Record<string, any>;
|
|
51
|
-
disabled: boolean;
|
|
52
50
|
name: string;
|
|
51
|
+
disabled: boolean;
|
|
52
|
+
model: Record<string, any>;
|
|
53
53
|
}>;
|
|
54
54
|
export default _default;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare type FormState = {
|
|
5
5
|
config: FormConfig;
|
|
6
|
+
popperClass?: string;
|
|
6
7
|
initValues: FormValue;
|
|
7
8
|
values: FormValue;
|
|
8
9
|
$emit: (event: string, ...args: any[]) => void;
|
|
@@ -137,6 +138,7 @@ export interface SelectGroupOption {
|
|
|
137
138
|
}
|
|
138
139
|
declare type SelectOptionFunction = (mForm: FormState | undefined, data: {
|
|
139
140
|
model: any;
|
|
141
|
+
prop?: string;
|
|
140
142
|
formValues: any;
|
|
141
143
|
formValue: any;
|
|
142
144
|
}) => SelectOption[] | SelectGroupOption[];
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-beta.
|
|
2
|
+
"version": "1.0.0-beta.12",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"main": "dist/tmagic-form.umd.js",
|
|
6
|
+
"module": "dist/tmagic-form.es.js",
|
|
6
7
|
"style": "dist/style.css",
|
|
7
8
|
"types": "dist/types/src/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"import": "./dist/
|
|
11
|
-
"require": "./dist/
|
|
11
|
+
"import": "./dist/tmagic-form.es.js",
|
|
12
|
+
"require": "./dist/tmagic-form.umd.js"
|
|
12
13
|
},
|
|
13
14
|
"./dist/style.css": {
|
|
14
15
|
"import": "./dist/style.css",
|
|
@@ -27,8 +28,8 @@
|
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@element-plus/icons": "0.0.11",
|
|
30
|
-
"@tmagic/utils": "^1.0.0-beta.
|
|
31
|
-
"element-plus": "^2.
|
|
31
|
+
"@tmagic/utils": "^1.0.0-beta.12",
|
|
32
|
+
"element-plus": "^2.1.7",
|
|
32
33
|
"lodash-es": "^4.17.21",
|
|
33
34
|
"moment": "^2.29.1",
|
|
34
35
|
"sortablejs": "^1.14.0",
|
|
@@ -47,5 +48,6 @@
|
|
|
47
48
|
"vite": "^2.3.7",
|
|
48
49
|
"vite-plugin-dts": "^0.9.6",
|
|
49
50
|
"vue-tsc": "^0.0.24"
|
|
50
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "ae00dd242d593ac8f57ffcd34e10e99399c7d00b"
|
|
51
53
|
}
|
package/src/Form.vue
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
v-if="initialized && Array.isArray(config)"
|
|
2
|
+
<el-form
|
|
4
3
|
class="m-form"
|
|
5
4
|
ref="elForm"
|
|
6
5
|
:model="values"
|
|
@@ -10,25 +9,26 @@
|
|
|
10
9
|
:inline="inline"
|
|
11
10
|
:label-position="labelPosition"
|
|
12
11
|
>
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
<template v-if="initialized && Array.isArray(config)">
|
|
13
|
+
<m-form-container
|
|
14
|
+
v-for="(item, index) in config"
|
|
15
|
+
:key="item[keyProp] ?? index"
|
|
16
|
+
:config="item"
|
|
17
|
+
:model="values"
|
|
18
|
+
:label-width="item.labelWidth || labelWidth"
|
|
19
|
+
:step-active="stepActive"
|
|
20
|
+
:size="size"
|
|
21
|
+
@change="changeHandler"
|
|
22
|
+
></m-form-container>
|
|
23
|
+
</template>
|
|
24
|
+
</el-form>
|
|
24
25
|
</template>
|
|
25
26
|
|
|
26
27
|
<script lang="ts">
|
|
27
|
-
import { defineComponent, PropType, provide, reactive, ref,
|
|
28
|
+
import { defineComponent, PropType, provide, reactive, ref, toRaw, watch } from 'vue';
|
|
28
29
|
import { ElForm } from 'element-plus';
|
|
29
|
-
import { cloneDeep } from 'lodash-es';
|
|
30
|
+
import { cloneDeep, isEqual } from 'lodash-es';
|
|
30
31
|
|
|
31
|
-
import MContainer from './containers/Container.vue';
|
|
32
32
|
import { getConfig } from './utils/config';
|
|
33
33
|
import { initValue } from './utils/form';
|
|
34
34
|
import { FormConfig, FormState, FormValue } from './schema';
|
|
@@ -45,8 +45,6 @@ export interface FieldErrorList {
|
|
|
45
45
|
export default defineComponent({
|
|
46
46
|
name: 'm-form',
|
|
47
47
|
|
|
48
|
-
components: { ElForm, MContainer },
|
|
49
|
-
|
|
50
48
|
props: {
|
|
51
49
|
// 表单初始化值
|
|
52
50
|
initValues: {
|
|
@@ -88,8 +86,7 @@ export default defineComponent({
|
|
|
88
86
|
},
|
|
89
87
|
|
|
90
88
|
size: {
|
|
91
|
-
type: String
|
|
92
|
-
default: 'small',
|
|
89
|
+
type: String as PropType<'small' | 'default' | 'large'>,
|
|
93
90
|
},
|
|
94
91
|
|
|
95
92
|
inline: {
|
|
@@ -106,6 +103,10 @@ export default defineComponent({
|
|
|
106
103
|
type: String,
|
|
107
104
|
default: '__key',
|
|
108
105
|
},
|
|
106
|
+
|
|
107
|
+
popperClass: {
|
|
108
|
+
type: String,
|
|
109
|
+
},
|
|
109
110
|
},
|
|
110
111
|
|
|
111
112
|
emits: ['change', 'field-input', 'field-change'],
|
|
@@ -120,6 +121,7 @@ export default defineComponent({
|
|
|
120
121
|
|
|
121
122
|
const formState: FormState = reactive<FormState>({
|
|
122
123
|
keyProp: props.keyProp,
|
|
124
|
+
popperClass: props.popperClass,
|
|
123
125
|
config: props.config,
|
|
124
126
|
initValues: props.initValues,
|
|
125
127
|
parentValues: props.parentValues,
|
|
@@ -141,16 +143,23 @@ export default defineComponent({
|
|
|
141
143
|
|
|
142
144
|
provide('mForm', formState);
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
watch(
|
|
147
|
+
[() => props.config, () => props.initValues],
|
|
148
|
+
([config], [preConfig]) => {
|
|
149
|
+
if (!isEqual(toRaw(config), toRaw(preConfig))) {
|
|
150
|
+
initialized.value = false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
initValue(formState, {
|
|
154
|
+
initValues: props.initValues,
|
|
155
|
+
config: props.config,
|
|
156
|
+
}).then((value) => {
|
|
157
|
+
values.value = value;
|
|
158
|
+
initialized.value = true;
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
{ immediate: true },
|
|
162
|
+
);
|
|
154
163
|
|
|
155
164
|
return {
|
|
156
165
|
initialized,
|
package/src/FormDialog.vue
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<m-form
|
|
16
16
|
v-model="stepActive"
|
|
17
17
|
ref="form"
|
|
18
|
+
:size="size"
|
|
18
19
|
:config="config"
|
|
19
20
|
:init-values="values"
|
|
20
21
|
:label-width="labelWidth"
|
|
@@ -77,6 +78,8 @@ export default defineComponent({
|
|
|
77
78
|
|
|
78
79
|
labelWidth: [Number, String],
|
|
79
80
|
|
|
81
|
+
size: String as PropType<'small' | 'default' | 'large'>,
|
|
82
|
+
|
|
80
83
|
confirmText: {
|
|
81
84
|
type: String,
|
|
82
85
|
default: '确定',
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
v-if="config"
|
|
4
|
+
:style="config.tip ? 'display: flex;align-items: baseline;' : ''"
|
|
5
|
+
:class="config.className"
|
|
6
|
+
class="m-form-container"
|
|
7
|
+
>
|
|
3
8
|
<m-fields-hidden
|
|
4
9
|
v-if="type === 'hidden'"
|
|
5
10
|
:model="model"
|
|
@@ -65,8 +70,8 @@
|
|
|
65
70
|
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
66
71
|
</el-form-item>
|
|
67
72
|
|
|
68
|
-
<el-tooltip v-if="config.tip" placement="top"
|
|
69
|
-
<
|
|
73
|
+
<el-tooltip v-if="config.tip" placement="top">
|
|
74
|
+
<el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
|
|
70
75
|
<template #content>
|
|
71
76
|
<div v-html="config.tip"></div>
|
|
72
77
|
</template>
|
|
@@ -98,6 +103,7 @@
|
|
|
98
103
|
|
|
99
104
|
<script lang="ts">
|
|
100
105
|
import { computed, defineComponent, inject, PropType, ref, resolveComponent, watchEffect } from 'vue';
|
|
106
|
+
import { WarningFilled } from '@element-plus/icons';
|
|
101
107
|
|
|
102
108
|
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
103
109
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
@@ -105,6 +111,8 @@ import { display as displayFunction, filterFunction, getRules } from '../utils/f
|
|
|
105
111
|
export default defineComponent({
|
|
106
112
|
name: 'm-form-container',
|
|
107
113
|
|
|
114
|
+
components: { WarningFilled },
|
|
115
|
+
|
|
108
116
|
props: {
|
|
109
117
|
labelWidth: String,
|
|
110
118
|
expandMore: Boolean,
|
|
@@ -224,10 +232,15 @@ export default defineComponent({
|
|
|
224
232
|
|
|
225
233
|
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
226
234
|
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
227
|
-
let value: FormValue | number | string =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
let value: FormValue | number | string = v;
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
value = filterHandler(filter, v);
|
|
239
|
+
value = (await changeHandler(onChange, value)) ?? value;
|
|
240
|
+
value = trimHandler(trim, value) ?? value;
|
|
241
|
+
} catch (e) {
|
|
242
|
+
console.error(e);
|
|
243
|
+
}
|
|
231
244
|
|
|
232
245
|
// field内容下包含field-link时,model===value, 这里避免循环引用
|
|
233
246
|
if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
|
package/src/containers/Table.vue
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
</el-table-column>
|
|
23
23
|
|
|
24
|
-
<el-table-column label="操作" width="
|
|
24
|
+
<el-table-column label="操作" width="60" :fixed="config.fixed === false ? undefined : 'left'">
|
|
25
25
|
<template v-slot="scope">
|
|
26
26
|
<el-button
|
|
27
27
|
v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</template>
|
|
34
34
|
</el-table-column>
|
|
35
35
|
|
|
36
|
-
<el-table-column v-if="sort && model[modelName] && model[modelName].length > 1" label="排序" width="
|
|
36
|
+
<el-table-column v-if="sort && model[modelName] && model[modelName].length > 1" label="排序" width="60">
|
|
37
37
|
<template v-slot="scope">
|
|
38
38
|
<el-tooltip
|
|
39
39
|
content="点击上移,双击置顶"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
width="45"
|
|
75
75
|
></el-table-column>
|
|
76
76
|
|
|
77
|
-
<el-table-column width="
|
|
77
|
+
<el-table-column width="60" label="序号">
|
|
78
78
|
<template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
|
|
79
79
|
</el-table-column>
|
|
80
80
|
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
</el-tooltip>
|
|
108
108
|
<slot></slot>
|
|
109
109
|
<el-button v-if="addable" size="small" type="primary" plain @click="newHandler()">添加</el-button>
|
|
110
|
-
<el-button icon="
|
|
110
|
+
<el-button :icon="Grid" size="small" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
|
|
111
111
|
>展开配置</el-button
|
|
112
112
|
>
|
|
113
|
-
<el-button icon="
|
|
113
|
+
<el-button :icon="FullScreen" size="small" @click="toggleFullscreen" v-if="config.enableFullscreen !== false">
|
|
114
114
|
{{ isFullscreen ? '退出全屏' : '全屏编辑' }}
|
|
115
115
|
</el-button>
|
|
116
116
|
<el-upload
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
<script lang="ts">
|
|
146
146
|
/* eslint-disable no-param-reassign */
|
|
147
147
|
import { computed, defineComponent, inject, onMounted, PropType, ref, toRefs } from 'vue';
|
|
148
|
-
import { ArrowDown, ArrowUp, Delete } from '@element-plus/icons';
|
|
148
|
+
import { ArrowDown, ArrowUp, Delete, FullScreen, Grid } from '@element-plus/icons';
|
|
149
149
|
import { ElMessage, ElTable, ElUpload } from 'element-plus';
|
|
150
150
|
import { cloneDeep } from 'lodash-es';
|
|
151
151
|
import Sortable, { SortableEvent } from 'sortablejs';
|
|
@@ -396,6 +396,8 @@ export default defineComponent({
|
|
|
396
396
|
ArrowDown,
|
|
397
397
|
ArrowUp,
|
|
398
398
|
Delete,
|
|
399
|
+
FullScreen,
|
|
400
|
+
Grid,
|
|
399
401
|
|
|
400
402
|
data: computed(() =>
|
|
401
403
|
props.model[modelName.value].filter(
|
package/src/containers/Tabs.vue
CHANGED
|
@@ -54,6 +54,10 @@ const getActive = (mForm: FormState | undefined, props: any, activeTabName: stri
|
|
|
54
54
|
|
|
55
55
|
const tabClickHandler = (mForm: FormState | undefined, tab: any, props: any) => {
|
|
56
56
|
const { config, model, prop } = props;
|
|
57
|
+
|
|
58
|
+
// 兼容vue2的element-ui
|
|
59
|
+
tab.name = tab.paneName;
|
|
60
|
+
|
|
57
61
|
if (typeof config.onTabClick === 'function') {
|
|
58
62
|
config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
|
|
59
63
|
}
|
package/src/fields/Select.vue
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
ref="select"
|
|
8
8
|
clearable
|
|
9
9
|
filterable
|
|
10
|
+
:popper-class="`m-select-popper ${popperClass}`"
|
|
10
11
|
:size="size"
|
|
11
12
|
:remote="remote"
|
|
12
13
|
:placeholder="config.placeholder"
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
:value-key="config.valueKey || 'value'"
|
|
15
16
|
:allow-create="config.allowCreate"
|
|
16
17
|
:disabled="disabled"
|
|
17
|
-
:remote-method="remoteMethod"
|
|
18
|
+
:remote-method="config.remote && remoteMethod"
|
|
18
19
|
@change="changeHandler"
|
|
19
20
|
@visible-change="visibleHandler"
|
|
20
21
|
>
|
|
@@ -288,6 +289,7 @@ export default defineComponent({
|
|
|
288
289
|
Promise.resolve(
|
|
289
290
|
props.config.options(mForm, {
|
|
290
291
|
model: props.model,
|
|
292
|
+
prop: props.prop,
|
|
291
293
|
formValues: mForm?.values,
|
|
292
294
|
formValue: mForm?.values,
|
|
293
295
|
}),
|
|
@@ -346,13 +348,12 @@ export default defineComponent({
|
|
|
346
348
|
remote,
|
|
347
349
|
options,
|
|
348
350
|
moreLoadingVisible,
|
|
351
|
+
popperClass: mForm?.popperClass,
|
|
349
352
|
|
|
350
353
|
getRequestFuc() {
|
|
351
354
|
return getConfig('request');
|
|
352
355
|
},
|
|
353
356
|
|
|
354
|
-
async getInitOption() {},
|
|
355
|
-
|
|
356
357
|
changeHandler(value: any) {
|
|
357
358
|
emit('change', value);
|
|
358
359
|
},
|
package/src/fields/Text.vue
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
<el-button
|
|
15
15
|
v-if="typeof config.append === 'object' && config.append.type === 'button'"
|
|
16
16
|
style="color: #409eff"
|
|
17
|
-
|
|
17
|
+
:size="size"
|
|
18
|
+
@click.prevent="buttonClickHandler"
|
|
18
19
|
>
|
|
19
20
|
{{ config.append.text }}
|
|
20
21
|
</el-button>
|
|
@@ -43,6 +44,8 @@ export default defineComponent({
|
|
|
43
44
|
emits: ['change', 'input'],
|
|
44
45
|
|
|
45
46
|
setup(props, { emit }) {
|
|
47
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
48
|
+
|
|
46
49
|
useAddField(props.prop);
|
|
47
50
|
|
|
48
51
|
const modelName = computed(() => props.name || props.config.name || '');
|
|
@@ -54,14 +57,11 @@ export default defineComponent({
|
|
|
54
57
|
},
|
|
55
58
|
|
|
56
59
|
inputHandler(v: string | number) {
|
|
57
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
58
60
|
emit('input', v);
|
|
59
61
|
mForm?.$emit('field-input', props.prop, v);
|
|
60
62
|
},
|
|
61
63
|
|
|
62
64
|
buttonClickHandler() {
|
|
63
|
-
const mForm = inject<FormState | undefined>('mForm');
|
|
64
|
-
|
|
65
65
|
if (typeof props.config.append === 'string') return;
|
|
66
66
|
|
|
67
67
|
if (props.config.append?.handler) {
|
package/src/schema.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export type FormState = {
|
|
23
23
|
config: FormConfig;
|
|
24
|
+
popperClass?: string;
|
|
24
25
|
initValues: FormValue;
|
|
25
26
|
values: FormValue;
|
|
26
27
|
$emit: (event: string, ...args: any[]) => void;
|
|
@@ -187,6 +188,7 @@ type SelectOptionFunction = (
|
|
|
187
188
|
mForm: FormState | undefined,
|
|
188
189
|
data: {
|
|
189
190
|
model: any;
|
|
191
|
+
prop?: string;
|
|
190
192
|
formValues: any;
|
|
191
193
|
formValue: any;
|
|
192
194
|
},
|