@form-create/iview 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/iview v2.5.
|
|
2
|
+
* @form-create/iview 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.
|
|
@@ -1927,7 +1927,10 @@
|
|
|
1927
1927
|
}
|
|
1928
1928
|
},
|
|
1929
1929
|
extendOption: Boolean,
|
|
1930
|
-
disabled:
|
|
1930
|
+
disabled: {
|
|
1931
|
+
type: Boolean,
|
|
1932
|
+
"default": undefined
|
|
1933
|
+
},
|
|
1931
1934
|
value: Object,
|
|
1932
1935
|
api: Object,
|
|
1933
1936
|
name: String,
|
|
@@ -1990,8 +1993,8 @@
|
|
|
1990
1993
|
this.formCreate.$handle.reloadRule(n);
|
|
1991
1994
|
this._renderRule();
|
|
1992
1995
|
},
|
|
1993
|
-
disabled: function disabled(
|
|
1994
|
-
this.$f.
|
|
1996
|
+
disabled: function disabled() {
|
|
1997
|
+
this.$f.refresh();
|
|
1995
1998
|
}
|
|
1996
1999
|
},
|
|
1997
2000
|
beforeCreate: function beforeCreate() {
|
|
@@ -2136,7 +2139,7 @@
|
|
|
2136
2139
|
var $TX = '$FNX:';
|
|
2137
2140
|
var FUNCTION = 'function';
|
|
2138
2141
|
function toJson(obj, space) {
|
|
2139
|
-
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
2142
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2140
2143
|
if (val && val._isVue === true) return undefined;
|
|
2141
2144
|
if (_typeof(val) !== FUNCTION) {
|
|
2142
2145
|
return val;
|
|
@@ -2247,6 +2250,61 @@
|
|
|
2247
2250
|
}
|
|
2248
2251
|
return def;
|
|
2249
2252
|
}
|
|
2253
|
+
var changeType = function changeType(a, b) {
|
|
2254
|
+
if (typeof a === 'string') {
|
|
2255
|
+
return String(b);
|
|
2256
|
+
} else if (typeof a === 'number') {
|
|
2257
|
+
return Number(b);
|
|
2258
|
+
}
|
|
2259
|
+
return b;
|
|
2260
|
+
};
|
|
2261
|
+
var condition = {
|
|
2262
|
+
'==': function _(a, b) {
|
|
2263
|
+
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2264
|
+
},
|
|
2265
|
+
'!=': function _(a, b) {
|
|
2266
|
+
return !condition['=='](a, b);
|
|
2267
|
+
},
|
|
2268
|
+
'>': function _(a, b) {
|
|
2269
|
+
return a > b;
|
|
2270
|
+
},
|
|
2271
|
+
'>=': function _(a, b) {
|
|
2272
|
+
return a >= b;
|
|
2273
|
+
},
|
|
2274
|
+
'<': function _(a, b) {
|
|
2275
|
+
return a < b;
|
|
2276
|
+
},
|
|
2277
|
+
'<=': function _(a, b) {
|
|
2278
|
+
return a <= b;
|
|
2279
|
+
},
|
|
2280
|
+
on: function on(a, b) {
|
|
2281
|
+
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2282
|
+
},
|
|
2283
|
+
notOn: function notOn(a, b) {
|
|
2284
|
+
return !condition.on(a, b);
|
|
2285
|
+
},
|
|
2286
|
+
"in": function _in(a, b) {
|
|
2287
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2288
|
+
},
|
|
2289
|
+
notIn: function notIn(a, b) {
|
|
2290
|
+
return !condition["in"](a, b);
|
|
2291
|
+
},
|
|
2292
|
+
between: function between(a, b) {
|
|
2293
|
+
return a > b[0] && a < b[1];
|
|
2294
|
+
},
|
|
2295
|
+
notBetween: function notBetween(a, b) {
|
|
2296
|
+
return a < b[0] || a > b[1];
|
|
2297
|
+
},
|
|
2298
|
+
empty: function empty(a) {
|
|
2299
|
+
return is.empty(a);
|
|
2300
|
+
},
|
|
2301
|
+
notEmpty: function notEmpty(a) {
|
|
2302
|
+
return !is.empty(a);
|
|
2303
|
+
},
|
|
2304
|
+
pattern: function pattern(a, b) {
|
|
2305
|
+
return new RegExp(b, 'g').test(a);
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2250
2308
|
|
|
2251
2309
|
function baseRule() {
|
|
2252
2310
|
return {
|
|
@@ -2328,6 +2386,92 @@
|
|
|
2328
2386
|
};
|
|
2329
2387
|
}
|
|
2330
2388
|
|
|
2389
|
+
function getError(action, option, xhr) {
|
|
2390
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2391
|
+
var err = new Error(msg);
|
|
2392
|
+
err.status = xhr.status;
|
|
2393
|
+
err.url = action;
|
|
2394
|
+
return err;
|
|
2395
|
+
}
|
|
2396
|
+
function getBody(xhr) {
|
|
2397
|
+
var text = xhr.responseText || xhr.response;
|
|
2398
|
+
if (!text) {
|
|
2399
|
+
return text;
|
|
2400
|
+
}
|
|
2401
|
+
try {
|
|
2402
|
+
return JSON.parse(text);
|
|
2403
|
+
} catch (e) {
|
|
2404
|
+
return text;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
function fetch(option) {
|
|
2408
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2409
|
+
return;
|
|
2410
|
+
}
|
|
2411
|
+
var xhr = new XMLHttpRequest();
|
|
2412
|
+
var action = option.action;
|
|
2413
|
+
xhr.onerror = function error(e) {
|
|
2414
|
+
option.onError(e);
|
|
2415
|
+
};
|
|
2416
|
+
xhr.onload = function onload() {
|
|
2417
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2418
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2419
|
+
}
|
|
2420
|
+
option.onSuccess(getBody(xhr));
|
|
2421
|
+
};
|
|
2422
|
+
xhr.open(option.method || 'get', action, true);
|
|
2423
|
+
var formData;
|
|
2424
|
+
if (option.data) {
|
|
2425
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2426
|
+
formData = new FormData();
|
|
2427
|
+
Object.keys(option.data).map(function (key) {
|
|
2428
|
+
formData.append(key, option.data[key]);
|
|
2429
|
+
});
|
|
2430
|
+
} else {
|
|
2431
|
+
formData = JSON.stringify(option.data);
|
|
2432
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2436
|
+
xhr.withCredentials = true;
|
|
2437
|
+
}
|
|
2438
|
+
var headers = option.headers || {};
|
|
2439
|
+
Object.keys(headers).forEach(function (item) {
|
|
2440
|
+
if (headers[item] !== null) {
|
|
2441
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
xhr.send(formData);
|
|
2445
|
+
}
|
|
2446
|
+
function asyncFetch(config) {
|
|
2447
|
+
return new Promise(function (resolve, reject) {
|
|
2448
|
+
fetch(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2449
|
+
onSuccess: function onSuccess(res) {
|
|
2450
|
+
var fn = function fn(v) {
|
|
2451
|
+
return v;
|
|
2452
|
+
};
|
|
2453
|
+
var parse = parseFn(config.parse);
|
|
2454
|
+
if (is.Function(parse)) {
|
|
2455
|
+
fn = parse;
|
|
2456
|
+
} else if (parse && is.String(parse)) {
|
|
2457
|
+
fn = function fn(v) {
|
|
2458
|
+
parse.split('.').forEach(function (k) {
|
|
2459
|
+
if (v) {
|
|
2460
|
+
v = v[k];
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
return v;
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
resolve(fn(res));
|
|
2467
|
+
},
|
|
2468
|
+
onError: function onError(err) {
|
|
2469
|
+
reject(err);
|
|
2470
|
+
}
|
|
2471
|
+
}));
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2331
2475
|
function copy(value) {
|
|
2332
2476
|
return deepCopy(value);
|
|
2333
2477
|
}
|
|
@@ -2609,6 +2753,21 @@
|
|
|
2609
2753
|
return origin ? ctx.origin : ctx.rule;
|
|
2610
2754
|
}
|
|
2611
2755
|
},
|
|
2756
|
+
getRenderRule: function getRenderRule(id) {
|
|
2757
|
+
var ctx = h.getCtx(id);
|
|
2758
|
+
if (ctx) {
|
|
2759
|
+
return ctx.prop;
|
|
2760
|
+
}
|
|
2761
|
+
},
|
|
2762
|
+
getRefRule: function getRefRule(id) {
|
|
2763
|
+
var ctxs = h.getCtxs(id);
|
|
2764
|
+
if (ctxs && ctxs.length) {
|
|
2765
|
+
var rules = ctxs.map(function (ctx) {
|
|
2766
|
+
return ctx.rule;
|
|
2767
|
+
});
|
|
2768
|
+
return rules.length === 1 ? rules[0] : rules;
|
|
2769
|
+
}
|
|
2770
|
+
},
|
|
2612
2771
|
setEffect: function setEffect(id, attr, value) {
|
|
2613
2772
|
var ctx = h.getCtx(id);
|
|
2614
2773
|
if (ctx && attr) {
|
|
@@ -2715,12 +2874,23 @@
|
|
|
2715
2874
|
deferSyncValue: function deferSyncValue(fn, sync) {
|
|
2716
2875
|
h.deferSyncValue(fn, sync);
|
|
2717
2876
|
},
|
|
2877
|
+
fetch: function fetch(opt) {
|
|
2878
|
+
h.options.beforeFetch && invoke(function () {
|
|
2879
|
+
return h.options.beforeFetch(opt, {
|
|
2880
|
+
api: api
|
|
2881
|
+
});
|
|
2882
|
+
});
|
|
2883
|
+
return asyncFetch(opt);
|
|
2884
|
+
},
|
|
2885
|
+
getData: function getData(id, def) {
|
|
2886
|
+
return hasProperty(h.fc.loadData, id) ? h.fc.loadData[id] : def;
|
|
2887
|
+
},
|
|
2718
2888
|
helper: {
|
|
2719
2889
|
tidyFields: tidyFields,
|
|
2720
2890
|
props: props
|
|
2721
2891
|
}
|
|
2722
2892
|
};
|
|
2723
|
-
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2893
|
+
['on', 'once', 'off', 'set', 'emit'].forEach(function (n) {
|
|
2724
2894
|
api[n] = function () {
|
|
2725
2895
|
var _h$vm2;
|
|
2726
2896
|
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
@@ -3106,6 +3276,7 @@
|
|
|
3106
3276
|
children: [],
|
|
3107
3277
|
prop: {},
|
|
3108
3278
|
preview: false,
|
|
3279
|
+
id: ctx.id,
|
|
3109
3280
|
field: ctx.field,
|
|
3110
3281
|
rule: ctx.rule,
|
|
3111
3282
|
input: ctx.input
|
|
@@ -3125,13 +3296,13 @@
|
|
|
3125
3296
|
});
|
|
3126
3297
|
return inject;
|
|
3127
3298
|
},
|
|
3128
|
-
ctxProp: function ctxProp(ctx
|
|
3299
|
+
ctxProp: function ctxProp(ctx) {
|
|
3129
3300
|
var _this8 = this;
|
|
3130
3301
|
var ref = ctx.ref,
|
|
3131
3302
|
key = ctx.key,
|
|
3132
3303
|
rule = ctx.rule;
|
|
3133
|
-
this.$manager.mergeProp(ctx
|
|
3134
|
-
ctx.parser.mergeProp(ctx
|
|
3304
|
+
this.$manager.mergeProp(ctx);
|
|
3305
|
+
ctx.parser.mergeProp(ctx);
|
|
3135
3306
|
var props = [{
|
|
3136
3307
|
ref: ref,
|
|
3137
3308
|
key: rule.key || "".concat(key, "fc"),
|
|
@@ -3151,7 +3322,10 @@
|
|
|
3151
3322
|
}
|
|
3152
3323
|
}
|
|
3153
3324
|
}];
|
|
3154
|
-
if (
|
|
3325
|
+
if (ctx.input) {
|
|
3326
|
+
if (this.vm.$props.disabled !== undefined) {
|
|
3327
|
+
ctx.prop.props.disabled = !!this.vm.$props.disabled;
|
|
3328
|
+
}
|
|
3155
3329
|
ctx.prop.model = {
|
|
3156
3330
|
value: this.$handle.getFormData(ctx),
|
|
3157
3331
|
callback: function callback(value) {
|
|
@@ -3309,16 +3483,17 @@
|
|
|
3309
3483
|
inject = rule.inject;
|
|
3310
3484
|
var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
|
|
3311
3485
|
if (is.trueArray(emit)) {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3486
|
+
emit.forEach(function (eventName) {
|
|
3487
|
+
if (!eventName) return;
|
|
3488
|
+
var eventInject;
|
|
3489
|
+
var emitKey = emitPrefix || field || name;
|
|
3490
|
+
if (is.Object(eventName)) {
|
|
3491
|
+
eventInject = eventName.inject;
|
|
3492
|
+
eventName = eventName.name;
|
|
3493
|
+
emitKey = eventName.prefix || emitKey;
|
|
3494
|
+
}
|
|
3495
|
+
if (emitKey) {
|
|
3496
|
+
if (!on) emitKey = "native-".concat(emitKey);
|
|
3322
3497
|
var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
|
|
3323
3498
|
var fn = function fn() {
|
|
3324
3499
|
var _this2$vm, _this2$vm2;
|
|
@@ -3335,8 +3510,8 @@
|
|
|
3335
3510
|
var _inject = eventInject || inject || _this2.options.injectEvent;
|
|
3336
3511
|
event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
|
|
3337
3512
|
}
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3513
|
+
}
|
|
3514
|
+
});
|
|
3340
3515
|
}
|
|
3341
3516
|
ctx.computed[on ? 'on' : 'nativeOn'] = event;
|
|
3342
3517
|
return event;
|
|
@@ -3512,6 +3687,30 @@
|
|
|
3512
3687
|
return _this.payload[k];
|
|
3513
3688
|
})), [this.computed]));
|
|
3514
3689
|
},
|
|
3690
|
+
injectValidate: function injectValidate() {
|
|
3691
|
+
var _this2 = this;
|
|
3692
|
+
return toArray(this.prop.validate).map(function (item) {
|
|
3693
|
+
if (is.Function(item.validator)) {
|
|
3694
|
+
var temp = _objectSpread2({}, item);
|
|
3695
|
+
var that = _this2;
|
|
3696
|
+
temp.validator = function () {
|
|
3697
|
+
var _item$validator;
|
|
3698
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3699
|
+
args[_key] = arguments[_key];
|
|
3700
|
+
}
|
|
3701
|
+
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
3702
|
+
that: this,
|
|
3703
|
+
id: that.id,
|
|
3704
|
+
field: that.field,
|
|
3705
|
+
rule: that.rule,
|
|
3706
|
+
api: that.$handle.api
|
|
3707
|
+
}].concat(args));
|
|
3708
|
+
};
|
|
3709
|
+
return temp;
|
|
3710
|
+
}
|
|
3711
|
+
return item;
|
|
3712
|
+
});
|
|
3713
|
+
},
|
|
3515
3714
|
check: function check(handle) {
|
|
3516
3715
|
return this.vm === handle.vm;
|
|
3517
3716
|
},
|
|
@@ -3560,12 +3759,12 @@
|
|
|
3560
3759
|
this.ctrlRule = [];
|
|
3561
3760
|
},
|
|
3562
3761
|
rm: function rm() {
|
|
3563
|
-
var
|
|
3762
|
+
var _this3 = this;
|
|
3564
3763
|
var _rm = function _rm() {
|
|
3565
|
-
var index =
|
|
3764
|
+
var index = _this3.root.indexOf(_this3.origin);
|
|
3566
3765
|
if (index > -1) {
|
|
3567
|
-
|
|
3568
|
-
|
|
3766
|
+
_this3.root.splice(index, 1);
|
|
3767
|
+
_this3.$handle && _this3.$handle.refresh();
|
|
3569
3768
|
}
|
|
3570
3769
|
};
|
|
3571
3770
|
if (this.deleted) {
|
|
@@ -3573,14 +3772,14 @@
|
|
|
3573
3772
|
return;
|
|
3574
3773
|
}
|
|
3575
3774
|
this.$handle.noWatch(function () {
|
|
3576
|
-
|
|
3577
|
-
|
|
3775
|
+
_this3.$handle.deferSyncValue(function () {
|
|
3776
|
+
_this3.rmCtrl();
|
|
3578
3777
|
_rm();
|
|
3579
|
-
|
|
3580
|
-
extend(
|
|
3778
|
+
_this3.$handle.rmCtx(_this3);
|
|
3779
|
+
extend(_this3, {
|
|
3581
3780
|
root: []
|
|
3582
3781
|
});
|
|
3583
|
-
},
|
|
3782
|
+
}, _this3.input);
|
|
3584
3783
|
});
|
|
3585
3784
|
},
|
|
3586
3785
|
update: function update(handle, init) {
|
|
@@ -3601,73 +3800,6 @@
|
|
|
3601
3800
|
}
|
|
3602
3801
|
});
|
|
3603
3802
|
|
|
3604
|
-
var condition = {
|
|
3605
|
-
'==': function _(b) {
|
|
3606
|
-
return function (a) {
|
|
3607
|
-
return a === b;
|
|
3608
|
-
};
|
|
3609
|
-
},
|
|
3610
|
-
'!=': function _(b) {
|
|
3611
|
-
return function (a) {
|
|
3612
|
-
return a !== b;
|
|
3613
|
-
};
|
|
3614
|
-
},
|
|
3615
|
-
'<>': function _(b) {
|
|
3616
|
-
return function (a) {
|
|
3617
|
-
return a !== b;
|
|
3618
|
-
};
|
|
3619
|
-
},
|
|
3620
|
-
'>': function _(b) {
|
|
3621
|
-
return function (a) {
|
|
3622
|
-
return a > b;
|
|
3623
|
-
};
|
|
3624
|
-
},
|
|
3625
|
-
'>=': function _(b) {
|
|
3626
|
-
return function (a) {
|
|
3627
|
-
return a >= b;
|
|
3628
|
-
};
|
|
3629
|
-
},
|
|
3630
|
-
'<': function _(b) {
|
|
3631
|
-
return function (a) {
|
|
3632
|
-
return a < b;
|
|
3633
|
-
};
|
|
3634
|
-
},
|
|
3635
|
-
'<=': function _(b) {
|
|
3636
|
-
return function (a) {
|
|
3637
|
-
return a <= b;
|
|
3638
|
-
};
|
|
3639
|
-
},
|
|
3640
|
-
'in': function _in(b) {
|
|
3641
|
-
return function (a) {
|
|
3642
|
-
return b && b.indexOf && b.indexOf(a) > -1;
|
|
3643
|
-
};
|
|
3644
|
-
},
|
|
3645
|
-
'on': function on(b) {
|
|
3646
|
-
return function (a) {
|
|
3647
|
-
return a && a.indexOf && a.indexOf(b) > -1;
|
|
3648
|
-
};
|
|
3649
|
-
},
|
|
3650
|
-
'notIn': function notIn(b) {
|
|
3651
|
-
return function (a) {
|
|
3652
|
-
return !condition["in"](b)(a);
|
|
3653
|
-
};
|
|
3654
|
-
},
|
|
3655
|
-
'notOn': function notOn(b) {
|
|
3656
|
-
return function (a) {
|
|
3657
|
-
return !condition.on(b)(a);
|
|
3658
|
-
};
|
|
3659
|
-
},
|
|
3660
|
-
'between': function between(b) {
|
|
3661
|
-
return function (a) {
|
|
3662
|
-
return a > b[0] && a < b[1];
|
|
3663
|
-
};
|
|
3664
|
-
},
|
|
3665
|
-
'notBetween': function notBetween(b) {
|
|
3666
|
-
return function (a) {
|
|
3667
|
-
return a < b[0] || a > b[1];
|
|
3668
|
-
};
|
|
3669
|
-
}
|
|
3670
|
-
};
|
|
3671
3803
|
function useLoader(Handler) {
|
|
3672
3804
|
extend(Handler.prototype, {
|
|
3673
3805
|
nextRefresh: function nextRefresh(fn) {
|
|
@@ -3819,7 +3951,7 @@
|
|
|
3819
3951
|
}
|
|
3820
3952
|
if (!ctx) {
|
|
3821
3953
|
var _rule2 = _this6.parseRule(_rule);
|
|
3822
|
-
ctx = new RuleContext(_this6, _rule2,
|
|
3954
|
+
ctx = new RuleContext(_this6, _rule2, defaultValue);
|
|
3823
3955
|
_this6.bindParser(ctx);
|
|
3824
3956
|
} else {
|
|
3825
3957
|
if (ctx.originType !== ctx.rule.type) {
|
|
@@ -3872,7 +4004,9 @@
|
|
|
3872
4004
|
if (!controls.length) return false;
|
|
3873
4005
|
var _loop = function _loop(i) {
|
|
3874
4006
|
var control = controls[i],
|
|
3875
|
-
handleFn = control.handle ||
|
|
4007
|
+
handleFn = control.handle || function (val) {
|
|
4008
|
+
return (condition[control.condition || '=='] || condition['=='])(val, control.value);
|
|
4009
|
+
};
|
|
3876
4010
|
if (!is.trueArray(control.rule)) return "continue";
|
|
3877
4011
|
var data = _objectSpread2(_objectSpread2({}, control), {}, {
|
|
3878
4012
|
valid: invoke(function () {
|
|
@@ -4034,6 +4168,11 @@
|
|
|
4034
4168
|
this.valueChange(ctx, value);
|
|
4035
4169
|
this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
4036
4170
|
this.effect(ctx, 'value');
|
|
4171
|
+
this.emitEvent('change', ctx.field, value, {
|
|
4172
|
+
rule: ctx.origin,
|
|
4173
|
+
api: this.api,
|
|
4174
|
+
setFlag: setFlag || false
|
|
4175
|
+
});
|
|
4037
4176
|
},
|
|
4038
4177
|
onInput: function onInput(ctx, value) {
|
|
4039
4178
|
var val;
|
|
@@ -4130,12 +4269,13 @@
|
|
|
4130
4269
|
isQuote: function isQuote(ctx, value) {
|
|
4131
4270
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
4132
4271
|
},
|
|
4133
|
-
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
4272
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
4134
4273
|
var _this4 = this;
|
|
4135
4274
|
if (is.Function(ctx.rule.update)) {
|
|
4136
4275
|
var state = invoke(function () {
|
|
4137
4276
|
return ctx.rule.update(val, ctx.origin, _this4.api, {
|
|
4138
|
-
origin: origin || 'change'
|
|
4277
|
+
origin: origin || 'change',
|
|
4278
|
+
linkField: field
|
|
4139
4279
|
});
|
|
4140
4280
|
});
|
|
4141
4281
|
if (state === undefined) return;
|
|
@@ -4146,21 +4286,21 @@
|
|
|
4146
4286
|
this.refreshRule(ctx, val);
|
|
4147
4287
|
this.bus.$emit('change-' + ctx.field, val);
|
|
4148
4288
|
},
|
|
4149
|
-
refreshRule: function refreshRule(ctx, val, origin) {
|
|
4289
|
+
refreshRule: function refreshRule(ctx, val, origin, field) {
|
|
4150
4290
|
if (this.refreshControl(ctx)) {
|
|
4151
4291
|
this.$render.clearCacheAll();
|
|
4152
4292
|
this.loadRule();
|
|
4153
4293
|
this.vm.$emit('update', this.api);
|
|
4154
4294
|
this.refresh();
|
|
4155
4295
|
}
|
|
4156
|
-
this.refreshUpdate(ctx, val, origin);
|
|
4296
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
4157
4297
|
},
|
|
4158
4298
|
appendLink: function appendLink(ctx) {
|
|
4159
4299
|
var _this5 = this;
|
|
4160
4300
|
var link = ctx.rule.link;
|
|
4161
4301
|
is.trueArray(link) && link.forEach(function (field) {
|
|
4162
4302
|
var fn = function fn() {
|
|
4163
|
-
return _this5.refreshRule(ctx, ctx.rule.value, 'link');
|
|
4303
|
+
return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
4164
4304
|
};
|
|
4165
4305
|
_this5.bus.$on('change-' + field, fn);
|
|
4166
4306
|
ctx.linkOn.push(function () {
|
|
@@ -4391,12 +4531,22 @@
|
|
|
4391
4531
|
}
|
|
4392
4532
|
},
|
|
4393
4533
|
lifecycle: function lifecycle(name) {
|
|
4394
|
-
var _this2 = this;
|
|
4395
|
-
var fn = this.options[name];
|
|
4396
|
-
is.Function(fn) && invoke(function () {
|
|
4397
|
-
return fn(_this2.api);
|
|
4398
|
-
});
|
|
4399
4534
|
this.vm.$emit(name, this.api);
|
|
4535
|
+
this.emitEvent(name, this.api);
|
|
4536
|
+
},
|
|
4537
|
+
emitEvent: function emitEvent(name) {
|
|
4538
|
+
var _this$bus;
|
|
4539
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4540
|
+
args[_key - 1] = arguments[_key];
|
|
4541
|
+
}
|
|
4542
|
+
var _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
4543
|
+
if (_fn) {
|
|
4544
|
+
var fn = parseFn(_fn);
|
|
4545
|
+
is.Function(fn) && invoke(function () {
|
|
4546
|
+
return fn.apply(void 0, args);
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
4400
4550
|
}
|
|
4401
4551
|
});
|
|
4402
4552
|
}
|
|
@@ -4598,6 +4748,7 @@
|
|
|
4598
4748
|
this.usePage();
|
|
4599
4749
|
this.loadRule();
|
|
4600
4750
|
this.$manager.__init();
|
|
4751
|
+
this.lifecycle('created');
|
|
4601
4752
|
this.vm.$set(this.vm, 'formData', this.formData);
|
|
4602
4753
|
}
|
|
4603
4754
|
});
|
|
@@ -4610,64 +4761,6 @@
|
|
|
4610
4761
|
useLifecycle(Handler);
|
|
4611
4762
|
useEffect(Handler);
|
|
4612
4763
|
|
|
4613
|
-
function getError(action, option, xhr) {
|
|
4614
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
4615
|
-
var err = new Error(msg);
|
|
4616
|
-
err.status = xhr.status;
|
|
4617
|
-
err.url = action;
|
|
4618
|
-
return err;
|
|
4619
|
-
}
|
|
4620
|
-
function getBody(xhr) {
|
|
4621
|
-
var text = xhr.responseText || xhr.response;
|
|
4622
|
-
if (!text) {
|
|
4623
|
-
return text;
|
|
4624
|
-
}
|
|
4625
|
-
try {
|
|
4626
|
-
return JSON.parse(text);
|
|
4627
|
-
} catch (e) {
|
|
4628
|
-
return text;
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
function fetch(option) {
|
|
4632
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
4633
|
-
return;
|
|
4634
|
-
}
|
|
4635
|
-
var xhr = new XMLHttpRequest();
|
|
4636
|
-
var action = option.action;
|
|
4637
|
-
xhr.onerror = function error(e) {
|
|
4638
|
-
option.onError(e);
|
|
4639
|
-
};
|
|
4640
|
-
xhr.onload = function onload() {
|
|
4641
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
4642
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
4643
|
-
}
|
|
4644
|
-
option.onSuccess(getBody(xhr));
|
|
4645
|
-
};
|
|
4646
|
-
xhr.open(option.method || 'get', action, true);
|
|
4647
|
-
var formData;
|
|
4648
|
-
if (option.data) {
|
|
4649
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
4650
|
-
formData = new FormData();
|
|
4651
|
-
Object.keys(option.data).map(function (key) {
|
|
4652
|
-
formData.append(key, option.data[key]);
|
|
4653
|
-
});
|
|
4654
|
-
} else {
|
|
4655
|
-
formData = JSON.stringify(option.data);
|
|
4656
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4659
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
4660
|
-
xhr.withCredentials = true;
|
|
4661
|
-
}
|
|
4662
|
-
var headers = option.headers || {};
|
|
4663
|
-
Object.keys(headers).forEach(function (item) {
|
|
4664
|
-
if (headers[item] !== null) {
|
|
4665
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
4666
|
-
}
|
|
4667
|
-
});
|
|
4668
|
-
xhr.send(formData);
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
4764
|
var NAME$9 = 'fcFragment';
|
|
4672
4765
|
var fragment = {
|
|
4673
4766
|
name: NAME$9,
|
|
@@ -4910,6 +5003,7 @@
|
|
|
4910
5003
|
set(undefined);
|
|
4911
5004
|
return;
|
|
4912
5005
|
}
|
|
5006
|
+
option = deepCopy(option);
|
|
4913
5007
|
if (!option.to) {
|
|
4914
5008
|
option.to = 'options';
|
|
4915
5009
|
}
|
|
@@ -4990,6 +5084,7 @@
|
|
|
4990
5084
|
var val = parseVal(inject.getValue());
|
|
4991
5085
|
if (val.required === false) {
|
|
4992
5086
|
inject.clearProp();
|
|
5087
|
+
api.clearValidateState([rule.field]);
|
|
4993
5088
|
} else {
|
|
4994
5089
|
var validate = _objectSpread2({
|
|
4995
5090
|
required: true,
|
|
@@ -5168,9 +5263,13 @@
|
|
|
5168
5263
|
component = id;
|
|
5169
5264
|
}
|
|
5170
5265
|
if (!name || !component) return;
|
|
5266
|
+
var nameAlias = toCase(name);
|
|
5171
5267
|
components[name] = component;
|
|
5268
|
+
components[nameAlias] = component;
|
|
5172
5269
|
delete CreateNode.aliasMap[name];
|
|
5270
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5173
5271
|
delete parsers[name];
|
|
5272
|
+
delete parsers[nameAlias];
|
|
5174
5273
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5175
5274
|
}
|
|
5176
5275
|
function _emitData(id) {
|
|
@@ -5279,7 +5378,6 @@
|
|
|
5279
5378
|
_this2.initOptions();
|
|
5280
5379
|
}
|
|
5281
5380
|
_this2.created();
|
|
5282
|
-
vm.disabled && vm.$f.disabled(true);
|
|
5283
5381
|
});
|
|
5284
5382
|
vm.$on('hook:mounted', function () {
|
|
5285
5383
|
_this2.mounted();
|
|
@@ -5777,8 +5875,7 @@
|
|
|
5777
5875
|
ref: ref
|
|
5778
5876
|
});
|
|
5779
5877
|
extend(this.rule.props, {
|
|
5780
|
-
model: $handle.formData
|
|
5781
|
-
rules: $handle.validate()
|
|
5878
|
+
model: $handle.formData
|
|
5782
5879
|
});
|
|
5783
5880
|
},
|
|
5784
5881
|
render: function render(children) {
|
|
@@ -5801,7 +5898,7 @@
|
|
|
5801
5898
|
labelWidth: labelWidth
|
|
5802
5899
|
}, rule.wrap || {}), {}, {
|
|
5803
5900
|
prop: ctx.id,
|
|
5804
|
-
rules:
|
|
5901
|
+
rules: ctx.injectValidate()
|
|
5805
5902
|
}),
|
|
5806
5903
|
"class": rule.className,
|
|
5807
5904
|
key: "".concat(uni, "fi"),
|
|
@@ -6210,7 +6307,7 @@
|
|
|
6210
6307
|
function ivuFormCreate() {
|
|
6211
6308
|
return FormCreateFactory({
|
|
6212
6309
|
ui: "".concat("iview"),
|
|
6213
|
-
version: "".concat("2.5.
|
|
6310
|
+
version: "".concat("2.5.36"),
|
|
6214
6311
|
manager: manager,
|
|
6215
6312
|
install: install,
|
|
6216
6313
|
extendApi: extendApi,
|