@tmagic/form 1.2.0-beta.22 → 1.2.0-beta.24
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 +54 -25
- package/dist/tmagic-form.js.map +1 -1
- package/dist/tmagic-form.umd.cjs +54 -25
- package/dist/tmagic-form.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/containers/Container.vue +1 -3
- package/src/fields/Select.vue +61 -22
- package/src/schema.ts +13 -4
- package/types/schema.d.ts +12 -4
package/dist/tmagic-form.js
CHANGED
|
@@ -215,9 +215,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
215
215
|
return component;
|
|
216
216
|
return "m-fields-text";
|
|
217
217
|
});
|
|
218
|
-
const disabled = computed(
|
|
219
|
-
() => typeof props.disabled === "undefined" ? filterFunction(mForm, props.config.disabled, props) : props.disabled
|
|
220
|
-
);
|
|
218
|
+
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
221
219
|
const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
222
220
|
const extra = computed(() => filterFunction(mForm, props.config.extra, props));
|
|
223
221
|
const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
@@ -3117,30 +3115,32 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3117
3115
|
let items = [];
|
|
3118
3116
|
const { config } = props;
|
|
3119
3117
|
const { option } = config;
|
|
3120
|
-
|
|
3118
|
+
const { root = "", totalKey = "total" } = option;
|
|
3119
|
+
let { body = {}, url } = option;
|
|
3120
|
+
if (typeof url === "function") {
|
|
3121
|
+
url = await url(mForm, { model: props.model, formValue: mForm?.values });
|
|
3122
|
+
}
|
|
3121
3123
|
let postOptions = {
|
|
3122
3124
|
method: option.method || "POST",
|
|
3123
|
-
url
|
|
3125
|
+
url,
|
|
3124
3126
|
cache: option.cache,
|
|
3125
3127
|
timeout: option.timeout,
|
|
3126
3128
|
mode: option.mode,
|
|
3127
3129
|
headers: option.headers || {},
|
|
3128
3130
|
json: option.json || false
|
|
3129
3131
|
};
|
|
3130
|
-
if (body) {
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
});
|
|
3138
|
-
}
|
|
3139
|
-
body.query = query.value;
|
|
3140
|
-
body.pgSize = pgSize.value;
|
|
3141
|
-
body.pgIndex = pgIndex.value;
|
|
3142
|
-
postOptions.data = body;
|
|
3132
|
+
if (typeof body === "function") {
|
|
3133
|
+
body = body(mForm, {
|
|
3134
|
+
model: props.model,
|
|
3135
|
+
formValue: mForm?.values,
|
|
3136
|
+
formValues: mForm?.values,
|
|
3137
|
+
config: props.config
|
|
3138
|
+
});
|
|
3143
3139
|
}
|
|
3140
|
+
body.query = query.value;
|
|
3141
|
+
body.pgSize = pgSize.value;
|
|
3142
|
+
body.pgIndex = pgIndex.value;
|
|
3143
|
+
postOptions.data = body;
|
|
3144
3144
|
const requestFuc = getConfig("request");
|
|
3145
3145
|
if (typeof option.beforeRequest === "function") {
|
|
3146
3146
|
postOptions = option.beforeRequest(mForm, postOptions, {
|
|
@@ -3160,9 +3160,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3160
3160
|
config: props.config
|
|
3161
3161
|
});
|
|
3162
3162
|
}
|
|
3163
|
-
const optionsData =
|
|
3164
|
-
|
|
3165
|
-
|
|
3163
|
+
const optionsData = root.split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res);
|
|
3164
|
+
const resTotal = globalThis.parseInt(
|
|
3165
|
+
totalKey.split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res),
|
|
3166
|
+
10
|
|
3167
|
+
);
|
|
3168
|
+
if (resTotal > 0) {
|
|
3169
|
+
total.value = resTotal;
|
|
3166
3170
|
}
|
|
3167
3171
|
remoteData.value = remoteData.value.concat(optionsData);
|
|
3168
3172
|
if (optionsData) {
|
|
@@ -3211,6 +3215,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3211
3215
|
return [];
|
|
3212
3216
|
const { config } = props;
|
|
3213
3217
|
const { option } = config;
|
|
3218
|
+
const { root = "", initRoot = "" } = option;
|
|
3219
|
+
let { initBody = {} } = option;
|
|
3214
3220
|
let options2 = [];
|
|
3215
3221
|
let url = option.initUrl;
|
|
3216
3222
|
if (!url) {
|
|
@@ -3219,22 +3225,45 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3219
3225
|
if (typeof url === "function") {
|
|
3220
3226
|
url = await url(mForm, { model: props.model, formValue: mForm?.values });
|
|
3221
3227
|
}
|
|
3222
|
-
|
|
3228
|
+
if (typeof initBody === "function") {
|
|
3229
|
+
initBody = initBody(mForm, {
|
|
3230
|
+
model: props.model,
|
|
3231
|
+
formValue: mForm?.values,
|
|
3232
|
+
formValues: mForm?.values,
|
|
3233
|
+
config: props.config
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
let postOptions = {
|
|
3223
3237
|
method: option.method || "POST",
|
|
3224
3238
|
url,
|
|
3225
3239
|
data: {
|
|
3226
|
-
id: props.model[props.name]
|
|
3240
|
+
id: props.model[props.name],
|
|
3241
|
+
...initBody
|
|
3227
3242
|
},
|
|
3228
3243
|
mode: option.mode,
|
|
3229
3244
|
headers: option.headers || {},
|
|
3230
3245
|
json: option.json || false
|
|
3231
3246
|
};
|
|
3247
|
+
if (typeof option.beforeInitRequest === "function") {
|
|
3248
|
+
postOptions = option.beforeInitRequest(mForm, postOptions, {
|
|
3249
|
+
model: props.model,
|
|
3250
|
+
formValue: mForm?.values
|
|
3251
|
+
});
|
|
3252
|
+
}
|
|
3232
3253
|
if (option.method?.toLocaleLowerCase() === "jsonp") {
|
|
3233
3254
|
postOptions.jsonpCallback = option.jsonpCallback || "callback";
|
|
3234
3255
|
}
|
|
3235
3256
|
const requestFuc = getConfig("request");
|
|
3236
|
-
|
|
3237
|
-
|
|
3257
|
+
let res = await requestFuc(postOptions);
|
|
3258
|
+
if (typeof option.afterRequest === "function") {
|
|
3259
|
+
res = option.afterRequest(mForm, res, {
|
|
3260
|
+
model: props.model,
|
|
3261
|
+
formValue: mForm?.values,
|
|
3262
|
+
formValues: mForm?.values,
|
|
3263
|
+
config: props.config
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
let initData = (initRoot || root).split(".").reduce((accumulator, currentValue) => accumulator[currentValue], res);
|
|
3238
3267
|
if (initData) {
|
|
3239
3268
|
if (!Array.isArray(initData)) {
|
|
3240
3269
|
initData = [initData];
|