@form-create/iview 2.5.27 → 2.5.29
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 +223 -110
- package/dist/form-create.min.js +3 -3
- package/dist/form-create.min.js.map +1 -1
- package/package.json +6 -6
- package/src/core/api.js +33 -66
- package/src/core/manager.js +20 -4
- package/types/config.d.ts +2 -2
package/dist/form-create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/iview v2.5.
|
|
3
|
-
* (c) 2018-
|
|
2
|
+
* @form-create/iview v2.5.29
|
|
3
|
+
* (c) 2018-2023 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
@@ -292,12 +292,12 @@
|
|
|
292
292
|
}));
|
|
293
293
|
},
|
|
294
294
|
update: function update() {
|
|
295
|
-
var
|
|
296
|
-
this.trueValue = this.
|
|
297
|
-
return
|
|
295
|
+
var checked = Array.isArray(this.value) ? this.value : [this.value];
|
|
296
|
+
this.trueValue = this.options().filter(function (opt) {
|
|
297
|
+
return checked.indexOf(opt.value) !== -1;
|
|
298
298
|
}).map(function (option) {
|
|
299
299
|
return option.label;
|
|
300
|
-
})
|
|
300
|
+
});
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
303
|
created: function created() {
|
|
@@ -1207,7 +1207,7 @@
|
|
|
1207
1207
|
}).filter(function (url) {
|
|
1208
1208
|
return url !== undefined;
|
|
1209
1209
|
});
|
|
1210
|
-
if (this.cacheFiles.length !== files.length) {
|
|
1210
|
+
if (this.cacheFiles.length !== files.length || !files.length) {
|
|
1211
1211
|
this.cacheFiles = _toConsumableArray(files);
|
|
1212
1212
|
this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
|
|
1213
1213
|
}
|
|
@@ -1615,7 +1615,7 @@
|
|
|
1615
1615
|
if (index === 0) {
|
|
1616
1616
|
return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
|
|
1617
1617
|
}
|
|
1618
|
-
if (
|
|
1618
|
+
if (total > this.min) {
|
|
1619
1619
|
return this.delIcon(index, key);
|
|
1620
1620
|
}
|
|
1621
1621
|
},
|
|
@@ -2194,6 +2194,7 @@
|
|
|
2194
2194
|
on: {},
|
|
2195
2195
|
options: [],
|
|
2196
2196
|
children: [],
|
|
2197
|
+
effect: {},
|
|
2197
2198
|
hidden: false,
|
|
2198
2199
|
display: true,
|
|
2199
2200
|
value: undefined
|
|
@@ -2552,7 +2553,7 @@
|
|
|
2552
2553
|
$set(ctx.rule, '$' + attr, value);
|
|
2553
2554
|
}
|
|
2554
2555
|
if (!hasProperty(ctx.rule, 'effect')) {
|
|
2555
|
-
ctx.rule
|
|
2556
|
+
$set(ctx.rule, 'effect', {});
|
|
2556
2557
|
}
|
|
2557
2558
|
$set(ctx.rule.effect, attr, value);
|
|
2558
2559
|
}
|
|
@@ -2669,6 +2670,9 @@
|
|
|
2669
2670
|
this.clearCacheAll();
|
|
2670
2671
|
},
|
|
2671
2672
|
clearCache: function clearCache(ctx) {
|
|
2673
|
+
if (ctx.rule.cache) {
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2672
2676
|
if (!this.cache[ctx.id]) {
|
|
2673
2677
|
ctx.parent && this.clearCache(ctx.parent);
|
|
2674
2678
|
return;
|
|
@@ -2762,11 +2766,16 @@
|
|
|
2762
2766
|
clearOrgChildren: function clearOrgChildren() {
|
|
2763
2767
|
this.orgChildren = {};
|
|
2764
2768
|
},
|
|
2765
|
-
getTypeSlot: function getTypeSlot(
|
|
2766
|
-
var name = 'type-' + toLine(type);
|
|
2769
|
+
getTypeSlot: function getTypeSlot(ctx) {
|
|
2767
2770
|
var _fn = function _fn(vm) {
|
|
2768
2771
|
if (vm) {
|
|
2769
|
-
var slot =
|
|
2772
|
+
var slot = undefined;
|
|
2773
|
+
if (ctx.rule.field) {
|
|
2774
|
+
slot = vm.$scopedSlots['field-' + toLine(ctx.rule.field)] || vm.$scopedSlots['field-' + ctx.rule.field];
|
|
2775
|
+
}
|
|
2776
|
+
if (!slot) {
|
|
2777
|
+
slot = vm.$scopedSlots['type-' + toLine(ctx.type)] || vm.$scopedSlots['type-' + ctx.type];
|
|
2778
|
+
}
|
|
2770
2779
|
if (slot) {
|
|
2771
2780
|
return slot;
|
|
2772
2781
|
}
|
|
@@ -2887,12 +2896,16 @@
|
|
|
2887
2896
|
vn.data.key = key;
|
|
2888
2897
|
return vn;
|
|
2889
2898
|
},
|
|
2890
|
-
parseSide: function parseSide(side) {
|
|
2891
|
-
return is.Object(side) ? mergeRule({
|
|
2899
|
+
parseSide: function parseSide(side, ctx) {
|
|
2900
|
+
return is.Object(side) ? mergeRule({
|
|
2901
|
+
props: {
|
|
2902
|
+
formCreateInject: ctx.prop.props.formCreateInject
|
|
2903
|
+
}
|
|
2904
|
+
}, side) : side;
|
|
2892
2905
|
},
|
|
2893
2906
|
renderSides: function renderSides(vn, ctx, temp) {
|
|
2894
2907
|
var prop = ctx[temp ? 'rule' : 'prop'];
|
|
2895
|
-
return [this.renderRule(this.parseSide(prop.prefix)), vn, this.renderRule(this.parseSide(prop.suffix))];
|
|
2908
|
+
return [this.renderRule(this.parseSide(prop.prefix, ctx)), vn, this.renderRule(this.parseSide(prop.suffix, ctx))];
|
|
2896
2909
|
},
|
|
2897
2910
|
renderSlot: function renderSlot(ctx, slot) {
|
|
2898
2911
|
return ctx.rule.slot === slot ? this.renderCtx(ctx) : undefined;
|
|
@@ -2945,7 +2958,7 @@
|
|
|
2945
2958
|
} else if (ctx.parser.loadChildren !== false) {
|
|
2946
2959
|
children = this.renderChildren(ctx);
|
|
2947
2960
|
}
|
|
2948
|
-
var slot = this.getTypeSlot(ctx
|
|
2961
|
+
var slot = this.getTypeSlot(ctx);
|
|
2949
2962
|
if (slot) {
|
|
2950
2963
|
vn = slot({
|
|
2951
2964
|
rule: rule,
|
|
@@ -3421,7 +3434,7 @@
|
|
|
3421
3434
|
var _this = this;
|
|
3422
3435
|
var rule = _objectSpread2({}, this.rule);
|
|
3423
3436
|
delete rule.children;
|
|
3424
|
-
this.prop =
|
|
3437
|
+
this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
|
|
3425
3438
|
return _this.payload[k];
|
|
3426
3439
|
})), [this.computed]));
|
|
3427
3440
|
},
|
|
@@ -3513,6 +3526,73 @@
|
|
|
3513
3526
|
}
|
|
3514
3527
|
});
|
|
3515
3528
|
|
|
3529
|
+
var condition = {
|
|
3530
|
+
'==': function _(b) {
|
|
3531
|
+
return function (a) {
|
|
3532
|
+
return a === b;
|
|
3533
|
+
};
|
|
3534
|
+
},
|
|
3535
|
+
'!=': function _(b) {
|
|
3536
|
+
return function (a) {
|
|
3537
|
+
return a !== b;
|
|
3538
|
+
};
|
|
3539
|
+
},
|
|
3540
|
+
'<>': function _(b) {
|
|
3541
|
+
return function (a) {
|
|
3542
|
+
return a !== b;
|
|
3543
|
+
};
|
|
3544
|
+
},
|
|
3545
|
+
'>': function _(b) {
|
|
3546
|
+
return function (a) {
|
|
3547
|
+
return a > b;
|
|
3548
|
+
};
|
|
3549
|
+
},
|
|
3550
|
+
'>=': function _(b) {
|
|
3551
|
+
return function (a) {
|
|
3552
|
+
return a >= b;
|
|
3553
|
+
};
|
|
3554
|
+
},
|
|
3555
|
+
'<': function _(b) {
|
|
3556
|
+
return function (a) {
|
|
3557
|
+
return a < b;
|
|
3558
|
+
};
|
|
3559
|
+
},
|
|
3560
|
+
'<=': function _(b) {
|
|
3561
|
+
return function (a) {
|
|
3562
|
+
return a <= b;
|
|
3563
|
+
};
|
|
3564
|
+
},
|
|
3565
|
+
'in': function _in(b) {
|
|
3566
|
+
return function (a) {
|
|
3567
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
3568
|
+
};
|
|
3569
|
+
},
|
|
3570
|
+
'on': function on(b) {
|
|
3571
|
+
return function (a) {
|
|
3572
|
+
return a && a.indexOf && a.indexOf(b) > -1;
|
|
3573
|
+
};
|
|
3574
|
+
},
|
|
3575
|
+
'notIn': function notIn(b) {
|
|
3576
|
+
return function (a) {
|
|
3577
|
+
return !condition["in"](b)(a);
|
|
3578
|
+
};
|
|
3579
|
+
},
|
|
3580
|
+
'notOn': function notOn(b) {
|
|
3581
|
+
return function (a) {
|
|
3582
|
+
return !condition.on(b)(a);
|
|
3583
|
+
};
|
|
3584
|
+
},
|
|
3585
|
+
'between': function between(b) {
|
|
3586
|
+
return function (a) {
|
|
3587
|
+
return a > b[0] && a < b[1];
|
|
3588
|
+
};
|
|
3589
|
+
},
|
|
3590
|
+
'notBetween': function notBetween(b) {
|
|
3591
|
+
return function (a) {
|
|
3592
|
+
return a < b[0] || a > b[1];
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
};
|
|
3516
3596
|
function useLoader(Handler) {
|
|
3517
3597
|
extend(Handler.prototype, {
|
|
3518
3598
|
nextRefresh: function nextRefresh(fn) {
|
|
@@ -3620,7 +3700,7 @@
|
|
|
3620
3700
|
}
|
|
3621
3701
|
};
|
|
3622
3702
|
rules.map(function (_rule, index) {
|
|
3623
|
-
if (parent &&
|
|
3703
|
+
if (parent && !is.Object(_rule)) return;
|
|
3624
3704
|
if (!_this6.pageEnd && !parent && index >= _this6.first) return;
|
|
3625
3705
|
if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
|
|
3626
3706
|
loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
|
|
@@ -3695,7 +3775,7 @@
|
|
|
3695
3775
|
ctx.updated = true;
|
|
3696
3776
|
if (is.Function(r.update)) {
|
|
3697
3777
|
_this6.bus.$once('load-end', function () {
|
|
3698
|
-
_this6.refreshUpdate(ctx, r.value);
|
|
3778
|
+
_this6.refreshUpdate(ctx, r.value, 'init');
|
|
3699
3779
|
});
|
|
3700
3780
|
}
|
|
3701
3781
|
_this6.effect(ctx, 'loaded');
|
|
@@ -3716,9 +3796,7 @@
|
|
|
3716
3796
|
if (!controls.length) return false;
|
|
3717
3797
|
var _loop = function _loop(i) {
|
|
3718
3798
|
var control = controls[i],
|
|
3719
|
-
handleFn = control.handle ||
|
|
3720
|
-
return val === control.value;
|
|
3721
|
-
};
|
|
3799
|
+
handleFn = control.handle || (condition[control.condition || '=='] || condition['=='])(control.value);
|
|
3722
3800
|
if (!is.trueArray(control.rule)) return "continue";
|
|
3723
3801
|
var data = _objectSpread2(_objectSpread2({}, control), {}, {
|
|
3724
3802
|
valid: invoke(function () {
|
|
@@ -3745,7 +3823,8 @@
|
|
|
3745
3823
|
prepend = _ref.prepend,
|
|
3746
3824
|
append = _ref.append,
|
|
3747
3825
|
child = _ref.child,
|
|
3748
|
-
ctrl = _ref.ctrl
|
|
3826
|
+
ctrl = _ref.ctrl,
|
|
3827
|
+
method = _ref.method;
|
|
3749
3828
|
if (isHidden) {
|
|
3750
3829
|
valid ? ctx.ctrlRule.push({
|
|
3751
3830
|
__ctrl: true,
|
|
@@ -3753,7 +3832,20 @@
|
|
|
3753
3832
|
valid: valid
|
|
3754
3833
|
}) : ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
|
|
3755
3834
|
hideLst[valid ? 'push' : 'unshift'](function () {
|
|
3756
|
-
|
|
3835
|
+
if (method === 'disabled') {
|
|
3836
|
+
_this7.api.disabled(!valid, rule);
|
|
3837
|
+
} else if (method === 'display') {
|
|
3838
|
+
_this7.api.display(valid, rule);
|
|
3839
|
+
} else if (method === 'required') {
|
|
3840
|
+
rule.forEach(function (item) {
|
|
3841
|
+
_this7.api.setEffect(item, 'required', valid);
|
|
3842
|
+
});
|
|
3843
|
+
if (!valid) {
|
|
3844
|
+
_this7.api.clearValidateState(rule);
|
|
3845
|
+
}
|
|
3846
|
+
} else {
|
|
3847
|
+
_this7.api.hidden(!valid, rule);
|
|
3848
|
+
}
|
|
3757
3849
|
});
|
|
3758
3850
|
return;
|
|
3759
3851
|
}
|
|
@@ -3962,11 +4054,13 @@
|
|
|
3962
4054
|
isQuote: function isQuote(ctx, value) {
|
|
3963
4055
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
3964
4056
|
},
|
|
3965
|
-
refreshUpdate: function refreshUpdate(ctx, val) {
|
|
4057
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
3966
4058
|
var _this4 = this;
|
|
3967
4059
|
if (is.Function(ctx.rule.update)) {
|
|
3968
4060
|
var state = invoke(function () {
|
|
3969
|
-
return ctx.rule.update(val, ctx.origin, _this4.api
|
|
4061
|
+
return ctx.rule.update(val, ctx.origin, _this4.api, {
|
|
4062
|
+
origin: origin || 'change'
|
|
4063
|
+
});
|
|
3970
4064
|
});
|
|
3971
4065
|
if (state === undefined) return;
|
|
3972
4066
|
ctx.rule.hidden = state === true;
|
|
@@ -3976,21 +4070,21 @@
|
|
|
3976
4070
|
this.refreshRule(ctx, val);
|
|
3977
4071
|
this.bus.$emit('change-' + ctx.field, val);
|
|
3978
4072
|
},
|
|
3979
|
-
refreshRule: function refreshRule(ctx, val) {
|
|
4073
|
+
refreshRule: function refreshRule(ctx, val, origin) {
|
|
3980
4074
|
if (this.refreshControl(ctx)) {
|
|
3981
4075
|
this.$render.clearCacheAll();
|
|
3982
4076
|
this.loadRule();
|
|
3983
4077
|
this.vm.$emit('update', this.api);
|
|
3984
4078
|
this.refresh();
|
|
3985
4079
|
}
|
|
3986
|
-
this.refreshUpdate(ctx, val);
|
|
4080
|
+
this.refreshUpdate(ctx, val, origin);
|
|
3987
4081
|
},
|
|
3988
4082
|
appendLink: function appendLink(ctx) {
|
|
3989
4083
|
var _this5 = this;
|
|
3990
4084
|
var link = ctx.rule.link;
|
|
3991
4085
|
is.trueArray(link) && link.forEach(function (field) {
|
|
3992
4086
|
var fn = function fn() {
|
|
3993
|
-
return _this5.refreshRule(ctx, ctx.rule.value);
|
|
4087
|
+
return _this5.refreshRule(ctx, ctx.rule.value, 'link');
|
|
3994
4088
|
};
|
|
3995
4089
|
_this5.bus.$on('change-' + field, fn);
|
|
3996
4090
|
ctx.linkOn.push(function () {
|
|
@@ -4262,7 +4356,12 @@
|
|
|
4262
4356
|
watchEffect: function watchEffect(ctx) {
|
|
4263
4357
|
var _this3 = this;
|
|
4264
4358
|
var vm = this.vm;
|
|
4265
|
-
var effect = {
|
|
4359
|
+
var effect = {
|
|
4360
|
+
required: function required() {
|
|
4361
|
+
var _ctx$rule, _ctx$rule$effect;
|
|
4362
|
+
return (hasProperty(ctx.rule, '$required') ? ctx.rule['$required'] : (_ctx$rule = ctx.rule) === null || _ctx$rule === void 0 ? void 0 : (_ctx$rule$effect = _ctx$rule.effect) === null || _ctx$rule$effect === void 0 ? void 0 : _ctx$rule$effect.required) || false;
|
|
4363
|
+
}
|
|
4364
|
+
};
|
|
4266
4365
|
Object.keys(ctx.rule.effect || {}).forEach(function (k) {
|
|
4267
4366
|
effect[k] = function () {
|
|
4268
4367
|
return ctx.rule.effect[k];
|
|
@@ -4345,7 +4444,7 @@
|
|
|
4345
4444
|
return ctx.clearEffectData(attr);
|
|
4346
4445
|
};
|
|
4347
4446
|
data.mergeProp = function (prop) {
|
|
4348
|
-
return
|
|
4447
|
+
return mergeRule(data.getProp(), [prop]);
|
|
4349
4448
|
};
|
|
4350
4449
|
}
|
|
4351
4450
|
_this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
|
|
@@ -4615,6 +4714,35 @@
|
|
|
4615
4714
|
render: function render(children) {}
|
|
4616
4715
|
});
|
|
4617
4716
|
|
|
4717
|
+
var componentValidate = {
|
|
4718
|
+
name: 'componentValidate',
|
|
4719
|
+
load: function load(attr, rule, api) {
|
|
4720
|
+
var method = attr.getValue();
|
|
4721
|
+
if (!method) {
|
|
4722
|
+
attr.clearProp();
|
|
4723
|
+
api.clearValidateState([rule.field]);
|
|
4724
|
+
} else {
|
|
4725
|
+
attr.getProp().validate = [{
|
|
4726
|
+
validator: function validator() {
|
|
4727
|
+
var ctx = byCtx(rule);
|
|
4728
|
+
if (ctx) {
|
|
4729
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4730
|
+
args[_key] = arguments[_key];
|
|
4731
|
+
}
|
|
4732
|
+
return api.exec.apply(api, [ctx.id, method === true ? 'formCreateValidate' : method].concat(args, [{
|
|
4733
|
+
attr: attr,
|
|
4734
|
+
rule: rule,
|
|
4735
|
+
api: api
|
|
4736
|
+
}]));
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
}];
|
|
4740
|
+
}
|
|
4741
|
+
},
|
|
4742
|
+
watch: function watch() {
|
|
4743
|
+
componentValidate.load.apply(componentValidate, arguments);
|
|
4744
|
+
}
|
|
4745
|
+
};
|
|
4618
4746
|
var fetch$1 = function fetch(fc) {
|
|
4619
4747
|
function parseOpt(option) {
|
|
4620
4748
|
if (is.String(option)) {
|
|
@@ -4728,6 +4856,10 @@
|
|
|
4728
4856
|
return {
|
|
4729
4857
|
message: val
|
|
4730
4858
|
};
|
|
4859
|
+
} else if (is.Undef(val)) {
|
|
4860
|
+
return {
|
|
4861
|
+
required: false
|
|
4862
|
+
};
|
|
4731
4863
|
} else if (is.Function(val)) {
|
|
4732
4864
|
return {
|
|
4733
4865
|
validator: val
|
|
@@ -4740,7 +4872,8 @@
|
|
|
4740
4872
|
}
|
|
4741
4873
|
var $provider = {
|
|
4742
4874
|
fetch: fetch$1,
|
|
4743
|
-
required: $required
|
|
4875
|
+
required: $required,
|
|
4876
|
+
componentValidate: componentValidate
|
|
4744
4877
|
};
|
|
4745
4878
|
|
|
4746
4879
|
var name = 'html';
|
|
@@ -5354,11 +5487,31 @@
|
|
|
5354
5487
|
}
|
|
5355
5488
|
}
|
|
5356
5489
|
var manager = {
|
|
5357
|
-
validate: function validate(
|
|
5358
|
-
this.form()
|
|
5490
|
+
validate: function validate() {
|
|
5491
|
+
var form = this.form();
|
|
5492
|
+
if (form) {
|
|
5493
|
+
return new Promise(function (resolve, reject) {
|
|
5494
|
+
form.validate().then(function (flag) {
|
|
5495
|
+
flag ? resolve(true) : reject(false);
|
|
5496
|
+
});
|
|
5497
|
+
});
|
|
5498
|
+
}
|
|
5499
|
+
return new Promise(function (v) {
|
|
5500
|
+
return v();
|
|
5501
|
+
});
|
|
5359
5502
|
},
|
|
5360
|
-
validateField: function validateField(field
|
|
5361
|
-
this.form()
|
|
5503
|
+
validateField: function validateField(field) {
|
|
5504
|
+
var form = this.form();
|
|
5505
|
+
if (form) {
|
|
5506
|
+
return new Promise(function (resolve, reject) {
|
|
5507
|
+
form.validateField(field, function (e) {
|
|
5508
|
+
e ? reject(e) : resolve(null);
|
|
5509
|
+
});
|
|
5510
|
+
});
|
|
5511
|
+
}
|
|
5512
|
+
return new Promise(function (v) {
|
|
5513
|
+
return v();
|
|
5514
|
+
});
|
|
5362
5515
|
},
|
|
5363
5516
|
clearValidateState: function clearValidateState(ctx) {
|
|
5364
5517
|
var fItem = this.vm.$refs[ctx.wrapRef];
|
|
@@ -5686,87 +5839,47 @@
|
|
|
5686
5839
|
function extendApi(api, h) {
|
|
5687
5840
|
extend(api, {
|
|
5688
5841
|
validate: function validate(callback) {
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5695
|
-
args[_key] = arguments[_key];
|
|
5696
|
-
}
|
|
5697
|
-
if (!args[0] || !flag) {
|
|
5698
|
-
flag = args;
|
|
5699
|
-
}
|
|
5700
|
-
callback && callback.apply(void 0, _toConsumableArray(flag));
|
|
5842
|
+
return new Promise(function (resolve, reject) {
|
|
5843
|
+
var forms = api.children;
|
|
5844
|
+
var all = [h.$manager.validate()];
|
|
5845
|
+
forms.forEach(function (v) {
|
|
5846
|
+
all.push(v.validate());
|
|
5701
5847
|
});
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
validate();
|
|
5712
|
-
}
|
|
5713
|
-
});
|
|
5714
|
-
};
|
|
5715
|
-
forms.forEach(function (form) {
|
|
5716
|
-
form.validate(function () {
|
|
5717
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
5718
|
-
args[_key2] = arguments[_key2];
|
|
5719
|
-
}
|
|
5720
|
-
return validFn(args);
|
|
5848
|
+
Promise.all(all).then(function () {
|
|
5849
|
+
resolve(true);
|
|
5850
|
+
callback && callback(true);
|
|
5851
|
+
})["catch"](function (e) {
|
|
5852
|
+
reject(e);
|
|
5853
|
+
callback && callback(e);
|
|
5854
|
+
h.vm.$emit('validate-fail', e, {
|
|
5855
|
+
api: api
|
|
5856
|
+
});
|
|
5721
5857
|
});
|
|
5722
5858
|
});
|
|
5723
|
-
if (!len) {
|
|
5724
|
-
validate();
|
|
5725
|
-
}
|
|
5726
5859
|
},
|
|
5727
5860
|
validateField: function validateField(field, callback) {
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
}
|
|
5738
|
-
if (args[0]) {
|
|
5739
|
-
flag = args;
|
|
5740
|
-
} else if (flag) {
|
|
5741
|
-
return callback && callback('子表单验证未通过');
|
|
5742
|
-
}
|
|
5743
|
-
callback && callback.apply(void 0, _toConsumableArray(flag || args));
|
|
5744
|
-
});
|
|
5745
|
-
};
|
|
5746
|
-
var validFn = function validFn(args) {
|
|
5747
|
-
setTimeout(function () {
|
|
5748
|
-
if (!args[0]) {
|
|
5749
|
-
if (!flag) {
|
|
5750
|
-
flag = args;
|
|
5751
|
-
}
|
|
5752
|
-
}
|
|
5753
|
-
if (! --len) {
|
|
5754
|
-
validate();
|
|
5755
|
-
}
|
|
5861
|
+
return new Promise(function (resolve, reject) {
|
|
5862
|
+
var ctx = h.getFieldCtx(field);
|
|
5863
|
+
if (!ctx) return;
|
|
5864
|
+
var sub = h.subForm[ctx.id];
|
|
5865
|
+
var all = [h.$manager.validateField(ctx.id)];
|
|
5866
|
+
toArray(sub).forEach(function (v) {
|
|
5867
|
+
all.push(v.validate()["catch"](function () {
|
|
5868
|
+
return Promise.reject('子表单验证未通过');
|
|
5869
|
+
}));
|
|
5756
5870
|
});
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5871
|
+
Promise.all(all).then(function () {
|
|
5872
|
+
resolve(null);
|
|
5873
|
+
callback && callback(null);
|
|
5874
|
+
})["catch"](function (e) {
|
|
5875
|
+
reject(e);
|
|
5876
|
+
callback && callback(e);
|
|
5877
|
+
h.vm.$emit('validate-field-fail', e, {
|
|
5878
|
+
field: field,
|
|
5879
|
+
api: api
|
|
5880
|
+
});
|
|
5765
5881
|
});
|
|
5766
5882
|
});
|
|
5767
|
-
if (!len) {
|
|
5768
|
-
validate();
|
|
5769
|
-
}
|
|
5770
5883
|
},
|
|
5771
5884
|
clearValidateState: function clearValidateState(fields) {
|
|
5772
5885
|
var _this = this;
|
|
@@ -5887,7 +6000,7 @@
|
|
|
5887
6000
|
function ivuFormCreate() {
|
|
5888
6001
|
return FormCreateFactory({
|
|
5889
6002
|
ui: "".concat("iview"),
|
|
5890
|
-
version: "".concat("2.5.
|
|
6003
|
+
version: "".concat("2.5.29"),
|
|
5891
6004
|
manager: manager,
|
|
5892
6005
|
install: install,
|
|
5893
6006
|
extendApi: extendApi,
|