@form-create/element-ui 2.5.11 → 2.5.15
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 +152 -93
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +13 -13
- package/src/core/manager.js +18 -22
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.15
|
|
3
3
|
* (c) 2018-2021 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -268,6 +268,12 @@
|
|
|
268
268
|
type: String
|
|
269
269
|
},
|
|
270
270
|
watch: {
|
|
271
|
+
'formCreateInject.options': {
|
|
272
|
+
handler: function handler() {
|
|
273
|
+
this.update();
|
|
274
|
+
},
|
|
275
|
+
deep: true
|
|
276
|
+
},
|
|
271
277
|
value: function value() {
|
|
272
278
|
this.update();
|
|
273
279
|
}
|
|
@@ -278,8 +284,12 @@
|
|
|
278
284
|
};
|
|
279
285
|
},
|
|
280
286
|
methods: {
|
|
287
|
+
options: function options() {
|
|
288
|
+
var opt = this.formCreateInject.options;
|
|
289
|
+
return Array.isArray(opt) ? opt : [];
|
|
290
|
+
},
|
|
281
291
|
onInput: function onInput(n) {
|
|
282
|
-
this.$emit('input', this.
|
|
292
|
+
this.$emit('input', this.options().filter(function (opt) {
|
|
283
293
|
return n.indexOf(opt.label) !== -1;
|
|
284
294
|
}).map(function (opt) {
|
|
285
295
|
return opt.value;
|
|
@@ -290,7 +300,7 @@
|
|
|
290
300
|
update: function update() {
|
|
291
301
|
var _this = this;
|
|
292
302
|
|
|
293
|
-
this.trueValue = this.value ? this.
|
|
303
|
+
this.trueValue = this.value ? this.options().filter(function (opt) {
|
|
294
304
|
return _this.value.indexOf(opt.value) !== -1;
|
|
295
305
|
}).map(function (option) {
|
|
296
306
|
return option.label;
|
|
@@ -311,7 +321,7 @@
|
|
|
311
321
|
"on": {
|
|
312
322
|
"input": this.onInput
|
|
313
323
|
}
|
|
314
|
-
}]), [this.
|
|
324
|
+
}]), [this.options().map(function (opt, index) {
|
|
315
325
|
var props = _objectSpread2({}, opt);
|
|
316
326
|
|
|
317
327
|
var Type = _this2.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
|
|
@@ -855,6 +865,12 @@
|
|
|
855
865
|
type: String
|
|
856
866
|
},
|
|
857
867
|
watch: {
|
|
868
|
+
'formCreateInject.options': {
|
|
869
|
+
handler: function handler() {
|
|
870
|
+
this.update();
|
|
871
|
+
},
|
|
872
|
+
deep: true
|
|
873
|
+
},
|
|
858
874
|
value: function value() {
|
|
859
875
|
this.update();
|
|
860
876
|
}
|
|
@@ -865,8 +881,12 @@
|
|
|
865
881
|
};
|
|
866
882
|
},
|
|
867
883
|
methods: {
|
|
884
|
+
options: function options() {
|
|
885
|
+
var opt = this.formCreateInject.options;
|
|
886
|
+
return Array.isArray(opt) ? opt : [];
|
|
887
|
+
},
|
|
868
888
|
onInput: function onInput(n) {
|
|
869
|
-
this.$emit('input', this.
|
|
889
|
+
this.$emit('input', this.options().filter(function (opt) {
|
|
870
890
|
return opt.label === n;
|
|
871
891
|
}).reduce(function (initial, opt) {
|
|
872
892
|
return opt.value;
|
|
@@ -875,7 +895,7 @@
|
|
|
875
895
|
update: function update() {
|
|
876
896
|
var _this = this;
|
|
877
897
|
|
|
878
|
-
this.trueValue = this.
|
|
898
|
+
this.trueValue = this.options().filter(function (opt) {
|
|
879
899
|
return opt.value === _this.value;
|
|
880
900
|
}).reduce(function (initial, opt) {
|
|
881
901
|
return opt.label;
|
|
@@ -896,7 +916,7 @@
|
|
|
896
916
|
"on": {
|
|
897
917
|
"input": this.onInput
|
|
898
918
|
}
|
|
899
|
-
}]), [this.
|
|
919
|
+
}]), [this.options().map(function (opt, index) {
|
|
900
920
|
var props = _objectSpread2({}, opt);
|
|
901
921
|
|
|
902
922
|
var Type = _this2.type === 'button' ? 'ElRadioButton' : 'ElRadio';
|
|
@@ -943,7 +963,8 @@
|
|
|
943
963
|
}
|
|
944
964
|
},
|
|
945
965
|
render: function render(h, ctx) {
|
|
946
|
-
|
|
966
|
+
var options = ctx.props.formCreateInject.options;
|
|
967
|
+
return h("ElSelect", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
|
|
947
968
|
var slot = props.slot;
|
|
948
969
|
return h("ElOption", {
|
|
949
970
|
"props": _objectSpread2({}, props),
|
|
@@ -1350,7 +1371,8 @@
|
|
|
1350
1371
|
return {
|
|
1351
1372
|
len: 0,
|
|
1352
1373
|
cacheRule: {},
|
|
1353
|
-
cacheValue: {}
|
|
1374
|
+
cacheValue: {},
|
|
1375
|
+
type: undefined
|
|
1354
1376
|
};
|
|
1355
1377
|
},
|
|
1356
1378
|
computed: {
|
|
@@ -1522,7 +1544,7 @@
|
|
|
1522
1544
|
this.addRule(i, true);
|
|
1523
1545
|
},
|
|
1524
1546
|
del: function del(index, key) {
|
|
1525
|
-
if (this.disabled || false === this.onBeforeRemove(this.value)) {
|
|
1547
|
+
if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
|
|
1526
1548
|
return;
|
|
1527
1549
|
}
|
|
1528
1550
|
|
|
@@ -1591,6 +1613,7 @@
|
|
|
1591
1613
|
}
|
|
1592
1614
|
},
|
|
1593
1615
|
created: function created() {
|
|
1616
|
+
this.type = this.formCreateInject.form.$form();
|
|
1594
1617
|
var d = (this.expand || 0) - this.value.length;
|
|
1595
1618
|
|
|
1596
1619
|
if (d > 0) {
|
|
@@ -1607,6 +1630,7 @@
|
|
|
1607
1630
|
var h = arguments[0];
|
|
1608
1631
|
var keys = Object.keys(this.cacheRule);
|
|
1609
1632
|
var button = this.button;
|
|
1633
|
+
var Type = this.type;
|
|
1610
1634
|
return keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
|
|
1611
1635
|
vm: this,
|
|
1612
1636
|
add: this.add
|
|
@@ -1634,7 +1658,7 @@
|
|
|
1634
1658
|
"attrs": {
|
|
1635
1659
|
"span": button ? 20 : 24
|
|
1636
1660
|
}
|
|
1637
|
-
}, [h("ElFormItem", [h(
|
|
1661
|
+
}, [h("ElFormItem", [h(Type, helper([{
|
|
1638
1662
|
"key": key
|
|
1639
1663
|
}, {
|
|
1640
1664
|
"on": {
|
|
@@ -1666,9 +1690,6 @@
|
|
|
1666
1690
|
}
|
|
1667
1691
|
}, [_this9.makeIcon(keys.length, index, key)]) : null]);
|
|
1668
1692
|
})]);
|
|
1669
|
-
},
|
|
1670
|
-
beforeMount: function beforeMount() {
|
|
1671
|
-
this.$options.components.FormCreate = this.formCreateInject.form.$form();
|
|
1672
1693
|
}
|
|
1673
1694
|
};
|
|
1674
1695
|
|
|
@@ -1700,7 +1721,8 @@
|
|
|
1700
1721
|
data: function data() {
|
|
1701
1722
|
return {
|
|
1702
1723
|
cacheRule: {},
|
|
1703
|
-
cacheValue: {}
|
|
1724
|
+
cacheValue: {},
|
|
1725
|
+
type: undefined
|
|
1704
1726
|
};
|
|
1705
1727
|
},
|
|
1706
1728
|
watch: {
|
|
@@ -1762,13 +1784,15 @@
|
|
|
1762
1784
|
},
|
|
1763
1785
|
created: function created() {
|
|
1764
1786
|
this.addRule();
|
|
1787
|
+
this.type = this.formCreateInject.form.$form();
|
|
1765
1788
|
},
|
|
1766
1789
|
render: function render() {
|
|
1767
1790
|
var h = arguments[0];
|
|
1768
1791
|
var _this$cacheRule = this.cacheRule,
|
|
1769
1792
|
rule = _this$cacheRule.rule,
|
|
1770
1793
|
options = _this$cacheRule.options;
|
|
1771
|
-
|
|
1794
|
+
var Type = this.type;
|
|
1795
|
+
return h(Type, helper([{}, {
|
|
1772
1796
|
"on": {
|
|
1773
1797
|
'update:value': this.formData,
|
|
1774
1798
|
'emit-event': this.emitEvent,
|
|
@@ -1781,9 +1805,6 @@
|
|
|
1781
1805
|
"extendOption": true
|
|
1782
1806
|
}
|
|
1783
1807
|
}]));
|
|
1784
|
-
},
|
|
1785
|
-
beforeMount: function beforeMount() {
|
|
1786
|
-
this.$options.components.FormCreate = this.formCreateInject.form.$form();
|
|
1787
1808
|
}
|
|
1788
1809
|
};
|
|
1789
1810
|
|
|
@@ -1908,6 +1929,7 @@
|
|
|
1908
1929
|
Object.keys(this.formCreate.prop).forEach(function (k) {
|
|
1909
1930
|
extend(_this2.$options[k], _this2.formCreate.prop[k]);
|
|
1910
1931
|
});
|
|
1932
|
+
this.$emit('beforeCreate', this.formCreate.api());
|
|
1911
1933
|
}
|
|
1912
1934
|
};
|
|
1913
1935
|
}
|
|
@@ -1988,6 +2010,20 @@
|
|
|
1988
2010
|
return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
|
|
1989
2011
|
}
|
|
1990
2012
|
|
|
2013
|
+
function format(type, msg, rule) {
|
|
2014
|
+
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
2015
|
+
}
|
|
2016
|
+
function tip(msg, rule) {
|
|
2017
|
+
console.warn(format('tip', msg, rule));
|
|
2018
|
+
}
|
|
2019
|
+
function err(msg, rule) {
|
|
2020
|
+
console.error(format('err', msg, rule));
|
|
2021
|
+
}
|
|
2022
|
+
function logError(e) {
|
|
2023
|
+
err(e.toString());
|
|
2024
|
+
console.error(e);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1991
2027
|
function deepExtend(origin) {
|
|
1992
2028
|
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1993
2029
|
var mode = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -2016,14 +2052,18 @@
|
|
|
2016
2052
|
}
|
|
2017
2053
|
|
|
2018
2054
|
origin[key] = deepExtend(origin[key], clone, mode);
|
|
2019
|
-
} else if (is.Undef(clone)) {
|
|
2020
|
-
$set(origin, key, clone);
|
|
2021
|
-
} else if (clone.__json !== undefined) {
|
|
2022
|
-
$set(origin, key, clone.__json);
|
|
2023
|
-
} else if (clone.__origin !== undefined) {
|
|
2024
|
-
$set(origin, key, clone.__origin);
|
|
2025
2055
|
} else {
|
|
2026
2056
|
$set(origin, key, clone);
|
|
2057
|
+
|
|
2058
|
+
if (!is.Undef(clone)) {
|
|
2059
|
+
if (clone.__json !== undefined) {
|
|
2060
|
+
origin[key].__json = clone.__json;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
if (clone.__origin !== undefined) {
|
|
2064
|
+
origin[key].__origin = clone.__origin;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2027
2067
|
}
|
|
2028
2068
|
}
|
|
2029
2069
|
}
|
|
@@ -2038,20 +2078,6 @@
|
|
|
2038
2078
|
}).value;
|
|
2039
2079
|
}
|
|
2040
2080
|
|
|
2041
|
-
function format(type, msg, rule) {
|
|
2042
|
-
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
2043
|
-
}
|
|
2044
|
-
function tip(msg, rule) {
|
|
2045
|
-
console.warn(format('tip', msg, rule));
|
|
2046
|
-
}
|
|
2047
|
-
function err(msg, rule) {
|
|
2048
|
-
console.error(format('err', msg, rule));
|
|
2049
|
-
}
|
|
2050
|
-
function logError(e) {
|
|
2051
|
-
err(e.toString());
|
|
2052
|
-
console.error(e);
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
2081
|
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
2056
2082
|
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2057
2083
|
var $T = '$FN:';
|
|
@@ -2128,8 +2154,8 @@
|
|
|
2128
2154
|
};
|
|
2129
2155
|
} //todo 优化位置
|
|
2130
2156
|
|
|
2131
|
-
function copyRule(rule
|
|
2132
|
-
return copyRules([rule]
|
|
2157
|
+
function copyRule(rule) {
|
|
2158
|
+
return copyRules([rule])[0];
|
|
2133
2159
|
}
|
|
2134
2160
|
function copyRules(rules, mode) {
|
|
2135
2161
|
return deepExtend([], _toConsumableArray(rules), mode || false);
|
|
@@ -2320,11 +2346,6 @@
|
|
|
2320
2346
|
}
|
|
2321
2347
|
|
|
2322
2348
|
var api = {
|
|
2323
|
-
helper: {
|
|
2324
|
-
tidyFields: tidyFields,
|
|
2325
|
-
props: props
|
|
2326
|
-
},
|
|
2327
|
-
|
|
2328
2349
|
get config() {
|
|
2329
2350
|
return h.options;
|
|
2330
2351
|
},
|
|
@@ -2468,6 +2489,12 @@
|
|
|
2468
2489
|
});
|
|
2469
2490
|
h.refresh();
|
|
2470
2491
|
},
|
|
2492
|
+
all: function all(origin) {
|
|
2493
|
+
return Object.keys(h.ctxs).map(function (k) {
|
|
2494
|
+
var ctx = h.ctxs[k];
|
|
2495
|
+
return origin ? ctx.origin : ctx.rule;
|
|
2496
|
+
});
|
|
2497
|
+
},
|
|
2471
2498
|
model: function model(origin) {
|
|
2472
2499
|
return h.fields().reduce(function (initial, key) {
|
|
2473
2500
|
var ctx = h.fieldCtx[key][0];
|
|
@@ -2655,13 +2682,26 @@
|
|
|
2655
2682
|
nextRefresh: function nextRefresh(fn) {
|
|
2656
2683
|
h.nextRefresh();
|
|
2657
2684
|
fn && invoke(fn);
|
|
2685
|
+
},
|
|
2686
|
+
emit: function emit(name) {
|
|
2687
|
+
var _h$vm;
|
|
2688
|
+
|
|
2689
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
2690
|
+
args[_key3 - 1] = arguments[_key3];
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
(_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
|
|
2694
|
+
},
|
|
2695
|
+
helper: {
|
|
2696
|
+
tidyFields: tidyFields,
|
|
2697
|
+
props: props
|
|
2658
2698
|
}
|
|
2659
2699
|
};
|
|
2660
2700
|
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2661
2701
|
api[n] = function () {
|
|
2662
|
-
var _h$
|
|
2702
|
+
var _h$vm2;
|
|
2663
2703
|
|
|
2664
|
-
(_h$
|
|
2704
|
+
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
2665
2705
|
};
|
|
2666
2706
|
});
|
|
2667
2707
|
api.changeValue = api.changeField = api.setValue;
|
|
@@ -2886,6 +2926,7 @@
|
|
|
2886
2926
|
renderCtx: function renderCtx(ctx, parent) {
|
|
2887
2927
|
if (ctx.type === 'hidden') return;
|
|
2888
2928
|
var rule = ctx.rule;
|
|
2929
|
+
var preview = this.options.preview || false;
|
|
2889
2930
|
|
|
2890
2931
|
if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
|
|
2891
2932
|
var vn;
|
|
@@ -2936,12 +2977,13 @@
|
|
|
2936
2977
|
vn = this.vm.$scopedSlots[slot]({
|
|
2937
2978
|
rule: rule,
|
|
2938
2979
|
prop: prop,
|
|
2980
|
+
preview: preview,
|
|
2939
2981
|
children: children,
|
|
2940
2982
|
api: this.$handle.api,
|
|
2941
2983
|
model: prop.model || {}
|
|
2942
2984
|
});
|
|
2943
2985
|
} else {
|
|
2944
|
-
vn = ctx.parser.render(children, ctx);
|
|
2986
|
+
vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
|
|
2945
2987
|
}
|
|
2946
2988
|
}
|
|
2947
2989
|
|
|
@@ -3006,20 +3048,26 @@
|
|
|
3006
3048
|
var _this7 = this;
|
|
3007
3049
|
|
|
3008
3050
|
if (!this.vm.ctxInject[ctx.id]) {
|
|
3009
|
-
$set(this.vm.ctxInject, ctx.id, {
|
|
3051
|
+
$set(this.vm.ctxInject, ctx.id, {
|
|
3052
|
+
api: this.$handle.api,
|
|
3053
|
+
form: this.fc.create,
|
|
3054
|
+
subForm: function subForm(_subForm) {
|
|
3055
|
+
_this7.$handle.addSubForm(ctx, _subForm);
|
|
3056
|
+
},
|
|
3057
|
+
options: [],
|
|
3058
|
+
children: [],
|
|
3059
|
+
prop: {},
|
|
3060
|
+
preview: false,
|
|
3061
|
+
field: ctx.field,
|
|
3062
|
+
rule: ctx.rule
|
|
3063
|
+
});
|
|
3010
3064
|
}
|
|
3011
3065
|
|
|
3012
3066
|
var inject = this.vm.ctxInject[ctx.id];
|
|
3013
3067
|
extend(inject, {
|
|
3014
|
-
|
|
3015
|
-
form: this.fc.create,
|
|
3016
|
-
subForm: function subForm(_subForm) {
|
|
3017
|
-
_this7.$handle.addSubForm(ctx, _subForm);
|
|
3018
|
-
},
|
|
3019
|
-
field: ctx.field,
|
|
3068
|
+
preview: this.options.preview || false,
|
|
3020
3069
|
options: ctx.prop.options,
|
|
3021
3070
|
children: ctx.rule.children,
|
|
3022
|
-
rule: ctx.rule,
|
|
3023
3071
|
prop: function () {
|
|
3024
3072
|
var temp = _objectSpread2({}, ctx.prop);
|
|
3025
3073
|
|
|
@@ -3045,6 +3093,9 @@
|
|
|
3045
3093
|
on: {
|
|
3046
3094
|
'hook:mounted': function hookMounted() {
|
|
3047
3095
|
_this8.onMounted(ctx);
|
|
3096
|
+
},
|
|
3097
|
+
'fc.sub-form': function fcSubForm(subForm) {
|
|
3098
|
+
_this8.$handle.addSubForm(ctx, subForm);
|
|
3048
3099
|
}
|
|
3049
3100
|
}
|
|
3050
3101
|
}];
|
|
@@ -3926,6 +3977,7 @@
|
|
|
3926
3977
|
this.refresh();
|
|
3927
3978
|
this.bus.$off('next-tick', this.nextReload);
|
|
3928
3979
|
this.bus.$once('next-tick', this.nextReload);
|
|
3980
|
+
this.vm.$emit('update', this.api);
|
|
3929
3981
|
},
|
|
3930
3982
|
//todo 组件生成全部通过 alias
|
|
3931
3983
|
refresh: function refresh() {
|
|
@@ -3961,7 +4013,7 @@
|
|
|
3961
4013
|
function useInput(Handler) {
|
|
3962
4014
|
extend(Handler.prototype, {
|
|
3963
4015
|
getValue: function getValue(ctx) {
|
|
3964
|
-
if (
|
|
4016
|
+
if (is.Undef(ctx.cacheValue)) {
|
|
3965
4017
|
ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
|
|
3966
4018
|
}
|
|
3967
4019
|
|
|
@@ -4085,7 +4137,7 @@
|
|
|
4085
4137
|
return JSON.stringify(ctx.rule.value) !== JSON.stringify(value);
|
|
4086
4138
|
},
|
|
4087
4139
|
isQuote: function isQuote(ctx, value) {
|
|
4088
|
-
return
|
|
4140
|
+
return value === ctx.rule.value || is.Object(value) || Array.isArray(value) || is.Function(value);
|
|
4089
4141
|
},
|
|
4090
4142
|
refreshUpdate: function refreshUpdate(ctx, val) {
|
|
4091
4143
|
var _this4 = this;
|
|
@@ -4106,6 +4158,7 @@
|
|
|
4106
4158
|
if (this.refreshControl(ctx)) {
|
|
4107
4159
|
this.$render.clearCacheAll();
|
|
4108
4160
|
this.loadRule();
|
|
4161
|
+
this.vm.$emit('update', this.api);
|
|
4109
4162
|
this.refresh();
|
|
4110
4163
|
}
|
|
4111
4164
|
|
|
@@ -4151,6 +4204,9 @@
|
|
|
4151
4204
|
render: function render(children, ctx) {
|
|
4152
4205
|
return ctx.$render.defaultRender(ctx, children);
|
|
4153
4206
|
},
|
|
4207
|
+
preview: function preview(children, ctx) {
|
|
4208
|
+
return ctx.$render.defaultRender(ctx, children);
|
|
4209
|
+
},
|
|
4154
4210
|
mergeProp: function mergeProp(ctx) {}
|
|
4155
4211
|
};
|
|
4156
4212
|
|
|
@@ -4277,6 +4333,8 @@
|
|
|
4277
4333
|
}
|
|
4278
4334
|
|
|
4279
4335
|
_flag && _this.loadChildren(n, ctx);
|
|
4336
|
+
|
|
4337
|
+
_this.vm.$emit('update', _this.api);
|
|
4280
4338
|
});
|
|
4281
4339
|
}
|
|
4282
4340
|
|
|
@@ -4812,6 +4870,11 @@
|
|
|
4812
4870
|
|
|
4813
4871
|
function run(inject, rule, api) {
|
|
4814
4872
|
var option = inject.value;
|
|
4873
|
+
|
|
4874
|
+
if (is.Function(option)) {
|
|
4875
|
+
option = option(rule, api);
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4815
4878
|
option = parseOpt(option);
|
|
4816
4879
|
|
|
4817
4880
|
if (!option || !option.action) {
|
|
@@ -4922,9 +4985,7 @@
|
|
|
4922
4985
|
|
|
4923
4986
|
|
|
4924
4987
|
function FormCreateFactory(config) {
|
|
4925
|
-
var
|
|
4926
|
-
|
|
4927
|
-
var components = _defineProperty({}, fragment.name, _fragment);
|
|
4988
|
+
var components = _defineProperty({}, fragment.name, fragment);
|
|
4928
4989
|
|
|
4929
4990
|
var parsers = {};
|
|
4930
4991
|
var directives = {};
|
|
@@ -4989,6 +5050,10 @@
|
|
|
4989
5050
|
|
|
4990
5051
|
function $form() {
|
|
4991
5052
|
return _vue.extend($FormCreate(FormCreate));
|
|
5053
|
+
}
|
|
5054
|
+
|
|
5055
|
+
function $vnode() {
|
|
5056
|
+
return _vue.extend(fragment);
|
|
4992
5057
|
} //todo 检查回调函数作用域
|
|
4993
5058
|
|
|
4994
5059
|
|
|
@@ -5110,6 +5175,7 @@
|
|
|
5110
5175
|
},
|
|
5111
5176
|
created: function created() {
|
|
5112
5177
|
this.$handle.init();
|
|
5178
|
+
this.vm.$emit('created', this.api());
|
|
5113
5179
|
},
|
|
5114
5180
|
api: function api() {
|
|
5115
5181
|
return this.$handle.api;
|
|
@@ -5131,7 +5197,7 @@
|
|
|
5131
5197
|
component: component,
|
|
5132
5198
|
directive: directive,
|
|
5133
5199
|
register: register,
|
|
5134
|
-
|
|
5200
|
+
$vnode: $vnode,
|
|
5135
5201
|
parser: parser,
|
|
5136
5202
|
use: use,
|
|
5137
5203
|
factory: factory,
|
|
@@ -5140,6 +5206,7 @@
|
|
|
5140
5206
|
copyRules: copyRules,
|
|
5141
5207
|
fetch: fetch,
|
|
5142
5208
|
$form: $form,
|
|
5209
|
+
parseFn: parseFn,
|
|
5143
5210
|
parseJson: parseJson,
|
|
5144
5211
|
toJson: toJson,
|
|
5145
5212
|
init: function init(rules) {
|
|
@@ -5185,7 +5252,7 @@
|
|
|
5185
5252
|
useAttr($formCreate);
|
|
5186
5253
|
Vue.prototype.$formCreate = $formCreate;
|
|
5187
5254
|
Vue.component('FormCreate', $form());
|
|
5188
|
-
Vue.component('FcFragment',
|
|
5255
|
+
Vue.component('FcFragment', $vnode());
|
|
5189
5256
|
}
|
|
5190
5257
|
});
|
|
5191
5258
|
}
|
|
@@ -5534,7 +5601,8 @@
|
|
|
5534
5601
|
_col = _this$rule$props.col;
|
|
5535
5602
|
var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
|
|
5536
5603
|
props: _objectSpread2(_objectSpread2({
|
|
5537
|
-
labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth)
|
|
5604
|
+
labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth),
|
|
5605
|
+
label: isTitle ? rule.title.title : undefined
|
|
5538
5606
|
}, rule.wrap || {}), {}, {
|
|
5539
5607
|
prop: ctx.id,
|
|
5540
5608
|
rules: rule.validate
|
|
@@ -5552,32 +5620,13 @@
|
|
|
5552
5620
|
return !(!title.title && !title["native"] || isFalse(title.show));
|
|
5553
5621
|
},
|
|
5554
5622
|
makeInfo: function makeInfo(rule, uni) {
|
|
5555
|
-
var _this = this;
|
|
5556
|
-
|
|
5557
5623
|
var titleProp = rule.title;
|
|
5558
5624
|
var infoProp = rule.info;
|
|
5559
5625
|
var isTip = isTooltip(infoProp);
|
|
5560
5626
|
var form = this.options.form;
|
|
5561
|
-
var children = [titleProp.title + (form.labelSuffix || form['label-suffix'] || '')];
|
|
5562
|
-
|
|
5563
|
-
var titleFn = function titleFn(pop) {
|
|
5564
|
-
return _this.$r(mergeProps([titleProp, {
|
|
5565
|
-
props: titleProp,
|
|
5566
|
-
slot: titleProp.slot || (pop ? isTip ? 'default' : 'reference' : 'label'),
|
|
5567
|
-
key: "".concat(uni, "tit"),
|
|
5568
|
-
type: titleProp.type || 'span'
|
|
5569
|
-
}]), children);
|
|
5570
|
-
};
|
|
5571
|
-
|
|
5572
|
-
if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"])) {
|
|
5573
|
-
if (infoProp.icon !== false) {
|
|
5574
|
-
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
|
|
5575
|
-
type: 'i',
|
|
5576
|
-
"class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
|
|
5577
|
-
key: "".concat(uni, "i")
|
|
5578
|
-
}));
|
|
5579
|
-
}
|
|
5627
|
+
var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
|
|
5580
5628
|
|
|
5629
|
+
if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
|
|
5581
5630
|
var prop = {
|
|
5582
5631
|
type: infoProp.type || 'popover',
|
|
5583
5632
|
props: _objectSpread2({}, infoProp),
|
|
@@ -5590,10 +5639,20 @@
|
|
|
5590
5639
|
prop.props[field] = infoProp.info;
|
|
5591
5640
|
}
|
|
5592
5641
|
|
|
5593
|
-
|
|
5642
|
+
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
|
|
5643
|
+
type: 'i',
|
|
5644
|
+
slot: isTip ? 'default' : 'reference',
|
|
5645
|
+
"class": infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
|
|
5646
|
+
key: "".concat(uni, "i")
|
|
5647
|
+
})]));
|
|
5594
5648
|
}
|
|
5595
5649
|
|
|
5596
|
-
return
|
|
5650
|
+
return this.$r(mergeProps([titleProp, {
|
|
5651
|
+
props: titleProp,
|
|
5652
|
+
slot: titleProp.slot || 'label',
|
|
5653
|
+
key: "".concat(uni, "tit"),
|
|
5654
|
+
type: titleProp.type || 'span'
|
|
5655
|
+
}]), children);
|
|
5597
5656
|
},
|
|
5598
5657
|
makeCol: function makeCol(rule, uni, children) {
|
|
5599
5658
|
var col = rule.col;
|
|
@@ -5643,7 +5702,7 @@
|
|
|
5643
5702
|
}, [item]);
|
|
5644
5703
|
},
|
|
5645
5704
|
makeResetBtn: function makeResetBtn() {
|
|
5646
|
-
var
|
|
5705
|
+
var _this = this;
|
|
5647
5706
|
|
|
5648
5707
|
var resetBtn = this.options.resetBtn;
|
|
5649
5708
|
return this.$r({
|
|
@@ -5654,7 +5713,7 @@
|
|
|
5654
5713
|
},
|
|
5655
5714
|
on: {
|
|
5656
5715
|
click: function click() {
|
|
5657
|
-
var fApi =
|
|
5716
|
+
var fApi = _this.$handle.api;
|
|
5658
5717
|
resetBtn.click ? resetBtn.click(fApi) : fApi.resetFields();
|
|
5659
5718
|
}
|
|
5660
5719
|
},
|
|
@@ -5662,7 +5721,7 @@
|
|
|
5662
5721
|
}, [resetBtn.innerText]);
|
|
5663
5722
|
},
|
|
5664
5723
|
makeSubmitBtn: function makeSubmitBtn() {
|
|
5665
|
-
var
|
|
5724
|
+
var _this2 = this;
|
|
5666
5725
|
|
|
5667
5726
|
var submitBtn = this.options.submitBtn;
|
|
5668
5727
|
return this.$r({
|
|
@@ -5673,7 +5732,7 @@
|
|
|
5673
5732
|
},
|
|
5674
5733
|
on: {
|
|
5675
5734
|
click: function click() {
|
|
5676
|
-
var fApi =
|
|
5735
|
+
var fApi = _this2.$handle.api;
|
|
5677
5736
|
submitBtn.click ? submitBtn.click(fApi) : fApi.submit();
|
|
5678
5737
|
}
|
|
5679
5738
|
},
|
|
@@ -6004,7 +6063,7 @@
|
|
|
6004
6063
|
function elmFormCreate() {
|
|
6005
6064
|
return FormCreateFactory({
|
|
6006
6065
|
ui: "".concat("element-ui"),
|
|
6007
|
-
version: "".concat("2.5.
|
|
6066
|
+
version: "".concat("2.5.15"),
|
|
6008
6067
|
manager: manager,
|
|
6009
6068
|
extendApi: extendApi,
|
|
6010
6069
|
install: install,
|