@form-create/element-ui 2.5.25 → 2.5.26
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 +121 -88
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +4 -4
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.26
|
|
3
3
|
* (c) 2018-2022 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -1676,7 +1676,7 @@
|
|
|
1676
1676
|
"attrs": {
|
|
1677
1677
|
"span": button ? 20 : 24
|
|
1678
1678
|
}
|
|
1679
|
-
}, [h(
|
|
1679
|
+
}, [h(Type, helper([{
|
|
1680
1680
|
"key": key
|
|
1681
1681
|
}, {
|
|
1682
1682
|
"on": {
|
|
@@ -1701,7 +1701,7 @@
|
|
|
1701
1701
|
extendOption: true,
|
|
1702
1702
|
inFor: true
|
|
1703
1703
|
}
|
|
1704
|
-
}]))])
|
|
1704
|
+
}]))]), button ? h("ElCol", helper([{}, {
|
|
1705
1705
|
"props": {
|
|
1706
1706
|
span: 2,
|
|
1707
1707
|
pull: 1,
|
|
@@ -1904,7 +1904,7 @@
|
|
|
1904
1904
|
value: {
|
|
1905
1905
|
handler: function handler(n) {
|
|
1906
1906
|
if (JSON.stringify(n || {}) === this.updateValue) return;
|
|
1907
|
-
this.$f.setValue(n || {});
|
|
1907
|
+
this.$f.config.forceCoverValue ? this.$f.coverValue(n || {}) : this.$f.setValue(n || {});
|
|
1908
1908
|
},
|
|
1909
1909
|
deep: true
|
|
1910
1910
|
},
|
|
@@ -2144,7 +2144,11 @@
|
|
|
2144
2144
|
return rule;
|
|
2145
2145
|
}
|
|
2146
2146
|
function getRule(rule) {
|
|
2147
|
-
|
|
2147
|
+
var r = is.Function(rule.getRule) ? rule.getRule() : rule;
|
|
2148
|
+
if (!r.type) {
|
|
2149
|
+
r.type = 'input';
|
|
2150
|
+
}
|
|
2151
|
+
return r;
|
|
2148
2152
|
}
|
|
2149
2153
|
function mergeGlobal(target, merge) {
|
|
2150
2154
|
if (!target) return merge;
|
|
@@ -2314,15 +2318,19 @@
|
|
|
2314
2318
|
return copy(ctx.rule.value);
|
|
2315
2319
|
},
|
|
2316
2320
|
coverValue: function coverValue(formData) {
|
|
2321
|
+
var data = _objectSpread2({}, formData || {});
|
|
2317
2322
|
h.deferSyncValue(function () {
|
|
2318
2323
|
api.fields().forEach(function (key) {
|
|
2319
2324
|
var ctxs = h.fieldCtx[key];
|
|
2320
|
-
if (
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
+
if (ctxs) {
|
|
2326
|
+
var flag = hasProperty(data, key);
|
|
2327
|
+
ctxs.forEach(function (ctx) {
|
|
2328
|
+
ctx.rule.value = flag ? data[key] : undefined;
|
|
2329
|
+
});
|
|
2330
|
+
delete data[key];
|
|
2331
|
+
}
|
|
2325
2332
|
});
|
|
2333
|
+
extend(h.appendData, data);
|
|
2326
2334
|
});
|
|
2327
2335
|
},
|
|
2328
2336
|
setValue: function setValue(field) {
|
|
@@ -2542,6 +2550,16 @@
|
|
|
2542
2550
|
$set(ctx.rule.effect, attr, value);
|
|
2543
2551
|
}
|
|
2544
2552
|
},
|
|
2553
|
+
clearEffectData: function clearEffectData(id, attr) {
|
|
2554
|
+
var ctx = h.getCtx(id);
|
|
2555
|
+
if (ctx) {
|
|
2556
|
+
if (attr && attr[0] === '$') {
|
|
2557
|
+
attr = attr.substr(1);
|
|
2558
|
+
}
|
|
2559
|
+
ctx.clearEffectData(attr);
|
|
2560
|
+
api.sync(id);
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2545
2563
|
updateValidate: function updateValidate(id, validate, merge) {
|
|
2546
2564
|
if (merge) {
|
|
2547
2565
|
api.mergeRule(id, {
|
|
@@ -3338,7 +3356,7 @@
|
|
|
3338
3356
|
__fc__: enumerable(ctx, true)
|
|
3339
3357
|
});
|
|
3340
3358
|
}
|
|
3341
|
-
function RuleContext(handle, rule) {
|
|
3359
|
+
function RuleContext(handle, rule, defaultValue) {
|
|
3342
3360
|
var id = uniqueId();
|
|
3343
3361
|
extend(this, {
|
|
3344
3362
|
id: id,
|
|
@@ -3358,7 +3376,7 @@
|
|
|
3358
3376
|
payload: {},
|
|
3359
3377
|
input: !!rule.field,
|
|
3360
3378
|
el: undefined,
|
|
3361
|
-
defaultValue: rule.field ? deepCopy(
|
|
3379
|
+
defaultValue: rule.field ? deepCopy(defaultValue) : undefined,
|
|
3362
3380
|
field: rule.field || undefined
|
|
3363
3381
|
});
|
|
3364
3382
|
this.updateType();
|
|
@@ -3374,7 +3392,11 @@
|
|
|
3374
3392
|
return this.payload[name];
|
|
3375
3393
|
},
|
|
3376
3394
|
clearEffectData: function clearEffectData(name) {
|
|
3377
|
-
|
|
3395
|
+
if (name === undefined) {
|
|
3396
|
+
this.payload = {};
|
|
3397
|
+
} else {
|
|
3398
|
+
delete this.payload[name];
|
|
3399
|
+
}
|
|
3378
3400
|
},
|
|
3379
3401
|
updateKey: function updateKey(flag) {
|
|
3380
3402
|
this.key = uniqueId();
|
|
@@ -3593,7 +3615,6 @@
|
|
|
3593
3615
|
rules.map(function (_rule, index) {
|
|
3594
3616
|
if (parent && (is.String(_rule) || is.Undef(_rule))) return;
|
|
3595
3617
|
if (!_this6.pageEnd && !parent && index >= _this6.first) return;
|
|
3596
|
-
if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
|
|
3597
3618
|
if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
|
|
3598
3619
|
loadChildren(_rule.__fc__.rule.children, _rule.__fc__);
|
|
3599
3620
|
return _rule.__fc__;
|
|
@@ -3611,8 +3632,10 @@
|
|
|
3611
3632
|
var ctx;
|
|
3612
3633
|
var isCopy = false;
|
|
3613
3634
|
var isInit = !!_rule.__fc__;
|
|
3635
|
+
var defaultValue = rule.value;
|
|
3614
3636
|
if (isInit) {
|
|
3615
3637
|
ctx = _rule.__fc__;
|
|
3638
|
+
defaultValue = ctx.defaultValue;
|
|
3616
3639
|
var check = !ctx.check(_this6);
|
|
3617
3640
|
if (ctx.deleted) {
|
|
3618
3641
|
if (check) {
|
|
@@ -3633,7 +3656,8 @@
|
|
|
3633
3656
|
}
|
|
3634
3657
|
}
|
|
3635
3658
|
if (!ctx) {
|
|
3636
|
-
|
|
3659
|
+
var _rule2 = _this6.parseRule(_rule);
|
|
3660
|
+
ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
|
|
3637
3661
|
_this6.bindParser(ctx);
|
|
3638
3662
|
} else {
|
|
3639
3663
|
if (ctx.originType !== ctx.rule.type) {
|
|
@@ -3923,7 +3947,7 @@
|
|
|
3923
3947
|
if (this.deferSyncFn) {
|
|
3924
3948
|
return this.deferSyncFn.sync = true;
|
|
3925
3949
|
}
|
|
3926
|
-
this.vm._updateValue(_objectSpread2({}, this.form));
|
|
3950
|
+
this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
|
|
3927
3951
|
},
|
|
3928
3952
|
isChange: function isChange(ctx, value) {
|
|
3929
3953
|
return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
|
|
@@ -4206,6 +4230,9 @@
|
|
|
4206
4230
|
var ps = this.fc.providers;
|
|
4207
4231
|
Object.keys(ps).forEach(function (k) {
|
|
4208
4232
|
var prop = ps[k];
|
|
4233
|
+
if (is.Function(prop)) {
|
|
4234
|
+
prop = prop(_this.fc);
|
|
4235
|
+
}
|
|
4209
4236
|
prop._c = getComponent(prop);
|
|
4210
4237
|
_this.onEffect(prop);
|
|
4211
4238
|
_this.providers[k] = prop;
|
|
@@ -4580,17 +4607,84 @@
|
|
|
4580
4607
|
render: function render(children) {}
|
|
4581
4608
|
});
|
|
4582
4609
|
|
|
4583
|
-
var $
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4610
|
+
var fetch$1 = function fetch(fc) {
|
|
4611
|
+
function parseOpt(option) {
|
|
4612
|
+
if (is.String(option)) {
|
|
4613
|
+
option = {
|
|
4614
|
+
action: option,
|
|
4615
|
+
to: 'options'
|
|
4616
|
+
};
|
|
4617
|
+
}
|
|
4618
|
+
return option;
|
|
4619
|
+
}
|
|
4620
|
+
function run(inject, rule, api) {
|
|
4621
|
+
var option = inject.value;
|
|
4622
|
+
if (is.Function(option)) {
|
|
4623
|
+
option = option(rule, api);
|
|
4592
4624
|
}
|
|
4625
|
+
option = parseOpt(option);
|
|
4626
|
+
if (!option || !option.action) {
|
|
4627
|
+
return false;
|
|
4628
|
+
}
|
|
4629
|
+
if (!option.to) {
|
|
4630
|
+
option.to = 'options';
|
|
4631
|
+
}
|
|
4632
|
+
var _onError = option.onError;
|
|
4633
|
+
var check = function check() {
|
|
4634
|
+
if (!inject.getValue()) {
|
|
4635
|
+
inject.clearProp();
|
|
4636
|
+
api.sync(rule);
|
|
4637
|
+
return true;
|
|
4638
|
+
}
|
|
4639
|
+
};
|
|
4640
|
+
var set = function set(val) {
|
|
4641
|
+
if (val === undefined) {
|
|
4642
|
+
inject.clearProp();
|
|
4643
|
+
api.sync(rule);
|
|
4644
|
+
} else {
|
|
4645
|
+
deepSet(inject.getProp(), option.to, val);
|
|
4646
|
+
}
|
|
4647
|
+
};
|
|
4648
|
+
invoke(function () {
|
|
4649
|
+
return fc.create.fetch(_objectSpread2(_objectSpread2({}, option), {}, {
|
|
4650
|
+
onSuccess: function onSuccess(body) {
|
|
4651
|
+
if (check()) return;
|
|
4652
|
+
var fn = function fn(v) {
|
|
4653
|
+
return v.data;
|
|
4654
|
+
};
|
|
4655
|
+
if (is.Function(option.parse)) {
|
|
4656
|
+
fn = option.parse;
|
|
4657
|
+
}
|
|
4658
|
+
set(fn(body, rule, api));
|
|
4659
|
+
api.sync(rule);
|
|
4660
|
+
},
|
|
4661
|
+
onError: function onError(e) {
|
|
4662
|
+
set(undefined);
|
|
4663
|
+
if (check()) return;
|
|
4664
|
+
(_onError || function (e) {
|
|
4665
|
+
return err(e.message || 'fetch fail ' + option.action);
|
|
4666
|
+
})(e, rule, api);
|
|
4667
|
+
}
|
|
4668
|
+
}), {
|
|
4669
|
+
inject: inject,
|
|
4670
|
+
rule: rule,
|
|
4671
|
+
api: api
|
|
4672
|
+
});
|
|
4673
|
+
});
|
|
4674
|
+
return true;
|
|
4593
4675
|
}
|
|
4676
|
+
return {
|
|
4677
|
+
name: 'fetch',
|
|
4678
|
+
loaded: function loaded() {
|
|
4679
|
+
run.apply(void 0, arguments);
|
|
4680
|
+
},
|
|
4681
|
+
watch: function watch(inject, rule, api) {
|
|
4682
|
+
if (!run(inject, rule, api)) {
|
|
4683
|
+
inject.clearProp();
|
|
4684
|
+
api.sync(rule);
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4687
|
+
};
|
|
4594
4688
|
};
|
|
4595
4689
|
var $required = {
|
|
4596
4690
|
name: 'required',
|
|
@@ -4636,69 +4730,8 @@
|
|
|
4636
4730
|
return val;
|
|
4637
4731
|
}
|
|
4638
4732
|
}
|
|
4639
|
-
function parseOpt(option) {
|
|
4640
|
-
if (is.String(option)) {
|
|
4641
|
-
option = {
|
|
4642
|
-
action: option,
|
|
4643
|
-
to: 'options'
|
|
4644
|
-
};
|
|
4645
|
-
}
|
|
4646
|
-
return option;
|
|
4647
|
-
}
|
|
4648
|
-
function run(inject, rule, api) {
|
|
4649
|
-
var option = inject.value;
|
|
4650
|
-
if (is.Function(option)) {
|
|
4651
|
-
option = option(rule, api);
|
|
4652
|
-
}
|
|
4653
|
-
option = parseOpt(option);
|
|
4654
|
-
if (!option || !option.action) {
|
|
4655
|
-
return false;
|
|
4656
|
-
}
|
|
4657
|
-
if (!option.to) {
|
|
4658
|
-
option.to = 'options';
|
|
4659
|
-
}
|
|
4660
|
-
var _onError = option.onError;
|
|
4661
|
-
var check = function check() {
|
|
4662
|
-
if (!inject.getValue()) {
|
|
4663
|
-
inject.clearProp();
|
|
4664
|
-
api.sync(rule);
|
|
4665
|
-
return true;
|
|
4666
|
-
}
|
|
4667
|
-
};
|
|
4668
|
-
var set = function set(val) {
|
|
4669
|
-
if (val === undefined) {
|
|
4670
|
-
inject.clearProp();
|
|
4671
|
-
api.sync(rule);
|
|
4672
|
-
} else {
|
|
4673
|
-
deepSet(inject.getProp(), option.to, val);
|
|
4674
|
-
}
|
|
4675
|
-
};
|
|
4676
|
-
invoke(function () {
|
|
4677
|
-
return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
|
|
4678
|
-
onSuccess: function onSuccess(body) {
|
|
4679
|
-
if (check()) return;
|
|
4680
|
-
var fn = function fn(v) {
|
|
4681
|
-
return v.data;
|
|
4682
|
-
};
|
|
4683
|
-
if (is.Function(option.parse)) {
|
|
4684
|
-
fn = option.parse;
|
|
4685
|
-
}
|
|
4686
|
-
set(fn(body, rule, api));
|
|
4687
|
-
api.sync(rule);
|
|
4688
|
-
},
|
|
4689
|
-
onError: function onError(e) {
|
|
4690
|
-
set(undefined);
|
|
4691
|
-
if (check()) return;
|
|
4692
|
-
(_onError || function (e) {
|
|
4693
|
-
return err(e.message || 'fetch fail ' + option.action);
|
|
4694
|
-
})(e, rule, api);
|
|
4695
|
-
}
|
|
4696
|
-
}));
|
|
4697
|
-
});
|
|
4698
|
-
return true;
|
|
4699
|
-
}
|
|
4700
4733
|
var $provider = {
|
|
4701
|
-
fetch: $
|
|
4734
|
+
fetch: fetch$1,
|
|
4702
4735
|
required: $required
|
|
4703
4736
|
};
|
|
4704
4737
|
|
|
@@ -5807,7 +5840,7 @@
|
|
|
5807
5840
|
function elmFormCreate() {
|
|
5808
5841
|
return FormCreateFactory({
|
|
5809
5842
|
ui: "".concat("element-ui"),
|
|
5810
|
-
version: "".concat("2.5.
|
|
5843
|
+
version: "".concat("2.5.26"),
|
|
5811
5844
|
manager: manager,
|
|
5812
5845
|
extendApi: extendApi,
|
|
5813
5846
|
install: install,
|