@form-create/element-ui 3.2.20 → 3.2.21
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/form-create.esm.js +648 -619
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +647 -618
- package/dist/form-create.min.js +2 -2
- package/package.json +3 -3
- package/src/core/api.js +4 -3
package/dist/form-create.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.2.
|
|
2
|
+
* @form-create/element-ui v3.2.21
|
|
3
3
|
* (c) 2018-2025 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent, toRef, ref, watch, computed, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, nextTick, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated,
|
|
7
|
+
import { defineComponent, toRef, ref, watch, computed, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, nextTick, markRaw, reactive, isVNode, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated, withDirectives, resolveDirective, createApp, h } from 'vue';
|
|
8
8
|
|
|
9
9
|
function ownKeys(object, enumerableOnly) {
|
|
10
10
|
var keys = Object.keys(object);
|
|
@@ -2161,424 +2161,122 @@ function upper(str) {
|
|
|
2161
2161
|
return str.replace(str[0], str[0].toLocaleUpperCase());
|
|
2162
2162
|
}
|
|
2163
2163
|
|
|
2164
|
-
var
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
if (vm.props.formCreateInject) {
|
|
2170
|
-
return vm.props.formCreateInject;
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
if (vm.parent) {
|
|
2174
|
-
return _getGroupInject(vm.parent, parent);
|
|
2175
|
-
}
|
|
2176
|
-
};
|
|
2164
|
+
var normalMerge = ['props'];
|
|
2165
|
+
var toArrayMerge = ['class', 'style', 'directives'];
|
|
2166
|
+
var functionalMerge = ['on', 'hook'];
|
|
2177
2167
|
|
|
2178
|
-
function
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
components: components,
|
|
2182
|
-
directives: directives,
|
|
2183
|
-
props: {
|
|
2184
|
-
rule: {
|
|
2185
|
-
type: Array,
|
|
2186
|
-
required: true,
|
|
2187
|
-
"default": function _default() {
|
|
2188
|
-
return [];
|
|
2189
|
-
}
|
|
2190
|
-
},
|
|
2191
|
-
option: {
|
|
2192
|
-
type: Object,
|
|
2193
|
-
"default": function _default() {
|
|
2194
|
-
return {};
|
|
2195
|
-
}
|
|
2196
|
-
},
|
|
2197
|
-
extendOption: Boolean,
|
|
2198
|
-
driver: [String, Object],
|
|
2199
|
-
modelValue: Object,
|
|
2200
|
-
disabled: {
|
|
2201
|
-
type: Boolean,
|
|
2202
|
-
"default": undefined
|
|
2203
|
-
},
|
|
2204
|
-
preview: {
|
|
2205
|
-
type: Boolean,
|
|
2206
|
-
"default": undefined
|
|
2207
|
-
},
|
|
2208
|
-
index: [String, Number],
|
|
2209
|
-
api: Object,
|
|
2210
|
-
locale: [String, Object],
|
|
2211
|
-
name: String,
|
|
2212
|
-
subForm: {
|
|
2213
|
-
type: Boolean,
|
|
2214
|
-
"default": true
|
|
2215
|
-
},
|
|
2216
|
-
inFor: Boolean
|
|
2217
|
-
},
|
|
2218
|
-
emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'reset', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
|
|
2219
|
-
render: function render() {
|
|
2220
|
-
return this.fc.render();
|
|
2221
|
-
},
|
|
2222
|
-
setup: function setup(props) {
|
|
2223
|
-
var vm = getCurrentInstance();
|
|
2224
|
-
provide('parentFC', vm);
|
|
2225
|
-
var parent = inject('parentFC', null);
|
|
2226
|
-
var top = parent;
|
|
2168
|
+
var mergeProps = function mergeProps(objects) {
|
|
2169
|
+
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2170
|
+
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2227
2171
|
|
|
2228
|
-
|
|
2229
|
-
while (top.setupState.parent) {
|
|
2230
|
-
top = top.setupState.parent;
|
|
2231
|
-
}
|
|
2232
|
-
} else {
|
|
2233
|
-
top = vm;
|
|
2234
|
-
}
|
|
2172
|
+
var _normalMerge = [].concat(normalMerge, _toConsumableArray(opt['normal'] || []));
|
|
2235
2173
|
|
|
2236
|
-
|
|
2237
|
-
rule = _toRefs.rule,
|
|
2238
|
-
modelValue = _toRefs.modelValue,
|
|
2239
|
-
subForm = _toRefs.subForm,
|
|
2240
|
-
inFor = _toRefs.inFor;
|
|
2174
|
+
var _toArrayMerge = [].concat(toArrayMerge, _toConsumableArray(opt['array'] || []));
|
|
2241
2175
|
|
|
2242
|
-
|
|
2243
|
-
ctxInject: {},
|
|
2244
|
-
destroyed: false,
|
|
2245
|
-
isShow: true,
|
|
2246
|
-
unique: 1,
|
|
2247
|
-
renderRule: _toConsumableArray(rule.value || []),
|
|
2248
|
-
updateValue: JSON.stringify(modelValue.value || {})
|
|
2249
|
-
});
|
|
2250
|
-
var fc = new FormCreate(vm);
|
|
2251
|
-
var fapi = fc.api();
|
|
2252
|
-
var isMore = inFor.value;
|
|
2176
|
+
var _functionalMerge = [].concat(functionalMerge, _toConsumableArray(opt['functional'] || []));
|
|
2253
2177
|
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2178
|
+
var propsMerge = opt['props'] || [];
|
|
2179
|
+
return objects.reduce(function (a, b) {
|
|
2180
|
+
for (var key in b) {
|
|
2181
|
+
if (a[key]) {
|
|
2182
|
+
if (propsMerge.indexOf(key) > -1) {
|
|
2183
|
+
a[key] = mergeProps([b[key]], a[key]);
|
|
2184
|
+
} else if (_normalMerge.indexOf(key) > -1) {
|
|
2185
|
+
a[key] = _objectSpread2(_objectSpread2({}, a[key]), b[key]);
|
|
2186
|
+
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
2187
|
+
var arrA = a[key] instanceof Array ? a[key] : [a[key]];
|
|
2188
|
+
var arrB = b[key] instanceof Array ? b[key] : [b[key]];
|
|
2189
|
+
a[key] = [].concat(_toConsumableArray(arrA), _toConsumableArray(arrB));
|
|
2190
|
+
} else if (_functionalMerge.indexOf(key) > -1) {
|
|
2191
|
+
for (var event in b[key]) {
|
|
2192
|
+
if (a[key][event]) {
|
|
2193
|
+
var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
|
|
2257
2194
|
|
|
2258
|
-
|
|
2259
|
-
var sub;
|
|
2195
|
+
var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
|
|
2260
2196
|
|
|
2261
|
-
|
|
2262
|
-
sub = toArray(_inject.getSubForm());
|
|
2263
|
-
sub.push(fapi);
|
|
2197
|
+
a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
|
|
2264
2198
|
} else {
|
|
2265
|
-
|
|
2199
|
+
a[key][event] = b[key][event];
|
|
2266
2200
|
}
|
|
2267
|
-
|
|
2268
|
-
_inject.subForm(sub);
|
|
2269
2201
|
}
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
if (inject) {
|
|
2277
|
-
if (isMore) {
|
|
2278
|
-
var sub = toArray(inject.getSubForm());
|
|
2279
|
-
var idx = sub.indexOf(fapi);
|
|
2280
|
-
|
|
2281
|
-
if (idx > -1) {
|
|
2282
|
-
sub.splice(idx, 1);
|
|
2202
|
+
} else if (key === 'hook') {
|
|
2203
|
+
for (var hook in b[key]) {
|
|
2204
|
+
if (a[key][hook]) {
|
|
2205
|
+
a[key][hook] = mergeFn(a[key][hook], b[key][hook]);
|
|
2206
|
+
} else {
|
|
2207
|
+
a[key][hook] = b[key][hook];
|
|
2283
2208
|
}
|
|
2284
|
-
} else {
|
|
2285
|
-
inject.subForm();
|
|
2286
2209
|
}
|
|
2210
|
+
} else {
|
|
2211
|
+
a[key] = b[key];
|
|
2287
2212
|
}
|
|
2288
|
-
}
|
|
2213
|
+
} else {
|
|
2214
|
+
if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
|
|
2215
|
+
a[key] = _objectSpread2({}, b[key]);
|
|
2216
|
+
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
2217
|
+
a[key] = b[key] instanceof Array ? _toConsumableArray(b[key]) : _typeof(b[key]) === 'object' ? _objectSpread2({}, b[key]) : b[key];
|
|
2218
|
+
} else a[key] = b[key];
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2289
2221
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
var content = '';
|
|
2294
|
-
var globalClass = props.option && props.option.globalClass || {};
|
|
2295
|
-
Object.keys(globalClass).forEach(function (k) {
|
|
2296
|
-
var subCss = '';
|
|
2297
|
-
globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
|
|
2298
|
-
subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
|
|
2299
|
-
});
|
|
2222
|
+
return a;
|
|
2223
|
+
}, initial);
|
|
2224
|
+
};
|
|
2300
2225
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2226
|
+
var mergeFn = function mergeFn(fn1, fn2) {
|
|
2227
|
+
return function () {
|
|
2228
|
+
fn1 && fn1.apply(this, arguments);
|
|
2229
|
+
fn2 && fn2.apply(this, arguments);
|
|
2230
|
+
};
|
|
2231
|
+
};
|
|
2304
2232
|
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2233
|
+
var keyAttrs = ['type', 'slot', 'ignore', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
|
|
2234
|
+
var arrayAttrs = ['validate', 'children', 'control'];
|
|
2235
|
+
var normalAttrs = ['effect', 'deep', 'renderSlots'];
|
|
2236
|
+
function attrs() {
|
|
2237
|
+
return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
|
|
2238
|
+
}
|
|
2309
2239
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2240
|
+
function format(type, msg, rule) {
|
|
2241
|
+
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
2242
|
+
}
|
|
2243
|
+
function err(msg, rule) {
|
|
2244
|
+
console.error(format('err', msg, rule));
|
|
2245
|
+
}
|
|
2246
|
+
function logError(e) {
|
|
2247
|
+
err(e.toString());
|
|
2248
|
+
console.error(e);
|
|
2249
|
+
}
|
|
2313
2250
|
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2251
|
+
function toCase(str) {
|
|
2252
|
+
var to = str.replace(/(-[a-z])/g, function (v) {
|
|
2253
|
+
return v.replace('-', '').toLocaleUpperCase();
|
|
2254
|
+
});
|
|
2255
|
+
return lower(to);
|
|
2256
|
+
}
|
|
2257
|
+
function lower(str) {
|
|
2258
|
+
return str.replace(str[0], str[0].toLowerCase());
|
|
2259
|
+
}
|
|
2319
2260
|
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
}, 100);
|
|
2326
|
-
var emit$scopeForm = debounce(function () {
|
|
2327
|
-
fc.bus.$emit('$loadData.$scopeForm');
|
|
2328
|
-
}, 100);
|
|
2329
|
-
var emit$form = debounce(function () {
|
|
2330
|
-
fc.bus.$emit('$loadData.$form');
|
|
2331
|
-
}, 100);
|
|
2261
|
+
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
2262
|
+
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2263
|
+
function toJson(obj, space) {
|
|
2264
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2265
|
+
if (val && val._isVue === true) return undefined;
|
|
2332
2266
|
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2267
|
+
if (typeof val !== 'function') {
|
|
2268
|
+
return val;
|
|
2269
|
+
}
|
|
2336
2270
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
fapi.top.bus.$on('change', emit$change);
|
|
2341
|
-
}
|
|
2271
|
+
if (val.__json) {
|
|
2272
|
+
return val.__json;
|
|
2273
|
+
}
|
|
2342
2274
|
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
});
|
|
2349
|
-
onBeforeUnmount(function () {
|
|
2350
|
-
if (parent) {
|
|
2351
|
-
fapi.top.bus.$off('$loadData.$form', emit$topForm);
|
|
2352
|
-
fapi.top.bus.$off('change', emit$change);
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
if (fapi !== fapi.scope) {
|
|
2356
|
-
fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
styleEl && document.head.removeChild(styleEl);
|
|
2360
|
-
rmSubForm();
|
|
2361
|
-
data.destroyed = true;
|
|
2362
|
-
fc.unmount();
|
|
2363
|
-
});
|
|
2364
|
-
onUpdated(function () {
|
|
2365
|
-
fc.updated();
|
|
2366
|
-
});
|
|
2367
|
-
watch(subForm, function (n) {
|
|
2368
|
-
n ? addSubForm() : rmSubForm();
|
|
2369
|
-
}, {
|
|
2370
|
-
immediate: true
|
|
2371
|
-
});
|
|
2372
|
-
watch(function () {
|
|
2373
|
-
return props.option;
|
|
2374
|
-
}, function () {
|
|
2375
|
-
fc.initOptions();
|
|
2376
|
-
fapi.refresh();
|
|
2377
|
-
}, {
|
|
2378
|
-
deep: true
|
|
2379
|
-
});
|
|
2380
|
-
watch(function () {
|
|
2381
|
-
return _toConsumableArray(rule.value);
|
|
2382
|
-
}, function (n) {
|
|
2383
|
-
if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(function (v) {
|
|
2384
|
-
return data.renderRule.indexOf(v) > -1;
|
|
2385
|
-
})) return;
|
|
2386
|
-
fc.$handle.updateAppendData();
|
|
2387
|
-
fc.$handle.reloadRule(rule.value);
|
|
2388
|
-
vm.setupState.renderRule();
|
|
2389
|
-
});
|
|
2390
|
-
watch(function () {
|
|
2391
|
-
return [props.disabled, props.preview];
|
|
2392
|
-
}, function () {
|
|
2393
|
-
fapi.refresh();
|
|
2394
|
-
});
|
|
2395
|
-
watch(modelValue, function (n) {
|
|
2396
|
-
if (JSON.stringify(n || {}) === data.updateValue) return;
|
|
2397
|
-
|
|
2398
|
-
if (fapi.config.forceCoverValue) {
|
|
2399
|
-
fapi.coverValue(n || {});
|
|
2400
|
-
} else {
|
|
2401
|
-
fapi.setValue(n || {});
|
|
2402
|
-
}
|
|
2403
|
-
}, {
|
|
2404
|
-
deep: true,
|
|
2405
|
-
flush: 'post'
|
|
2406
|
-
});
|
|
2407
|
-
watch(function () {
|
|
2408
|
-
return props.index;
|
|
2409
|
-
}, function () {
|
|
2410
|
-
fapi.coverValue({});
|
|
2411
|
-
fc.$handle.updateAppendData();
|
|
2412
|
-
nextTick(function () {
|
|
2413
|
-
nextTick(function () {
|
|
2414
|
-
fapi.clearValidateState();
|
|
2415
|
-
});
|
|
2416
|
-
});
|
|
2417
|
-
}, {
|
|
2418
|
-
flush: 'sync'
|
|
2419
|
-
});
|
|
2420
|
-
return _objectSpread2(_objectSpread2({
|
|
2421
|
-
fc: markRaw(fc),
|
|
2422
|
-
parent: parent ? markRaw(parent) : parent,
|
|
2423
|
-
top: markRaw(top),
|
|
2424
|
-
fapi: markRaw(fapi)
|
|
2425
|
-
}, toRefs(data)), {}, {
|
|
2426
|
-
getGroupInject: function getGroupInject() {
|
|
2427
|
-
return _getGroupInject(vm, parent);
|
|
2428
|
-
},
|
|
2429
|
-
refresh: function refresh() {
|
|
2430
|
-
++data.unique;
|
|
2431
|
-
},
|
|
2432
|
-
renderRule: function renderRule() {
|
|
2433
|
-
data.renderRule = _toConsumableArray(rule.value || []);
|
|
2434
|
-
},
|
|
2435
|
-
updateValue: function updateValue(value) {
|
|
2436
|
-
if (data.destroyed) return;
|
|
2437
|
-
var json = JSON.stringify(value);
|
|
2438
|
-
|
|
2439
|
-
if (data.updateValue === json) {
|
|
2440
|
-
return;
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
data.updateValue = json;
|
|
2444
|
-
vm.emit('update:modelValue', value);
|
|
2445
|
-
nextTick(function () {
|
|
2446
|
-
emit$form();
|
|
2447
|
-
|
|
2448
|
-
if (!parent) {
|
|
2449
|
-
emit$topForm();
|
|
2450
|
-
emit$scopeForm();
|
|
2451
|
-
} else if (!subForm.value) {
|
|
2452
|
-
emit$scopeForm();
|
|
2453
|
-
}
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
});
|
|
2457
|
-
},
|
|
2458
|
-
created: function created() {
|
|
2459
|
-
var vm = getCurrentInstance();
|
|
2460
|
-
vm.emit('update:api', vm.setupState.fapi);
|
|
2461
|
-
vm.setupState.fc.init();
|
|
2462
|
-
}
|
|
2463
|
-
});
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
var normalMerge = ['props'];
|
|
2467
|
-
var toArrayMerge = ['class', 'style', 'directives'];
|
|
2468
|
-
var functionalMerge = ['on', 'hook'];
|
|
2469
|
-
|
|
2470
|
-
var mergeProps = function mergeProps(objects) {
|
|
2471
|
-
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2472
|
-
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2473
|
-
|
|
2474
|
-
var _normalMerge = [].concat(normalMerge, _toConsumableArray(opt['normal'] || []));
|
|
2475
|
-
|
|
2476
|
-
var _toArrayMerge = [].concat(toArrayMerge, _toConsumableArray(opt['array'] || []));
|
|
2477
|
-
|
|
2478
|
-
var _functionalMerge = [].concat(functionalMerge, _toConsumableArray(opt['functional'] || []));
|
|
2479
|
-
|
|
2480
|
-
var propsMerge = opt['props'] || [];
|
|
2481
|
-
return objects.reduce(function (a, b) {
|
|
2482
|
-
for (var key in b) {
|
|
2483
|
-
if (a[key]) {
|
|
2484
|
-
if (propsMerge.indexOf(key) > -1) {
|
|
2485
|
-
a[key] = mergeProps([b[key]], a[key]);
|
|
2486
|
-
} else if (_normalMerge.indexOf(key) > -1) {
|
|
2487
|
-
a[key] = _objectSpread2(_objectSpread2({}, a[key]), b[key]);
|
|
2488
|
-
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
2489
|
-
var arrA = a[key] instanceof Array ? a[key] : [a[key]];
|
|
2490
|
-
var arrB = b[key] instanceof Array ? b[key] : [b[key]];
|
|
2491
|
-
a[key] = [].concat(_toConsumableArray(arrA), _toConsumableArray(arrB));
|
|
2492
|
-
} else if (_functionalMerge.indexOf(key) > -1) {
|
|
2493
|
-
for (var event in b[key]) {
|
|
2494
|
-
if (a[key][event]) {
|
|
2495
|
-
var _arrA = a[key][event] instanceof Array ? a[key][event] : [a[key][event]];
|
|
2496
|
-
|
|
2497
|
-
var _arrB = b[key][event] instanceof Array ? b[key][event] : [b[key][event]];
|
|
2498
|
-
|
|
2499
|
-
a[key][event] = [].concat(_toConsumableArray(_arrA), _toConsumableArray(_arrB));
|
|
2500
|
-
} else {
|
|
2501
|
-
a[key][event] = b[key][event];
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
} else if (key === 'hook') {
|
|
2505
|
-
for (var hook in b[key]) {
|
|
2506
|
-
if (a[key][hook]) {
|
|
2507
|
-
a[key][hook] = mergeFn(a[key][hook], b[key][hook]);
|
|
2508
|
-
} else {
|
|
2509
|
-
a[key][hook] = b[key][hook];
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
} else {
|
|
2513
|
-
a[key] = b[key];
|
|
2514
|
-
}
|
|
2515
|
-
} else {
|
|
2516
|
-
if (_normalMerge.indexOf(key) > -1 || _functionalMerge.indexOf(key) > -1 || propsMerge.indexOf(key) > -1) {
|
|
2517
|
-
a[key] = _objectSpread2({}, b[key]);
|
|
2518
|
-
} else if (_toArrayMerge.indexOf(key) > -1) {
|
|
2519
|
-
a[key] = b[key] instanceof Array ? _toConsumableArray(b[key]) : _typeof(b[key]) === 'object' ? _objectSpread2({}, b[key]) : b[key];
|
|
2520
|
-
} else a[key] = b[key];
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
|
|
2524
|
-
return a;
|
|
2525
|
-
}, initial);
|
|
2526
|
-
};
|
|
2527
|
-
|
|
2528
|
-
var mergeFn = function mergeFn(fn1, fn2) {
|
|
2529
|
-
return function () {
|
|
2530
|
-
fn1 && fn1.apply(this, arguments);
|
|
2531
|
-
fn2 && fn2.apply(this, arguments);
|
|
2532
|
-
};
|
|
2533
|
-
};
|
|
2534
|
-
|
|
2535
|
-
var keyAttrs = ['type', 'slot', 'ignore', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
|
|
2536
|
-
var arrayAttrs = ['validate', 'children', 'control'];
|
|
2537
|
-
var normalAttrs = ['effect', 'deep', 'renderSlots'];
|
|
2538
|
-
function attrs() {
|
|
2539
|
-
return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
function format(type, msg, rule) {
|
|
2543
|
-
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
2544
|
-
}
|
|
2545
|
-
function err(msg, rule) {
|
|
2546
|
-
console.error(format('err', msg, rule));
|
|
2547
|
-
}
|
|
2548
|
-
function logError(e) {
|
|
2549
|
-
err(e.toString());
|
|
2550
|
-
console.error(e);
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2553
|
-
function toCase(str) {
|
|
2554
|
-
var to = str.replace(/(-[a-z])/g, function (v) {
|
|
2555
|
-
return v.replace('-', '').toLocaleUpperCase();
|
|
2556
|
-
});
|
|
2557
|
-
return lower(to);
|
|
2558
|
-
}
|
|
2559
|
-
function lower(str) {
|
|
2560
|
-
return str.replace(str[0], str[0].toLowerCase());
|
|
2561
|
-
}
|
|
2562
|
-
|
|
2563
|
-
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
2564
|
-
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2565
|
-
function toJson(obj, space) {
|
|
2566
|
-
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2567
|
-
if (val && val._isVue === true) return undefined;
|
|
2568
|
-
|
|
2569
|
-
if (typeof val !== 'function') {
|
|
2570
|
-
return val;
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
if (val.__json) {
|
|
2574
|
-
return val.__json;
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
if (val.__origin) val = val.__origin;
|
|
2578
|
-
if (val.__emit) return undefined;
|
|
2579
|
-
return PREFIX + val + SUFFIX;
|
|
2580
|
-
}, space);
|
|
2581
|
-
}
|
|
2275
|
+
if (val.__origin) val = val.__origin;
|
|
2276
|
+
if (val.__emit) return undefined;
|
|
2277
|
+
return PREFIX + val + SUFFIX;
|
|
2278
|
+
}, space);
|
|
2279
|
+
}
|
|
2582
2280
|
|
|
2583
2281
|
function makeFn(fn) {
|
|
2584
2282
|
return new Function('return ' + fn)();
|
|
@@ -2750,170 +2448,468 @@ function makeSlotBag() {
|
|
|
2750
2448
|
children.push(fn);
|
|
2751
2449
|
}
|
|
2752
2450
|
});
|
|
2753
|
-
return children;
|
|
2754
|
-
},
|
|
2755
|
-
getSlots: function getSlots() {
|
|
2756
|
-
var _this = this;
|
|
2451
|
+
return children;
|
|
2452
|
+
},
|
|
2453
|
+
getSlots: function getSlots() {
|
|
2454
|
+
var _this = this;
|
|
2455
|
+
|
|
2456
|
+
var slots = {};
|
|
2457
|
+
Object.keys(slotBag).forEach(function (k) {
|
|
2458
|
+
slots[k] = function () {
|
|
2459
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2460
|
+
args[_key] = arguments[_key];
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
return _this.getSlot(k, args);
|
|
2464
|
+
};
|
|
2465
|
+
});
|
|
2466
|
+
return slots;
|
|
2467
|
+
},
|
|
2468
|
+
slotLen: function slotLen(slot) {
|
|
2469
|
+
slot = slotName(slot);
|
|
2470
|
+
return slotBag[slot] ? slotBag[slot].length : 0;
|
|
2471
|
+
},
|
|
2472
|
+
mergeBag: function mergeBag(bag) {
|
|
2473
|
+
var _this2 = this;
|
|
2474
|
+
|
|
2475
|
+
if (!bag) return this;
|
|
2476
|
+
var slots = is.Function(bag.getSlots) ? bag.getSlots() : bag;
|
|
2477
|
+
|
|
2478
|
+
if (Array.isArray(bag) || isVNode(bag)) {
|
|
2479
|
+
this.setSlot(undefined, function () {
|
|
2480
|
+
return bag;
|
|
2481
|
+
});
|
|
2482
|
+
} else {
|
|
2483
|
+
Object.keys(slots).forEach(function (k) {
|
|
2484
|
+
_this2.setSlot(k, slots[k]);
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
return this;
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
function toProps(rule) {
|
|
2493
|
+
var prop = _objectSpread2({}, rule.props || {});
|
|
2494
|
+
|
|
2495
|
+
Object.keys(rule.on || {}).forEach(function (k) {
|
|
2496
|
+
if (k.indexOf('-') > 0) {
|
|
2497
|
+
k = toCase(k);
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
var name = "on".concat(upper(k));
|
|
2501
|
+
|
|
2502
|
+
if (Array.isArray(prop[name])) {
|
|
2503
|
+
prop[name] = [].concat(_toConsumableArray(prop[name]), [rule.on[k]]);
|
|
2504
|
+
} else if (prop[name]) {
|
|
2505
|
+
prop[name] = [prop[name], rule.on[k]];
|
|
2506
|
+
} else {
|
|
2507
|
+
prop[name] = rule.on[k];
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
prop.key = rule.key;
|
|
2511
|
+
prop.ref = rule.ref;
|
|
2512
|
+
prop["class"] = rule["class"];
|
|
2513
|
+
prop.id = rule.id;
|
|
2514
|
+
prop.style = rule.style;
|
|
2515
|
+
if (prop.slot) delete prop.slot;
|
|
2516
|
+
return prop;
|
|
2517
|
+
}
|
|
2518
|
+
function setPrototypeOf(o, proto) {
|
|
2519
|
+
Object.setPrototypeOf(o, proto);
|
|
2520
|
+
return o;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
var changeType = function changeType(a, b) {
|
|
2524
|
+
if (typeof a === 'string') {
|
|
2525
|
+
return String(b);
|
|
2526
|
+
} else if (typeof a === 'number') {
|
|
2527
|
+
return Number(b);
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
return b;
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
var condition = {
|
|
2534
|
+
'==': function _(a, b) {
|
|
2535
|
+
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2536
|
+
},
|
|
2537
|
+
'!=': function _(a, b) {
|
|
2538
|
+
return !condition['=='](a, b);
|
|
2539
|
+
},
|
|
2540
|
+
'>': function _(a, b) {
|
|
2541
|
+
return a > b;
|
|
2542
|
+
},
|
|
2543
|
+
'>=': function _(a, b) {
|
|
2544
|
+
return a >= b;
|
|
2545
|
+
},
|
|
2546
|
+
'<': function _(a, b) {
|
|
2547
|
+
return a < b;
|
|
2548
|
+
},
|
|
2549
|
+
'<=': function _(a, b) {
|
|
2550
|
+
return a <= b;
|
|
2551
|
+
},
|
|
2552
|
+
on: function on(a, b) {
|
|
2553
|
+
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2554
|
+
},
|
|
2555
|
+
notOn: function notOn(a, b) {
|
|
2556
|
+
return !condition.on(a, b);
|
|
2557
|
+
},
|
|
2558
|
+
"in": function _in(a, b) {
|
|
2559
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2560
|
+
},
|
|
2561
|
+
notIn: function notIn(a, b) {
|
|
2562
|
+
return !condition["in"](a, b);
|
|
2563
|
+
},
|
|
2564
|
+
between: function between(a, b) {
|
|
2565
|
+
return a > b[0] && a < b[1];
|
|
2566
|
+
},
|
|
2567
|
+
notBetween: function notBetween(a, b) {
|
|
2568
|
+
return a < b[0] || a > b[1];
|
|
2569
|
+
},
|
|
2570
|
+
empty: function empty(a) {
|
|
2571
|
+
return is.empty(a);
|
|
2572
|
+
},
|
|
2573
|
+
notEmpty: function notEmpty(a) {
|
|
2574
|
+
return !is.empty(a);
|
|
2575
|
+
},
|
|
2576
|
+
pattern: function pattern(a, b) {
|
|
2577
|
+
return new RegExp(b, 'g').test(a);
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
function deepGet(val, split) {
|
|
2581
|
+
(Array.isArray(split) ? split : (split || '').split('.')).forEach(function (k) {
|
|
2582
|
+
if (val != null) {
|
|
2583
|
+
val = val[k];
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
return val;
|
|
2587
|
+
}
|
|
2588
|
+
function extractVar(str) {
|
|
2589
|
+
var regex = /{{\s*(.*?)\s*}}/g;
|
|
2590
|
+
var match;
|
|
2591
|
+
var matches = {};
|
|
2592
|
+
|
|
2593
|
+
while ((match = regex.exec(str)) !== null) {
|
|
2594
|
+
if (match[1]) {
|
|
2595
|
+
matches[match[1]] = true;
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
return Object.keys(matches);
|
|
2600
|
+
}
|
|
2601
|
+
function convertFieldToConditions(field) {
|
|
2602
|
+
var parts = field.split('.');
|
|
2603
|
+
var conditions = [];
|
|
2604
|
+
var currentCondition = '';
|
|
2605
|
+
parts.forEach(function (part, index) {
|
|
2606
|
+
if (index === 0) {
|
|
2607
|
+
currentCondition = part;
|
|
2608
|
+
} else {
|
|
2609
|
+
currentCondition += '.' + part;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
conditions.push(currentCondition);
|
|
2613
|
+
});
|
|
2614
|
+
return conditions.join(' && ');
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
var _getGroupInject = function getGroupInject(vm, parent) {
|
|
2618
|
+
if (!vm || vm === parent) {
|
|
2619
|
+
return;
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
if (vm.props.formCreateInject) {
|
|
2623
|
+
return vm.props.formCreateInject;
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
if (vm.parent) {
|
|
2627
|
+
return _getGroupInject(vm.parent, parent);
|
|
2628
|
+
}
|
|
2629
|
+
};
|
|
2630
|
+
|
|
2631
|
+
function $FormCreate(FormCreate, components, directives) {
|
|
2632
|
+
return defineComponent({
|
|
2633
|
+
name: 'FormCreate' + (FormCreate.isMobile ? 'Mobile' : ''),
|
|
2634
|
+
components: components,
|
|
2635
|
+
directives: directives,
|
|
2636
|
+
props: {
|
|
2637
|
+
rule: {
|
|
2638
|
+
type: Array,
|
|
2639
|
+
required: true,
|
|
2640
|
+
"default": function _default() {
|
|
2641
|
+
return [];
|
|
2642
|
+
}
|
|
2643
|
+
},
|
|
2644
|
+
option: {
|
|
2645
|
+
type: Object,
|
|
2646
|
+
"default": function _default() {
|
|
2647
|
+
return {};
|
|
2648
|
+
}
|
|
2649
|
+
},
|
|
2650
|
+
extendOption: Boolean,
|
|
2651
|
+
driver: [String, Object],
|
|
2652
|
+
modelValue: Object,
|
|
2653
|
+
disabled: {
|
|
2654
|
+
type: Boolean,
|
|
2655
|
+
"default": undefined
|
|
2656
|
+
},
|
|
2657
|
+
preview: {
|
|
2658
|
+
type: Boolean,
|
|
2659
|
+
"default": undefined
|
|
2660
|
+
},
|
|
2661
|
+
index: [String, Number],
|
|
2662
|
+
api: Object,
|
|
2663
|
+
locale: [String, Object],
|
|
2664
|
+
name: String,
|
|
2665
|
+
subForm: {
|
|
2666
|
+
type: Boolean,
|
|
2667
|
+
"default": true
|
|
2668
|
+
},
|
|
2669
|
+
inFor: Boolean
|
|
2670
|
+
},
|
|
2671
|
+
emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'reset', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
|
|
2672
|
+
render: function render() {
|
|
2673
|
+
return this.fc.render();
|
|
2674
|
+
},
|
|
2675
|
+
setup: function setup(props) {
|
|
2676
|
+
var vm = getCurrentInstance();
|
|
2677
|
+
provide('parentFC', vm);
|
|
2678
|
+
var parent = inject('parentFC', null);
|
|
2679
|
+
var top = parent;
|
|
2680
|
+
|
|
2681
|
+
if (parent) {
|
|
2682
|
+
while (top.setupState.parent) {
|
|
2683
|
+
top = top.setupState.parent;
|
|
2684
|
+
}
|
|
2685
|
+
} else {
|
|
2686
|
+
top = vm;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
var _toRefs = toRefs(props),
|
|
2690
|
+
rule = _toRefs.rule,
|
|
2691
|
+
modelValue = _toRefs.modelValue,
|
|
2692
|
+
subForm = _toRefs.subForm,
|
|
2693
|
+
inFor = _toRefs.inFor;
|
|
2694
|
+
|
|
2695
|
+
var data = reactive({
|
|
2696
|
+
ctxInject: {},
|
|
2697
|
+
destroyed: false,
|
|
2698
|
+
isShow: true,
|
|
2699
|
+
unique: 1,
|
|
2700
|
+
renderRule: _toConsumableArray(rule.value || []),
|
|
2701
|
+
updateValue: JSON.stringify(modelValue.value || {})
|
|
2702
|
+
});
|
|
2703
|
+
var fc = new FormCreate(vm);
|
|
2704
|
+
var fapi = fc.api();
|
|
2705
|
+
var isMore = inFor.value;
|
|
2706
|
+
|
|
2707
|
+
var addSubForm = function addSubForm() {
|
|
2708
|
+
if (parent) {
|
|
2709
|
+
var _inject = _getGroupInject(vm, parent);
|
|
2710
|
+
|
|
2711
|
+
if (_inject) {
|
|
2712
|
+
var sub;
|
|
2713
|
+
|
|
2714
|
+
if (isMore) {
|
|
2715
|
+
sub = toArray(_inject.getSubForm());
|
|
2716
|
+
sub.push(fapi);
|
|
2717
|
+
} else {
|
|
2718
|
+
sub = fapi;
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
_inject.subForm(sub);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
};
|
|
2725
|
+
|
|
2726
|
+
var rmSubForm = function rmSubForm() {
|
|
2727
|
+
var inject = _getGroupInject(vm, parent);
|
|
2728
|
+
|
|
2729
|
+
if (inject) {
|
|
2730
|
+
if (isMore) {
|
|
2731
|
+
var sub = toArray(inject.getSubForm());
|
|
2732
|
+
var idx = sub.indexOf(fapi);
|
|
2733
|
+
|
|
2734
|
+
if (idx > -1) {
|
|
2735
|
+
sub.splice(idx, 1);
|
|
2736
|
+
}
|
|
2737
|
+
} else {
|
|
2738
|
+
inject.subForm();
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2743
|
+
var styleEl = null;
|
|
2744
|
+
onBeforeMount(function () {
|
|
2745
|
+
watchEffect(function () {
|
|
2746
|
+
var content = '';
|
|
2747
|
+
var globalClass = props.option && props.option.globalClass || {};
|
|
2748
|
+
Object.keys(globalClass).forEach(function (k) {
|
|
2749
|
+
var subCss = '';
|
|
2750
|
+
globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
|
|
2751
|
+
subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
|
|
2752
|
+
});
|
|
2753
|
+
|
|
2754
|
+
if (globalClass[k].content) {
|
|
2755
|
+
subCss += globalClass[k].content + ';';
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
if (subCss) {
|
|
2759
|
+
content += ".".concat(k, "{").concat(subCss, "}");
|
|
2760
|
+
}
|
|
2761
|
+
});
|
|
2762
|
+
|
|
2763
|
+
if (props.option && props.option.style) {
|
|
2764
|
+
content += props.option.style;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
if (!styleEl) {
|
|
2768
|
+
styleEl = document.createElement('style');
|
|
2769
|
+
styleEl.type = 'text/css';
|
|
2770
|
+
document.head.appendChild(styleEl);
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
styleEl.innerHTML = content || '';
|
|
2774
|
+
});
|
|
2775
|
+
});
|
|
2776
|
+
var emit$topForm = debounce(function () {
|
|
2777
|
+
fc.bus.$emit('$loadData.$topForm');
|
|
2778
|
+
}, 100);
|
|
2779
|
+
var emit$scopeForm = debounce(function () {
|
|
2780
|
+
fc.bus.$emit('$loadData.$scopeForm');
|
|
2781
|
+
}, 100);
|
|
2782
|
+
var emit$form = debounce(function () {
|
|
2783
|
+
fc.bus.$emit('$loadData.$form');
|
|
2784
|
+
}, 100);
|
|
2785
|
+
|
|
2786
|
+
var emit$change = function emit$change(field) {
|
|
2787
|
+
fc.bus.$emit('change-$form.' + field);
|
|
2788
|
+
};
|
|
2789
|
+
|
|
2790
|
+
onMounted(function () {
|
|
2791
|
+
if (parent) {
|
|
2792
|
+
fapi.top.bus.$on('$loadData.$form', emit$topForm);
|
|
2793
|
+
fapi.top.bus.$on('change', emit$change);
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
if (fapi !== fapi.scope) {
|
|
2797
|
+
fapi.scope.bus.$on('$loadData.$scopeForm', emit$scopeForm);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
fc.mounted();
|
|
2801
|
+
});
|
|
2802
|
+
onBeforeUnmount(function () {
|
|
2803
|
+
if (parent) {
|
|
2804
|
+
fapi.top.bus.$off('$loadData.$form', emit$topForm);
|
|
2805
|
+
fapi.top.bus.$off('change', emit$change);
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
if (fapi !== fapi.scope) {
|
|
2809
|
+
fapi.scope.bus.$off('$loadData.$scopeForm', emit$scopeForm);
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
styleEl && document.head.removeChild(styleEl);
|
|
2813
|
+
rmSubForm();
|
|
2814
|
+
data.destroyed = true;
|
|
2815
|
+
fc.unmount();
|
|
2816
|
+
});
|
|
2817
|
+
onUpdated(function () {
|
|
2818
|
+
fc.updated();
|
|
2819
|
+
});
|
|
2820
|
+
addSubForm();
|
|
2821
|
+
watch(function () {
|
|
2822
|
+
return props.option;
|
|
2823
|
+
}, function () {
|
|
2824
|
+
fc.initOptions();
|
|
2825
|
+
fapi.refresh();
|
|
2826
|
+
}, {
|
|
2827
|
+
deep: true
|
|
2828
|
+
});
|
|
2829
|
+
watch(function () {
|
|
2830
|
+
return _toConsumableArray(rule.value);
|
|
2831
|
+
}, function (n) {
|
|
2832
|
+
if (fc.$handle.isBreakWatch() || n.length === data.renderRule.length && n.every(function (v) {
|
|
2833
|
+
return data.renderRule.indexOf(v) > -1;
|
|
2834
|
+
})) return;
|
|
2835
|
+
fc.$handle.updateAppendData();
|
|
2836
|
+
fc.$handle.reloadRule(rule.value);
|
|
2837
|
+
vm.setupState.renderRule();
|
|
2838
|
+
});
|
|
2839
|
+
watch(function () {
|
|
2840
|
+
return [props.disabled, props.preview];
|
|
2841
|
+
}, function () {
|
|
2842
|
+
fapi.refresh();
|
|
2843
|
+
});
|
|
2844
|
+
watch(modelValue, function (n) {
|
|
2845
|
+
if (toJson(n || {}) === data.updateValue) return;
|
|
2846
|
+
|
|
2847
|
+
if (fapi.config.forceCoverValue) {
|
|
2848
|
+
fapi.coverValue(n || {});
|
|
2849
|
+
} else {
|
|
2850
|
+
fapi.setValue(n || {});
|
|
2851
|
+
}
|
|
2852
|
+
}, {
|
|
2853
|
+
deep: true,
|
|
2854
|
+
flush: 'post'
|
|
2855
|
+
});
|
|
2856
|
+
watch(function () {
|
|
2857
|
+
return props.index;
|
|
2858
|
+
}, function () {
|
|
2859
|
+
fapi.coverValue({});
|
|
2860
|
+
fc.$handle.updateAppendData();
|
|
2861
|
+
nextTick(function () {
|
|
2862
|
+
nextTick(function () {
|
|
2863
|
+
fapi.clearValidateState();
|
|
2864
|
+
});
|
|
2865
|
+
});
|
|
2866
|
+
}, {
|
|
2867
|
+
flush: 'sync'
|
|
2868
|
+
});
|
|
2869
|
+
return _objectSpread2(_objectSpread2({
|
|
2870
|
+
fc: markRaw(fc),
|
|
2871
|
+
parent: parent ? markRaw(parent) : parent,
|
|
2872
|
+
top: markRaw(top),
|
|
2873
|
+
fapi: markRaw(fapi)
|
|
2874
|
+
}, toRefs(data)), {}, {
|
|
2875
|
+
getGroupInject: function getGroupInject() {
|
|
2876
|
+
return _getGroupInject(vm, parent);
|
|
2877
|
+
},
|
|
2878
|
+
refresh: function refresh() {
|
|
2879
|
+
++data.unique;
|
|
2880
|
+
},
|
|
2881
|
+
renderRule: function renderRule() {
|
|
2882
|
+
data.renderRule = _toConsumableArray(rule.value || []);
|
|
2883
|
+
},
|
|
2884
|
+
updateValue: function updateValue(value) {
|
|
2885
|
+
if (data.destroyed) return;
|
|
2886
|
+
var json = toJson(value);
|
|
2757
2887
|
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
slots[k] = function () {
|
|
2761
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2762
|
-
args[_key] = arguments[_key];
|
|
2888
|
+
if (data.updateValue === json) {
|
|
2889
|
+
return;
|
|
2763
2890
|
}
|
|
2764
2891
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2892
|
+
data.updateValue = json;
|
|
2893
|
+
vm.emit('update:modelValue', value);
|
|
2894
|
+
nextTick(function () {
|
|
2895
|
+
emit$form();
|
|
2896
|
+
|
|
2897
|
+
if (!parent) {
|
|
2898
|
+
emit$topForm();
|
|
2899
|
+
emit$scopeForm();
|
|
2900
|
+
} else if (!subForm.value) {
|
|
2901
|
+
emit$scopeForm();
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2767
2905
|
});
|
|
2768
|
-
return slots;
|
|
2769
|
-
},
|
|
2770
|
-
slotLen: function slotLen(slot) {
|
|
2771
|
-
slot = slotName(slot);
|
|
2772
|
-
return slotBag[slot] ? slotBag[slot].length : 0;
|
|
2773
2906
|
},
|
|
2774
|
-
|
|
2775
|
-
var
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
var slots = is.Function(bag.getSlots) ? bag.getSlots() : bag;
|
|
2779
|
-
|
|
2780
|
-
if (Array.isArray(bag) || isVNode(bag)) {
|
|
2781
|
-
this.setSlot(undefined, function () {
|
|
2782
|
-
return bag;
|
|
2783
|
-
});
|
|
2784
|
-
} else {
|
|
2785
|
-
Object.keys(slots).forEach(function (k) {
|
|
2786
|
-
_this2.setSlot(k, slots[k]);
|
|
2787
|
-
});
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
|
-
return this;
|
|
2791
|
-
}
|
|
2792
|
-
};
|
|
2793
|
-
}
|
|
2794
|
-
function toProps(rule) {
|
|
2795
|
-
var prop = _objectSpread2({}, rule.props || {});
|
|
2796
|
-
|
|
2797
|
-
Object.keys(rule.on || {}).forEach(function (k) {
|
|
2798
|
-
if (k.indexOf('-') > 0) {
|
|
2799
|
-
k = toCase(k);
|
|
2800
|
-
}
|
|
2801
|
-
|
|
2802
|
-
var name = "on".concat(upper(k));
|
|
2803
|
-
|
|
2804
|
-
if (Array.isArray(prop[name])) {
|
|
2805
|
-
prop[name] = [].concat(_toConsumableArray(prop[name]), [rule.on[k]]);
|
|
2806
|
-
} else if (prop[name]) {
|
|
2807
|
-
prop[name] = [prop[name], rule.on[k]];
|
|
2808
|
-
} else {
|
|
2809
|
-
prop[name] = rule.on[k];
|
|
2810
|
-
}
|
|
2811
|
-
});
|
|
2812
|
-
prop.key = rule.key;
|
|
2813
|
-
prop.ref = rule.ref;
|
|
2814
|
-
prop["class"] = rule["class"];
|
|
2815
|
-
prop.id = rule.id;
|
|
2816
|
-
prop.style = rule.style;
|
|
2817
|
-
if (prop.slot) delete prop.slot;
|
|
2818
|
-
return prop;
|
|
2819
|
-
}
|
|
2820
|
-
function setPrototypeOf(o, proto) {
|
|
2821
|
-
Object.setPrototypeOf(o, proto);
|
|
2822
|
-
return o;
|
|
2823
|
-
}
|
|
2824
|
-
|
|
2825
|
-
var changeType = function changeType(a, b) {
|
|
2826
|
-
if (typeof a === 'string') {
|
|
2827
|
-
return String(b);
|
|
2828
|
-
} else if (typeof a === 'number') {
|
|
2829
|
-
return Number(b);
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
|
-
return b;
|
|
2833
|
-
};
|
|
2834
|
-
|
|
2835
|
-
var condition = {
|
|
2836
|
-
'==': function _(a, b) {
|
|
2837
|
-
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2838
|
-
},
|
|
2839
|
-
'!=': function _(a, b) {
|
|
2840
|
-
return !condition['=='](a, b);
|
|
2841
|
-
},
|
|
2842
|
-
'>': function _(a, b) {
|
|
2843
|
-
return a > b;
|
|
2844
|
-
},
|
|
2845
|
-
'>=': function _(a, b) {
|
|
2846
|
-
return a >= b;
|
|
2847
|
-
},
|
|
2848
|
-
'<': function _(a, b) {
|
|
2849
|
-
return a < b;
|
|
2850
|
-
},
|
|
2851
|
-
'<=': function _(a, b) {
|
|
2852
|
-
return a <= b;
|
|
2853
|
-
},
|
|
2854
|
-
on: function on(a, b) {
|
|
2855
|
-
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2856
|
-
},
|
|
2857
|
-
notOn: function notOn(a, b) {
|
|
2858
|
-
return !condition.on(a, b);
|
|
2859
|
-
},
|
|
2860
|
-
"in": function _in(a, b) {
|
|
2861
|
-
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2862
|
-
},
|
|
2863
|
-
notIn: function notIn(a, b) {
|
|
2864
|
-
return !condition["in"](a, b);
|
|
2865
|
-
},
|
|
2866
|
-
between: function between(a, b) {
|
|
2867
|
-
return a > b[0] && a < b[1];
|
|
2868
|
-
},
|
|
2869
|
-
notBetween: function notBetween(a, b) {
|
|
2870
|
-
return a < b[0] || a > b[1];
|
|
2871
|
-
},
|
|
2872
|
-
empty: function empty(a) {
|
|
2873
|
-
return is.empty(a);
|
|
2874
|
-
},
|
|
2875
|
-
notEmpty: function notEmpty(a) {
|
|
2876
|
-
return !is.empty(a);
|
|
2877
|
-
},
|
|
2878
|
-
pattern: function pattern(a, b) {
|
|
2879
|
-
return new RegExp(b, 'g').test(a);
|
|
2880
|
-
}
|
|
2881
|
-
};
|
|
2882
|
-
function deepGet(val, split) {
|
|
2883
|
-
(Array.isArray(split) ? split : (split || '').split('.')).forEach(function (k) {
|
|
2884
|
-
if (val != null) {
|
|
2885
|
-
val = val[k];
|
|
2886
|
-
}
|
|
2887
|
-
});
|
|
2888
|
-
return val;
|
|
2889
|
-
}
|
|
2890
|
-
function extractVar(str) {
|
|
2891
|
-
var regex = /{{\s*(.*?)\s*}}/g;
|
|
2892
|
-
var match;
|
|
2893
|
-
var matches = {};
|
|
2894
|
-
|
|
2895
|
-
while ((match = regex.exec(str)) !== null) {
|
|
2896
|
-
if (match[1]) {
|
|
2897
|
-
matches[match[1]] = true;
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
return Object.keys(matches);
|
|
2902
|
-
}
|
|
2903
|
-
function convertFieldToConditions(field) {
|
|
2904
|
-
var parts = field.split('.');
|
|
2905
|
-
var conditions = [];
|
|
2906
|
-
var currentCondition = '';
|
|
2907
|
-
parts.forEach(function (part, index) {
|
|
2908
|
-
if (index === 0) {
|
|
2909
|
-
currentCondition = part;
|
|
2910
|
-
} else {
|
|
2911
|
-
currentCondition += '.' + part;
|
|
2907
|
+
created: function created() {
|
|
2908
|
+
var vm = getCurrentInstance();
|
|
2909
|
+
vm.emit('update:api', vm.setupState.fapi);
|
|
2910
|
+
vm.setupState.fc.init();
|
|
2912
2911
|
}
|
|
2913
|
-
|
|
2914
|
-
conditions.push(currentCondition);
|
|
2915
2912
|
});
|
|
2916
|
-
return conditions.join(' && ');
|
|
2917
2913
|
}
|
|
2918
2914
|
|
|
2919
2915
|
function baseRule() {
|
|
@@ -3121,8 +3117,15 @@ function Api(h) {
|
|
|
3121
3117
|
}
|
|
3122
3118
|
|
|
3123
3119
|
function props(fields, key, val) {
|
|
3124
|
-
|
|
3125
|
-
|
|
3120
|
+
if (is.Undef(fields)) {
|
|
3121
|
+
fields = Object.keys(_objectSpread2(_objectSpread2({}, h.fieldCtx), h.nameCtx));
|
|
3122
|
+
} else if (!Array.isArray(fields)) {
|
|
3123
|
+
fields = [fields];
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
fields.forEach(function (field) {
|
|
3127
|
+
var ctxs = h.fieldCtx[field] || h.nameCtx[field];
|
|
3128
|
+
ctxs && ctxs.forEach(function (ctx) {
|
|
3126
3129
|
$set(ctx.rule, key, val);
|
|
3127
3130
|
h.$render.clearCache(ctx);
|
|
3128
3131
|
});
|
|
@@ -3140,6 +3143,14 @@ function Api(h) {
|
|
|
3140
3143
|
}
|
|
3141
3144
|
|
|
3142
3145
|
var api = {
|
|
3146
|
+
get isScope() {
|
|
3147
|
+
return h.vm.props.subForm === false;
|
|
3148
|
+
},
|
|
3149
|
+
|
|
3150
|
+
get isPreview() {
|
|
3151
|
+
return h.preview;
|
|
3152
|
+
},
|
|
3153
|
+
|
|
3143
3154
|
get config() {
|
|
3144
3155
|
return h.options;
|
|
3145
3156
|
},
|
|
@@ -5651,7 +5662,7 @@ function useInput(Handler) {
|
|
|
5651
5662
|
return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
|
|
5652
5663
|
},
|
|
5653
5664
|
isQuote: function isQuote(ctx, value) {
|
|
5654
|
-
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
5665
|
+
return (value instanceof Function || is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
5655
5666
|
},
|
|
5656
5667
|
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
5657
5668
|
var _this5 = this;
|
|
@@ -6067,7 +6078,7 @@ function useContext(Handler) {
|
|
|
6067
6078
|
field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
|
|
6068
6079
|
} else if (one.field) {
|
|
6069
6080
|
field = convertFieldToConditions(one.field || '');
|
|
6070
|
-
} else {
|
|
6081
|
+
} else if (!one.mode) {
|
|
6071
6082
|
return {
|
|
6072
6083
|
v: true
|
|
6073
6084
|
};
|
|
@@ -6138,6 +6149,8 @@ function useContext(Handler) {
|
|
|
6138
6149
|
return invoke(fn, undefined);
|
|
6139
6150
|
},
|
|
6140
6151
|
computeValue: function computeValue(str, ctx, group) {
|
|
6152
|
+
var _this3 = this;
|
|
6153
|
+
|
|
6141
6154
|
var that = this;
|
|
6142
6155
|
var formulas = Object.keys(this.fc.formulas).reduce(function (obj, k) {
|
|
6143
6156
|
obj[k] = function () {
|
|
@@ -6157,34 +6170,36 @@ function useContext(Handler) {
|
|
|
6157
6170
|
|
|
6158
6171
|
return obj;
|
|
6159
6172
|
}, {});
|
|
6160
|
-
return
|
|
6173
|
+
return invoke(function () {
|
|
6174
|
+
return new Function('$formulas', '$form', '$scope', '$group', '$rule', '$api', "with($form){with($scope){with(this){with($group){with($formulas){ return ".concat(str, " }}}}}")).call(_this3.api.form, formulas, _this3.api.top.form, _this3.api.top === _this3.api.scope ? {} : _this3.api.scope.form, group ? _this3.subRuleData[group.id] || {} : {}, ctx.rule, _this3.api);
|
|
6175
|
+
}, undefined);
|
|
6161
6176
|
},
|
|
6162
6177
|
updateChildren: function updateChildren(ctx, n, o) {
|
|
6163
|
-
var
|
|
6178
|
+
var _this4 = this;
|
|
6164
6179
|
|
|
6165
6180
|
this.deferSyncValue(function () {
|
|
6166
6181
|
o && o.forEach(function (child) {
|
|
6167
6182
|
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx) {
|
|
6168
|
-
|
|
6183
|
+
_this4.rmCtx(child.__fc__);
|
|
6169
6184
|
}
|
|
6170
6185
|
});
|
|
6171
6186
|
|
|
6172
6187
|
if (is.trueArray(n)) {
|
|
6173
|
-
|
|
6188
|
+
_this4.loadChildren(n, ctx);
|
|
6174
6189
|
|
|
6175
|
-
|
|
6190
|
+
_this4.bus.$emit('update', _this4.api);
|
|
6176
6191
|
}
|
|
6177
6192
|
});
|
|
6178
6193
|
},
|
|
6179
6194
|
rmSub: function rmSub(sub) {
|
|
6180
|
-
var
|
|
6195
|
+
var _this5 = this;
|
|
6181
6196
|
|
|
6182
6197
|
is.trueArray(sub) && sub.forEach(function (r) {
|
|
6183
|
-
r && r.__fc__ &&
|
|
6198
|
+
r && r.__fc__ && _this5.rmCtx(r.__fc__);
|
|
6184
6199
|
});
|
|
6185
6200
|
},
|
|
6186
6201
|
rmCtx: function rmCtx(ctx) {
|
|
6187
|
-
var
|
|
6202
|
+
var _this6 = this;
|
|
6188
6203
|
|
|
6189
6204
|
if (ctx.deleted) return;
|
|
6190
6205
|
var id = ctx.id,
|
|
@@ -6213,19 +6228,19 @@ function useContext(Handler) {
|
|
|
6213
6228
|
}
|
|
6214
6229
|
|
|
6215
6230
|
this.deferSyncValue(function () {
|
|
6216
|
-
if (!
|
|
6231
|
+
if (!_this6.reloading) {
|
|
6217
6232
|
if (ctx.parser.loadChildren !== false) {
|
|
6218
6233
|
var children = ctx.getPending('children', ctx.rule.children);
|
|
6219
6234
|
|
|
6220
6235
|
if (is.trueArray(children)) {
|
|
6221
6236
|
children.forEach(function (h) {
|
|
6222
|
-
return h.__fc__ &&
|
|
6237
|
+
return h.__fc__ && _this6.rmCtx(h.__fc__);
|
|
6223
6238
|
});
|
|
6224
6239
|
}
|
|
6225
6240
|
}
|
|
6226
6241
|
|
|
6227
|
-
if (ctx.root ===
|
|
6228
|
-
|
|
6242
|
+
if (ctx.root === _this6.rules) {
|
|
6243
|
+
_this6.vm.setupState.renderRule();
|
|
6229
6244
|
}
|
|
6230
6245
|
}
|
|
6231
6246
|
}, input);
|
|
@@ -6487,7 +6502,13 @@ function Handler(fc) {
|
|
|
6487
6502
|
return fc.bus;
|
|
6488
6503
|
},
|
|
6489
6504
|
preview: function preview() {
|
|
6490
|
-
|
|
6505
|
+
if (fc.vm.props.preview != null) {
|
|
6506
|
+
return fc.vm.props.preview;
|
|
6507
|
+
} else if (fc.vm.setupState.parent && fc.vm.setupState.parent.props.preview != null) {
|
|
6508
|
+
return fc.vm.setupState.parent.props.preview;
|
|
6509
|
+
}
|
|
6510
|
+
|
|
6511
|
+
return fc.options.value.preview || false;
|
|
6491
6512
|
}
|
|
6492
6513
|
});
|
|
6493
6514
|
extend(this, {
|
|
@@ -6592,7 +6613,7 @@ extend(Handler.prototype, {
|
|
|
6592
6613
|
}
|
|
6593
6614
|
}).then(function () {
|
|
6594
6615
|
return _this3.globalBeforeFetch(opt);
|
|
6595
|
-
});
|
|
6616
|
+
})["catch"](function () {});
|
|
6596
6617
|
}
|
|
6597
6618
|
});
|
|
6598
6619
|
useInject(Handler);
|
|
@@ -6794,57 +6815,61 @@ var loadData = function loadData(fc) {
|
|
|
6794
6815
|
var loadData = {
|
|
6795
6816
|
name: 'loadData',
|
|
6796
6817
|
_fn: [],
|
|
6797
|
-
|
|
6798
|
-
this
|
|
6799
|
-
var attrs = toArray(inject.getValue());
|
|
6800
|
-
var unwatchs = [];
|
|
6801
|
-
attrs.forEach(function (attr) {
|
|
6802
|
-
if (attr && (attr.attr || attr.template)) {
|
|
6803
|
-
var fn = function fn(get) {
|
|
6804
|
-
var value;
|
|
6818
|
+
loaded: function loaded(inject, rule, api) {
|
|
6819
|
+
var _this = this;
|
|
6805
6820
|
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6821
|
+
this.deleted(inject);
|
|
6822
|
+
nextTick(function () {
|
|
6823
|
+
var attrs = toArray(inject.getValue());
|
|
6824
|
+
var unwatchs = [];
|
|
6825
|
+
attrs.forEach(function (attr) {
|
|
6826
|
+
if (attr && (attr.attr || attr.template)) {
|
|
6827
|
+
var fn = function fn(get) {
|
|
6828
|
+
var value;
|
|
6829
|
+
|
|
6830
|
+
if (attr.template) {
|
|
6831
|
+
value = fc.$handle.loadStrVar(attr.template, get);
|
|
6832
|
+
} else if (attr.handler && is.Function(attr.handler)) {
|
|
6833
|
+
value = attr.handler(get, rule, api);
|
|
6834
|
+
} else {
|
|
6835
|
+
value = get(attr.attr, attr["default"]);
|
|
6836
|
+
}
|
|
6813
6837
|
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6838
|
+
if (attr.copy !== false) {
|
|
6839
|
+
value = deepCopy(value);
|
|
6840
|
+
}
|
|
6817
6841
|
|
|
6818
|
-
|
|
6842
|
+
var _rule = attr.modify ? rule : inject.getProp();
|
|
6819
6843
|
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6844
|
+
if (attr.to === 'child') {
|
|
6845
|
+
if (_rule.children) {
|
|
6846
|
+
_rule.children[0] = value;
|
|
6847
|
+
} else {
|
|
6848
|
+
_rule.children = [value];
|
|
6849
|
+
}
|
|
6823
6850
|
} else {
|
|
6824
|
-
_rule.
|
|
6851
|
+
deepSet(_rule, attr.to || 'options', value);
|
|
6825
6852
|
}
|
|
6826
|
-
} else {
|
|
6827
|
-
deepSet(_rule, attr.to || 'options', value);
|
|
6828
|
-
}
|
|
6829
6853
|
|
|
6830
|
-
|
|
6831
|
-
|
|
6854
|
+
api.sync(rule);
|
|
6855
|
+
};
|
|
6832
6856
|
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6857
|
+
var callback = function callback(get) {
|
|
6858
|
+
return fn(get);
|
|
6859
|
+
};
|
|
6836
6860
|
|
|
6837
|
-
|
|
6838
|
-
|
|
6861
|
+
var unwatch = fc.watchLoadData(callback);
|
|
6862
|
+
fn = debounce(fn, attr.wait || 300);
|
|
6839
6863
|
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6864
|
+
if (attr.watch !== false) {
|
|
6865
|
+
unwatchs.push(unwatch);
|
|
6866
|
+
} else {
|
|
6867
|
+
unwatch();
|
|
6868
|
+
}
|
|
6844
6869
|
}
|
|
6845
|
-
}
|
|
6870
|
+
});
|
|
6871
|
+
_this._fn[inject.id] = unwatchs;
|
|
6846
6872
|
});
|
|
6847
|
-
this._fn[inject.id] = unwatchs;
|
|
6848
6873
|
},
|
|
6849
6874
|
deleted: function deleted(inject) {
|
|
6850
6875
|
if (this._fn[inject.id]) {
|
|
@@ -6858,7 +6883,7 @@ var loadData = function loadData(fc) {
|
|
|
6858
6883
|
inject.clearProp();
|
|
6859
6884
|
}
|
|
6860
6885
|
};
|
|
6861
|
-
loadData.watch = loadData.
|
|
6886
|
+
loadData.watch = loadData.loaded;
|
|
6862
6887
|
return loadData;
|
|
6863
6888
|
};
|
|
6864
6889
|
|
|
@@ -7071,7 +7096,6 @@ var fetch = function fetch(fc) {
|
|
|
7071
7096
|
}
|
|
7072
7097
|
|
|
7073
7098
|
set(fn(body, rule, api));
|
|
7074
|
-
api.sync(rule);
|
|
7075
7099
|
},
|
|
7076
7100
|
onError: function onError(e) {
|
|
7077
7101
|
set(undefined);
|
|
@@ -7788,7 +7812,7 @@ function FormCreateFactory(config) {
|
|
|
7788
7812
|
}
|
|
7789
7813
|
});
|
|
7790
7814
|
this.unwatch.push(unwatch);
|
|
7791
|
-
return val;
|
|
7815
|
+
return deepGet(val, split);
|
|
7792
7816
|
}
|
|
7793
7817
|
}
|
|
7794
7818
|
},
|
|
@@ -8783,7 +8807,9 @@ function extendApi(api, h) {
|
|
|
8783
8807
|
return new Promise(function (resolve, reject) {
|
|
8784
8808
|
var forms = api.children;
|
|
8785
8809
|
var all = [h.$manager.validate()];
|
|
8786
|
-
forms.
|
|
8810
|
+
forms.filter(function (v) {
|
|
8811
|
+
return !v.isScope;
|
|
8812
|
+
}).forEach(function (v) {
|
|
8787
8813
|
all.push(v.validate());
|
|
8788
8814
|
});
|
|
8789
8815
|
Promise.all(all).then(function () {
|
|
@@ -8804,7 +8830,9 @@ function extendApi(api, h) {
|
|
|
8804
8830
|
if (!ctx) return;
|
|
8805
8831
|
var sub = h.subForm[ctx.id];
|
|
8806
8832
|
var all = [h.$manager.validateField(ctx.id)];
|
|
8807
|
-
toArray(sub).
|
|
8833
|
+
toArray(sub).filter(function (v) {
|
|
8834
|
+
return !v.isScope;
|
|
8835
|
+
}).forEach(function (v) {
|
|
8808
8836
|
all.push(v.validate());
|
|
8809
8837
|
});
|
|
8810
8838
|
Promise.all(all).then(function () {
|
|
@@ -8907,7 +8935,8 @@ function extendApi(api, h) {
|
|
|
8907
8935
|
},
|
|
8908
8936
|
submit: function submit(successFn, failFn) {
|
|
8909
8937
|
return new Promise(function (resolve, reject) {
|
|
8910
|
-
|
|
8938
|
+
var promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
|
|
8939
|
+
promise.then(function () {
|
|
8911
8940
|
var formData = api.formData();
|
|
8912
8941
|
is.Function(successFn) && invoke(function () {
|
|
8913
8942
|
return successFn(formData, api);
|
|
@@ -9023,7 +9052,7 @@ function install(FormCreate) {
|
|
|
9023
9052
|
function elmFormCreate() {
|
|
9024
9053
|
return FormCreateFactory({
|
|
9025
9054
|
ui: 'element-ui',
|
|
9026
|
-
version: '3.2.
|
|
9055
|
+
version: '3.2.21',
|
|
9027
9056
|
manager: manager,
|
|
9028
9057
|
extendApi: extendApi,
|
|
9029
9058
|
install: install,
|