@form-create/view-design 2.5.34 → 2.5.36
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 +299 -185
- 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.36
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -1497,6 +1497,7 @@
|
|
|
1497
1497
|
for (var i = len; i < 0; i++) {
|
|
1498
1498
|
this.addRule(n.length + i);
|
|
1499
1499
|
}
|
|
1500
|
+
this.sort = Object.keys(this.cacheRule);
|
|
1500
1501
|
for (var _i = 0; _i < total; _i++) {
|
|
1501
1502
|
this.setValue(keys[_i], n[_i]);
|
|
1502
1503
|
}
|
|
@@ -1506,6 +1507,7 @@
|
|
|
1506
1507
|
this.removeRule(keys[total - _i2 - 1]);
|
|
1507
1508
|
}
|
|
1508
1509
|
}
|
|
1510
|
+
this.sort = Object.keys(this.cacheRule);
|
|
1509
1511
|
n.forEach(function (val, i) {
|
|
1510
1512
|
_this2.setValue(keys[i], n[i]);
|
|
1511
1513
|
});
|
|
@@ -1925,6 +1927,10 @@
|
|
|
1925
1927
|
}
|
|
1926
1928
|
},
|
|
1927
1929
|
extendOption: Boolean,
|
|
1930
|
+
disabled: {
|
|
1931
|
+
type: Boolean,
|
|
1932
|
+
"default": undefined
|
|
1933
|
+
},
|
|
1928
1934
|
value: Object,
|
|
1929
1935
|
api: Object,
|
|
1930
1936
|
name: String,
|
|
@@ -1973,8 +1979,8 @@
|
|
|
1973
1979
|
deep: true
|
|
1974
1980
|
},
|
|
1975
1981
|
option: {
|
|
1976
|
-
handler: function handler(
|
|
1977
|
-
this.formCreate.initOptions(
|
|
1982
|
+
handler: function handler() {
|
|
1983
|
+
this.formCreate.initOptions();
|
|
1978
1984
|
this.$f.refresh();
|
|
1979
1985
|
},
|
|
1980
1986
|
deep: true
|
|
@@ -1986,14 +1992,14 @@
|
|
|
1986
1992
|
})) return;
|
|
1987
1993
|
this.formCreate.$handle.reloadRule(n);
|
|
1988
1994
|
this._renderRule();
|
|
1995
|
+
},
|
|
1996
|
+
disabled: function disabled() {
|
|
1997
|
+
this.$f.refresh();
|
|
1989
1998
|
}
|
|
1990
1999
|
},
|
|
1991
2000
|
beforeCreate: function beforeCreate() {
|
|
1992
2001
|
var _this2 = this;
|
|
1993
|
-
|
|
1994
|
-
rule = _this$$options$propsD.rule,
|
|
1995
|
-
option = _this$$options$propsD.option;
|
|
1996
|
-
this.formCreate = new FormCreate(this, rule, option);
|
|
2002
|
+
this.formCreate = new FormCreate(this);
|
|
1997
2003
|
Object.keys(this.formCreate.prop).forEach(function (k) {
|
|
1998
2004
|
extend(_this2.$options[k], _this2.formCreate.prop[k]);
|
|
1999
2005
|
});
|
|
@@ -2133,7 +2139,7 @@
|
|
|
2133
2139
|
var $TX = '$FNX:';
|
|
2134
2140
|
var FUNCTION = 'function';
|
|
2135
2141
|
function toJson(obj, space) {
|
|
2136
|
-
return JSON.stringify(deepExtend([], obj, true), function (key, val) {
|
|
2142
|
+
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2137
2143
|
if (val && val._isVue === true) return undefined;
|
|
2138
2144
|
if (_typeof(val) !== FUNCTION) {
|
|
2139
2145
|
return val;
|
|
@@ -2244,6 +2250,61 @@
|
|
|
2244
2250
|
}
|
|
2245
2251
|
return def;
|
|
2246
2252
|
}
|
|
2253
|
+
var changeType = function changeType(a, b) {
|
|
2254
|
+
if (typeof a === 'string') {
|
|
2255
|
+
return String(b);
|
|
2256
|
+
} else if (typeof a === 'number') {
|
|
2257
|
+
return Number(b);
|
|
2258
|
+
}
|
|
2259
|
+
return b;
|
|
2260
|
+
};
|
|
2261
|
+
var condition = {
|
|
2262
|
+
'==': function _(a, b) {
|
|
2263
|
+
return JSON.stringify(a) === JSON.stringify(changeType(a, b));
|
|
2264
|
+
},
|
|
2265
|
+
'!=': function _(a, b) {
|
|
2266
|
+
return !condition['=='](a, b);
|
|
2267
|
+
},
|
|
2268
|
+
'>': function _(a, b) {
|
|
2269
|
+
return a > b;
|
|
2270
|
+
},
|
|
2271
|
+
'>=': function _(a, b) {
|
|
2272
|
+
return a >= b;
|
|
2273
|
+
},
|
|
2274
|
+
'<': function _(a, b) {
|
|
2275
|
+
return a < b;
|
|
2276
|
+
},
|
|
2277
|
+
'<=': function _(a, b) {
|
|
2278
|
+
return a <= b;
|
|
2279
|
+
},
|
|
2280
|
+
on: function on(a, b) {
|
|
2281
|
+
return a && a.indexOf && a.indexOf(changeType(a[0], b)) > -1;
|
|
2282
|
+
},
|
|
2283
|
+
notOn: function notOn(a, b) {
|
|
2284
|
+
return !condition.on(a, b);
|
|
2285
|
+
},
|
|
2286
|
+
"in": function _in(a, b) {
|
|
2287
|
+
return b && b.indexOf && b.indexOf(a) > -1;
|
|
2288
|
+
},
|
|
2289
|
+
notIn: function notIn(a, b) {
|
|
2290
|
+
return !condition["in"](a, b);
|
|
2291
|
+
},
|
|
2292
|
+
between: function between(a, b) {
|
|
2293
|
+
return a > b[0] && a < b[1];
|
|
2294
|
+
},
|
|
2295
|
+
notBetween: function notBetween(a, b) {
|
|
2296
|
+
return a < b[0] || a > b[1];
|
|
2297
|
+
},
|
|
2298
|
+
empty: function empty(a) {
|
|
2299
|
+
return is.empty(a);
|
|
2300
|
+
},
|
|
2301
|
+
notEmpty: function notEmpty(a) {
|
|
2302
|
+
return !is.empty(a);
|
|
2303
|
+
},
|
|
2304
|
+
pattern: function pattern(a, b) {
|
|
2305
|
+
return new RegExp(b, 'g').test(a);
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2247
2308
|
|
|
2248
2309
|
function baseRule() {
|
|
2249
2310
|
return {
|
|
@@ -2325,6 +2386,92 @@
|
|
|
2325
2386
|
};
|
|
2326
2387
|
}
|
|
2327
2388
|
|
|
2389
|
+
function getError(action, option, xhr) {
|
|
2390
|
+
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
2391
|
+
var err = new Error(msg);
|
|
2392
|
+
err.status = xhr.status;
|
|
2393
|
+
err.url = action;
|
|
2394
|
+
return err;
|
|
2395
|
+
}
|
|
2396
|
+
function getBody(xhr) {
|
|
2397
|
+
var text = xhr.responseText || xhr.response;
|
|
2398
|
+
if (!text) {
|
|
2399
|
+
return text;
|
|
2400
|
+
}
|
|
2401
|
+
try {
|
|
2402
|
+
return JSON.parse(text);
|
|
2403
|
+
} catch (e) {
|
|
2404
|
+
return text;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
function fetch(option) {
|
|
2408
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2409
|
+
return;
|
|
2410
|
+
}
|
|
2411
|
+
var xhr = new XMLHttpRequest();
|
|
2412
|
+
var action = option.action;
|
|
2413
|
+
xhr.onerror = function error(e) {
|
|
2414
|
+
option.onError(e);
|
|
2415
|
+
};
|
|
2416
|
+
xhr.onload = function onload() {
|
|
2417
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
2418
|
+
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
2419
|
+
}
|
|
2420
|
+
option.onSuccess(getBody(xhr));
|
|
2421
|
+
};
|
|
2422
|
+
xhr.open(option.method || 'get', action, true);
|
|
2423
|
+
var formData;
|
|
2424
|
+
if (option.data) {
|
|
2425
|
+
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
2426
|
+
formData = new FormData();
|
|
2427
|
+
Object.keys(option.data).map(function (key) {
|
|
2428
|
+
formData.append(key, option.data[key]);
|
|
2429
|
+
});
|
|
2430
|
+
} else {
|
|
2431
|
+
formData = JSON.stringify(option.data);
|
|
2432
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
2436
|
+
xhr.withCredentials = true;
|
|
2437
|
+
}
|
|
2438
|
+
var headers = option.headers || {};
|
|
2439
|
+
Object.keys(headers).forEach(function (item) {
|
|
2440
|
+
if (headers[item] !== null) {
|
|
2441
|
+
xhr.setRequestHeader(item, headers[item]);
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
xhr.send(formData);
|
|
2445
|
+
}
|
|
2446
|
+
function asyncFetch(config) {
|
|
2447
|
+
return new Promise(function (resolve, reject) {
|
|
2448
|
+
fetch(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2449
|
+
onSuccess: function onSuccess(res) {
|
|
2450
|
+
var fn = function fn(v) {
|
|
2451
|
+
return v;
|
|
2452
|
+
};
|
|
2453
|
+
var parse = parseFn(config.parse);
|
|
2454
|
+
if (is.Function(parse)) {
|
|
2455
|
+
fn = parse;
|
|
2456
|
+
} else if (parse && is.String(parse)) {
|
|
2457
|
+
fn = function fn(v) {
|
|
2458
|
+
parse.split('.').forEach(function (k) {
|
|
2459
|
+
if (v) {
|
|
2460
|
+
v = v[k];
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
return v;
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
resolve(fn(res));
|
|
2467
|
+
},
|
|
2468
|
+
onError: function onError(err) {
|
|
2469
|
+
reject(err);
|
|
2470
|
+
}
|
|
2471
|
+
}));
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2328
2475
|
function copy(value) {
|
|
2329
2476
|
return deepCopy(value);
|
|
2330
2477
|
}
|
|
@@ -2366,6 +2513,12 @@
|
|
|
2366
2513
|
get parent() {
|
|
2367
2514
|
return h.vm.$pfc && h.vm.$pfc.$f;
|
|
2368
2515
|
},
|
|
2516
|
+
get top() {
|
|
2517
|
+
if (api.parent) {
|
|
2518
|
+
return api.parent.top;
|
|
2519
|
+
}
|
|
2520
|
+
return api;
|
|
2521
|
+
},
|
|
2369
2522
|
get children() {
|
|
2370
2523
|
return allSubForm();
|
|
2371
2524
|
},
|
|
@@ -2600,6 +2753,21 @@
|
|
|
2600
2753
|
return origin ? ctx.origin : ctx.rule;
|
|
2601
2754
|
}
|
|
2602
2755
|
},
|
|
2756
|
+
getRenderRule: function getRenderRule(id) {
|
|
2757
|
+
var ctx = h.getCtx(id);
|
|
2758
|
+
if (ctx) {
|
|
2759
|
+
return ctx.prop;
|
|
2760
|
+
}
|
|
2761
|
+
},
|
|
2762
|
+
getRefRule: function getRefRule(id) {
|
|
2763
|
+
var ctxs = h.getCtxs(id);
|
|
2764
|
+
if (ctxs && ctxs.length) {
|
|
2765
|
+
var rules = ctxs.map(function (ctx) {
|
|
2766
|
+
return ctx.rule;
|
|
2767
|
+
});
|
|
2768
|
+
return rules.length === 1 ? rules[0] : rules;
|
|
2769
|
+
}
|
|
2770
|
+
},
|
|
2603
2771
|
setEffect: function setEffect(id, attr, value) {
|
|
2604
2772
|
var ctx = h.getCtx(id);
|
|
2605
2773
|
if (ctx && attr) {
|
|
@@ -2706,12 +2874,23 @@
|
|
|
2706
2874
|
deferSyncValue: function deferSyncValue(fn, sync) {
|
|
2707
2875
|
h.deferSyncValue(fn, sync);
|
|
2708
2876
|
},
|
|
2877
|
+
fetch: function fetch(opt) {
|
|
2878
|
+
h.options.beforeFetch && invoke(function () {
|
|
2879
|
+
return h.options.beforeFetch(opt, {
|
|
2880
|
+
api: api
|
|
2881
|
+
});
|
|
2882
|
+
});
|
|
2883
|
+
return asyncFetch(opt);
|
|
2884
|
+
},
|
|
2885
|
+
getData: function getData(id, def) {
|
|
2886
|
+
return hasProperty(h.fc.loadData, id) ? h.fc.loadData[id] : def;
|
|
2887
|
+
},
|
|
2709
2888
|
helper: {
|
|
2710
2889
|
tidyFields: tidyFields,
|
|
2711
2890
|
props: props
|
|
2712
2891
|
}
|
|
2713
2892
|
};
|
|
2714
|
-
['on', 'once', 'off', 'set'].forEach(function (n) {
|
|
2893
|
+
['on', 'once', 'off', 'set', 'emit'].forEach(function (n) {
|
|
2715
2894
|
api[n] = function () {
|
|
2716
2895
|
var _h$vm2;
|
|
2717
2896
|
(_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
|
|
@@ -2785,7 +2964,8 @@
|
|
|
2785
2964
|
|
|
2786
2965
|
var id = 0;
|
|
2787
2966
|
function uniqueId() {
|
|
2788
|
-
|
|
2967
|
+
var num = 370 + ++id;
|
|
2968
|
+
return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
|
|
2789
2969
|
}
|
|
2790
2970
|
|
|
2791
2971
|
function deepSet(data, idx, val) {
|
|
@@ -3096,6 +3276,7 @@
|
|
|
3096
3276
|
children: [],
|
|
3097
3277
|
prop: {},
|
|
3098
3278
|
preview: false,
|
|
3279
|
+
id: ctx.id,
|
|
3099
3280
|
field: ctx.field,
|
|
3100
3281
|
rule: ctx.rule,
|
|
3101
3282
|
input: ctx.input
|
|
@@ -3115,13 +3296,13 @@
|
|
|
3115
3296
|
});
|
|
3116
3297
|
return inject;
|
|
3117
3298
|
},
|
|
3118
|
-
ctxProp: function ctxProp(ctx
|
|
3299
|
+
ctxProp: function ctxProp(ctx) {
|
|
3119
3300
|
var _this8 = this;
|
|
3120
3301
|
var ref = ctx.ref,
|
|
3121
3302
|
key = ctx.key,
|
|
3122
3303
|
rule = ctx.rule;
|
|
3123
|
-
this.$manager.mergeProp(ctx
|
|
3124
|
-
ctx.parser.mergeProp(ctx
|
|
3304
|
+
this.$manager.mergeProp(ctx);
|
|
3305
|
+
ctx.parser.mergeProp(ctx);
|
|
3125
3306
|
var props = [{
|
|
3126
3307
|
ref: ref,
|
|
3127
3308
|
key: rule.key || "".concat(key, "fc"),
|
|
@@ -3141,7 +3322,10 @@
|
|
|
3141
3322
|
}
|
|
3142
3323
|
}
|
|
3143
3324
|
}];
|
|
3144
|
-
if (
|
|
3325
|
+
if (ctx.input) {
|
|
3326
|
+
if (this.vm.$props.disabled !== undefined) {
|
|
3327
|
+
ctx.prop.props.disabled = !!this.vm.$props.disabled;
|
|
3328
|
+
}
|
|
3145
3329
|
ctx.prop.model = {
|
|
3146
3330
|
value: this.$handle.getFormData(ctx),
|
|
3147
3331
|
callback: function callback(value) {
|
|
@@ -3299,16 +3483,17 @@
|
|
|
3299
3483
|
inject = rule.inject;
|
|
3300
3484
|
var emit = rule[on ? 'emit' : 'nativeEmit'] || [];
|
|
3301
3485
|
if (is.trueArray(emit)) {
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3486
|
+
emit.forEach(function (eventName) {
|
|
3487
|
+
if (!eventName) return;
|
|
3488
|
+
var eventInject;
|
|
3489
|
+
var emitKey = emitPrefix || field || name;
|
|
3490
|
+
if (is.Object(eventName)) {
|
|
3491
|
+
eventInject = eventName.inject;
|
|
3492
|
+
eventName = eventName.name;
|
|
3493
|
+
emitKey = eventName.prefix || emitKey;
|
|
3494
|
+
}
|
|
3495
|
+
if (emitKey) {
|
|
3496
|
+
if (!on) emitKey = "native-".concat(emitKey);
|
|
3312
3497
|
var fieldKey = toLine("".concat(emitKey, "-").concat(eventName));
|
|
3313
3498
|
var fn = function fn() {
|
|
3314
3499
|
var _this2$vm, _this2$vm2;
|
|
@@ -3325,8 +3510,8 @@
|
|
|
3325
3510
|
var _inject = eventInject || inject || _this2.options.injectEvent;
|
|
3326
3511
|
event[eventName] = is.Undef(_inject) ? fn : _this2.inject(rule, fn, _inject);
|
|
3327
3512
|
}
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3513
|
+
}
|
|
3514
|
+
});
|
|
3330
3515
|
}
|
|
3331
3516
|
ctx.computed[on ? 'on' : 'nativeOn'] = event;
|
|
3332
3517
|
return event;
|
|
@@ -3502,6 +3687,30 @@
|
|
|
3502
3687
|
return _this.payload[k];
|
|
3503
3688
|
})), [this.computed]));
|
|
3504
3689
|
},
|
|
3690
|
+
injectValidate: function injectValidate() {
|
|
3691
|
+
var _this2 = this;
|
|
3692
|
+
return toArray(this.prop.validate).map(function (item) {
|
|
3693
|
+
if (is.Function(item.validator)) {
|
|
3694
|
+
var temp = _objectSpread2({}, item);
|
|
3695
|
+
var that = _this2;
|
|
3696
|
+
temp.validator = function () {
|
|
3697
|
+
var _item$validator;
|
|
3698
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3699
|
+
args[_key] = arguments[_key];
|
|
3700
|
+
}
|
|
3701
|
+
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
3702
|
+
that: this,
|
|
3703
|
+
id: that.id,
|
|
3704
|
+
field: that.field,
|
|
3705
|
+
rule: that.rule,
|
|
3706
|
+
api: that.$handle.api
|
|
3707
|
+
}].concat(args));
|
|
3708
|
+
};
|
|
3709
|
+
return temp;
|
|
3710
|
+
}
|
|
3711
|
+
return item;
|
|
3712
|
+
});
|
|
3713
|
+
},
|
|
3505
3714
|
check: function check(handle) {
|
|
3506
3715
|
return this.vm === handle.vm;
|
|
3507
3716
|
},
|
|
@@ -3550,12 +3759,12 @@
|
|
|
3550
3759
|
this.ctrlRule = [];
|
|
3551
3760
|
},
|
|
3552
3761
|
rm: function rm() {
|
|
3553
|
-
var
|
|
3762
|
+
var _this3 = this;
|
|
3554
3763
|
var _rm = function _rm() {
|
|
3555
|
-
var index =
|
|
3764
|
+
var index = _this3.root.indexOf(_this3.origin);
|
|
3556
3765
|
if (index > -1) {
|
|
3557
|
-
|
|
3558
|
-
|
|
3766
|
+
_this3.root.splice(index, 1);
|
|
3767
|
+
_this3.$handle && _this3.$handle.refresh();
|
|
3559
3768
|
}
|
|
3560
3769
|
};
|
|
3561
3770
|
if (this.deleted) {
|
|
@@ -3563,14 +3772,14 @@
|
|
|
3563
3772
|
return;
|
|
3564
3773
|
}
|
|
3565
3774
|
this.$handle.noWatch(function () {
|
|
3566
|
-
|
|
3567
|
-
|
|
3775
|
+
_this3.$handle.deferSyncValue(function () {
|
|
3776
|
+
_this3.rmCtrl();
|
|
3568
3777
|
_rm();
|
|
3569
|
-
|
|
3570
|
-
extend(
|
|
3778
|
+
_this3.$handle.rmCtx(_this3);
|
|
3779
|
+
extend(_this3, {
|
|
3571
3780
|
root: []
|
|
3572
3781
|
});
|
|
3573
|
-
},
|
|
3782
|
+
}, _this3.input);
|
|
3574
3783
|
});
|
|
3575
3784
|
},
|
|
3576
3785
|
update: function update(handle, init) {
|
|
@@ -3591,73 +3800,6 @@
|
|
|
3591
3800
|
}
|
|
3592
3801
|
});
|
|
3593
3802
|
|
|
3594
|
-
var condition = {
|
|
3595
|
-
'==': function _(b) {
|
|
3596
|
-
return function (a) {
|
|
3597
|
-
return a === b;
|
|
3598
|
-
};
|
|
3599
|
-
},
|
|
3600
|
-
'!=': function _(b) {
|
|
3601
|
-
return function (a) {
|
|
3602
|
-
return a !== b;
|
|
3603
|
-
};
|
|
3604
|
-
},
|
|
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
|
-
'in': function _in(b) {
|
|
3631
|
-
return function (a) {
|
|
3632
|
-
return b && b.indexOf && b.indexOf(a) > -1;
|
|
3633
|
-
};
|
|
3634
|
-
},
|
|
3635
|
-
'on': function on(b) {
|
|
3636
|
-
return function (a) {
|
|
3637
|
-
return a && a.indexOf && a.indexOf(b) > -1;
|
|
3638
|
-
};
|
|
3639
|
-
},
|
|
3640
|
-
'notIn': function notIn(b) {
|
|
3641
|
-
return function (a) {
|
|
3642
|
-
return !condition["in"](b)(a);
|
|
3643
|
-
};
|
|
3644
|
-
},
|
|
3645
|
-
'notOn': function notOn(b) {
|
|
3646
|
-
return function (a) {
|
|
3647
|
-
return !condition.on(b)(a);
|
|
3648
|
-
};
|
|
3649
|
-
},
|
|
3650
|
-
'between': function between(b) {
|
|
3651
|
-
return function (a) {
|
|
3652
|
-
return a > b[0] && a < b[1];
|
|
3653
|
-
};
|
|
3654
|
-
},
|
|
3655
|
-
'notBetween': function notBetween(b) {
|
|
3656
|
-
return function (a) {
|
|
3657
|
-
return a < b[0] || a > b[1];
|
|
3658
|
-
};
|
|
3659
|
-
}
|
|
3660
|
-
};
|
|
3661
3803
|
function useLoader(Handler) {
|
|
3662
3804
|
extend(Handler.prototype, {
|
|
3663
3805
|
nextRefresh: function nextRefresh(fn) {
|
|
@@ -3809,7 +3951,7 @@
|
|
|
3809
3951
|
}
|
|
3810
3952
|
if (!ctx) {
|
|
3811
3953
|
var _rule2 = _this6.parseRule(_rule);
|
|
3812
|
-
ctx = new RuleContext(_this6, _rule2,
|
|
3954
|
+
ctx = new RuleContext(_this6, _rule2, defaultValue);
|
|
3813
3955
|
_this6.bindParser(ctx);
|
|
3814
3956
|
} else {
|
|
3815
3957
|
if (ctx.originType !== ctx.rule.type) {
|
|
@@ -3862,7 +4004,9 @@
|
|
|
3862
4004
|
if (!controls.length) return false;
|
|
3863
4005
|
var _loop = function _loop(i) {
|
|
3864
4006
|
var control = controls[i],
|
|
3865
|
-
handleFn = control.handle ||
|
|
4007
|
+
handleFn = control.handle || function (val) {
|
|
4008
|
+
return (condition[control.condition || '=='] || condition['=='])(val, control.value);
|
|
4009
|
+
};
|
|
3866
4010
|
if (!is.trueArray(control.rule)) return "continue";
|
|
3867
4011
|
var data = _objectSpread2(_objectSpread2({}, control), {}, {
|
|
3868
4012
|
valid: invoke(function () {
|
|
@@ -4024,6 +4168,11 @@
|
|
|
4024
4168
|
this.valueChange(ctx, value);
|
|
4025
4169
|
this.vm.$emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
4026
4170
|
this.effect(ctx, 'value');
|
|
4171
|
+
this.emitEvent('change', ctx.field, value, {
|
|
4172
|
+
rule: ctx.origin,
|
|
4173
|
+
api: this.api,
|
|
4174
|
+
setFlag: setFlag || false
|
|
4175
|
+
});
|
|
4027
4176
|
},
|
|
4028
4177
|
onInput: function onInput(ctx, value) {
|
|
4029
4178
|
var val;
|
|
@@ -4120,12 +4269,13 @@
|
|
|
4120
4269
|
isQuote: function isQuote(ctx, value) {
|
|
4121
4270
|
return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
|
|
4122
4271
|
},
|
|
4123
|
-
refreshUpdate: function refreshUpdate(ctx, val, origin) {
|
|
4272
|
+
refreshUpdate: function refreshUpdate(ctx, val, origin, field) {
|
|
4124
4273
|
var _this4 = this;
|
|
4125
4274
|
if (is.Function(ctx.rule.update)) {
|
|
4126
4275
|
var state = invoke(function () {
|
|
4127
4276
|
return ctx.rule.update(val, ctx.origin, _this4.api, {
|
|
4128
|
-
origin: origin || 'change'
|
|
4277
|
+
origin: origin || 'change',
|
|
4278
|
+
linkField: field
|
|
4129
4279
|
});
|
|
4130
4280
|
});
|
|
4131
4281
|
if (state === undefined) return;
|
|
@@ -4136,21 +4286,21 @@
|
|
|
4136
4286
|
this.refreshRule(ctx, val);
|
|
4137
4287
|
this.bus.$emit('change-' + ctx.field, val);
|
|
4138
4288
|
},
|
|
4139
|
-
refreshRule: function refreshRule(ctx, val, origin) {
|
|
4289
|
+
refreshRule: function refreshRule(ctx, val, origin, field) {
|
|
4140
4290
|
if (this.refreshControl(ctx)) {
|
|
4141
4291
|
this.$render.clearCacheAll();
|
|
4142
4292
|
this.loadRule();
|
|
4143
4293
|
this.vm.$emit('update', this.api);
|
|
4144
4294
|
this.refresh();
|
|
4145
4295
|
}
|
|
4146
|
-
this.refreshUpdate(ctx, val, origin);
|
|
4296
|
+
this.refreshUpdate(ctx, val, origin, field);
|
|
4147
4297
|
},
|
|
4148
4298
|
appendLink: function appendLink(ctx) {
|
|
4149
4299
|
var _this5 = this;
|
|
4150
4300
|
var link = ctx.rule.link;
|
|
4151
4301
|
is.trueArray(link) && link.forEach(function (field) {
|
|
4152
4302
|
var fn = function fn() {
|
|
4153
|
-
return _this5.refreshRule(ctx, ctx.rule.value, 'link');
|
|
4303
|
+
return _this5.refreshRule(ctx, ctx.rule.value, 'link', field);
|
|
4154
4304
|
};
|
|
4155
4305
|
_this5.bus.$on('change-' + field, fn);
|
|
4156
4306
|
ctx.linkOn.push(function () {
|
|
@@ -4381,12 +4531,22 @@
|
|
|
4381
4531
|
}
|
|
4382
4532
|
},
|
|
4383
4533
|
lifecycle: function lifecycle(name) {
|
|
4384
|
-
var _this2 = this;
|
|
4385
|
-
var fn = this.options[name];
|
|
4386
|
-
is.Function(fn) && invoke(function () {
|
|
4387
|
-
return fn(_this2.api);
|
|
4388
|
-
});
|
|
4389
4534
|
this.vm.$emit(name, this.api);
|
|
4535
|
+
this.emitEvent(name, this.api);
|
|
4536
|
+
},
|
|
4537
|
+
emitEvent: function emitEvent(name) {
|
|
4538
|
+
var _this$bus;
|
|
4539
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4540
|
+
args[_key - 1] = arguments[_key];
|
|
4541
|
+
}
|
|
4542
|
+
var _fn = this.options[name] || this.options[toCase('on-' + name)];
|
|
4543
|
+
if (_fn) {
|
|
4544
|
+
var fn = parseFn(_fn);
|
|
4545
|
+
is.Function(fn) && invoke(function () {
|
|
4546
|
+
return fn.apply(void 0, args);
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
4390
4550
|
}
|
|
4391
4551
|
});
|
|
4392
4552
|
}
|
|
@@ -4588,6 +4748,7 @@
|
|
|
4588
4748
|
this.usePage();
|
|
4589
4749
|
this.loadRule();
|
|
4590
4750
|
this.$manager.__init();
|
|
4751
|
+
this.lifecycle('created');
|
|
4591
4752
|
this.vm.$set(this.vm, 'formData', this.formData);
|
|
4592
4753
|
}
|
|
4593
4754
|
});
|
|
@@ -4600,64 +4761,6 @@
|
|
|
4600
4761
|
useLifecycle(Handler);
|
|
4601
4762
|
useEffect(Handler);
|
|
4602
4763
|
|
|
4603
|
-
function getError(action, option, xhr) {
|
|
4604
|
-
var msg = "fail to ".concat(action, " ").concat(xhr.status, "'");
|
|
4605
|
-
var err = new Error(msg);
|
|
4606
|
-
err.status = xhr.status;
|
|
4607
|
-
err.url = action;
|
|
4608
|
-
return err;
|
|
4609
|
-
}
|
|
4610
|
-
function getBody(xhr) {
|
|
4611
|
-
var text = xhr.responseText || xhr.response;
|
|
4612
|
-
if (!text) {
|
|
4613
|
-
return text;
|
|
4614
|
-
}
|
|
4615
|
-
try {
|
|
4616
|
-
return JSON.parse(text);
|
|
4617
|
-
} catch (e) {
|
|
4618
|
-
return text;
|
|
4619
|
-
}
|
|
4620
|
-
}
|
|
4621
|
-
function fetch(option) {
|
|
4622
|
-
if (typeof XMLHttpRequest === 'undefined') {
|
|
4623
|
-
return;
|
|
4624
|
-
}
|
|
4625
|
-
var xhr = new XMLHttpRequest();
|
|
4626
|
-
var action = option.action;
|
|
4627
|
-
xhr.onerror = function error(e) {
|
|
4628
|
-
option.onError(e);
|
|
4629
|
-
};
|
|
4630
|
-
xhr.onload = function onload() {
|
|
4631
|
-
if (xhr.status < 200 || xhr.status >= 300) {
|
|
4632
|
-
return option.onError(getError(action, option, xhr), getBody(xhr));
|
|
4633
|
-
}
|
|
4634
|
-
option.onSuccess(getBody(xhr));
|
|
4635
|
-
};
|
|
4636
|
-
xhr.open(option.method || 'get', action, true);
|
|
4637
|
-
var formData;
|
|
4638
|
-
if (option.data) {
|
|
4639
|
-
if ((option.dataType || '').toLowerCase() !== 'json') {
|
|
4640
|
-
formData = new FormData();
|
|
4641
|
-
Object.keys(option.data).map(function (key) {
|
|
4642
|
-
formData.append(key, option.data[key]);
|
|
4643
|
-
});
|
|
4644
|
-
} else {
|
|
4645
|
-
formData = JSON.stringify(option.data);
|
|
4646
|
-
xhr.setRequestHeader('content-type', 'application/json');
|
|
4647
|
-
}
|
|
4648
|
-
}
|
|
4649
|
-
if (option.withCredentials && 'withCredentials' in xhr) {
|
|
4650
|
-
xhr.withCredentials = true;
|
|
4651
|
-
}
|
|
4652
|
-
var headers = option.headers || {};
|
|
4653
|
-
Object.keys(headers).forEach(function (item) {
|
|
4654
|
-
if (headers[item] !== null) {
|
|
4655
|
-
xhr.setRequestHeader(item, headers[item]);
|
|
4656
|
-
}
|
|
4657
|
-
});
|
|
4658
|
-
xhr.send(formData);
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
4764
|
var NAME$9 = 'fcFragment';
|
|
4662
4765
|
var fragment = {
|
|
4663
4766
|
name: NAME$9,
|
|
@@ -4900,6 +5003,7 @@
|
|
|
4900
5003
|
set(undefined);
|
|
4901
5004
|
return;
|
|
4902
5005
|
}
|
|
5006
|
+
option = deepCopy(option);
|
|
4903
5007
|
if (!option.to) {
|
|
4904
5008
|
option.to = 'options';
|
|
4905
5009
|
}
|
|
@@ -4980,6 +5084,7 @@
|
|
|
4980
5084
|
var val = parseVal(inject.getValue());
|
|
4981
5085
|
if (val.required === false) {
|
|
4982
5086
|
inject.clearProp();
|
|
5087
|
+
api.clearValidateState([rule.field]);
|
|
4983
5088
|
} else {
|
|
4984
5089
|
var validate = _objectSpread2({
|
|
4985
5090
|
required: true,
|
|
@@ -5135,11 +5240,12 @@
|
|
|
5135
5240
|
}
|
|
5136
5241
|
function parser() {
|
|
5137
5242
|
var data = nameProp.apply(void 0, arguments);
|
|
5138
|
-
if (!data.id || !data.prop) return;
|
|
5243
|
+
if (!data.id || !data.prop) return BaseParser;
|
|
5139
5244
|
var name = toCase(data.id);
|
|
5140
5245
|
var parser = data.prop;
|
|
5141
5246
|
var base = parser.merge === true ? parsers[name] : undefined;
|
|
5142
|
-
parsers[name] =
|
|
5247
|
+
parsers[name] = parser;
|
|
5248
|
+
Object.setPrototypeOf(parser, base || BaseParser);
|
|
5143
5249
|
maker[name] = creatorFactory(name);
|
|
5144
5250
|
parser.maker && extend(maker, parser.maker);
|
|
5145
5251
|
}
|
|
@@ -5157,7 +5263,13 @@
|
|
|
5157
5263
|
component = id;
|
|
5158
5264
|
}
|
|
5159
5265
|
if (!name || !component) return;
|
|
5266
|
+
var nameAlias = toCase(name);
|
|
5160
5267
|
components[name] = component;
|
|
5268
|
+
components[nameAlias] = component;
|
|
5269
|
+
delete CreateNode.aliasMap[name];
|
|
5270
|
+
delete CreateNode.aliasMap[nameAlias];
|
|
5271
|
+
delete parsers[name];
|
|
5272
|
+
delete parsers[nameAlias];
|
|
5161
5273
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5162
5274
|
}
|
|
5163
5275
|
function _emitData(id) {
|
|
@@ -5209,7 +5321,8 @@
|
|
|
5209
5321
|
}
|
|
5210
5322
|
return FormCreateFactory(_config);
|
|
5211
5323
|
}
|
|
5212
|
-
function FormCreate(vm
|
|
5324
|
+
function FormCreate(vm) {
|
|
5325
|
+
var rules = vm.$options.propsData.rule;
|
|
5213
5326
|
extend(this, {
|
|
5214
5327
|
id: id$1++,
|
|
5215
5328
|
vm: vm,
|
|
@@ -5228,13 +5341,13 @@
|
|
|
5228
5341
|
CreateNode: CreateNode,
|
|
5229
5342
|
bus: new _vue(),
|
|
5230
5343
|
unwatch: null,
|
|
5231
|
-
options:
|
|
5344
|
+
options: {},
|
|
5232
5345
|
extendApi: config.extendApi || function (api) {
|
|
5233
5346
|
return api;
|
|
5234
5347
|
}
|
|
5235
5348
|
});
|
|
5236
5349
|
this.init();
|
|
5237
|
-
this.initOptions(
|
|
5350
|
+
this.initOptions();
|
|
5238
5351
|
if (this.name) {
|
|
5239
5352
|
if (this.inFor) {
|
|
5240
5353
|
if (!instance[this.name]) instance[this.name] = [];
|
|
@@ -5257,12 +5370,12 @@
|
|
|
5257
5370
|
_this2.unwatch = vm.$watch(function () {
|
|
5258
5371
|
return vm.$pfc.option;
|
|
5259
5372
|
}, function () {
|
|
5260
|
-
_this2.initOptions(
|
|
5373
|
+
_this2.initOptions();
|
|
5261
5374
|
vm.$f.refresh();
|
|
5262
5375
|
}, {
|
|
5263
5376
|
deep: true
|
|
5264
5377
|
});
|
|
5265
|
-
_this2.initOptions(
|
|
5378
|
+
_this2.initOptions();
|
|
5266
5379
|
}
|
|
5267
5380
|
_this2.created();
|
|
5268
5381
|
});
|
|
@@ -5294,8 +5407,9 @@
|
|
|
5294
5407
|
isSub: function isSub() {
|
|
5295
5408
|
return this.vm.$pfc && this.vm.extendOption;
|
|
5296
5409
|
},
|
|
5297
|
-
initOptions: function initOptions(
|
|
5298
|
-
this.options =
|
|
5410
|
+
initOptions: function initOptions() {
|
|
5411
|
+
this.options = {};
|
|
5412
|
+
var options = _objectSpread2({
|
|
5299
5413
|
formData: {},
|
|
5300
5414
|
submitBtn: {},
|
|
5301
5415
|
resetBtn: {}
|
|
@@ -5303,6 +5417,7 @@
|
|
|
5303
5417
|
if (this.isSub()) {
|
|
5304
5418
|
this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
|
|
5305
5419
|
}
|
|
5420
|
+
options = this.mergeOptions(options, this.vm.$options.propsData.option);
|
|
5306
5421
|
this.updateOptions(options);
|
|
5307
5422
|
},
|
|
5308
5423
|
mergeOptions: function mergeOptions(target, opt, parent) {
|
|
@@ -5760,8 +5875,7 @@
|
|
|
5760
5875
|
ref: ref
|
|
5761
5876
|
});
|
|
5762
5877
|
extend(this.rule.props, {
|
|
5763
|
-
model: $handle.formData
|
|
5764
|
-
rules: $handle.validate()
|
|
5878
|
+
model: $handle.formData
|
|
5765
5879
|
});
|
|
5766
5880
|
},
|
|
5767
5881
|
render: function render(children) {
|
|
@@ -5784,7 +5898,7 @@
|
|
|
5784
5898
|
labelWidth: labelWidth
|
|
5785
5899
|
}, rule.wrap || {}), {}, {
|
|
5786
5900
|
prop: ctx.id,
|
|
5787
|
-
rules:
|
|
5901
|
+
rules: ctx.injectValidate()
|
|
5788
5902
|
}),
|
|
5789
5903
|
"class": rule.className,
|
|
5790
5904
|
key: "".concat(uni, "fi"),
|
|
@@ -6193,7 +6307,7 @@
|
|
|
6193
6307
|
function ivuFormCreate() {
|
|
6194
6308
|
return FormCreateFactory({
|
|
6195
6309
|
ui: "".concat("view-design"),
|
|
6196
|
-
version: "".concat("2.5.
|
|
6310
|
+
version: "".concat("2.5.36"),
|
|
6197
6311
|
manager: manager,
|
|
6198
6312
|
install: install,
|
|
6199
6313
|
extendApi: extendApi,
|