@form-create/element-ui 3.2.15 → 3.2.16
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/README.md +32 -13
- package/dist/form-create.esm.js +81 -35
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +81 -35
- package/dist/form-create.min.js +2 -2
- package/package.json +3 -3
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.2.
|
|
2
|
+
* @form-create/element-ui v3.2.16
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -2882,6 +2882,21 @@
|
|
|
2882
2882
|
|
|
2883
2883
|
return Object.keys(matches);
|
|
2884
2884
|
}
|
|
2885
|
+
function convertFieldToConditions(field) {
|
|
2886
|
+
var parts = field.split('.');
|
|
2887
|
+
var conditions = [];
|
|
2888
|
+
var currentCondition = '';
|
|
2889
|
+
parts.forEach(function (part, index) {
|
|
2890
|
+
if (index === 0) {
|
|
2891
|
+
currentCondition = part;
|
|
2892
|
+
} else {
|
|
2893
|
+
currentCondition += '.' + part;
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
conditions.push(currentCondition);
|
|
2897
|
+
});
|
|
2898
|
+
return conditions.join(' && ');
|
|
2899
|
+
}
|
|
2885
2900
|
|
|
2886
2901
|
function baseRule() {
|
|
2887
2902
|
return {
|
|
@@ -3674,11 +3689,16 @@
|
|
|
3674
3689
|
});
|
|
3675
3690
|
});
|
|
3676
3691
|
},
|
|
3677
|
-
watchFetch: function watchFetch(opt, callback, error) {
|
|
3692
|
+
watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
|
|
3678
3693
|
return h.fc.watchLoadData(function (get, change) {
|
|
3679
3694
|
var _opt = deepCopy(opt);
|
|
3680
3695
|
|
|
3681
3696
|
_opt = h.loadFetchVar(_opt, get);
|
|
3697
|
+
|
|
3698
|
+
if (beforeFetch && beforeFetch(_opt, change) === false) {
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3682
3702
|
h.beforeFetch(_opt).then(function () {
|
|
3683
3703
|
return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
|
|
3684
3704
|
invoke(function () {
|
|
@@ -3692,7 +3712,7 @@
|
|
|
3692
3712
|
error && error(e);
|
|
3693
3713
|
});
|
|
3694
3714
|
});
|
|
3695
|
-
});
|
|
3715
|
+
}, opt.wait == null ? 1000 : opt.wait);
|
|
3696
3716
|
},
|
|
3697
3717
|
getData: function getData(id, def) {
|
|
3698
3718
|
return h.fc.getLoadData(id, def);
|
|
@@ -4909,8 +4929,8 @@
|
|
|
4909
4929
|
var rule = ctx.rule;
|
|
4910
4930
|
is.trueArray(rule.sync) && mergeProps([{
|
|
4911
4931
|
on: rule.sync.reduce(function (pre, prop) {
|
|
4912
|
-
pre["update:".concat(prop)] = function (val) {
|
|
4913
|
-
rule.props[prop] = val;
|
|
4932
|
+
pre[_typeof(prop) === 'object' && prop.event || "update:".concat(prop)] = function (val) {
|
|
4933
|
+
rule.props[_typeof(prop) === 'object' && prop.prop || prop] = val;
|
|
4914
4934
|
|
|
4915
4935
|
_this4.vm.emit('sync', prop, val, rule, _this4.fapi);
|
|
4916
4936
|
};
|
|
@@ -5036,7 +5056,7 @@
|
|
|
5036
5056
|
return;
|
|
5037
5057
|
}
|
|
5038
5058
|
|
|
5039
|
-
rules[index] = _rule = _rule._clone ? _rule._clone() :
|
|
5059
|
+
rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
|
|
5040
5060
|
ctx = null;
|
|
5041
5061
|
isCopy = true;
|
|
5042
5062
|
}
|
|
@@ -5564,6 +5584,7 @@
|
|
|
5564
5584
|
};
|
|
5565
5585
|
|
|
5566
5586
|
var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
|
|
5587
|
+
var oldValueTag = Symbol('oldValue');
|
|
5567
5588
|
function useContext(Handler) {
|
|
5568
5589
|
extend(Handler.prototype, {
|
|
5569
5590
|
getCtx: function getCtx(id) {
|
|
@@ -5833,7 +5854,7 @@
|
|
|
5833
5854
|
|
|
5834
5855
|
var value = _this.compute(ctx, item);
|
|
5835
5856
|
|
|
5836
|
-
if (item.linkage && value ===
|
|
5857
|
+
if (item.linkage && value === oldValueTag) {
|
|
5837
5858
|
return oldValue;
|
|
5838
5859
|
}
|
|
5839
5860
|
|
|
@@ -5888,10 +5909,22 @@
|
|
|
5888
5909
|
var _loop = function _loop(i) {
|
|
5889
5910
|
var one = item.group[i];
|
|
5890
5911
|
var flag = void 0;
|
|
5891
|
-
var field =
|
|
5912
|
+
var field = null;
|
|
5892
5913
|
|
|
5893
5914
|
if (one.variable) {
|
|
5894
5915
|
field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
|
|
5916
|
+
} else if (one.field) {
|
|
5917
|
+
field = convertFieldToConditions(one.field || '');
|
|
5918
|
+
} else {
|
|
5919
|
+
return {
|
|
5920
|
+
v: true
|
|
5921
|
+
};
|
|
5922
|
+
}
|
|
5923
|
+
|
|
5924
|
+
var compare = one.compare;
|
|
5925
|
+
|
|
5926
|
+
if (compare) {
|
|
5927
|
+
compare = convertFieldToConditions(compare || '');
|
|
5895
5928
|
}
|
|
5896
5929
|
|
|
5897
5930
|
if (one.mode) {
|
|
@@ -5903,7 +5936,7 @@
|
|
|
5903
5936
|
return one.handler(_this2.api, ctx.rule);
|
|
5904
5937
|
});
|
|
5905
5938
|
} else {
|
|
5906
|
-
flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(
|
|
5939
|
+
flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
|
|
5907
5940
|
}
|
|
5908
5941
|
|
|
5909
5942
|
if (or && flag) {
|
|
@@ -5932,7 +5965,7 @@
|
|
|
5932
5965
|
if (item.linkage) {
|
|
5933
5966
|
return val ? invoke(function () {
|
|
5934
5967
|
return _this2.computeValue(item.linkage, ctx, group);
|
|
5935
|
-
}, undefined) :
|
|
5968
|
+
}, undefined) : oldValueTag;
|
|
5936
5969
|
}
|
|
5937
5970
|
|
|
5938
5971
|
return val;
|
|
@@ -6329,9 +6362,14 @@
|
|
|
6329
6362
|
this.$manager = new fc.manager(this);
|
|
6330
6363
|
this.$render = new Render(this);
|
|
6331
6364
|
this.api = fc.extendApiFn.reduce(function (api, fn) {
|
|
6332
|
-
|
|
6365
|
+
var extendApi = invoke(function () {
|
|
6333
6366
|
return fn(api, _this);
|
|
6334
|
-
}
|
|
6367
|
+
});
|
|
6368
|
+
|
|
6369
|
+
if (extendApi && extendApi !== api) {
|
|
6370
|
+
extend(api, extendApi);
|
|
6371
|
+
}
|
|
6372
|
+
|
|
6335
6373
|
return api;
|
|
6336
6374
|
}, Api(this));
|
|
6337
6375
|
}
|
|
@@ -7034,7 +7072,8 @@
|
|
|
7034
7072
|
}
|
|
7035
7073
|
|
|
7036
7074
|
var id = 1;
|
|
7037
|
-
var instance = {};
|
|
7075
|
+
var instance = {};
|
|
7076
|
+
var defValueTag = Symbol('defValue'); //todo 表单嵌套
|
|
7038
7077
|
|
|
7039
7078
|
function FormCreateFactory(config) {
|
|
7040
7079
|
var components = _defineProperty({}, fragment.name, fragment);
|
|
@@ -7257,7 +7296,11 @@
|
|
|
7257
7296
|
id = split.shift();
|
|
7258
7297
|
var field = split.join('.');
|
|
7259
7298
|
|
|
7260
|
-
if (hasProperty(loadData, id)) {
|
|
7299
|
+
if (!hasProperty(loadData, id)) {
|
|
7300
|
+
loadData[id] = defValueTag;
|
|
7301
|
+
}
|
|
7302
|
+
|
|
7303
|
+
if (loadData[id] !== defValueTag) {
|
|
7261
7304
|
var val = loadData[id];
|
|
7262
7305
|
|
|
7263
7306
|
if (val && val._driver) {
|
|
@@ -7310,6 +7353,7 @@
|
|
|
7310
7353
|
},
|
|
7311
7354
|
drivers: drivers,
|
|
7312
7355
|
renderDriver: null,
|
|
7356
|
+
get: null,
|
|
7313
7357
|
refreshData: refreshData,
|
|
7314
7358
|
loadData: loadData,
|
|
7315
7359
|
CreateNode: CreateNode,
|
|
@@ -7542,22 +7586,11 @@
|
|
|
7542
7586
|
var handle = is.Function(option) ? option : option.handle;
|
|
7543
7587
|
|
|
7544
7588
|
if (handle) {
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
_this5.bus.$emit('$loadData.$var.' + key);
|
|
7551
|
-
|
|
7552
|
-
return val;
|
|
7553
|
-
}
|
|
7554
|
-
|
|
7555
|
-
val = invoke(function () {
|
|
7556
|
-
return handle(get, _this5.$handle.api);
|
|
7557
|
-
});
|
|
7558
|
-
});
|
|
7559
|
-
this.unwatch.push(unwatch);
|
|
7560
|
-
return val;
|
|
7589
|
+
return deepGet(invoke(function () {
|
|
7590
|
+
return handle(_this5.get || function () {
|
|
7591
|
+
return _this5.getLoadData.apply(_this5, arguments);
|
|
7592
|
+
}, _this5.$handle.api);
|
|
7593
|
+
}), split);
|
|
7561
7594
|
}
|
|
7562
7595
|
}
|
|
7563
7596
|
},
|
|
@@ -7596,7 +7629,12 @@
|
|
|
7596
7629
|
split = [];
|
|
7597
7630
|
} else {
|
|
7598
7631
|
var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
|
|
7599
|
-
|
|
7632
|
+
|
|
7633
|
+
if (!hasProperty(tmpData, key)) {
|
|
7634
|
+
tmpData[key] = defValueTag;
|
|
7635
|
+
}
|
|
7636
|
+
|
|
7637
|
+
val = tmpData[key] !== defValueTag ? deepGet(tmpData, id) : getData(id);
|
|
7600
7638
|
split = [];
|
|
7601
7639
|
}
|
|
7602
7640
|
|
|
@@ -7607,15 +7645,23 @@
|
|
|
7607
7645
|
|
|
7608
7646
|
return val == null || val === '' ? def : val;
|
|
7609
7647
|
},
|
|
7610
|
-
watchLoadData: function watchLoadData(fn) {
|
|
7648
|
+
watchLoadData: function watchLoadData(fn, wait) {
|
|
7611
7649
|
var _this6 = this;
|
|
7612
7650
|
|
|
7613
7651
|
var unwatch = {};
|
|
7614
7652
|
|
|
7615
7653
|
var run = function run(flag) {
|
|
7654
|
+
if (!_this6.get) {
|
|
7655
|
+
_this6.get = get;
|
|
7656
|
+
}
|
|
7657
|
+
|
|
7616
7658
|
invoke(function () {
|
|
7617
7659
|
fn(get, flag);
|
|
7618
7660
|
});
|
|
7661
|
+
|
|
7662
|
+
if (_this6.get === get) {
|
|
7663
|
+
_this6.get = undefined;
|
|
7664
|
+
}
|
|
7619
7665
|
};
|
|
7620
7666
|
|
|
7621
7667
|
var get = function get(id, def) {
|
|
@@ -7638,7 +7684,7 @@
|
|
|
7638
7684
|
unwatch[id].val = temp;
|
|
7639
7685
|
run(true);
|
|
7640
7686
|
}
|
|
7641
|
-
}, 0);
|
|
7687
|
+
}, wait || 0);
|
|
7642
7688
|
var un = vue.watch(data, function (n) {
|
|
7643
7689
|
callback();
|
|
7644
7690
|
});
|
|
@@ -7698,7 +7744,7 @@
|
|
|
7698
7744
|
this.updateOptions(options);
|
|
7699
7745
|
},
|
|
7700
7746
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
7701
|
-
opt =
|
|
7747
|
+
opt = _objectSpread2({}, opt || {});
|
|
7702
7748
|
parent && ['page', 'onSubmit', 'onReset', 'onCreated', 'onChange', 'onMounted', 'mounted', 'onReload', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
|
|
7703
7749
|
delete opt[n];
|
|
7704
7750
|
});
|
|
@@ -8755,7 +8801,7 @@
|
|
|
8755
8801
|
function elmFormCreate() {
|
|
8756
8802
|
return FormCreateFactory({
|
|
8757
8803
|
ui: 'element-ui',
|
|
8758
|
-
version: '3.2.
|
|
8804
|
+
version: '3.2.16',
|
|
8759
8805
|
manager: manager,
|
|
8760
8806
|
extendApi: extendApi,
|
|
8761
8807
|
install: install,
|