@tmagic/form 1.3.0-alpha.7 → 1.3.0-alpha.9
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 +15 -9
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +15 -9
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/fields/Select.vue +17 -9
- package/src/schema.ts +3 -3
- package/types/schema.d.ts +3 -3
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.9",
|
|
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-alpha.
|
|
40
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
39
|
+
"@tmagic/design": "1.3.0-alpha.9",
|
|
40
|
+
"@tmagic/utils": "1.3.0-alpha.9",
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
42
|
"sortablejs": "^1.14.0",
|
|
43
43
|
"vue": "^3.3.4"
|
package/src/fields/Select.vue
CHANGED
|
@@ -82,13 +82,17 @@ const equalValue = (value: any, v: any): boolean => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const mapOptions = (data: any[]) => {
|
|
85
|
-
const {
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
const {
|
|
86
|
+
option = {
|
|
87
|
+
text: 'text',
|
|
88
|
+
value: 'value',
|
|
89
|
+
},
|
|
90
|
+
} = props.config;
|
|
91
|
+
const { text = 'text', value = 'value' } = option;
|
|
88
92
|
|
|
89
93
|
return data.map((item) => ({
|
|
90
|
-
text: typeof text === 'function' ? text(item) : item[text
|
|
91
|
-
value: typeof value === 'function' ? value(item) : item[value
|
|
94
|
+
text: typeof text === 'function' ? text(item) : item[text],
|
|
95
|
+
value: typeof value === 'function' ? value(item) : item[value],
|
|
92
96
|
}));
|
|
93
97
|
};
|
|
94
98
|
|
|
@@ -103,8 +107,10 @@ const getOptions = async () => {
|
|
|
103
107
|
|
|
104
108
|
let items: SelectOption[] | SelectGroupOption[] = [];
|
|
105
109
|
|
|
106
|
-
const {
|
|
107
|
-
|
|
110
|
+
const { option } = props.config;
|
|
111
|
+
|
|
112
|
+
if (!option) return [];
|
|
113
|
+
|
|
108
114
|
const { root = '', totalKey = 'total' } = option;
|
|
109
115
|
let { body = {}, url } = option;
|
|
110
116
|
|
|
@@ -224,8 +230,10 @@ const getInitLocalOption = async () => {
|
|
|
224
230
|
const getInitOption = async () => {
|
|
225
231
|
if (!props.model) return [];
|
|
226
232
|
|
|
227
|
-
const {
|
|
228
|
-
|
|
233
|
+
const { option } = props.config;
|
|
234
|
+
|
|
235
|
+
if (!option) return [];
|
|
236
|
+
|
|
229
237
|
const { root = '', initRoot = '' } = option;
|
|
230
238
|
let { initBody = {} } = option;
|
|
231
239
|
|
package/src/schema.ts
CHANGED
|
@@ -435,9 +435,9 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
435
435
|
allowCreate?: boolean;
|
|
436
436
|
filterable?: boolean;
|
|
437
437
|
group?: boolean;
|
|
438
|
-
options
|
|
439
|
-
remote
|
|
440
|
-
option
|
|
438
|
+
options?: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
439
|
+
remote?: true;
|
|
440
|
+
option?: {
|
|
441
441
|
url: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
|
|
442
442
|
initUrl?: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
|
|
443
443
|
method?: 'jsonp' | string;
|
package/types/schema.d.ts
CHANGED
|
@@ -347,9 +347,9 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
347
347
|
allowCreate?: boolean;
|
|
348
348
|
filterable?: boolean;
|
|
349
349
|
group?: boolean;
|
|
350
|
-
options
|
|
351
|
-
remote
|
|
352
|
-
option
|
|
350
|
+
options?: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
351
|
+
remote?: true;
|
|
352
|
+
option?: {
|
|
353
353
|
url: string | ((mForm: FormState | undefined, data: {
|
|
354
354
|
model: any;
|
|
355
355
|
formValue: any;
|