@form-create/view-design 2.5.35 → 2.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form-create.js +318 -212
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +4 -4
package/dist/form-create.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/view-design v2.5.
|
|
2
|
+
* @form-create/view-design v2.5.37
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -1473,14 +1473,6 @@
|
|
|
1473
1473
|
},
|
|
1474
1474
|
deep: true
|
|
1475
1475
|
},
|
|
1476
|
-
disabled: function disabled(n) {
|
|
1477
|
-
if (this.syncDisabled) {
|
|
1478
|
-
var lst = this.cacheRule;
|
|
1479
|
-
Object.keys(lst).forEach(function (k) {
|
|
1480
|
-
lst[k].$f.disabled(n);
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
},
|
|
1484
1476
|
expand: function expand(n) {
|
|
1485
1477
|
var d = n - this.value.length;
|
|
1486
1478
|
if (d > 0) {
|
|
@@ -1585,9 +1577,6 @@
|
|
|
1585
1577
|
var _this5 = this;
|
|
1586
1578
|
this.cacheRule[key].$f = $f;
|
|
1587
1579
|
this.$nextTick(function () {
|
|
1588
|
-
if (_this5.syncDisabled) {
|
|
1589
|
-
$f.disabled(_this5.disabled);
|
|
1590
|
-
}
|
|
1591
1580
|
_this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
|
|
1592
1581
|
});
|
|
1593
1582
|
},
|
|
@@ -1759,6 +1748,7 @@
|
|
|
1759
1748
|
}
|
|
1760
1749
|
}, {}, {
|
|
1761
1750
|
"props": {
|
|
1751
|
+
disabled: disabled,
|
|
1762
1752
|
inFor: true,
|
|
1763
1753
|
value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
|
|
1764
1754
|
rule: rule,
|
|
@@ -1811,9 +1801,6 @@
|
|
|
1811
1801
|
};
|
|
1812
1802
|
},
|
|
1813
1803
|
watch: {
|
|
1814
|
-
disabled: function disabled(n) {
|
|
1815
|
-
this.syncDisabled && this.cacheRule.$f.disabled(n);
|
|
1816
|
-
},
|
|
1817
1804
|
value: function value(n) {
|
|
1818
1805
|
this.setValue(n);
|
|
1819
1806
|
}
|
|
@@ -1847,7 +1834,6 @@
|
|
|
1847
1834
|
var _this = this;
|
|
1848
1835
|
this.cacheRule.$f = $f;
|
|
1849
1836
|
this.$nextTick(function () {
|
|
1850
|
-
_this.syncDisabled && $f.disabled(_this.disabled);
|
|
1851
1837
|
_this.$emit('itemMounted', $f);
|
|
1852
1838
|
});
|
|
1853
1839
|
},
|
|
@@ -1878,6 +1864,7 @@
|
|
|
1878
1864
|
"props": {
|
|
1879
1865
|
rule: rule,
|
|
1880
1866
|
option: options,
|
|
1867
|
+
disabled: this.disabled,
|
|
1881
1868
|
extendOption: true
|
|
1882
1869
|
}
|
|
1883
1870
|
}]));
|
|
@@ -1927,7 +1914,10 @@
|
|
|
1927
1914
|
}
|
|
1928
1915
|
},
|
|
1929
1916
|
extendOption: Boolean,
|
|
1930
|
-
disabled:
|
|
1917
|
+
disabled: {
|
|
1918
|
+
type: Boolean,
|
|
1919
|
+
"default": undefined
|
|
1920
|
+
},
|
|
1931
1921
|
value: Object,
|
|
1932
1922
|
api: Object,
|
|
1933
1923
|
name: String,
|
|
@@ -1990,8 +1980,8 @@
|
|
|
1990
1980
|
this.formCreate.$handle.reloadRule(n);
|
|
1991
1981
|
this._renderRule();
|
|
1992
1982
|
},
|
|
1993
|
-
disabled: function disabled(
|
|
1994
|
-
this.$f.
|
|
1983
|
+
disabled: function disabled() {
|
|
1984
|
+
this.$f.refresh();
|
|
1995
1985
|
}
|
|
1996
1986
|
},
|
|
1997
1987
|
beforeCreate: function beforeCreate() {
|
|
@@ -2136,7 +2126,7 @@
|
|
|
2136
2126
|
var $TX = '$FNX:';
|
|
2137
2127
|
var FUNCTION = 'function';
|
|
2138
2128
|
function toJson(obj, space) {
|
|
2139
|
-
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
2129
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2140
2130
|
if (val && val._isVue === true) return undefined;
|
|
2141
2131
|
if (_typeof(val) !== FUNCTION) {
|
|
2142
2132
|
return val;
|
|
@@ -2247,6 +2237,61 @@
|
|
|
2247
2237
|
}
|
|
2248
2238
|
return def;
|
|
2249
2239
|
}
|
|
2240
|
+
var changeType = function changeType(a, b) {
|
|
2241
|
+
if (typeof a === 'string') {
|
|
2242
|
+
return String(b);
|
|
2243
|
+
} else if (typeof a === 'number') {
|
|
2244
|
+
return Number(b);
|
|
2245
|
+
}
|
|
2246
|
+
return b;
|
|
2247
|
+
};
|
|
2248
|
+
var condition = {
|
|
2249
|
+
'==': function _(a, b) {
|
|
2250
|
+
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2251
|
+
},
|
|
2252
|
+
'!=': function _(a, b) {
|
|
2253
|
+
return !condition['=='](a, b);
|
|
2254
|
+
},
|
|
2255
|
+
'>': function _(a, b) {
|
|
2256
|
+
return a > b;
|
|
2257
|
+
},
|
|
2258
|
+
'>=': function _(a, b) {
|
|
2259
|
+
return a >= b;
|
|
2260
|
+
},
|
|
2261
|
+
'<': function _(a, b) {
|
|
2262
|
+
return a < b;
|
|
2263
|
+
},
|
|
2264
|
+
'<=': function _(a, b) {
|
|
2265
|
+
return a <= b;
|
|
2266
|
+
},
|
|
2267
|
+
on: function on(a, b) {
|
|
2268
|
+
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2269
|
+
},
|
|
2270
|
+
notOn: function notOn(a, b) {
|
|
2271
|
+
return !condition.on(a, b);
|
|
2272
|
+
},
|
|
2273
|
+
"in": function _in(a, b) {
|
|
2274
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2275
|
+
},
|
|
2276
|
+
notIn: function notIn(a, b) {
|
|
2277
|
+
return !condition["in"](a, b);
|
|
2278
|
+
},
|
|
2279
|
+
between: function between(a, b) {
|
|
2280
|
+
return a > b[0] && a < b[1];
|
|
2281
|
+
},
|
|
2282
|
+
notBetween: function notBetween(a, b) {
|
|
2283
|
+
return a < b[0] || a > b[1];
|
|
2284
|
+
},
|
|
2285
|
+
empty: function empty(a) {
|
|
2286
|
+
return is.empty(a);
|
|
2287
|
+
},
|
|
2288
|
+
notEmpty: function notEmpty(a) {
|
|
2289
|
+
return !is.empty(a);
|
|
2290
|
+
},
|
|
2291
|
+
pattern: function pattern(a, b) {
|
|
2292
|
+
return new RegExp(b, 'g').test(a);
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2250
2295
|
|
|
2251
2296
|
function baseRule() {
|
|
2252
2297
|
return {
|
|
@@ -2328,6 +2373,92 @@
|
|
|
2328
2373
|
};
|
|
2329
2374
|
}
|
|
2330
2375
|
|
|
2376
|
+
function getError(action, option, xhr) {
|
|
2377
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2378
|
+
var err = new Error(msg);
|
|
2379
|
+
err.status = xhr.status;
|
|
2380
|
+
err.url = action;
|
|
2381
|
+
return err;
|
|
2382
|
+
}
|
|
2383
|
+
function getBody(xhr) {
|
|
2384
|
+
var text = xhr.responseText || xhr.response;
|
|
2385
|
+
if (!text) {
|
|
2386
|
+
return text;
|
|
2387
|
+
}
|
|
2388
|
+
try {
|
|
2389
|
+
return JSON.parse(text);
|
|
2390
|
+
} catch (e) {
|
|
2391
|
+
return text;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
function fetch(option) {
|
|
2395
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
var xhr = new XMLHttpRequest();
|
|
2399
|
+
var action = option.action;
|
|
2400
|
+
xhr.onerror = function error(e) {
|
|
2401
|
+
option.onError(e);
|
|
2402
|
+
};
|
|
2403
|
+
xhr.onload = function onload() {
|
|
2404
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2405
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2406
|
+
}
|
|
2407
|
+
option.onSuccess(getBody(xhr));
|
|
2408
|
+
};
|
|
2409
|
+
xhr.open(option.method || 'get', action, true);
|
|
2410
|
+
var formData;
|
|
2411
|
+
if (option.data) {
|
|
2412
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2413
|
+
formData = new FormData();
|
|
2414
|
+
Object.keys(option.data).map(function (key) {
|
|
2415
|
+
formData.append(key, option.data[key]);
|
|
2416
|
+
});
|
|
2417
|
+
} else {
|
|
2418
|
+
formData = JSON.stringify(option.data);
|
|
2419
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2423
|
+
xhr.withCredentials = true;
|
|
2424
|
+
}
|
|
2425
|
+
var headers = option.headers || {};
|
|
2426
|
+
Object.keys(headers).forEach(function (item) {
|
|
2427
|
+
if (headers[item] !== null) {
|
|
2428
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
xhr.send(formData);
|
|
2432
|
+
}
|
|
2433
|
+
function asyncFetch(config) {
|
|
2434
|
+
return new Promise(function (resolve, reject) {
|
|
2435
|
+
fetch(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2436
|
+
onSuccess: function onSuccess(res) {
|
|
2437
|
+
var fn = function fn(v) {
|
|
2438
|
+
return v;
|
|
2439
|
+
};
|
|
2440
|
+
var parse = parseFn(config.parse);
|
|
2441
|
+
if (is.Function(parse)) {
|
|
2442
|
+
fn = parse;
|
|
2443
|
+
} else if (parse && is.String(parse)) {
|
|
2444
|
+
fn = function fn(v) {
|
|
2445
|
+
parse.split('.').forEach(function (k) {
|
|
2446
|
+
if (v) {
|
|
2447
|
+
v = v[k];
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
return v;
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
resolve(fn(res));
|
|
2454
|
+
},
|
|
2455
|
+
onError: function onError(err) {
|
|
2456
|
+
reject(err);
|
|
2457
|
+
}
|
|
2458
|
+
}));
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2331
2462
|
function copy(value) {
|
|
2332
2463
|
return deepCopy(value);
|
|
2333
2464
|
}
|
|
@@ -2384,7 +2515,7 @@
|
|
|
2384
2515
|
if (!ctx) return initial;
|
|
2385
2516
|
initial[ctx.field] = copy(ctx.rule.value);
|
|
2386
2517
|
return initial;
|
|
2387
|
-
}, h.options.appendValue ? copy(h.appendData) : {});
|
|
2518
|
+
}, h.options.appendValue !== false ? copy(h.appendData) : {});
|
|
2388
2519
|
},
|
|
2389
2520
|
getValue: function getValue(field) {
|
|
2390
2521
|
var ctx = h.getFieldCtx(field);
|
|
@@ -2609,6 +2740,21 @@
|
|
|
2609
2740
|
return origin ? ctx.origin : ctx.rule;
|
|
2610
2741
|
}
|
|
2611
2742
|
},
|
|
2743
|
+
getRenderRule: function getRenderRule(id) {
|
|
2744
|
+
var ctx = h.getCtx(id);
|
|
2745
|
+
if (ctx) {
|
|
2746
|
+
return ctx.prop;
|
|
2747
|
+
}
|
|
2748
|
+
},
|
|
2749
|
+
getRefRule: function getRefRule(id) {
|
|
2750
|
+
var ctxs = h.getCtxs(id);
|
|
2751
|
+
if (ctxs && ctxs.length) {
|
|
2752
|
+
var rules = ctxs.map(function (ctx) {
|
|
2753
|
+
return ctx.rule;
|
|
2754
|
+
});
|
|
2755
|
+
return rules.length === 1 ? rules[0] : rules;
|
|
2756
|
+
}
|
|
2757
|
+
},
|
|
2612
2758
|
setEffect: function setEffect(id, attr, value) {
|
|
2613
2759
|
var ctx = h.getCtx(id);
|
|
2614
2760
|
if (ctx && attr) {
|
|
@@ -2715,12 +2861,25 @@
|
|
|
2715
2861
|
deferSyncValue: function deferSyncValue(fn, sync) {
|
|
2716
2862
|
h.deferSyncValue(fn, sync);
|
|
2717
2863
|
},
|
|
2864
|
+
fetch: function fetch(opt) {
|
|
2865
|
+
return new Promise(function (resolve, reject) {
|
|
2866
|
+
h.beforeFetch(opt).then(function () {
|
|
2867
|
+
return asyncFetch(opt).then(resolve)["catch"](reject);
|
|
2868
|
+
});
|
|
2869
|
+
});
|
|
2870
|
+
},
|
|
2871
|
+
getData: function getData(id, def) {
|
|
2872
|
+
return h.fc.getData(id, def);
|
|
2873
|
+
},
|
|
2874
|
+
setData: function setData(id, data) {
|
|
2875
|
+
return h.fc.setData(id, data);
|
|
2876
|
+
},
|
|
2718
2877
|
helper: {
|
|
2719
2878
|
tidyFields: tidyFields,
|
|
2720
2879
|
props: props
|
|
2721
2880
|
}
|
|
2722
2881
|
};
|
|
2723
|
-
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2882
|
+
['on', 'once', 'off', 'set', 'emit'].forEach(function (n) {
|
|
2724
2883
|
api[n] = function () {
|
|
2725
2884
|
var _h$vm2;
|
|
2726
2885
|
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
@@ -3106,6 +3265,7 @@
|
|
|
3106
3265
|
children: [],
|
|
3107
3266
|
prop: {},
|
|
3108
3267
|
preview: false,
|
|
3268
|
+
id: ctx.id,
|
|
3109
3269
|
field: ctx.field,
|
|
3110
3270
|
rule: ctx.rule,
|
|
3111
3271
|
input: ctx.input
|
|
@@ -3125,13 +3285,13 @@
|
|
|
3125
3285
|
});
|
|
3126
3286
|
return inject;
|
|
3127
3287
|
},
|
|
3128
|
-
ctxProp: function ctxProp(ctx
|
|
3288
|
+
ctxProp: function ctxProp(ctx) {
|
|
3129
3289
|
var _this8 = this;
|
|
3130
3290
|
var ref = ctx.ref,
|
|
3131
3291
|
key = ctx.key,
|
|
3132
3292
|
rule = ctx.rule;
|
|
3133
|
-
this.$manager.mergeProp(ctx
|
|
3134
|
-
ctx.parser.mergeProp(ctx
|
|
3293
|
+
this.$manager.mergeProp(ctx);
|
|
3294
|
+
ctx.parser.mergeProp(ctx);
|
|
3135
3295
|
var props = [{
|
|
3136
3296
|
ref: ref,
|
|
3137
3297
|
key: rule.key || "".concat(key, "fc"),
|
|
@@ -3151,7 +3311,10 @@
|
|
|
3151
3311
|
}
|
|
3152
3312
|
}
|
|
3153
3313
|
}];
|
|
3154
|
-
if (
|
|
3314
|
+
if (ctx.input) {
|
|
3315
|
+
if (this.vm.$props.disabled === true) {
|
|
3316
|
+
ctx.prop.props.disabled = true;
|
|
3317
|
+
}
|
|
3155
3318
|
ctx.prop.model = {
|
|
3156
3319
|
value: this.$handle.getFormData(ctx),
|
|
3157
3320
|
callback: function callback(value) {
|
|
@@ -3309,16 +3472,17 @@
|
|
|
3309
3472
|
inject = rule.inject;
|
|
3310
3473
|
var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
|
|
3311
3474
|
if (is.trueArray(emit)) {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3475
|
+
emit.forEach(function (eventName) {
|
|
3476
|
+
if (!eventName) return;
|
|
3477
|
+
var eventInject;
|
|
3478
|
+
var emitKey = emitPrefix || field || name;
|
|
3479
|
+
if (is.Object(eventName)) {
|
|
3480
|
+
eventInject = eventName.inject;
|
|
3481
|
+
eventName = eventName.name;
|
|
3482
|
+
emitKey = eventName.prefix || emitKey;
|
|
3483
|
+
}
|
|
3484
|
+
if (emitKey) {
|
|
3485
|
+
if (!on) emitKey = "native-".concat(emitKey);
|
|
3322
3486
|
var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
|
|
3323
3487
|
var fn = function fn() {
|
|
3324
3488
|
var _this2$vm, _this2$vm2;
|
|
@@ -3335,8 +3499,8 @@
|
|
|
3335
3499
|
var _inject = eventInject || inject || _this2.options.injectEvent;
|
|
3336
3500
|
event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
|
|
3337
3501
|
}
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3502
|
+
}
|
|
3503
|
+
});
|
|
3340
3504
|
}
|
|
3341
3505
|
ctx.computed[on ? 'on' : 'nativeOn'] = event;
|
|
3342
3506
|
return event;
|
|
@@ -3512,6 +3676,30 @@
|
|
|
3512
3676
|
return _this.payload[k];
|
|
3513
3677
|
})), [this.computed]));
|
|
3514
3678
|
},
|
|
3679
|
+
injectValidate: function injectValidate() {
|
|
3680
|
+
var _this2 = this;
|
|
3681
|
+
return toArray(this.prop.validate).map(function (item) {
|
|
3682
|
+
if (is.Function(item.validator)) {
|
|
3683
|
+
var temp = _objectSpread2({}, item);
|
|
3684
|
+
var that = _this2;
|
|
3685
|
+
temp.validator = function () {
|
|
3686
|
+
var _item$validator;
|
|
3687
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3688
|
+
args[_key] = arguments[_key];
|
|
3689
|
+
}
|
|
3690
|
+
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
3691
|
+
that: this,
|
|
3692
|
+
id: that.id,
|
|
3693
|
+
field: that.field,
|
|
3694
|
+
rule: that.rule,
|
|
3695
|
+
api: that.$handle.api
|
|
3696
|
+
}].concat(args));
|
|
3697
|
+
};
|
|
3698
|
+
return temp;
|
|
3699
|
+
}
|
|
3700
|
+
return item;
|
|
3701
|
+
});
|
|
3702
|
+
},
|
|
3515
3703
|
check: function check(handle) {
|
|
3516
3704
|
return this.vm === handle.vm;
|
|
3517
3705
|
},
|
|
@@ -3560,12 +3748,12 @@
|
|
|
3560
3748
|
this.ctrlRule = [];
|
|
3561
3749
|
},
|
|
3562
3750
|
rm: function rm() {
|
|
3563
|
-
var
|
|
3751
|
+
var _this3 = this;
|
|
3564
3752
|
var _rm = function _rm() {
|
|
3565
|
-
var index =
|
|
3753
|
+
var index = _this3.root.indexOf(_this3.origin);
|
|
3566
3754
|
if (index > -1) {
|
|
3567
|
-
|
|
3568
|
-
|
|
3755
|
+
_this3.root.splice(index, 1);
|
|
3756
|
+
_this3.$handle && _this3.$handle.refresh();
|
|
3569
3757
|
}
|
|
3570
3758
|
};
|
|
3571
3759
|
if (this.deleted) {
|
|
@@ -3573,14 +3761,14 @@
|
|
|
3573
3761
|
return;
|
|
3574
3762
|
}
|
|
3575
3763
|
this.$handle.noWatch(function () {
|
|
3576
|
-
|
|
3577
|
-
|
|
3764
|
+
_this3.$handle.deferSyncValue(function () {
|
|
3765
|
+
_this3.rmCtrl();
|
|
3578
3766
|
_rm();
|
|
3579
|
-
|
|
3580
|
-
extend(
|
|
3767
|
+
_this3.$handle.rmCtx(_this3);
|
|
3768
|
+
extend(_this3, {
|
|
3581
3769
|
root: []
|
|
3582
3770
|
});
|
|
3583
|
-
},
|
|
3771
|
+
}, _this3.input);
|
|
3584
3772
|
});
|
|
3585
3773
|
},
|
|
3586
3774
|
update: function update(handle, init) {
|
|
@@ -3601,73 +3789,6 @@
|
|
|
3601
3789
|
}
|
|
3602
3790
|
});
|
|
3603
3791
|
|
|
3604
|
-
var condition = {
|
|
3605
|
-
'==': function _(b) {
|
|
3606
|
-
return function (a) {
|
|
3607
|
-
return a === b;
|
|
3608
|
-
};
|
|
3609
|
-
},
|
|
3610
|
-
'!=': function _(b) {
|
|
3611
|
-
return function (a) {
|
|
3612
|
-
return a !== b;
|
|
3613
|
-
};
|
|
3614
|
-
},
|
|
3615
|
-
'<>': function _(b) {
|
|
3616
|
-
return function (a) {
|
|
3617
|
-
return a !== b;
|
|
3618
|
-
};
|
|
3619
|
-
},
|
|
3620
|
-
'>': function _(b) {
|
|
3621
|
-
return function (a) {
|
|
3622
|
-
return a > b;
|
|
3623
|
-
};
|
|
3624
|
-
},
|
|
3625
|
-
'>=': function _(b) {
|
|
3626
|
-
return function (a) {
|
|
3627
|
-
return a >= b;
|
|
3628
|
-
};
|
|
3629
|
-
},
|
|
3630
|
-
'<': function _(b) {
|
|
3631
|
-
return function (a) {
|
|
3632
|
-
return a < b;
|
|
3633
|
-
};
|
|
3634
|
-
},
|
|
3635
|
-
'<=': function _(b) {
|
|
3636
|
-
return function (a) {
|
|
3637
|
-
return a <= b;
|
|
3638
|
-
};
|
|
3639
|
-
},
|
|
3640
|
-
'in': function _in(b) {
|
|
3641
|
-
return function (a) {
|
|
3642
|
-
return b && b.indexOf && b.indexOf(a) > -1;
|
|
3643
|
-
};
|
|
3644
|
-
},
|
|
3645
|
-
'on': function on(b) {
|
|
3646
|
-
return function (a) {
|
|
3647
|
-
return a && a.indexOf && a.indexOf(b) > -1;
|
|
3648
|
-
};
|
|
3649
|
-
},
|
|
3650
|
-
'notIn': function notIn(b) {
|
|
3651
|
-
return function (a) {
|
|
3652
|
-
return !condition["in"](b)(a);
|
|
3653
|
-
};
|
|
3654
|
-
},
|
|
3655
|
-
'notOn': function notOn(b) {
|
|
3656
|
-
return function (a) {
|
|
3657
|
-
return !condition.on(b)(a);
|
|
3658
|
-
};
|
|
3659
|
-
},
|
|
3660
|
-
'between': function between(b) {
|
|
3661
|
-
return function (a) {
|
|
3662
|
-
return a > b[0] && a < b[1];
|
|
3663
|
-
};
|
|
3664
|
-
},
|
|
3665
|
-
'notBetween': function notBetween(b) {
|
|
3666
|
-
return function (a) {
|
|
3667
|
-
return a < b[0] || a > b[1];
|
|
3668
|
-
};
|
|
3669
|
-
}
|
|
3670
|
-
};
|
|
3671
3792
|
function useLoader(Handler) {
|
|
3672
3793
|
extend(Handler.prototype, {
|
|
3673
3794
|
nextRefresh: function nextRefresh(fn) {
|
|
@@ -3819,7 +3940,7 @@
|
|
|
3819
3940
|
}
|
|
3820
3941
|
if (!ctx) {
|
|
3821
3942
|
var _rule2 = _this6.parseRule(_rule);
|
|
3822
|
-
ctx = new RuleContext(_this6, _rule2,
|
|
3943
|
+
ctx = new RuleContext(_this6, _rule2, defaultValue);
|
|
3823
3944
|
_this6.bindParser(ctx);
|
|
3824
3945
|
} else {
|
|
3825
3946
|
if (ctx.originType !== ctx.rule.type) {
|
|
@@ -3872,7 +3993,9 @@
|
|
|
3872
3993
|
if (!controls.length) return false;
|
|
3873
3994
|
var _loop = function _loop(i) {
|
|
3874
3995
|
var control = controls[i],
|
|
3875
|
-
handleFn = control.handle ||
|
|
3996
|
+
handleFn = control.handle || function (val) {
|
|
3997
|
+
return (condition[control.condition || '=='] || condition['=='])(val, control.value);
|
|
3998
|
+
};
|
|
3876
3999
|
if (!is.trueArray(control.rule)) return "continue";
|
|
3877
4000
|
var data = _objectSpread2(_objectSpread2({}, control), {}, {
|
|
3878
4001
|
valid: invoke(function () {
|
|
@@ -4034,6 +4157,11 @@
|
|
|
4034
4157
|
this.valueChange(ctx, value);
|
|
4035
4158
|
this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
4036
4159
|
this.effect(ctx, 'value');
|
|
4160
|
+
this.emitEvent('change', ctx.field, value, {
|
|
4161
|
+
rule: ctx.origin,
|
|
4162
|
+
api: this.api,
|
|
4163
|
+
setFlag: setFlag || false
|
|
4164
|
+
});
|
|
4037
4165
|
},
|
|
4038
4166
|
onInput: function onInput(ctx, value) {
|
|
4039
4167
|
var val;
|
|
@@ -4066,7 +4194,7 @@
|
|
|
4066
4194
|
handle.configurable = true;
|
|
4067
4195
|
initial[field] = handle;
|
|
4068
4196
|
return initial;
|
|
4069
|
-
}, this.options.appendValue ? Object.keys(this.appendData).reduce(function (initial, field) {
|
|
4197
|
+
}, this.options.appendValue !== false ? Object.keys(this.appendData).reduce(function (initial, field) {
|
|
4070
4198
|
initial[field] = {
|
|
4071
4199
|
enumerable: true,
|
|
4072
4200
|
configurable: true,
|
|
@@ -4122,7 +4250,7 @@
|
|
|
4122
4250
|
if (this.deferSyncFn) {
|
|
4123
4251
|
return this.deferSyncFn.sync = true;
|
|
4124
4252
|
}
|
|
4125
|
-
this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
|
|
4253
|
+
this.vm._updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue !== false ? this.appendData : {}), this.form));
|
|
4126
4254
|
},
|
|
4127
4255
|
isChange: function isChange(ctx, value) {
|
|
4128
4256
|
return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value === null ? undefined : value, strFn);
|
|
@@ -4130,12 +4258,13 @@
|
|
|
4130
4258
|
isQuote: function isQuote(ctx, value) {
|
|
4131
4259
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
4132
4260
|
},
|
|
4133
|
-
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
4261
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
4134
4262
|
var _this4 = this;
|
|
4135
4263
|
if (is.Function(ctx.rule.update)) {
|
|
4136
4264
|
var state = invoke(function () {
|
|
4137
4265
|
return ctx.rule.update(val, ctx.origin, _this4.api, {
|
|
4138
|
-
origin: origin || 'change'
|
|
4266
|
+
origin: origin || 'change',
|
|
4267
|
+
linkField: field
|
|
4139
4268
|
});
|
|
4140
4269
|
});
|
|
4141
4270
|
if (state === undefined) return;
|
|
@@ -4146,21 +4275,21 @@
|
|
|
4146
4275
|
this.refreshRule(ctx, val);
|
|
4147
4276
|
this.bus.$emit('change-' + ctx.field, val);
|
|
4148
4277
|
},
|
|
4149
|
-
refreshRule: function refreshRule(ctx, val, origin) {
|
|
4278
|
+
refreshRule: function refreshRule(ctx, val, origin, field) {
|
|
4150
4279
|
if (this.refreshControl(ctx)) {
|
|
4151
4280
|
this.$render.clearCacheAll();
|
|
4152
4281
|
this.loadRule();
|
|
4153
4282
|
this.vm.$emit('update', this.api);
|
|
4154
4283
|
this.refresh();
|
|
4155
4284
|
}
|
|
4156
|
-
this.refreshUpdate(ctx, val, origin);
|
|
4285
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
4157
4286
|
},
|
|
4158
4287
|
appendLink: function appendLink(ctx) {
|
|
4159
4288
|
var _this5 = this;
|
|
4160
4289
|
var link = ctx.rule.link;
|
|
4161
4290
|
is.trueArray(link) && link.forEach(function (field) {
|
|
4162
4291
|
var fn = function fn() {
|
|
4163
|
-
return _this5.refreshRule(ctx, ctx.rule.value, 'link');
|
|
4292
|
+
return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
4164
4293
|
};
|
|
4165
4294
|
_this5.bus.$on('change-' + field, fn);
|
|
4166
4295
|
ctx.linkOn.push(function () {
|
|
@@ -4391,12 +4520,22 @@
|
|
|
4391
4520
|
}
|
|
4392
4521
|
},
|
|
4393
4522
|
lifecycle: function lifecycle(name) {
|
|
4394
|
-
var _this2 = this;
|
|
4395
|
-
var fn = this.options[name];
|
|
4396
|
-
is.Function(fn) && invoke(function () {
|
|
4397
|
-
return fn(_this2.api);
|
|
4398
|
-
});
|
|
4399
4523
|
this.vm.$emit(name, this.api);
|
|
4524
|
+
this.emitEvent(name, this.api);
|
|
4525
|
+
},
|
|
4526
|
+
emitEvent: function emitEvent(name) {
|
|
4527
|
+
var _this$bus;
|
|
4528
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4529
|
+
args[_key - 1] = arguments[_key];
|
|
4530
|
+
}
|
|
4531
|
+
var _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
4532
|
+
if (_fn) {
|
|
4533
|
+
var fn = parseFn(_fn);
|
|
4534
|
+
is.Function(fn) && invoke(function () {
|
|
4535
|
+
return fn.apply(void 0, args);
|
|
4536
|
+
});
|
|
4537
|
+
}
|
|
4538
|
+
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
4400
4539
|
}
|
|
4401
4540
|
});
|
|
4402
4541
|
}
|
|
@@ -4598,7 +4737,23 @@
|
|
|
4598
4737
|
this.usePage();
|
|
4599
4738
|
this.loadRule();
|
|
4600
4739
|
this.$manager.__init();
|
|
4740
|
+
this.lifecycle('created');
|
|
4601
4741
|
this.vm.$set(this.vm, 'formData', this.formData);
|
|
4742
|
+
},
|
|
4743
|
+
beforeFetch: function beforeFetch(opt) {
|
|
4744
|
+
var _this2 = this;
|
|
4745
|
+
return new Promise(function (resolve) {
|
|
4746
|
+
var source = _this2.options.beforeFetch && invoke(function () {
|
|
4747
|
+
return _this2.options.beforeFetch(opt, {
|
|
4748
|
+
api: _this2.api
|
|
4749
|
+
});
|
|
4750
|
+
});
|
|
4751
|
+
if (source && is.Function(source.then)) {
|
|
4752
|
+
source.then(resolve);
|
|
4753
|
+
} else {
|
|
4754
|
+
resolve();
|
|
4755
|
+
}
|
|
4756
|
+
});
|
|
4602
4757
|
}
|
|
4603
4758
|
});
|
|
4604
4759
|
useInject(Handler);
|
|
@@ -4610,64 +4765,6 @@
|
|
|
4610
4765
|
useLifecycle(Handler);
|
|
4611
4766
|
useEffect(Handler);
|
|
4612
4767
|
|
|
4613
|
-
function getError(action, option, xhr) {
|
|
4614
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
4615
|
-
var err = new Error(msg);
|
|
4616
|
-
err.status = xhr.status;
|
|
4617
|
-
err.url = action;
|
|
4618
|
-
return err;
|
|
4619
|
-
}
|
|
4620
|
-
function getBody(xhr) {
|
|
4621
|
-
var text = xhr.responseText || xhr.response;
|
|
4622
|
-
if (!text) {
|
|
4623
|
-
return text;
|
|
4624
|
-
}
|
|
4625
|
-
try {
|
|
4626
|
-
return JSON.parse(text);
|
|
4627
|
-
} catch (e) {
|
|
4628
|
-
return text;
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
function fetch(option) {
|
|
4632
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
4633
|
-
return;
|
|
4634
|
-
}
|
|
4635
|
-
var xhr = new XMLHttpRequest();
|
|
4636
|
-
var action = option.action;
|
|
4637
|
-
xhr.onerror = function error(e) {
|
|
4638
|
-
option.onError(e);
|
|
4639
|
-
};
|
|
4640
|
-
xhr.onload = function onload() {
|
|
4641
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
4642
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
4643
|
-
}
|
|
4644
|
-
option.onSuccess(getBody(xhr));
|
|
4645
|
-
};
|
|
4646
|
-
xhr.open(option.method || 'get', action, true);
|
|
4647
|
-
var formData;
|
|
4648
|
-
if (option.data) {
|
|
4649
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
4650
|
-
formData = new FormData();
|
|
4651
|
-
Object.keys(option.data).map(function (key) {
|
|
4652
|
-
formData.append(key, option.data[key]);
|
|
4653
|
-
});
|
|
4654
|
-
} else {
|
|
4655
|
-
formData = JSON.stringify(option.data);
|
|
4656
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4659
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
4660
|
-
xhr.withCredentials = true;
|
|
4661
|
-
}
|
|
4662
|
-
var headers = option.headers || {};
|
|
4663
|
-
Object.keys(headers).forEach(function (item) {
|
|
4664
|
-
if (headers[item] !== null) {
|
|
4665
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
4666
|
-
}
|
|
4667
|
-
});
|
|
4668
|
-
xhr.send(formData);
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
4768
|
var NAME$9 = 'fcFragment';
|
|
4672
4769
|
var fragment = {
|
|
4673
4770
|
name: NAME$9,
|
|
@@ -4825,7 +4922,7 @@
|
|
|
4825
4922
|
var value = undefined;
|
|
4826
4923
|
if (attr.attr) {
|
|
4827
4924
|
value = fc.loadData[attr.attr] || attr["default"];
|
|
4828
|
-
if (attr.copy) {
|
|
4925
|
+
if (attr.copy !== false) {
|
|
4829
4926
|
value = deepCopy(value);
|
|
4830
4927
|
}
|
|
4831
4928
|
}
|
|
@@ -4910,6 +5007,7 @@
|
|
|
4910
5007
|
set(undefined);
|
|
4911
5008
|
return;
|
|
4912
5009
|
}
|
|
5010
|
+
option = deepCopy(option);
|
|
4913
5011
|
if (!option.to) {
|
|
4914
5012
|
option.to = 'options';
|
|
4915
5013
|
}
|
|
@@ -4927,7 +5025,7 @@
|
|
|
4927
5025
|
onSuccess: function onSuccess(body, flag) {
|
|
4928
5026
|
if (check()) return;
|
|
4929
5027
|
var fn = function fn(v) {
|
|
4930
|
-
return flag ? v : v.data;
|
|
5028
|
+
return flag ? v : hasProperty(v, 'data') ? v.data : v;
|
|
4931
5029
|
};
|
|
4932
5030
|
if (is.Function(option.parse)) {
|
|
4933
5031
|
fn = option.parse;
|
|
@@ -4952,25 +5050,24 @@
|
|
|
4952
5050
|
})(e, rule, api);
|
|
4953
5051
|
}
|
|
4954
5052
|
});
|
|
4955
|
-
fc.
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
}
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
api: api
|
|
5053
|
+
fc.$handle.beforeFetch(config, {
|
|
5054
|
+
rule: rule,
|
|
5055
|
+
api: api
|
|
5056
|
+
}).then(function () {
|
|
5057
|
+
if (is.Function(option.action)) {
|
|
5058
|
+
option.action(rule, api).then(function (val) {
|
|
5059
|
+
config.onSuccess(val, true);
|
|
5060
|
+
})["catch"](function (e) {
|
|
5061
|
+
config.onError(e);
|
|
5062
|
+
});
|
|
5063
|
+
return;
|
|
5064
|
+
}
|
|
5065
|
+
invoke(function () {
|
|
5066
|
+
return fc.create.fetch(config, {
|
|
5067
|
+
inject: inject,
|
|
5068
|
+
rule: rule,
|
|
5069
|
+
api: api
|
|
5070
|
+
});
|
|
4974
5071
|
});
|
|
4975
5072
|
});
|
|
4976
5073
|
}
|
|
@@ -4990,6 +5087,7 @@
|
|
|
4990
5087
|
var val = parseVal(inject.getValue());
|
|
4991
5088
|
if (val.required === false) {
|
|
4992
5089
|
inject.clearProp();
|
|
5090
|
+
api.clearValidateState([rule.field]);
|
|
4993
5091
|
} else {
|
|
4994
5092
|
var validate = _objectSpread2({
|
|
4995
5093
|
required: true,
|
|
@@ -5168,9 +5266,13 @@
|
|
|
5168
5266
|
component = id;
|
|
5169
5267
|
}
|
|
5170
5268
|
if (!name || !component) return;
|
|
5269
|
+
var nameAlias = toCase(name);
|
|
5171
5270
|
components[name] = component;
|
|
5271
|
+
components[nameAlias] = component;
|
|
5172
5272
|
delete CreateNode.aliasMap[name];
|
|
5273
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5173
5274
|
delete parsers[name];
|
|
5275
|
+
delete parsers[nameAlias];
|
|
5174
5276
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5175
5277
|
}
|
|
5176
5278
|
function _emitData(id) {
|
|
@@ -5185,6 +5287,9 @@
|
|
|
5185
5287
|
loadData[id] = data;
|
|
5186
5288
|
_emitData(id);
|
|
5187
5289
|
}
|
|
5290
|
+
function getData(id, def) {
|
|
5291
|
+
return hasProperty(loadData, id) ? loadData[id] : def;
|
|
5292
|
+
}
|
|
5188
5293
|
function removeData(id) {
|
|
5189
5294
|
delete loadData[id];
|
|
5190
5295
|
_emitData(id);
|
|
@@ -5238,6 +5343,8 @@
|
|
|
5238
5343
|
components: components,
|
|
5239
5344
|
directives: directives
|
|
5240
5345
|
},
|
|
5346
|
+
setData: setData,
|
|
5347
|
+
getData: getData,
|
|
5241
5348
|
loadData: loadData,
|
|
5242
5349
|
CreateNode: CreateNode,
|
|
5243
5350
|
bus: new _vue(),
|
|
@@ -5279,7 +5386,6 @@
|
|
|
5279
5386
|
_this2.initOptions();
|
|
5280
5387
|
}
|
|
5281
5388
|
_this2.created();
|
|
5282
|
-
vm.disabled && vm.$f.disabled(true);
|
|
5283
5389
|
});
|
|
5284
5390
|
vm.$on('hook:mounted', function () {
|
|
5285
5391
|
_this2.mounted();
|
|
@@ -5357,6 +5463,7 @@
|
|
|
5357
5463
|
version: config.version,
|
|
5358
5464
|
ui: config.ui,
|
|
5359
5465
|
setData: setData,
|
|
5466
|
+
getData: getData,
|
|
5360
5467
|
removeData: removeData,
|
|
5361
5468
|
maker: maker,
|
|
5362
5469
|
component: component,
|
|
@@ -5777,8 +5884,7 @@
|
|
|
5777
5884
|
ref: ref
|
|
5778
5885
|
});
|
|
5779
5886
|
extend(this.rule.props, {
|
|
5780
|
-
model: $handle.formData
|
|
5781
|
-
rules: $handle.validate()
|
|
5887
|
+
model: $handle.formData
|
|
5782
5888
|
});
|
|
5783
5889
|
},
|
|
5784
5890
|
render: function render(children) {
|
|
@@ -5801,7 +5907,7 @@
|
|
|
5801
5907
|
labelWidth: labelWidth
|
|
5802
5908
|
}, rule.wrap || {}), {}, {
|
|
5803
5909
|
prop: ctx.id,
|
|
5804
|
-
rules:
|
|
5910
|
+
rules: ctx.injectValidate()
|
|
5805
5911
|
}),
|
|
5806
5912
|
"class": rule.className,
|
|
5807
5913
|
key: "".concat(uni, "fi"),
|
|
@@ -6210,7 +6316,7 @@
|
|
|
6210
6316
|
function ivuFormCreate() {
|
|
6211
6317
|
return FormCreateFactory({
|
|
6212
6318
|
ui: "".concat("view-design"),
|
|
6213
|
-
version: "".concat("2.5.
|
|
6319
|
+
version: "".concat("2.5.37"),
|
|
6214
6320
|
manager: manager,
|
|
6215
6321
|
install: install,
|
|
6216
6322
|
extendApi: extendApi,
|