@form-create/element-ui 2.5.35 → 2.5.36
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.js +270 -173
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +11 -11
- package/src/core/manager.js +2 -2
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v2.5.
|
|
2
|
+
* @form-create/element-ui v2.5.36
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -1935,7 +1935,10 @@
|
|
|
1935
1935
|
}
|
|
1936
1936
|
},
|
|
1937
1937
|
extendOption: Boolean,
|
|
1938
|
-
disabled:
|
|
1938
|
+
disabled: {
|
|
1939
|
+
type: Boolean,
|
|
1940
|
+
"default": undefined
|
|
1941
|
+
},
|
|
1939
1942
|
value: Object,
|
|
1940
1943
|
api: Object,
|
|
1941
1944
|
name: String,
|
|
@@ -1998,8 +2001,8 @@
|
|
|
1998
2001
|
this.formCreate.$handle.reloadRule(n);
|
|
1999
2002
|
this._renderRule();
|
|
2000
2003
|
},
|
|
2001
|
-
disabled: function disabled(
|
|
2002
|
-
this.$f.
|
|
2004
|
+
disabled: function disabled() {
|
|
2005
|
+
this.$f.refresh();
|
|
2003
2006
|
}
|
|
2004
2007
|
},
|
|
2005
2008
|
beforeCreate: function beforeCreate() {
|
|
@@ -2144,7 +2147,7 @@
|
|
|
2144
2147
|
var $TX = '$FNX:';
|
|
2145
2148
|
var FUNCTION = 'function';
|
|
2146
2149
|
function toJson(obj, space) {
|
|
2147
|
-
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
2150
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2148
2151
|
if (val && val._isVue === true) return undefined;
|
|
2149
2152
|
if (_typeof(val) !== FUNCTION) {
|
|
2150
2153
|
return val;
|
|
@@ -2255,6 +2258,61 @@
|
|
|
2255
2258
|
}
|
|
2256
2259
|
return def;
|
|
2257
2260
|
}
|
|
2261
|
+
var changeType = function changeType(a, b) {
|
|
2262
|
+
if (typeof a === 'string') {
|
|
2263
|
+
return String(b);
|
|
2264
|
+
} else if (typeof a === 'number') {
|
|
2265
|
+
return Number(b);
|
|
2266
|
+
}
|
|
2267
|
+
return b;
|
|
2268
|
+
};
|
|
2269
|
+
var condition = {
|
|
2270
|
+
'==': function _(a, b) {
|
|
2271
|
+
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2272
|
+
},
|
|
2273
|
+
'!=': function _(a, b) {
|
|
2274
|
+
return !condition['=='](a, b);
|
|
2275
|
+
},
|
|
2276
|
+
'>': function _(a, b) {
|
|
2277
|
+
return a > b;
|
|
2278
|
+
},
|
|
2279
|
+
'>=': function _(a, b) {
|
|
2280
|
+
return a >= b;
|
|
2281
|
+
},
|
|
2282
|
+
'<': function _(a, b) {
|
|
2283
|
+
return a < b;
|
|
2284
|
+
},
|
|
2285
|
+
'<=': function _(a, b) {
|
|
2286
|
+
return a <= b;
|
|
2287
|
+
},
|
|
2288
|
+
on: function on(a, b) {
|
|
2289
|
+
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2290
|
+
},
|
|
2291
|
+
notOn: function notOn(a, b) {
|
|
2292
|
+
return !condition.on(a, b);
|
|
2293
|
+
},
|
|
2294
|
+
"in": function _in(a, b) {
|
|
2295
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2296
|
+
},
|
|
2297
|
+
notIn: function notIn(a, b) {
|
|
2298
|
+
return !condition["in"](a, b);
|
|
2299
|
+
},
|
|
2300
|
+
between: function between(a, b) {
|
|
2301
|
+
return a > b[0] && a < b[1];
|
|
2302
|
+
},
|
|
2303
|
+
notBetween: function notBetween(a, b) {
|
|
2304
|
+
return a < b[0] || a > b[1];
|
|
2305
|
+
},
|
|
2306
|
+
empty: function empty(a) {
|
|
2307
|
+
return is.empty(a);
|
|
2308
|
+
},
|
|
2309
|
+
notEmpty: function notEmpty(a) {
|
|
2310
|
+
return !is.empty(a);
|
|
2311
|
+
},
|
|
2312
|
+
pattern: function pattern(a, b) {
|
|
2313
|
+
return new RegExp(b, 'g').test(a);
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2258
2316
|
|
|
2259
2317
|
function baseRule() {
|
|
2260
2318
|
return {
|
|
@@ -2336,6 +2394,92 @@
|
|
|
2336
2394
|
};
|
|
2337
2395
|
}
|
|
2338
2396
|
|
|
2397
|
+
function getError(action, option, xhr) {
|
|
2398
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2399
|
+
var err = new Error(msg);
|
|
2400
|
+
err.status = xhr.status;
|
|
2401
|
+
err.url = action;
|
|
2402
|
+
return err;
|
|
2403
|
+
}
|
|
2404
|
+
function getBody(xhr) {
|
|
2405
|
+
var text = xhr.responseText || xhr.response;
|
|
2406
|
+
if (!text) {
|
|
2407
|
+
return text;
|
|
2408
|
+
}
|
|
2409
|
+
try {
|
|
2410
|
+
return JSON.parse(text);
|
|
2411
|
+
} catch (e) {
|
|
2412
|
+
return text;
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
function fetch(option) {
|
|
2416
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
var xhr = new XMLHttpRequest();
|
|
2420
|
+
var action = option.action;
|
|
2421
|
+
xhr.onerror = function error(e) {
|
|
2422
|
+
option.onError(e);
|
|
2423
|
+
};
|
|
2424
|
+
xhr.onload = function onload() {
|
|
2425
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2426
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2427
|
+
}
|
|
2428
|
+
option.onSuccess(getBody(xhr));
|
|
2429
|
+
};
|
|
2430
|
+
xhr.open(option.method || 'get', action, true);
|
|
2431
|
+
var formData;
|
|
2432
|
+
if (option.data) {
|
|
2433
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2434
|
+
formData = new FormData();
|
|
2435
|
+
Object.keys(option.data).map(function (key) {
|
|
2436
|
+
formData.append(key, option.data[key]);
|
|
2437
|
+
});
|
|
2438
|
+
} else {
|
|
2439
|
+
formData = JSON.stringify(option.data);
|
|
2440
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2444
|
+
xhr.withCredentials = true;
|
|
2445
|
+
}
|
|
2446
|
+
var headers = option.headers || {};
|
|
2447
|
+
Object.keys(headers).forEach(function (item) {
|
|
2448
|
+
if (headers[item] !== null) {
|
|
2449
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
xhr.send(formData);
|
|
2453
|
+
}
|
|
2454
|
+
function asyncFetch(config) {
|
|
2455
|
+
return new Promise(function (resolve, reject) {
|
|
2456
|
+
fetch(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2457
|
+
onSuccess: function onSuccess(res) {
|
|
2458
|
+
var fn = function fn(v) {
|
|
2459
|
+
return v;
|
|
2460
|
+
};
|
|
2461
|
+
var parse = parseFn(config.parse);
|
|
2462
|
+
if (is.Function(parse)) {
|
|
2463
|
+
fn = parse;
|
|
2464
|
+
} else if (parse && is.String(parse)) {
|
|
2465
|
+
fn = function fn(v) {
|
|
2466
|
+
parse.split('.').forEach(function (k) {
|
|
2467
|
+
if (v) {
|
|
2468
|
+
v = v[k];
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
return v;
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
resolve(fn(res));
|
|
2475
|
+
},
|
|
2476
|
+
onError: function onError(err) {
|
|
2477
|
+
reject(err);
|
|
2478
|
+
}
|
|
2479
|
+
}));
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2339
2483
|
function copy(value) {
|
|
2340
2484
|
return deepCopy(value);
|
|
2341
2485
|
}
|
|
@@ -2617,6 +2761,21 @@
|
|
|
2617
2761
|
return origin ? ctx.origin : ctx.rule;
|
|
2618
2762
|
}
|
|
2619
2763
|
},
|
|
2764
|
+
getRenderRule: function getRenderRule(id) {
|
|
2765
|
+
var ctx = h.getCtx(id);
|
|
2766
|
+
if (ctx) {
|
|
2767
|
+
return ctx.prop;
|
|
2768
|
+
}
|
|
2769
|
+
},
|
|
2770
|
+
getRefRule: function getRefRule(id) {
|
|
2771
|
+
var ctxs = h.getCtxs(id);
|
|
2772
|
+
if (ctxs && ctxs.length) {
|
|
2773
|
+
var rules = ctxs.map(function (ctx) {
|
|
2774
|
+
return ctx.rule;
|
|
2775
|
+
});
|
|
2776
|
+
return rules.length === 1 ? rules[0] : rules;
|
|
2777
|
+
}
|
|
2778
|
+
},
|
|
2620
2779
|
setEffect: function setEffect(id, attr, value) {
|
|
2621
2780
|
var ctx = h.getCtx(id);
|
|
2622
2781
|
if (ctx && attr) {
|
|
@@ -2723,12 +2882,23 @@
|
|
|
2723
2882
|
deferSyncValue: function deferSyncValue(fn, sync) {
|
|
2724
2883
|
h.deferSyncValue(fn, sync);
|
|
2725
2884
|
},
|
|
2885
|
+
fetch: function fetch(opt) {
|
|
2886
|
+
h.options.beforeFetch && invoke(function () {
|
|
2887
|
+
return h.options.beforeFetch(opt, {
|
|
2888
|
+
api: api
|
|
2889
|
+
});
|
|
2890
|
+
});
|
|
2891
|
+
return asyncFetch(opt);
|
|
2892
|
+
},
|
|
2893
|
+
getData: function getData(id, def) {
|
|
2894
|
+
return hasProperty(h.fc.loadData, id) ? h.fc.loadData[id] : def;
|
|
2895
|
+
},
|
|
2726
2896
|
helper: {
|
|
2727
2897
|
tidyFields: tidyFields,
|
|
2728
2898
|
props: props
|
|
2729
2899
|
}
|
|
2730
2900
|
};
|
|
2731
|
-
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2901
|
+
['on', 'once', 'off', 'set', 'emit'].forEach(function (n) {
|
|
2732
2902
|
api[n] = function () {
|
|
2733
2903
|
var _h$vm2;
|
|
2734
2904
|
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
@@ -3114,6 +3284,7 @@
|
|
|
3114
3284
|
children: [],
|
|
3115
3285
|
prop: {},
|
|
3116
3286
|
preview: false,
|
|
3287
|
+
id: ctx.id,
|
|
3117
3288
|
field: ctx.field,
|
|
3118
3289
|
rule: ctx.rule,
|
|
3119
3290
|
input: ctx.input
|
|
@@ -3133,13 +3304,13 @@
|
|
|
3133
3304
|
});
|
|
3134
3305
|
return inject;
|
|
3135
3306
|
},
|
|
3136
|
-
ctxProp: function ctxProp(ctx
|
|
3307
|
+
ctxProp: function ctxProp(ctx) {
|
|
3137
3308
|
var _this8 = this;
|
|
3138
3309
|
var ref = ctx.ref,
|
|
3139
3310
|
key = ctx.key,
|
|
3140
3311
|
rule = ctx.rule;
|
|
3141
|
-
this.$manager.mergeProp(ctx
|
|
3142
|
-
ctx.parser.mergeProp(ctx
|
|
3312
|
+
this.$manager.mergeProp(ctx);
|
|
3313
|
+
ctx.parser.mergeProp(ctx);
|
|
3143
3314
|
var props = [{
|
|
3144
3315
|
ref: ref,
|
|
3145
3316
|
key: rule.key || "".concat(key, "fc"),
|
|
@@ -3159,7 +3330,10 @@
|
|
|
3159
3330
|
}
|
|
3160
3331
|
}
|
|
3161
3332
|
}];
|
|
3162
|
-
if (
|
|
3333
|
+
if (ctx.input) {
|
|
3334
|
+
if (this.vm.$props.disabled !== undefined) {
|
|
3335
|
+
ctx.prop.props.disabled = !!this.vm.$props.disabled;
|
|
3336
|
+
}
|
|
3163
3337
|
ctx.prop.model = {
|
|
3164
3338
|
value: this.$handle.getFormData(ctx),
|
|
3165
3339
|
callback: function callback(value) {
|
|
@@ -3317,16 +3491,17 @@
|
|
|
3317
3491
|
inject = rule.inject;
|
|
3318
3492
|
var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
|
|
3319
3493
|
if (is.trueArray(emit)) {
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3494
|
+
emit.forEach(function (eventName) {
|
|
3495
|
+
if (!eventName) return;
|
|
3496
|
+
var eventInject;
|
|
3497
|
+
var emitKey = emitPrefix || field || name;
|
|
3498
|
+
if (is.Object(eventName)) {
|
|
3499
|
+
eventInject = eventName.inject;
|
|
3500
|
+
eventName = eventName.name;
|
|
3501
|
+
emitKey = eventName.prefix || emitKey;
|
|
3502
|
+
}
|
|
3503
|
+
if (emitKey) {
|
|
3504
|
+
if (!on) emitKey = "native-".concat(emitKey);
|
|
3330
3505
|
var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
|
|
3331
3506
|
var fn = function fn() {
|
|
3332
3507
|
var _this2$vm, _this2$vm2;
|
|
@@ -3343,8 +3518,8 @@
|
|
|
3343
3518
|
var _inject = eventInject || inject || _this2.options.injectEvent;
|
|
3344
3519
|
event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
|
|
3345
3520
|
}
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3348
3523
|
}
|
|
3349
3524
|
ctx.computed[on ? 'on' : 'nativeOn'] = event;
|
|
3350
3525
|
return event;
|
|
@@ -3520,6 +3695,30 @@
|
|
|
3520
3695
|
return _this.payload[k];
|
|
3521
3696
|
})), [this.computed]));
|
|
3522
3697
|
},
|
|
3698
|
+
injectValidate: function injectValidate() {
|
|
3699
|
+
var _this2 = this;
|
|
3700
|
+
return toArray(this.prop.validate).map(function (item) {
|
|
3701
|
+
if (is.Function(item.validator)) {
|
|
3702
|
+
var temp = _objectSpread2({}, item);
|
|
3703
|
+
var that = _this2;
|
|
3704
|
+
temp.validator = function () {
|
|
3705
|
+
var _item$validator;
|
|
3706
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3707
|
+
args[_key] = arguments[_key];
|
|
3708
|
+
}
|
|
3709
|
+
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
3710
|
+
that: this,
|
|
3711
|
+
id: that.id,
|
|
3712
|
+
field: that.field,
|
|
3713
|
+
rule: that.rule,
|
|
3714
|
+
api: that.$handle.api
|
|
3715
|
+
}].concat(args));
|
|
3716
|
+
};
|
|
3717
|
+
return temp;
|
|
3718
|
+
}
|
|
3719
|
+
return item;
|
|
3720
|
+
});
|
|
3721
|
+
},
|
|
3523
3722
|
check: function check(handle) {
|
|
3524
3723
|
return this.vm === handle.vm;
|
|
3525
3724
|
},
|
|
@@ -3568,12 +3767,12 @@
|
|
|
3568
3767
|
this.ctrlRule = [];
|
|
3569
3768
|
},
|
|
3570
3769
|
rm: function rm() {
|
|
3571
|
-
var
|
|
3770
|
+
var _this3 = this;
|
|
3572
3771
|
var _rm = function _rm() {
|
|
3573
|
-
var index =
|
|
3772
|
+
var index = _this3.root.indexOf(_this3.origin);
|
|
3574
3773
|
if (index > -1) {
|
|
3575
|
-
|
|
3576
|
-
|
|
3774
|
+
_this3.root.splice(index, 1);
|
|
3775
|
+
_this3.$handle && _this3.$handle.refresh();
|
|
3577
3776
|
}
|
|
3578
3777
|
};
|
|
3579
3778
|
if (this.deleted) {
|
|
@@ -3581,14 +3780,14 @@
|
|
|
3581
3780
|
return;
|
|
3582
3781
|
}
|
|
3583
3782
|
this.$handle.noWatch(function () {
|
|
3584
|
-
|
|
3585
|
-
|
|
3783
|
+
_this3.$handle.deferSyncValue(function () {
|
|
3784
|
+
_this3.rmCtrl();
|
|
3586
3785
|
_rm();
|
|
3587
|
-
|
|
3588
|
-
extend(
|
|
3786
|
+
_this3.$handle.rmCtx(_this3);
|
|
3787
|
+
extend(_this3, {
|
|
3589
3788
|
root: []
|
|
3590
3789
|
});
|
|
3591
|
-
},
|
|
3790
|
+
}, _this3.input);
|
|
3592
3791
|
});
|
|
3593
3792
|
},
|
|
3594
3793
|
update: function update(handle, init) {
|
|
@@ -3609,73 +3808,6 @@
|
|
|
3609
3808
|
}
|
|
3610
3809
|
});
|
|
3611
3810
|
|
|
3612
|
-
var condition = {
|
|
3613
|
-
'==': function _(b) {
|
|
3614
|
-
return function (a) {
|
|
3615
|
-
return a === b;
|
|
3616
|
-
};
|
|
3617
|
-
},
|
|
3618
|
-
'!=': function _(b) {
|
|
3619
|
-
return function (a) {
|
|
3620
|
-
return a !== b;
|
|
3621
|
-
};
|
|
3622
|
-
},
|
|
3623
|
-
'<>': function _(b) {
|
|
3624
|
-
return function (a) {
|
|
3625
|
-
return a !== b;
|
|
3626
|
-
};
|
|
3627
|
-
},
|
|
3628
|
-
'>': function _(b) {
|
|
3629
|
-
return function (a) {
|
|
3630
|
-
return a > b;
|
|
3631
|
-
};
|
|
3632
|
-
},
|
|
3633
|
-
'>=': function _(b) {
|
|
3634
|
-
return function (a) {
|
|
3635
|
-
return a >= b;
|
|
3636
|
-
};
|
|
3637
|
-
},
|
|
3638
|
-
'<': function _(b) {
|
|
3639
|
-
return function (a) {
|
|
3640
|
-
return a < b;
|
|
3641
|
-
};
|
|
3642
|
-
},
|
|
3643
|
-
'<=': function _(b) {
|
|
3644
|
-
return function (a) {
|
|
3645
|
-
return a <= b;
|
|
3646
|
-
};
|
|
3647
|
-
},
|
|
3648
|
-
'in': function _in(b) {
|
|
3649
|
-
return function (a) {
|
|
3650
|
-
return b && b.indexOf && b.indexOf(a) > -1;
|
|
3651
|
-
};
|
|
3652
|
-
},
|
|
3653
|
-
'on': function on(b) {
|
|
3654
|
-
return function (a) {
|
|
3655
|
-
return a && a.indexOf && a.indexOf(b) > -1;
|
|
3656
|
-
};
|
|
3657
|
-
},
|
|
3658
|
-
'notIn': function notIn(b) {
|
|
3659
|
-
return function (a) {
|
|
3660
|
-
return !condition["in"](b)(a);
|
|
3661
|
-
};
|
|
3662
|
-
},
|
|
3663
|
-
'notOn': function notOn(b) {
|
|
3664
|
-
return function (a) {
|
|
3665
|
-
return !condition.on(b)(a);
|
|
3666
|
-
};
|
|
3667
|
-
},
|
|
3668
|
-
'between': function between(b) {
|
|
3669
|
-
return function (a) {
|
|
3670
|
-
return a > b[0] && a < b[1];
|
|
3671
|
-
};
|
|
3672
|
-
},
|
|
3673
|
-
'notBetween': function notBetween(b) {
|
|
3674
|
-
return function (a) {
|
|
3675
|
-
return a < b[0] || a > b[1];
|
|
3676
|
-
};
|
|
3677
|
-
}
|
|
3678
|
-
};
|
|
3679
3811
|
function useLoader(Handler) {
|
|
3680
3812
|
extend(Handler.prototype, {
|
|
3681
3813
|
nextRefresh: function nextRefresh(fn) {
|
|
@@ -3827,7 +3959,7 @@
|
|
|
3827
3959
|
}
|
|
3828
3960
|
if (!ctx) {
|
|
3829
3961
|
var _rule2 = _this6.parseRule(_rule);
|
|
3830
|
-
ctx = new RuleContext(_this6, _rule2,
|
|
3962
|
+
ctx = new RuleContext(_this6, _rule2, defaultValue);
|
|
3831
3963
|
_this6.bindParser(ctx);
|
|
3832
3964
|
} else {
|
|
3833
3965
|
if (ctx.originType !== ctx.rule.type) {
|
|
@@ -3880,7 +4012,9 @@
|
|
|
3880
4012
|
if (!controls.length) return false;
|
|
3881
4013
|
var _loop = function _loop(i) {
|
|
3882
4014
|
var control = controls[i],
|
|
3883
|
-
handleFn = control.handle ||
|
|
4015
|
+
handleFn = control.handle || function (val) {
|
|
4016
|
+
return (condition[control.condition || '=='] || condition['=='])(val, control.value);
|
|
4017
|
+
};
|
|
3884
4018
|
if (!is.trueArray(control.rule)) return "continue";
|
|
3885
4019
|
var data = _objectSpread2(_objectSpread2({}, control), {}, {
|
|
3886
4020
|
valid: invoke(function () {
|
|
@@ -4042,6 +4176,11 @@
|
|
|
4042
4176
|
this.valueChange(ctx, value);
|
|
4043
4177
|
this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
4044
4178
|
this.effect(ctx, 'value');
|
|
4179
|
+
this.emitEvent('change', ctx.field, value, {
|
|
4180
|
+
rule: ctx.origin,
|
|
4181
|
+
api: this.api,
|
|
4182
|
+
setFlag: setFlag || false
|
|
4183
|
+
});
|
|
4045
4184
|
},
|
|
4046
4185
|
onInput: function onInput(ctx, value) {
|
|
4047
4186
|
var val;
|
|
@@ -4138,12 +4277,13 @@
|
|
|
4138
4277
|
isQuote: function isQuote(ctx, value) {
|
|
4139
4278
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
4140
4279
|
},
|
|
4141
|
-
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
4280
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
4142
4281
|
var _this4 = this;
|
|
4143
4282
|
if (is.Function(ctx.rule.update)) {
|
|
4144
4283
|
var state = invoke(function () {
|
|
4145
4284
|
return ctx.rule.update(val, ctx.origin, _this4.api, {
|
|
4146
|
-
origin: origin || 'change'
|
|
4285
|
+
origin: origin || 'change',
|
|
4286
|
+
linkField: field
|
|
4147
4287
|
});
|
|
4148
4288
|
});
|
|
4149
4289
|
if (state === undefined) return;
|
|
@@ -4154,21 +4294,21 @@
|
|
|
4154
4294
|
this.refreshRule(ctx, val);
|
|
4155
4295
|
this.bus.$emit('change-' + ctx.field, val);
|
|
4156
4296
|
},
|
|
4157
|
-
refreshRule: function refreshRule(ctx, val, origin) {
|
|
4297
|
+
refreshRule: function refreshRule(ctx, val, origin, field) {
|
|
4158
4298
|
if (this.refreshControl(ctx)) {
|
|
4159
4299
|
this.$render.clearCacheAll();
|
|
4160
4300
|
this.loadRule();
|
|
4161
4301
|
this.vm.$emit('update', this.api);
|
|
4162
4302
|
this.refresh();
|
|
4163
4303
|
}
|
|
4164
|
-
this.refreshUpdate(ctx, val, origin);
|
|
4304
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
4165
4305
|
},
|
|
4166
4306
|
appendLink: function appendLink(ctx) {
|
|
4167
4307
|
var _this5 = this;
|
|
4168
4308
|
var link = ctx.rule.link;
|
|
4169
4309
|
is.trueArray(link) && link.forEach(function (field) {
|
|
4170
4310
|
var fn = function fn() {
|
|
4171
|
-
return _this5.refreshRule(ctx, ctx.rule.value, 'link');
|
|
4311
|
+
return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
4172
4312
|
};
|
|
4173
4313
|
_this5.bus.$on('change-' + field, fn);
|
|
4174
4314
|
ctx.linkOn.push(function () {
|
|
@@ -4399,12 +4539,22 @@
|
|
|
4399
4539
|
}
|
|
4400
4540
|
},
|
|
4401
4541
|
lifecycle: function lifecycle(name) {
|
|
4402
|
-
var _this2 = this;
|
|
4403
|
-
var fn = this.options[name];
|
|
4404
|
-
is.Function(fn) && invoke(function () {
|
|
4405
|
-
return fn(_this2.api);
|
|
4406
|
-
});
|
|
4407
4542
|
this.vm.$emit(name, this.api);
|
|
4543
|
+
this.emitEvent(name, this.api);
|
|
4544
|
+
},
|
|
4545
|
+
emitEvent: function emitEvent(name) {
|
|
4546
|
+
var _this$bus;
|
|
4547
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4548
|
+
args[_key - 1] = arguments[_key];
|
|
4549
|
+
}
|
|
4550
|
+
var _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
4551
|
+
if (_fn) {
|
|
4552
|
+
var fn = parseFn(_fn);
|
|
4553
|
+
is.Function(fn) && invoke(function () {
|
|
4554
|
+
return fn.apply(void 0, args);
|
|
4555
|
+
});
|
|
4556
|
+
}
|
|
4557
|
+
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
4408
4558
|
}
|
|
4409
4559
|
});
|
|
4410
4560
|
}
|
|
@@ -4606,6 +4756,7 @@
|
|
|
4606
4756
|
this.usePage();
|
|
4607
4757
|
this.loadRule();
|
|
4608
4758
|
this.$manager.__init();
|
|
4759
|
+
this.lifecycle('created');
|
|
4609
4760
|
this.vm.$set(this.vm, 'formData', this.formData);
|
|
4610
4761
|
}
|
|
4611
4762
|
});
|
|
@@ -4618,64 +4769,6 @@
|
|
|
4618
4769
|
useLifecycle(Handler);
|
|
4619
4770
|
useEffect(Handler);
|
|
4620
4771
|
|
|
4621
|
-
function getError(action, option, xhr) {
|
|
4622
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
4623
|
-
var err = new Error(msg);
|
|
4624
|
-
err.status = xhr.status;
|
|
4625
|
-
err.url = action;
|
|
4626
|
-
return err;
|
|
4627
|
-
}
|
|
4628
|
-
function getBody(xhr) {
|
|
4629
|
-
var text = xhr.responseText || xhr.response;
|
|
4630
|
-
if (!text) {
|
|
4631
|
-
return text;
|
|
4632
|
-
}
|
|
4633
|
-
try {
|
|
4634
|
-
return JSON.parse(text);
|
|
4635
|
-
} catch (e) {
|
|
4636
|
-
return text;
|
|
4637
|
-
}
|
|
4638
|
-
}
|
|
4639
|
-
function fetch(option) {
|
|
4640
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
4641
|
-
return;
|
|
4642
|
-
}
|
|
4643
|
-
var xhr = new XMLHttpRequest();
|
|
4644
|
-
var action = option.action;
|
|
4645
|
-
xhr.onerror = function error(e) {
|
|
4646
|
-
option.onError(e);
|
|
4647
|
-
};
|
|
4648
|
-
xhr.onload = function onload() {
|
|
4649
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
4650
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
4651
|
-
}
|
|
4652
|
-
option.onSuccess(getBody(xhr));
|
|
4653
|
-
};
|
|
4654
|
-
xhr.open(option.method || 'get', action, true);
|
|
4655
|
-
var formData;
|
|
4656
|
-
if (option.data) {
|
|
4657
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
4658
|
-
formData = new FormData();
|
|
4659
|
-
Object.keys(option.data).map(function (key) {
|
|
4660
|
-
formData.append(key, option.data[key]);
|
|
4661
|
-
});
|
|
4662
|
-
} else {
|
|
4663
|
-
formData = JSON.stringify(option.data);
|
|
4664
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
4668
|
-
xhr.withCredentials = true;
|
|
4669
|
-
}
|
|
4670
|
-
var headers = option.headers || {};
|
|
4671
|
-
Object.keys(headers).forEach(function (item) {
|
|
4672
|
-
if (headers[item] !== null) {
|
|
4673
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
4674
|
-
}
|
|
4675
|
-
});
|
|
4676
|
-
xhr.send(formData);
|
|
4677
|
-
}
|
|
4678
|
-
|
|
4679
4772
|
var NAME$9 = 'fcFragment';
|
|
4680
4773
|
var fragment = {
|
|
4681
4774
|
name: NAME$9,
|
|
@@ -4918,6 +5011,7 @@
|
|
|
4918
5011
|
set(undefined);
|
|
4919
5012
|
return;
|
|
4920
5013
|
}
|
|
5014
|
+
option = deepCopy(option);
|
|
4921
5015
|
if (!option.to) {
|
|
4922
5016
|
option.to = 'options';
|
|
4923
5017
|
}
|
|
@@ -4998,6 +5092,7 @@
|
|
|
4998
5092
|
var val = parseVal(inject.getValue());
|
|
4999
5093
|
if (val.required === false) {
|
|
5000
5094
|
inject.clearProp();
|
|
5095
|
+
api.clearValidateState([rule.field]);
|
|
5001
5096
|
} else {
|
|
5002
5097
|
var validate = _objectSpread2({
|
|
5003
5098
|
required: true,
|
|
@@ -5176,9 +5271,13 @@
|
|
|
5176
5271
|
component = id;
|
|
5177
5272
|
}
|
|
5178
5273
|
if (!name || !component) return;
|
|
5274
|
+
var nameAlias = toCase(name);
|
|
5179
5275
|
components[name] = component;
|
|
5276
|
+
components[nameAlias] = component;
|
|
5180
5277
|
delete CreateNode.aliasMap[name];
|
|
5278
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5181
5279
|
delete parsers[name];
|
|
5280
|
+
delete parsers[nameAlias];
|
|
5182
5281
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5183
5282
|
}
|
|
5184
5283
|
function _emitData(id) {
|
|
@@ -5287,7 +5386,6 @@
|
|
|
5287
5386
|
_this2.initOptions();
|
|
5288
5387
|
}
|
|
5289
5388
|
_this2.created();
|
|
5290
|
-
vm.disabled && vm.$f.disabled(true);
|
|
5291
5389
|
});
|
|
5292
5390
|
vm.$on('hook:mounted', function () {
|
|
5293
5391
|
_this2.mounted();
|
|
@@ -5759,8 +5857,7 @@
|
|
|
5759
5857
|
ref: ref
|
|
5760
5858
|
});
|
|
5761
5859
|
extend(this.rule.props, {
|
|
5762
|
-
model: $handle.formData
|
|
5763
|
-
rules: $handle.validate()
|
|
5860
|
+
model: $handle.formData
|
|
5764
5861
|
});
|
|
5765
5862
|
},
|
|
5766
5863
|
render: function render(children) {
|
|
@@ -5784,7 +5881,7 @@
|
|
|
5784
5881
|
label: isTitle ? rule.title.title : undefined
|
|
5785
5882
|
}, rule.wrap || {}), {}, {
|
|
5786
5883
|
prop: ctx.id,
|
|
5787
|
-
rules:
|
|
5884
|
+
rules: ctx.injectValidate()
|
|
5788
5885
|
}),
|
|
5789
5886
|
"class": rule.className,
|
|
5790
5887
|
key: "".concat(uni, "fi"),
|
|
@@ -6175,7 +6272,7 @@
|
|
|
6175
6272
|
function elmFormCreate() {
|
|
6176
6273
|
return FormCreateFactory({
|
|
6177
6274
|
ui: "".concat("element-ui"),
|
|
6178
|
-
version: "".concat("2.5.
|
|
6275
|
+
version: "".concat("2.5.36"),
|
|
6179
6276
|
manager: manager,
|
|
6180
6277
|
extendApi: extendApi,
|
|
6181
6278
|
install: install,
|