@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.esm.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.
|
|
@@ -253,13 +253,16 @@ var Checkbox = defineComponent({
|
|
|
253
253
|
var props = _objectSpread2({}, opt);
|
|
254
254
|
|
|
255
255
|
var value = props.value;
|
|
256
|
+
var label = props.label;
|
|
256
257
|
delete props.value;
|
|
258
|
+
delete props.label;
|
|
257
259
|
return createVNode(Type, mergeProps$1(props, {
|
|
258
260
|
"label": value,
|
|
259
|
-
"
|
|
261
|
+
"value": value,
|
|
262
|
+
"key": name + index + '-' + value
|
|
260
263
|
}), {
|
|
261
264
|
"default": function _default() {
|
|
262
|
-
return [
|
|
265
|
+
return [label || value || ''];
|
|
263
266
|
}
|
|
264
267
|
});
|
|
265
268
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -997,13 +1000,16 @@ var Radio = defineComponent({
|
|
|
997
1000
|
var props = _objectSpread2({}, opt);
|
|
998
1001
|
|
|
999
1002
|
var value = props.value;
|
|
1003
|
+
var label = props.label;
|
|
1000
1004
|
delete props.value;
|
|
1005
|
+
delete props.label;
|
|
1001
1006
|
return createVNode(Type, mergeProps$1(props, {
|
|
1002
1007
|
"label": value,
|
|
1003
|
-
"
|
|
1008
|
+
"value": value,
|
|
1009
|
+
"key": name + index + '-' + value
|
|
1004
1010
|
}), {
|
|
1005
1011
|
"default": function _default() {
|
|
1006
|
-
return [
|
|
1012
|
+
return [label || value || ''];
|
|
1007
1013
|
}
|
|
1008
1014
|
});
|
|
1009
1015
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -1415,6 +1421,10 @@ var _extends = Object.assign || function (a) {
|
|
|
1415
1421
|
function extend() {
|
|
1416
1422
|
return _extends.apply(this, arguments);
|
|
1417
1423
|
}
|
|
1424
|
+
function copy$1(obj) {
|
|
1425
|
+
if (_typeof(obj) !== 'object' || obj === null) return obj;
|
|
1426
|
+
return obj instanceof Array ? _toConsumableArray(obj) : _objectSpread2({}, obj);
|
|
1427
|
+
}
|
|
1418
1428
|
|
|
1419
1429
|
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%}";
|
|
1420
1430
|
styleInject(css_248z$1);
|
|
@@ -1798,7 +1808,7 @@ var Group = defineComponent({
|
|
|
1798
1808
|
add: this.add
|
|
1799
1809
|
}) : createVNode("div", {
|
|
1800
1810
|
"key": 'a_def',
|
|
1801
|
-
"class": "_fc-group-plus-minus _fc-group-add",
|
|
1811
|
+
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
|
|
1802
1812
|
"onClick": this.add
|
|
1803
1813
|
}, null) : keys.map(function (key, index) {
|
|
1804
1814
|
var _this12$cacheRule$key = _this12.cacheRule[key],
|
|
@@ -1832,7 +1842,7 @@ var Group = defineComponent({
|
|
|
1832
1842
|
}), null), createVNode("div", {
|
|
1833
1843
|
"class": "_fc-group-idx"
|
|
1834
1844
|
}, [index + 1]), btn.length ? createVNode("div", {
|
|
1835
|
-
"class": "_fc-group-handle"
|
|
1845
|
+
"class": "_fc-group-handle fc-clock"
|
|
1836
1846
|
}, [btn]) : null]);
|
|
1837
1847
|
});
|
|
1838
1848
|
return createVNode("div", {
|
|
@@ -1990,6 +2000,7 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
1990
2000
|
},
|
|
1991
2001
|
extendOption: Boolean,
|
|
1992
2002
|
modelValue: Object,
|
|
2003
|
+
disabled: Boolean,
|
|
1993
2004
|
api: Object,
|
|
1994
2005
|
name: String,
|
|
1995
2006
|
subForm: {
|
|
@@ -2019,7 +2030,7 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2019
2030
|
isShow: true,
|
|
2020
2031
|
unique: 1,
|
|
2021
2032
|
renderRule: _toConsumableArray(rule.value || []),
|
|
2022
|
-
updateValue: JSON.stringify(modelValue || {})
|
|
2033
|
+
updateValue: JSON.stringify(modelValue.value || {})
|
|
2023
2034
|
});
|
|
2024
2035
|
var fc = new FormCreate(vm);
|
|
2025
2036
|
var fapi = fc.api();
|
|
@@ -2088,8 +2099,8 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2088
2099
|
});
|
|
2089
2100
|
watch(function () {
|
|
2090
2101
|
return props.option;
|
|
2091
|
-
}, function (
|
|
2092
|
-
fc.initOptions(
|
|
2102
|
+
}, function () {
|
|
2103
|
+
fc.initOptions();
|
|
2093
2104
|
fapi.refresh();
|
|
2094
2105
|
}, {
|
|
2095
2106
|
deep: true
|
|
@@ -2100,6 +2111,11 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2100
2111
|
}, {
|
|
2101
2112
|
deep: true
|
|
2102
2113
|
});
|
|
2114
|
+
watch(function () {
|
|
2115
|
+
return props.disabled;
|
|
2116
|
+
}, function (n) {
|
|
2117
|
+
fapi.disabled(!!n);
|
|
2118
|
+
});
|
|
2103
2119
|
return _objectSpread2(_objectSpread2({
|
|
2104
2120
|
fc: markRaw(fc),
|
|
2105
2121
|
parent: parent ? markRaw(parent) : parent,
|
|
@@ -2122,6 +2138,7 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2122
2138
|
var vm = getCurrentInstance();
|
|
2123
2139
|
vm.setupState.fc.init();
|
|
2124
2140
|
vm.emit('update:api', vm.setupState.fapi);
|
|
2141
|
+
vm.props.disabled && vm.setupState.fapi.disabled(true);
|
|
2125
2142
|
}
|
|
2126
2143
|
});
|
|
2127
2144
|
}
|
|
@@ -2195,7 +2212,7 @@ var mergeFn = function mergeFn(fn1, fn2) {
|
|
|
2195
2212
|
};
|
|
2196
2213
|
};
|
|
2197
2214
|
|
|
2198
|
-
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'];
|
|
2215
|
+
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'];
|
|
2199
2216
|
var arrayAttrs = ['validate', 'children', 'control'];
|
|
2200
2217
|
var normalAttrs = ['effect'];
|
|
2201
2218
|
function attrs() {
|
|
@@ -2226,6 +2243,7 @@ var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
|
2226
2243
|
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2227
2244
|
var $T = '$FN:';
|
|
2228
2245
|
var $TX = '$FNX:';
|
|
2246
|
+
var $ON = '$GLOBAL:';
|
|
2229
2247
|
var FUNCTION = 'function';
|
|
2230
2248
|
function toJson(obj, space) {
|
|
2231
2249
|
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
@@ -2261,6 +2279,26 @@ function parseFn(fn, mode) {
|
|
|
2261
2279
|
} else if (v.indexOf($T) === 0) {
|
|
2262
2280
|
v = v.replace($T, '');
|
|
2263
2281
|
flag = true;
|
|
2282
|
+
} else if (v.indexOf($ON) === 0) {
|
|
2283
|
+
var name = v.replace($ON, '');
|
|
2284
|
+
|
|
2285
|
+
v = function v() {
|
|
2286
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2287
|
+
args[_key] = arguments[_key];
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
var callback = args[0].api.getGlobalEvent(name);
|
|
2291
|
+
|
|
2292
|
+
if (callback) {
|
|
2293
|
+
return callback.call.apply(callback, [this].concat(args));
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
return undefined;
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2299
|
+
v.__json = fn;
|
|
2300
|
+
v.__inject = true;
|
|
2301
|
+
return v;
|
|
2264
2302
|
} else if (v.indexOf($TX) === 0) {
|
|
2265
2303
|
v = makeFn('function($inject){' + v.replace($TX, '') + '}');
|
|
2266
2304
|
v.__json = fn;
|
|
@@ -2445,6 +2483,10 @@ function toProps(rule) {
|
|
|
2445
2483
|
if (prop.slot) delete prop.slot;
|
|
2446
2484
|
return prop;
|
|
2447
2485
|
}
|
|
2486
|
+
function setPrototypeOf(o, proto) {
|
|
2487
|
+
Object.setPrototypeOf(o, proto);
|
|
2488
|
+
return o;
|
|
2489
|
+
}
|
|
2448
2490
|
|
|
2449
2491
|
function baseRule() {
|
|
2450
2492
|
return {
|
|
@@ -2521,6 +2563,107 @@ function makerFactory() {
|
|
|
2521
2563
|
};
|
|
2522
2564
|
}
|
|
2523
2565
|
|
|
2566
|
+
function getError(action, option, xhr) {
|
|
2567
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2568
|
+
var err = new Error(msg);
|
|
2569
|
+
err.status = xhr.status;
|
|
2570
|
+
err.url = action;
|
|
2571
|
+
return err;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
function getBody(xhr) {
|
|
2575
|
+
var text = xhr.responseText || xhr.response;
|
|
2576
|
+
|
|
2577
|
+
if (!text) {
|
|
2578
|
+
return text;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
try {
|
|
2582
|
+
return JSON.parse(text);
|
|
2583
|
+
} catch (e) {
|
|
2584
|
+
return text;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
function fetch$1(option) {
|
|
2589
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
var xhr = new XMLHttpRequest();
|
|
2594
|
+
var action = option.action;
|
|
2595
|
+
|
|
2596
|
+
xhr.onerror = function error(e) {
|
|
2597
|
+
option.onError(e);
|
|
2598
|
+
};
|
|
2599
|
+
|
|
2600
|
+
xhr.onload = function onload() {
|
|
2601
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2602
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
option.onSuccess(getBody(xhr));
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2608
|
+
xhr.open(option.method || 'get', action, true);
|
|
2609
|
+
var formData;
|
|
2610
|
+
|
|
2611
|
+
if (option.data) {
|
|
2612
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2613
|
+
formData = new FormData();
|
|
2614
|
+
Object.keys(option.data).map(function (key) {
|
|
2615
|
+
formData.append(key, option.data[key]);
|
|
2616
|
+
});
|
|
2617
|
+
} else {
|
|
2618
|
+
formData = JSON.stringify(option.data);
|
|
2619
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2624
|
+
xhr.withCredentials = true;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
var headers = option.headers || {};
|
|
2628
|
+
Object.keys(headers).forEach(function (item) {
|
|
2629
|
+
if (headers[item] !== null) {
|
|
2630
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
xhr.send(formData);
|
|
2634
|
+
}
|
|
2635
|
+
function asyncFetch(config) {
|
|
2636
|
+
return new Promise(function (resolve, reject) {
|
|
2637
|
+
fetch$1(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2638
|
+
onSuccess: function onSuccess(res) {
|
|
2639
|
+
var fn = function fn(v) {
|
|
2640
|
+
return v;
|
|
2641
|
+
};
|
|
2642
|
+
|
|
2643
|
+
var parse = parseFn(config.parse);
|
|
2644
|
+
|
|
2645
|
+
if (is.Function(parse)) {
|
|
2646
|
+
fn = parse;
|
|
2647
|
+
} else if (parse && is.String(parse)) {
|
|
2648
|
+
fn = function fn(v) {
|
|
2649
|
+
parse.split('.').forEach(function (k) {
|
|
2650
|
+
if (v) {
|
|
2651
|
+
v = v[k];
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
return v;
|
|
2655
|
+
};
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
resolve(fn(res));
|
|
2659
|
+
},
|
|
2660
|
+
onError: function onError(err) {
|
|
2661
|
+
reject(err);
|
|
2662
|
+
}
|
|
2663
|
+
}));
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2524
2667
|
function copy(value) {
|
|
2525
2668
|
return deepCopy(value);
|
|
2526
2669
|
}
|
|
@@ -2576,7 +2719,15 @@ function Api(h) {
|
|
|
2576
2719
|
},
|
|
2577
2720
|
|
|
2578
2721
|
get parent() {
|
|
2579
|
-
return h.vm.parent && h.vm.parent.setupState.fapi;
|
|
2722
|
+
return h.vm.setupState.parent && h.vm.setupState.parent.setupState.fapi;
|
|
2723
|
+
},
|
|
2724
|
+
|
|
2725
|
+
get top() {
|
|
2726
|
+
if (api.parent) {
|
|
2727
|
+
return api.parent.top;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
return api;
|
|
2580
2731
|
},
|
|
2581
2732
|
|
|
2582
2733
|
get children() {
|
|
@@ -2920,6 +3071,84 @@ function Api(h) {
|
|
|
2920
3071
|
var ctx = h.getCtx(field);
|
|
2921
3072
|
return ctx ? h.subForm[ctx.id] : undefined;
|
|
2922
3073
|
},
|
|
3074
|
+
getChildrenRuleList: function getChildrenRuleList(id) {
|
|
3075
|
+
var flag = _typeof(id) === 'object';
|
|
3076
|
+
var ctx = flag ? byCtx(id) : h.getCtx(id);
|
|
3077
|
+
var rule = ctx ? ctx.rule : flag ? id : api.getRule(id);
|
|
3078
|
+
|
|
3079
|
+
if (!rule) {
|
|
3080
|
+
return [];
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
var rules = [];
|
|
3084
|
+
|
|
3085
|
+
var findRules = function findRules(children) {
|
|
3086
|
+
children && children.forEach(function (item) {
|
|
3087
|
+
if (_typeof(item) !== 'object') {
|
|
3088
|
+
return;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
if (item.field) {
|
|
3092
|
+
rules.push(item);
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
rules.push.apply(rules, _toConsumableArray(api.getChildrenRuleList(item)));
|
|
3096
|
+
});
|
|
3097
|
+
};
|
|
3098
|
+
|
|
3099
|
+
findRules(ctx ? ctx.loadChildrenPending() : rule.children);
|
|
3100
|
+
return rules;
|
|
3101
|
+
},
|
|
3102
|
+
getChildrenFormData: function getChildrenFormData(id) {
|
|
3103
|
+
var rules = api.getChildrenRuleList(id);
|
|
3104
|
+
return rules.reduce(function (formData, rule) {
|
|
3105
|
+
formData[rule.field] = copy(rule.value);
|
|
3106
|
+
return formData;
|
|
3107
|
+
}, {});
|
|
3108
|
+
},
|
|
3109
|
+
setChildrenFormData: function setChildrenFormData(id, formData, cover) {
|
|
3110
|
+
var rules = api.getChildrenRuleList(id);
|
|
3111
|
+
rules.forEach(function (rule) {
|
|
3112
|
+
if (hasProperty(formData, rule.field)) {
|
|
3113
|
+
rule.value = formData[rule.field];
|
|
3114
|
+
} else if (cover) {
|
|
3115
|
+
rule.value = undefined;
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
},
|
|
3119
|
+
getGlobalEvent: function getGlobalEvent(name) {
|
|
3120
|
+
var event = api.options.globalEvent[name];
|
|
3121
|
+
|
|
3122
|
+
if (event) {
|
|
3123
|
+
if (_typeof(event) === 'object') {
|
|
3124
|
+
event = event.handle;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
return parseFn(event);
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
return undefined;
|
|
3131
|
+
},
|
|
3132
|
+
getGlobalData: function getGlobalData(name) {
|
|
3133
|
+
return new Promise(function (resolve, inject) {
|
|
3134
|
+
var config = api.options.globalData[name];
|
|
3135
|
+
|
|
3136
|
+
if (!config) {
|
|
3137
|
+
resolve(h.fc.loadData[name]);
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
if (config.type === 'fetch') {
|
|
3141
|
+
asyncFetch(config).then(function (res) {
|
|
3142
|
+
resolve({
|
|
3143
|
+
res: res,
|
|
3144
|
+
config: config
|
|
3145
|
+
});
|
|
3146
|
+
})["catch"](inject);
|
|
3147
|
+
} else {
|
|
3148
|
+
resolve(config.data);
|
|
3149
|
+
}
|
|
3150
|
+
});
|
|
3151
|
+
},
|
|
2923
3152
|
nextTick: function nextTick(fn) {
|
|
2924
3153
|
h.bus.$once('next-tick', fn);
|
|
2925
3154
|
h.refresh();
|
|
@@ -3016,7 +3245,8 @@ function toString(val) {
|
|
|
3016
3245
|
|
|
3017
3246
|
var id$2 = 0;
|
|
3018
3247
|
function uniqueId() {
|
|
3019
|
-
|
|
3248
|
+
var num = 370 + ++id$2;
|
|
3249
|
+
return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
|
|
3020
3250
|
}
|
|
3021
3251
|
|
|
3022
3252
|
function deepSet(data, idx, val) {
|
|
@@ -3215,7 +3445,7 @@ function useRender$1(Render) {
|
|
|
3215
3445
|
inject.children = children;
|
|
3216
3446
|
_vn = slot(inject);
|
|
3217
3447
|
} else {
|
|
3218
|
-
_vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
|
|
3448
|
+
_vn = preview ? ctx.parser.preview(copy$1(children), ctx) : ctx.parser.render(copy$1(children), ctx);
|
|
3219
3449
|
}
|
|
3220
3450
|
|
|
3221
3451
|
_vn = _this4.renderSides(_vn, ctx);
|
|
@@ -3225,7 +3455,17 @@ function useRender$1(Render) {
|
|
|
3225
3455
|
}
|
|
3226
3456
|
|
|
3227
3457
|
if (ctx.none) {
|
|
3228
|
-
|
|
3458
|
+
if (Array.isArray(_vn)) {
|
|
3459
|
+
_vn = _vn.map(function (v) {
|
|
3460
|
+
if (!v || !v.__v_isVNode) {
|
|
3461
|
+
return v;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
return _this4.none(v);
|
|
3465
|
+
});
|
|
3466
|
+
} else {
|
|
3467
|
+
_vn = _this4.none(_vn);
|
|
3468
|
+
}
|
|
3229
3469
|
}
|
|
3230
3470
|
|
|
3231
3471
|
cacheFlag && !Object.keys(children).length && _this4.setCache(ctx, function () {
|
|
@@ -3257,43 +3497,25 @@ function useRender$1(Render) {
|
|
|
3257
3497
|
return;
|
|
3258
3498
|
}
|
|
3259
3499
|
},
|
|
3260
|
-
getModelField: function getModelField(ctx) {
|
|
3261
|
-
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';
|
|
3262
|
-
},
|
|
3263
|
-
display: function display(vn) {
|
|
3264
|
-
var _this5 = this;
|
|
3265
|
-
|
|
3266
|
-
if (Array.isArray(vn)) {
|
|
3267
|
-
var data = [];
|
|
3268
|
-
vn.forEach(function (v) {
|
|
3269
|
-
if (Array.isArray(v)) return _this5.display(v);
|
|
3270
|
-
if (_this5.none(v)) data.push(v);
|
|
3271
|
-
});
|
|
3272
|
-
return data;
|
|
3273
|
-
} else {
|
|
3274
|
-
return this.none(vn);
|
|
3275
|
-
}
|
|
3276
|
-
},
|
|
3277
3500
|
none: function none(vn) {
|
|
3278
3501
|
if (vn) {
|
|
3279
|
-
if (Array.isArray(vn.props
|
|
3280
|
-
vn.props.
|
|
3281
|
-
display: 'none'
|
|
3282
|
-
});
|
|
3502
|
+
if (Array.isArray(vn.props["class"])) {
|
|
3503
|
+
vn.props["class"].push('fc-none');
|
|
3283
3504
|
} else {
|
|
3284
|
-
vn.props
|
|
3285
|
-
display: 'none'
|
|
3286
|
-
}];
|
|
3505
|
+
vn.props["class"] = [vn.props["class"], 'fc-none'];
|
|
3287
3506
|
}
|
|
3288
3507
|
|
|
3289
3508
|
return vn;
|
|
3290
3509
|
}
|
|
3291
3510
|
},
|
|
3511
|
+
getModelField: function getModelField(ctx) {
|
|
3512
|
+
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';
|
|
3513
|
+
},
|
|
3292
3514
|
isFragment: function isFragment(ctx) {
|
|
3293
3515
|
return ctx.type === 'fragment' || ctx.type === 'template';
|
|
3294
3516
|
},
|
|
3295
3517
|
injectProp: function injectProp(ctx) {
|
|
3296
|
-
var
|
|
3518
|
+
var _this5 = this;
|
|
3297
3519
|
|
|
3298
3520
|
var state = this.vm.setupState;
|
|
3299
3521
|
|
|
@@ -3302,14 +3524,15 @@ function useRender$1(Render) {
|
|
|
3302
3524
|
api: this.$handle.api,
|
|
3303
3525
|
form: this.fc.create,
|
|
3304
3526
|
subForm: function subForm(_subForm) {
|
|
3305
|
-
|
|
3527
|
+
_this5.$handle.addSubForm(ctx, _subForm);
|
|
3306
3528
|
},
|
|
3307
3529
|
getSubForm: function getSubForm() {
|
|
3308
|
-
return
|
|
3530
|
+
return _this5.$handle.subForm[ctx.id];
|
|
3309
3531
|
},
|
|
3310
3532
|
options: [],
|
|
3311
3533
|
children: [],
|
|
3312
3534
|
preview: false,
|
|
3535
|
+
id: ctx.id,
|
|
3313
3536
|
field: ctx.field,
|
|
3314
3537
|
rule: ctx.rule,
|
|
3315
3538
|
input: ctx.input
|
|
@@ -3325,7 +3548,7 @@ function useRender$1(Render) {
|
|
|
3325
3548
|
return inject;
|
|
3326
3549
|
},
|
|
3327
3550
|
ctxProp: function ctxProp(ctx, custom) {
|
|
3328
|
-
var
|
|
3551
|
+
var _this6 = this;
|
|
3329
3552
|
|
|
3330
3553
|
var ref = ctx.ref,
|
|
3331
3554
|
key = ctx.key,
|
|
@@ -3340,7 +3563,7 @@ function useRender$1(Render) {
|
|
|
3340
3563
|
vnodeMounted: function vnodeMounted(vn) {
|
|
3341
3564
|
vn.el.__rule__ = ctx.rule;
|
|
3342
3565
|
|
|
3343
|
-
|
|
3566
|
+
_this6.onMounted(ctx, vn.el);
|
|
3344
3567
|
},
|
|
3345
3568
|
'fc.el': function fcEl(el) {
|
|
3346
3569
|
ctx.exportEl = el;
|
|
@@ -3356,12 +3579,14 @@ function useRender$1(Render) {
|
|
|
3356
3579
|
var field = this.getModelField(ctx);
|
|
3357
3580
|
var model = {
|
|
3358
3581
|
callback: function callback(value) {
|
|
3359
|
-
|
|
3582
|
+
_this6.onInput(ctx, value);
|
|
3360
3583
|
},
|
|
3361
3584
|
value: this.$handle.getFormData(ctx)
|
|
3362
3585
|
};
|
|
3363
3586
|
props.push({
|
|
3364
|
-
on: _defineProperty({}, "update:".concat(field), model.callback),
|
|
3587
|
+
on: _objectSpread2(_defineProperty({}, "update:".concat(field), model.callback), ctx.prop.modelEmit ? _defineProperty({}, ctx.prop.modelEmit, function () {
|
|
3588
|
+
return _this6.onEmitInput(ctx);
|
|
3589
|
+
}) : {}),
|
|
3365
3590
|
props: _defineProperty({}, field, model.value)
|
|
3366
3591
|
});
|
|
3367
3592
|
ctx.prop.model = model;
|
|
@@ -3376,10 +3601,18 @@ function useRender$1(Render) {
|
|
|
3376
3601
|
this.$handle.effect(ctx, 'mounted');
|
|
3377
3602
|
},
|
|
3378
3603
|
onInput: function onInput(ctx, value) {
|
|
3604
|
+
if (ctx.prop.modelEmit) {
|
|
3605
|
+
this.$handle.onBaseInput(ctx, value);
|
|
3606
|
+
return;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3379
3609
|
this.$handle.onInput(ctx, value);
|
|
3380
3610
|
},
|
|
3611
|
+
onEmitInput: function onEmitInput(ctx) {
|
|
3612
|
+
this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
|
|
3613
|
+
},
|
|
3381
3614
|
renderChildren: function renderChildren(children, ctx) {
|
|
3382
|
-
var
|
|
3615
|
+
var _this7 = this;
|
|
3383
3616
|
|
|
3384
3617
|
if (!is.trueArray(children)) return {};
|
|
3385
3618
|
var slotBag = makeSlotBag();
|
|
@@ -3388,14 +3621,14 @@ function useRender$1(Render) {
|
|
|
3388
3621
|
if (is.String(child)) return slotBag.setSlot(null, child);
|
|
3389
3622
|
|
|
3390
3623
|
if (child.__fc__) {
|
|
3391
|
-
return
|
|
3624
|
+
return _this7.renderSlot(slotBag, child.__fc__, ctx);
|
|
3392
3625
|
}
|
|
3393
3626
|
|
|
3394
3627
|
if (child.type) {
|
|
3395
3628
|
nextTick(function () {
|
|
3396
|
-
|
|
3629
|
+
_this7.$handle.loadChildren(children, ctx);
|
|
3397
3630
|
|
|
3398
|
-
|
|
3631
|
+
_this7.$handle.refresh();
|
|
3399
3632
|
});
|
|
3400
3633
|
}
|
|
3401
3634
|
});
|
|
@@ -3409,7 +3642,7 @@ function useRender$1(Render) {
|
|
|
3409
3642
|
return this.vNode.make(lower(ctx.originType), prop, children);
|
|
3410
3643
|
},
|
|
3411
3644
|
renderRule: function renderRule(rule, children, origin) {
|
|
3412
|
-
var
|
|
3645
|
+
var _this8 = this;
|
|
3413
3646
|
|
|
3414
3647
|
if (!rule) return undefined;
|
|
3415
3648
|
if (is.String(rule)) return rule;
|
|
@@ -3433,7 +3666,7 @@ function useRender$1(Render) {
|
|
|
3433
3666
|
if (is.trueArray(rule.children)) {
|
|
3434
3667
|
rule.children.forEach(function (v) {
|
|
3435
3668
|
v && slotBag.setSlot(v === null || v === void 0 ? void 0 : v.slot, function () {
|
|
3436
|
-
return
|
|
3669
|
+
return _this8.renderRule(v);
|
|
3437
3670
|
});
|
|
3438
3671
|
});
|
|
3439
3672
|
}
|
|
@@ -3677,16 +3910,6 @@ function useRender(Handler) {
|
|
|
3677
3910
|
});
|
|
3678
3911
|
}
|
|
3679
3912
|
|
|
3680
|
-
function isNone(ctx) {
|
|
3681
|
-
var none = !(is.Undef(ctx.prop.display) || !!ctx.prop.display);
|
|
3682
|
-
|
|
3683
|
-
if (ctx.parent) {
|
|
3684
|
-
return ctx.parent.none || none;
|
|
3685
|
-
} else {
|
|
3686
|
-
return none;
|
|
3687
|
-
}
|
|
3688
|
-
}
|
|
3689
|
-
|
|
3690
3913
|
function bind(ctx) {
|
|
3691
3914
|
Object.defineProperties(ctx.origin, {
|
|
3692
3915
|
__fc__: enumerable(markRaw(ctx), true)
|
|
@@ -3709,7 +3932,9 @@ function RuleContext(handle, rule, defaultValue) {
|
|
|
3709
3932
|
linkOn: [],
|
|
3710
3933
|
root: [],
|
|
3711
3934
|
ctrlRule: [],
|
|
3935
|
+
children: [],
|
|
3712
3936
|
parent: null,
|
|
3937
|
+
group: rule.subRule ? this : null,
|
|
3713
3938
|
cacheConfig: null,
|
|
3714
3939
|
prop: _objectSpread2({}, rule),
|
|
3715
3940
|
computed: {},
|
|
@@ -3727,6 +3952,17 @@ function RuleContext(handle, rule, defaultValue) {
|
|
|
3727
3952
|
this.update(handle, true);
|
|
3728
3953
|
}
|
|
3729
3954
|
extend(RuleContext.prototype, {
|
|
3955
|
+
getParentGroup: function getParentGroup() {
|
|
3956
|
+
var ctx = this.parent;
|
|
3957
|
+
|
|
3958
|
+
while (ctx) {
|
|
3959
|
+
if (ctx.group) {
|
|
3960
|
+
return ctx;
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
ctx = ctx.parent;
|
|
3964
|
+
}
|
|
3965
|
+
},
|
|
3730
3966
|
loadChildrenPending: function loadChildrenPending() {
|
|
3731
3967
|
var _this = this;
|
|
3732
3968
|
|
|
@@ -3862,7 +4098,7 @@ extend(RuleContext.prototype, {
|
|
|
3862
4098
|
})), [this.computed]));
|
|
3863
4099
|
},
|
|
3864
4100
|
initNone: function initNone() {
|
|
3865
|
-
this.none =
|
|
4101
|
+
this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
|
|
3866
4102
|
},
|
|
3867
4103
|
check: function check(handle) {
|
|
3868
4104
|
return this.vm === handle.vm;
|
|
@@ -3892,6 +4128,11 @@ extend(RuleContext.prototype, {
|
|
|
3892
4128
|
this.unwatch();
|
|
3893
4129
|
this.unlink();
|
|
3894
4130
|
this.rmCtrl();
|
|
4131
|
+
|
|
4132
|
+
if (this.parent) {
|
|
4133
|
+
this.parent.children.splice(this.parent.children.indexOf(this) >>> 0, 1);
|
|
4134
|
+
}
|
|
4135
|
+
|
|
3895
4136
|
extend(this, {
|
|
3896
4137
|
deleted: true,
|
|
3897
4138
|
prop: _objectSpread2({}, this.rule),
|
|
@@ -3903,6 +4144,7 @@ extend(RuleContext.prototype, {
|
|
|
3903
4144
|
vm: undef,
|
|
3904
4145
|
vNode: undef,
|
|
3905
4146
|
parent: null,
|
|
4147
|
+
children: [],
|
|
3906
4148
|
cacheConfig: null,
|
|
3907
4149
|
none: false
|
|
3908
4150
|
});
|
|
@@ -4163,7 +4405,7 @@ function useLoader(Handler) {
|
|
|
4163
4405
|
}
|
|
4164
4406
|
};
|
|
4165
4407
|
|
|
4166
|
-
rules.map(function (_rule, index) {
|
|
4408
|
+
var ctxs = rules.map(function (_rule, index) {
|
|
4167
4409
|
if (parent && !is.Object(_rule)) return;
|
|
4168
4410
|
if (!_this6.pageEnd && !parent && index >= _this6.first) return;
|
|
4169
4411
|
|
|
@@ -4231,6 +4473,10 @@ function useLoader(Handler) {
|
|
|
4231
4473
|
}
|
|
4232
4474
|
|
|
4233
4475
|
_this6.appendValue(ctx.rule);
|
|
4476
|
+
|
|
4477
|
+
if (ctx.parent && ctx.parent !== parent) {
|
|
4478
|
+
_this6.rmSubRuleData(ctx);
|
|
4479
|
+
}
|
|
4234
4480
|
}
|
|
4235
4481
|
|
|
4236
4482
|
_this6.parseEmit(ctx);
|
|
@@ -4278,7 +4524,13 @@ function useLoader(Handler) {
|
|
|
4278
4524
|
|
|
4279
4525
|
if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
|
|
4280
4526
|
return ctx;
|
|
4527
|
+
}).filter(function (v) {
|
|
4528
|
+
return !!v;
|
|
4281
4529
|
});
|
|
4530
|
+
|
|
4531
|
+
if (parent) {
|
|
4532
|
+
parent.children = ctxs;
|
|
4533
|
+
}
|
|
4282
4534
|
},
|
|
4283
4535
|
refreshControl: function refreshControl(ctx) {
|
|
4284
4536
|
return ctx.input && ctx.rule.control && this.useCtrl(ctx);
|
|
@@ -4481,9 +4733,33 @@ function useInput(Handler) {
|
|
|
4481
4733
|
this.setValue(ctx, val, value);
|
|
4482
4734
|
}
|
|
4483
4735
|
},
|
|
4736
|
+
onBaseInput: function onBaseInput(ctx, value) {
|
|
4737
|
+
this.setFormData(ctx, value);
|
|
4738
|
+
ctx.modelValue = value;
|
|
4739
|
+
this.nextRefresh();
|
|
4740
|
+
this.$render.clearCache(ctx);
|
|
4741
|
+
},
|
|
4484
4742
|
setFormData: function setFormData(ctx, value) {
|
|
4743
|
+
ctx.modelValue = value;
|
|
4744
|
+
var group = ctx.getParentGroup();
|
|
4745
|
+
|
|
4746
|
+
if (group) {
|
|
4747
|
+
if (!this.subRuleData[group.id]) {
|
|
4748
|
+
this.subRuleData[group.id] = {};
|
|
4749
|
+
}
|
|
4750
|
+
|
|
4751
|
+
this.subRuleData[group.id][ctx.field] = ctx.rule.value;
|
|
4752
|
+
}
|
|
4753
|
+
|
|
4485
4754
|
$set(this.formData, ctx.id, value);
|
|
4486
4755
|
},
|
|
4756
|
+
rmSubRuleData: function rmSubRuleData(ctx) {
|
|
4757
|
+
var group = ctx.getParentGroup();
|
|
4758
|
+
|
|
4759
|
+
if (group && this.subRuleData[group.id]) {
|
|
4760
|
+
delete this.subRuleData[group.id][ctx.field];
|
|
4761
|
+
}
|
|
4762
|
+
},
|
|
4487
4763
|
getFormData: function getFormData(ctx) {
|
|
4488
4764
|
return this.formData[ctx.id];
|
|
4489
4765
|
},
|
|
@@ -4611,40 +4887,6 @@ var BaseParser = {
|
|
|
4611
4887
|
mergeProp: function mergeProp(ctx) {}
|
|
4612
4888
|
};
|
|
4613
4889
|
|
|
4614
|
-
var _ = {
|
|
4615
|
-
sum: function sum(arr) {
|
|
4616
|
-
if (Array.isArray(arr)) {
|
|
4617
|
-
var val = 0;
|
|
4618
|
-
arr.map(function (v) {
|
|
4619
|
-
return val += v || 0;
|
|
4620
|
-
});
|
|
4621
|
-
return val;
|
|
4622
|
-
}
|
|
4623
|
-
},
|
|
4624
|
-
column: function column(arr, field) {
|
|
4625
|
-
if (Array.isArray(arr)) {
|
|
4626
|
-
return arr.map(function (v) {
|
|
4627
|
-
return v[field];
|
|
4628
|
-
});
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
|
-
return [];
|
|
4632
|
-
},
|
|
4633
|
-
get: function get(obj, field, def) {
|
|
4634
|
-
var lst = field.split('.');
|
|
4635
|
-
var val = obj;
|
|
4636
|
-
|
|
4637
|
-
for (var i = 0; i < lst.length; i++) {
|
|
4638
|
-
if (hasProperty(val, lst[i])) {
|
|
4639
|
-
val = val[lst[i]];
|
|
4640
|
-
} else {
|
|
4641
|
-
return def === undefined ? 0 : def;
|
|
4642
|
-
}
|
|
4643
|
-
}
|
|
4644
|
-
|
|
4645
|
-
return val;
|
|
4646
|
-
}
|
|
4647
|
-
};
|
|
4648
4890
|
var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
|
|
4649
4891
|
function useContext(Handler) {
|
|
4650
4892
|
extend(Handler.prototype, {
|
|
@@ -4795,28 +5037,43 @@ function useContext(Handler) {
|
|
|
4795
5037
|
}
|
|
4796
5038
|
}));
|
|
4797
5039
|
this.bus.$once('load-end', function () {
|
|
4798
|
-
var
|
|
4799
|
-
ctx.watch.push(watch(function () {
|
|
4800
|
-
var computed = computedRef.value;
|
|
4801
|
-
if (!computed) return undefined;
|
|
4802
|
-
var fn;
|
|
4803
|
-
|
|
4804
|
-
if (is.Function(computed)) {
|
|
4805
|
-
fn = function fn() {
|
|
4806
|
-
return computed(_this.api.form, _this.api);
|
|
4807
|
-
};
|
|
4808
|
-
} else {
|
|
4809
|
-
fn = function fn() {
|
|
4810
|
-
return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
|
|
4811
|
-
};
|
|
4812
|
-
}
|
|
5040
|
+
var computed = ctx.rule.computed;
|
|
4813
5041
|
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
5042
|
+
if (!computed) {
|
|
5043
|
+
return;
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
if (_typeof(computed) !== 'object') {
|
|
5047
|
+
computed = {
|
|
5048
|
+
value: computed
|
|
5049
|
+
};
|
|
5050
|
+
}
|
|
5051
|
+
|
|
5052
|
+
Object.keys(computed).forEach(function (k) {
|
|
5053
|
+
ctx.watch.push(watch(function () {
|
|
5054
|
+
var item = computed[k];
|
|
5055
|
+
if (!item) return undefined;
|
|
5056
|
+
var fn;
|
|
5057
|
+
|
|
5058
|
+
if (is.Function(item)) {
|
|
5059
|
+
fn = function fn() {
|
|
5060
|
+
return item(_this.api.form, _this.api);
|
|
5061
|
+
};
|
|
5062
|
+
} else {
|
|
5063
|
+
var group = ctx.getParentGroup();
|
|
5064
|
+
|
|
5065
|
+
fn = function fn() {
|
|
5066
|
+
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] || {} : {});
|
|
5067
|
+
};
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
return invoke(fn, undefined);
|
|
5071
|
+
}, function (n) {
|
|
5072
|
+
deepSet(ctx.rule, k, n);
|
|
5073
|
+
}, {
|
|
5074
|
+
immediate: true
|
|
5075
|
+
}));
|
|
5076
|
+
});
|
|
4820
5077
|
});
|
|
4821
5078
|
}
|
|
4822
5079
|
|
|
@@ -4827,7 +5084,7 @@ function useContext(Handler) {
|
|
|
4827
5084
|
|
|
4828
5085
|
this.deferSyncValue(function () {
|
|
4829
5086
|
o && o.forEach(function (child) {
|
|
4830
|
-
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root
|
|
5087
|
+
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root !== n) {
|
|
4831
5088
|
_this2.rmCtx(child.__fc__);
|
|
4832
5089
|
}
|
|
4833
5090
|
});
|
|
@@ -4858,6 +5115,16 @@ function useContext(Handler) {
|
|
|
4858
5115
|
$del(this.formData, id);
|
|
4859
5116
|
$del(this.subForm, id);
|
|
4860
5117
|
$del(this.vm.setupState.ctxInject, id);
|
|
5118
|
+
var group = ctx.getParentGroup();
|
|
5119
|
+
|
|
5120
|
+
if (group && this.subRuleData[group.id]) {
|
|
5121
|
+
$del(this.subRuleData[group.id], field);
|
|
5122
|
+
}
|
|
5123
|
+
|
|
5124
|
+
if (ctx.group) {
|
|
5125
|
+
$del(this.subRuleData, id);
|
|
5126
|
+
}
|
|
5127
|
+
|
|
4861
5128
|
input && this.rmIdCtx(ctx, field, 'field');
|
|
4862
5129
|
name && this.rmIdCtx(ctx, name, 'name');
|
|
4863
5130
|
|
|
@@ -5113,6 +5380,7 @@ function Handler(fc) {
|
|
|
5113
5380
|
deferSyncFn: null,
|
|
5114
5381
|
isMounted: false,
|
|
5115
5382
|
formData: reactive({}),
|
|
5383
|
+
subRuleData: reactive({}),
|
|
5116
5384
|
subForm: {},
|
|
5117
5385
|
form: reactive({}),
|
|
5118
5386
|
appendData: {},
|
|
@@ -5162,77 +5430,6 @@ useContext(Handler);
|
|
|
5162
5430
|
useLifecycle(Handler);
|
|
5163
5431
|
useEffect(Handler);
|
|
5164
5432
|
|
|
5165
|
-
// https://github.com/ElemeFE/element/blob/dev/packages/upload/src/ajax.js
|
|
5166
|
-
function getError(action, option, xhr) {
|
|
5167
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
5168
|
-
var err = new Error(msg);
|
|
5169
|
-
err.status = xhr.status;
|
|
5170
|
-
err.url = action;
|
|
5171
|
-
return err;
|
|
5172
|
-
}
|
|
5173
|
-
|
|
5174
|
-
function getBody(xhr) {
|
|
5175
|
-
var text = xhr.responseText || xhr.response;
|
|
5176
|
-
|
|
5177
|
-
if (!text) {
|
|
5178
|
-
return text;
|
|
5179
|
-
}
|
|
5180
|
-
|
|
5181
|
-
try {
|
|
5182
|
-
return JSON.parse(text);
|
|
5183
|
-
} catch (e) {
|
|
5184
|
-
return text;
|
|
5185
|
-
}
|
|
5186
|
-
}
|
|
5187
|
-
|
|
5188
|
-
function fetch$1(option) {
|
|
5189
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
5190
|
-
return;
|
|
5191
|
-
}
|
|
5192
|
-
|
|
5193
|
-
var xhr = new XMLHttpRequest();
|
|
5194
|
-
var action = option.action;
|
|
5195
|
-
|
|
5196
|
-
xhr.onerror = function error(e) {
|
|
5197
|
-
option.onError(e);
|
|
5198
|
-
};
|
|
5199
|
-
|
|
5200
|
-
xhr.onload = function onload() {
|
|
5201
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
5202
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
5203
|
-
}
|
|
5204
|
-
|
|
5205
|
-
option.onSuccess(getBody(xhr));
|
|
5206
|
-
};
|
|
5207
|
-
|
|
5208
|
-
xhr.open(option.method || 'get', action, true);
|
|
5209
|
-
var formData;
|
|
5210
|
-
|
|
5211
|
-
if (option.data) {
|
|
5212
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
5213
|
-
formData = new FormData();
|
|
5214
|
-
Object.keys(option.data).map(function (key) {
|
|
5215
|
-
formData.append(key, option.data[key]);
|
|
5216
|
-
});
|
|
5217
|
-
} else {
|
|
5218
|
-
formData = JSON.stringify(option.data);
|
|
5219
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
5220
|
-
}
|
|
5221
|
-
}
|
|
5222
|
-
|
|
5223
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
5224
|
-
xhr.withCredentials = true;
|
|
5225
|
-
}
|
|
5226
|
-
|
|
5227
|
-
var headers = option.headers || {};
|
|
5228
|
-
Object.keys(headers).forEach(function (item) {
|
|
5229
|
-
if (headers[item] !== null) {
|
|
5230
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
5231
|
-
}
|
|
5232
|
-
});
|
|
5233
|
-
xhr.send(formData);
|
|
5234
|
-
}
|
|
5235
|
-
|
|
5236
5433
|
var NAME = 'fcFragment';
|
|
5237
5434
|
var fragment = defineComponent({
|
|
5238
5435
|
name: NAME,
|
|
@@ -5515,22 +5712,23 @@ var fetch = function fetch(fc) {
|
|
|
5515
5712
|
function run(inject, rule, api) {
|
|
5516
5713
|
var option = inject.value;
|
|
5517
5714
|
|
|
5715
|
+
if (is.Function(option)) {
|
|
5716
|
+
option = option(rule, api);
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
option = parseOpt(option);
|
|
5720
|
+
|
|
5518
5721
|
var set = function set(val) {
|
|
5519
5722
|
if (val === undefined) {
|
|
5520
5723
|
inject.clearProp();
|
|
5521
|
-
api.sync(rule);
|
|
5522
5724
|
} else {
|
|
5523
5725
|
deepSet(inject.getProp(), option.to || 'options', val);
|
|
5524
5726
|
}
|
|
5525
|
-
};
|
|
5526
|
-
|
|
5527
|
-
if (is.Function(option)) {
|
|
5528
|
-
option = option(rule, api);
|
|
5529
|
-
}
|
|
5530
5727
|
|
|
5531
|
-
|
|
5728
|
+
api.sync(rule);
|
|
5729
|
+
};
|
|
5532
5730
|
|
|
5533
|
-
if (!option || !option.action) {
|
|
5731
|
+
if (!option || !option.action && !option.key) {
|
|
5534
5732
|
set(undefined);
|
|
5535
5733
|
return;
|
|
5536
5734
|
}
|
|
@@ -5539,6 +5737,22 @@ var fetch = function fetch(fc) {
|
|
|
5539
5737
|
option.to = 'options';
|
|
5540
5738
|
}
|
|
5541
5739
|
|
|
5740
|
+
if (option.key) {
|
|
5741
|
+
var item = fc.$handle.options.globalData[option.key];
|
|
5742
|
+
|
|
5743
|
+
if (!item) {
|
|
5744
|
+
set(undefined);
|
|
5745
|
+
return;
|
|
5746
|
+
}
|
|
5747
|
+
|
|
5748
|
+
if (item.type === 'static') {
|
|
5749
|
+
set(item.data);
|
|
5750
|
+
return;
|
|
5751
|
+
} else {
|
|
5752
|
+
option = _objectSpread2(_objectSpread2({}, option), item);
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
|
|
5542
5756
|
var _onError = option.onError;
|
|
5543
5757
|
|
|
5544
5758
|
var check = function check() {
|
|
@@ -5559,11 +5773,13 @@ var fetch = function fetch(fc) {
|
|
|
5559
5773
|
return flag ? v : v.data;
|
|
5560
5774
|
};
|
|
5561
5775
|
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5776
|
+
var parse = parseFn(option.parse);
|
|
5777
|
+
|
|
5778
|
+
if (is.Function(parse)) {
|
|
5779
|
+
fn = parse;
|
|
5780
|
+
} else if (parse && is.String(parse)) {
|
|
5565
5781
|
fn = function fn(v) {
|
|
5566
|
-
|
|
5782
|
+
parse.split('.').forEach(function (k) {
|
|
5567
5783
|
if (v) {
|
|
5568
5784
|
v = v[k];
|
|
5569
5785
|
}
|
|
@@ -5695,6 +5911,7 @@ function FormCreateFactory(config) {
|
|
|
5695
5911
|
};
|
|
5696
5912
|
var loadData = {};
|
|
5697
5913
|
var CreateNode = CreateNodeFactory();
|
|
5914
|
+
var formulas = {};
|
|
5698
5915
|
exportAttrs(config.attrs || {});
|
|
5699
5916
|
|
|
5700
5917
|
function getApi(name) {
|
|
@@ -5731,11 +5948,11 @@ function FormCreateFactory(config) {
|
|
|
5731
5948
|
|
|
5732
5949
|
function parser() {
|
|
5733
5950
|
var data = nameProp.apply(void 0, arguments);
|
|
5734
|
-
if (!data.id || !data.prop) return;
|
|
5951
|
+
if (!data.id || !data.prop) return BaseParser;
|
|
5735
5952
|
var name = toCase(data.id);
|
|
5736
5953
|
var parser = data.prop;
|
|
5737
5954
|
var base = parser.merge === true ? parsers[name] : undefined;
|
|
5738
|
-
parsers[name] =
|
|
5955
|
+
parsers[name] = setPrototypeOf(parser, base || BaseParser);
|
|
5739
5956
|
maker[name] = creatorFactory(name);
|
|
5740
5957
|
parser.maker && extend(maker, parser.maker);
|
|
5741
5958
|
}
|
|
@@ -5755,8 +5972,13 @@ function FormCreateFactory(config) {
|
|
|
5755
5972
|
}
|
|
5756
5973
|
|
|
5757
5974
|
if (!name || !component) return;
|
|
5975
|
+
var nameAlias = toCase(name);
|
|
5758
5976
|
components[name] = component;
|
|
5759
|
-
components[
|
|
5977
|
+
components[nameAlias] = component;
|
|
5978
|
+
delete CreateNode.aliasMap[name];
|
|
5979
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5980
|
+
delete parsers[name];
|
|
5981
|
+
delete parsers[nameAlias];
|
|
5760
5982
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5761
5983
|
}
|
|
5762
5984
|
|
|
@@ -5816,6 +6038,7 @@ function FormCreateFactory(config) {
|
|
|
5816
6038
|
providers: providers,
|
|
5817
6039
|
useApps: useApps,
|
|
5818
6040
|
maker: maker,
|
|
6041
|
+
formulas: formulas,
|
|
5819
6042
|
loadData: loadData
|
|
5820
6043
|
};
|
|
5821
6044
|
} else {
|
|
@@ -5829,6 +6052,10 @@ function FormCreateFactory(config) {
|
|
|
5829
6052
|
modelFields[name] = field;
|
|
5830
6053
|
}
|
|
5831
6054
|
|
|
6055
|
+
function setFormula(name, fn) {
|
|
6056
|
+
formulas[name] = fn;
|
|
6057
|
+
}
|
|
6058
|
+
|
|
5832
6059
|
function _emitData(id) {
|
|
5833
6060
|
Object.keys(instance).forEach(function (v) {
|
|
5834
6061
|
var apis = Array.isArray(instance[v]) ? instance[v] : [instance[v]];
|
|
@@ -5861,6 +6088,7 @@ function FormCreateFactory(config) {
|
|
|
5861
6088
|
parsers: parsers,
|
|
5862
6089
|
providers: providers,
|
|
5863
6090
|
modelFields: modelFields,
|
|
6091
|
+
formulas: formulas,
|
|
5864
6092
|
rules: vm.props.rule,
|
|
5865
6093
|
name: vm.props.name || uniqueId(),
|
|
5866
6094
|
inFor: vm.props.inFor,
|
|
@@ -5872,7 +6100,7 @@ function FormCreateFactory(config) {
|
|
|
5872
6100
|
CreateNode: CreateNode,
|
|
5873
6101
|
bus: new Mitt(),
|
|
5874
6102
|
unwatch: null,
|
|
5875
|
-
options: ref(
|
|
6103
|
+
options: ref({}),
|
|
5876
6104
|
extendApi: config.extendApi || function (api) {
|
|
5877
6105
|
return api;
|
|
5878
6106
|
}
|
|
@@ -5906,9 +6134,9 @@ function FormCreateFactory(config) {
|
|
|
5906
6134
|
|
|
5907
6135
|
if (this.isSub()) {
|
|
5908
6136
|
this.unwatch = watch(function () {
|
|
5909
|
-
return _this2.vm.parent.
|
|
6137
|
+
return _this2.vm.setupState.parent.setupState.fc.options.value;
|
|
5910
6138
|
}, function () {
|
|
5911
|
-
_this2.initOptions(
|
|
6139
|
+
_this2.initOptions();
|
|
5912
6140
|
|
|
5913
6141
|
_this2.$handle.api.refresh();
|
|
5914
6142
|
}, {
|
|
@@ -5916,23 +6144,28 @@ function FormCreateFactory(config) {
|
|
|
5916
6144
|
});
|
|
5917
6145
|
}
|
|
5918
6146
|
|
|
5919
|
-
this.initOptions(
|
|
6147
|
+
this.initOptions();
|
|
5920
6148
|
this.$handle.init();
|
|
5921
6149
|
},
|
|
5922
6150
|
isSub: function isSub() {
|
|
5923
6151
|
return this.vm.setupState.parent && this.vm.props.extendOption;
|
|
5924
6152
|
},
|
|
5925
|
-
initOptions: function initOptions(
|
|
5926
|
-
this.options.value =
|
|
6153
|
+
initOptions: function initOptions() {
|
|
6154
|
+
this.options.value = {};
|
|
6155
|
+
|
|
6156
|
+
var options = _objectSpread2({
|
|
5927
6157
|
formData: {},
|
|
5928
6158
|
submitBtn: {},
|
|
5929
|
-
resetBtn: {}
|
|
6159
|
+
resetBtn: {},
|
|
6160
|
+
globalEvent: {},
|
|
6161
|
+
globalData: {}
|
|
5930
6162
|
}, deepCopy(globalConfig));
|
|
5931
6163
|
|
|
5932
6164
|
if (this.isSub()) {
|
|
5933
|
-
|
|
6165
|
+
options = this.mergeOptions(options, this.vm.setupState.parent.setupState.fc.options.value || {}, true);
|
|
5934
6166
|
}
|
|
5935
6167
|
|
|
6168
|
+
options = this.mergeOptions(options, this.vm.props.option);
|
|
5936
6169
|
this.updateOptions(options);
|
|
5937
6170
|
},
|
|
5938
6171
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
@@ -5994,6 +6227,7 @@ function FormCreateFactory(config) {
|
|
|
5994
6227
|
component: component,
|
|
5995
6228
|
directive: directive,
|
|
5996
6229
|
setModelField: setModelField,
|
|
6230
|
+
setFormula: setFormula,
|
|
5997
6231
|
register: register,
|
|
5998
6232
|
$vnode: $vnode,
|
|
5999
6233
|
parser: parser,
|
|
@@ -6060,6 +6294,7 @@ function FormCreateFactory(config) {
|
|
|
6060
6294
|
inherit.useApps && extend(useApps, inherit.useApps);
|
|
6061
6295
|
inherit.maker && extend(maker, inherit.maker);
|
|
6062
6296
|
inherit.loadData && extend(loadData, inherit.loadData);
|
|
6297
|
+
inherit.formulas && extend(formulas, inherit.formulas);
|
|
6063
6298
|
}
|
|
6064
6299
|
|
|
6065
6300
|
return create;
|
|
@@ -6339,7 +6574,7 @@ var manager = {
|
|
|
6339
6574
|
}
|
|
6340
6575
|
},
|
|
6341
6576
|
tidyOptions: function tidyOptions(options) {
|
|
6342
|
-
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col'].forEach(function (name) {
|
|
6577
|
+
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col', 'title'].forEach(function (name) {
|
|
6343
6578
|
tidyBool(options, name);
|
|
6344
6579
|
});
|
|
6345
6580
|
return options;
|
|
@@ -6354,7 +6589,8 @@ var manager = {
|
|
|
6354
6589
|
ctx.prop = mergeProps([{
|
|
6355
6590
|
info: this.options.info || {},
|
|
6356
6591
|
wrap: this.options.wrap || {},
|
|
6357
|
-
col: this.options.col || {}
|
|
6592
|
+
col: this.options.col || {},
|
|
6593
|
+
title: this.options.title || {}
|
|
6358
6594
|
}, ctx.prop], {
|
|
6359
6595
|
info: {
|
|
6360
6596
|
trigger: 'hover',
|
|
@@ -6382,7 +6618,7 @@ var manager = {
|
|
|
6382
6618
|
e.preventDefault();
|
|
6383
6619
|
}
|
|
6384
6620
|
},
|
|
6385
|
-
"class": [form.className, form["class"], 'form-create'],
|
|
6621
|
+
"class": [form.className, form["class"], 'form-create', this.options.preview ? 'is-preview' : ''],
|
|
6386
6622
|
style: form.style,
|
|
6387
6623
|
type: 'form'
|
|
6388
6624
|
};
|
|
@@ -6402,7 +6638,7 @@ var manager = {
|
|
|
6402
6638
|
render: function render(children) {
|
|
6403
6639
|
var _this2 = this;
|
|
6404
6640
|
|
|
6405
|
-
if (children.slotLen()) {
|
|
6641
|
+
if (children.slotLen() && !this.options.preview) {
|
|
6406
6642
|
children.setSlot(undefined, function () {
|
|
6407
6643
|
return _this2.makeFormBtn();
|
|
6408
6644
|
});
|
|
@@ -6689,7 +6925,7 @@ function useFrame(maker) {
|
|
|
6689
6925
|
return maker;
|
|
6690
6926
|
}
|
|
6691
6927
|
|
|
6692
|
-
var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}";
|
|
6928
|
+
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}";
|
|
6693
6929
|
styleInject(css_248z);
|
|
6694
6930
|
|
|
6695
6931
|
function tidyBtnProp(btn, def) {
|
|
@@ -6942,7 +7178,7 @@ function install(FormCreate) {
|
|
|
6942
7178
|
function elmFormCreate() {
|
|
6943
7179
|
return FormCreateFactory({
|
|
6944
7180
|
ui: 'element-ui',
|
|
6945
|
-
version: '3.1.
|
|
7181
|
+
version: '3.1.29',
|
|
6946
7182
|
manager: manager,
|
|
6947
7183
|
extendApi: extendApi,
|
|
6948
7184
|
install: install,
|