@form-create/element-ui 3.1.28 → 3.1.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.esm.js +456 -220
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +456 -220
- package/dist/form-create.min.js +2 -2
- package/package.json +12 -12
- package/src/core/manager.js +4 -3
- package/src/style/index.css +4 -0
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.1.
|
|
2
|
+
* @form-create/element-ui v3.1.29
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -257,13 +257,16 @@
|
|
|
257
257
|
var props = _objectSpread2({}, opt);
|
|
258
258
|
|
|
259
259
|
var value = props.value;
|
|
260
|
+
var label = props.label;
|
|
260
261
|
delete props.value;
|
|
262
|
+
delete props.label;
|
|
261
263
|
return vue.createVNode(Type, vue.mergeProps(props, {
|
|
262
264
|
"label": value,
|
|
263
|
-
"
|
|
265
|
+
"value": value,
|
|
266
|
+
"key": name + index + '-' + value
|
|
264
267
|
}), {
|
|
265
268
|
"default": function _default() {
|
|
266
|
-
return [
|
|
269
|
+
return [label || value || ''];
|
|
267
270
|
}
|
|
268
271
|
});
|
|
269
272
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -1001,13 +1004,16 @@
|
|
|
1001
1004
|
var props = _objectSpread2({}, opt);
|
|
1002
1005
|
|
|
1003
1006
|
var value = props.value;
|
|
1007
|
+
var label = props.label;
|
|
1004
1008
|
delete props.value;
|
|
1009
|
+
delete props.label;
|
|
1005
1010
|
return vue.createVNode(Type, vue.mergeProps(props, {
|
|
1006
1011
|
"label": value,
|
|
1007
|
-
"
|
|
1012
|
+
"value": value,
|
|
1013
|
+
"key": name + index + '-' + value
|
|
1008
1014
|
}), {
|
|
1009
1015
|
"default": function _default() {
|
|
1010
|
-
return [
|
|
1016
|
+
return [label || value || ''];
|
|
1011
1017
|
}
|
|
1012
1018
|
});
|
|
1013
1019
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -1419,6 +1425,10 @@
|
|
|
1419
1425
|
function extend() {
|
|
1420
1426
|
return _extends.apply(this, arguments);
|
|
1421
1427
|
}
|
|
1428
|
+
function copy$1(obj) {
|
|
1429
|
+
if (_typeof(obj) !== 'object' || obj === null) return obj;
|
|
1430
|
+
return obj instanceof Array ? _toConsumableArray(obj) : _objectSpread2({}, obj);
|
|
1431
|
+
}
|
|
1422
1432
|
|
|
1423
1433
|
var css_248z$1 = "._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:\"\";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:\"\";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}";
|
|
1424
1434
|
styleInject(css_248z$1);
|
|
@@ -1802,7 +1812,7 @@
|
|
|
1802
1812
|
add: this.add
|
|
1803
1813
|
}) : vue.createVNode("div", {
|
|
1804
1814
|
"key": 'a_def',
|
|
1805
|
-
"class": "_fc-group-plus-minus _fc-group-add",
|
|
1815
|
+
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
|
|
1806
1816
|
"onClick": this.add
|
|
1807
1817
|
}, null) : keys.map(function (key, index) {
|
|
1808
1818
|
var _this12$cacheRule$key = _this12.cacheRule[key],
|
|
@@ -1836,7 +1846,7 @@
|
|
|
1836
1846
|
}), null), vue.createVNode("div", {
|
|
1837
1847
|
"class": "_fc-group-idx"
|
|
1838
1848
|
}, [index + 1]), btn.length ? vue.createVNode("div", {
|
|
1839
|
-
"class": "_fc-group-handle"
|
|
1849
|
+
"class": "_fc-group-handle fc-clock"
|
|
1840
1850
|
}, [btn]) : null]);
|
|
1841
1851
|
});
|
|
1842
1852
|
return vue.createVNode("div", {
|
|
@@ -1994,6 +2004,7 @@
|
|
|
1994
2004
|
},
|
|
1995
2005
|
extendOption: Boolean,
|
|
1996
2006
|
modelValue: Object,
|
|
2007
|
+
disabled: Boolean,
|
|
1997
2008
|
api: Object,
|
|
1998
2009
|
name: String,
|
|
1999
2010
|
subForm: {
|
|
@@ -2023,7 +2034,7 @@
|
|
|
2023
2034
|
isShow: true,
|
|
2024
2035
|
unique: 1,
|
|
2025
2036
|
renderRule: _toConsumableArray(rule.value || []),
|
|
2026
|
-
updateValue: JSON.stringify(modelValue || {})
|
|
2037
|
+
updateValue: JSON.stringify(modelValue.value || {})
|
|
2027
2038
|
});
|
|
2028
2039
|
var fc = new FormCreate(vm);
|
|
2029
2040
|
var fapi = fc.api();
|
|
@@ -2092,8 +2103,8 @@
|
|
|
2092
2103
|
});
|
|
2093
2104
|
vue.watch(function () {
|
|
2094
2105
|
return props.option;
|
|
2095
|
-
}, function (
|
|
2096
|
-
fc.initOptions(
|
|
2106
|
+
}, function () {
|
|
2107
|
+
fc.initOptions();
|
|
2097
2108
|
fapi.refresh();
|
|
2098
2109
|
}, {
|
|
2099
2110
|
deep: true
|
|
@@ -2104,6 +2115,11 @@
|
|
|
2104
2115
|
}, {
|
|
2105
2116
|
deep: true
|
|
2106
2117
|
});
|
|
2118
|
+
vue.watch(function () {
|
|
2119
|
+
return props.disabled;
|
|
2120
|
+
}, function (n) {
|
|
2121
|
+
fapi.disabled(!!n);
|
|
2122
|
+
});
|
|
2107
2123
|
return _objectSpread2(_objectSpread2({
|
|
2108
2124
|
fc: vue.markRaw(fc),
|
|
2109
2125
|
parent: parent ? vue.markRaw(parent) : parent,
|
|
@@ -2126,6 +2142,7 @@
|
|
|
2126
2142
|
var vm = vue.getCurrentInstance();
|
|
2127
2143
|
vm.setupState.fc.init();
|
|
2128
2144
|
vm.emit('update:api', vm.setupState.fapi);
|
|
2145
|
+
vm.props.disabled && vm.setupState.fapi.disabled(true);
|
|
2129
2146
|
}
|
|
2130
2147
|
});
|
|
2131
2148
|
}
|
|
@@ -2199,7 +2216,7 @@
|
|
|
2199
2216
|
};
|
|
2200
2217
|
};
|
|
2201
2218
|
|
|
2202
|
-
var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache'];
|
|
2219
|
+
var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
|
|
2203
2220
|
var arrayAttrs = ['validate', 'children', 'control'];
|
|
2204
2221
|
var normalAttrs = ['effect'];
|
|
2205
2222
|
function attrs() {
|
|
@@ -2230,6 +2247,7 @@
|
|
|
2230
2247
|
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2231
2248
|
var $T = '$FN:';
|
|
2232
2249
|
var $TX = '$FNX:';
|
|
2250
|
+
var $ON = '$GLOBAL:';
|
|
2233
2251
|
var FUNCTION = 'function';
|
|
2234
2252
|
function toJson(obj, space) {
|
|
2235
2253
|
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
@@ -2265,6 +2283,26 @@
|
|
|
2265
2283
|
} else if (v.indexOf($T) === 0) {
|
|
2266
2284
|
v = v.replace($T, '');
|
|
2267
2285
|
flag = true;
|
|
2286
|
+
} else if (v.indexOf($ON) === 0) {
|
|
2287
|
+
var name = v.replace($ON, '');
|
|
2288
|
+
|
|
2289
|
+
v = function v() {
|
|
2290
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2291
|
+
args[_key] = arguments[_key];
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
var callback = args[0].api.getGlobalEvent(name);
|
|
2295
|
+
|
|
2296
|
+
if (callback) {
|
|
2297
|
+
return callback.call.apply(callback, [this].concat(args));
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
return undefined;
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
v.__json = fn;
|
|
2304
|
+
v.__inject = true;
|
|
2305
|
+
return v;
|
|
2268
2306
|
} else if (v.indexOf($TX) === 0) {
|
|
2269
2307
|
v = makeFn('function($inject){' + v.replace($TX, '') + '}');
|
|
2270
2308
|
v.__json = fn;
|
|
@@ -2449,6 +2487,10 @@
|
|
|
2449
2487
|
if (prop.slot) delete prop.slot;
|
|
2450
2488
|
return prop;
|
|
2451
2489
|
}
|
|
2490
|
+
function setPrototypeOf(o, proto) {
|
|
2491
|
+
Object.setPrototypeOf(o, proto);
|
|
2492
|
+
return o;
|
|
2493
|
+
}
|
|
2452
2494
|
|
|
2453
2495
|
function baseRule() {
|
|
2454
2496
|
return {
|
|
@@ -2525,6 +2567,107 @@
|
|
|
2525
2567
|
};
|
|
2526
2568
|
}
|
|
2527
2569
|
|
|
2570
|
+
function getError(action, option, xhr) {
|
|
2571
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2572
|
+
var err = new Error(msg);
|
|
2573
|
+
err.status = xhr.status;
|
|
2574
|
+
err.url = action;
|
|
2575
|
+
return err;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
function getBody(xhr) {
|
|
2579
|
+
var text = xhr.responseText || xhr.response;
|
|
2580
|
+
|
|
2581
|
+
if (!text) {
|
|
2582
|
+
return text;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
try {
|
|
2586
|
+
return JSON.parse(text);
|
|
2587
|
+
} catch (e) {
|
|
2588
|
+
return text;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
function fetch$1(option) {
|
|
2593
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
var xhr = new XMLHttpRequest();
|
|
2598
|
+
var action = option.action;
|
|
2599
|
+
|
|
2600
|
+
xhr.onerror = function error(e) {
|
|
2601
|
+
option.onError(e);
|
|
2602
|
+
};
|
|
2603
|
+
|
|
2604
|
+
xhr.onload = function onload() {
|
|
2605
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2606
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
option.onSuccess(getBody(xhr));
|
|
2610
|
+
};
|
|
2611
|
+
|
|
2612
|
+
xhr.open(option.method || 'get', action, true);
|
|
2613
|
+
var formData;
|
|
2614
|
+
|
|
2615
|
+
if (option.data) {
|
|
2616
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2617
|
+
formData = new FormData();
|
|
2618
|
+
Object.keys(option.data).map(function (key) {
|
|
2619
|
+
formData.append(key, option.data[key]);
|
|
2620
|
+
});
|
|
2621
|
+
} else {
|
|
2622
|
+
formData = JSON.stringify(option.data);
|
|
2623
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2628
|
+
xhr.withCredentials = true;
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
var headers = option.headers || {};
|
|
2632
|
+
Object.keys(headers).forEach(function (item) {
|
|
2633
|
+
if (headers[item] !== null) {
|
|
2634
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2637
|
+
xhr.send(formData);
|
|
2638
|
+
}
|
|
2639
|
+
function asyncFetch(config) {
|
|
2640
|
+
return new Promise(function (resolve, reject) {
|
|
2641
|
+
fetch$1(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2642
|
+
onSuccess: function onSuccess(res) {
|
|
2643
|
+
var fn = function fn(v) {
|
|
2644
|
+
return v;
|
|
2645
|
+
};
|
|
2646
|
+
|
|
2647
|
+
var parse = parseFn(config.parse);
|
|
2648
|
+
|
|
2649
|
+
if (is.Function(parse)) {
|
|
2650
|
+
fn = parse;
|
|
2651
|
+
} else if (parse && is.String(parse)) {
|
|
2652
|
+
fn = function fn(v) {
|
|
2653
|
+
parse.split('.').forEach(function (k) {
|
|
2654
|
+
if (v) {
|
|
2655
|
+
v = v[k];
|
|
2656
|
+
}
|
|
2657
|
+
});
|
|
2658
|
+
return v;
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
resolve(fn(res));
|
|
2663
|
+
},
|
|
2664
|
+
onError: function onError(err) {
|
|
2665
|
+
reject(err);
|
|
2666
|
+
}
|
|
2667
|
+
}));
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2528
2671
|
function copy(value) {
|
|
2529
2672
|
return deepCopy(value);
|
|
2530
2673
|
}
|
|
@@ -2580,7 +2723,15 @@
|
|
|
2580
2723
|
},
|
|
2581
2724
|
|
|
2582
2725
|
get parent() {
|
|
2583
|
-
return h.vm.parent && h.vm.parent.setupState.fapi;
|
|
2726
|
+
return h.vm.setupState.parent && h.vm.setupState.parent.setupState.fapi;
|
|
2727
|
+
},
|
|
2728
|
+
|
|
2729
|
+
get top() {
|
|
2730
|
+
if (api.parent) {
|
|
2731
|
+
return api.parent.top;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
return api;
|
|
2584
2735
|
},
|
|
2585
2736
|
|
|
2586
2737
|
get children() {
|
|
@@ -2924,6 +3075,84 @@
|
|
|
2924
3075
|
var ctx = h.getCtx(field);
|
|
2925
3076
|
return ctx ? h.subForm[ctx.id] : undefined;
|
|
2926
3077
|
},
|
|
3078
|
+
getChildrenRuleList: function getChildrenRuleList(id) {
|
|
3079
|
+
var flag = _typeof(id) === 'object';
|
|
3080
|
+
var ctx = flag ? byCtx(id) : h.getCtx(id);
|
|
3081
|
+
var rule = ctx ? ctx.rule : flag ? id : api.getRule(id);
|
|
3082
|
+
|
|
3083
|
+
if (!rule) {
|
|
3084
|
+
return [];
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
var rules = [];
|
|
3088
|
+
|
|
3089
|
+
var findRules = function findRules(children) {
|
|
3090
|
+
children && children.forEach(function (item) {
|
|
3091
|
+
if (_typeof(item) !== 'object') {
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
if (item.field) {
|
|
3096
|
+
rules.push(item);
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
rules.push.apply(rules, _toConsumableArray(api.getChildrenRuleList(item)));
|
|
3100
|
+
});
|
|
3101
|
+
};
|
|
3102
|
+
|
|
3103
|
+
findRules(ctx ? ctx.loadChildrenPending() : rule.children);
|
|
3104
|
+
return rules;
|
|
3105
|
+
},
|
|
3106
|
+
getChildrenFormData: function getChildrenFormData(id) {
|
|
3107
|
+
var rules = api.getChildrenRuleList(id);
|
|
3108
|
+
return rules.reduce(function (formData, rule) {
|
|
3109
|
+
formData[rule.field] = copy(rule.value);
|
|
3110
|
+
return formData;
|
|
3111
|
+
}, {});
|
|
3112
|
+
},
|
|
3113
|
+
setChildrenFormData: function setChildrenFormData(id, formData, cover) {
|
|
3114
|
+
var rules = api.getChildrenRuleList(id);
|
|
3115
|
+
rules.forEach(function (rule) {
|
|
3116
|
+
if (hasProperty(formData, rule.field)) {
|
|
3117
|
+
rule.value = formData[rule.field];
|
|
3118
|
+
} else if (cover) {
|
|
3119
|
+
rule.value = undefined;
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
3122
|
+
},
|
|
3123
|
+
getGlobalEvent: function getGlobalEvent(name) {
|
|
3124
|
+
var event = api.options.globalEvent[name];
|
|
3125
|
+
|
|
3126
|
+
if (event) {
|
|
3127
|
+
if (_typeof(event) === 'object') {
|
|
3128
|
+
event = event.handle;
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3131
|
+
return parseFn(event);
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
return undefined;
|
|
3135
|
+
},
|
|
3136
|
+
getGlobalData: function getGlobalData(name) {
|
|
3137
|
+
return new Promise(function (resolve, inject) {
|
|
3138
|
+
var config = api.options.globalData[name];
|
|
3139
|
+
|
|
3140
|
+
if (!config) {
|
|
3141
|
+
resolve(h.fc.loadData[name]);
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
if (config.type === 'fetch') {
|
|
3145
|
+
asyncFetch(config).then(function (res) {
|
|
3146
|
+
resolve({
|
|
3147
|
+
res: res,
|
|
3148
|
+
config: config
|
|
3149
|
+
});
|
|
3150
|
+
})["catch"](inject);
|
|
3151
|
+
} else {
|
|
3152
|
+
resolve(config.data);
|
|
3153
|
+
}
|
|
3154
|
+
});
|
|
3155
|
+
},
|
|
2927
3156
|
nextTick: function nextTick(fn) {
|
|
2928
3157
|
h.bus.$once('next-tick', fn);
|
|
2929
3158
|
h.refresh();
|
|
@@ -3020,7 +3249,8 @@
|
|
|
3020
3249
|
|
|
3021
3250
|
var id$2 = 0;
|
|
3022
3251
|
function uniqueId() {
|
|
3023
|
-
|
|
3252
|
+
var num = 370 + ++id$2;
|
|
3253
|
+
return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
|
|
3024
3254
|
}
|
|
3025
3255
|
|
|
3026
3256
|
function deepSet(data, idx, val) {
|
|
@@ -3219,7 +3449,7 @@
|
|
|
3219
3449
|
inject.children = children;
|
|
3220
3450
|
_vn = slot(inject);
|
|
3221
3451
|
} else {
|
|
3222
|
-
_vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
|
|
3452
|
+
_vn = preview ? ctx.parser.preview(copy$1(children), ctx) : ctx.parser.render(copy$1(children), ctx);
|
|
3223
3453
|
}
|
|
3224
3454
|
|
|
3225
3455
|
_vn = _this4.renderSides(_vn, ctx);
|
|
@@ -3229,7 +3459,17 @@
|
|
|
3229
3459
|
}
|
|
3230
3460
|
|
|
3231
3461
|
if (ctx.none) {
|
|
3232
|
-
|
|
3462
|
+
if (Array.isArray(_vn)) {
|
|
3463
|
+
_vn = _vn.map(function (v) {
|
|
3464
|
+
if (!v || !v.__v_isVNode) {
|
|
3465
|
+
return v;
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
return _this4.none(v);
|
|
3469
|
+
});
|
|
3470
|
+
} else {
|
|
3471
|
+
_vn = _this4.none(_vn);
|
|
3472
|
+
}
|
|
3233
3473
|
}
|
|
3234
3474
|
|
|
3235
3475
|
cacheFlag && !Object.keys(children).length && _this4.setCache(ctx, function () {
|
|
@@ -3261,43 +3501,25 @@
|
|
|
3261
3501
|
return;
|
|
3262
3502
|
}
|
|
3263
3503
|
},
|
|
3264
|
-
getModelField: function getModelField(ctx) {
|
|
3265
|
-
return ctx.rule.modelField || ctx.parser.modelField || this.fc.modelFields[this.vNode.aliasMap[ctx.type]] || this.fc.modelFields[ctx.type] || this.fc.modelFields[ctx.originType] || 'modelValue';
|
|
3266
|
-
},
|
|
3267
|
-
display: function display(vn) {
|
|
3268
|
-
var _this5 = this;
|
|
3269
|
-
|
|
3270
|
-
if (Array.isArray(vn)) {
|
|
3271
|
-
var data = [];
|
|
3272
|
-
vn.forEach(function (v) {
|
|
3273
|
-
if (Array.isArray(v)) return _this5.display(v);
|
|
3274
|
-
if (_this5.none(v)) data.push(v);
|
|
3275
|
-
});
|
|
3276
|
-
return data;
|
|
3277
|
-
} else {
|
|
3278
|
-
return this.none(vn);
|
|
3279
|
-
}
|
|
3280
|
-
},
|
|
3281
3504
|
none: function none(vn) {
|
|
3282
3505
|
if (vn) {
|
|
3283
|
-
if (Array.isArray(vn.props
|
|
3284
|
-
vn.props.
|
|
3285
|
-
display: 'none'
|
|
3286
|
-
});
|
|
3506
|
+
if (Array.isArray(vn.props["class"])) {
|
|
3507
|
+
vn.props["class"].push('fc-none');
|
|
3287
3508
|
} else {
|
|
3288
|
-
vn.props
|
|
3289
|
-
display: 'none'
|
|
3290
|
-
}];
|
|
3509
|
+
vn.props["class"] = [vn.props["class"], 'fc-none'];
|
|
3291
3510
|
}
|
|
3292
3511
|
|
|
3293
3512
|
return vn;
|
|
3294
3513
|
}
|
|
3295
3514
|
},
|
|
3515
|
+
getModelField: function getModelField(ctx) {
|
|
3516
|
+
return ctx.rule.modelField || ctx.parser.modelField || this.fc.modelFields[this.vNode.aliasMap[ctx.type]] || this.fc.modelFields[ctx.type] || this.fc.modelFields[ctx.originType] || 'modelValue';
|
|
3517
|
+
},
|
|
3296
3518
|
isFragment: function isFragment(ctx) {
|
|
3297
3519
|
return ctx.type === 'fragment' || ctx.type === 'template';
|
|
3298
3520
|
},
|
|
3299
3521
|
injectProp: function injectProp(ctx) {
|
|
3300
|
-
var
|
|
3522
|
+
var _this5 = this;
|
|
3301
3523
|
|
|
3302
3524
|
var state = this.vm.setupState;
|
|
3303
3525
|
|
|
@@ -3306,14 +3528,15 @@
|
|
|
3306
3528
|
api: this.$handle.api,
|
|
3307
3529
|
form: this.fc.create,
|
|
3308
3530
|
subForm: function subForm(_subForm) {
|
|
3309
|
-
|
|
3531
|
+
_this5.$handle.addSubForm(ctx, _subForm);
|
|
3310
3532
|
},
|
|
3311
3533
|
getSubForm: function getSubForm() {
|
|
3312
|
-
return
|
|
3534
|
+
return _this5.$handle.subForm[ctx.id];
|
|
3313
3535
|
},
|
|
3314
3536
|
options: [],
|
|
3315
3537
|
children: [],
|
|
3316
3538
|
preview: false,
|
|
3539
|
+
id: ctx.id,
|
|
3317
3540
|
field: ctx.field,
|
|
3318
3541
|
rule: ctx.rule,
|
|
3319
3542
|
input: ctx.input
|
|
@@ -3329,7 +3552,7 @@
|
|
|
3329
3552
|
return inject;
|
|
3330
3553
|
},
|
|
3331
3554
|
ctxProp: function ctxProp(ctx, custom) {
|
|
3332
|
-
var
|
|
3555
|
+
var _this6 = this;
|
|
3333
3556
|
|
|
3334
3557
|
var ref = ctx.ref,
|
|
3335
3558
|
key = ctx.key,
|
|
@@ -3344,7 +3567,7 @@
|
|
|
3344
3567
|
vnodeMounted: function vnodeMounted(vn) {
|
|
3345
3568
|
vn.el.__rule__ = ctx.rule;
|
|
3346
3569
|
|
|
3347
|
-
|
|
3570
|
+
_this6.onMounted(ctx, vn.el);
|
|
3348
3571
|
},
|
|
3349
3572
|
'fc.el': function fcEl(el) {
|
|
3350
3573
|
ctx.exportEl = el;
|
|
@@ -3360,12 +3583,14 @@
|
|
|
3360
3583
|
var field = this.getModelField(ctx);
|
|
3361
3584
|
var model = {
|
|
3362
3585
|
callback: function callback(value) {
|
|
3363
|
-
|
|
3586
|
+
_this6.onInput(ctx, value);
|
|
3364
3587
|
},
|
|
3365
3588
|
value: this.$handle.getFormData(ctx)
|
|
3366
3589
|
};
|
|
3367
3590
|
props.push({
|
|
3368
|
-
on: _defineProperty({}, "update:".concat(field), model.callback),
|
|
3591
|
+
on: _objectSpread2(_defineProperty({}, "update:".concat(field), model.callback), ctx.prop.modelEmit ? _defineProperty({}, ctx.prop.modelEmit, function () {
|
|
3592
|
+
return _this6.onEmitInput(ctx);
|
|
3593
|
+
}) : {}),
|
|
3369
3594
|
props: _defineProperty({}, field, model.value)
|
|
3370
3595
|
});
|
|
3371
3596
|
ctx.prop.model = model;
|
|
@@ -3380,10 +3605,18 @@
|
|
|
3380
3605
|
this.$handle.effect(ctx, 'mounted');
|
|
3381
3606
|
},
|
|
3382
3607
|
onInput: function onInput(ctx, value) {
|
|
3608
|
+
if (ctx.prop.modelEmit) {
|
|
3609
|
+
this.$handle.onBaseInput(ctx, value);
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3383
3613
|
this.$handle.onInput(ctx, value);
|
|
3384
3614
|
},
|
|
3615
|
+
onEmitInput: function onEmitInput(ctx) {
|
|
3616
|
+
this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
|
|
3617
|
+
},
|
|
3385
3618
|
renderChildren: function renderChildren(children, ctx) {
|
|
3386
|
-
var
|
|
3619
|
+
var _this7 = this;
|
|
3387
3620
|
|
|
3388
3621
|
if (!is.trueArray(children)) return {};
|
|
3389
3622
|
var slotBag = makeSlotBag();
|
|
@@ -3392,14 +3625,14 @@
|
|
|
3392
3625
|
if (is.String(child)) return slotBag.setSlot(null, child);
|
|
3393
3626
|
|
|
3394
3627
|
if (child.__fc__) {
|
|
3395
|
-
return
|
|
3628
|
+
return _this7.renderSlot(slotBag, child.__fc__, ctx);
|
|
3396
3629
|
}
|
|
3397
3630
|
|
|
3398
3631
|
if (child.type) {
|
|
3399
3632
|
vue.nextTick(function () {
|
|
3400
|
-
|
|
3633
|
+
_this7.$handle.loadChildren(children, ctx);
|
|
3401
3634
|
|
|
3402
|
-
|
|
3635
|
+
_this7.$handle.refresh();
|
|
3403
3636
|
});
|
|
3404
3637
|
}
|
|
3405
3638
|
});
|
|
@@ -3413,7 +3646,7 @@
|
|
|
3413
3646
|
return this.vNode.make(lower(ctx.originType), prop, children);
|
|
3414
3647
|
},
|
|
3415
3648
|
renderRule: function renderRule(rule, children, origin) {
|
|
3416
|
-
var
|
|
3649
|
+
var _this8 = this;
|
|
3417
3650
|
|
|
3418
3651
|
if (!rule) return undefined;
|
|
3419
3652
|
if (is.String(rule)) return rule;
|
|
@@ -3437,7 +3670,7 @@
|
|
|
3437
3670
|
if (is.trueArray(rule.children)) {
|
|
3438
3671
|
rule.children.forEach(function (v) {
|
|
3439
3672
|
v && slotBag.setSlot(v === null || v === void 0 ? void 0 : v.slot, function () {
|
|
3440
|
-
return
|
|
3673
|
+
return _this8.renderRule(v);
|
|
3441
3674
|
});
|
|
3442
3675
|
});
|
|
3443
3676
|
}
|
|
@@ -3681,16 +3914,6 @@
|
|
|
3681
3914
|
});
|
|
3682
3915
|
}
|
|
3683
3916
|
|
|
3684
|
-
function isNone(ctx) {
|
|
3685
|
-
var none = !(is.Undef(ctx.prop.display) || !!ctx.prop.display);
|
|
3686
|
-
|
|
3687
|
-
if (ctx.parent) {
|
|
3688
|
-
return ctx.parent.none || none;
|
|
3689
|
-
} else {
|
|
3690
|
-
return none;
|
|
3691
|
-
}
|
|
3692
|
-
}
|
|
3693
|
-
|
|
3694
3917
|
function bind(ctx) {
|
|
3695
3918
|
Object.defineProperties(ctx.origin, {
|
|
3696
3919
|
__fc__: enumerable(vue.markRaw(ctx), true)
|
|
@@ -3713,7 +3936,9 @@
|
|
|
3713
3936
|
linkOn: [],
|
|
3714
3937
|
root: [],
|
|
3715
3938
|
ctrlRule: [],
|
|
3939
|
+
children: [],
|
|
3716
3940
|
parent: null,
|
|
3941
|
+
group: rule.subRule ? this : null,
|
|
3717
3942
|
cacheConfig: null,
|
|
3718
3943
|
prop: _objectSpread2({}, rule),
|
|
3719
3944
|
computed: {},
|
|
@@ -3731,6 +3956,17 @@
|
|
|
3731
3956
|
this.update(handle, true);
|
|
3732
3957
|
}
|
|
3733
3958
|
extend(RuleContext.prototype, {
|
|
3959
|
+
getParentGroup: function getParentGroup() {
|
|
3960
|
+
var ctx = this.parent;
|
|
3961
|
+
|
|
3962
|
+
while (ctx) {
|
|
3963
|
+
if (ctx.group) {
|
|
3964
|
+
return ctx;
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
ctx = ctx.parent;
|
|
3968
|
+
}
|
|
3969
|
+
},
|
|
3734
3970
|
loadChildrenPending: function loadChildrenPending() {
|
|
3735
3971
|
var _this = this;
|
|
3736
3972
|
|
|
@@ -3866,7 +4102,7 @@
|
|
|
3866
4102
|
})), [this.computed]));
|
|
3867
4103
|
},
|
|
3868
4104
|
initNone: function initNone() {
|
|
3869
|
-
this.none =
|
|
4105
|
+
this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
|
|
3870
4106
|
},
|
|
3871
4107
|
check: function check(handle) {
|
|
3872
4108
|
return this.vm === handle.vm;
|
|
@@ -3896,6 +4132,11 @@
|
|
|
3896
4132
|
this.unwatch();
|
|
3897
4133
|
this.unlink();
|
|
3898
4134
|
this.rmCtrl();
|
|
4135
|
+
|
|
4136
|
+
if (this.parent) {
|
|
4137
|
+
this.parent.children.splice(this.parent.children.indexOf(this) >>> 0, 1);
|
|
4138
|
+
}
|
|
4139
|
+
|
|
3899
4140
|
extend(this, {
|
|
3900
4141
|
deleted: true,
|
|
3901
4142
|
prop: _objectSpread2({}, this.rule),
|
|
@@ -3907,6 +4148,7 @@
|
|
|
3907
4148
|
vm: undef,
|
|
3908
4149
|
vNode: undef,
|
|
3909
4150
|
parent: null,
|
|
4151
|
+
children: [],
|
|
3910
4152
|
cacheConfig: null,
|
|
3911
4153
|
none: false
|
|
3912
4154
|
});
|
|
@@ -4167,7 +4409,7 @@
|
|
|
4167
4409
|
}
|
|
4168
4410
|
};
|
|
4169
4411
|
|
|
4170
|
-
rules.map(function (_rule, index) {
|
|
4412
|
+
var ctxs = rules.map(function (_rule, index) {
|
|
4171
4413
|
if (parent && !is.Object(_rule)) return;
|
|
4172
4414
|
if (!_this6.pageEnd && !parent && index >= _this6.first) return;
|
|
4173
4415
|
|
|
@@ -4235,6 +4477,10 @@
|
|
|
4235
4477
|
}
|
|
4236
4478
|
|
|
4237
4479
|
_this6.appendValue(ctx.rule);
|
|
4480
|
+
|
|
4481
|
+
if (ctx.parent && ctx.parent !== parent) {
|
|
4482
|
+
_this6.rmSubRuleData(ctx);
|
|
4483
|
+
}
|
|
4238
4484
|
}
|
|
4239
4485
|
|
|
4240
4486
|
_this6.parseEmit(ctx);
|
|
@@ -4282,7 +4528,13 @@
|
|
|
4282
4528
|
|
|
4283
4529
|
if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
|
|
4284
4530
|
return ctx;
|
|
4531
|
+
}).filter(function (v) {
|
|
4532
|
+
return !!v;
|
|
4285
4533
|
});
|
|
4534
|
+
|
|
4535
|
+
if (parent) {
|
|
4536
|
+
parent.children = ctxs;
|
|
4537
|
+
}
|
|
4286
4538
|
},
|
|
4287
4539
|
refreshControl: function refreshControl(ctx) {
|
|
4288
4540
|
return ctx.input && ctx.rule.control && this.useCtrl(ctx);
|
|
@@ -4485,9 +4737,33 @@
|
|
|
4485
4737
|
this.setValue(ctx, val, value);
|
|
4486
4738
|
}
|
|
4487
4739
|
},
|
|
4740
|
+
onBaseInput: function onBaseInput(ctx, value) {
|
|
4741
|
+
this.setFormData(ctx, value);
|
|
4742
|
+
ctx.modelValue = value;
|
|
4743
|
+
this.nextRefresh();
|
|
4744
|
+
this.$render.clearCache(ctx);
|
|
4745
|
+
},
|
|
4488
4746
|
setFormData: function setFormData(ctx, value) {
|
|
4747
|
+
ctx.modelValue = value;
|
|
4748
|
+
var group = ctx.getParentGroup();
|
|
4749
|
+
|
|
4750
|
+
if (group) {
|
|
4751
|
+
if (!this.subRuleData[group.id]) {
|
|
4752
|
+
this.subRuleData[group.id] = {};
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
this.subRuleData[group.id][ctx.field] = ctx.rule.value;
|
|
4756
|
+
}
|
|
4757
|
+
|
|
4489
4758
|
$set(this.formData, ctx.id, value);
|
|
4490
4759
|
},
|
|
4760
|
+
rmSubRuleData: function rmSubRuleData(ctx) {
|
|
4761
|
+
var group = ctx.getParentGroup();
|
|
4762
|
+
|
|
4763
|
+
if (group && this.subRuleData[group.id]) {
|
|
4764
|
+
delete this.subRuleData[group.id][ctx.field];
|
|
4765
|
+
}
|
|
4766
|
+
},
|
|
4491
4767
|
getFormData: function getFormData(ctx) {
|
|
4492
4768
|
return this.formData[ctx.id];
|
|
4493
4769
|
},
|
|
@@ -4615,40 +4891,6 @@
|
|
|
4615
4891
|
mergeProp: function mergeProp(ctx) {}
|
|
4616
4892
|
};
|
|
4617
4893
|
|
|
4618
|
-
var _ = {
|
|
4619
|
-
sum: function sum(arr) {
|
|
4620
|
-
if (Array.isArray(arr)) {
|
|
4621
|
-
var val = 0;
|
|
4622
|
-
arr.map(function (v) {
|
|
4623
|
-
return val += v || 0;
|
|
4624
|
-
});
|
|
4625
|
-
return val;
|
|
4626
|
-
}
|
|
4627
|
-
},
|
|
4628
|
-
column: function column(arr, field) {
|
|
4629
|
-
if (Array.isArray(arr)) {
|
|
4630
|
-
return arr.map(function (v) {
|
|
4631
|
-
return v[field];
|
|
4632
|
-
});
|
|
4633
|
-
}
|
|
4634
|
-
|
|
4635
|
-
return [];
|
|
4636
|
-
},
|
|
4637
|
-
get: function get(obj, field, def) {
|
|
4638
|
-
var lst = field.split('.');
|
|
4639
|
-
var val = obj;
|
|
4640
|
-
|
|
4641
|
-
for (var i = 0; i < lst.length; i++) {
|
|
4642
|
-
if (hasProperty(val, lst[i])) {
|
|
4643
|
-
val = val[lst[i]];
|
|
4644
|
-
} else {
|
|
4645
|
-
return def === undefined ? 0 : def;
|
|
4646
|
-
}
|
|
4647
|
-
}
|
|
4648
|
-
|
|
4649
|
-
return val;
|
|
4650
|
-
}
|
|
4651
|
-
};
|
|
4652
4894
|
var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
|
|
4653
4895
|
function useContext(Handler) {
|
|
4654
4896
|
extend(Handler.prototype, {
|
|
@@ -4799,28 +5041,43 @@
|
|
|
4799
5041
|
}
|
|
4800
5042
|
}));
|
|
4801
5043
|
this.bus.$once('load-end', function () {
|
|
4802
|
-
var
|
|
4803
|
-
ctx.watch.push(vue.watch(function () {
|
|
4804
|
-
var computed = computedRef.value;
|
|
4805
|
-
if (!computed) return undefined;
|
|
4806
|
-
var fn;
|
|
4807
|
-
|
|
4808
|
-
if (is.Function(computed)) {
|
|
4809
|
-
fn = function fn() {
|
|
4810
|
-
return computed(_this.api.form, _this.api);
|
|
4811
|
-
};
|
|
4812
|
-
} else {
|
|
4813
|
-
fn = function fn() {
|
|
4814
|
-
return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
|
|
4815
|
-
};
|
|
4816
|
-
}
|
|
5044
|
+
var computed = ctx.rule.computed;
|
|
4817
5045
|
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
5046
|
+
if (!computed) {
|
|
5047
|
+
return;
|
|
5048
|
+
}
|
|
5049
|
+
|
|
5050
|
+
if (_typeof(computed) !== 'object') {
|
|
5051
|
+
computed = {
|
|
5052
|
+
value: computed
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
Object.keys(computed).forEach(function (k) {
|
|
5057
|
+
ctx.watch.push(vue.watch(function () {
|
|
5058
|
+
var item = computed[k];
|
|
5059
|
+
if (!item) return undefined;
|
|
5060
|
+
var fn;
|
|
5061
|
+
|
|
5062
|
+
if (is.Function(item)) {
|
|
5063
|
+
fn = function fn() {
|
|
5064
|
+
return item(_this.api.form, _this.api);
|
|
5065
|
+
};
|
|
5066
|
+
} else {
|
|
5067
|
+
var group = ctx.getParentGroup();
|
|
5068
|
+
|
|
5069
|
+
fn = function fn() {
|
|
5070
|
+
return new Function('formulas', 'top', 'group', "with(top){with(this){with(group){with(formulas){ return ".concat(item, " }}}}")).call(_this.api.form, _this.fc.formulas, _this.api.top.form, group ? _this.subRuleData[group.id] || {} : {});
|
|
5071
|
+
};
|
|
5072
|
+
}
|
|
5073
|
+
|
|
5074
|
+
return invoke(fn, undefined);
|
|
5075
|
+
}, function (n) {
|
|
5076
|
+
deepSet(ctx.rule, k, n);
|
|
5077
|
+
}, {
|
|
5078
|
+
immediate: true
|
|
5079
|
+
}));
|
|
5080
|
+
});
|
|
4824
5081
|
});
|
|
4825
5082
|
}
|
|
4826
5083
|
|
|
@@ -4831,7 +5088,7 @@
|
|
|
4831
5088
|
|
|
4832
5089
|
this.deferSyncValue(function () {
|
|
4833
5090
|
o && o.forEach(function (child) {
|
|
4834
|
-
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root
|
|
5091
|
+
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root !== n) {
|
|
4835
5092
|
_this2.rmCtx(child.__fc__);
|
|
4836
5093
|
}
|
|
4837
5094
|
});
|
|
@@ -4862,6 +5119,16 @@
|
|
|
4862
5119
|
$del(this.formData, id);
|
|
4863
5120
|
$del(this.subForm, id);
|
|
4864
5121
|
$del(this.vm.setupState.ctxInject, id);
|
|
5122
|
+
var group = ctx.getParentGroup();
|
|
5123
|
+
|
|
5124
|
+
if (group && this.subRuleData[group.id]) {
|
|
5125
|
+
$del(this.subRuleData[group.id], field);
|
|
5126
|
+
}
|
|
5127
|
+
|
|
5128
|
+
if (ctx.group) {
|
|
5129
|
+
$del(this.subRuleData, id);
|
|
5130
|
+
}
|
|
5131
|
+
|
|
4865
5132
|
input && this.rmIdCtx(ctx, field, 'field');
|
|
4866
5133
|
name && this.rmIdCtx(ctx, name, 'name');
|
|
4867
5134
|
|
|
@@ -5117,6 +5384,7 @@
|
|
|
5117
5384
|
deferSyncFn: null,
|
|
5118
5385
|
isMounted: false,
|
|
5119
5386
|
formData: vue.reactive({}),
|
|
5387
|
+
subRuleData: vue.reactive({}),
|
|
5120
5388
|
subForm: {},
|
|
5121
5389
|
form: vue.reactive({}),
|
|
5122
5390
|
appendData: {},
|
|
@@ -5166,77 +5434,6 @@
|
|
|
5166
5434
|
useLifecycle(Handler);
|
|
5167
5435
|
useEffect(Handler);
|
|
5168
5436
|
|
|
5169
|
-
// https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
|
|
5170
|
-
function getError(action, option, xhr) {
|
|
5171
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
5172
|
-
var err = new Error(msg);
|
|
5173
|
-
err.status = xhr.status;
|
|
5174
|
-
err.url = action;
|
|
5175
|
-
return err;
|
|
5176
|
-
}
|
|
5177
|
-
|
|
5178
|
-
function getBody(xhr) {
|
|
5179
|
-
var text = xhr.responseText || xhr.response;
|
|
5180
|
-
|
|
5181
|
-
if (!text) {
|
|
5182
|
-
return text;
|
|
5183
|
-
}
|
|
5184
|
-
|
|
5185
|
-
try {
|
|
5186
|
-
return JSON.parse(text);
|
|
5187
|
-
} catch (e) {
|
|
5188
|
-
return text;
|
|
5189
|
-
}
|
|
5190
|
-
}
|
|
5191
|
-
|
|
5192
|
-
function fetch$1(option) {
|
|
5193
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
5194
|
-
return;
|
|
5195
|
-
}
|
|
5196
|
-
|
|
5197
|
-
var xhr = new XMLHttpRequest();
|
|
5198
|
-
var action = option.action;
|
|
5199
|
-
|
|
5200
|
-
xhr.onerror = function error(e) {
|
|
5201
|
-
option.onError(e);
|
|
5202
|
-
};
|
|
5203
|
-
|
|
5204
|
-
xhr.onload = function onload() {
|
|
5205
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
5206
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
5207
|
-
}
|
|
5208
|
-
|
|
5209
|
-
option.onSuccess(getBody(xhr));
|
|
5210
|
-
};
|
|
5211
|
-
|
|
5212
|
-
xhr.open(option.method || 'get', action, true);
|
|
5213
|
-
var formData;
|
|
5214
|
-
|
|
5215
|
-
if (option.data) {
|
|
5216
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
5217
|
-
formData = new FormData();
|
|
5218
|
-
Object.keys(option.data).map(function (key) {
|
|
5219
|
-
formData.append(key, option.data[key]);
|
|
5220
|
-
});
|
|
5221
|
-
} else {
|
|
5222
|
-
formData = JSON.stringify(option.data);
|
|
5223
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
5224
|
-
}
|
|
5225
|
-
}
|
|
5226
|
-
|
|
5227
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
5228
|
-
xhr.withCredentials = true;
|
|
5229
|
-
}
|
|
5230
|
-
|
|
5231
|
-
var headers = option.headers || {};
|
|
5232
|
-
Object.keys(headers).forEach(function (item) {
|
|
5233
|
-
if (headers[item] !== null) {
|
|
5234
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
5235
|
-
}
|
|
5236
|
-
});
|
|
5237
|
-
xhr.send(formData);
|
|
5238
|
-
}
|
|
5239
|
-
|
|
5240
5437
|
var NAME = 'fcFragment';
|
|
5241
5438
|
var fragment = vue.defineComponent({
|
|
5242
5439
|
name: NAME,
|
|
@@ -5519,22 +5716,23 @@
|
|
|
5519
5716
|
function run(inject, rule, api) {
|
|
5520
5717
|
var option = inject.value;
|
|
5521
5718
|
|
|
5719
|
+
if (is.Function(option)) {
|
|
5720
|
+
option = option(rule, api);
|
|
5721
|
+
}
|
|
5722
|
+
|
|
5723
|
+
option = parseOpt(option);
|
|
5724
|
+
|
|
5522
5725
|
var set = function set(val) {
|
|
5523
5726
|
if (val === undefined) {
|
|
5524
5727
|
inject.clearProp();
|
|
5525
|
-
api.sync(rule);
|
|
5526
5728
|
} else {
|
|
5527
5729
|
deepSet(inject.getProp(), option.to || 'options', val);
|
|
5528
5730
|
}
|
|
5529
|
-
};
|
|
5530
|
-
|
|
5531
|
-
if (is.Function(option)) {
|
|
5532
|
-
option = option(rule, api);
|
|
5533
|
-
}
|
|
5534
5731
|
|
|
5535
|
-
|
|
5732
|
+
api.sync(rule);
|
|
5733
|
+
};
|
|
5536
5734
|
|
|
5537
|
-
if (!option || !option.action) {
|
|
5735
|
+
if (!option || !option.action && !option.key) {
|
|
5538
5736
|
set(undefined);
|
|
5539
5737
|
return;
|
|
5540
5738
|
}
|
|
@@ -5543,6 +5741,22 @@
|
|
|
5543
5741
|
option.to = 'options';
|
|
5544
5742
|
}
|
|
5545
5743
|
|
|
5744
|
+
if (option.key) {
|
|
5745
|
+
var item = fc.$handle.options.globalData[option.key];
|
|
5746
|
+
|
|
5747
|
+
if (!item) {
|
|
5748
|
+
set(undefined);
|
|
5749
|
+
return;
|
|
5750
|
+
}
|
|
5751
|
+
|
|
5752
|
+
if (item.type === 'static') {
|
|
5753
|
+
set(item.data);
|
|
5754
|
+
return;
|
|
5755
|
+
} else {
|
|
5756
|
+
option = _objectSpread2(_objectSpread2({}, option), item);
|
|
5757
|
+
}
|
|
5758
|
+
}
|
|
5759
|
+
|
|
5546
5760
|
var _onError = option.onError;
|
|
5547
5761
|
|
|
5548
5762
|
var check = function check() {
|
|
@@ -5563,11 +5777,13 @@
|
|
|
5563
5777
|
return flag ? v : v.data;
|
|
5564
5778
|
};
|
|
5565
5779
|
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5780
|
+
var parse = parseFn(option.parse);
|
|
5781
|
+
|
|
5782
|
+
if (is.Function(parse)) {
|
|
5783
|
+
fn = parse;
|
|
5784
|
+
} else if (parse && is.String(parse)) {
|
|
5569
5785
|
fn = function fn(v) {
|
|
5570
|
-
|
|
5786
|
+
parse.split('.').forEach(function (k) {
|
|
5571
5787
|
if (v) {
|
|
5572
5788
|
v = v[k];
|
|
5573
5789
|
}
|
|
@@ -5699,6 +5915,7 @@
|
|
|
5699
5915
|
};
|
|
5700
5916
|
var loadData = {};
|
|
5701
5917
|
var CreateNode = CreateNodeFactory();
|
|
5918
|
+
var formulas = {};
|
|
5702
5919
|
exportAttrs(config.attrs || {});
|
|
5703
5920
|
|
|
5704
5921
|
function getApi(name) {
|
|
@@ -5735,11 +5952,11 @@
|
|
|
5735
5952
|
|
|
5736
5953
|
function parser() {
|
|
5737
5954
|
var data = nameProp.apply(void 0, arguments);
|
|
5738
|
-
if (!data.id || !data.prop) return;
|
|
5955
|
+
if (!data.id || !data.prop) return BaseParser;
|
|
5739
5956
|
var name = toCase(data.id);
|
|
5740
5957
|
var parser = data.prop;
|
|
5741
5958
|
var base = parser.merge === true ? parsers[name] : undefined;
|
|
5742
|
-
parsers[name] =
|
|
5959
|
+
parsers[name] = setPrototypeOf(parser, base || BaseParser);
|
|
5743
5960
|
maker[name] = creatorFactory(name);
|
|
5744
5961
|
parser.maker && extend(maker, parser.maker);
|
|
5745
5962
|
}
|
|
@@ -5759,8 +5976,13 @@
|
|
|
5759
5976
|
}
|
|
5760
5977
|
|
|
5761
5978
|
if (!name || !component) return;
|
|
5979
|
+
var nameAlias = toCase(name);
|
|
5762
5980
|
components[name] = component;
|
|
5763
|
-
components[
|
|
5981
|
+
components[nameAlias] = component;
|
|
5982
|
+
delete CreateNode.aliasMap[name];
|
|
5983
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5984
|
+
delete parsers[name];
|
|
5985
|
+
delete parsers[nameAlias];
|
|
5764
5986
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5765
5987
|
}
|
|
5766
5988
|
|
|
@@ -5820,6 +6042,7 @@
|
|
|
5820
6042
|
providers: providers,
|
|
5821
6043
|
useApps: useApps,
|
|
5822
6044
|
maker: maker,
|
|
6045
|
+
formulas: formulas,
|
|
5823
6046
|
loadData: loadData
|
|
5824
6047
|
};
|
|
5825
6048
|
} else {
|
|
@@ -5833,6 +6056,10 @@
|
|
|
5833
6056
|
modelFields[name] = field;
|
|
5834
6057
|
}
|
|
5835
6058
|
|
|
6059
|
+
function setFormula(name, fn) {
|
|
6060
|
+
formulas[name] = fn;
|
|
6061
|
+
}
|
|
6062
|
+
|
|
5836
6063
|
function _emitData(id) {
|
|
5837
6064
|
Object.keys(instance).forEach(function (v) {
|
|
5838
6065
|
var apis = Array.isArray(instance[v]) ? instance[v] : [instance[v]];
|
|
@@ -5865,6 +6092,7 @@
|
|
|
5865
6092
|
parsers: parsers,
|
|
5866
6093
|
providers: providers,
|
|
5867
6094
|
modelFields: modelFields,
|
|
6095
|
+
formulas: formulas,
|
|
5868
6096
|
rules: vm.props.rule,
|
|
5869
6097
|
name: vm.props.name || uniqueId(),
|
|
5870
6098
|
inFor: vm.props.inFor,
|
|
@@ -5876,7 +6104,7 @@
|
|
|
5876
6104
|
CreateNode: CreateNode,
|
|
5877
6105
|
bus: new Mitt(),
|
|
5878
6106
|
unwatch: null,
|
|
5879
|
-
options: vue.ref(
|
|
6107
|
+
options: vue.ref({}),
|
|
5880
6108
|
extendApi: config.extendApi || function (api) {
|
|
5881
6109
|
return api;
|
|
5882
6110
|
}
|
|
@@ -5910,9 +6138,9 @@
|
|
|
5910
6138
|
|
|
5911
6139
|
if (this.isSub()) {
|
|
5912
6140
|
this.unwatch = vue.watch(function () {
|
|
5913
|
-
return _this2.vm.parent.
|
|
6141
|
+
return _this2.vm.setupState.parent.setupState.fc.options.value;
|
|
5914
6142
|
}, function () {
|
|
5915
|
-
_this2.initOptions(
|
|
6143
|
+
_this2.initOptions();
|
|
5916
6144
|
|
|
5917
6145
|
_this2.$handle.api.refresh();
|
|
5918
6146
|
}, {
|
|
@@ -5920,23 +6148,28 @@
|
|
|
5920
6148
|
});
|
|
5921
6149
|
}
|
|
5922
6150
|
|
|
5923
|
-
this.initOptions(
|
|
6151
|
+
this.initOptions();
|
|
5924
6152
|
this.$handle.init();
|
|
5925
6153
|
},
|
|
5926
6154
|
isSub: function isSub() {
|
|
5927
6155
|
return this.vm.setupState.parent && this.vm.props.extendOption;
|
|
5928
6156
|
},
|
|
5929
|
-
initOptions: function initOptions(
|
|
5930
|
-
this.options.value =
|
|
6157
|
+
initOptions: function initOptions() {
|
|
6158
|
+
this.options.value = {};
|
|
6159
|
+
|
|
6160
|
+
var options = _objectSpread2({
|
|
5931
6161
|
formData: {},
|
|
5932
6162
|
submitBtn: {},
|
|
5933
|
-
resetBtn: {}
|
|
6163
|
+
resetBtn: {},
|
|
6164
|
+
globalEvent: {},
|
|
6165
|
+
globalData: {}
|
|
5934
6166
|
}, deepCopy(globalConfig));
|
|
5935
6167
|
|
|
5936
6168
|
if (this.isSub()) {
|
|
5937
|
-
|
|
6169
|
+
options = this.mergeOptions(options, this.vm.setupState.parent.setupState.fc.options.value || {}, true);
|
|
5938
6170
|
}
|
|
5939
6171
|
|
|
6172
|
+
options = this.mergeOptions(options, this.vm.props.option);
|
|
5940
6173
|
this.updateOptions(options);
|
|
5941
6174
|
},
|
|
5942
6175
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
@@ -5998,6 +6231,7 @@
|
|
|
5998
6231
|
component: component,
|
|
5999
6232
|
directive: directive,
|
|
6000
6233
|
setModelField: setModelField,
|
|
6234
|
+
setFormula: setFormula,
|
|
6001
6235
|
register: register,
|
|
6002
6236
|
$vnode: $vnode,
|
|
6003
6237
|
parser: parser,
|
|
@@ -6064,6 +6298,7 @@
|
|
|
6064
6298
|
inherit.useApps && extend(useApps, inherit.useApps);
|
|
6065
6299
|
inherit.maker && extend(maker, inherit.maker);
|
|
6066
6300
|
inherit.loadData && extend(loadData, inherit.loadData);
|
|
6301
|
+
inherit.formulas && extend(formulas, inherit.formulas);
|
|
6067
6302
|
}
|
|
6068
6303
|
|
|
6069
6304
|
return create;
|
|
@@ -6343,7 +6578,7 @@
|
|
|
6343
6578
|
}
|
|
6344
6579
|
},
|
|
6345
6580
|
tidyOptions: function tidyOptions(options) {
|
|
6346
|
-
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col'].forEach(function (name) {
|
|
6581
|
+
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col', 'title'].forEach(function (name) {
|
|
6347
6582
|
tidyBool(options, name);
|
|
6348
6583
|
});
|
|
6349
6584
|
return options;
|
|
@@ -6358,7 +6593,8 @@
|
|
|
6358
6593
|
ctx.prop = mergeProps([{
|
|
6359
6594
|
info: this.options.info || {},
|
|
6360
6595
|
wrap: this.options.wrap || {},
|
|
6361
|
-
col: this.options.col || {}
|
|
6596
|
+
col: this.options.col || {},
|
|
6597
|
+
title: this.options.title || {}
|
|
6362
6598
|
}, ctx.prop], {
|
|
6363
6599
|
info: {
|
|
6364
6600
|
trigger: 'hover',
|
|
@@ -6386,7 +6622,7 @@
|
|
|
6386
6622
|
e.preventDefault();
|
|
6387
6623
|
}
|
|
6388
6624
|
},
|
|
6389
|
-
"class": [form.className, form["class"], 'form-create'],
|
|
6625
|
+
"class": [form.className, form["class"], 'form-create', this.options.preview ? 'is-preview' : ''],
|
|
6390
6626
|
style: form.style,
|
|
6391
6627
|
type: 'form'
|
|
6392
6628
|
};
|
|
@@ -6406,7 +6642,7 @@
|
|
|
6406
6642
|
render: function render(children) {
|
|
6407
6643
|
var _this2 = this;
|
|
6408
6644
|
|
|
6409
|
-
if (children.slotLen()) {
|
|
6645
|
+
if (children.slotLen() && !this.options.preview) {
|
|
6410
6646
|
children.setSlot(undefined, function () {
|
|
6411
6647
|
return _this2.makeFormBtn();
|
|
6412
6648
|
});
|
|
@@ -6693,7 +6929,7 @@
|
|
|
6693
6929
|
return maker;
|
|
6694
6930
|
}
|
|
6695
6931
|
|
|
6696
|
-
var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}";
|
|
6932
|
+
var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}.form-create .fc-none,.form-create.is-preview .fc-clock{display:none!important}";
|
|
6697
6933
|
styleInject(css_248z);
|
|
6698
6934
|
|
|
6699
6935
|
function tidyBtnProp(btn, def) {
|
|
@@ -6946,7 +7182,7 @@
|
|
|
6946
7182
|
function elmFormCreate() {
|
|
6947
7183
|
return FormCreateFactory({
|
|
6948
7184
|
ui: 'element-ui',
|
|
6949
|
-
version: '3.1.
|
|
7185
|
+
version: '3.1.29',
|
|
6950
7186
|
manager: manager,
|
|
6951
7187
|
extendApi: extendApi,
|
|
6952
7188
|
install: install,
|