@form-create/element-ui 3.1.28 → 3.1.30
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 +748 -376
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +747 -375
- package/dist/form-create.min.js +2 -2
- package/package.json +12 -12
- package/src/core/manager.js +7 -6
- package/src/core/provider.js +1 -0
- package/src/style/index.css +9 -1
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.30
|
|
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,15 @@
|
|
|
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
|
-
"
|
|
263
|
-
"key": name + index + '-' +
|
|
264
|
+
"value": value,
|
|
265
|
+
"key": name + index + '-' + value
|
|
264
266
|
}), {
|
|
265
267
|
"default": function _default() {
|
|
266
|
-
return [
|
|
268
|
+
return [label || value || ''];
|
|
267
269
|
}
|
|
268
270
|
});
|
|
269
271
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -1001,13 +1003,15 @@
|
|
|
1001
1003
|
var props = _objectSpread2({}, opt);
|
|
1002
1004
|
|
|
1003
1005
|
var value = props.value;
|
|
1006
|
+
var label = props.label;
|
|
1004
1007
|
delete props.value;
|
|
1008
|
+
delete props.label;
|
|
1005
1009
|
return vue.createVNode(Type, vue.mergeProps(props, {
|
|
1006
|
-
"
|
|
1007
|
-
"key": name + index + '-' +
|
|
1010
|
+
"value": value,
|
|
1011
|
+
"key": name + index + '-' + value
|
|
1008
1012
|
}), {
|
|
1009
1013
|
"default": function _default() {
|
|
1010
|
-
return [
|
|
1014
|
+
return [label || value || ''];
|
|
1011
1015
|
}
|
|
1012
1016
|
});
|
|
1013
1017
|
}), (_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)];
|
|
@@ -1419,6 +1423,10 @@
|
|
|
1419
1423
|
function extend() {
|
|
1420
1424
|
return _extends.apply(this, arguments);
|
|
1421
1425
|
}
|
|
1426
|
+
function copy$1(obj) {
|
|
1427
|
+
if (_typeof(obj) !== 'object' || obj === null) return obj;
|
|
1428
|
+
return obj instanceof Array ? _toConsumableArray(obj) : _objectSpread2({}, obj);
|
|
1429
|
+
}
|
|
1422
1430
|
|
|
1423
1431
|
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
1432
|
styleInject(css_248z$1);
|
|
@@ -1802,7 +1810,7 @@
|
|
|
1802
1810
|
add: this.add
|
|
1803
1811
|
}) : vue.createVNode("div", {
|
|
1804
1812
|
"key": 'a_def',
|
|
1805
|
-
"class": "_fc-group-plus-minus _fc-group-add",
|
|
1813
|
+
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
|
|
1806
1814
|
"onClick": this.add
|
|
1807
1815
|
}, null) : keys.map(function (key, index) {
|
|
1808
1816
|
var _this12$cacheRule$key = _this12.cacheRule[key],
|
|
@@ -1836,7 +1844,7 @@
|
|
|
1836
1844
|
}), null), vue.createVNode("div", {
|
|
1837
1845
|
"class": "_fc-group-idx"
|
|
1838
1846
|
}, [index + 1]), btn.length ? vue.createVNode("div", {
|
|
1839
|
-
"class": "_fc-group-handle"
|
|
1847
|
+
"class": "_fc-group-handle fc-clock"
|
|
1840
1848
|
}, [btn]) : null]);
|
|
1841
1849
|
});
|
|
1842
1850
|
return vue.createVNode("div", {
|
|
@@ -1957,6 +1965,142 @@
|
|
|
1957
1965
|
|
|
1958
1966
|
var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub, script];
|
|
1959
1967
|
|
|
1968
|
+
function toString(val) {
|
|
1969
|
+
return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
function toLine(name) {
|
|
1973
|
+
var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
|
|
1974
|
+
if (line.indexOf('-') === 0) line = line.substr(1);
|
|
1975
|
+
return line;
|
|
1976
|
+
}
|
|
1977
|
+
function upper(str) {
|
|
1978
|
+
return str.replace(str[0], str[0].toLocaleUpperCase());
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function format(type, msg, rule) {
|
|
1982
|
+
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
1983
|
+
}
|
|
1984
|
+
function err(msg, rule) {
|
|
1985
|
+
console.error(format('err', msg, rule));
|
|
1986
|
+
}
|
|
1987
|
+
function logError(e) {
|
|
1988
|
+
err(e.toString());
|
|
1989
|
+
console.error(e);
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
1993
|
+
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
1994
|
+
var $T = '$FN:';
|
|
1995
|
+
var $TX = '$FNX:';
|
|
1996
|
+
var $ON = '$GLOBAL:';
|
|
1997
|
+
var FUNCTION = 'function';
|
|
1998
|
+
function toJson(obj, space) {
|
|
1999
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2000
|
+
if (val && val._isVue === true) return undefined;
|
|
2001
|
+
|
|
2002
|
+
if (_typeof(val) !== FUNCTION) {
|
|
2003
|
+
return val;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
if (val.__json) {
|
|
2007
|
+
return val.__json;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
if (val.__origin) val = val.__origin;
|
|
2011
|
+
if (val.__emit) return undefined;
|
|
2012
|
+
return PREFIX + val + SUFFIX;
|
|
2013
|
+
}, space);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
function makeFn(fn) {
|
|
2017
|
+
return new Function('return ' + fn)();
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
function parseFn(fn, mode) {
|
|
2021
|
+
if (fn && is.String(fn) && fn.length > 4) {
|
|
2022
|
+
var v = fn.trim();
|
|
2023
|
+
var flag = false;
|
|
2024
|
+
|
|
2025
|
+
try {
|
|
2026
|
+
if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
|
|
2027
|
+
v = v.replace(SUFFIX, '').replace(PREFIX, '');
|
|
2028
|
+
flag = true;
|
|
2029
|
+
} else if (v.indexOf($T) === 0) {
|
|
2030
|
+
v = v.replace($T, '');
|
|
2031
|
+
flag = true;
|
|
2032
|
+
} else if (v.indexOf($ON) === 0) {
|
|
2033
|
+
var name = v.replace($ON, '');
|
|
2034
|
+
|
|
2035
|
+
v = function v() {
|
|
2036
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2037
|
+
args[_key] = arguments[_key];
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
var callback = args[0].api.getGlobalEvent(name);
|
|
2041
|
+
|
|
2042
|
+
if (callback) {
|
|
2043
|
+
return callback.call.apply(callback, [this].concat(args));
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
return undefined;
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
v.__json = fn;
|
|
2050
|
+
v.__inject = true;
|
|
2051
|
+
return v;
|
|
2052
|
+
} else if (v.indexOf($TX) === 0) {
|
|
2053
|
+
v = makeFn('function($inject){' + v.replace($TX, '') + '}');
|
|
2054
|
+
v.__json = fn;
|
|
2055
|
+
v.__inject = true;
|
|
2056
|
+
return v;
|
|
2057
|
+
} else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
|
|
2058
|
+
flag = true;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
if (!flag) return fn;
|
|
2062
|
+
var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
|
|
2063
|
+
val.__json = fn;
|
|
2064
|
+
return val;
|
|
2065
|
+
} catch (e) {
|
|
2066
|
+
err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
|
|
2067
|
+
return undefined;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
return fn;
|
|
2072
|
+
}
|
|
2073
|
+
function parseJson(json, mode) {
|
|
2074
|
+
return JSON.parse(json, function (k, v) {
|
|
2075
|
+
if (is.Undef(v) || !v.indexOf) return v;
|
|
2076
|
+
return parseFn(v, mode);
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
var id$2 = 0;
|
|
2081
|
+
function uniqueId() {
|
|
2082
|
+
var num = 370 + ++id$2;
|
|
2083
|
+
return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
function deepSet(data, idx, val) {
|
|
2087
|
+
var _data = data,
|
|
2088
|
+
to;
|
|
2089
|
+
(idx || '').split('.').forEach(function (v) {
|
|
2090
|
+
if (to) {
|
|
2091
|
+
if (!_data[to] || _typeof(_data[to]) != 'object') {
|
|
2092
|
+
_data[to] = {};
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
_data = _data[to];
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
to = v;
|
|
2099
|
+
});
|
|
2100
|
+
_data[to] = val;
|
|
2101
|
+
return _data;
|
|
2102
|
+
}
|
|
2103
|
+
|
|
1960
2104
|
var NAME$1 = 'FormCreate';
|
|
1961
2105
|
|
|
1962
2106
|
var getRuleInject = function getRuleInject(vm, parent) {
|
|
@@ -1994,6 +2138,10 @@
|
|
|
1994
2138
|
},
|
|
1995
2139
|
extendOption: Boolean,
|
|
1996
2140
|
modelValue: Object,
|
|
2141
|
+
disabled: {
|
|
2142
|
+
type: Boolean,
|
|
2143
|
+
"default": undefined
|
|
2144
|
+
},
|
|
1997
2145
|
api: Object,
|
|
1998
2146
|
name: String,
|
|
1999
2147
|
subForm: {
|
|
@@ -2002,7 +2150,7 @@
|
|
|
2002
2150
|
},
|
|
2003
2151
|
inFor: Boolean
|
|
2004
2152
|
},
|
|
2005
|
-
emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail'],
|
|
2153
|
+
emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update', 'validate-field-fail', 'validate-fail', 'created'],
|
|
2006
2154
|
render: function render() {
|
|
2007
2155
|
return this.fc.render();
|
|
2008
2156
|
},
|
|
@@ -2023,7 +2171,7 @@
|
|
|
2023
2171
|
isShow: true,
|
|
2024
2172
|
unique: 1,
|
|
2025
2173
|
renderRule: _toConsumableArray(rule.value || []),
|
|
2026
|
-
updateValue: JSON.stringify(modelValue || {})
|
|
2174
|
+
updateValue: JSON.stringify(modelValue.value || {})
|
|
2027
2175
|
});
|
|
2028
2176
|
var fc = new FormCreate(vm);
|
|
2029
2177
|
var fapi = fc.api();
|
|
@@ -2065,10 +2213,37 @@
|
|
|
2065
2213
|
}
|
|
2066
2214
|
};
|
|
2067
2215
|
|
|
2216
|
+
var styleEl = null;
|
|
2217
|
+
vue.onBeforeMount(function () {
|
|
2218
|
+
var content = '';
|
|
2219
|
+
var globalClass = props.option && props.option.globalClass || {};
|
|
2220
|
+
Object.keys(globalClass).forEach(function (k) {
|
|
2221
|
+
var subCss = '';
|
|
2222
|
+
globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
|
|
2223
|
+
subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
|
|
2224
|
+
});
|
|
2225
|
+
|
|
2226
|
+
if (globalClass[k].content) {
|
|
2227
|
+
subCss += globalClass[k].content + ';';
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
if (subCss) {
|
|
2231
|
+
content += ".".concat(k, "{").concat(subCss, "}");
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
|
|
2235
|
+
if (content) {
|
|
2236
|
+
styleEl = document.createElement('style');
|
|
2237
|
+
styleEl.type = 'text/css';
|
|
2238
|
+
styleEl.innerHTML = content;
|
|
2239
|
+
document.head.appendChild(styleEl);
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2068
2242
|
vue.onMounted(function () {
|
|
2069
2243
|
fc.mounted();
|
|
2070
2244
|
});
|
|
2071
2245
|
vue.onBeforeUnmount(function () {
|
|
2246
|
+
styleEl && document.head.removeChild(styleEl);
|
|
2072
2247
|
rmSubForm();
|
|
2073
2248
|
data.destroyed = true;
|
|
2074
2249
|
fc.unmount();
|
|
@@ -2092,12 +2267,17 @@
|
|
|
2092
2267
|
});
|
|
2093
2268
|
vue.watch(function () {
|
|
2094
2269
|
return props.option;
|
|
2095
|
-
}, function (
|
|
2096
|
-
fc.initOptions(
|
|
2270
|
+
}, function () {
|
|
2271
|
+
fc.initOptions();
|
|
2097
2272
|
fapi.refresh();
|
|
2098
2273
|
}, {
|
|
2099
2274
|
deep: true
|
|
2100
2275
|
});
|
|
2276
|
+
vue.watch(function () {
|
|
2277
|
+
return props.disabled;
|
|
2278
|
+
}, function () {
|
|
2279
|
+
fapi.refresh();
|
|
2280
|
+
});
|
|
2101
2281
|
vue.watch(modelValue, function (n) {
|
|
2102
2282
|
if (JSON.stringify(n || {}) === data.updateValue) return;
|
|
2103
2283
|
fapi.config.forceCoverValue ? fapi.coverValue(n || {}) : fapi.setValue(n || {});
|
|
@@ -2117,15 +2297,21 @@
|
|
|
2117
2297
|
},
|
|
2118
2298
|
updateValue: function updateValue(value) {
|
|
2119
2299
|
if (data.destroyed) return;
|
|
2120
|
-
|
|
2300
|
+
var json = JSON.stringify(value);
|
|
2301
|
+
|
|
2302
|
+
if (data.updateValue === json) {
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
data.updateValue = json;
|
|
2121
2307
|
vm.emit('update:modelValue', value);
|
|
2122
2308
|
}
|
|
2123
2309
|
});
|
|
2124
2310
|
},
|
|
2125
2311
|
created: function created() {
|
|
2126
2312
|
var vm = vue.getCurrentInstance();
|
|
2127
|
-
vm.setupState.fc.init();
|
|
2128
2313
|
vm.emit('update:api', vm.setupState.fapi);
|
|
2314
|
+
vm.setupState.fc.init();
|
|
2129
2315
|
}
|
|
2130
2316
|
});
|
|
2131
2317
|
}
|
|
@@ -2199,100 +2385,13 @@
|
|
|
2199
2385
|
};
|
|
2200
2386
|
};
|
|
2201
2387
|
|
|
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'];
|
|
2388
|
+
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
2389
|
var arrayAttrs = ['validate', 'children', 'control'];
|
|
2204
2390
|
var normalAttrs = ['effect'];
|
|
2205
2391
|
function attrs() {
|
|
2206
2392
|
return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
|
|
2207
2393
|
}
|
|
2208
2394
|
|
|
2209
|
-
function format(type, msg, rule) {
|
|
2210
|
-
return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
|
|
2211
|
-
}
|
|
2212
|
-
function err(msg, rule) {
|
|
2213
|
-
console.error(format('err', msg, rule));
|
|
2214
|
-
}
|
|
2215
|
-
function logError(e) {
|
|
2216
|
-
err(e.toString());
|
|
2217
|
-
console.error(e);
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
function toLine(name) {
|
|
2221
|
-
var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
|
|
2222
|
-
if (line.indexOf('-') === 0) line = line.substr(1);
|
|
2223
|
-
return line;
|
|
2224
|
-
}
|
|
2225
|
-
function upper(str) {
|
|
2226
|
-
return str.replace(str[0], str[0].toLocaleUpperCase());
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
|
-
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
2230
|
-
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2231
|
-
var $T = '$FN:';
|
|
2232
|
-
var $TX = '$FNX:';
|
|
2233
|
-
var FUNCTION = 'function';
|
|
2234
|
-
function toJson(obj, space) {
|
|
2235
|
-
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
2236
|
-
if (val && val._isVue === true) return undefined;
|
|
2237
|
-
|
|
2238
|
-
if (_typeof(val) !== FUNCTION) {
|
|
2239
|
-
return val;
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
if (val.__json) {
|
|
2243
|
-
return val.__json;
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
if (val.__origin) val = val.__origin;
|
|
2247
|
-
if (val.__emit) return undefined;
|
|
2248
|
-
return PREFIX + val + SUFFIX;
|
|
2249
|
-
}, space);
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
function makeFn(fn) {
|
|
2253
|
-
return new Function('return ' + fn)();
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
function parseFn(fn, mode) {
|
|
2257
|
-
if (fn && is.String(fn) && fn.length > 4) {
|
|
2258
|
-
var v = fn.trim();
|
|
2259
|
-
var flag = false;
|
|
2260
|
-
|
|
2261
|
-
try {
|
|
2262
|
-
if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
|
|
2263
|
-
v = v.replace(SUFFIX, '').replace(PREFIX, '');
|
|
2264
|
-
flag = true;
|
|
2265
|
-
} else if (v.indexOf($T) === 0) {
|
|
2266
|
-
v = v.replace($T, '');
|
|
2267
|
-
flag = true;
|
|
2268
|
-
} else if (v.indexOf($TX) === 0) {
|
|
2269
|
-
v = makeFn('function($inject){' + v.replace($TX, '') + '}');
|
|
2270
|
-
v.__json = fn;
|
|
2271
|
-
v.__inject = true;
|
|
2272
|
-
return v;
|
|
2273
|
-
} else if (!mode && v.indexOf(FUNCTION) === 0 && v !== FUNCTION) {
|
|
2274
|
-
flag = true;
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
if (!flag) return fn;
|
|
2278
|
-
var val = makeFn(v.indexOf(FUNCTION) === -1 && v.indexOf('(') !== 0 ? FUNCTION + ' ' + v : v);
|
|
2279
|
-
val.__json = fn;
|
|
2280
|
-
return val;
|
|
2281
|
-
} catch (e) {
|
|
2282
|
-
err("\u89E3\u6790\u5931\u8D25:".concat(v, "\n\nerr: ").concat(e));
|
|
2283
|
-
return undefined;
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
return fn;
|
|
2288
|
-
}
|
|
2289
|
-
function parseJson(json, mode) {
|
|
2290
|
-
return JSON.parse(json, function (k, v) {
|
|
2291
|
-
if (is.Undef(v) || !v.indexOf) return v;
|
|
2292
|
-
return parseFn(v, mode);
|
|
2293
|
-
});
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
2395
|
function enumerable(value, writable) {
|
|
2297
2396
|
return {
|
|
2298
2397
|
value: value,
|
|
@@ -2449,6 +2548,10 @@
|
|
|
2449
2548
|
if (prop.slot) delete prop.slot;
|
|
2450
2549
|
return prop;
|
|
2451
2550
|
}
|
|
2551
|
+
function setPrototypeOf(o, proto) {
|
|
2552
|
+
Object.setPrototypeOf(o, proto);
|
|
2553
|
+
return o;
|
|
2554
|
+
}
|
|
2452
2555
|
|
|
2453
2556
|
function baseRule() {
|
|
2454
2557
|
return {
|
|
@@ -2525,6 +2628,107 @@
|
|
|
2525
2628
|
};
|
|
2526
2629
|
}
|
|
2527
2630
|
|
|
2631
|
+
function getError(action, option, xhr) {
|
|
2632
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2633
|
+
var err = new Error(msg);
|
|
2634
|
+
err.status = xhr.status;
|
|
2635
|
+
err.url = action;
|
|
2636
|
+
return err;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function getBody(xhr) {
|
|
2640
|
+
var text = xhr.responseText || xhr.response;
|
|
2641
|
+
|
|
2642
|
+
if (!text) {
|
|
2643
|
+
return text;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
try {
|
|
2647
|
+
return JSON.parse(text);
|
|
2648
|
+
} catch (e) {
|
|
2649
|
+
return text;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
function fetch$1(option) {
|
|
2654
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
var xhr = new XMLHttpRequest();
|
|
2659
|
+
var action = option.action;
|
|
2660
|
+
|
|
2661
|
+
xhr.onerror = function error(e) {
|
|
2662
|
+
option.onError(e);
|
|
2663
|
+
};
|
|
2664
|
+
|
|
2665
|
+
xhr.onload = function onload() {
|
|
2666
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2667
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
option.onSuccess(getBody(xhr));
|
|
2671
|
+
};
|
|
2672
|
+
|
|
2673
|
+
xhr.open(option.method || 'get', action, true);
|
|
2674
|
+
var formData;
|
|
2675
|
+
|
|
2676
|
+
if (option.data) {
|
|
2677
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2678
|
+
formData = new FormData();
|
|
2679
|
+
Object.keys(option.data).map(function (key) {
|
|
2680
|
+
formData.append(key, option.data[key]);
|
|
2681
|
+
});
|
|
2682
|
+
} else {
|
|
2683
|
+
formData = JSON.stringify(option.data);
|
|
2684
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2689
|
+
xhr.withCredentials = true;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
var headers = option.headers || {};
|
|
2693
|
+
Object.keys(headers).forEach(function (item) {
|
|
2694
|
+
if (headers[item] !== null) {
|
|
2695
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
xhr.send(formData);
|
|
2699
|
+
}
|
|
2700
|
+
function asyncFetch(config) {
|
|
2701
|
+
return new Promise(function (resolve, reject) {
|
|
2702
|
+
fetch$1(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2703
|
+
onSuccess: function onSuccess(res) {
|
|
2704
|
+
var fn = function fn(v) {
|
|
2705
|
+
return v;
|
|
2706
|
+
};
|
|
2707
|
+
|
|
2708
|
+
var parse = parseFn(config.parse);
|
|
2709
|
+
|
|
2710
|
+
if (is.Function(parse)) {
|
|
2711
|
+
fn = parse;
|
|
2712
|
+
} else if (parse && is.String(parse)) {
|
|
2713
|
+
fn = function fn(v) {
|
|
2714
|
+
parse.split('.').forEach(function (k) {
|
|
2715
|
+
if (v) {
|
|
2716
|
+
v = v[k];
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
return v;
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
resolve(fn(res));
|
|
2724
|
+
},
|
|
2725
|
+
onError: function onError(err) {
|
|
2726
|
+
reject(err);
|
|
2727
|
+
}
|
|
2728
|
+
}));
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2528
2732
|
function copy(value) {
|
|
2529
2733
|
return deepCopy(value);
|
|
2530
2734
|
}
|
|
@@ -2580,7 +2784,15 @@
|
|
|
2580
2784
|
},
|
|
2581
2785
|
|
|
2582
2786
|
get parent() {
|
|
2583
|
-
return h.vm.parent && h.vm.parent.setupState.fapi;
|
|
2787
|
+
return h.vm.setupState.parent && h.vm.setupState.parent.setupState.fapi;
|
|
2788
|
+
},
|
|
2789
|
+
|
|
2790
|
+
get top() {
|
|
2791
|
+
if (api.parent) {
|
|
2792
|
+
return api.parent.top;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
return api;
|
|
2584
2796
|
},
|
|
2585
2797
|
|
|
2586
2798
|
get children() {
|
|
@@ -2829,6 +3041,23 @@
|
|
|
2829
3041
|
return origin ? ctx.origin : ctx.rule;
|
|
2830
3042
|
}
|
|
2831
3043
|
},
|
|
3044
|
+
getRenderRule: function getRenderRule(id) {
|
|
3045
|
+
var ctx = h.getCtx(id);
|
|
3046
|
+
|
|
3047
|
+
if (ctx) {
|
|
3048
|
+
return ctx.prop;
|
|
3049
|
+
}
|
|
3050
|
+
},
|
|
3051
|
+
getRefRule: function getRefRule(id) {
|
|
3052
|
+
var ctxs = h.getCtxs(id);
|
|
3053
|
+
|
|
3054
|
+
if (ctxs) {
|
|
3055
|
+
var rules = ctxs.map(function (ctx) {
|
|
3056
|
+
return ctx.rule;
|
|
3057
|
+
});
|
|
3058
|
+
return rules.length === 1 ? rules[0] : rules;
|
|
3059
|
+
}
|
|
3060
|
+
},
|
|
2832
3061
|
setEffect: function setEffect(id, attr, value) {
|
|
2833
3062
|
var ctx = h.getCtx(id);
|
|
2834
3063
|
|
|
@@ -2924,6 +3153,84 @@
|
|
|
2924
3153
|
var ctx = h.getCtx(field);
|
|
2925
3154
|
return ctx ? h.subForm[ctx.id] : undefined;
|
|
2926
3155
|
},
|
|
3156
|
+
getChildrenRuleList: function getChildrenRuleList(id) {
|
|
3157
|
+
var flag = _typeof(id) === 'object';
|
|
3158
|
+
var ctx = flag ? byCtx(id) : h.getCtx(id);
|
|
3159
|
+
var rule = ctx ? ctx.rule : flag ? id : api.getRule(id);
|
|
3160
|
+
|
|
3161
|
+
if (!rule) {
|
|
3162
|
+
return [];
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
var rules = [];
|
|
3166
|
+
|
|
3167
|
+
var findRules = function findRules(children) {
|
|
3168
|
+
children && children.forEach(function (item) {
|
|
3169
|
+
if (_typeof(item) !== 'object') {
|
|
3170
|
+
return;
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
if (item.field) {
|
|
3174
|
+
rules.push(item);
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
rules.push.apply(rules, _toConsumableArray(api.getChildrenRuleList(item)));
|
|
3178
|
+
});
|
|
3179
|
+
};
|
|
3180
|
+
|
|
3181
|
+
findRules(ctx ? ctx.loadChildrenPending() : rule.children);
|
|
3182
|
+
return rules;
|
|
3183
|
+
},
|
|
3184
|
+
getChildrenFormData: function getChildrenFormData(id) {
|
|
3185
|
+
var rules = api.getChildrenRuleList(id);
|
|
3186
|
+
return rules.reduce(function (formData, rule) {
|
|
3187
|
+
formData[rule.field] = copy(rule.value);
|
|
3188
|
+
return formData;
|
|
3189
|
+
}, {});
|
|
3190
|
+
},
|
|
3191
|
+
setChildrenFormData: function setChildrenFormData(id, formData, cover) {
|
|
3192
|
+
var rules = api.getChildrenRuleList(id);
|
|
3193
|
+
rules.forEach(function (rule) {
|
|
3194
|
+
if (hasProperty(formData, rule.field)) {
|
|
3195
|
+
rule.value = formData[rule.field];
|
|
3196
|
+
} else if (cover) {
|
|
3197
|
+
rule.value = undefined;
|
|
3198
|
+
}
|
|
3199
|
+
});
|
|
3200
|
+
},
|
|
3201
|
+
getGlobalEvent: function getGlobalEvent(name) {
|
|
3202
|
+
var event = api.options.globalEvent[name];
|
|
3203
|
+
|
|
3204
|
+
if (event) {
|
|
3205
|
+
if (_typeof(event) === 'object') {
|
|
3206
|
+
event = event.handle;
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
return parseFn(event);
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
return undefined;
|
|
3213
|
+
},
|
|
3214
|
+
getGlobalData: function getGlobalData(name) {
|
|
3215
|
+
return new Promise(function (resolve, inject) {
|
|
3216
|
+
var config = api.options.globalData[name];
|
|
3217
|
+
|
|
3218
|
+
if (!config) {
|
|
3219
|
+
resolve(h.fc.loadData[name]);
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
if (config.type === 'fetch') {
|
|
3223
|
+
api.fetch(config).then(function (res) {
|
|
3224
|
+
resolve({
|
|
3225
|
+
res: res,
|
|
3226
|
+
config: config
|
|
3227
|
+
});
|
|
3228
|
+
})["catch"](inject);
|
|
3229
|
+
} else {
|
|
3230
|
+
resolve(config.data);
|
|
3231
|
+
}
|
|
3232
|
+
});
|
|
3233
|
+
},
|
|
2927
3234
|
nextTick: function nextTick(fn) {
|
|
2928
3235
|
h.bus.$once('next-tick', fn);
|
|
2929
3236
|
h.refresh();
|
|
@@ -2944,12 +3251,21 @@
|
|
|
2944
3251
|
|
|
2945
3252
|
(_h$vm = h.vm).emit.apply(_h$vm, [name].concat(args));
|
|
2946
3253
|
},
|
|
3254
|
+
bus: h.bus,
|
|
3255
|
+
fetch: function fetch(opt) {
|
|
3256
|
+
h.options.beforeFetch && invoke(function () {
|
|
3257
|
+
return h.options.beforeFetch(opt, {
|
|
3258
|
+
api: api
|
|
3259
|
+
});
|
|
3260
|
+
});
|
|
3261
|
+
return asyncFetch(opt);
|
|
3262
|
+
},
|
|
2947
3263
|
helper: {
|
|
2948
3264
|
tidyFields: tidyFields,
|
|
2949
3265
|
props: props
|
|
2950
3266
|
}
|
|
2951
3267
|
};
|
|
2952
|
-
['on', 'once', 'off'
|
|
3268
|
+
['on', 'once', 'off'].forEach(function (n) {
|
|
2953
3269
|
api[n] = function () {
|
|
2954
3270
|
var _h$bus;
|
|
2955
3271
|
|
|
@@ -2971,6 +3287,10 @@
|
|
|
2971
3287
|
}
|
|
2972
3288
|
|
|
2973
3289
|
if (!this.cache[ctx.id]) {
|
|
3290
|
+
if (ctx.parent) {
|
|
3291
|
+
this.clearCache(ctx.parent);
|
|
3292
|
+
}
|
|
3293
|
+
|
|
2974
3294
|
return;
|
|
2975
3295
|
}
|
|
2976
3296
|
|
|
@@ -2978,6 +3298,10 @@
|
|
|
2978
3298
|
this.$handle.refresh();
|
|
2979
3299
|
}
|
|
2980
3300
|
|
|
3301
|
+
if (this.cache[ctx.id].parent) {
|
|
3302
|
+
this.clearCache(this.cache[ctx.id].parent);
|
|
3303
|
+
}
|
|
3304
|
+
|
|
2981
3305
|
this.cache[ctx.id] = null;
|
|
2982
3306
|
},
|
|
2983
3307
|
clearCacheAll: function clearCacheAll() {
|
|
@@ -2992,53 +3316,26 @@
|
|
|
2992
3316
|
};
|
|
2993
3317
|
},
|
|
2994
3318
|
getCache: function getCache(ctx) {
|
|
2995
|
-
var cache = this.cache[ctx.id];
|
|
2996
|
-
|
|
2997
|
-
if (cache) {
|
|
2998
|
-
cache.use = true;
|
|
2999
|
-
return cache.vnode;
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3002
|
-
return undefined;
|
|
3003
|
-
}
|
|
3004
|
-
});
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
|
-
function toCase(str) {
|
|
3008
|
-
var to = str.replace(/(-[a-z])/g, function (v) {
|
|
3009
|
-
return v.replace('-', '').toLocaleUpperCase();
|
|
3010
|
-
});
|
|
3011
|
-
return lower(to);
|
|
3012
|
-
}
|
|
3013
|
-
function lower(str) {
|
|
3014
|
-
return str.replace(str[0], str[0].toLowerCase());
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
function toString(val) {
|
|
3018
|
-
return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
|
|
3019
|
-
}
|
|
3020
|
-
|
|
3021
|
-
var id$2 = 0;
|
|
3022
|
-
function uniqueId() {
|
|
3023
|
-
return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id$2)).toString(36);
|
|
3024
|
-
}
|
|
3319
|
+
var cache = this.cache[ctx.id];
|
|
3025
3320
|
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
(idx || '').split('.').forEach(function (v) {
|
|
3030
|
-
if (to) {
|
|
3031
|
-
if (!_data[to] || _typeof(_data[to]) != 'object') {
|
|
3032
|
-
_data[to] = {};
|
|
3321
|
+
if (cache) {
|
|
3322
|
+
cache.use = true;
|
|
3323
|
+
return cache.vnode;
|
|
3033
3324
|
}
|
|
3034
3325
|
|
|
3035
|
-
|
|
3326
|
+
return undefined;
|
|
3036
3327
|
}
|
|
3328
|
+
});
|
|
3329
|
+
}
|
|
3037
3330
|
|
|
3038
|
-
|
|
3331
|
+
function toCase(str) {
|
|
3332
|
+
var to = str.replace(/(-[a-z])/g, function (v) {
|
|
3333
|
+
return v.replace('-', '').toLocaleUpperCase();
|
|
3039
3334
|
});
|
|
3040
|
-
|
|
3041
|
-
|
|
3335
|
+
return lower(to);
|
|
3336
|
+
}
|
|
3337
|
+
function lower(str) {
|
|
3338
|
+
return str.replace(str[0], str[0].toLowerCase());
|
|
3042
3339
|
}
|
|
3043
3340
|
|
|
3044
3341
|
function useRender$1(Render) {
|
|
@@ -3219,7 +3516,7 @@
|
|
|
3219
3516
|
inject.children = children;
|
|
3220
3517
|
_vn = slot(inject);
|
|
3221
3518
|
} else {
|
|
3222
|
-
_vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
|
|
3519
|
+
_vn = preview ? ctx.parser.preview(copy$1(children), ctx) : ctx.parser.render(copy$1(children), ctx);
|
|
3223
3520
|
}
|
|
3224
3521
|
|
|
3225
3522
|
_vn = _this4.renderSides(_vn, ctx);
|
|
@@ -3229,11 +3526,21 @@
|
|
|
3229
3526
|
}
|
|
3230
3527
|
|
|
3231
3528
|
if (ctx.none) {
|
|
3232
|
-
|
|
3529
|
+
if (Array.isArray(_vn)) {
|
|
3530
|
+
_vn = _vn.map(function (v) {
|
|
3531
|
+
if (!v || !v.__v_isVNode) {
|
|
3532
|
+
return v;
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
return _this4.none(v);
|
|
3536
|
+
});
|
|
3537
|
+
} else {
|
|
3538
|
+
_vn = _this4.none(_vn);
|
|
3539
|
+
}
|
|
3233
3540
|
}
|
|
3234
3541
|
|
|
3235
|
-
cacheFlag &&
|
|
3236
|
-
return _vn;
|
|
3542
|
+
cacheFlag && _this4.setCache(ctx, function () {
|
|
3543
|
+
return _this4.stable(_vn);
|
|
3237
3544
|
}, parent);
|
|
3238
3545
|
return _vn;
|
|
3239
3546
|
};
|
|
@@ -3261,38 +3568,33 @@
|
|
|
3261
3568
|
return;
|
|
3262
3569
|
}
|
|
3263
3570
|
},
|
|
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
3571
|
none: function none(vn) {
|
|
3282
3572
|
if (vn) {
|
|
3283
|
-
if (Array.isArray(vn.props
|
|
3284
|
-
vn.props.
|
|
3285
|
-
display: 'none'
|
|
3286
|
-
});
|
|
3573
|
+
if (Array.isArray(vn.props["class"])) {
|
|
3574
|
+
vn.props["class"].push('fc-none');
|
|
3287
3575
|
} else {
|
|
3288
|
-
vn.props
|
|
3289
|
-
display: 'none'
|
|
3290
|
-
}];
|
|
3576
|
+
vn.props["class"] = vn.props["class"] ? [vn.props["class"], 'fc-none'] : 'fc-none';
|
|
3291
3577
|
}
|
|
3292
3578
|
|
|
3293
3579
|
return vn;
|
|
3294
3580
|
}
|
|
3295
3581
|
},
|
|
3582
|
+
stable: function stable(vn) {
|
|
3583
|
+
var _this5 = this;
|
|
3584
|
+
|
|
3585
|
+
var list = Array.isArray(vn) ? vn : [vn];
|
|
3586
|
+
list.forEach(function (v) {
|
|
3587
|
+
if (v && v.__v_isVNode && v.children && _typeof(v.children) === 'object') {
|
|
3588
|
+
v.children.$stable = true;
|
|
3589
|
+
|
|
3590
|
+
_this5.stable(v.children);
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
return vn;
|
|
3594
|
+
},
|
|
3595
|
+
getModelField: function getModelField(ctx) {
|
|
3596
|
+
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';
|
|
3597
|
+
},
|
|
3296
3598
|
isFragment: function isFragment(ctx) {
|
|
3297
3599
|
return ctx.type === 'fragment' || ctx.type === 'template';
|
|
3298
3600
|
},
|
|
@@ -3314,6 +3616,7 @@
|
|
|
3314
3616
|
options: [],
|
|
3315
3617
|
children: [],
|
|
3316
3618
|
preview: false,
|
|
3619
|
+
id: ctx.id,
|
|
3317
3620
|
field: ctx.field,
|
|
3318
3621
|
rule: ctx.rule,
|
|
3319
3622
|
input: ctx.input
|
|
@@ -3328,14 +3631,14 @@
|
|
|
3328
3631
|
});
|
|
3329
3632
|
return inject;
|
|
3330
3633
|
},
|
|
3331
|
-
ctxProp: function ctxProp(ctx
|
|
3634
|
+
ctxProp: function ctxProp(ctx) {
|
|
3332
3635
|
var _this7 = this;
|
|
3333
3636
|
|
|
3334
3637
|
var ref = ctx.ref,
|
|
3335
3638
|
key = ctx.key,
|
|
3336
3639
|
rule = ctx.rule;
|
|
3337
|
-
this.$manager.mergeProp(ctx
|
|
3338
|
-
ctx.parser.mergeProp(ctx
|
|
3640
|
+
this.$manager.mergeProp(ctx);
|
|
3641
|
+
ctx.parser.mergeProp(ctx);
|
|
3339
3642
|
var props = [{
|
|
3340
3643
|
ref: ref,
|
|
3341
3644
|
key: rule.key || "".concat(key, "fc"),
|
|
@@ -3356,7 +3659,11 @@
|
|
|
3356
3659
|
}
|
|
3357
3660
|
}];
|
|
3358
3661
|
|
|
3359
|
-
if (
|
|
3662
|
+
if (ctx.input) {
|
|
3663
|
+
if (this.vm.props.disabled !== undefined) {
|
|
3664
|
+
ctx.prop.props.disabled = !!this.vm.props.disabled;
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3360
3667
|
var field = this.getModelField(ctx);
|
|
3361
3668
|
var model = {
|
|
3362
3669
|
callback: function callback(value) {
|
|
@@ -3365,7 +3672,9 @@
|
|
|
3365
3672
|
value: this.$handle.getFormData(ctx)
|
|
3366
3673
|
};
|
|
3367
3674
|
props.push({
|
|
3368
|
-
on: _defineProperty({}, "update:".concat(field), model.callback),
|
|
3675
|
+
on: _objectSpread2(_defineProperty({}, "update:".concat(field), model.callback), ctx.prop.modelEmit ? _defineProperty({}, ctx.prop.modelEmit, function () {
|
|
3676
|
+
return _this7.onEmitInput(ctx);
|
|
3677
|
+
}) : {}),
|
|
3369
3678
|
props: _defineProperty({}, field, model.value)
|
|
3370
3679
|
});
|
|
3371
3680
|
ctx.prop.model = model;
|
|
@@ -3380,8 +3689,16 @@
|
|
|
3380
3689
|
this.$handle.effect(ctx, 'mounted');
|
|
3381
3690
|
},
|
|
3382
3691
|
onInput: function onInput(ctx, value) {
|
|
3692
|
+
if (ctx.prop.modelEmit) {
|
|
3693
|
+
this.$handle.onBaseInput(ctx, value);
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3383
3697
|
this.$handle.onInput(ctx, value);
|
|
3384
3698
|
},
|
|
3699
|
+
onEmitInput: function onEmitInput(ctx) {
|
|
3700
|
+
this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
|
|
3701
|
+
},
|
|
3385
3702
|
renderChildren: function renderChildren(children, ctx) {
|
|
3386
3703
|
var _this8 = this;
|
|
3387
3704
|
|
|
@@ -3518,23 +3835,27 @@
|
|
|
3518
3835
|
var emit = rule.emit || [];
|
|
3519
3836
|
|
|
3520
3837
|
if (is.trueArray(emit)) {
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
}
|
|
3838
|
+
emit.forEach(function (eventName) {
|
|
3839
|
+
if (!eventName) return;
|
|
3840
|
+
var eventInject;
|
|
3841
|
+
var emitKey = emitPrefix || field || name;
|
|
3842
|
+
|
|
3843
|
+
if (is.Object(eventName)) {
|
|
3844
|
+
eventInject = eventName.inject;
|
|
3845
|
+
eventName = eventName.name;
|
|
3846
|
+
emitKey = eventName.prefix || emitKey;
|
|
3847
|
+
}
|
|
3532
3848
|
|
|
3849
|
+
if (emitKey) {
|
|
3533
3850
|
var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
|
|
3534
3851
|
|
|
3535
3852
|
var fn = function fn() {
|
|
3536
3853
|
var _this2$vm, _this2$vm2, _this2$bus;
|
|
3537
3854
|
|
|
3855
|
+
if (_this2.vm.emitsOptions) {
|
|
3856
|
+
_this2.vm.emitsOptions[fieldKey] = null;
|
|
3857
|
+
}
|
|
3858
|
+
|
|
3538
3859
|
for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3539
3860
|
arg[_key] = arguments[_key];
|
|
3540
3861
|
}
|
|
@@ -3555,8 +3876,8 @@
|
|
|
3555
3876
|
|
|
3556
3877
|
event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
|
|
3557
3878
|
}
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3560
3881
|
}
|
|
3561
3882
|
|
|
3562
3883
|
ctx.computed.on = event;
|
|
@@ -3681,16 +4002,6 @@
|
|
|
3681
4002
|
});
|
|
3682
4003
|
}
|
|
3683
4004
|
|
|
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
4005
|
function bind(ctx) {
|
|
3695
4006
|
Object.defineProperties(ctx.origin, {
|
|
3696
4007
|
__fc__: enumerable(vue.markRaw(ctx), true)
|
|
@@ -3713,7 +4024,9 @@
|
|
|
3713
4024
|
linkOn: [],
|
|
3714
4025
|
root: [],
|
|
3715
4026
|
ctrlRule: [],
|
|
4027
|
+
children: [],
|
|
3716
4028
|
parent: null,
|
|
4029
|
+
group: rule.subRule ? this : null,
|
|
3717
4030
|
cacheConfig: null,
|
|
3718
4031
|
prop: _objectSpread2({}, rule),
|
|
3719
4032
|
computed: {},
|
|
@@ -3731,6 +4044,17 @@
|
|
|
3731
4044
|
this.update(handle, true);
|
|
3732
4045
|
}
|
|
3733
4046
|
extend(RuleContext.prototype, {
|
|
4047
|
+
getParentGroup: function getParentGroup() {
|
|
4048
|
+
var ctx = this.parent;
|
|
4049
|
+
|
|
4050
|
+
while (ctx) {
|
|
4051
|
+
if (ctx.group) {
|
|
4052
|
+
return ctx;
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
ctx = ctx.parent;
|
|
4056
|
+
}
|
|
4057
|
+
},
|
|
3734
4058
|
loadChildrenPending: function loadChildrenPending() {
|
|
3735
4059
|
var _this = this;
|
|
3736
4060
|
|
|
@@ -3866,7 +4190,21 @@
|
|
|
3866
4190
|
})), [this.computed]));
|
|
3867
4191
|
},
|
|
3868
4192
|
initNone: function initNone() {
|
|
3869
|
-
this.none =
|
|
4193
|
+
this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
|
|
4194
|
+
},
|
|
4195
|
+
injectValidate: function injectValidate() {
|
|
4196
|
+
var _this4 = this;
|
|
4197
|
+
|
|
4198
|
+
return toArray(this.prop.validate).map(function (item) {
|
|
4199
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
4200
|
+
inject: {
|
|
4201
|
+
id: _this4.id,
|
|
4202
|
+
field: _this4.field,
|
|
4203
|
+
rule: _this4.rule,
|
|
4204
|
+
api: _this4.$handle.api
|
|
4205
|
+
}
|
|
4206
|
+
});
|
|
4207
|
+
});
|
|
3870
4208
|
},
|
|
3871
4209
|
check: function check(handle) {
|
|
3872
4210
|
return this.vm === handle.vm;
|
|
@@ -3896,6 +4234,11 @@
|
|
|
3896
4234
|
this.unwatch();
|
|
3897
4235
|
this.unlink();
|
|
3898
4236
|
this.rmCtrl();
|
|
4237
|
+
|
|
4238
|
+
if (this.parent) {
|
|
4239
|
+
this.parent.children.splice(this.parent.children.indexOf(this) >>> 0, 1);
|
|
4240
|
+
}
|
|
4241
|
+
|
|
3899
4242
|
extend(this, {
|
|
3900
4243
|
deleted: true,
|
|
3901
4244
|
prop: _objectSpread2({}, this.rule),
|
|
@@ -3907,6 +4250,7 @@
|
|
|
3907
4250
|
vm: undef,
|
|
3908
4251
|
vNode: undef,
|
|
3909
4252
|
parent: null,
|
|
4253
|
+
children: [],
|
|
3910
4254
|
cacheConfig: null,
|
|
3911
4255
|
none: false
|
|
3912
4256
|
});
|
|
@@ -3918,15 +4262,15 @@
|
|
|
3918
4262
|
this.ctrlRule = [];
|
|
3919
4263
|
},
|
|
3920
4264
|
rm: function rm() {
|
|
3921
|
-
var
|
|
4265
|
+
var _this5 = this;
|
|
3922
4266
|
|
|
3923
4267
|
var _rm = function _rm() {
|
|
3924
|
-
var index =
|
|
4268
|
+
var index = _this5.root.indexOf(_this5.origin);
|
|
3925
4269
|
|
|
3926
4270
|
if (index > -1) {
|
|
3927
|
-
|
|
4271
|
+
_this5.root.splice(index, 1);
|
|
3928
4272
|
|
|
3929
|
-
|
|
4273
|
+
_this5.$handle && _this5.$handle.refresh();
|
|
3930
4274
|
}
|
|
3931
4275
|
};
|
|
3932
4276
|
|
|
@@ -3937,17 +4281,17 @@
|
|
|
3937
4281
|
}
|
|
3938
4282
|
|
|
3939
4283
|
this.$handle.noWatch(function () {
|
|
3940
|
-
|
|
3941
|
-
|
|
4284
|
+
_this5.$handle.deferSyncValue(function () {
|
|
4285
|
+
_this5.rmCtrl();
|
|
3942
4286
|
|
|
3943
4287
|
_rm();
|
|
3944
4288
|
|
|
3945
|
-
|
|
4289
|
+
_this5.$handle.rmCtx(_this5);
|
|
3946
4290
|
|
|
3947
|
-
extend(
|
|
4291
|
+
extend(_this5, {
|
|
3948
4292
|
root: []
|
|
3949
4293
|
});
|
|
3950
|
-
},
|
|
4294
|
+
}, _this5.input);
|
|
3951
4295
|
});
|
|
3952
4296
|
},
|
|
3953
4297
|
update: function update(handle, init) {
|
|
@@ -4167,7 +4511,7 @@
|
|
|
4167
4511
|
}
|
|
4168
4512
|
};
|
|
4169
4513
|
|
|
4170
|
-
rules.map(function (_rule, index) {
|
|
4514
|
+
var ctxs = rules.map(function (_rule, index) {
|
|
4171
4515
|
if (parent && !is.Object(_rule)) return;
|
|
4172
4516
|
if (!_this6.pageEnd && !parent && index >= _this6.first) return;
|
|
4173
4517
|
|
|
@@ -4235,6 +4579,10 @@
|
|
|
4235
4579
|
}
|
|
4236
4580
|
|
|
4237
4581
|
_this6.appendValue(ctx.rule);
|
|
4582
|
+
|
|
4583
|
+
if (ctx.parent && ctx.parent !== parent) {
|
|
4584
|
+
_this6.rmSubRuleData(ctx);
|
|
4585
|
+
}
|
|
4238
4586
|
}
|
|
4239
4587
|
|
|
4240
4588
|
_this6.parseEmit(ctx);
|
|
@@ -4282,7 +4630,13 @@
|
|
|
4282
4630
|
|
|
4283
4631
|
if (_this6.refreshControl(ctx)) _this6.cycleLoad = true;
|
|
4284
4632
|
return ctx;
|
|
4633
|
+
}).filter(function (v) {
|
|
4634
|
+
return !!v;
|
|
4285
4635
|
});
|
|
4636
|
+
|
|
4637
|
+
if (parent) {
|
|
4638
|
+
parent.children = ctxs;
|
|
4639
|
+
}
|
|
4286
4640
|
},
|
|
4287
4641
|
refreshControl: function refreshControl(ctx) {
|
|
4288
4642
|
return ctx.input && ctx.rule.control && this.useCtrl(ctx);
|
|
@@ -4477,6 +4831,11 @@
|
|
|
4477
4831
|
this.valueChange(ctx, value);
|
|
4478
4832
|
this.vm.emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
4479
4833
|
this.effect(ctx, 'value');
|
|
4834
|
+
this.emitEvent('change', ctx.field, value, {
|
|
4835
|
+
rule: ctx.origin,
|
|
4836
|
+
api: this.api,
|
|
4837
|
+
setFlag: setFlag || false
|
|
4838
|
+
});
|
|
4480
4839
|
},
|
|
4481
4840
|
onInput: function onInput(ctx, value) {
|
|
4482
4841
|
var val;
|
|
@@ -4485,9 +4844,33 @@
|
|
|
4485
4844
|
this.setValue(ctx, val, value);
|
|
4486
4845
|
}
|
|
4487
4846
|
},
|
|
4847
|
+
onBaseInput: function onBaseInput(ctx, value) {
|
|
4848
|
+
this.setFormData(ctx, value);
|
|
4849
|
+
ctx.modelValue = value;
|
|
4850
|
+
this.nextRefresh();
|
|
4851
|
+
this.$render.clearCache(ctx);
|
|
4852
|
+
},
|
|
4488
4853
|
setFormData: function setFormData(ctx, value) {
|
|
4854
|
+
ctx.modelValue = value;
|
|
4855
|
+
var group = ctx.getParentGroup();
|
|
4856
|
+
|
|
4857
|
+
if (group) {
|
|
4858
|
+
if (!this.subRuleData[group.id]) {
|
|
4859
|
+
this.subRuleData[group.id] = {};
|
|
4860
|
+
}
|
|
4861
|
+
|
|
4862
|
+
this.subRuleData[group.id][ctx.field] = ctx.rule.value;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4489
4865
|
$set(this.formData, ctx.id, value);
|
|
4490
4866
|
},
|
|
4867
|
+
rmSubRuleData: function rmSubRuleData(ctx) {
|
|
4868
|
+
var group = ctx.getParentGroup();
|
|
4869
|
+
|
|
4870
|
+
if (group && this.subRuleData[group.id]) {
|
|
4871
|
+
delete this.subRuleData[group.id][ctx.field];
|
|
4872
|
+
}
|
|
4873
|
+
},
|
|
4491
4874
|
getFormData: function getFormData(ctx) {
|
|
4492
4875
|
return this.formData[ctx.id];
|
|
4493
4876
|
},
|
|
@@ -4544,13 +4927,14 @@
|
|
|
4544
4927
|
isQuote: function isQuote(ctx, value) {
|
|
4545
4928
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
4546
4929
|
},
|
|
4547
|
-
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
4930
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
4548
4931
|
var _this2 = this;
|
|
4549
4932
|
|
|
4550
4933
|
if (is.Function(ctx.rule.update)) {
|
|
4551
4934
|
var state = invoke(function () {
|
|
4552
4935
|
return ctx.rule.update(val, ctx.origin, _this2.api, {
|
|
4553
|
-
origin: origin || 'change'
|
|
4936
|
+
origin: origin || 'change',
|
|
4937
|
+
linkField: field
|
|
4554
4938
|
});
|
|
4555
4939
|
});
|
|
4556
4940
|
if (state === undefined) return;
|
|
@@ -4561,7 +4945,7 @@
|
|
|
4561
4945
|
this.refreshRule(ctx, val);
|
|
4562
4946
|
this.bus.$emit('change-' + ctx.field, val);
|
|
4563
4947
|
},
|
|
4564
|
-
refreshRule: function refreshRule(ctx, val, origin) {
|
|
4948
|
+
refreshRule: function refreshRule(ctx, val, origin, field) {
|
|
4565
4949
|
if (this.refreshControl(ctx)) {
|
|
4566
4950
|
this.$render.clearCacheAll();
|
|
4567
4951
|
this.loadRule();
|
|
@@ -4569,7 +4953,7 @@
|
|
|
4569
4953
|
this.refresh();
|
|
4570
4954
|
}
|
|
4571
4955
|
|
|
4572
|
-
this.refreshUpdate(ctx, val, origin);
|
|
4956
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
4573
4957
|
},
|
|
4574
4958
|
appendLink: function appendLink(ctx) {
|
|
4575
4959
|
var _this3 = this;
|
|
@@ -4577,7 +4961,7 @@
|
|
|
4577
4961
|
var link = ctx.rule.link;
|
|
4578
4962
|
is.trueArray(link) && link.forEach(function (field) {
|
|
4579
4963
|
var fn = function fn() {
|
|
4580
|
-
return _this3.refreshRule(ctx, ctx.rule.value, 'link');
|
|
4964
|
+
return _this3.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
4581
4965
|
};
|
|
4582
4966
|
|
|
4583
4967
|
_this3.bus.$on('change-' + field, fn);
|
|
@@ -4615,40 +4999,6 @@
|
|
|
4615
4999
|
mergeProp: function mergeProp(ctx) {}
|
|
4616
5000
|
};
|
|
4617
5001
|
|
|
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
5002
|
var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
|
|
4653
5003
|
function useContext(Handler) {
|
|
4654
5004
|
extend(Handler.prototype, {
|
|
@@ -4760,7 +5110,11 @@
|
|
|
4760
5110
|
if (key === 'props' && ctx.input) {
|
|
4761
5111
|
_this.setFormData(ctx, ctx.parser.toFormValue(ctx.rule.value, ctx));
|
|
4762
5112
|
}
|
|
4763
|
-
} else if (key === 'emit')
|
|
5113
|
+
} else if (key === 'emit') {
|
|
5114
|
+
_this.parseEmit(ctx);
|
|
5115
|
+
} else if (key === 'hidden' && Boolean(n) !== Boolean(o)) {
|
|
5116
|
+
_this.$render.clearCacheAll();
|
|
5117
|
+
} else if (['prefix', 'suffix'].indexOf(key) > -1) n && _this.loadFn(n, ctx.rule);else if (key === 'type') {
|
|
4764
5118
|
ctx.updateType();
|
|
4765
5119
|
|
|
4766
5120
|
_this.bindParser(ctx);
|
|
@@ -4798,32 +5152,55 @@
|
|
|
4798
5152
|
_this.setValue(ctx, val.value, formValue, true);
|
|
4799
5153
|
}
|
|
4800
5154
|
}));
|
|
4801
|
-
|
|
4802
|
-
|
|
5155
|
+
}
|
|
5156
|
+
|
|
5157
|
+
this.bus.$once('load-end', function () {
|
|
5158
|
+
var computed = ctx.rule.computed;
|
|
5159
|
+
|
|
5160
|
+
if (!computed) {
|
|
5161
|
+
return;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
if (_typeof(computed) !== 'object') {
|
|
5165
|
+
computed = {
|
|
5166
|
+
value: computed
|
|
5167
|
+
};
|
|
5168
|
+
}
|
|
5169
|
+
|
|
5170
|
+
Object.keys(computed).forEach(function (k) {
|
|
4803
5171
|
ctx.watch.push(vue.watch(function () {
|
|
4804
|
-
var
|
|
4805
|
-
if (!
|
|
5172
|
+
var item = computed[k];
|
|
5173
|
+
if (!item) return undefined;
|
|
4806
5174
|
var fn;
|
|
4807
5175
|
|
|
4808
|
-
if (is.Function(
|
|
5176
|
+
if (is.Function(item)) {
|
|
4809
5177
|
fn = function fn() {
|
|
4810
|
-
return
|
|
5178
|
+
return item(_this.api.form, _this.api);
|
|
4811
5179
|
};
|
|
4812
5180
|
} else {
|
|
5181
|
+
var group = ctx.getParentGroup();
|
|
5182
|
+
|
|
4813
5183
|
fn = function fn() {
|
|
4814
|
-
return new Function('
|
|
5184
|
+
return new Function('formulas', 'top', 'group', '$rule', '$api', "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] || {} : {}, ctx.rule, _this.api);
|
|
4815
5185
|
};
|
|
4816
5186
|
}
|
|
4817
5187
|
|
|
4818
5188
|
return invoke(fn, undefined);
|
|
4819
5189
|
}, function (n) {
|
|
4820
|
-
|
|
5190
|
+
setTimeout(function () {
|
|
5191
|
+
if (k === 'value') {
|
|
5192
|
+
_this.onInput(ctx, n);
|
|
5193
|
+
} else if (k[0] === '$') {
|
|
5194
|
+
_this.api.setEffect(ctx.id, k, n);
|
|
5195
|
+
} else {
|
|
5196
|
+
deepSet(ctx.rule, k, n);
|
|
5197
|
+
}
|
|
5198
|
+
});
|
|
4821
5199
|
}, {
|
|
4822
|
-
immediate:
|
|
5200
|
+
immediate: true
|
|
4823
5201
|
}));
|
|
4824
5202
|
});
|
|
4825
|
-
}
|
|
4826
|
-
|
|
5203
|
+
});
|
|
4827
5204
|
this.watchEffect(ctx);
|
|
4828
5205
|
},
|
|
4829
5206
|
updateChildren: function updateChildren(ctx, n, o) {
|
|
@@ -4831,7 +5208,7 @@
|
|
|
4831
5208
|
|
|
4832
5209
|
this.deferSyncValue(function () {
|
|
4833
5210
|
o && o.forEach(function (child) {
|
|
4834
|
-
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root
|
|
5211
|
+
if ((n || []).indexOf(child) === -1 && child && !is.String(child) && child.__fc__ && child.__fc__.parent === ctx && child.__fc__.root !== n) {
|
|
4835
5212
|
_this2.rmCtx(child.__fc__);
|
|
4836
5213
|
}
|
|
4837
5214
|
});
|
|
@@ -4862,6 +5239,16 @@
|
|
|
4862
5239
|
$del(this.formData, id);
|
|
4863
5240
|
$del(this.subForm, id);
|
|
4864
5241
|
$del(this.vm.setupState.ctxInject, id);
|
|
5242
|
+
var group = ctx.getParentGroup();
|
|
5243
|
+
|
|
5244
|
+
if (group && this.subRuleData[group.id]) {
|
|
5245
|
+
$del(this.subRuleData[group.id], field);
|
|
5246
|
+
}
|
|
5247
|
+
|
|
5248
|
+
if (ctx.group) {
|
|
5249
|
+
$del(this.subRuleData, id);
|
|
5250
|
+
}
|
|
5251
|
+
|
|
4865
5252
|
input && this.rmIdCtx(ctx, field, 'field');
|
|
4866
5253
|
name && this.rmIdCtx(ctx, name, 'name');
|
|
4867
5254
|
|
|
@@ -4920,13 +5307,26 @@
|
|
|
4920
5307
|
}
|
|
4921
5308
|
},
|
|
4922
5309
|
lifecycle: function lifecycle(name) {
|
|
4923
|
-
var _this2 = this;
|
|
4924
|
-
|
|
4925
|
-
var fn = this.options[name];
|
|
4926
|
-
is.Function(fn) && invoke(function () {
|
|
4927
|
-
return fn(_this2.api);
|
|
4928
|
-
});
|
|
4929
5310
|
this.vm.emit(name, this.api);
|
|
5311
|
+
this.emitEvent(name, this.api);
|
|
5312
|
+
},
|
|
5313
|
+
emitEvent: function emitEvent(name) {
|
|
5314
|
+
var _this$bus;
|
|
5315
|
+
|
|
5316
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
5317
|
+
args[_key - 1] = arguments[_key];
|
|
5318
|
+
}
|
|
5319
|
+
|
|
5320
|
+
var _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
5321
|
+
|
|
5322
|
+
if (_fn) {
|
|
5323
|
+
var fn = parseFn(_fn);
|
|
5324
|
+
is.Function(fn) && invoke(function () {
|
|
5325
|
+
return fn.apply(void 0, args);
|
|
5326
|
+
});
|
|
5327
|
+
}
|
|
5328
|
+
|
|
5329
|
+
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
4930
5330
|
}
|
|
4931
5331
|
});
|
|
4932
5332
|
}
|
|
@@ -5117,6 +5517,7 @@
|
|
|
5117
5517
|
deferSyncFn: null,
|
|
5118
5518
|
isMounted: false,
|
|
5119
5519
|
formData: vue.reactive({}),
|
|
5520
|
+
subRuleData: vue.reactive({}),
|
|
5120
5521
|
subForm: {},
|
|
5121
5522
|
form: vue.reactive({}),
|
|
5122
5523
|
appendData: {},
|
|
@@ -5152,6 +5553,8 @@
|
|
|
5152
5553
|
this.loadRule();
|
|
5153
5554
|
|
|
5154
5555
|
this.$manager.__init();
|
|
5556
|
+
|
|
5557
|
+
this.lifecycle('created');
|
|
5155
5558
|
},
|
|
5156
5559
|
isBreakWatch: function isBreakWatch() {
|
|
5157
5560
|
return this.loading || this.noWatchFn || this.reloading;
|
|
@@ -5166,77 +5569,6 @@
|
|
|
5166
5569
|
useLifecycle(Handler);
|
|
5167
5570
|
useEffect(Handler);
|
|
5168
5571
|
|
|
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
5572
|
var NAME = 'fcFragment';
|
|
5241
5573
|
var fragment = vue.defineComponent({
|
|
5242
5574
|
name: NAME,
|
|
@@ -5519,22 +5851,23 @@
|
|
|
5519
5851
|
function run(inject, rule, api) {
|
|
5520
5852
|
var option = inject.value;
|
|
5521
5853
|
|
|
5854
|
+
if (is.Function(option)) {
|
|
5855
|
+
option = option(rule, api);
|
|
5856
|
+
}
|
|
5857
|
+
|
|
5858
|
+
option = parseOpt(option);
|
|
5859
|
+
|
|
5522
5860
|
var set = function set(val) {
|
|
5523
5861
|
if (val === undefined) {
|
|
5524
5862
|
inject.clearProp();
|
|
5525
|
-
api.sync(rule);
|
|
5526
5863
|
} else {
|
|
5527
5864
|
deepSet(inject.getProp(), option.to || 'options', val);
|
|
5528
5865
|
}
|
|
5529
|
-
};
|
|
5530
|
-
|
|
5531
|
-
if (is.Function(option)) {
|
|
5532
|
-
option = option(rule, api);
|
|
5533
|
-
}
|
|
5534
5866
|
|
|
5535
|
-
|
|
5867
|
+
api.sync(rule);
|
|
5868
|
+
};
|
|
5536
5869
|
|
|
5537
|
-
if (!option || !option.action) {
|
|
5870
|
+
if (!option || !option.action && !option.key) {
|
|
5538
5871
|
set(undefined);
|
|
5539
5872
|
return;
|
|
5540
5873
|
}
|
|
@@ -5543,6 +5876,22 @@
|
|
|
5543
5876
|
option.to = 'options';
|
|
5544
5877
|
}
|
|
5545
5878
|
|
|
5879
|
+
if (option.key) {
|
|
5880
|
+
var item = fc.$handle.options.globalData[option.key];
|
|
5881
|
+
|
|
5882
|
+
if (!item) {
|
|
5883
|
+
set(undefined);
|
|
5884
|
+
return;
|
|
5885
|
+
}
|
|
5886
|
+
|
|
5887
|
+
if (item.type === 'static') {
|
|
5888
|
+
set(item.data);
|
|
5889
|
+
return;
|
|
5890
|
+
} else {
|
|
5891
|
+
option = _objectSpread2(_objectSpread2({}, option), item);
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
|
|
5546
5895
|
var _onError = option.onError;
|
|
5547
5896
|
|
|
5548
5897
|
var check = function check() {
|
|
@@ -5563,11 +5912,13 @@
|
|
|
5563
5912
|
return flag ? v : v.data;
|
|
5564
5913
|
};
|
|
5565
5914
|
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5915
|
+
var parse = parseFn(option.parse);
|
|
5916
|
+
|
|
5917
|
+
if (is.Function(parse)) {
|
|
5918
|
+
fn = parse;
|
|
5919
|
+
} else if (parse && is.String(parse)) {
|
|
5569
5920
|
fn = function fn(v) {
|
|
5570
|
-
|
|
5921
|
+
parse.split('.').forEach(function (k) {
|
|
5571
5922
|
if (v) {
|
|
5572
5923
|
v = v[k];
|
|
5573
5924
|
}
|
|
@@ -5699,6 +6050,7 @@
|
|
|
5699
6050
|
};
|
|
5700
6051
|
var loadData = {};
|
|
5701
6052
|
var CreateNode = CreateNodeFactory();
|
|
6053
|
+
var formulas = {};
|
|
5702
6054
|
exportAttrs(config.attrs || {});
|
|
5703
6055
|
|
|
5704
6056
|
function getApi(name) {
|
|
@@ -5735,11 +6087,11 @@
|
|
|
5735
6087
|
|
|
5736
6088
|
function parser() {
|
|
5737
6089
|
var data = nameProp.apply(void 0, arguments);
|
|
5738
|
-
if (!data.id || !data.prop) return;
|
|
6090
|
+
if (!data.id || !data.prop) return BaseParser;
|
|
5739
6091
|
var name = toCase(data.id);
|
|
5740
6092
|
var parser = data.prop;
|
|
5741
6093
|
var base = parser.merge === true ? parsers[name] : undefined;
|
|
5742
|
-
parsers[name] =
|
|
6094
|
+
parsers[name] = setPrototypeOf(parser, base || BaseParser);
|
|
5743
6095
|
maker[name] = creatorFactory(name);
|
|
5744
6096
|
parser.maker && extend(maker, parser.maker);
|
|
5745
6097
|
}
|
|
@@ -5759,8 +6111,13 @@
|
|
|
5759
6111
|
}
|
|
5760
6112
|
|
|
5761
6113
|
if (!name || !component) return;
|
|
6114
|
+
var nameAlias = toCase(name);
|
|
5762
6115
|
components[name] = component;
|
|
5763
|
-
components[
|
|
6116
|
+
components[nameAlias] = component;
|
|
6117
|
+
delete CreateNode.aliasMap[name];
|
|
6118
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
6119
|
+
delete parsers[name];
|
|
6120
|
+
delete parsers[nameAlias];
|
|
5764
6121
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5765
6122
|
}
|
|
5766
6123
|
|
|
@@ -5820,6 +6177,7 @@
|
|
|
5820
6177
|
providers: providers,
|
|
5821
6178
|
useApps: useApps,
|
|
5822
6179
|
maker: maker,
|
|
6180
|
+
formulas: formulas,
|
|
5823
6181
|
loadData: loadData
|
|
5824
6182
|
};
|
|
5825
6183
|
} else {
|
|
@@ -5833,6 +6191,10 @@
|
|
|
5833
6191
|
modelFields[name] = field;
|
|
5834
6192
|
}
|
|
5835
6193
|
|
|
6194
|
+
function setFormula(name, fn) {
|
|
6195
|
+
formulas[name] = fn;
|
|
6196
|
+
}
|
|
6197
|
+
|
|
5836
6198
|
function _emitData(id) {
|
|
5837
6199
|
Object.keys(instance).forEach(function (v) {
|
|
5838
6200
|
var apis = Array.isArray(instance[v]) ? instance[v] : [instance[v]];
|
|
@@ -5865,6 +6227,7 @@
|
|
|
5865
6227
|
parsers: parsers,
|
|
5866
6228
|
providers: providers,
|
|
5867
6229
|
modelFields: modelFields,
|
|
6230
|
+
formulas: formulas,
|
|
5868
6231
|
rules: vm.props.rule,
|
|
5869
6232
|
name: vm.props.name || uniqueId(),
|
|
5870
6233
|
inFor: vm.props.inFor,
|
|
@@ -5876,7 +6239,7 @@
|
|
|
5876
6239
|
CreateNode: CreateNode,
|
|
5877
6240
|
bus: new Mitt(),
|
|
5878
6241
|
unwatch: null,
|
|
5879
|
-
options: vue.ref(
|
|
6242
|
+
options: vue.ref({}),
|
|
5880
6243
|
extendApi: config.extendApi || function (api) {
|
|
5881
6244
|
return api;
|
|
5882
6245
|
}
|
|
@@ -5910,9 +6273,9 @@
|
|
|
5910
6273
|
|
|
5911
6274
|
if (this.isSub()) {
|
|
5912
6275
|
this.unwatch = vue.watch(function () {
|
|
5913
|
-
return _this2.vm.parent.
|
|
6276
|
+
return _this2.vm.setupState.parent.setupState.fc.options.value;
|
|
5914
6277
|
}, function () {
|
|
5915
|
-
_this2.initOptions(
|
|
6278
|
+
_this2.initOptions();
|
|
5916
6279
|
|
|
5917
6280
|
_this2.$handle.api.refresh();
|
|
5918
6281
|
}, {
|
|
@@ -5920,28 +6283,33 @@
|
|
|
5920
6283
|
});
|
|
5921
6284
|
}
|
|
5922
6285
|
|
|
5923
|
-
this.initOptions(
|
|
6286
|
+
this.initOptions();
|
|
5924
6287
|
this.$handle.init();
|
|
5925
6288
|
},
|
|
5926
6289
|
isSub: function isSub() {
|
|
5927
6290
|
return this.vm.setupState.parent && this.vm.props.extendOption;
|
|
5928
6291
|
},
|
|
5929
|
-
initOptions: function initOptions(
|
|
5930
|
-
this.options.value =
|
|
6292
|
+
initOptions: function initOptions() {
|
|
6293
|
+
this.options.value = {};
|
|
6294
|
+
|
|
6295
|
+
var options = _objectSpread2({
|
|
5931
6296
|
formData: {},
|
|
5932
6297
|
submitBtn: {},
|
|
5933
|
-
resetBtn: {}
|
|
6298
|
+
resetBtn: {},
|
|
6299
|
+
globalEvent: {},
|
|
6300
|
+
globalData: {}
|
|
5934
6301
|
}, deepCopy(globalConfig));
|
|
5935
6302
|
|
|
5936
6303
|
if (this.isSub()) {
|
|
5937
|
-
|
|
6304
|
+
options = this.mergeOptions(options, this.vm.setupState.parent.setupState.fc.options.value || {}, true);
|
|
5938
6305
|
}
|
|
5939
6306
|
|
|
6307
|
+
options = this.mergeOptions(options, this.vm.props.option);
|
|
5940
6308
|
this.updateOptions(options);
|
|
5941
6309
|
},
|
|
5942
6310
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
5943
6311
|
opt = deepCopy(opt);
|
|
5944
|
-
parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el'].forEach(function (n) {
|
|
6312
|
+
parent && ['page', 'onSubmit', 'mounted', 'reload', 'formData', 'el', 'globalClass'].forEach(function (n) {
|
|
5945
6313
|
delete opt[n];
|
|
5946
6314
|
});
|
|
5947
6315
|
|
|
@@ -5998,6 +6366,7 @@
|
|
|
5998
6366
|
component: component,
|
|
5999
6367
|
directive: directive,
|
|
6000
6368
|
setModelField: setModelField,
|
|
6369
|
+
setFormula: setFormula,
|
|
6001
6370
|
register: register,
|
|
6002
6371
|
$vnode: $vnode,
|
|
6003
6372
|
parser: parser,
|
|
@@ -6064,6 +6433,7 @@
|
|
|
6064
6433
|
inherit.useApps && extend(useApps, inherit.useApps);
|
|
6065
6434
|
inherit.maker && extend(maker, inherit.maker);
|
|
6066
6435
|
inherit.loadData && extend(loadData, inherit.loadData);
|
|
6436
|
+
inherit.formulas && extend(formulas, inherit.formulas);
|
|
6067
6437
|
}
|
|
6068
6438
|
|
|
6069
6439
|
return create;
|
|
@@ -6327,8 +6697,8 @@
|
|
|
6327
6697
|
var form = _this.form();
|
|
6328
6698
|
|
|
6329
6699
|
if (form) {
|
|
6330
|
-
form.validateField(field, function (res) {
|
|
6331
|
-
|
|
6700
|
+
form.validateField(field, function (res, err) {
|
|
6701
|
+
err ? reject(err) : resolve(res);
|
|
6332
6702
|
});
|
|
6333
6703
|
} else {
|
|
6334
6704
|
resolve();
|
|
@@ -6343,7 +6713,7 @@
|
|
|
6343
6713
|
}
|
|
6344
6714
|
},
|
|
6345
6715
|
tidyOptions: function tidyOptions(options) {
|
|
6346
|
-
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col'].forEach(function (name) {
|
|
6716
|
+
['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col', 'title'].forEach(function (name) {
|
|
6347
6717
|
tidyBool(options, name);
|
|
6348
6718
|
});
|
|
6349
6719
|
return options;
|
|
@@ -6358,7 +6728,8 @@
|
|
|
6358
6728
|
ctx.prop = mergeProps([{
|
|
6359
6729
|
info: this.options.info || {},
|
|
6360
6730
|
wrap: this.options.wrap || {},
|
|
6361
|
-
col: this.options.col || {}
|
|
6731
|
+
col: this.options.col || {},
|
|
6732
|
+
title: this.options.title || {}
|
|
6362
6733
|
}, ctx.prop], {
|
|
6363
6734
|
info: {
|
|
6364
6735
|
trigger: 'hover',
|
|
@@ -6386,7 +6757,7 @@
|
|
|
6386
6757
|
e.preventDefault();
|
|
6387
6758
|
}
|
|
6388
6759
|
},
|
|
6389
|
-
"class": [form.className, form["class"], 'form-create'],
|
|
6760
|
+
"class": [form.className, form["class"], 'form-create', this.options.preview ? 'is-preview' : ''],
|
|
6390
6761
|
style: form.style,
|
|
6391
6762
|
type: 'form'
|
|
6392
6763
|
};
|
|
@@ -6406,7 +6777,7 @@
|
|
|
6406
6777
|
render: function render(children) {
|
|
6407
6778
|
var _this2 = this;
|
|
6408
6779
|
|
|
6409
|
-
if (children.slotLen()) {
|
|
6780
|
+
if (children.slotLen() && !this.options.preview) {
|
|
6410
6781
|
children.setSlot(undefined, function () {
|
|
6411
6782
|
return _this2.makeFormBtn();
|
|
6412
6783
|
});
|
|
@@ -6431,7 +6802,7 @@
|
|
|
6431
6802
|
label: isTitle ? rule.title.title : undefined
|
|
6432
6803
|
}, tidyRule(rule.wrap || {})), {}, {
|
|
6433
6804
|
prop: ctx.id,
|
|
6434
|
-
rules:
|
|
6805
|
+
rules: ctx.injectValidate()
|
|
6435
6806
|
}),
|
|
6436
6807
|
"class": rule.className,
|
|
6437
6808
|
key: "".concat(uni, "fi"),
|
|
@@ -6693,7 +7064,7 @@
|
|
|
6693
7064
|
return maker;
|
|
6694
7065
|
}
|
|
6695
7066
|
|
|
6696
|
-
var css_248z = ".form-create .form-create .el-form-item{margin-bottom:22px}.form-create{width:100%}";
|
|
7067
|
+
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}.form-create.is-preview .el-form-item.is-required>.el-form-item__label-wrap>.el-form-item__label:before,.form-create.is-preview .el-form-item.is-required>.el-form-item__label:before{content:\"\"!important}";
|
|
6697
7068
|
styleInject(css_248z);
|
|
6698
7069
|
|
|
6699
7070
|
function tidyBtnProp(btn, def) {
|
|
@@ -6876,6 +7247,7 @@
|
|
|
6876
7247
|
|
|
6877
7248
|
if (val.required === false) {
|
|
6878
7249
|
inject.clearProp();
|
|
7250
|
+
api.clearValidateState([rule.field]);
|
|
6879
7251
|
} else {
|
|
6880
7252
|
var validate = _objectSpread2({
|
|
6881
7253
|
required: true,
|
|
@@ -6946,7 +7318,7 @@
|
|
|
6946
7318
|
function elmFormCreate() {
|
|
6947
7319
|
return FormCreateFactory({
|
|
6948
7320
|
ui: 'element-ui',
|
|
6949
|
-
version: '3.1.
|
|
7321
|
+
version: '3.1.30',
|
|
6950
7322
|
manager: manager,
|
|
6951
7323
|
extendApi: extendApi,
|
|
6952
7324
|
install: install,
|