@form-create/element-ui 3.2.12 → 3.2.14
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 +464 -132
- package/dist/form-create.esm.min.js +2 -2
- package/dist/form-create.js +463 -131
- package/dist/form-create.min.js +2 -2
- package/package.json +12 -12
- package/src/core/alias.js +1 -0
- package/src/core/manager.js +22 -16
- package/src/core/provider.js +6 -2
- package/src/parsers/datePicker.js +1 -0
- package/src/style/index.css +7 -3
- package/types/config.d.ts +18 -18
package/dist/form-create.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/element-ui v3.2.
|
|
2
|
+
* @form-create/element-ui v3.2.14
|
|
3
3
|
* (c) 2018-2024 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent, toRef, ref, watch, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated,
|
|
7
|
+
import { defineComponent, toRef, ref, watch, computed, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated, withDirectives, resolveDirective, createApp, h } from 'vue';
|
|
8
8
|
|
|
9
9
|
function ownKeys(object, enumerableOnly) {
|
|
10
10
|
var keys = Object.keys(object);
|
|
@@ -222,12 +222,14 @@ var Checkbox = defineComponent({
|
|
|
222
222
|
}
|
|
223
223
|
},
|
|
224
224
|
type: String,
|
|
225
|
+
options: Array,
|
|
225
226
|
input: Boolean,
|
|
226
227
|
inputValue: String
|
|
227
228
|
},
|
|
228
229
|
emits: ['update:modelValue', 'fc.el'],
|
|
229
230
|
setup: function setup(props, _) {
|
|
230
231
|
var options = toRef(props.formCreateInject, 'options', []);
|
|
232
|
+
var opt = toRef(props, 'options');
|
|
231
233
|
var value = toRef(props, 'modelValue');
|
|
232
234
|
var inputValue = toRef(props, 'inputValue', '');
|
|
233
235
|
var customValue = ref(inputValue.value);
|
|
@@ -258,9 +260,37 @@ var Checkbox = defineComponent({
|
|
|
258
260
|
updateCustomValue(n);
|
|
259
261
|
});
|
|
260
262
|
|
|
261
|
-
var _options = function
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
var _options = computed(function () {
|
|
264
|
+
var arr = options.value || [];
|
|
265
|
+
|
|
266
|
+
if (opt.value) {
|
|
267
|
+
arr = opt.value || [];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return Array.isArray(arr) ? arr : [];
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
watch(value, function (n) {
|
|
274
|
+
var value = null;
|
|
275
|
+
|
|
276
|
+
if (!inputValue.value && n != null && Array.isArray(n) && n.length > 0 && input.value) {
|
|
277
|
+
var values = _options.value.map(function (item) {
|
|
278
|
+
return item.value;
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
n.forEach(function (val) {
|
|
282
|
+
if (values.indexOf(val) === -1) {
|
|
283
|
+
value = val;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (value != null) {
|
|
289
|
+
customValue.value = value;
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
immediate: true
|
|
293
|
+
});
|
|
264
294
|
|
|
265
295
|
var onInput = function onInput(n) {
|
|
266
296
|
_.emit('update:modelValue', n);
|
|
@@ -304,7 +334,7 @@ var Checkbox = defineComponent({
|
|
|
304
334
|
"ref": "el"
|
|
305
335
|
}), _objectSpread2({
|
|
306
336
|
"default": function _default() {
|
|
307
|
-
return [_this.options
|
|
337
|
+
return [_this.options.map(function (opt, index) {
|
|
308
338
|
var props = _objectSpread2({}, opt);
|
|
309
339
|
|
|
310
340
|
var value = props.value;
|
|
@@ -1015,6 +1045,7 @@ var Radio = defineComponent({
|
|
|
1015
1045
|
type: [String, Number, Boolean],
|
|
1016
1046
|
"default": ''
|
|
1017
1047
|
},
|
|
1048
|
+
options: Array,
|
|
1018
1049
|
type: String,
|
|
1019
1050
|
input: Boolean,
|
|
1020
1051
|
inputValue: String
|
|
@@ -1022,15 +1053,11 @@ var Radio = defineComponent({
|
|
|
1022
1053
|
emits: ['update:modelValue', 'fc.el'],
|
|
1023
1054
|
setup: function setup(props, _) {
|
|
1024
1055
|
var options = toRef(props.formCreateInject, 'options', []);
|
|
1056
|
+
var opt = toRef(props, 'options');
|
|
1025
1057
|
var value = toRef(props, 'modelValue');
|
|
1026
1058
|
var inputValue = toRef(props, 'inputValue', '');
|
|
1027
1059
|
var customValue = ref(inputValue.value);
|
|
1028
1060
|
var input = toRef(props, 'input', false);
|
|
1029
|
-
|
|
1030
|
-
var _options = function _options() {
|
|
1031
|
-
return Array.isArray(options.value) ? options.value : [];
|
|
1032
|
-
};
|
|
1033
|
-
|
|
1034
1061
|
watch(inputValue, function (n) {
|
|
1035
1062
|
if (!input.value) {
|
|
1036
1063
|
customValue.value = n;
|
|
@@ -1040,6 +1067,32 @@ var Radio = defineComponent({
|
|
|
1040
1067
|
updateCustomValue(n);
|
|
1041
1068
|
});
|
|
1042
1069
|
|
|
1070
|
+
var _options = computed(function () {
|
|
1071
|
+
var arr = options.value || [];
|
|
1072
|
+
|
|
1073
|
+
if (opt.value) {
|
|
1074
|
+
arr = opt.value || [];
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
return Array.isArray(arr) ? arr : [];
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
watch(value, function (n) {
|
|
1081
|
+
var flag = false;
|
|
1082
|
+
|
|
1083
|
+
if (!inputValue.value && n != null && input.value) {
|
|
1084
|
+
flag = _options.value.map(function (item) {
|
|
1085
|
+
return item.value;
|
|
1086
|
+
}).indexOf(n) === -1;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if (flag) {
|
|
1090
|
+
customValue.value = n;
|
|
1091
|
+
}
|
|
1092
|
+
}, {
|
|
1093
|
+
immediate: true
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1043
1096
|
var onInput = function onInput(n) {
|
|
1044
1097
|
_.emit('update:modelValue', n);
|
|
1045
1098
|
};
|
|
@@ -1093,7 +1146,7 @@ var Radio = defineComponent({
|
|
|
1093
1146
|
"ref": "el"
|
|
1094
1147
|
}), _objectSpread2({
|
|
1095
1148
|
"default": function _default() {
|
|
1096
|
-
return [_this.options
|
|
1149
|
+
return [_this.options.map(function (opt, index) {
|
|
1097
1150
|
var props = _objectSpread2({}, opt);
|
|
1098
1151
|
|
|
1099
1152
|
var value = props.value;
|
|
@@ -1321,13 +1374,25 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1321
1374
|
script$1.render = render$1;
|
|
1322
1375
|
|
|
1323
1376
|
function parseFile(file, i) {
|
|
1377
|
+
if (_typeof(file) === 'object') {
|
|
1378
|
+
return file;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1324
1381
|
return {
|
|
1325
1382
|
url: file,
|
|
1383
|
+
is_string: true,
|
|
1326
1384
|
name: getFileName(file),
|
|
1327
1385
|
uid: i
|
|
1328
1386
|
};
|
|
1329
1387
|
}
|
|
1330
1388
|
|
|
1389
|
+
function parseUpload(file) {
|
|
1390
|
+
return _objectSpread2(_objectSpread2({}, file), {}, {
|
|
1391
|
+
file: file,
|
|
1392
|
+
value: file
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1331
1396
|
function getFileName(file) {
|
|
1332
1397
|
return ('' + file).split('/').pop();
|
|
1333
1398
|
}
|
|
@@ -1360,11 +1425,11 @@ var Upload = defineComponent({
|
|
|
1360
1425
|
};
|
|
1361
1426
|
},
|
|
1362
1427
|
created: function created() {
|
|
1363
|
-
this.fileList = toArray(this.modelValue).map(parseFile);
|
|
1428
|
+
this.fileList = toArray(this.modelValue).map(parseFile).map(parseUpload);
|
|
1364
1429
|
},
|
|
1365
1430
|
watch: {
|
|
1366
1431
|
modelValue: function modelValue(n) {
|
|
1367
|
-
this.fileList = toArray(n).map(parseFile);
|
|
1432
|
+
this.fileList = toArray(n).map(parseFile).map(parseUpload);
|
|
1368
1433
|
}
|
|
1369
1434
|
},
|
|
1370
1435
|
methods: {
|
|
@@ -1381,10 +1446,10 @@ var Upload = defineComponent({
|
|
|
1381
1446
|
}
|
|
1382
1447
|
},
|
|
1383
1448
|
update: function update(fileList) {
|
|
1384
|
-
var files = fileList.map(function (
|
|
1385
|
-
return
|
|
1449
|
+
var files = fileList.map(function (v) {
|
|
1450
|
+
return v.is_string ? v.url : v.value || v.url;
|
|
1386
1451
|
}).filter(function (url) {
|
|
1387
|
-
return url !== undefined;
|
|
1452
|
+
return url !== undefined && url.indexOf('blob:') !== 0;
|
|
1388
1453
|
});
|
|
1389
1454
|
this.$emit('update:modelValue', files);
|
|
1390
1455
|
},
|
|
@@ -1425,7 +1490,7 @@ var Upload = defineComponent({
|
|
|
1425
1490
|
"ref": "upload"
|
|
1426
1491
|
}), _objectSpread2({
|
|
1427
1492
|
"default": function _default() {
|
|
1428
|
-
return [(_this$$slots$default = (_this$$slots = _this.$slots)["default"])
|
|
1493
|
+
return [((_this$$slots$default = (_this$$slots = _this.$slots)["default"]) === null || _this$$slots$default === void 0 ? void 0 : _this$$slots$default.call(_this$$slots)) || (['text', 'picture'].indexOf(_this.listType) === -1 ? createVNode(resolveComponent("ElIcon"), null, {
|
|
1429
1494
|
"default": function _default() {
|
|
1430
1495
|
return [createVNode(script$1, null, null)];
|
|
1431
1496
|
}
|
|
@@ -1435,7 +1500,7 @@ var Upload = defineComponent({
|
|
|
1435
1500
|
"default": function _default() {
|
|
1436
1501
|
return [createTextVNode("\u70B9\u51FB\u4E0A\u4F20")];
|
|
1437
1502
|
}
|
|
1438
|
-
})];
|
|
1503
|
+
}))];
|
|
1439
1504
|
}
|
|
1440
1505
|
}, getSlot(this.$slots, ['default']))), createVNode(resolveComponent("ElDialog"), {
|
|
1441
1506
|
"appendToBody": true,
|
|
@@ -2134,6 +2199,7 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2134
2199
|
},
|
|
2135
2200
|
index: [String, Number],
|
|
2136
2201
|
api: Object,
|
|
2202
|
+
locale: [String, Object],
|
|
2137
2203
|
name: String,
|
|
2138
2204
|
subForm: {
|
|
2139
2205
|
type: Boolean,
|
|
@@ -2377,7 +2443,7 @@ function $FormCreate(FormCreate, components, directives) {
|
|
|
2377
2443
|
|
|
2378
2444
|
var normalMerge = ['props'];
|
|
2379
2445
|
var toArrayMerge = ['class', 'style', 'directives'];
|
|
2380
|
-
var functionalMerge = ['on'];
|
|
2446
|
+
var functionalMerge = ['on', 'hook'];
|
|
2381
2447
|
|
|
2382
2448
|
var mergeProps = function mergeProps(objects) {
|
|
2383
2449
|
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -2474,15 +2540,11 @@ function lower(str) {
|
|
|
2474
2540
|
|
|
2475
2541
|
var PREFIX = '[[FORM-CREATE-PREFIX-';
|
|
2476
2542
|
var SUFFIX = '-FORM-CREATE-SUFFIX]]';
|
|
2477
|
-
var $T = '$FN:';
|
|
2478
|
-
var $TX = '$FNX:';
|
|
2479
|
-
var $ON = '$GLOBAL:';
|
|
2480
|
-
var FUNCTION = 'function';
|
|
2481
2543
|
function toJson(obj, space) {
|
|
2482
2544
|
return JSON.stringify(deepExtend(Array.isArray(obj) ? [] : {}, obj, true), function (key, val) {
|
|
2483
2545
|
if (val && val._isVue === true) return undefined;
|
|
2484
2546
|
|
|
2485
|
-
if (
|
|
2547
|
+
if (typeof val !== 'function') {
|
|
2486
2548
|
return val;
|
|
2487
2549
|
}
|
|
2488
2550
|
|
|
@@ -2509,11 +2571,14 @@ function parseFn(fn, mode) {
|
|
|
2509
2571
|
if (v.indexOf(SUFFIX) > 0 && v.indexOf(PREFIX) === 0) {
|
|
2510
2572
|
v = v.replace(SUFFIX, '').replace(PREFIX, '');
|
|
2511
2573
|
flag = true;
|
|
2512
|
-
} else if (v.indexOf($
|
|
2513
|
-
v = v.
|
|
2574
|
+
} else if (v.indexOf('$FN:') === 0) {
|
|
2575
|
+
v = v.substring(4);
|
|
2514
2576
|
flag = true;
|
|
2515
|
-
} else if (v.indexOf($
|
|
2516
|
-
|
|
2577
|
+
} else if (v.indexOf('$EXEC:') === 0) {
|
|
2578
|
+
v = v.substring(6);
|
|
2579
|
+
flag = true;
|
|
2580
|
+
} else if (v.indexOf('$GLOBAL:') === 0) {
|
|
2581
|
+
var name = v.substring(8);
|
|
2517
2582
|
|
|
2518
2583
|
v = function v() {
|
|
2519
2584
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -2532,17 +2597,19 @@ function parseFn(fn, mode) {
|
|
|
2532
2597
|
v.__json = fn;
|
|
2533
2598
|
v.__inject = true;
|
|
2534
2599
|
return v;
|
|
2535
|
-
} else if (v.indexOf($
|
|
2536
|
-
v = makeFn('function($inject){' + v.
|
|
2600
|
+
} else if (v.indexOf('$FNX:') === 0) {
|
|
2601
|
+
v = makeFn('function($inject){' + v.substring(5) + '}');
|
|
2537
2602
|
v.__json = fn;
|
|
2538
2603
|
v.__inject = true;
|
|
2539
2604
|
return v;
|
|
2540
|
-
} else if (!mode && v.indexOf(
|
|
2605
|
+
} else if (!mode && v.indexOf('function ') === 0 && v !== 'function ') {
|
|
2606
|
+
flag = true;
|
|
2607
|
+
} else if (!mode && v.indexOf('function(') === 0 && v !== 'function(') {
|
|
2541
2608
|
flag = true;
|
|
2542
2609
|
}
|
|
2543
2610
|
|
|
2544
2611
|
if (!flag) return fn;
|
|
2545
|
-
var val = makeFn(v
|
|
2612
|
+
var val = makeFn(v);
|
|
2546
2613
|
val.__json = fn;
|
|
2547
2614
|
return val;
|
|
2548
2615
|
} catch (e) {
|
|
@@ -2908,7 +2975,17 @@ function fetch$1(option) {
|
|
|
2908
2975
|
}
|
|
2909
2976
|
|
|
2910
2977
|
var xhr = new XMLHttpRequest();
|
|
2911
|
-
var action = option.action;
|
|
2978
|
+
var action = option.action || '';
|
|
2979
|
+
|
|
2980
|
+
if (option.query) {
|
|
2981
|
+
var queryString = new URLSearchParams(option.query).toString();
|
|
2982
|
+
|
|
2983
|
+
if (action.includes('?')) {
|
|
2984
|
+
action += "&".concat(queryString);
|
|
2985
|
+
} else {
|
|
2986
|
+
action += "?".concat(queryString);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2912
2989
|
|
|
2913
2990
|
xhr.onerror = function error(e) {
|
|
2914
2991
|
option.onError(e);
|
|
@@ -2949,7 +3026,7 @@ function fetch$1(option) {
|
|
|
2949
3026
|
});
|
|
2950
3027
|
xhr.send(formData);
|
|
2951
3028
|
}
|
|
2952
|
-
function asyncFetch(config, _fetch) {
|
|
3029
|
+
function asyncFetch(config, _fetch, api) {
|
|
2953
3030
|
return new Promise(function (resolve, reject) {
|
|
2954
3031
|
(_fetch || fetch$1)(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
2955
3032
|
onSuccess: function onSuccess(res) {
|
|
@@ -2967,7 +3044,7 @@ function asyncFetch(config, _fetch) {
|
|
|
2967
3044
|
};
|
|
2968
3045
|
}
|
|
2969
3046
|
|
|
2970
|
-
resolve(fn(res));
|
|
3047
|
+
resolve(fn(res, undefined, api));
|
|
2971
3048
|
},
|
|
2972
3049
|
onError: function onError(err) {
|
|
2973
3050
|
reject(err);
|
|
@@ -3572,7 +3649,7 @@ function Api(h) {
|
|
|
3572
3649
|
opt = deepCopy(opt);
|
|
3573
3650
|
opt = h.loadFetchVar(opt);
|
|
3574
3651
|
h.beforeFetch(opt).then(function () {
|
|
3575
|
-
return asyncFetch(opt, h.fc.create.fetch).then(function (res) {
|
|
3652
|
+
return asyncFetch(opt, h.fc.create.fetch, api).then(function (res) {
|
|
3576
3653
|
invoke(function () {
|
|
3577
3654
|
return opt.onSuccess && opt.onSuccess(res);
|
|
3578
3655
|
});
|
|
@@ -3592,7 +3669,7 @@ function Api(h) {
|
|
|
3592
3669
|
|
|
3593
3670
|
_opt = h.loadFetchVar(_opt, get);
|
|
3594
3671
|
h.beforeFetch(_opt).then(function () {
|
|
3595
|
-
return asyncFetch(_opt, h.fc.create.fetch).then(function (res) {
|
|
3672
|
+
return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
|
|
3596
3673
|
invoke(function () {
|
|
3597
3674
|
return _opt.onSuccess && _opt.onSuccess(res);
|
|
3598
3675
|
});
|
|
@@ -3615,6 +3692,12 @@ function Api(h) {
|
|
|
3615
3692
|
refreshData: function refreshData(id) {
|
|
3616
3693
|
return h.fc.refreshData(id);
|
|
3617
3694
|
},
|
|
3695
|
+
t: function t(id, params) {
|
|
3696
|
+
return h.fc.t(id, params);
|
|
3697
|
+
},
|
|
3698
|
+
getLocale: function getLocale() {
|
|
3699
|
+
return h.fc.getLocale();
|
|
3700
|
+
},
|
|
3618
3701
|
helper: {
|
|
3619
3702
|
tidyFields: tidyFields,
|
|
3620
3703
|
props: props
|
|
@@ -3945,15 +4028,19 @@ function useRender$1(Render) {
|
|
|
3945
4028
|
},
|
|
3946
4029
|
none: function none(vn) {
|
|
3947
4030
|
if (vn) {
|
|
3948
|
-
|
|
3949
|
-
vn.props["class"].push('fc-none');
|
|
3950
|
-
} else {
|
|
3951
|
-
vn.props["class"] = vn.props["class"] ? [vn.props["class"], 'fc-none'] : 'fc-none';
|
|
3952
|
-
}
|
|
3953
|
-
|
|
4031
|
+
vn.props["class"] = this.mergeClass(vn.props["class"], 'fc-none');
|
|
3954
4032
|
return vn;
|
|
3955
4033
|
}
|
|
3956
4034
|
},
|
|
4035
|
+
mergeClass: function mergeClass(target, value) {
|
|
4036
|
+
if (Array.isArray(target)) {
|
|
4037
|
+
target.push(value);
|
|
4038
|
+
} else {
|
|
4039
|
+
return target ? [target, value] : value;
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
return target;
|
|
4043
|
+
},
|
|
3957
4044
|
stable: function stable(vn) {
|
|
3958
4045
|
var _this5 = this;
|
|
3959
4046
|
|
|
@@ -4053,6 +4140,7 @@ function useRender$1(Render) {
|
|
|
4053
4140
|
callback: function callback(value) {
|
|
4054
4141
|
_this7.onInput(ctx, value);
|
|
4055
4142
|
},
|
|
4143
|
+
modelField: field,
|
|
4056
4144
|
value: this.$handle.getFormData(ctx)
|
|
4057
4145
|
};
|
|
4058
4146
|
props.push({
|
|
@@ -4071,6 +4159,7 @@ function useRender$1(Render) {
|
|
|
4071
4159
|
ctx.el = this.vm.refs[ctx.ref] || el;
|
|
4072
4160
|
ctx.parser.mounted(ctx);
|
|
4073
4161
|
this.$handle.effect(ctx, 'mounted');
|
|
4162
|
+
this.$handle.targetHook(ctx, 'mounted');
|
|
4074
4163
|
},
|
|
4075
4164
|
onInput: function onInput(ctx, value) {
|
|
4076
4165
|
if (ctx.prop.modelEmit) {
|
|
@@ -4632,43 +4721,17 @@ extend(RuleContext.prototype, {
|
|
|
4632
4721
|
var rule = _objectSpread2({}, this.rule);
|
|
4633
4722
|
|
|
4634
4723
|
delete rule.children;
|
|
4724
|
+
delete rule.validate;
|
|
4635
4725
|
this.prop = mergeRule({}, [rule].concat(_toConsumableArray(Object.keys(this.payload).map(function (k) {
|
|
4636
4726
|
return _this3.payload[k];
|
|
4637
4727
|
})), [this.computed]));
|
|
4728
|
+
this.prop.validate = [].concat(_toConsumableArray(this.refRule.__$validate.value || []), _toConsumableArray(this.prop.validate || []));
|
|
4638
4729
|
},
|
|
4639
4730
|
initNone: function initNone() {
|
|
4640
4731
|
this.none = !(is.Undef(this.prop.display) || !!this.prop.display);
|
|
4641
4732
|
},
|
|
4642
4733
|
injectValidate: function injectValidate() {
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
return toArray(this.prop.validate).map(function (item) {
|
|
4646
|
-
if (is.Function(item.validator)) {
|
|
4647
|
-
var temp = _objectSpread2({}, item);
|
|
4648
|
-
|
|
4649
|
-
var that = _this4;
|
|
4650
|
-
|
|
4651
|
-
temp.validator = function () {
|
|
4652
|
-
var _item$validator;
|
|
4653
|
-
|
|
4654
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4655
|
-
args[_key] = arguments[_key];
|
|
4656
|
-
}
|
|
4657
|
-
|
|
4658
|
-
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
4659
|
-
that: this,
|
|
4660
|
-
id: that.id,
|
|
4661
|
-
field: that.field,
|
|
4662
|
-
rule: that.rule,
|
|
4663
|
-
api: that.$handle.api
|
|
4664
|
-
}].concat(args));
|
|
4665
|
-
};
|
|
4666
|
-
|
|
4667
|
-
return temp;
|
|
4668
|
-
}
|
|
4669
|
-
|
|
4670
|
-
return item;
|
|
4671
|
-
});
|
|
4734
|
+
return this.prop.validate;
|
|
4672
4735
|
},
|
|
4673
4736
|
check: function check(handle) {
|
|
4674
4737
|
return this.vm === handle.vm;
|
|
@@ -4718,15 +4781,15 @@ extend(RuleContext.prototype, {
|
|
|
4718
4781
|
this.ctrlRule = [];
|
|
4719
4782
|
},
|
|
4720
4783
|
rm: function rm() {
|
|
4721
|
-
var
|
|
4784
|
+
var _this4 = this;
|
|
4722
4785
|
|
|
4723
4786
|
var _rm = function _rm() {
|
|
4724
|
-
var index =
|
|
4787
|
+
var index = _this4.root.indexOf(_this4.origin);
|
|
4725
4788
|
|
|
4726
4789
|
if (index > -1) {
|
|
4727
|
-
|
|
4790
|
+
_this4.root.splice(index, 1);
|
|
4728
4791
|
|
|
4729
|
-
|
|
4792
|
+
_this4.$handle && _this4.$handle.refresh();
|
|
4730
4793
|
}
|
|
4731
4794
|
};
|
|
4732
4795
|
|
|
@@ -4737,17 +4800,17 @@ extend(RuleContext.prototype, {
|
|
|
4737
4800
|
}
|
|
4738
4801
|
|
|
4739
4802
|
this.$handle.noWatch(function () {
|
|
4740
|
-
|
|
4741
|
-
|
|
4803
|
+
_this4.$handle.deferSyncValue(function () {
|
|
4804
|
+
_this4.rmCtrl();
|
|
4742
4805
|
|
|
4743
4806
|
_rm();
|
|
4744
4807
|
|
|
4745
|
-
|
|
4808
|
+
_this4.$handle.rmCtx(_this4);
|
|
4746
4809
|
|
|
4747
|
-
extend(
|
|
4810
|
+
extend(_this4, {
|
|
4748
4811
|
root: []
|
|
4749
4812
|
});
|
|
4750
|
-
},
|
|
4813
|
+
}, _this4.input);
|
|
4751
4814
|
});
|
|
4752
4815
|
},
|
|
4753
4816
|
update: function update(handle, init) {
|
|
@@ -4985,7 +5048,11 @@ function useLoader(Handler) {
|
|
|
4985
5048
|
|
|
4986
5049
|
_this6.setCtx(ctx);
|
|
4987
5050
|
|
|
4988
|
-
!isCopy && !isInit
|
|
5051
|
+
if (!isCopy && !isInit) {
|
|
5052
|
+
_this6.effect(ctx, 'load');
|
|
5053
|
+
|
|
5054
|
+
_this6.targetHook(ctx, 'load');
|
|
5055
|
+
}
|
|
4989
5056
|
|
|
4990
5057
|
_this6.effect(ctx, 'created');
|
|
4991
5058
|
|
|
@@ -5237,6 +5304,9 @@ function useInput(Handler) {
|
|
|
5237
5304
|
this.valueChange(ctx, value);
|
|
5238
5305
|
this.vm.emit('change', ctx.field, value, ctx.origin, this.api, setFlag || false);
|
|
5239
5306
|
this.effect(ctx, 'value');
|
|
5307
|
+
this.targetHook(ctx, 'value', {
|
|
5308
|
+
value: value
|
|
5309
|
+
});
|
|
5240
5310
|
this.emitEvent('change', ctx.field, value, {
|
|
5241
5311
|
rule: ctx.origin,
|
|
5242
5312
|
api: this.api,
|
|
@@ -5336,7 +5406,7 @@ function useInput(Handler) {
|
|
|
5336
5406
|
this.syncValue();
|
|
5337
5407
|
},
|
|
5338
5408
|
isIgnore: function isIgnore(rule) {
|
|
5339
|
-
return rule.ignore || this.options.ignoreHiddenFields && rule.hidden;
|
|
5409
|
+
return rule.ignore === true || rule.ignore === 'hidden' && rule.hidden || this.options.ignoreHiddenFields && rule.hidden;
|
|
5340
5410
|
},
|
|
5341
5411
|
appendValue: function appendValue(rule) {
|
|
5342
5412
|
if ((!rule.field || !hasProperty(this.appendData, rule.field)) && !this.options.forceCoverValue) {
|
|
@@ -5582,12 +5652,25 @@ function useContext(Handler) {
|
|
|
5582
5652
|
}
|
|
5583
5653
|
|
|
5584
5654
|
_this.watching = true;
|
|
5655
|
+
nextTick(function () {
|
|
5656
|
+
_this.targetHook(ctx, 'watch', {
|
|
5657
|
+
key: key,
|
|
5658
|
+
oldValue: o,
|
|
5659
|
+
newValue: n
|
|
5660
|
+
});
|
|
5661
|
+
});
|
|
5585
5662
|
|
|
5586
5663
|
if (key === 'hidden' && Boolean(n) !== Boolean(o)) {
|
|
5587
5664
|
_this.$render.clearCacheAll();
|
|
5665
|
+
|
|
5666
|
+
nextTick(function () {
|
|
5667
|
+
_this.targetHook(ctx, 'hidden', {
|
|
5668
|
+
value: n
|
|
5669
|
+
});
|
|
5670
|
+
});
|
|
5588
5671
|
}
|
|
5589
5672
|
|
|
5590
|
-
if (key === 'ignore' && ctx.input || key === 'hidden' && ctx.input && _this.options.ignoreHiddenFields) {
|
|
5673
|
+
if (key === 'ignore' && ctx.input || key === 'hidden' && ctx.input && (ctx.rule.ignore === 'hidden' || _this.options.ignoreHiddenFields)) {
|
|
5591
5674
|
_this.syncForm();
|
|
5592
5675
|
} else if (key === 'link') {
|
|
5593
5676
|
ctx.link();
|
|
@@ -5626,6 +5709,71 @@ function useContext(Handler) {
|
|
|
5626
5709
|
sync: flag
|
|
5627
5710
|
}));
|
|
5628
5711
|
});
|
|
5712
|
+
ctx.refRule['__$title'] = computed(function () {
|
|
5713
|
+
var title = (_typeof(ctx.rule.title) === 'object' ? ctx.rule.title.title : ctx.rule.title) || '';
|
|
5714
|
+
|
|
5715
|
+
if (title) {
|
|
5716
|
+
var match = title.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
|
|
5717
|
+
|
|
5718
|
+
if (match) {
|
|
5719
|
+
title = _this.api.t(match[1]);
|
|
5720
|
+
}
|
|
5721
|
+
}
|
|
5722
|
+
|
|
5723
|
+
return title;
|
|
5724
|
+
});
|
|
5725
|
+
ctx.refRule['__$info'] = computed(function () {
|
|
5726
|
+
var info = (_typeof(ctx.rule.info) === 'object' ? ctx.rule.info.info : ctx.rule.info) || '';
|
|
5727
|
+
|
|
5728
|
+
if (info) {
|
|
5729
|
+
var match = info.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
|
|
5730
|
+
|
|
5731
|
+
if (match) {
|
|
5732
|
+
info = _this.api.t(match[1]);
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5735
|
+
|
|
5736
|
+
return info;
|
|
5737
|
+
});
|
|
5738
|
+
ctx.refRule['__$validate'] = computed(function () {
|
|
5739
|
+
return toArray(ctx.rule.validate).map(function (item) {
|
|
5740
|
+
var temp = _objectSpread2({}, item);
|
|
5741
|
+
|
|
5742
|
+
if (temp.message) {
|
|
5743
|
+
var match = temp.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
|
|
5744
|
+
|
|
5745
|
+
if (match) {
|
|
5746
|
+
temp.message = _this.api.t(match[1], {
|
|
5747
|
+
title: ctx.refRule.__$title.value
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
|
|
5752
|
+
if (is.Function(temp.validator)) {
|
|
5753
|
+
var that = ctx;
|
|
5754
|
+
|
|
5755
|
+
temp.validator = function () {
|
|
5756
|
+
var _item$validator;
|
|
5757
|
+
|
|
5758
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5759
|
+
args[_key] = arguments[_key];
|
|
5760
|
+
}
|
|
5761
|
+
|
|
5762
|
+
return (_item$validator = item.validator).call.apply(_item$validator, [{
|
|
5763
|
+
that: this,
|
|
5764
|
+
id: that.id,
|
|
5765
|
+
field: that.field,
|
|
5766
|
+
rule: that.rule,
|
|
5767
|
+
api: that.$handle.api
|
|
5768
|
+
}].concat(args));
|
|
5769
|
+
};
|
|
5770
|
+
|
|
5771
|
+
return temp;
|
|
5772
|
+
}
|
|
5773
|
+
|
|
5774
|
+
return temp;
|
|
5775
|
+
});
|
|
5776
|
+
});
|
|
5629
5777
|
|
|
5630
5778
|
if (ctx.input) {
|
|
5631
5779
|
var val = toRef(ctx.rule, 'value');
|
|
@@ -5713,25 +5861,42 @@ function useContext(Handler) {
|
|
|
5713
5861
|
var or = item.mode === 'OR';
|
|
5714
5862
|
var valid = true;
|
|
5715
5863
|
|
|
5716
|
-
|
|
5864
|
+
var _loop = function _loop(i) {
|
|
5717
5865
|
var one = item.group[i];
|
|
5718
5866
|
var flag = void 0;
|
|
5867
|
+
var field = one.field;
|
|
5868
|
+
|
|
5869
|
+
if (one.variable) {
|
|
5870
|
+
field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
|
|
5871
|
+
}
|
|
5719
5872
|
|
|
5720
5873
|
if (one.mode) {
|
|
5721
5874
|
flag = checkCondition(one);
|
|
5722
5875
|
} else if (!condition[one.condition]) {
|
|
5723
5876
|
flag = false;
|
|
5877
|
+
} else if (is.Function(one.handler)) {
|
|
5878
|
+
flag = invoke(function () {
|
|
5879
|
+
return one.handler(_this2.api, ctx.rule);
|
|
5880
|
+
});
|
|
5724
5881
|
} else {
|
|
5725
|
-
flag = new Function('$condition', '$val', '$form', '$group', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(
|
|
5882
|
+
flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
|
|
5726
5883
|
}
|
|
5727
5884
|
|
|
5728
5885
|
if (or && flag) {
|
|
5729
|
-
return
|
|
5886
|
+
return {
|
|
5887
|
+
v: true
|
|
5888
|
+
};
|
|
5730
5889
|
}
|
|
5731
5890
|
|
|
5732
5891
|
if (!or) {
|
|
5733
5892
|
valid = valid && flag;
|
|
5734
5893
|
}
|
|
5894
|
+
};
|
|
5895
|
+
|
|
5896
|
+
for (var i = 0; i < item.group.length; i++) {
|
|
5897
|
+
var _ret = _loop(i);
|
|
5898
|
+
|
|
5899
|
+
if (_typeof(_ret) === "object") return _ret.v;
|
|
5735
5900
|
}
|
|
5736
5901
|
|
|
5737
5902
|
return or ? false : valid;
|
|
@@ -5767,8 +5932,8 @@ function useContext(Handler) {
|
|
|
5767
5932
|
obj[k] = function () {
|
|
5768
5933
|
var _that$fc$formulas$k;
|
|
5769
5934
|
|
|
5770
|
-
for (var
|
|
5771
|
-
args[
|
|
5935
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
5936
|
+
args[_key2] = arguments[_key2];
|
|
5772
5937
|
}
|
|
5773
5938
|
|
|
5774
5939
|
return (_that$fc$formulas$k = that.fc.formulas[k]).call.apply(_that$fc$formulas$k, [{
|
|
@@ -5862,6 +6027,7 @@ function useContext(Handler) {
|
|
|
5862
6027
|
this.$render.clearCache(ctx);
|
|
5863
6028
|
ctx["delete"]();
|
|
5864
6029
|
this.effect(ctx, 'deleted');
|
|
6030
|
+
this.targetHook(ctx, 'deleted');
|
|
5865
6031
|
input && !this.fieldCtx[field] && this.vm.emit('remove-field', field, ctx.rule, this.api);
|
|
5866
6032
|
ctx.rule.__ctrl || this.vm.emit('remove-rule', ctx.rule, this.api);
|
|
5867
6033
|
return ctx;
|
|
@@ -5908,6 +6074,25 @@ function useLifecycle(Handler) {
|
|
|
5908
6074
|
}
|
|
5909
6075
|
|
|
5910
6076
|
(_this$bus = this.bus).$emit.apply(_this$bus, [name].concat(args));
|
|
6077
|
+
},
|
|
6078
|
+
targetHook: function targetHook(ctx, name, args) {
|
|
6079
|
+
var _ctx$prop,
|
|
6080
|
+
_ctx$prop$hook,
|
|
6081
|
+
_this2 = this;
|
|
6082
|
+
|
|
6083
|
+
var hook = (_ctx$prop = ctx.prop) === null || _ctx$prop === void 0 ? void 0 : (_ctx$prop$hook = _ctx$prop.hook) === null || _ctx$prop$hook === void 0 ? void 0 : _ctx$prop$hook[name];
|
|
6084
|
+
|
|
6085
|
+
if (hook) {
|
|
6086
|
+
hook = Array.isArray(hook) ? hook : [hook];
|
|
6087
|
+
hook.forEach(function (fn) {
|
|
6088
|
+
invoke(function () {
|
|
6089
|
+
return fn(_objectSpread2(_objectSpread2({}, args || {}), {}, {
|
|
6090
|
+
rule: ctx.rule,
|
|
6091
|
+
api: _this2.api
|
|
6092
|
+
}));
|
|
6093
|
+
});
|
|
6094
|
+
});
|
|
6095
|
+
}
|
|
5911
6096
|
}
|
|
5912
6097
|
});
|
|
5913
6098
|
}
|
|
@@ -6375,7 +6560,7 @@ var loadData = function loadData(fc) {
|
|
|
6375
6560
|
var unwatchs = [];
|
|
6376
6561
|
attrs.forEach(function (attr) {
|
|
6377
6562
|
if (attr && (attr.attr || attr.template)) {
|
|
6378
|
-
var
|
|
6563
|
+
var fn = function fn(get) {
|
|
6379
6564
|
var value;
|
|
6380
6565
|
|
|
6381
6566
|
if (attr.template) {
|
|
@@ -6401,7 +6586,14 @@ var loadData = function loadData(fc) {
|
|
|
6401
6586
|
}
|
|
6402
6587
|
|
|
6403
6588
|
api.sync(rule);
|
|
6404
|
-
}
|
|
6589
|
+
};
|
|
6590
|
+
|
|
6591
|
+
var callback = function callback(get) {
|
|
6592
|
+
return fn(get);
|
|
6593
|
+
};
|
|
6594
|
+
|
|
6595
|
+
var unwatch = fc.watchLoadData(callback);
|
|
6596
|
+
fn = debounce(fn, attr.wait || 300);
|
|
6405
6597
|
|
|
6406
6598
|
if (attr.watch !== false) {
|
|
6407
6599
|
unwatchs.push(unwatch);
|
|
@@ -6422,10 +6614,72 @@ var loadData = function loadData(fc) {
|
|
|
6422
6614
|
inject.clearProp();
|
|
6423
6615
|
}
|
|
6424
6616
|
};
|
|
6425
|
-
loadData.watch = loadData.
|
|
6617
|
+
loadData.watch = loadData.mounted;
|
|
6426
6618
|
return loadData;
|
|
6427
6619
|
};
|
|
6428
6620
|
|
|
6621
|
+
var t = function t(fc) {
|
|
6622
|
+
var t = {
|
|
6623
|
+
name: 't',
|
|
6624
|
+
_fn: [],
|
|
6625
|
+
loaded: function loaded(inject, rule, api) {
|
|
6626
|
+
this.deleted(inject);
|
|
6627
|
+
var attrs = inject.getValue() || {};
|
|
6628
|
+
var unwatchs = [];
|
|
6629
|
+
Object.keys(attrs).forEach(function (key) {
|
|
6630
|
+
var attr = attrs[key];
|
|
6631
|
+
|
|
6632
|
+
if (attr) {
|
|
6633
|
+
var isObj = _typeof(attr) === 'object';
|
|
6634
|
+
|
|
6635
|
+
var fn = function fn(get) {
|
|
6636
|
+
var value = fc.t(isObj ? attr.attr : attr, isObj ? attr.params : null, get);
|
|
6637
|
+
|
|
6638
|
+
var _rule = isObj && attr.modify ? rule : inject.getProp();
|
|
6639
|
+
|
|
6640
|
+
if (key === 'child') {
|
|
6641
|
+
if (_rule.children) {
|
|
6642
|
+
_rule.children[0] = value;
|
|
6643
|
+
} else {
|
|
6644
|
+
_rule.children = [value];
|
|
6645
|
+
}
|
|
6646
|
+
} else {
|
|
6647
|
+
deepSet(_rule, key, value);
|
|
6648
|
+
}
|
|
6649
|
+
|
|
6650
|
+
api.sync(rule);
|
|
6651
|
+
};
|
|
6652
|
+
|
|
6653
|
+
var callback = function callback(get) {
|
|
6654
|
+
return fn(get);
|
|
6655
|
+
};
|
|
6656
|
+
|
|
6657
|
+
var unwatch = fc.watchLoadData(callback);
|
|
6658
|
+
fn = debounce(fn, attr.wait || 300);
|
|
6659
|
+
|
|
6660
|
+
if (attr.watch !== false) {
|
|
6661
|
+
unwatchs.push(unwatch);
|
|
6662
|
+
} else {
|
|
6663
|
+
unwatch();
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
});
|
|
6667
|
+
this._fn[inject.id] = unwatchs;
|
|
6668
|
+
},
|
|
6669
|
+
deleted: function deleted(inject) {
|
|
6670
|
+
if (this._fn[inject.id]) {
|
|
6671
|
+
this._fn[inject.id].forEach(function (un) {
|
|
6672
|
+
un();
|
|
6673
|
+
});
|
|
6674
|
+
}
|
|
6675
|
+
|
|
6676
|
+
inject.clearProp();
|
|
6677
|
+
}
|
|
6678
|
+
};
|
|
6679
|
+
t.watch = t.loaded;
|
|
6680
|
+
return t;
|
|
6681
|
+
};
|
|
6682
|
+
|
|
6429
6683
|
var componentValidate = {
|
|
6430
6684
|
name: 'componentValidate',
|
|
6431
6685
|
load: function load(attr, rule, api) {
|
|
@@ -6624,6 +6878,7 @@ var fetch = function fetch(fc) {
|
|
|
6624
6878
|
var $provider = {
|
|
6625
6879
|
fetch: fetch,
|
|
6626
6880
|
loadData: loadData,
|
|
6881
|
+
t: t,
|
|
6627
6882
|
componentValidate: componentValidate
|
|
6628
6883
|
};
|
|
6629
6884
|
|
|
@@ -7026,7 +7281,7 @@ function FormCreateFactory(config) {
|
|
|
7026
7281
|
options: ref({}),
|
|
7027
7282
|
extendApiFn: extendApiFn,
|
|
7028
7283
|
fetchCache: new WeakMap(),
|
|
7029
|
-
tmpData: {}
|
|
7284
|
+
tmpData: reactive({})
|
|
7030
7285
|
});
|
|
7031
7286
|
listener.forEach(function (item) {
|
|
7032
7287
|
_this.bus.$on(item.name, item.callback);
|
|
@@ -7101,6 +7356,26 @@ function FormCreateFactory(config) {
|
|
|
7101
7356
|
});
|
|
7102
7357
|
}
|
|
7103
7358
|
},
|
|
7359
|
+
t: function t(id, params, get) {
|
|
7360
|
+
var value = get ? get('$t.' + id) : this.globalLanguageDriver(id);
|
|
7361
|
+
|
|
7362
|
+
if (value == null && this.vm.appContext.config.globalProperties.$i18n) {
|
|
7363
|
+
return this.vm.appContext.config.globalProperties.$i18n.t(id, params);
|
|
7364
|
+
}
|
|
7365
|
+
|
|
7366
|
+
if (value == null) {
|
|
7367
|
+
value = '';
|
|
7368
|
+
}
|
|
7369
|
+
|
|
7370
|
+
if (value && params) {
|
|
7371
|
+
Object.keys(params).forEach(function (param) {
|
|
7372
|
+
var regex = new RegExp("{".concat(param, "}"), 'g');
|
|
7373
|
+
value = value.replace(regex, params[param]);
|
|
7374
|
+
});
|
|
7375
|
+
}
|
|
7376
|
+
|
|
7377
|
+
return value;
|
|
7378
|
+
},
|
|
7104
7379
|
globalDataDriver: function globalDataDriver(id) {
|
|
7105
7380
|
var _this4 = this;
|
|
7106
7381
|
|
|
@@ -7184,6 +7459,41 @@ function FormCreateFactory(config) {
|
|
|
7184
7459
|
}
|
|
7185
7460
|
}
|
|
7186
7461
|
},
|
|
7462
|
+
getLocale: function getLocale() {
|
|
7463
|
+
var locale = this.vm.setupState.top.props.locale;
|
|
7464
|
+
|
|
7465
|
+
if (locale && _typeof(locale) === 'object') {
|
|
7466
|
+
return locale.name;
|
|
7467
|
+
}
|
|
7468
|
+
|
|
7469
|
+
if (typeof locale === 'string') {
|
|
7470
|
+
return locale;
|
|
7471
|
+
}
|
|
7472
|
+
|
|
7473
|
+
if (this.vm.appContext.config.globalProperties.$i18n && this.vm.appContext.config.globalProperties.$i18n.locale) {
|
|
7474
|
+
return this.vm.appContext.config.globalProperties.$i18n.locale;
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
return 'zh-cn';
|
|
7478
|
+
},
|
|
7479
|
+
globalLanguageDriver: function globalLanguageDriver(id) {
|
|
7480
|
+
var locale = this.vm.setupState.top.props.locale;
|
|
7481
|
+
var value = undefined;
|
|
7482
|
+
|
|
7483
|
+
if (locale && _typeof(locale) === 'object') {
|
|
7484
|
+
value = deepGet(locale, id);
|
|
7485
|
+
}
|
|
7486
|
+
|
|
7487
|
+
if (value == null) {
|
|
7488
|
+
var language = this.options.value.language || {};
|
|
7489
|
+
|
|
7490
|
+
var _locale = this.getLocale();
|
|
7491
|
+
|
|
7492
|
+
value = deepGet(language[_locale], id);
|
|
7493
|
+
}
|
|
7494
|
+
|
|
7495
|
+
return value;
|
|
7496
|
+
},
|
|
7187
7497
|
globalVarDriver: function globalVarDriver(id) {
|
|
7188
7498
|
var _this5 = this;
|
|
7189
7499
|
|
|
@@ -7241,6 +7551,12 @@ function FormCreateFactory(config) {
|
|
|
7241
7551
|
} else if (key === '$var') {
|
|
7242
7552
|
val = this.globalVarDriver(split.join('.'));
|
|
7243
7553
|
split = [];
|
|
7554
|
+
} else if (key === '$locale') {
|
|
7555
|
+
val = this.getLocale();
|
|
7556
|
+
split = [];
|
|
7557
|
+
} else if (key === '$t') {
|
|
7558
|
+
val = this.globalLanguageDriver(split.join('.'));
|
|
7559
|
+
split = [];
|
|
7244
7560
|
} else {
|
|
7245
7561
|
var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
|
|
7246
7562
|
val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(id);
|
|
@@ -7270,8 +7586,9 @@ function FormCreateFactory(config) {
|
|
|
7270
7586
|
return unwatch[id].val;
|
|
7271
7587
|
}
|
|
7272
7588
|
|
|
7273
|
-
var
|
|
7274
|
-
|
|
7589
|
+
var data = computed(function () {
|
|
7590
|
+
return _this6.getLoadData(id, def);
|
|
7591
|
+
});
|
|
7275
7592
|
var split = id.split('.');
|
|
7276
7593
|
var key = split.shift();
|
|
7277
7594
|
var key2 = split.shift() || '';
|
|
@@ -7285,6 +7602,9 @@ function FormCreateFactory(config) {
|
|
|
7285
7602
|
run(true);
|
|
7286
7603
|
}
|
|
7287
7604
|
}, 0);
|
|
7605
|
+
var un = watch(data, function (n) {
|
|
7606
|
+
callback();
|
|
7607
|
+
});
|
|
7288
7608
|
|
|
7289
7609
|
_this6.bus.$on('$loadData.' + key, callback);
|
|
7290
7610
|
|
|
@@ -7299,10 +7619,12 @@ function FormCreateFactory(config) {
|
|
|
7299
7619
|
if (key2) {
|
|
7300
7620
|
_this6.bus.$off('$loadData.' + key + '.' + key2, callback);
|
|
7301
7621
|
}
|
|
7622
|
+
|
|
7623
|
+
un();
|
|
7302
7624
|
},
|
|
7303
|
-
val:
|
|
7625
|
+
val: data.value
|
|
7304
7626
|
};
|
|
7305
|
-
return
|
|
7627
|
+
return data.value;
|
|
7306
7628
|
};
|
|
7307
7629
|
|
|
7308
7630
|
run(false);
|
|
@@ -7508,6 +7830,7 @@ function FormCreateFactory(config) {
|
|
|
7508
7830
|
var DEFAULT_FORMATS = {
|
|
7509
7831
|
date: 'YYYY-MM-DD',
|
|
7510
7832
|
month: 'YYYY-MM',
|
|
7833
|
+
week: 'YYYY-wo',
|
|
7511
7834
|
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
7512
7835
|
timerange: 'HH:mm:ss',
|
|
7513
7836
|
daterange: 'YYYY-MM-DD',
|
|
@@ -7673,6 +7996,7 @@ var alias = {
|
|
|
7673
7996
|
autoComplete: PRE + '-autocomplete',
|
|
7674
7997
|
auto: PRE + '-autocomplete',
|
|
7675
7998
|
group: 'fc-group',
|
|
7999
|
+
array: 'fc-group',
|
|
7676
8000
|
object: 'fc-sub-form',
|
|
7677
8001
|
subForm: 'fc-sub-form'
|
|
7678
8002
|
};
|
|
@@ -7791,12 +8115,9 @@ var manager = {
|
|
|
7791
8115
|
return prop;
|
|
7792
8116
|
},
|
|
7793
8117
|
mergeProp: function mergeProp(ctx) {
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
col: this.options.col || {},
|
|
7798
|
-
title: this.options.title || {}
|
|
7799
|
-
}, ctx.prop], {
|
|
8118
|
+
var _this2 = this;
|
|
8119
|
+
|
|
8120
|
+
var def = {
|
|
7800
8121
|
info: {
|
|
7801
8122
|
trigger: 'hover',
|
|
7802
8123
|
placement: 'top-start',
|
|
@@ -7807,8 +8128,9 @@ var manager = {
|
|
|
7807
8128
|
span: 24
|
|
7808
8129
|
},
|
|
7809
8130
|
wrap: {}
|
|
7810
|
-
}
|
|
7811
|
-
|
|
8131
|
+
};
|
|
8132
|
+
['info', 'wrap', 'col', 'title'].forEach(function (name) {
|
|
8133
|
+
ctx.prop[name] = mergeProps([_this2.options[name] || {}, ctx.prop[name] || {}], def[name]);
|
|
7812
8134
|
});
|
|
7813
8135
|
},
|
|
7814
8136
|
getDefaultOptions: function getDefaultOptions() {
|
|
@@ -7837,22 +8159,22 @@ var manager = {
|
|
|
7837
8159
|
ref: ref
|
|
7838
8160
|
});
|
|
7839
8161
|
extend(this.rule.props, {
|
|
7840
|
-
model:
|
|
8162
|
+
model: $handle.formData
|
|
7841
8163
|
});
|
|
7842
8164
|
},
|
|
7843
8165
|
render: function render(children) {
|
|
7844
|
-
var
|
|
8166
|
+
var _this3 = this;
|
|
7845
8167
|
|
|
7846
8168
|
if (children.slotLen() && !this.$handle.preview) {
|
|
7847
8169
|
children.setSlot(undefined, function () {
|
|
7848
|
-
return
|
|
8170
|
+
return _this3.makeFormBtn();
|
|
7849
8171
|
});
|
|
7850
8172
|
}
|
|
7851
8173
|
|
|
7852
8174
|
return this.$r(this.rule, isFalse(this.options.row.show) ? children.getSlots() : [this.makeRow(children)]);
|
|
7853
8175
|
},
|
|
7854
8176
|
makeWrap: function makeWrap(ctx, children) {
|
|
7855
|
-
var
|
|
8177
|
+
var _this4 = this;
|
|
7856
8178
|
|
|
7857
8179
|
var rule = ctx.prop;
|
|
7858
8180
|
var uni = "".concat(this.key).concat(ctx.key);
|
|
@@ -7871,7 +8193,7 @@ var manager = {
|
|
|
7871
8193
|
prop: ctx.id,
|
|
7872
8194
|
rules: ctx.injectValidate()
|
|
7873
8195
|
}),
|
|
7874
|
-
"class": rule.className,
|
|
8196
|
+
"class": this.$render.mergeClass(rule.className, 'fc-form-item'),
|
|
7875
8197
|
key: "".concat(uni, "fi"),
|
|
7876
8198
|
ref: ctx.wrapRef,
|
|
7877
8199
|
type: 'formItem'
|
|
@@ -7881,7 +8203,7 @@ var manager = {
|
|
|
7881
8203
|
}
|
|
7882
8204
|
}, isTitle ? {
|
|
7883
8205
|
label: function label() {
|
|
7884
|
-
return
|
|
8206
|
+
return _this4.makeInfo(rule, uni, ctx);
|
|
7885
8207
|
}
|
|
7886
8208
|
} : {}));
|
|
7887
8209
|
return inline === true || isFalse(_col) || isFalse(col.show) ? item : this.makeCol(rule, uni, [item]);
|
|
@@ -7892,7 +8214,7 @@ var manager = {
|
|
|
7892
8214
|
return !(!title.title && !title["native"] || isFalse(title.show));
|
|
7893
8215
|
},
|
|
7894
8216
|
makeInfo: function makeInfo(rule, uni, ctx) {
|
|
7895
|
-
var
|
|
8217
|
+
var _this5 = this;
|
|
7896
8218
|
|
|
7897
8219
|
var titleProp = _objectSpread2({}, rule.title);
|
|
7898
8220
|
|
|
@@ -7902,10 +8224,10 @@ var manager = {
|
|
|
7902
8224
|
var form = this.options.form;
|
|
7903
8225
|
var titleSlot = this.getSlot('title');
|
|
7904
8226
|
var children = [titleSlot ? titleSlot({
|
|
7905
|
-
title:
|
|
8227
|
+
title: ctx.refRule.__$title.value,
|
|
7906
8228
|
rule: ctx.rule,
|
|
7907
8229
|
options: this.options
|
|
7908
|
-
}) :
|
|
8230
|
+
}) : ctx.refRule.__$title.value + (form.labelSuffix || form['label-suffix'] || '')];
|
|
7909
8231
|
|
|
7910
8232
|
if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
|
|
7911
8233
|
var prop = {
|
|
@@ -7921,17 +8243,17 @@ var manager = {
|
|
|
7921
8243
|
var field = 'content';
|
|
7922
8244
|
|
|
7923
8245
|
if (infoProp.info && !hasProperty(prop.props, field)) {
|
|
7924
|
-
prop.props[field] =
|
|
8246
|
+
prop.props[field] = ctx.refRule.__$info.value;
|
|
7925
8247
|
}
|
|
7926
8248
|
|
|
7927
8249
|
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), _defineProperty({}, titleProp.slot || (isTip ? 'default' : 'reference'), function () {
|
|
7928
|
-
return
|
|
8250
|
+
return _this5.$r({
|
|
7929
8251
|
type: 'ElIcon',
|
|
7930
8252
|
style: 'top:2px',
|
|
7931
8253
|
key: "".concat(uni, "i")
|
|
7932
8254
|
}, {
|
|
7933
8255
|
"default": function _default() {
|
|
7934
|
-
return
|
|
8256
|
+
return _this5.$r({
|
|
7935
8257
|
type: infoProp.icon === true ? 'icon-warning' : infoProp.icon
|
|
7936
8258
|
});
|
|
7937
8259
|
}
|
|
@@ -7942,6 +8264,7 @@ var manager = {
|
|
|
7942
8264
|
var _prop = mergeProps([titleProp, {
|
|
7943
8265
|
props: tidyRule(titleProp),
|
|
7944
8266
|
key: "".concat(uni, "tit"),
|
|
8267
|
+
"class": 'fc-form-title',
|
|
7945
8268
|
type: titleProp.type || 'span'
|
|
7946
8269
|
}]);
|
|
7947
8270
|
|
|
@@ -7953,7 +8276,7 @@ var manager = {
|
|
|
7953
8276
|
makeCol: function makeCol(rule, uni, children) {
|
|
7954
8277
|
var col = rule.col;
|
|
7955
8278
|
return this.$r({
|
|
7956
|
-
"class": col["class"],
|
|
8279
|
+
"class": this.$render.mergeClass(col["class"], 'fc-form-col'),
|
|
7957
8280
|
type: 'col',
|
|
7958
8281
|
props: col || {
|
|
7959
8282
|
span: 24
|
|
@@ -7966,7 +8289,7 @@ var manager = {
|
|
|
7966
8289
|
return this.$r({
|
|
7967
8290
|
type: 'row',
|
|
7968
8291
|
props: row,
|
|
7969
|
-
"class": row["class"],
|
|
8292
|
+
"class": this.$render.mergeClass(row["class"], 'fc-form-row'),
|
|
7970
8293
|
key: "".concat(this.key, "row")
|
|
7971
8294
|
}, children);
|
|
7972
8295
|
},
|
|
@@ -7987,10 +8310,12 @@ var manager = {
|
|
|
7987
8310
|
|
|
7988
8311
|
var item = this.$r({
|
|
7989
8312
|
type: 'formItem',
|
|
8313
|
+
"class": 'fc-form-item',
|
|
7990
8314
|
key: "".concat(this.key, "fb")
|
|
7991
8315
|
}, vn);
|
|
7992
8316
|
return this.rule.props.inline === true ? item : this.$r({
|
|
7993
8317
|
type: 'col',
|
|
8318
|
+
"class": 'fc-form-col fc-form-footer',
|
|
7994
8319
|
props: {
|
|
7995
8320
|
span: 24
|
|
7996
8321
|
},
|
|
@@ -7998,7 +8323,7 @@ var manager = {
|
|
|
7998
8323
|
}, [item]);
|
|
7999
8324
|
},
|
|
8000
8325
|
makeResetBtn: function makeResetBtn() {
|
|
8001
|
-
var
|
|
8326
|
+
var _this6 = this;
|
|
8002
8327
|
|
|
8003
8328
|
var resetBtn = _objectSpread2({}, this.options.resetBtn);
|
|
8004
8329
|
|
|
@@ -8010,21 +8335,21 @@ var manager = {
|
|
|
8010
8335
|
return this.$r({
|
|
8011
8336
|
type: 'button',
|
|
8012
8337
|
props: resetBtn,
|
|
8013
|
-
"class": '
|
|
8338
|
+
"class": 'fc-reset-btn',
|
|
8014
8339
|
style: {
|
|
8015
8340
|
width: resetBtn.width
|
|
8016
8341
|
},
|
|
8017
8342
|
on: {
|
|
8018
8343
|
click: function click() {
|
|
8019
|
-
var fApi =
|
|
8020
|
-
|
|
8344
|
+
var fApi = _this6.$handle.api;
|
|
8345
|
+
_this6.options.resetBtn.click ? _this6.options.resetBtn.click(fApi) : fApi.resetFields();
|
|
8021
8346
|
}
|
|
8022
8347
|
},
|
|
8023
8348
|
key: "".concat(this.key, "b2")
|
|
8024
8349
|
}, [innerText]);
|
|
8025
8350
|
},
|
|
8026
8351
|
makeSubmitBtn: function makeSubmitBtn() {
|
|
8027
|
-
var
|
|
8352
|
+
var _this7 = this;
|
|
8028
8353
|
|
|
8029
8354
|
var submitBtn = _objectSpread2({}, this.options.submitBtn);
|
|
8030
8355
|
|
|
@@ -8036,14 +8361,14 @@ var manager = {
|
|
|
8036
8361
|
return this.$r({
|
|
8037
8362
|
type: 'button',
|
|
8038
8363
|
props: submitBtn,
|
|
8039
|
-
"class": '
|
|
8364
|
+
"class": 'fc-submit-btn',
|
|
8040
8365
|
style: {
|
|
8041
8366
|
width: submitBtn.width
|
|
8042
8367
|
},
|
|
8043
8368
|
on: {
|
|
8044
8369
|
click: function click() {
|
|
8045
|
-
var fApi =
|
|
8046
|
-
|
|
8370
|
+
var fApi = _this7.$handle.api;
|
|
8371
|
+
_this7.options.submitBtn.click ? _this7.options.submitBtn.click(fApi) : fApi.submit()["catch"](function () {});
|
|
8047
8372
|
}
|
|
8048
8373
|
},
|
|
8049
8374
|
key: "".concat(this.key, "b1")
|
|
@@ -8133,7 +8458,7 @@ function useFrame(maker) {
|
|
|
8133
8458
|
return maker;
|
|
8134
8459
|
}
|
|
8135
8460
|
|
|
8136
|
-
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 .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,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-
|
|
8461
|
+
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 .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,.form-create.is-preview .fc-clock{display:none!important}.fc-wrap-right .el-form-item__label{justify-content:flex-end}.fc-wrap-left .el-form-item__label{justify-content:flex-start}.fc-wrap-top.el-form-item{display:block}.fc-wrap-top.el-form-item .el-form-item__label{display:block;height:auto;line-height:22px;margin-bottom:8px;text-align:left}.el-form--large .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:12px}.el-form--default .fc-wrap-top.el-form-item .el-form-item__label{line-height:22px;margin-bottom:8px}.el-form--small .fc-wrap-top.el-form-item .el-form-item__label{line-height:20px;margin-bottom:4px}.fc-form-footer{margin-top:12px}";
|
|
8137
8462
|
styleInject(css_248z);
|
|
8138
8463
|
|
|
8139
8464
|
function tidyBtnProp(btn, def) {
|
|
@@ -8325,8 +8650,15 @@ var required = {
|
|
|
8325
8650
|
}, val);
|
|
8326
8651
|
|
|
8327
8652
|
if (!validate.message) {
|
|
8328
|
-
|
|
8329
|
-
|
|
8653
|
+
validate.message = rule.__fc__.refRule.__$title.value + (api.getLocale() === 'en' ? ' is required' : '不能为空');
|
|
8654
|
+
} else {
|
|
8655
|
+
var match = validate.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
|
|
8656
|
+
|
|
8657
|
+
if (match) {
|
|
8658
|
+
validate.message = api.t(match[1], {
|
|
8659
|
+
title: rule.__fc__.refRule.__$title.value
|
|
8660
|
+
});
|
|
8661
|
+
}
|
|
8330
8662
|
}
|
|
8331
8663
|
|
|
8332
8664
|
inject.getProp().validate = [validate];
|
|
@@ -8386,7 +8718,7 @@ function install(FormCreate) {
|
|
|
8386
8718
|
function elmFormCreate() {
|
|
8387
8719
|
return FormCreateFactory({
|
|
8388
8720
|
ui: 'element-ui',
|
|
8389
|
-
version: '3.2.
|
|
8721
|
+
version: '3.2.14',
|
|
8390
8722
|
manager: manager,
|
|
8391
8723
|
extendApi: extendApi,
|
|
8392
8724
|
install: install,
|