@form-create/view-design 2.5.31 → 2.5.33
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 +586 -412
- package/dist/form-create.min.js +2 -2
- package/dist/form-create.min.js.map +1 -1
- package/package.json +4 -4
- package/types/config.d.ts +5 -1
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.33
|
|
3
3
|
* (c) 2018-2023 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -305,7 +305,9 @@
|
|
|
305
305
|
},
|
|
306
306
|
render: function render() {
|
|
307
307
|
var h = arguments[0];
|
|
308
|
-
return h("CheckboxGroup", helper([{}, this.formCreateInject.prop, {
|
|
308
|
+
return h("CheckboxGroup", helper([{}, this.formCreateInject.prop, {
|
|
309
|
+
"ref": "el"
|
|
310
|
+
}, {
|
|
309
311
|
"props": {
|
|
310
312
|
value: this.trueValue
|
|
311
313
|
}
|
|
@@ -322,6 +324,9 @@
|
|
|
322
324
|
"key": '' + index + '-' + opt.value
|
|
323
325
|
}]));
|
|
324
326
|
}), getSlot(this.$slots)]);
|
|
327
|
+
},
|
|
328
|
+
mounted: function mounted() {
|
|
329
|
+
this.$emit('fc.el', this.$refs.el);
|
|
325
330
|
}
|
|
326
331
|
};
|
|
327
332
|
|
|
@@ -862,6 +867,7 @@
|
|
|
862
867
|
value: this.trueValue
|
|
863
868
|
}
|
|
864
869
|
}, {
|
|
870
|
+
"ref": "el",
|
|
865
871
|
"on": {
|
|
866
872
|
"input": this.onInput
|
|
867
873
|
}
|
|
@@ -874,6 +880,9 @@
|
|
|
874
880
|
"key": '' + index + '-' + opt.value
|
|
875
881
|
}]));
|
|
876
882
|
}), getSlot(this.$slots)]);
|
|
883
|
+
},
|
|
884
|
+
mounted: function mounted() {
|
|
885
|
+
this.$emit('fc.el', this.$refs.el);
|
|
877
886
|
}
|
|
878
887
|
};
|
|
879
888
|
|
|
@@ -928,8 +937,7 @@
|
|
|
928
937
|
}
|
|
929
938
|
},
|
|
930
939
|
render: function render(h, ctx) {
|
|
931
|
-
var
|
|
932
|
-
return h("Select", helper([{}, ctx.data]), [(Array.isArray(options) ? options : []).map(function (props, index) {
|
|
940
|
+
var makeOption = function makeOption(props, index) {
|
|
933
941
|
var slot = props.slot;
|
|
934
942
|
return h("Option", helper([{}, {
|
|
935
943
|
"props": props
|
|
@@ -938,7 +946,26 @@
|
|
|
938
946
|
}]), [slot ? h("template", {
|
|
939
947
|
"slot": props.slotName || 'default'
|
|
940
948
|
}, [is.Function(slot) ? props.slot(h) : slot]) : null]);
|
|
949
|
+
};
|
|
950
|
+
var makeOptionGroup = function makeOptionGroup(props, index) {
|
|
951
|
+
return h("OptionGroup", {
|
|
952
|
+
"attrs": {
|
|
953
|
+
"label": props.label
|
|
954
|
+
},
|
|
955
|
+
"key": '' + index + '-' + props.label
|
|
956
|
+
}, [is.trueArray(props.options) && props.options.map(function (v, index) {
|
|
957
|
+
return makeOption(v, index);
|
|
958
|
+
})]);
|
|
959
|
+
};
|
|
960
|
+
var options = ctx.props.formCreateInject.options;
|
|
961
|
+
return h("Select", helper([{}, ctx.data, {
|
|
962
|
+
"ref": "el"
|
|
963
|
+
}]), [(Array.isArray(options) ? options : []).map(function (props, index) {
|
|
964
|
+
return hasProperty(props || '', 'options') ? makeOptionGroup(props, index) : makeOption(props, index);
|
|
941
965
|
}), ctx.children]);
|
|
966
|
+
},
|
|
967
|
+
mounted: function mounted() {
|
|
968
|
+
this.$emit('fc.el', this.$refs.el);
|
|
942
969
|
}
|
|
943
970
|
};
|
|
944
971
|
|
|
@@ -1007,6 +1034,9 @@
|
|
|
1007
1034
|
}, {
|
|
1008
1035
|
"on": on
|
|
1009
1036
|
}]), [getSlot(this.$slots)]);
|
|
1037
|
+
},
|
|
1038
|
+
mounted: function mounted() {
|
|
1039
|
+
this.$emit('fc.el', this.$refs.tree);
|
|
1010
1040
|
}
|
|
1011
1041
|
};
|
|
1012
1042
|
|
|
@@ -1184,12 +1214,12 @@
|
|
|
1184
1214
|
makeUpload: function makeUpload() {
|
|
1185
1215
|
var h = this.$createElement;
|
|
1186
1216
|
var isShow = !this.maxLength || this.maxLength > this.uploadList.length;
|
|
1187
|
-
return h("Upload", helper([{}, this.formCreateInject.prop, {
|
|
1188
|
-
|
|
1189
|
-
"style": {
|
|
1217
|
+
return h("Upload", helper([{}, this.formCreateInject.prop, {}, {
|
|
1218
|
+
style: {
|
|
1190
1219
|
display: 'inline-block'
|
|
1191
1220
|
},
|
|
1192
|
-
|
|
1221
|
+
key: this.key('upload'),
|
|
1222
|
+
ref: 'upload'
|
|
1193
1223
|
}]), [isShow ? h("template", {
|
|
1194
1224
|
"slot": "default"
|
|
1195
1225
|
}, [this.$slots["default"] || h("div", {
|
|
@@ -1255,6 +1285,7 @@
|
|
|
1255
1285
|
}, {
|
|
1256
1286
|
deep: true
|
|
1257
1287
|
});
|
|
1288
|
+
this.$emit('fc.el', this.$refs.upload);
|
|
1258
1289
|
}
|
|
1259
1290
|
};
|
|
1260
1291
|
}
|
|
@@ -1334,390 +1365,416 @@
|
|
|
1334
1365
|
return _extends$1.apply(this, arguments);
|
|
1335
1366
|
}
|
|
1336
1367
|
|
|
1368
|
+
var css_248z$2 = "._fc-group{\n display: flex;\n min-height: 42px;\n justify-content: center;\n flex-direction: column;\n}\n\n._fc-group-disabled ._fc-group-btn, ._fc-group-disabled ._fc-group-add{\n cursor: not-allowed;\n}\n\n._fc-group-handle {\n display: flex;\n flex-direction: row;\n position: absolute;\n bottom: -15px;\n right: 30px;\n border-radius: 15px;\n border: 1px dashed #d9d9d9;\n padding: 3px 8px;\n background-color: #ffffff;\n}\n\n._fc-group-btn{\n cursor: pointer;\n}\n\n._fc-group-idx {\n position: absolute;\n bottom: -15px;\n left: 10px;\n width: 30px;\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #eee;\n border-radius: 15px;\n font-weight: 700;\n}\n\n._fc-group-handle ._fc-group-btn + ._fc-group-btn {\n margin-left: 7px;\n}\n\n._fc-group-container{\n position: relative;\n display: flex;\n flex-direction: column;\n border: 1px dashed #d9d9d9;\n padding: 20px;\n margin: 5px;\n border-radius: 5px;\n margin-bottom: 25px;\n padding-bottom: 25px;\n}\n\n._fc-group-arrow {\n position: relative;\n width: 20px;\n height: 20px;\n}\n\n._fc-group-arrow::before {\n content: \"\";\n position: absolute;\n top: 8px;\n left: 5px;\n width: 9px;\n height: 9px;\n border-left: 2px solid #999;\n border-top: 2px solid #999;\n}\n._fc-group-arrow::before {\n transform: rotate(45deg);\n}\n\n._fc-group-arrow._fc-group-down {\n transform: rotate(180deg);\n}\n\n._fc-group-plus-minus {\n width: 20px;\n height: 20px;\n position: relative;\n cursor: pointer;\n}\n\n._fc-group-plus-minus::before,\n._fc-group-plus-minus::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n width: 60%;\n height: 2px;\n background-color: #409eff;\n transform: translate(-50%, -50%);\n}\n\n._fc-group-plus-minus::before {\n transform: translate(-50%, -50%) rotate(90deg);\n}\n\n._fc-group-plus-minus._fc-group-minus::before {\n display: none;\n}\n._fc-group-plus-minus._fc-group-minus::after {\n background-color: #f56c6c;\n}\n\n\n._fc-group-add{\n cursor: pointer;\n width: 25px;\n height: 25px;\n border: 1px solid rgb(64 158 255 / 50%);\n border-radius: 15px;\n}\n\n._fc-group-add._fc-group-plus-minus::before, ._fc-group-add._fc-group-plus-minus::after {\n width: 50%;\n}\n\n";
|
|
1369
|
+
styleInject(css_248z$2);
|
|
1370
|
+
|
|
1337
1371
|
var NAME$6 = 'fcGroup';
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
required: true
|
|
1350
|
-
},
|
|
1351
|
-
button: {
|
|
1352
|
-
type: Boolean,
|
|
1353
|
-
"default": true
|
|
1354
|
-
},
|
|
1355
|
-
max: {
|
|
1356
|
-
type: Number,
|
|
1357
|
-
"default": 0
|
|
1358
|
-
},
|
|
1359
|
-
min: {
|
|
1360
|
-
type: Number,
|
|
1361
|
-
"default": 0
|
|
1362
|
-
},
|
|
1363
|
-
value: {
|
|
1364
|
-
type: Array,
|
|
1365
|
-
"default": function _default() {
|
|
1366
|
-
return [];
|
|
1367
|
-
}
|
|
1368
|
-
},
|
|
1369
|
-
defaultValue: Object,
|
|
1370
|
-
disabled: {
|
|
1371
|
-
type: Boolean,
|
|
1372
|
-
"default": false
|
|
1373
|
-
},
|
|
1374
|
-
syncDisabled: {
|
|
1375
|
-
type: Boolean,
|
|
1376
|
-
"default": true
|
|
1377
|
-
},
|
|
1378
|
-
fontSize: {
|
|
1379
|
-
type: Number,
|
|
1380
|
-
"default": 28
|
|
1381
|
-
},
|
|
1382
|
-
onBeforeRemove: {
|
|
1383
|
-
type: Function,
|
|
1384
|
-
"default": function _default() {}
|
|
1385
|
-
},
|
|
1386
|
-
onBeforeAdd: {
|
|
1387
|
-
type: Function,
|
|
1388
|
-
"default": function _default() {}
|
|
1389
|
-
}
|
|
1372
|
+
var Group = {
|
|
1373
|
+
name: NAME$6,
|
|
1374
|
+
props: {
|
|
1375
|
+
field: String,
|
|
1376
|
+
rule: [Array, Object],
|
|
1377
|
+
rules: Array,
|
|
1378
|
+
expand: Number,
|
|
1379
|
+
options: Object,
|
|
1380
|
+
formCreateInject: {
|
|
1381
|
+
type: Object,
|
|
1382
|
+
required: true
|
|
1390
1383
|
},
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
cacheRule: {},
|
|
1395
|
-
cacheValue: {},
|
|
1396
|
-
type: undefined
|
|
1397
|
-
};
|
|
1384
|
+
button: {
|
|
1385
|
+
type: Boolean,
|
|
1386
|
+
"default": true
|
|
1398
1387
|
},
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1388
|
+
max: {
|
|
1389
|
+
type: Number,
|
|
1390
|
+
"default": 0
|
|
1391
|
+
},
|
|
1392
|
+
min: {
|
|
1393
|
+
type: Number,
|
|
1394
|
+
"default": 0
|
|
1395
|
+
},
|
|
1396
|
+
value: {
|
|
1397
|
+
type: Array,
|
|
1398
|
+
"default": function _default() {
|
|
1407
1399
|
return [];
|
|
1408
1400
|
}
|
|
1409
1401
|
},
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1402
|
+
sortBtn: {
|
|
1403
|
+
type: Boolean,
|
|
1404
|
+
"default": true
|
|
1405
|
+
},
|
|
1406
|
+
defaultValue: Object,
|
|
1407
|
+
disabled: {
|
|
1408
|
+
type: Boolean,
|
|
1409
|
+
"default": false
|
|
1410
|
+
},
|
|
1411
|
+
syncDisabled: {
|
|
1412
|
+
type: Boolean,
|
|
1413
|
+
"default": true
|
|
1414
|
+
},
|
|
1415
|
+
onBeforeRemove: {
|
|
1416
|
+
type: Function,
|
|
1417
|
+
"default": function _default() {}
|
|
1418
|
+
},
|
|
1419
|
+
onBeforeAdd: {
|
|
1420
|
+
type: Function,
|
|
1421
|
+
"default": function _default() {}
|
|
1422
|
+
},
|
|
1423
|
+
parse: Function
|
|
1424
|
+
},
|
|
1425
|
+
data: function data() {
|
|
1426
|
+
return {
|
|
1427
|
+
len: 0,
|
|
1428
|
+
cacheRule: {},
|
|
1429
|
+
cacheValue: {},
|
|
1430
|
+
sort: [],
|
|
1431
|
+
type: undefined
|
|
1432
|
+
};
|
|
1433
|
+
},
|
|
1434
|
+
computed: {
|
|
1435
|
+
formRule: function formRule() {
|
|
1436
|
+
if (this.rules) {
|
|
1437
|
+
return this.rules;
|
|
1438
|
+
}
|
|
1439
|
+
if (this.rule) {
|
|
1440
|
+
return Array.isArray(this.rule) ? this.rule : [this.rule];
|
|
1441
|
+
}
|
|
1442
|
+
return [];
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
watch: {
|
|
1446
|
+
cacheRule: {
|
|
1447
|
+
handler: function handler(n) {
|
|
1448
|
+
this.sort = Object.keys(n);
|
|
1448
1449
|
},
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1450
|
+
immediate: true
|
|
1451
|
+
},
|
|
1452
|
+
formRule: {
|
|
1453
|
+
handler: function handler(n, o) {
|
|
1454
|
+
var _this = this;
|
|
1455
|
+
Object.keys(this.cacheRule).forEach(function (v) {
|
|
1456
|
+
var item = _this.cacheRule[v];
|
|
1457
|
+
if (item.$f) {
|
|
1458
|
+
var val = item.$f.formData();
|
|
1459
|
+
if (n === o) {
|
|
1460
|
+
item.$f.deferSyncValue(function () {
|
|
1461
|
+
deepExtend(item.rule, n);
|
|
1462
|
+
item.$f.setValue(val);
|
|
1463
|
+
}, true);
|
|
1464
|
+
} else {
|
|
1465
|
+
var _val = item.$f.formData();
|
|
1466
|
+
item.$f.once('reloading', function () {
|
|
1467
|
+
item.$f.setValue(_val);
|
|
1468
|
+
});
|
|
1469
|
+
item.rule = deepCopy(n);
|
|
1466
1470
|
}
|
|
1467
1471
|
}
|
|
1468
|
-
n.forEach(function (val, i) {
|
|
1469
|
-
_this2.setValue(keys[i], n[i]);
|
|
1470
|
-
});
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
},
|
|
1474
|
-
methods: {
|
|
1475
|
-
_value: function _value(v) {
|
|
1476
|
-
return v && hasProperty(v, this.field) ? v[this.field] : v;
|
|
1477
|
-
},
|
|
1478
|
-
cache: function cache(k, val) {
|
|
1479
|
-
this.cacheValue[k] = JSON.stringify(val);
|
|
1480
|
-
},
|
|
1481
|
-
input: function input(value) {
|
|
1482
|
-
this.$emit('input', value);
|
|
1483
|
-
this.$emit('change', value);
|
|
1484
|
-
},
|
|
1485
|
-
formData: function formData(key, _formData) {
|
|
1486
|
-
var _this3 = this;
|
|
1487
|
-
var cacheRule = this.cacheRule;
|
|
1488
|
-
var keys = Object.keys(cacheRule);
|
|
1489
|
-
if (keys.filter(function (k) {
|
|
1490
|
-
return cacheRule[k].$f;
|
|
1491
|
-
}).length !== keys.length) {
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
var value = keys.map(function (k) {
|
|
1495
|
-
var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
|
|
1496
|
-
var value = _this3.field ? data[_this3.field] || null : data;
|
|
1497
|
-
_this3.cache(k, value);
|
|
1498
|
-
return value;
|
|
1499
1472
|
});
|
|
1500
|
-
this.input(value);
|
|
1501
1473
|
},
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1474
|
+
deep: true
|
|
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
|
+
expand: function expand(n) {
|
|
1485
|
+
var d = n - this.value.length;
|
|
1486
|
+
if (d > 0) {
|
|
1487
|
+
this.expandRule(d);
|
|
1488
|
+
}
|
|
1489
|
+
},
|
|
1490
|
+
value: function value(n, o) {
|
|
1491
|
+
var _this2 = this;
|
|
1492
|
+
n = n || [];
|
|
1493
|
+
var keys = this.sort,
|
|
1494
|
+
total = keys.length,
|
|
1495
|
+
len = total - n.length;
|
|
1496
|
+
if (len < 0) {
|
|
1497
|
+
for (var i = len; i < 0; i++) {
|
|
1498
|
+
this.addRule(n.length + i);
|
|
1507
1499
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1500
|
+
for (var _i = 0; _i < total; _i++) {
|
|
1501
|
+
this.setValue(keys[_i], n[_i]);
|
|
1510
1502
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
var rule = this.formCreateInject.form.copyRules(this.formRule);
|
|
1517
|
-
var options = this.options ? _objectSpread2({}, this.options) : {
|
|
1518
|
-
submitBtn: false,
|
|
1519
|
-
resetBtn: false
|
|
1520
|
-
};
|
|
1521
|
-
if (this.defaultValue) {
|
|
1522
|
-
if (!options.formData) options.formData = {};
|
|
1523
|
-
var defVal = deepCopy(this.defaultValue);
|
|
1524
|
-
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
1503
|
+
} else {
|
|
1504
|
+
if (len > 0) {
|
|
1505
|
+
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
1506
|
+
this.removeRule(keys[total - _i2 - 1]);
|
|
1507
|
+
}
|
|
1525
1508
|
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
options: options
|
|
1509
|
+
n.forEach(function (val, i) {
|
|
1510
|
+
_this2.setValue(keys[i], n[i]);
|
|
1529
1511
|
});
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
methods: {
|
|
1516
|
+
_value: function _value(v) {
|
|
1517
|
+
return v && hasProperty(v, this.field) ? v[this.field] : v;
|
|
1518
|
+
},
|
|
1519
|
+
cache: function cache(k, val) {
|
|
1520
|
+
this.cacheValue[k] = JSON.stringify(val);
|
|
1521
|
+
},
|
|
1522
|
+
input: function input(value) {
|
|
1523
|
+
this.$emit('input', value);
|
|
1524
|
+
this.$emit('change', value);
|
|
1525
|
+
},
|
|
1526
|
+
formData: function formData(key, _formData) {
|
|
1527
|
+
var _this3 = this;
|
|
1528
|
+
var cacheRule = this.cacheRule;
|
|
1529
|
+
var keys = this.sort;
|
|
1530
|
+
if (keys.filter(function (k) {
|
|
1531
|
+
return cacheRule[k].$f;
|
|
1532
|
+
}).length !== keys.length) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
var value = keys.map(function (k) {
|
|
1536
|
+
var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
|
|
1537
|
+
var value = _this3.field ? data[_this3.field] || null : data;
|
|
1538
|
+
_this3.cache(k, value);
|
|
1539
|
+
return value;
|
|
1540
|
+
});
|
|
1541
|
+
this.input(value);
|
|
1542
|
+
},
|
|
1543
|
+
setValue: function setValue(key, value) {
|
|
1544
|
+
var field = this.field,
|
|
1545
|
+
$f = this.cacheRule[key].$f;
|
|
1546
|
+
if (field) {
|
|
1547
|
+
value = _defineProperty({}, field, this._value(value));
|
|
1548
|
+
}
|
|
1549
|
+
if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
this.cache(key, value);
|
|
1553
|
+
$f && $f.coverValue(value || {});
|
|
1554
|
+
},
|
|
1555
|
+
addRule: function addRule(i, emit) {
|
|
1556
|
+
var _this4 = this;
|
|
1557
|
+
var rule = this.formCreateInject.form.copyRules(this.formRule);
|
|
1558
|
+
var options = this.options ? _objectSpread2({}, this.options) : {
|
|
1559
|
+
submitBtn: false,
|
|
1560
|
+
resetBtn: false
|
|
1561
|
+
};
|
|
1562
|
+
if (this.defaultValue) {
|
|
1563
|
+
if (!options.formData) options.formData = {};
|
|
1564
|
+
var defVal = deepCopy(this.defaultValue);
|
|
1565
|
+
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
1566
|
+
}
|
|
1567
|
+
this.parse && this.parse({
|
|
1568
|
+
rule: rule,
|
|
1569
|
+
options: options,
|
|
1570
|
+
index: this.sort.length
|
|
1571
|
+
});
|
|
1572
|
+
this.$set(this.cacheRule, ++this.len, {
|
|
1573
|
+
rule: rule,
|
|
1574
|
+
options: options
|
|
1575
|
+
});
|
|
1576
|
+
if (emit) {
|
|
1577
|
+
this.$nextTick(function () {
|
|
1578
|
+
return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
add$f: function add$f(i, key, $f) {
|
|
1583
|
+
var _this5 = this;
|
|
1584
|
+
this.cacheRule[key].$f = $f;
|
|
1585
|
+
this.$nextTick(function () {
|
|
1586
|
+
if (_this5.syncDisabled) {
|
|
1587
|
+
$f.disabled(_this5.disabled);
|
|
1534
1588
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1589
|
+
_this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
|
|
1590
|
+
});
|
|
1591
|
+
},
|
|
1592
|
+
removeRule: function removeRule(key, emit) {
|
|
1593
|
+
var _this6 = this;
|
|
1594
|
+
var index = Object.keys(this.cacheRule).indexOf(key);
|
|
1595
|
+
this.$delete(this.cacheRule, key);
|
|
1596
|
+
this.$delete(this.cacheValue, key);
|
|
1597
|
+
if (emit) {
|
|
1540
1598
|
this.$nextTick(function () {
|
|
1541
|
-
|
|
1542
|
-
$f.disabled(_this5.disabled);
|
|
1543
|
-
}
|
|
1544
|
-
_this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
|
|
1599
|
+
return _this6.$emit('remove', index);
|
|
1545
1600
|
});
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1601
|
+
}
|
|
1602
|
+
},
|
|
1603
|
+
add: function add(i) {
|
|
1604
|
+
if (this.disabled || false === this.onBeforeAdd(this.value)) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
this.addRule(i, true);
|
|
1608
|
+
},
|
|
1609
|
+
del: function del(index, key) {
|
|
1610
|
+
if (this.disabled || false === this.onBeforeRemove(this.value, index)) {
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
this.removeRule(key, true);
|
|
1614
|
+
var value = _toConsumableArray(this.value);
|
|
1615
|
+
value.splice(index, 1);
|
|
1616
|
+
this.input(value);
|
|
1617
|
+
},
|
|
1618
|
+
addIcon: function addIcon(key) {
|
|
1619
|
+
var h = this.$createElement;
|
|
1620
|
+
return h("div", {
|
|
1621
|
+
"class": "_fc-group-btn _fc-group-plus-minus",
|
|
1622
|
+
"on": {
|
|
1623
|
+
"click": this.add
|
|
1556
1624
|
}
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1625
|
+
});
|
|
1626
|
+
},
|
|
1627
|
+
delIcon: function delIcon(index, key) {
|
|
1628
|
+
var _this7 = this;
|
|
1629
|
+
var h = this.$createElement;
|
|
1630
|
+
return h("div", {
|
|
1631
|
+
"class": "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
|
|
1632
|
+
"on": {
|
|
1633
|
+
"click": function click() {
|
|
1634
|
+
return _this7.del(index, key);
|
|
1635
|
+
}
|
|
1561
1636
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1637
|
+
});
|
|
1638
|
+
},
|
|
1639
|
+
sortUpIcon: function sortUpIcon(index) {
|
|
1640
|
+
var _this8 = this;
|
|
1641
|
+
var h = this.$createElement;
|
|
1642
|
+
return h("div", {
|
|
1643
|
+
"class": "_fc-group-btn _fc-group-arrow _fc-group-up",
|
|
1644
|
+
"on": {
|
|
1645
|
+
"click": function click() {
|
|
1646
|
+
return _this8.changeSort(index, -1);
|
|
1647
|
+
}
|
|
1567
1648
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
"
|
|
1577
|
-
|
|
1578
|
-
},
|
|
1579
|
-
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#000'),
|
|
1580
|
-
"on": {
|
|
1581
|
-
"click": this.add
|
|
1649
|
+
});
|
|
1650
|
+
},
|
|
1651
|
+
sortDownIcon: function sortDownIcon(index) {
|
|
1652
|
+
var _this9 = this;
|
|
1653
|
+
var h = this.$createElement;
|
|
1654
|
+
return h("div", {
|
|
1655
|
+
"class": "_fc-group-btn _fc-group-arrow _fc-group-down",
|
|
1656
|
+
"on": {
|
|
1657
|
+
"click": function click() {
|
|
1658
|
+
return _this9.changeSort(index, 1);
|
|
1582
1659
|
}
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
},
|
|
1663
|
+
changeSort: function changeSort(index, sort) {
|
|
1664
|
+
var a = this.sort[index];
|
|
1665
|
+
this.$set(this.sort, index, this.sort[index + sort]);
|
|
1666
|
+
this.sort[index + sort] = a;
|
|
1667
|
+
this.formData(0);
|
|
1668
|
+
},
|
|
1669
|
+
makeIcon: function makeIcon(total, index, key) {
|
|
1670
|
+
var _this10 = this;
|
|
1671
|
+
if (this.$scopedSlots.button) {
|
|
1672
|
+
return this.$scopedSlots.button({
|
|
1673
|
+
total: total,
|
|
1674
|
+
index: index,
|
|
1675
|
+
vm: this,
|
|
1676
|
+
key: key,
|
|
1677
|
+
del: function del() {
|
|
1678
|
+
return _this10.del(index, key);
|
|
1592
1679
|
},
|
|
1593
|
-
|
|
1594
|
-
"on": {
|
|
1595
|
-
"click": function click() {
|
|
1596
|
-
return _this7.del(index, key);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1680
|
+
add: this.add
|
|
1599
1681
|
});
|
|
1600
|
-
},
|
|
1601
|
-
makeIcon: function makeIcon(total, index, key) {
|
|
1602
|
-
var _this8 = this;
|
|
1603
|
-
if (this.$scopedSlots.button) {
|
|
1604
|
-
return this.$scopedSlots.button({
|
|
1605
|
-
total: total,
|
|
1606
|
-
index: index,
|
|
1607
|
-
vm: this,
|
|
1608
|
-
key: key,
|
|
1609
|
-
del: function del() {
|
|
1610
|
-
return _this8.del(index, key);
|
|
1611
|
-
},
|
|
1612
|
-
add: this.add
|
|
1613
|
-
});
|
|
1614
|
-
}
|
|
1615
|
-
if (index === 0) {
|
|
1616
|
-
return [this.max !== 0 && total >= this.max ? null : this.addIcon(key), this.min === 0 || total > this.min ? this.delIcon(index, key) : null];
|
|
1617
|
-
}
|
|
1618
|
-
if (total > this.min) {
|
|
1619
|
-
return this.delIcon(index, key);
|
|
1620
|
-
}
|
|
1621
|
-
},
|
|
1622
|
-
emitEvent: function emitEvent(name, args, index, key) {
|
|
1623
|
-
this.$emit.apply(this, [name].concat(_toConsumableArray(args), [this.cacheRule[key].$f, index]));
|
|
1624
|
-
},
|
|
1625
|
-
expandRule: function expandRule(n) {
|
|
1626
|
-
for (var i = 0; i < n; i++) {
|
|
1627
|
-
this.value.push(this.field ? null : {});
|
|
1628
|
-
}
|
|
1629
1682
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
if (
|
|
1635
|
-
this.
|
|
1683
|
+
var btn = [];
|
|
1684
|
+
if ((!this.max || total < this.max) && total === index + 1) {
|
|
1685
|
+
btn.push(this.addIcon(key));
|
|
1686
|
+
}
|
|
1687
|
+
if (total > this.min) {
|
|
1688
|
+
btn.push(this.delIcon(index, key));
|
|
1636
1689
|
}
|
|
1637
|
-
|
|
1638
|
-
this.
|
|
1690
|
+
if (this.sortBtn && index) {
|
|
1691
|
+
btn.push(this.sortUpIcon(index));
|
|
1639
1692
|
}
|
|
1693
|
+
if (this.sortBtn && index !== total - 1) {
|
|
1694
|
+
btn.push(this.sortDownIcon(index));
|
|
1695
|
+
}
|
|
1696
|
+
return btn;
|
|
1640
1697
|
},
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
var
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1698
|
+
emitEvent: function emitEvent(name, args, index, key) {
|
|
1699
|
+
this.$emit.apply(this, [name].concat(_toConsumableArray(args), [this.cacheRule[key].$f, index]));
|
|
1700
|
+
},
|
|
1701
|
+
expandRule: function expandRule(n) {
|
|
1702
|
+
for (var i = 0; i < n; i++) {
|
|
1703
|
+
this.value.push(this.field ? null : {});
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
},
|
|
1707
|
+
created: function created() {
|
|
1708
|
+
this.type = this.formCreateInject.form.$form();
|
|
1709
|
+
var d = (this.expand || 0) - this.value.length;
|
|
1710
|
+
if (d > 0) {
|
|
1711
|
+
this.expandRule(d);
|
|
1712
|
+
}
|
|
1713
|
+
for (var i = 0; i < this.value.length; i++) {
|
|
1714
|
+
this.addRule(i);
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
render: function render() {
|
|
1718
|
+
var _this11 = this;
|
|
1719
|
+
var h = arguments[0];
|
|
1720
|
+
var keys = this.sort;
|
|
1721
|
+
var button = this.button;
|
|
1722
|
+
var Type = this.type;
|
|
1723
|
+
var disabled = this.disabled;
|
|
1724
|
+
var children = keys.length === 0 ? this.$scopedSlots["default"] ? this.$scopedSlots["default"]({
|
|
1725
|
+
vm: this,
|
|
1726
|
+
add: this.add
|
|
1727
|
+
}) : h("div", {
|
|
1728
|
+
"key": 'a_def',
|
|
1729
|
+
"class": "_fc-group-plus-minus _fc-group-add",
|
|
1730
|
+
"on": {
|
|
1731
|
+
"click": this.add
|
|
1732
|
+
}
|
|
1733
|
+
}) : keys.map(function (key, index) {
|
|
1734
|
+
var _this11$cacheRule$key = _this11.cacheRule[key],
|
|
1735
|
+
rule = _this11$cacheRule$key.rule,
|
|
1736
|
+
options = _this11$cacheRule$key.options;
|
|
1737
|
+
var btn = button && !disabled ? _this11.makeIcon(keys.length, index, key) : [];
|
|
1738
|
+
return h("div", {
|
|
1739
|
+
"class": "_fc-group-container",
|
|
1740
|
+
"key": key
|
|
1741
|
+
}, [h(Type, helper([{
|
|
1742
|
+
"key": key
|
|
1743
|
+
}, {
|
|
1656
1744
|
"on": {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
}) : h("div", {
|
|
1660
|
-
"key": 'con'
|
|
1661
|
-
}, [keys.map(function (key, index) {
|
|
1662
|
-
var _this9$cacheRule$key = _this9.cacheRule[key],
|
|
1663
|
-
rule = _this9$cacheRule$key.rule,
|
|
1664
|
-
options = _this9$cacheRule$key.options;
|
|
1665
|
-
return h("Row", {
|
|
1666
|
-
"attrs": {
|
|
1667
|
-
"align": "middle",
|
|
1668
|
-
"type": "flex"
|
|
1745
|
+
'update:value': function updateValue(formData) {
|
|
1746
|
+
return _this11.formData(key, formData);
|
|
1669
1747
|
},
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
"attrs": {
|
|
1674
|
-
"span": button ? 20 : 24
|
|
1675
|
-
}
|
|
1676
|
-
}, [h(Type, helper([{
|
|
1677
|
-
"key": key
|
|
1678
|
-
}, {
|
|
1679
|
-
"on": {
|
|
1680
|
-
'update:value': function updateValue(formData) {
|
|
1681
|
-
return _this9.formData(key, formData);
|
|
1682
|
-
},
|
|
1683
|
-
'emit-event': function emitEvent(name) {
|
|
1684
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1685
|
-
args[_key - 1] = arguments[_key];
|
|
1686
|
-
}
|
|
1687
|
-
return _this9.emitEvent(name, args, index, key);
|
|
1688
|
-
},
|
|
1689
|
-
input: function input($f) {
|
|
1690
|
-
return _this9.add$f(index, key, $f);
|
|
1748
|
+
'emit-event': function emitEvent(name) {
|
|
1749
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1750
|
+
args[_key - 1] = arguments[_key];
|
|
1691
1751
|
}
|
|
1752
|
+
return _this11.emitEvent(name, args, index, key);
|
|
1753
|
+
},
|
|
1754
|
+
input: function input($f) {
|
|
1755
|
+
return _this11.add$f(index, key, $f);
|
|
1692
1756
|
}
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
removeIcon: 'ios-remove-circle-outline',
|
|
1715
|
-
addIcon: 'ios-add-circle-outline'
|
|
1716
|
-
});
|
|
1717
|
-
group.v2 = createGroup({
|
|
1718
|
-
addIcon: 'ios-plus-outline',
|
|
1719
|
-
removeIcon: 'ios-minus-outline'
|
|
1720
|
-
});
|
|
1757
|
+
}
|
|
1758
|
+
}, {}, {
|
|
1759
|
+
"props": {
|
|
1760
|
+
inFor: true,
|
|
1761
|
+
value: _this11.field ? _defineProperty({}, _this11.field, _this11._value(_this11.value[index])) : _this11.value[index],
|
|
1762
|
+
rule: rule,
|
|
1763
|
+
option: options,
|
|
1764
|
+
extendOption: true
|
|
1765
|
+
}
|
|
1766
|
+
}])), h("div", {
|
|
1767
|
+
"class": "_fc-group-idx"
|
|
1768
|
+
}, [index + 1]), btn.length ? h("div", {
|
|
1769
|
+
"class": "_fc-group-handle"
|
|
1770
|
+
}, [btn]) : null]);
|
|
1771
|
+
});
|
|
1772
|
+
return h("div", {
|
|
1773
|
+
"key": 'con',
|
|
1774
|
+
"class": '_fc-group ' + (disabled ? '_fc-group-disabled' : '')
|
|
1775
|
+
}, [children]);
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1721
1778
|
|
|
1722
1779
|
var NAME$7 = 'fcSubForm';
|
|
1723
1780
|
var Sub = {
|
|
@@ -1825,7 +1882,7 @@
|
|
|
1825
1882
|
}
|
|
1826
1883
|
};
|
|
1827
1884
|
|
|
1828
|
-
var components = [Checkbox, Radio, Select, Tree, Sub, frame, upload,
|
|
1885
|
+
var components = [Checkbox, Radio, Select, Tree, Sub, frame, upload, Group];
|
|
1829
1886
|
|
|
1830
1887
|
var NAME$8 = 'FormCreate';
|
|
1831
1888
|
var getRuleInject = function getRuleInject(vm, parent) {
|
|
@@ -2621,7 +2678,7 @@
|
|
|
2621
2678
|
},
|
|
2622
2679
|
el: function el(id) {
|
|
2623
2680
|
var ctx = h.getCtx(id);
|
|
2624
|
-
if (ctx) return ctx.el || h.vm.$refs[ctx.ref];
|
|
2681
|
+
if (ctx) return ctx.exportEl || ctx.el || h.vm.$refs[ctx.ref];
|
|
2625
2682
|
},
|
|
2626
2683
|
closeModal: function closeModal(id) {
|
|
2627
2684
|
var el = api.el(id);
|
|
@@ -3075,6 +3132,12 @@
|
|
|
3075
3132
|
},
|
|
3076
3133
|
'fc.sub-form': function fcSubForm(subForm) {
|
|
3077
3134
|
_this8.$handle.addSubForm(ctx, subForm);
|
|
3135
|
+
},
|
|
3136
|
+
'fc.el': function fcEl(el) {
|
|
3137
|
+
ctx.exportEl = el;
|
|
3138
|
+
if (el) {
|
|
3139
|
+
(el.$el || el).__rule__ = ctx.rule;
|
|
3140
|
+
}
|
|
3078
3141
|
}
|
|
3079
3142
|
}
|
|
3080
3143
|
}];
|
|
@@ -3396,6 +3459,7 @@
|
|
|
3396
3459
|
payload: {},
|
|
3397
3460
|
input: !!rule.field,
|
|
3398
3461
|
el: undefined,
|
|
3462
|
+
exportEl: undefined,
|
|
3399
3463
|
defaultValue: rule.field ? deepCopy(defaultValue) : undefined,
|
|
3400
3464
|
field: rule.field || undefined
|
|
3401
3465
|
});
|
|
@@ -3518,7 +3582,8 @@
|
|
|
3518
3582
|
vm: handle.vm,
|
|
3519
3583
|
trueType: handle.getType(this.originType),
|
|
3520
3584
|
vNode: handle.$render.vNode,
|
|
3521
|
-
updated: false
|
|
3585
|
+
updated: false,
|
|
3586
|
+
cacheValue: this.rule.value
|
|
3522
3587
|
});
|
|
3523
3588
|
!init && this.unwatch();
|
|
3524
3589
|
this.watchTo();
|
|
@@ -3761,6 +3826,7 @@
|
|
|
3761
3826
|
ctx.root = rules;
|
|
3762
3827
|
_this6.setCtx(ctx);
|
|
3763
3828
|
!isCopy && !isInit && _this6.effect(ctx, 'load');
|
|
3829
|
+
_this6.effect(ctx, 'created');
|
|
3764
3830
|
ctx.parser.loadChildren === false || loadChildren(ctx.rule.children, ctx);
|
|
3765
3831
|
if (!parent) {
|
|
3766
3832
|
var _preIndex = preIndex(index);
|
|
@@ -4446,6 +4512,7 @@
|
|
|
4446
4512
|
data.mergeProp = function (prop) {
|
|
4447
4513
|
return mergeRule(data.getProp(), [prop]);
|
|
4448
4514
|
};
|
|
4515
|
+
data.id = ctx.id;
|
|
4449
4516
|
}
|
|
4450
4517
|
_this4.bus.$emit("p:".concat(attr, ":").concat(_type, ":").concat(p.input ? 1 : 0), event, [data, rule, _this4.api]);
|
|
4451
4518
|
});
|
|
@@ -4459,9 +4526,12 @@
|
|
|
4459
4526
|
}
|
|
4460
4527
|
function getComponent(p) {
|
|
4461
4528
|
var c = p.components;
|
|
4462
|
-
if (Array.isArray(c))
|
|
4463
|
-
|
|
4464
|
-
|
|
4529
|
+
if (Array.isArray(c)) {
|
|
4530
|
+
var arr = unique(c.filter(function (v) {
|
|
4531
|
+
return v !== '*';
|
|
4532
|
+
}));
|
|
4533
|
+
return arr.length ? arr : false;
|
|
4534
|
+
} else if (is.String(c)) return [c];else return false;
|
|
4465
4535
|
}
|
|
4466
4536
|
|
|
4467
4537
|
function Handler(fc) {
|
|
@@ -4714,6 +4784,52 @@
|
|
|
4714
4784
|
render: function render(children) {}
|
|
4715
4785
|
});
|
|
4716
4786
|
|
|
4787
|
+
var loadData = function loadData(fc) {
|
|
4788
|
+
var loadData = {
|
|
4789
|
+
name: 'loadData',
|
|
4790
|
+
_fn: [],
|
|
4791
|
+
created: function created(inject, rule, api) {
|
|
4792
|
+
this.deleted(inject);
|
|
4793
|
+
var attrs = toArray(inject.getValue());
|
|
4794
|
+
var events = [];
|
|
4795
|
+
attrs.forEach(function (attr) {
|
|
4796
|
+
if (attr) {
|
|
4797
|
+
var on = function on() {
|
|
4798
|
+
if (attr.watch !== false) {
|
|
4799
|
+
fc.bus.$off('p.loadData.' + attr.attr, on);
|
|
4800
|
+
fc.bus.$once('p.loadData.' + attr.attr, on);
|
|
4801
|
+
}
|
|
4802
|
+
var value = undefined;
|
|
4803
|
+
if (attr.attr) {
|
|
4804
|
+
value = fc.loadData[attr.attr] || attr["default"];
|
|
4805
|
+
if (attr.copy) {
|
|
4806
|
+
value = deepCopy(value);
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
4809
|
+
deepSet(inject.getProp(), attr.to || 'options', value);
|
|
4810
|
+
api.sync(rule);
|
|
4811
|
+
};
|
|
4812
|
+
events.push(function () {
|
|
4813
|
+
return fc.bus.$off('p.loadData.' + attr.attr, on);
|
|
4814
|
+
});
|
|
4815
|
+
on();
|
|
4816
|
+
}
|
|
4817
|
+
});
|
|
4818
|
+
this._fn[inject.id] = events;
|
|
4819
|
+
},
|
|
4820
|
+
deleted: function deleted(inject) {
|
|
4821
|
+
if (this._fn[inject.id]) {
|
|
4822
|
+
this._fn[inject.id].forEach(function (un) {
|
|
4823
|
+
un();
|
|
4824
|
+
});
|
|
4825
|
+
delete this._fn[inject.id];
|
|
4826
|
+
}
|
|
4827
|
+
inject.clearProp();
|
|
4828
|
+
}
|
|
4829
|
+
};
|
|
4830
|
+
loadData.watch = loadData.created;
|
|
4831
|
+
return loadData;
|
|
4832
|
+
};
|
|
4717
4833
|
var componentValidate = {
|
|
4718
4834
|
name: 'componentValidate',
|
|
4719
4835
|
load: function load(attr, rule, api) {
|
|
@@ -4755,12 +4871,21 @@
|
|
|
4755
4871
|
}
|
|
4756
4872
|
function run(inject, rule, api) {
|
|
4757
4873
|
var option = inject.value;
|
|
4874
|
+
var set = function set(val) {
|
|
4875
|
+
if (val === undefined) {
|
|
4876
|
+
inject.clearProp();
|
|
4877
|
+
api.sync(rule);
|
|
4878
|
+
} else {
|
|
4879
|
+
deepSet(inject.getProp(), option.to || 'options', val);
|
|
4880
|
+
}
|
|
4881
|
+
};
|
|
4758
4882
|
if (is.Function(option)) {
|
|
4759
4883
|
option = option(rule, api);
|
|
4760
4884
|
}
|
|
4761
4885
|
option = parseOpt(option);
|
|
4762
4886
|
if (!option || !option.action) {
|
|
4763
|
-
|
|
4887
|
+
set(undefined);
|
|
4888
|
+
return;
|
|
4764
4889
|
}
|
|
4765
4890
|
if (!option.to) {
|
|
4766
4891
|
option.to = 'options';
|
|
@@ -4773,52 +4898,66 @@
|
|
|
4773
4898
|
return true;
|
|
4774
4899
|
}
|
|
4775
4900
|
};
|
|
4776
|
-
var
|
|
4777
|
-
|
|
4778
|
-
|
|
4901
|
+
var config = _objectSpread2(_objectSpread2({
|
|
4902
|
+
headers: {}
|
|
4903
|
+
}, option), {}, {
|
|
4904
|
+
onSuccess: function onSuccess(body, flag) {
|
|
4905
|
+
if (check()) return;
|
|
4906
|
+
var fn = function fn(v) {
|
|
4907
|
+
return flag ? v : v.data;
|
|
4908
|
+
};
|
|
4909
|
+
if (is.Function(option.parse)) {
|
|
4910
|
+
fn = option.parse;
|
|
4911
|
+
} else if (option.parse && is.String(option.parse)) {
|
|
4912
|
+
fn = function fn(v) {
|
|
4913
|
+
option.parse.split('.').forEach(function (k) {
|
|
4914
|
+
if (v) {
|
|
4915
|
+
v = v[k];
|
|
4916
|
+
}
|
|
4917
|
+
});
|
|
4918
|
+
return v;
|
|
4919
|
+
};
|
|
4920
|
+
}
|
|
4921
|
+
set(fn(body, rule, api));
|
|
4779
4922
|
api.sync(rule);
|
|
4780
|
-
}
|
|
4781
|
-
|
|
4923
|
+
},
|
|
4924
|
+
onError: function onError(e) {
|
|
4925
|
+
set(undefined);
|
|
4926
|
+
if (check()) return;
|
|
4927
|
+
(_onError || function (e) {
|
|
4928
|
+
return err(e.message || 'fetch fail ' + option.action);
|
|
4929
|
+
})(e, rule, api);
|
|
4782
4930
|
}
|
|
4783
|
-
};
|
|
4931
|
+
});
|
|
4932
|
+
fc.options.beforeFetch && invoke(function () {
|
|
4933
|
+
return fc.options.beforeFetch(config, {
|
|
4934
|
+
rule: rule,
|
|
4935
|
+
api: api
|
|
4936
|
+
});
|
|
4937
|
+
});
|
|
4938
|
+
if (is.Function(option.action)) {
|
|
4939
|
+
option.action(rule, api).then(function (val) {
|
|
4940
|
+
config.onSuccess(val, true);
|
|
4941
|
+
})["catch"](function (e) {
|
|
4942
|
+
config.onError(e);
|
|
4943
|
+
});
|
|
4944
|
+
return;
|
|
4945
|
+
}
|
|
4784
4946
|
invoke(function () {
|
|
4785
|
-
return fc.create.fetch(
|
|
4786
|
-
onSuccess: function onSuccess(body) {
|
|
4787
|
-
if (check()) return;
|
|
4788
|
-
var fn = function fn(v) {
|
|
4789
|
-
return v.data;
|
|
4790
|
-
};
|
|
4791
|
-
if (is.Function(option.parse)) {
|
|
4792
|
-
fn = option.parse;
|
|
4793
|
-
}
|
|
4794
|
-
set(fn(body, rule, api));
|
|
4795
|
-
api.sync(rule);
|
|
4796
|
-
},
|
|
4797
|
-
onError: function onError(e) {
|
|
4798
|
-
set(undefined);
|
|
4799
|
-
if (check()) return;
|
|
4800
|
-
(_onError || function (e) {
|
|
4801
|
-
return err(e.message || 'fetch fail ' + option.action);
|
|
4802
|
-
})(e, rule, api);
|
|
4803
|
-
}
|
|
4804
|
-
}), {
|
|
4947
|
+
return fc.create.fetch(config, {
|
|
4805
4948
|
inject: inject,
|
|
4806
4949
|
rule: rule,
|
|
4807
4950
|
api: api
|
|
4808
4951
|
});
|
|
4809
4952
|
});
|
|
4810
|
-
return true;
|
|
4811
4953
|
}
|
|
4812
4954
|
return {
|
|
4813
4955
|
name: 'fetch',
|
|
4814
4956
|
loaded: function loaded() {
|
|
4815
4957
|
run.apply(void 0, arguments);
|
|
4816
4958
|
},
|
|
4817
|
-
watch: function watch(
|
|
4818
|
-
|
|
4819
|
-
inject.clearProp();
|
|
4820
|
-
api.sync(rule);
|
|
4821
|
-
}
|
|
4959
|
+
watch: function watch() {
|
|
4960
|
+
run.apply(void 0, arguments);
|
|
4822
4961
|
}
|
|
4823
4962
|
};
|
|
4824
4963
|
};
|
|
@@ -4872,6 +5011,7 @@
|
|
|
4872
5011
|
}
|
|
4873
5012
|
var $provider = {
|
|
4874
5013
|
fetch: fetch$1,
|
|
5014
|
+
loadData: loadData,
|
|
4875
5015
|
required: $required,
|
|
4876
5016
|
componentValidate: componentValidate
|
|
4877
5017
|
};
|
|
@@ -4954,13 +5094,18 @@
|
|
|
4954
5094
|
var globalConfig = {
|
|
4955
5095
|
global: {}
|
|
4956
5096
|
};
|
|
4957
|
-
var
|
|
5097
|
+
var loadData = {};
|
|
4958
5098
|
var CreateNode = CreateNodeFactory();
|
|
4959
5099
|
exportAttrs(config.attrs || {});
|
|
4960
5100
|
function getApi(name) {
|
|
4961
5101
|
var val = instance[name];
|
|
4962
|
-
if (Array.isArray(val))
|
|
4963
|
-
|
|
5102
|
+
if (Array.isArray(val)) {
|
|
5103
|
+
return val.map(function (v) {
|
|
5104
|
+
return v.api();
|
|
5105
|
+
});
|
|
5106
|
+
} else if (val) {
|
|
5107
|
+
return val.api();
|
|
5108
|
+
}
|
|
4964
5109
|
}
|
|
4965
5110
|
function directive() {
|
|
4966
5111
|
var data = nameProp.apply(void 0, arguments);
|
|
@@ -5002,6 +5147,22 @@
|
|
|
5002
5147
|
components[name] = component;
|
|
5003
5148
|
if (component.formCreateParser) parser(name, component.formCreateParser);
|
|
5004
5149
|
}
|
|
5150
|
+
function _emitData(id) {
|
|
5151
|
+
Object.keys(instance).forEach(function (v) {
|
|
5152
|
+
var apis = Array.isArray(instance[v]) ? instance[v] : [instance[v]];
|
|
5153
|
+
apis.forEach(function (that) {
|
|
5154
|
+
that.bus.$emit('p.loadData.' + id);
|
|
5155
|
+
});
|
|
5156
|
+
});
|
|
5157
|
+
}
|
|
5158
|
+
function setData(id, data) {
|
|
5159
|
+
loadData[id] = data;
|
|
5160
|
+
_emitData(id);
|
|
5161
|
+
}
|
|
5162
|
+
function removeData(id) {
|
|
5163
|
+
delete loadData[id];
|
|
5164
|
+
_emitData(id);
|
|
5165
|
+
}
|
|
5005
5166
|
function $form() {
|
|
5006
5167
|
return _vue.extend($FormCreate(FormCreate));
|
|
5007
5168
|
}
|
|
@@ -5028,7 +5189,7 @@
|
|
|
5028
5189
|
directives: directives,
|
|
5029
5190
|
providers: providers,
|
|
5030
5191
|
maker: maker,
|
|
5031
|
-
|
|
5192
|
+
loadData: loadData
|
|
5032
5193
|
};
|
|
5033
5194
|
} else {
|
|
5034
5195
|
delete _config.inherit;
|
|
@@ -5044,12 +5205,13 @@
|
|
|
5044
5205
|
parsers: parsers,
|
|
5045
5206
|
providers: providers,
|
|
5046
5207
|
rules: Array.isArray(rules) ? rules : [],
|
|
5047
|
-
name: vm.$options.propsData.name,
|
|
5208
|
+
name: vm.$options.propsData.name || uniqueId(),
|
|
5048
5209
|
inFor: vm.$options.propsData.inFor,
|
|
5049
5210
|
prop: {
|
|
5050
5211
|
components: components,
|
|
5051
5212
|
directives: directives
|
|
5052
5213
|
},
|
|
5214
|
+
loadData: loadData,
|
|
5053
5215
|
CreateNode: CreateNode,
|
|
5054
5216
|
bus: new _vue(),
|
|
5055
5217
|
unwatch: null,
|
|
@@ -5063,9 +5225,9 @@
|
|
|
5063
5225
|
if (this.name) {
|
|
5064
5226
|
if (this.inFor) {
|
|
5065
5227
|
if (!instance[this.name]) instance[this.name] = [];
|
|
5066
|
-
instance[this.name].push(this
|
|
5228
|
+
instance[this.name].push(this);
|
|
5067
5229
|
} else {
|
|
5068
|
-
instance[this.name] = this
|
|
5230
|
+
instance[this.name] = this;
|
|
5069
5231
|
}
|
|
5070
5232
|
}
|
|
5071
5233
|
}
|
|
@@ -5100,8 +5262,11 @@
|
|
|
5100
5262
|
h.reloadRule([]);
|
|
5101
5263
|
if (_this2.name) {
|
|
5102
5264
|
if (_this2.inFor) {
|
|
5103
|
-
var idx = instance[_this2.name].indexOf(_this2
|
|
5265
|
+
var idx = instance[_this2.name].indexOf(_this2);
|
|
5104
5266
|
instance[_this2.name].splice(idx, 1);
|
|
5267
|
+
if (!instance[_this2.name].length) {
|
|
5268
|
+
delete instance[_this2.name];
|
|
5269
|
+
}
|
|
5105
5270
|
} else {
|
|
5106
5271
|
delete instance[_this2.name];
|
|
5107
5272
|
}
|
|
@@ -5161,7 +5326,8 @@
|
|
|
5161
5326
|
extend(formCreate, {
|
|
5162
5327
|
version: config.version,
|
|
5163
5328
|
ui: config.ui,
|
|
5164
|
-
|
|
5329
|
+
setData: setData,
|
|
5330
|
+
removeData: removeData,
|
|
5165
5331
|
maker: maker,
|
|
5166
5332
|
component: component,
|
|
5167
5333
|
directive: directive,
|
|
@@ -5234,7 +5400,7 @@
|
|
|
5234
5400
|
inherit.directives && extend(directives, inherit.directives);
|
|
5235
5401
|
inherit.providers && extend(providers, inherit.providers);
|
|
5236
5402
|
inherit.maker && extend(maker, inherit.maker);
|
|
5237
|
-
inherit.
|
|
5403
|
+
inherit.loadData && extend(loadData, inherit.loadData);
|
|
5238
5404
|
}
|
|
5239
5405
|
return create;
|
|
5240
5406
|
}
|
|
@@ -5825,8 +5991,8 @@
|
|
|
5825
5991
|
useFrame(maker);
|
|
5826
5992
|
useTimePicker(maker);
|
|
5827
5993
|
|
|
5828
|
-
var css_248z$
|
|
5829
|
-
styleInject(css_248z$
|
|
5994
|
+
var css_248z$3 = ".form-create .form-create .ivu-form-item {\n margin-bottom: 24px;\n}\n\n.form-create .form-create .ivu-form-item .ivu-form-item {\n margin-bottom: 0px;\n}\n";
|
|
5995
|
+
styleInject(css_248z$3);
|
|
5830
5996
|
|
|
5831
5997
|
function tidyBtnProp(btn, def) {
|
|
5832
5998
|
if (is.Boolean(btn)) btn = {
|
|
@@ -5838,6 +6004,14 @@
|
|
|
5838
6004
|
}
|
|
5839
6005
|
function extendApi(api, h) {
|
|
5840
6006
|
extend(api, {
|
|
6007
|
+
formEl: function formEl() {
|
|
6008
|
+
return h.$manager.form();
|
|
6009
|
+
},
|
|
6010
|
+
wrapEl: function wrapEl(id) {
|
|
6011
|
+
var ctx = h.getFieldCtx(id);
|
|
6012
|
+
if (!ctx) return;
|
|
6013
|
+
return h.vm.$refs[ctx.wrapRef];
|
|
6014
|
+
},
|
|
5841
6015
|
validate: function validate(callback) {
|
|
5842
6016
|
return new Promise(function (resolve, reject) {
|
|
5843
6017
|
var forms = api.children;
|
|
@@ -6000,7 +6174,7 @@
|
|
|
6000
6174
|
function ivuFormCreate() {
|
|
6001
6175
|
return FormCreateFactory({
|
|
6002
6176
|
ui: "".concat("view-design"),
|
|
6003
|
-
version: "".concat("2.5.
|
|
6177
|
+
version: "".concat("2.5.33"),
|
|
6004
6178
|
manager: manager,
|
|
6005
6179
|
install: install,
|
|
6006
6180
|
extendApi: extendApi,
|