@tmagic/form 1.3.0-beta.2 → 1.3.0-beta.3
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 +107 -99
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +106 -98
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/containers/Table.vue +49 -43
- package/src/fields/Cascader.vue +5 -1
- package/src/schema.ts +5 -6
- package/types/schema.d.ts +5 -6
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-beta.
|
|
2
|
+
"version": "1.3.0-beta.3",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@element-plus/icons-vue": "^2.0.9",
|
|
39
|
-
"@tmagic/design": "1.3.0-beta.
|
|
40
|
-
"@tmagic/utils": "1.3.0-beta.
|
|
39
|
+
"@tmagic/design": "1.3.0-beta.3",
|
|
40
|
+
"@tmagic/utils": "1.3.0-beta.3",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
43
|
"vue": "^3.3.4"
|
package/src/containers/Table.vue
CHANGED
|
@@ -120,41 +120,46 @@
|
|
|
120
120
|
</TMagicTable>
|
|
121
121
|
</TMagicTooltip>
|
|
122
122
|
<slot></slot>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
123
|
+
|
|
124
|
+
<div style="display: flex; justify-content: space-between; margin: 10px 0">
|
|
125
|
+
<TMagicButton v-if="addable" size="small" type="primary" :disabled="disabled" plain @click="newHandler()"
|
|
126
|
+
>新增一行</TMagicButton
|
|
127
|
+
>
|
|
128
|
+
|
|
129
|
+
<div style="display: flex">
|
|
130
|
+
<TMagicButton
|
|
131
|
+
:icon="Grid"
|
|
132
|
+
size="small"
|
|
133
|
+
type="primary"
|
|
134
|
+
@click="toggleMode"
|
|
135
|
+
v-if="enableToggleMode && config.enableToggleMode !== false && !isFullscreen"
|
|
136
|
+
>展开配置</TMagicButton
|
|
137
|
+
>
|
|
138
|
+
<TMagicButton
|
|
139
|
+
:icon="FullScreen"
|
|
140
|
+
size="small"
|
|
141
|
+
type="primary"
|
|
142
|
+
@click="toggleFullscreen"
|
|
143
|
+
v-if="config.enableFullscreen !== false"
|
|
144
|
+
>
|
|
145
|
+
{{ isFullscreen ? '退出全屏' : '全屏编辑' }}
|
|
146
|
+
</TMagicButton>
|
|
147
|
+
<TMagicUpload
|
|
148
|
+
v-if="importable"
|
|
149
|
+
style="display: inline-block"
|
|
150
|
+
ref="excelBtn"
|
|
151
|
+
action="/noop"
|
|
152
|
+
:disabled="disabled"
|
|
153
|
+
:on-change="excelHandler"
|
|
154
|
+
:auto-upload="false"
|
|
155
|
+
>
|
|
156
|
+
<TMagicButton size="small" type="success" :disabled="disabled" plain>导入EXCEL</TMagicButton>
|
|
157
|
+
</TMagicUpload>
|
|
158
|
+
<TMagicButton v-if="importable" size="small" type="warning" :disabled="disabled" plain @click="clearHandler()"
|
|
159
|
+
>清空</TMagicButton
|
|
160
|
+
>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
158
163
|
|
|
159
164
|
<div class="bottom" style="text-align: right" v-if="config.pagination">
|
|
160
165
|
<TMagicPagination
|
|
@@ -244,7 +249,7 @@ const modelName = computed(() => props.name || props.config.name || '');
|
|
|
244
249
|
|
|
245
250
|
const data = computed(() =>
|
|
246
251
|
props.config.pagination
|
|
247
|
-
? props.model[modelName.value].filter(
|
|
252
|
+
? (props.model[modelName.value] || []).filter(
|
|
248
253
|
(item: any, index: number) =>
|
|
249
254
|
index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value,
|
|
250
255
|
)
|
|
@@ -253,11 +258,11 @@ const data = computed(() =>
|
|
|
253
258
|
|
|
254
259
|
const lastData = computed(() =>
|
|
255
260
|
props.config.pagination
|
|
256
|
-
? props.lastValues[modelName.value].filter(
|
|
261
|
+
? (props.lastValues[modelName.value] || []).filter(
|
|
257
262
|
(item: any, index: number) =>
|
|
258
263
|
index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value,
|
|
259
264
|
)
|
|
260
|
-
: props.lastValues[modelName.value] ||
|
|
265
|
+
: props.lastValues[modelName.value] || [],
|
|
261
266
|
);
|
|
262
267
|
|
|
263
268
|
const sortChange = ({ prop, order }: SortProp) => {
|
|
@@ -371,10 +376,6 @@ const newHandler = async (row?: any) => {
|
|
|
371
376
|
emit('change', props.model[modelName.value]);
|
|
372
377
|
};
|
|
373
378
|
|
|
374
|
-
if (!(globalThis as any).XLSX) {
|
|
375
|
-
asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js');
|
|
376
|
-
}
|
|
377
|
-
|
|
378
379
|
onMounted(() => {
|
|
379
380
|
if (props.config.defautSort) {
|
|
380
381
|
sortChange(props.config.defautSort);
|
|
@@ -535,10 +536,15 @@ const clearHandler = () => {
|
|
|
535
536
|
mForm?.$emit('field-change', props.prop, props.model[modelName.value]);
|
|
536
537
|
};
|
|
537
538
|
|
|
538
|
-
const excelHandler = (file: any) => {
|
|
539
|
+
const excelHandler = async (file: any) => {
|
|
539
540
|
if (!file?.raw) {
|
|
540
541
|
return false;
|
|
541
542
|
}
|
|
543
|
+
|
|
544
|
+
if (!(globalThis as any).XLSX) {
|
|
545
|
+
await asyncLoadJs('https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js');
|
|
546
|
+
}
|
|
547
|
+
|
|
542
548
|
const reader = new FileReader();
|
|
543
549
|
reader.onload = () => {
|
|
544
550
|
const data = reader.result;
|
package/src/fields/Cascader.vue
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
:placeholder="config.placeholder"
|
|
10
10
|
:disabled="disabled"
|
|
11
11
|
:options="options"
|
|
12
|
-
:props="{
|
|
12
|
+
:props="{
|
|
13
|
+
multiple: config.multiple ?? false,
|
|
14
|
+
emitPath: config.emitPath ?? true,
|
|
15
|
+
checkStrictly: config.checkStrictly ?? false,
|
|
16
|
+
}"
|
|
13
17
|
@change="changeHandler"
|
|
14
18
|
></TMagicCascader>
|
|
15
19
|
</template>
|
package/src/schema.ts
CHANGED
|
@@ -527,7 +527,12 @@ export interface LinkConfig extends FormItem {
|
|
|
527
527
|
export interface CascaderConfig extends FormItem, Input {
|
|
528
528
|
type: 'cascader';
|
|
529
529
|
remote?: boolean;
|
|
530
|
+
/** 在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false,则只返回该节点的值,默认 true */
|
|
531
|
+
emitPath?: boolean;
|
|
532
|
+
/** 是否多选,默认 false */
|
|
530
533
|
multiple?: boolean;
|
|
534
|
+
/** 是否严格的遵守父子节点不互相关联,默认 false */
|
|
535
|
+
checkStrictly?: boolean;
|
|
531
536
|
options?:
|
|
532
537
|
| ((
|
|
533
538
|
mForm: FormState | undefined,
|
|
@@ -545,12 +550,6 @@ export interface CascaderConfig extends FormItem, Input {
|
|
|
545
550
|
root: 'string';
|
|
546
551
|
item: (optionsData: Record<string, any>) => CascaderOption[];
|
|
547
552
|
};
|
|
548
|
-
add?: {
|
|
549
|
-
action: {
|
|
550
|
-
method: 'post' | 'get';
|
|
551
|
-
body?: Record<string, any>;
|
|
552
|
-
};
|
|
553
|
-
};
|
|
554
553
|
}
|
|
555
554
|
|
|
556
555
|
export interface DynamicFieldConfig extends FormItem {
|
package/types/schema.d.ts
CHANGED
|
@@ -427,7 +427,12 @@ export interface LinkConfig extends FormItem {
|
|
|
427
427
|
export interface CascaderConfig extends FormItem, Input {
|
|
428
428
|
type: 'cascader';
|
|
429
429
|
remote?: boolean;
|
|
430
|
+
/** 在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false,则只返回该节点的值,默认 true */
|
|
431
|
+
emitPath?: boolean;
|
|
432
|
+
/** 是否多选,默认 false */
|
|
430
433
|
multiple?: boolean;
|
|
434
|
+
/** 是否严格的遵守父子节点不互相关联,默认 false */
|
|
435
|
+
checkStrictly?: boolean;
|
|
431
436
|
options?: ((mForm: FormState | undefined, data: {
|
|
432
437
|
model: Record<any, any>;
|
|
433
438
|
formValues: Record<any, any>;
|
|
@@ -440,12 +445,6 @@ export interface CascaderConfig extends FormItem, Input {
|
|
|
440
445
|
root: 'string';
|
|
441
446
|
item: (optionsData: Record<string, any>) => CascaderOption[];
|
|
442
447
|
};
|
|
443
|
-
add?: {
|
|
444
|
-
action: {
|
|
445
|
-
method: 'post' | 'get';
|
|
446
|
-
body?: Record<string, any>;
|
|
447
|
-
};
|
|
448
|
-
};
|
|
449
448
|
}
|
|
450
449
|
export interface DynamicFieldConfig extends FormItem {
|
|
451
450
|
type: 'dynamic-field';
|