@tmagic/form 1.1.4 → 1.1.6
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 +4 -0
- package/dist/tmagic-form.mjs +296 -226
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +294 -224
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/FormDialog.vue +53 -48
- package/src/containers/GroupList.vue +3 -3
- package/src/containers/Table.vue +18 -22
- package/src/index.ts +1 -1
- package/src/schema.ts +12 -1
- package/src/theme/table.scss +5 -0
- package/types/FormDialog.vue.d.ts +6 -0
- package/types/containers/GroupList.vue.d.ts +1 -0
- package/types/containers/Table.vue.d.ts +9 -0
- package/types/fields/Link.vue.d.ts +9 -0
- package/types/schema.d.ts +12 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
2
|
+
"version": "1.1.6",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@element-plus/icons-vue": "^2.0.9",
|
|
38
|
-
"@tmagic/utils": "1.1.
|
|
39
|
-
"element-plus": "^2.2.
|
|
38
|
+
"@tmagic/utils": "1.1.6",
|
|
39
|
+
"element-plus": "^2.2.17",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
41
|
"sortablejs": "^1.14.0",
|
|
42
42
|
"vue": "^3.2.37"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"element-plus": "^2.2.
|
|
45
|
+
"element-plus": "^2.2.17",
|
|
46
46
|
"vue": "^3.2.37"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -50,13 +50,13 @@
|
|
|
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": "^3.0
|
|
53
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
54
54
|
"@vue/compiler-sfc": "^3.2.37",
|
|
55
55
|
"@vue/test-utils": "^2.0.0",
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"sass": "^1.35.1",
|
|
58
58
|
"typescript": "^4.7.4",
|
|
59
|
-
"vite": "^3.
|
|
59
|
+
"vite": "^3.1.3",
|
|
60
60
|
"vue-tsc": "^0.39.4"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/src/FormDialog.vue
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
2
|
+
<teleport to="body">
|
|
3
|
+
<div class="m-form-dialog" v-show="dialogVisible">
|
|
4
|
+
<el-dialog
|
|
5
|
+
v-model="dialogVisible"
|
|
6
|
+
top="20px"
|
|
7
|
+
:title="title"
|
|
8
|
+
:width="width"
|
|
9
|
+
:fullscreen="fullscreen"
|
|
10
|
+
:close-on-click-modal="false"
|
|
11
|
+
@close="closeHandler"
|
|
12
|
+
>
|
|
13
|
+
<div class="m-dialog-body" :style="`max-height: ${bodyHeight}; overflow-y: auto; overflow-x: hidden;`">
|
|
14
|
+
<m-form
|
|
15
|
+
v-model="stepActive"
|
|
16
|
+
ref="form"
|
|
17
|
+
:size="size"
|
|
18
|
+
:config="config"
|
|
19
|
+
:init-values="values"
|
|
20
|
+
:parent-values="parentValues"
|
|
21
|
+
:label-width="labelWidth"
|
|
22
|
+
@change="changeHandler"
|
|
23
|
+
></m-form>
|
|
24
|
+
<slot></slot>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<template #footer>
|
|
28
|
+
<el-row class="dialog-footer">
|
|
29
|
+
<el-col :span="12" style="text-align: left">
|
|
30
|
+
<div style="min-height: 1px">
|
|
31
|
+
<slot name="left"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
</el-col>
|
|
34
|
+
<el-col :span="12">
|
|
35
|
+
<slot name="footer">
|
|
36
|
+
<el-button @click="cancel" size="small">取 消</el-button>
|
|
37
|
+
<el-button v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep">上一步</el-button>
|
|
38
|
+
<el-button v-if="hasStep && stepCount > stepActive" type="info" size="small" @click="nextStep"
|
|
39
|
+
>下一步</el-button
|
|
40
|
+
>
|
|
41
|
+
<el-button v-else type="primary" size="small" :loading="saveFetch" @click="save">{{
|
|
42
|
+
confirmText
|
|
43
|
+
}}</el-button>
|
|
44
|
+
</slot>
|
|
45
|
+
</el-col>
|
|
46
|
+
</el-row>
|
|
47
|
+
</template>
|
|
48
|
+
</el-dialog>
|
|
49
|
+
</div>
|
|
50
|
+
</teleport>
|
|
50
51
|
</template>
|
|
51
52
|
|
|
52
53
|
<script lang="ts">
|
|
@@ -64,6 +65,10 @@ export default defineComponent({
|
|
|
64
65
|
default: () => ({}),
|
|
65
66
|
},
|
|
66
67
|
|
|
68
|
+
parentValues: {
|
|
69
|
+
type: Object,
|
|
70
|
+
},
|
|
71
|
+
|
|
67
72
|
width: [Number, String],
|
|
68
73
|
|
|
69
74
|
fullscreen: Boolean,
|
|
@@ -23,14 +23,13 @@
|
|
|
23
23
|
|
|
24
24
|
<el-button @click="addHandler" size="small" v-if="addable">添加组</el-button>
|
|
25
25
|
|
|
26
|
-
<el-button icon="
|
|
27
|
-
>切换为表格</el-button
|
|
28
|
-
>
|
|
26
|
+
<el-button :icon="Grid" size="small" @click="toggleMode" v-if="config.enableToggleMode">切换为表格</el-button>
|
|
29
27
|
</div>
|
|
30
28
|
</template>
|
|
31
29
|
|
|
32
30
|
<script lang="ts">
|
|
33
31
|
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
32
|
+
import { Grid } from '@element-plus/icons-vue';
|
|
34
33
|
|
|
35
34
|
import { FormState, GroupListConfig } from '../schema';
|
|
36
35
|
import { initValue } from '../utils/form';
|
|
@@ -144,6 +143,7 @@ export default defineComponent({
|
|
|
144
143
|
}))) as any;
|
|
145
144
|
};
|
|
146
145
|
return {
|
|
146
|
+
Grid,
|
|
147
147
|
addable,
|
|
148
148
|
toggleMode,
|
|
149
149
|
removeHandler,
|
package/src/containers/Table.vue
CHANGED
|
@@ -21,15 +21,14 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
</el-table-column>
|
|
23
23
|
|
|
24
|
-
<el-table-column label="操作" width="
|
|
24
|
+
<el-table-column label="操作" width="55" align="center" :fixed="config.fixed === false ? undefined : 'left'">
|
|
25
25
|
<template v-slot="scope">
|
|
26
|
-
<el-
|
|
26
|
+
<el-icon
|
|
27
27
|
v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
28
|
-
|
|
29
|
-
text
|
|
30
|
-
:icon="Delete"
|
|
28
|
+
class="m-table-delete-icon"
|
|
31
29
|
@click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
|
|
32
|
-
|
|
30
|
+
><Delete
|
|
31
|
+
/></el-icon>
|
|
33
32
|
</template>
|
|
34
33
|
</el-table-column>
|
|
35
34
|
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
width="45"
|
|
77
76
|
></el-table-column>
|
|
78
77
|
|
|
79
|
-
<el-table-column width="60" label="序号">
|
|
78
|
+
<el-table-column width="60" label="序号" v-if="showIndex && config.showIndex">
|
|
80
79
|
<template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
|
|
81
80
|
</el-table-column>
|
|
82
81
|
|
|
@@ -163,12 +162,7 @@ import { asyncLoadJs, sleep } from '@tmagic/utils';
|
|
|
163
162
|
import { ColumnConfig, FormState, SortProp, TableConfig } from '../schema';
|
|
164
163
|
import { display, initValue } from '../utils/form';
|
|
165
164
|
|
|
166
|
-
let loadedAMapJS = false; // 是否加载完js
|
|
167
|
-
let firstLoadingAMapJS = true; // 否是第一次请求
|
|
168
|
-
|
|
169
165
|
export default defineComponent({
|
|
170
|
-
name: 'm-form-table',
|
|
171
|
-
|
|
172
166
|
props: {
|
|
173
167
|
name: {
|
|
174
168
|
type: String,
|
|
@@ -215,12 +209,19 @@ export default defineComponent({
|
|
|
215
209
|
type: Boolean,
|
|
216
210
|
default: true,
|
|
217
211
|
},
|
|
212
|
+
|
|
213
|
+
showIndex: {
|
|
214
|
+
type: Boolean,
|
|
215
|
+
default: true,
|
|
216
|
+
},
|
|
218
217
|
},
|
|
219
218
|
|
|
220
219
|
emits: ['change', 'select'],
|
|
221
220
|
|
|
221
|
+
components: { Delete },
|
|
222
|
+
|
|
222
223
|
setup(props, { emit }) {
|
|
223
|
-
let timer:
|
|
224
|
+
let timer: any | null = null;
|
|
224
225
|
const mForm = inject<FormState | undefined>('mForm');
|
|
225
226
|
|
|
226
227
|
const elTable = ref<any>();
|
|
@@ -348,20 +349,15 @@ export default defineComponent({
|
|
|
348
349
|
emit('change', props.model[modelName.value]);
|
|
349
350
|
};
|
|
350
351
|
|
|
351
|
-
if (!
|
|
352
|
-
|
|
353
|
-
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js')
|
|
354
|
-
.then(() => {
|
|
355
|
-
loadedAMapJS = true;
|
|
356
|
-
})
|
|
357
|
-
.catch(() => {
|
|
358
|
-
firstLoadingAMapJS = true; // 出错置为true 下次进来还是能重新请求js
|
|
359
|
-
});
|
|
352
|
+
if (!(globalThis as any).XLSX) {
|
|
353
|
+
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js');
|
|
360
354
|
}
|
|
361
355
|
|
|
362
356
|
onMounted(() => {
|
|
363
357
|
if (props.config.defautSort) {
|
|
364
358
|
sortChange(props.config.defautSort);
|
|
359
|
+
} else if (props.config.defaultSort) {
|
|
360
|
+
sortChange(props.config.defaultSort);
|
|
365
361
|
}
|
|
366
362
|
|
|
367
363
|
if (props.sort && props.sortKey) {
|
package/src/index.ts
CHANGED
|
@@ -100,7 +100,7 @@ const install = (app: App, opt: any) => {
|
|
|
100
100
|
app.component(Panel.name, Panel);
|
|
101
101
|
app.component(Row.name, Row);
|
|
102
102
|
app.component(MStep.name, MStep);
|
|
103
|
-
app.component(
|
|
103
|
+
app.component('m-form-table', Table);
|
|
104
104
|
app.component(Tabs.name, Tabs);
|
|
105
105
|
app.component(Text.name, Text);
|
|
106
106
|
app.component(Number.name, Number);
|
package/src/schema.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface ContainerCommonConfig {
|
|
|
97
97
|
export interface Rule {
|
|
98
98
|
message?: string;
|
|
99
99
|
/** 系统提供的验证器类型。有:string,number,boolean,method,regexp,integer,float,array,object,enum,date,url,hex,email,any */
|
|
100
|
-
type
|
|
100
|
+
type?: string;
|
|
101
101
|
/** 是否必填 */
|
|
102
102
|
required?: boolean;
|
|
103
103
|
/** 自定义验证器 */
|
|
@@ -570,18 +570,29 @@ export interface TableConfig extends FormItem {
|
|
|
570
570
|
tableItems?: ColumnConfig[];
|
|
571
571
|
groupItems?: ColumnConfig[];
|
|
572
572
|
enableToggleMode?: boolean;
|
|
573
|
+
/** 最大行数 */
|
|
573
574
|
max?: number;
|
|
575
|
+
/** 最大高度 */
|
|
574
576
|
maxHeight?: number | string;
|
|
575
577
|
border?: boolean;
|
|
578
|
+
/** 显示行号 */
|
|
579
|
+
showIndex?: boolean;
|
|
576
580
|
enum?: any[];
|
|
581
|
+
/** 是否显示添加按钮 */
|
|
577
582
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
583
|
+
/** 是否显示删除按钮 */
|
|
578
584
|
delete?: (model: any, index: number, values: any) => boolean | boolean;
|
|
585
|
+
/** 是否显示导入按钮 */
|
|
579
586
|
importable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
587
|
+
/** 是否显示checkbox */
|
|
580
588
|
selection?: (mForm: FormState | undefined, data: any) => boolean | boolean | 'single';
|
|
589
|
+
/** 新增的默认行 */
|
|
581
590
|
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
|
582
591
|
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
|
583
592
|
defautSort?: SortProp;
|
|
593
|
+
defaultSort?: SortProp;
|
|
584
594
|
dropSort?: boolean;
|
|
595
|
+
/** 是否显示全屏按钮 */
|
|
585
596
|
enableFullscreen?: boolean;
|
|
586
597
|
fixed?: boolean;
|
|
587
598
|
itemExtra?: string | FilterFunction;
|
package/src/theme/table.scss
CHANGED
|
@@ -5,6 +5,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
5
5
|
type: ObjectConstructor;
|
|
6
6
|
default: () => {};
|
|
7
7
|
};
|
|
8
|
+
parentValues: {
|
|
9
|
+
type: ObjectConstructor;
|
|
10
|
+
};
|
|
8
11
|
width: (NumberConstructor | StringConstructor)[];
|
|
9
12
|
fullscreen: BooleanConstructor;
|
|
10
13
|
title: StringConstructor;
|
|
@@ -272,6 +275,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
272
275
|
type: ObjectConstructor;
|
|
273
276
|
default: () => {};
|
|
274
277
|
};
|
|
278
|
+
parentValues: {
|
|
279
|
+
type: ObjectConstructor;
|
|
280
|
+
};
|
|
275
281
|
width: (NumberConstructor | StringConstructor)[];
|
|
276
282
|
fullscreen: BooleanConstructor;
|
|
277
283
|
title: StringConstructor;
|
|
@@ -20,6 +20,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
20
20
|
default: string;
|
|
21
21
|
};
|
|
22
22
|
}, {
|
|
23
|
+
Grid: import("vue").DefineComponent<{}, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
23
24
|
addable: import("vue").ComputedRef<boolean | "undefined">;
|
|
24
25
|
toggleMode: () => void;
|
|
25
26
|
removeHandler: (index: number) => false | undefined;
|
|
@@ -38,6 +38,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
38
38
|
type: BooleanConstructor;
|
|
39
39
|
default: boolean;
|
|
40
40
|
};
|
|
41
|
+
showIndex: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
41
45
|
}, {
|
|
42
46
|
mForm: FormState | undefined;
|
|
43
47
|
pagesize: import("vue").Ref<number>;
|
|
@@ -115,6 +119,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
115
119
|
type: BooleanConstructor;
|
|
116
120
|
default: boolean;
|
|
117
121
|
};
|
|
122
|
+
showIndex: {
|
|
123
|
+
type: BooleanConstructor;
|
|
124
|
+
default: boolean;
|
|
125
|
+
};
|
|
118
126
|
}>> & {
|
|
119
127
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
120
128
|
onSelect?: ((...args: any[]) => any) | undefined;
|
|
@@ -122,6 +130,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
122
130
|
config: TableConfig;
|
|
123
131
|
enableToggleMode: boolean;
|
|
124
132
|
sort: boolean;
|
|
133
|
+
showIndex: boolean;
|
|
125
134
|
model: Record<string, any>;
|
|
126
135
|
sortKey: string;
|
|
127
136
|
}>;
|
|
@@ -37,6 +37,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
37
37
|
type: ObjectConstructor;
|
|
38
38
|
default: () => {};
|
|
39
39
|
};
|
|
40
|
+
parentValues: {
|
|
41
|
+
type: ObjectConstructor;
|
|
42
|
+
};
|
|
40
43
|
width: (NumberConstructor | StringConstructor)[];
|
|
41
44
|
fullscreen: BooleanConstructor;
|
|
42
45
|
title: StringConstructor;
|
|
@@ -75,6 +78,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
75
78
|
type: ObjectConstructor;
|
|
76
79
|
default: () => {};
|
|
77
80
|
};
|
|
81
|
+
parentValues: {
|
|
82
|
+
type: ObjectConstructor;
|
|
83
|
+
};
|
|
78
84
|
width: (NumberConstructor | StringConstructor)[];
|
|
79
85
|
fullscreen: BooleanConstructor;
|
|
80
86
|
title: StringConstructor;
|
|
@@ -372,6 +378,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
372
378
|
type: ObjectConstructor;
|
|
373
379
|
default: () => {};
|
|
374
380
|
};
|
|
381
|
+
parentValues: {
|
|
382
|
+
type: ObjectConstructor;
|
|
383
|
+
};
|
|
375
384
|
width: (NumberConstructor | StringConstructor)[];
|
|
376
385
|
fullscreen: BooleanConstructor;
|
|
377
386
|
title: StringConstructor;
|
package/types/schema.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export interface ContainerCommonConfig {
|
|
|
71
71
|
export interface Rule {
|
|
72
72
|
message?: string;
|
|
73
73
|
/** 系统提供的验证器类型。有:string,number,boolean,method,regexp,integer,float,array,object,enum,date,url,hex,email,any */
|
|
74
|
-
type
|
|
74
|
+
type?: string;
|
|
75
75
|
/** 是否必填 */
|
|
76
76
|
required?: boolean;
|
|
77
77
|
/** 自定义验证器 */
|
|
@@ -462,18 +462,29 @@ export interface TableConfig extends FormItem {
|
|
|
462
462
|
tableItems?: ColumnConfig[];
|
|
463
463
|
groupItems?: ColumnConfig[];
|
|
464
464
|
enableToggleMode?: boolean;
|
|
465
|
+
/** 最大行数 */
|
|
465
466
|
max?: number;
|
|
467
|
+
/** 最大高度 */
|
|
466
468
|
maxHeight?: number | string;
|
|
467
469
|
border?: boolean;
|
|
470
|
+
/** 显示行号 */
|
|
471
|
+
showIndex?: boolean;
|
|
468
472
|
enum?: any[];
|
|
473
|
+
/** 是否显示添加按钮 */
|
|
469
474
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
475
|
+
/** 是否显示删除按钮 */
|
|
470
476
|
delete?: (model: any, index: number, values: any) => boolean | boolean;
|
|
477
|
+
/** 是否显示导入按钮 */
|
|
471
478
|
importable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
479
|
+
/** 是否显示checkbox */
|
|
472
480
|
selection?: (mForm: FormState | undefined, data: any) => boolean | boolean | 'single';
|
|
481
|
+
/** 新增的默认行 */
|
|
473
482
|
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
|
474
483
|
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
|
475
484
|
defautSort?: SortProp;
|
|
485
|
+
defaultSort?: SortProp;
|
|
476
486
|
dropSort?: boolean;
|
|
487
|
+
/** 是否显示全屏按钮 */
|
|
477
488
|
enableFullscreen?: boolean;
|
|
478
489
|
fixed?: boolean;
|
|
479
490
|
itemExtra?: string | FilterFunction;
|