@tmagic/form 1.0.0-beta.6 → 1.0.0-rc.2
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/coverage/clover.xml +1360 -0
- package/coverage/coverage-final.json +38 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Form.vue.html +676 -0
- package/coverage/lcov-report/src/FormDialog.vue.html +583 -0
- package/coverage/lcov-report/src/containers/Col.vue.html +253 -0
- package/coverage/lcov-report/src/containers/Container.vue.html +925 -0
- package/coverage/lcov-report/src/containers/Fieldset.vue.html +499 -0
- package/coverage/lcov-report/src/containers/GroupList.vue.html +541 -0
- package/coverage/lcov-report/src/containers/GroupListItem.vue.html +562 -0
- package/coverage/lcov-report/src/containers/Panel.vue.html +403 -0
- package/coverage/lcov-report/src/containers/Row.vue.html +277 -0
- package/coverage/lcov-report/src/containers/Step.vue.html +331 -0
- package/coverage/lcov-report/src/containers/Table.vue.html +1987 -0
- package/coverage/lcov-report/src/containers/Tabs.vue.html +625 -0
- package/coverage/lcov-report/src/containers/index.html +251 -0
- package/coverage/lcov-report/src/fields/Cascader.vue.html +526 -0
- package/coverage/lcov-report/src/fields/Checkbox.vue.html +286 -0
- package/coverage/lcov-report/src/fields/CheckboxGroup.vue.html +217 -0
- package/coverage/lcov-report/src/fields/ColorPicker.vue.html +199 -0
- package/coverage/lcov-report/src/fields/Date.vue.html +238 -0
- package/coverage/lcov-report/src/fields/DateTime.vue.html +262 -0
- package/coverage/lcov-report/src/fields/Daterange.vue.html +310 -0
- package/coverage/lcov-report/src/fields/Display.vue.html +187 -0
- package/coverage/lcov-report/src/fields/DynamicField.vue.html +412 -0
- package/coverage/lcov-report/src/fields/Hidden.vue.html +172 -0
- package/coverage/lcov-report/src/fields/Link.vue.html +421 -0
- package/coverage/lcov-report/src/fields/Number.vue.html +244 -0
- package/coverage/lcov-report/src/fields/RadioGroup.vue.html +184 -0
- package/coverage/lcov-report/src/fields/Select.vue.html +1243 -0
- package/coverage/lcov-report/src/fields/Switch.vue.html +280 -0
- package/coverage/lcov-report/src/fields/Text.vue.html +487 -0
- package/coverage/lcov-report/src/fields/Textarea.vue.html +265 -0
- package/coverage/lcov-report/src/fields/Time.vue.html +229 -0
- package/coverage/lcov-report/src/fields/index.html +371 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/index.ts.html +466 -0
- package/coverage/lcov-report/src/theme/index.html +116 -0
- package/coverage/lcov-report/src/theme/index.scss.html +112 -0
- package/coverage/lcov-report/src/utils/config.ts.html +166 -0
- package/coverage/lcov-report/src/utils/createForm.ts.html +160 -0
- package/coverage/lcov-report/src/utils/fieldProps.ts.html +202 -0
- package/coverage/lcov-report/src/utils/form.ts.html +895 -0
- package/coverage/lcov-report/src/utils/index.html +176 -0
- package/coverage/lcov-report/src/utils/useAddField.ts.html +205 -0
- package/coverage/lcov.info +3061 -0
- package/dist/style.css +9 -11
- package/dist/tmagic-form.es.js +188 -127
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +191 -131
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/Form.vue.d.ts +181 -120
- package/dist/types/src/FormDialog.vue.d.ts +357 -238
- package/dist/types/src/containers/Col.vue.d.ts +42 -0
- package/dist/types/src/containers/Container.vue.d.ts +1 -0
- package/dist/types/src/containers/Row.vue.d.ts +0 -1
- package/dist/types/src/containers/Table.vue.d.ts +1742 -544
- package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
- package/dist/types/src/fields/Link.vue.d.ts +710 -472
- package/dist/types/src/schema.d.ts +2 -0
- package/package.json +29 -9
- package/src/Form.vue +7 -2
- package/src/FormDialog.vue +1 -1
- package/src/containers/Col.vue +56 -0
- package/src/containers/Container.vue +28 -11
- package/src/containers/GroupListItem.vue +4 -4
- package/src/containers/Row.vue +13 -17
- package/src/containers/Table.vue +14 -6
- package/src/fields/Checkbox.vue +2 -2
- package/src/fields/Link.vue +1 -1
- package/src/fields/Select.vue +8 -15
- package/src/fields/Text.vue +4 -4
- package/src/fields/Textarea.vue +11 -13
- package/src/schema.ts +2 -0
- package/src/theme/form.scss +24 -17
- package/src/utils/form.ts +5 -1
- package/dist/types/src/fields/Cascader.vue.d.ts +0 -1748
- package/dist/types/src/fields/Select.vue.d.ts +0 -975
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -27
|
@@ -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,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-
|
|
2
|
+
"version": "1.0.0-rc.2",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
|
-
"sideEffects":
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"dist/*",
|
|
6
|
+
"src/theme/*"
|
|
7
|
+
],
|
|
5
8
|
"main": "dist/tmagic-form.umd.js",
|
|
6
9
|
"module": "dist/tmagic-form.es.js",
|
|
7
10
|
"style": "dist/style.css",
|
|
@@ -14,10 +17,14 @@
|
|
|
14
17
|
"./dist/style.css": {
|
|
15
18
|
"import": "./dist/style.css",
|
|
16
19
|
"require": "./dist/style.css"
|
|
17
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"./*": "./*"
|
|
18
22
|
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
19
24
|
"scripts": {
|
|
20
|
-
"build": "vite build"
|
|
25
|
+
"build": "vite build",
|
|
26
|
+
"test": "jest --maxWorkers=8",
|
|
27
|
+
"test:coverage": "jest --maxWorkers=16 --coverage"
|
|
21
28
|
},
|
|
22
29
|
"engines": {
|
|
23
30
|
"node": ">=14"
|
|
@@ -28,25 +35,38 @@
|
|
|
28
35
|
},
|
|
29
36
|
"dependencies": {
|
|
30
37
|
"@element-plus/icons": "0.0.11",
|
|
31
|
-
"@tmagic/utils": "^1.0.0-
|
|
32
|
-
"element-plus": "^2.0
|
|
38
|
+
"@tmagic/utils": "^1.0.0-rc.2",
|
|
39
|
+
"element-plus": "^2.2.0",
|
|
33
40
|
"lodash-es": "^4.17.21",
|
|
34
|
-
"moment": "^2.29.
|
|
41
|
+
"moment": "^2.29.2",
|
|
35
42
|
"sortablejs": "^1.14.0",
|
|
36
43
|
"vue": "^3.2.0"
|
|
37
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"element-plus": "^2.2.0",
|
|
47
|
+
"vue": "^3.2.0"
|
|
48
|
+
},
|
|
38
49
|
"devDependencies": {
|
|
50
|
+
"@babel/core": "^7.18.0",
|
|
51
|
+
"@types/jest": "^27.5.1",
|
|
39
52
|
"@types/lodash-es": "^4.17.4",
|
|
40
53
|
"@types/node": "^15.12.4",
|
|
41
54
|
"@types/sortablejs": "^1.10.7",
|
|
42
55
|
"@vitejs/plugin-vue": "^1.2.3",
|
|
43
56
|
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
|
44
57
|
"@vue/compiler-sfc": "^3.2.0",
|
|
45
|
-
"@vue/test-utils": "^2.0.0-rc.
|
|
58
|
+
"@vue/test-utils": "^2.0.0-rc.20",
|
|
59
|
+
"@vue/vue3-jest": "^27.0.0-alpha.4",
|
|
60
|
+
"babel-jest": "^27.0.6",
|
|
61
|
+
"jest": "^27.5.1",
|
|
62
|
+
"jest-serializer-vue": "^2.0.2",
|
|
63
|
+
"jest-transform-stub": "^2.0.0",
|
|
46
64
|
"sass": "^1.35.1",
|
|
65
|
+
"ts-jest": "^27.1.4",
|
|
47
66
|
"typescript": "^4.3.4",
|
|
48
67
|
"vite": "^2.3.7",
|
|
49
68
|
"vite-plugin-dts": "^0.9.6",
|
|
50
69
|
"vue-tsc": "^0.0.24"
|
|
51
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "3e309780ed33640ab3fc986a93dd0e7b15c167e5"
|
|
52
72
|
}
|
package/src/Form.vue
CHANGED
|
@@ -86,7 +86,7 @@ export default defineComponent({
|
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
size: {
|
|
89
|
-
type: String
|
|
89
|
+
type: String as PropType<'small' | 'default' | 'large'>,
|
|
90
90
|
},
|
|
91
91
|
|
|
92
92
|
inline: {
|
|
@@ -103,6 +103,10 @@ export default defineComponent({
|
|
|
103
103
|
type: String,
|
|
104
104
|
default: '__key',
|
|
105
105
|
},
|
|
106
|
+
|
|
107
|
+
popperClass: {
|
|
108
|
+
type: String,
|
|
109
|
+
},
|
|
106
110
|
},
|
|
107
111
|
|
|
108
112
|
emits: ['change', 'field-input', 'field-change'],
|
|
@@ -117,6 +121,7 @@ export default defineComponent({
|
|
|
117
121
|
|
|
118
122
|
const formState: FormState = reactive<FormState>({
|
|
119
123
|
keyProp: props.keyProp,
|
|
124
|
+
popperClass: props.popperClass,
|
|
120
125
|
config: props.config,
|
|
121
126
|
initValues: props.initValues,
|
|
122
127
|
parentValues: props.parentValues,
|
|
@@ -172,7 +177,7 @@ export default defineComponent({
|
|
|
172
177
|
submitForm: async (native?: boolean): Promise<any> => {
|
|
173
178
|
try {
|
|
174
179
|
await elForm.value?.validate();
|
|
175
|
-
return native ? values.value : cloneDeep(values.value);
|
|
180
|
+
return native ? values.value : cloneDeep(toRaw(values.value));
|
|
176
181
|
} catch (invalidFields: any) {
|
|
177
182
|
const error: string[] = [];
|
|
178
183
|
|
package/src/FormDialog.vue
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-col v-show="display && config.type !== 'hidden'" :span="span">
|
|
3
|
+
<m-form-container
|
|
4
|
+
:model="model"
|
|
5
|
+
:config="config"
|
|
6
|
+
:prop="prop"
|
|
7
|
+
:label-width="config.labelWidth || labelWidth"
|
|
8
|
+
:expand-more="expandMore"
|
|
9
|
+
:size="size"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
></m-form-container>
|
|
12
|
+
</el-col>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
17
|
+
|
|
18
|
+
import { ChildConfig, FormState } from '../schema';
|
|
19
|
+
import { display as displayFunction } from '../utils/form';
|
|
20
|
+
|
|
21
|
+
export default defineComponent({
|
|
22
|
+
props: {
|
|
23
|
+
labelWidth: String,
|
|
24
|
+
expandMore: Boolean,
|
|
25
|
+
span: Number,
|
|
26
|
+
|
|
27
|
+
model: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => ({}),
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
config: {
|
|
33
|
+
type: Object as PropType<ChildConfig>,
|
|
34
|
+
default: () => ({}),
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
prop: String,
|
|
38
|
+
|
|
39
|
+
size: String,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
emits: ['change'],
|
|
43
|
+
|
|
44
|
+
setup(props, { emit }) {
|
|
45
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
46
|
+
|
|
47
|
+
const changeHandler = () => emit('change', props.model);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
mForm,
|
|
51
|
+
display: computed(() => displayFunction(mForm, props.config.display, props)),
|
|
52
|
+
changeHandler,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
@@ -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"
|
|
@@ -20,15 +25,16 @@
|
|
|
20
25
|
:prop="itemProp"
|
|
21
26
|
:step-active="stepActive"
|
|
22
27
|
:expand-more="expand"
|
|
23
|
-
:label-width="
|
|
28
|
+
:label-width="itemLabelWidth"
|
|
24
29
|
@change="onChangeHandler"
|
|
25
30
|
></component>
|
|
26
31
|
|
|
27
32
|
<template v-else-if="type && display">
|
|
28
33
|
<el-form-item
|
|
29
34
|
:style="config.tip ? 'flex: 1' : ''"
|
|
35
|
+
:class="{ hidden: itemLabelWidth === 0 || !config.text }"
|
|
30
36
|
:prop="itemProp"
|
|
31
|
-
:label-width="
|
|
37
|
+
:label-width="itemLabelWidth"
|
|
32
38
|
:rules="rule"
|
|
33
39
|
>
|
|
34
40
|
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
@@ -65,8 +71,8 @@
|
|
|
65
71
|
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
66
72
|
</el-form-item>
|
|
67
73
|
|
|
68
|
-
<el-tooltip v-if="config.tip" placement="
|
|
69
|
-
<
|
|
74
|
+
<el-tooltip v-if="config.tip" placement="left">
|
|
75
|
+
<el-icon style="line-height: 40px; margin-left: 5px"><warning-filled /></el-icon>
|
|
70
76
|
<template #content>
|
|
71
77
|
<div v-html="config.tip"></div>
|
|
72
78
|
</template>
|
|
@@ -83,7 +89,7 @@
|
|
|
83
89
|
:size="size"
|
|
84
90
|
:step-active="stepActive"
|
|
85
91
|
:expand-more="expand"
|
|
86
|
-
:label-width="
|
|
92
|
+
:label-width="itemLabelWidth"
|
|
87
93
|
:prop="itemProp"
|
|
88
94
|
@change="onChangeHandler"
|
|
89
95
|
></m-form-container>
|
|
@@ -91,13 +97,14 @@
|
|
|
91
97
|
</template>
|
|
92
98
|
|
|
93
99
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
|
94
|
-
<el-button
|
|
100
|
+
<el-button text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</el-button>
|
|
95
101
|
</div>
|
|
96
102
|
</div>
|
|
97
103
|
</template>
|
|
98
104
|
|
|
99
105
|
<script lang="ts">
|
|
100
106
|
import { computed, defineComponent, inject, PropType, ref, resolveComponent, watchEffect } from 'vue';
|
|
107
|
+
import { WarningFilled } from '@element-plus/icons';
|
|
101
108
|
|
|
102
109
|
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
103
110
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
@@ -105,6 +112,8 @@ import { display as displayFunction, filterFunction, getRules } from '../utils/f
|
|
|
105
112
|
export default defineComponent({
|
|
106
113
|
name: 'm-form-container',
|
|
107
114
|
|
|
115
|
+
components: { WarningFilled },
|
|
116
|
+
|
|
108
117
|
props: {
|
|
109
118
|
labelWidth: String,
|
|
110
119
|
expandMore: Boolean,
|
|
@@ -180,6 +189,8 @@ export default defineComponent({
|
|
|
180
189
|
return displayFunction(mForm, props.config.display, props);
|
|
181
190
|
});
|
|
182
191
|
|
|
192
|
+
const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
|
|
193
|
+
|
|
183
194
|
watchEffect(() => {
|
|
184
195
|
expand.value = props.expandMore;
|
|
185
196
|
});
|
|
@@ -224,10 +235,15 @@ export default defineComponent({
|
|
|
224
235
|
|
|
225
236
|
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
226
237
|
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
227
|
-
let value: FormValue | number | string =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
let value: FormValue | number | string = v;
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
value = filterHandler(filter, v);
|
|
242
|
+
value = (await changeHandler(onChange, value)) ?? value;
|
|
243
|
+
value = trimHandler(trim, value) ?? value;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
console.error(e);
|
|
246
|
+
}
|
|
231
247
|
|
|
232
248
|
// field内容下包含field-link时,model===value, 这里避免循环引用
|
|
233
249
|
if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
|
|
@@ -250,6 +266,7 @@ export default defineComponent({
|
|
|
250
266
|
itemProp,
|
|
251
267
|
items,
|
|
252
268
|
display,
|
|
269
|
+
itemLabelWidth,
|
|
253
270
|
tagName,
|
|
254
271
|
rule,
|
|
255
272
|
tooltip,
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
><caret-bottom v-if="expand" /><caret-right v-else
|
|
6
6
|
/></el-icon>
|
|
7
7
|
|
|
8
|
-
<el-button
|
|
8
|
+
<el-button text @click="expandHandler">{{ title }}</el-button>
|
|
9
9
|
|
|
10
10
|
<el-button
|
|
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
|
></el-button>
|
|
17
17
|
|
|
18
18
|
<template v-if="movable()">
|
|
19
|
-
<el-button v-show="index !== 0"
|
|
19
|
+
<el-button v-show="index !== 0" text size="small" @click="changeOrder(-1)"
|
|
20
20
|
>上移<el-icon><CaretRight /></el-icon
|
|
21
21
|
></el-button>
|
|
22
|
-
<el-button v-show="index !== length - 1"
|
|
22
|
+
<el-button v-show="index !== length - 1" text size="small" @click="changeOrder(1)"
|
|
23
23
|
>下移<el-icon><CaretBottom /></el-icon
|
|
24
24
|
></el-button>
|
|
25
25
|
</template>
|
package/src/containers/Row.vue
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-row :gutter="10">
|
|
3
|
-
<
|
|
3
|
+
<Col
|
|
4
4
|
v-for="(col, index) in config.items"
|
|
5
|
-
:style="!display(col) || col.type === 'hidden' ? 'display: none' : ''"
|
|
6
5
|
:key="col[mForm?.keyProp || '__key'] ?? index"
|
|
7
6
|
:span="col.span || config.span || 24 / config.items.length"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@change="changeHandler"
|
|
17
|
-
></m-form-container>
|
|
18
|
-
</el-col>
|
|
7
|
+
:config="col"
|
|
8
|
+
:labelWidth="config.labelWidth || labelWidth"
|
|
9
|
+
:expandMore="expandMore"
|
|
10
|
+
:model="name ? model[name] : model"
|
|
11
|
+
:prop="prop"
|
|
12
|
+
:size="size"
|
|
13
|
+
@change="changeHandler"
|
|
14
|
+
/>
|
|
19
15
|
</el-row>
|
|
20
16
|
</template>
|
|
21
17
|
|
|
@@ -23,11 +19,14 @@
|
|
|
23
19
|
import { defineComponent, inject, PropType } from 'vue';
|
|
24
20
|
|
|
25
21
|
import { FormState, RowConfig } from '../schema';
|
|
26
|
-
|
|
22
|
+
|
|
23
|
+
import Col from './Col.vue';
|
|
27
24
|
|
|
28
25
|
export default defineComponent({
|
|
29
26
|
name: 'm-form-row',
|
|
30
27
|
|
|
28
|
+
components: { Col },
|
|
29
|
+
|
|
31
30
|
props: {
|
|
32
31
|
labelWidth: String,
|
|
33
32
|
expandMore: Boolean,
|
|
@@ -58,9 +57,6 @@ export default defineComponent({
|
|
|
58
57
|
|
|
59
58
|
return {
|
|
60
59
|
mForm,
|
|
61
|
-
display(config: any) {
|
|
62
|
-
return displayFunction(mForm, config.display, props);
|
|
63
|
-
},
|
|
64
60
|
changeHandler,
|
|
65
61
|
};
|
|
66
62
|
},
|
package/src/containers/Table.vue
CHANGED
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
<template v-slot="scope">
|
|
26
26
|
<el-button
|
|
27
27
|
v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
type="danger"
|
|
29
|
+
text
|
|
30
30
|
:icon="Delete"
|
|
31
31
|
@click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
32
32
|
></el-button>
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
<el-button
|
|
44
44
|
plain
|
|
45
45
|
size="small"
|
|
46
|
+
type="primary"
|
|
46
47
|
:icon="ArrowUp"
|
|
47
|
-
|
|
48
|
+
text
|
|
48
49
|
@click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
49
50
|
@dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
50
51
|
></el-button>
|
|
@@ -57,8 +58,9 @@
|
|
|
57
58
|
<el-button
|
|
58
59
|
plain
|
|
59
60
|
size="small"
|
|
61
|
+
type="primary"
|
|
60
62
|
:icon="ArrowDown"
|
|
61
|
-
|
|
63
|
+
text
|
|
62
64
|
@click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
63
65
|
@dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
64
66
|
></el-button>
|
|
@@ -107,10 +109,16 @@
|
|
|
107
109
|
</el-tooltip>
|
|
108
110
|
<slot></slot>
|
|
109
111
|
<el-button v-if="addable" size="small" type="primary" plain @click="newHandler()">添加</el-button>
|
|
110
|
-
<el-button :icon="Grid" size="small" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
|
|
112
|
+
<el-button :icon="Grid" size="small" type="primary" @click="toggleMode" v-if="enableToggleMode && !isFullscreen"
|
|
111
113
|
>展开配置</el-button
|
|
112
114
|
>
|
|
113
|
-
<el-button
|
|
115
|
+
<el-button
|
|
116
|
+
:icon="FullScreen"
|
|
117
|
+
size="small"
|
|
118
|
+
type="primary"
|
|
119
|
+
@click="toggleFullscreen"
|
|
120
|
+
v-if="config.enableFullscreen !== false"
|
|
121
|
+
>
|
|
114
122
|
{{ isFullscreen ? '退出全屏' : '全屏编辑' }}
|
|
115
123
|
</el-button>
|
|
116
124
|
<el-upload
|
package/src/fields/Checkbox.vue
CHANGED
|
@@ -43,7 +43,7 @@ export default defineComponent({
|
|
|
43
43
|
return props.config.activeValue;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
return
|
|
46
|
+
return undefined;
|
|
47
47
|
}),
|
|
48
48
|
|
|
49
49
|
inactiveValue: computed(() => {
|
|
@@ -55,7 +55,7 @@ export default defineComponent({
|
|
|
55
55
|
return props.config.inactiveValue;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
return
|
|
58
|
+
return undefined;
|
|
59
59
|
}),
|
|
60
60
|
|
|
61
61
|
changeHandler(value: number | boolean) {
|
package/src/fields/Link.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
|
|
3
3
|
<span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
|
|
4
4
|
<div v-else class="m-fields-link">
|
|
5
|
-
<el-button type="
|
|
5
|
+
<el-button text type="primary" @click="editHandler">点击编辑</el-button>
|
|
6
6
|
<m-form-dialog
|
|
7
7
|
ref="editor"
|
|
8
8
|
:title="config.formTitle || '编辑扩展配置'"
|
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,20 +15,15 @@
|
|
|
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
|
>
|
|
21
22
|
<template v-if="config.group">
|
|
22
|
-
<el-option-group
|
|
23
|
-
v-for="(group, index) in options"
|
|
24
|
-
:key="group.label + index"
|
|
25
|
-
:label="group.label"
|
|
26
|
-
:disabled="group.disabled"
|
|
27
|
-
>
|
|
23
|
+
<el-option-group v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
|
28
24
|
<el-option
|
|
29
25
|
v-for="(item, index) in group.options"
|
|
30
|
-
:key="
|
|
26
|
+
:key="index"
|
|
31
27
|
:label="item.label"
|
|
32
28
|
:value="item.value"
|
|
33
29
|
:disabled="item.disabled"
|
|
@@ -288,6 +284,7 @@ export default defineComponent({
|
|
|
288
284
|
Promise.resolve(
|
|
289
285
|
props.config.options(mForm, {
|
|
290
286
|
model: props.model,
|
|
287
|
+
prop: props.prop,
|
|
291
288
|
formValues: mForm?.values,
|
|
292
289
|
formValue: mForm?.values,
|
|
293
290
|
}),
|
|
@@ -346,13 +343,14 @@ export default defineComponent({
|
|
|
346
343
|
remote,
|
|
347
344
|
options,
|
|
348
345
|
moreLoadingVisible,
|
|
346
|
+
popperClass: mForm?.popperClass,
|
|
347
|
+
|
|
348
|
+
getOptions,
|
|
349
349
|
|
|
350
350
|
getRequestFuc() {
|
|
351
351
|
return getConfig('request');
|
|
352
352
|
},
|
|
353
353
|
|
|
354
|
-
async getInitOption() {},
|
|
355
|
-
|
|
356
354
|
changeHandler(value: any) {
|
|
357
355
|
emit('change', value);
|
|
358
356
|
},
|
|
@@ -370,11 +368,6 @@ export default defineComponent({
|
|
|
370
368
|
}
|
|
371
369
|
},
|
|
372
370
|
|
|
373
|
-
async editAfterAction() {
|
|
374
|
-
pgIndex.value = 0;
|
|
375
|
-
options.value = await getOptions();
|
|
376
|
-
},
|
|
377
|
-
|
|
378
371
|
async remoteMethod(q: string) {
|
|
379
372
|
if (!localOptions.value.length) {
|
|
380
373
|
query.value = q;
|
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/fields/Textarea.vue
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</el-input>
|
|
14
|
-
</div>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model="model[name]"
|
|
4
|
+
type="textarea"
|
|
5
|
+
:size="size"
|
|
6
|
+
clearable
|
|
7
|
+
:placeholder="config.placeholder"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
@change="changeHandler"
|
|
10
|
+
@input="inputHandler"
|
|
11
|
+
>
|
|
12
|
+
</el-input>
|
|
15
13
|
</template>
|
|
16
14
|
|
|
17
15
|
<script lang="ts">
|
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
|
},
|
package/src/theme/form.scss
CHANGED
|
@@ -2,29 +2,36 @@
|
|
|
2
2
|
.fade-leave-active {
|
|
3
3
|
transition: opacity 0.5s;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
|
|
6
7
|
opacity: 0;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
.m-form
|
|
10
|
-
.m-form-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
.m-form {
|
|
11
|
+
.m-form-tip {
|
|
12
|
+
color: rgba(0, 0, 0, 0.45);
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
transition: color 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
.m-form
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
.m-form-schematic {
|
|
18
|
+
max-width: 50%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
22
|
+
.el-table {
|
|
23
|
+
.cell > div.m-form-container {
|
|
24
|
+
display: block;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.el-tabs {
|
|
29
|
+
margin-bottom: 10px;
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
.el-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
.el-form-item.hidden {
|
|
33
|
+
.el-form-item__label {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|