@form-create/component-antdv-group 3.1.1 → 3.1.4
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/index.esm.js +179 -34
- package/dist/index.esm.min.js +2 -2
- package/dist/index.js +178 -33
- package/dist/index.min.js +2 -2
- package/package.json +3 -3
- package/src/MinusCircleOutlined.vue +17 -0
- package/src/PlusCircleOutlined.vue +18 -0
- package/src/component.jsx +12 -8
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/component-antdv-group v3.1.
|
|
2
|
+
* @form-create/component-antdv-group v3.1.4
|
|
3
3
|
* (c) 2018-2022 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create with group
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent, markRaw, nextTick, createVNode, resolveComponent, isVNode } from 'vue';
|
|
7
|
+
import { openBlock, createElementBlock, createElementVNode, defineComponent, markRaw, nextTick, createVNode, resolveComponent, isVNode } from 'vue';
|
|
8
8
|
|
|
9
9
|
function ownKeys(object, enumerableOnly) {
|
|
10
10
|
var keys = Object.keys(object);
|
|
@@ -120,9 +120,28 @@ var is = {
|
|
|
120
120
|
},
|
|
121
121
|
trueArray: function trueArray(data) {
|
|
122
122
|
return Array.isArray(data) && data.length > 0;
|
|
123
|
+
},
|
|
124
|
+
Function: function Function(v) {
|
|
125
|
+
var type = this.getType(v);
|
|
126
|
+
return type === 'Function' || type === 'AsyncFunction';
|
|
127
|
+
},
|
|
128
|
+
getType: function getType(v) {
|
|
129
|
+
var str = Object.prototype.toString.call(v);
|
|
130
|
+
return /^\[object (.*)\]$/.exec(str)[1];
|
|
131
|
+
},
|
|
132
|
+
empty: function empty(value) {
|
|
133
|
+
if (value === undefined || value === null) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (Array.isArray(value) && Array.isArray(value) && !value.length) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return typeof value === 'string' && !value;
|
|
123
142
|
}
|
|
124
143
|
};
|
|
125
|
-
['Date', 'Object', '
|
|
144
|
+
['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
|
|
126
145
|
is[t] = function (arg) {
|
|
127
146
|
return is.type(arg, t);
|
|
128
147
|
};
|
|
@@ -131,6 +150,134 @@ function hasProperty(rule, k) {
|
|
|
131
150
|
return {}.hasOwnProperty.call(rule, k);
|
|
132
151
|
}
|
|
133
152
|
|
|
153
|
+
var script$1 = {
|
|
154
|
+
name: 'MinusCircleOutlined'
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var _hoisted_1$1 = {
|
|
158
|
+
"class": "anticon"
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var _hoisted_2$1 = /*#__PURE__*/createElementVNode("svg", {
|
|
162
|
+
height: "1em",
|
|
163
|
+
width: "1em",
|
|
164
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
165
|
+
viewBox: "0 0 1024 1024"
|
|
166
|
+
}, [/*#__PURE__*/createElementVNode("path", {
|
|
167
|
+
d: "M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
|
|
168
|
+
fill: "currentColor"
|
|
169
|
+
}), /*#__PURE__*/createElementVNode("path", {
|
|
170
|
+
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
|
|
171
|
+
fill: "currentColor"
|
|
172
|
+
})], -1);
|
|
173
|
+
|
|
174
|
+
var _hoisted_3$1 = [_hoisted_2$1];
|
|
175
|
+
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
176
|
+
return openBlock(), createElementBlock("span", _hoisted_1$1, _hoisted_3$1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
script$1.render = render$1;
|
|
180
|
+
|
|
181
|
+
var script = {
|
|
182
|
+
name: 'PlusCircleOutlined'
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
var _hoisted_1 = {
|
|
186
|
+
"class": "anticon"
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var _hoisted_2 = /*#__PURE__*/createElementVNode("svg", {
|
|
190
|
+
height: "1em",
|
|
191
|
+
width: "1em",
|
|
192
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
193
|
+
viewBox: "0 0 1024 1024"
|
|
194
|
+
}, [/*#__PURE__*/createElementVNode("path", {
|
|
195
|
+
d: "M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
|
|
196
|
+
fill: "currentColor"
|
|
197
|
+
}), /*#__PURE__*/createElementVNode("path", {
|
|
198
|
+
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
|
|
199
|
+
fill: "currentColor"
|
|
200
|
+
})], -1);
|
|
201
|
+
|
|
202
|
+
var _hoisted_3 = [_hoisted_2];
|
|
203
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
204
|
+
return openBlock(), createElementBlock("span", _hoisted_1, _hoisted_3);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
script.render = render;
|
|
208
|
+
|
|
209
|
+
function $set(target, field, value) {
|
|
210
|
+
target[field] = value;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function deepExtend(origin) {
|
|
214
|
+
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
215
|
+
var mode = arguments.length > 2 ? arguments[2] : undefined;
|
|
216
|
+
var isArr = false;
|
|
217
|
+
|
|
218
|
+
for (var key in target) {
|
|
219
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
220
|
+
var clone = target[key];
|
|
221
|
+
|
|
222
|
+
if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
|
|
223
|
+
var nst = origin[key] === undefined;
|
|
224
|
+
|
|
225
|
+
if (isArr) {
|
|
226
|
+
isArr = false;
|
|
227
|
+
nst && $set(origin, key, []);
|
|
228
|
+
} else if (clone._clone && mode !== undefined) {
|
|
229
|
+
if (mode) {
|
|
230
|
+
clone = clone.getRule();
|
|
231
|
+
nst && $set(origin, key, {});
|
|
232
|
+
} else {
|
|
233
|
+
$set(origin, key, clone._clone());
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
nst && $set(origin, key, {});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
origin[key] = deepExtend(origin[key], clone, mode);
|
|
241
|
+
} else {
|
|
242
|
+
$set(origin, key, clone);
|
|
243
|
+
|
|
244
|
+
if (!is.Undef(clone)) {
|
|
245
|
+
if (!is.Undef(clone.__json)) {
|
|
246
|
+
origin[key].__json = clone.__json;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!is.Undef(clone.__origin)) {
|
|
250
|
+
origin[key].__origin = clone.__origin;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
|
|
258
|
+
return !v || !v.__ctrl;
|
|
259
|
+
}) : origin;
|
|
260
|
+
}
|
|
261
|
+
function deepCopy(value) {
|
|
262
|
+
return deepExtend({}, {
|
|
263
|
+
value: value
|
|
264
|
+
}).value;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
var _extends = Object.assign || function (a) {
|
|
268
|
+
for (var b, c = 1; c < arguments.length; c++) {
|
|
269
|
+
for (var d in b = arguments[c], b) {
|
|
270
|
+
Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return a;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
function extend() {
|
|
278
|
+
return _extends.apply(this, arguments);
|
|
279
|
+
}
|
|
280
|
+
|
|
134
281
|
function _isSlot(s) {
|
|
135
282
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
136
283
|
}
|
|
@@ -161,6 +308,7 @@ var Group = defineComponent({
|
|
|
161
308
|
return [];
|
|
162
309
|
}
|
|
163
310
|
},
|
|
311
|
+
defaultValue: Object,
|
|
164
312
|
disabled: {
|
|
165
313
|
type: Boolean,
|
|
166
314
|
"default": false
|
|
@@ -230,8 +378,6 @@ var Group = defineComponent({
|
|
|
230
378
|
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
231
379
|
this.removeRule(keys[total - _i2 - 1]);
|
|
232
380
|
}
|
|
233
|
-
|
|
234
|
-
this.subForm();
|
|
235
381
|
}
|
|
236
382
|
|
|
237
383
|
n.forEach(function (val, i) {
|
|
@@ -239,8 +385,7 @@ var Group = defineComponent({
|
|
|
239
385
|
});
|
|
240
386
|
}
|
|
241
387
|
},
|
|
242
|
-
deep: true
|
|
243
|
-
flush: 'post'
|
|
388
|
+
deep: true
|
|
244
389
|
}
|
|
245
390
|
},
|
|
246
391
|
methods: {
|
|
@@ -297,6 +442,13 @@ var Group = defineComponent({
|
|
|
297
442
|
submitBtn: false,
|
|
298
443
|
resetBtn: false
|
|
299
444
|
};
|
|
445
|
+
|
|
446
|
+
if (this.defaultValue) {
|
|
447
|
+
if (!options.formData) options.formData = {};
|
|
448
|
+
var defVal = deepCopy(this.defaultValue);
|
|
449
|
+
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
450
|
+
}
|
|
451
|
+
|
|
300
452
|
this.cacheRule[++this.len] = {
|
|
301
453
|
rule: rule,
|
|
302
454
|
options: options
|
|
@@ -312,7 +464,7 @@ var Group = defineComponent({
|
|
|
312
464
|
var _this4 = this;
|
|
313
465
|
|
|
314
466
|
this.cacheRule[key].$f = $f;
|
|
315
|
-
this.
|
|
467
|
+
this.formData(key, $f.formData());
|
|
316
468
|
nextTick(function () {
|
|
317
469
|
if (_this4.syncDisabled) {
|
|
318
470
|
$f.disabled(_this4.disabled);
|
|
@@ -321,15 +473,8 @@ var Group = defineComponent({
|
|
|
321
473
|
_this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
|
|
322
474
|
});
|
|
323
475
|
},
|
|
324
|
-
subForm: function subForm() {
|
|
325
|
-
var _this5 = this;
|
|
326
|
-
|
|
327
|
-
this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
|
|
328
|
-
return _this5.cacheRule[k].$f;
|
|
329
|
-
}));
|
|
330
|
-
},
|
|
331
476
|
removeRule: function removeRule(key, emit) {
|
|
332
|
-
var
|
|
477
|
+
var _this5 = this;
|
|
333
478
|
|
|
334
479
|
var index = Object.keys(this.cacheRule).indexOf(key);
|
|
335
480
|
delete this.cacheRule[key];
|
|
@@ -337,7 +482,7 @@ var Group = defineComponent({
|
|
|
337
482
|
|
|
338
483
|
if (emit) {
|
|
339
484
|
nextTick(function () {
|
|
340
|
-
return
|
|
485
|
+
return _this5.$emit('remove', index);
|
|
341
486
|
});
|
|
342
487
|
}
|
|
343
488
|
},
|
|
@@ -355,30 +500,29 @@ var Group = defineComponent({
|
|
|
355
500
|
}
|
|
356
501
|
|
|
357
502
|
this.removeRule(key, true);
|
|
358
|
-
this.subForm();
|
|
359
503
|
this.modelValue.splice(index, 1);
|
|
360
504
|
this.input(this.modelValue);
|
|
361
505
|
},
|
|
362
506
|
addIcon: function addIcon(key) {
|
|
363
|
-
return createVNode(
|
|
507
|
+
return createVNode(script, {
|
|
364
508
|
"key": "a".concat(key),
|
|
365
509
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
|
|
366
510
|
"onClick": this.add
|
|
367
511
|
}, null);
|
|
368
512
|
},
|
|
369
513
|
delIcon: function delIcon(index, key) {
|
|
370
|
-
var
|
|
514
|
+
var _this6 = this;
|
|
371
515
|
|
|
372
|
-
return createVNode(
|
|
516
|
+
return createVNode(script$1, {
|
|
373
517
|
"key": "d".concat(key),
|
|
374
518
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
|
|
375
519
|
"onClick": function onClick() {
|
|
376
|
-
return
|
|
520
|
+
return _this6.del(index, key);
|
|
377
521
|
}
|
|
378
522
|
}, null);
|
|
379
523
|
},
|
|
380
524
|
makeIcon: function makeIcon(total, index, key) {
|
|
381
|
-
var
|
|
525
|
+
var _this7 = this;
|
|
382
526
|
|
|
383
527
|
if (this.$slots.button) {
|
|
384
528
|
return this.$slots.button({
|
|
@@ -387,7 +531,7 @@ var Group = defineComponent({
|
|
|
387
531
|
vm: this,
|
|
388
532
|
key: key,
|
|
389
533
|
del: function del() {
|
|
390
|
-
return
|
|
534
|
+
return _this7.del(index, key);
|
|
391
535
|
},
|
|
392
536
|
add: this.add
|
|
393
537
|
});
|
|
@@ -422,7 +566,7 @@ var Group = defineComponent({
|
|
|
422
566
|
}
|
|
423
567
|
},
|
|
424
568
|
render: function render() {
|
|
425
|
-
var
|
|
569
|
+
var _this8 = this;
|
|
426
570
|
|
|
427
571
|
var keys = Object.keys(this.cacheRule);
|
|
428
572
|
var button = this.button;
|
|
@@ -430,7 +574,7 @@ var Group = defineComponent({
|
|
|
430
574
|
return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
|
|
431
575
|
vm: this,
|
|
432
576
|
add: this.add
|
|
433
|
-
}) : createVNode(
|
|
577
|
+
}) : createVNode(script, {
|
|
434
578
|
"key": 1,
|
|
435
579
|
"style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
|
|
436
580
|
"onClick": this.add
|
|
@@ -439,9 +583,9 @@ var Group = defineComponent({
|
|
|
439
583
|
}, [keys.map(function (key, index) {
|
|
440
584
|
var _slot;
|
|
441
585
|
|
|
442
|
-
var
|
|
443
|
-
rule =
|
|
444
|
-
options =
|
|
586
|
+
var _this8$cacheRule$key = _this8.cacheRule[key],
|
|
587
|
+
rule = _this8$cacheRule$key.rule,
|
|
588
|
+
options = _this8$cacheRule$key.options;
|
|
445
589
|
return createVNode(resolveComponent("aRow"), {
|
|
446
590
|
"align": "middle",
|
|
447
591
|
"type": "flex",
|
|
@@ -455,19 +599,20 @@ var Group = defineComponent({
|
|
|
455
599
|
"default": function _default() {
|
|
456
600
|
return [createVNode(Type, {
|
|
457
601
|
"key": key,
|
|
602
|
+
"inFor": true,
|
|
458
603
|
"onUpdate:modelValue": function onUpdateModelValue(formData) {
|
|
459
|
-
return
|
|
604
|
+
return _this8.formData(key, formData);
|
|
460
605
|
},
|
|
461
|
-
"modelValue":
|
|
606
|
+
"modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
|
|
462
607
|
"onEmit-event": function onEmitEvent(name) {
|
|
463
608
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
464
609
|
args[_key - 1] = arguments[_key];
|
|
465
610
|
}
|
|
466
611
|
|
|
467
|
-
return
|
|
612
|
+
return _this8.emitEvent(name, args, index, key);
|
|
468
613
|
},
|
|
469
614
|
"onUpdate:api": function onUpdateApi($f) {
|
|
470
|
-
return
|
|
615
|
+
return _this8.add$f(index, key, $f);
|
|
471
616
|
},
|
|
472
617
|
"rule": rule,
|
|
473
618
|
"option": options,
|
|
@@ -478,7 +623,7 @@ var Group = defineComponent({
|
|
|
478
623
|
"span": 2,
|
|
479
624
|
"pull": 1,
|
|
480
625
|
"push": 1
|
|
481
|
-
}, _isSlot(_slot =
|
|
626
|
+
}, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
|
|
482
627
|
"default": function _default() {
|
|
483
628
|
return [_slot];
|
|
484
629
|
}
|
package/dist/index.esm.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/component-antdv-group v3.1.
|
|
2
|
+
* @form-create/component-antdv-group v3.1.4
|
|
3
3
|
* (c) 2018-2022 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create with group
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
import{
|
|
7
|
+
import{openBlock as e,createElementBlock as t,createElementVNode as n,defineComponent as r,markRaw as o,nextTick as i,createVNode as l,resolveComponent as a,isVNode as u}from"vue";function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var m={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===f(e)&&null!==e&&1===e.nodeType&&!m.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0},Function:function(e){var t=this.getType(e);return"Function"===t||"AsyncFunction"===t},getType:function(e){var t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty:function(e){return null==e||(!(!Array.isArray(e)||!Array.isArray(e)||e.length)||"string"==typeof e&&!e)}};["Date","Object","String","Boolean","Array","Number"].forEach((function(e){m[e]=function(t){return m.type(t,e)}}));var y={name:"MinusCircleOutlined"},b={class:"anticon"},v=[n("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[n("path",{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),n("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];y.render=function(n,r,o,i,l,a){return e(),t("span",b,v)};var g={name:"PlusCircleOutlined"},O={class:"anticon"},j=[n("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[n("path",{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),n("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];function w(e,t,n){e[t]=n}function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=!1;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var i=t[o];if((r=Array.isArray(i))||m.Object(i)){var l=void 0===e[o];if(r)r=!1,l&&w(e,o,[]);else if(i._clone&&void 0!==n){if(!n){w(e,o,i._clone());continue}i=i.getRule(),l&&w(e,o,{})}else l&&w(e,o,{});e[o]=V(e[o],i,n)}else w(e,o,i),m.Undef(i)||(m.Undef(i.__json)||(e[o].__json=i.__json),m.Undef(i.__origin)||(e[o].__origin=i.__origin))}return void 0!==n&&Array.isArray(e)?e.filter((function(e){return!e||!e.__ctrl})):e}function R(e){return V({},{value:e}).value}g.render=function(n,r,o,i,l,a){return e(),t("span",O,j)};var x=Object.assign||function(e){for(var t,n=1;n<arguments.length;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&w(e,r,t[r]);return e};var A=r({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object},data:function(){return{len:0,cacheRule:{},cacheValue:{},form:o(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),r=n.length,o=r-e.length;if(o<0){for(var i=o;i<0;i++)this.addRule(e.length+i);for(var l=0;l<r;l++)this.setValue(n[l],e[l])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(n[r-a-1]);e.forEach((function(r,o){t.setValue(n[o],e[o])}))}},deep:!0}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},cache:function(e,t){this.cacheValue[e]=JSON.stringify(t)},input:function(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData:function(e,t){var n=this,r=this.cacheRule,o=Object.keys(r);if(o.filter((function(e){return r[e].$f})).length===o.length){var i=o.map((function(r){var o=e===r?t:s({},n.cacheRule[r].$f.form),i=n.field?o[n.field]||null:o;return n.cache(r,i),i}));this.input(i)}},setValue:function(e,t){var n=this.field;n&&(t=d({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,t){var n=this,r=this.formCreateInject.form.copyRules(this.rule||[]),o=this.options?s({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){o.formData||(o.formData={});var l=R(this.defaultValue);!function(){x.apply(this,arguments)}(o.formData,this.field?d({},this.field,l):l)}this.cacheRule[++this.len]={rule:r,options:o},t&&i((function(){return n.$emit("add",r,Object.keys(n.cacheRule).length-1)}))},add$f:function(e,t,n){var r=this;this.cacheRule[t].$f=n,this.formData(t,n.formData()),i((function(){r.syncDisabled&&n.disabled(r.disabled),r.$emit("itemMounted",n,Object.keys(r.cacheRule).indexOf(t))}))},removeRule:function(e,t){var n=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],t&&i((function(){return n.$emit("remove",r)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return l(g,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,t){var n=this;return l(y,{key:"d".concat(t),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return n.del(e,t)}},null)},makeIcon:function(e,t,n){var r=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return r.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,r){this.$emit.apply(this,[e].concat(h(t),[this.cacheRule[r].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,t=Object.keys(this.cacheRule),n=this.button,r=this.form;return 0===t.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):l(g,{key:1,style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):l("div",{key:2},[t.map((function(o,i){var c,s=e.cacheRule[o],f=s.rule,h=s.options;return l(a("aRow"),{align:"middle",type:"flex",key:o,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[l(a("aCol"),{span:n?20:24},{default:function(){return[l(r,{key:o,inFor:!0,"onUpdate:modelValue":function(t){return e.formData(o,t)},modelValue:e.field?d({},e.field,e._value(e.modelValue[i])):e.modelValue[i],"onEmit-event":function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return e.emitEvent(t,r,i,o)},"onUpdate:api":function(t){return e.add$f(i,o,t)},rule:f,option:h,extendOption:!0},null)]}}),n?l(a("aCol"),{span:2,pull:1,push:1},(s=c=e.makeIcon(t.length,i,o),"function"==typeof s||"[object Object]"===Object.prototype.toString.call(s)&&!u(s)?c:{default:function(){return[c]}})):null];var s}})}))])}});export{A as default};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/component-antdv-group v3.1.
|
|
2
|
+
* @form-create/component-antdv-group v3.1.4
|
|
3
3
|
* (c) 2018-2022 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create with group
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -124,9 +124,28 @@
|
|
|
124
124
|
},
|
|
125
125
|
trueArray: function trueArray(data) {
|
|
126
126
|
return Array.isArray(data) && data.length > 0;
|
|
127
|
+
},
|
|
128
|
+
Function: function Function(v) {
|
|
129
|
+
var type = this.getType(v);
|
|
130
|
+
return type === 'Function' || type === 'AsyncFunction';
|
|
131
|
+
},
|
|
132
|
+
getType: function getType(v) {
|
|
133
|
+
var str = Object.prototype.toString.call(v);
|
|
134
|
+
return /^\[object (.*)\]$/.exec(str)[1];
|
|
135
|
+
},
|
|
136
|
+
empty: function empty(value) {
|
|
137
|
+
if (value === undefined || value === null) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (Array.isArray(value) && Array.isArray(value) && !value.length) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return typeof value === 'string' && !value;
|
|
127
146
|
}
|
|
128
147
|
};
|
|
129
|
-
['Date', 'Object', '
|
|
148
|
+
['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
|
|
130
149
|
is[t] = function (arg) {
|
|
131
150
|
return is.type(arg, t);
|
|
132
151
|
};
|
|
@@ -135,6 +154,134 @@
|
|
|
135
154
|
return {}.hasOwnProperty.call(rule, k);
|
|
136
155
|
}
|
|
137
156
|
|
|
157
|
+
var script$1 = {
|
|
158
|
+
name: 'MinusCircleOutlined'
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var _hoisted_1$1 = {
|
|
162
|
+
"class": "anticon"
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var _hoisted_2$1 = /*#__PURE__*/vue.createElementVNode("svg", {
|
|
166
|
+
height: "1em",
|
|
167
|
+
width: "1em",
|
|
168
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
169
|
+
viewBox: "0 0 1024 1024"
|
|
170
|
+
}, [/*#__PURE__*/vue.createElementVNode("path", {
|
|
171
|
+
d: "M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
|
|
172
|
+
fill: "currentColor"
|
|
173
|
+
}), /*#__PURE__*/vue.createElementVNode("path", {
|
|
174
|
+
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
|
|
175
|
+
fill: "currentColor"
|
|
176
|
+
})], -1);
|
|
177
|
+
|
|
178
|
+
var _hoisted_3$1 = [_hoisted_2$1];
|
|
179
|
+
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
180
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$1, _hoisted_3$1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
script$1.render = render$1;
|
|
184
|
+
|
|
185
|
+
var script = {
|
|
186
|
+
name: 'PlusCircleOutlined'
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var _hoisted_1 = {
|
|
190
|
+
"class": "anticon"
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
var _hoisted_2 = /*#__PURE__*/vue.createElementVNode("svg", {
|
|
194
|
+
height: "1em",
|
|
195
|
+
width: "1em",
|
|
196
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
197
|
+
viewBox: "0 0 1024 1024"
|
|
198
|
+
}, [/*#__PURE__*/vue.createElementVNode("path", {
|
|
199
|
+
d: "M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
|
|
200
|
+
fill: "currentColor"
|
|
201
|
+
}), /*#__PURE__*/vue.createElementVNode("path", {
|
|
202
|
+
d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
|
|
203
|
+
fill: "currentColor"
|
|
204
|
+
})], -1);
|
|
205
|
+
|
|
206
|
+
var _hoisted_3 = [_hoisted_2];
|
|
207
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
208
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1, _hoisted_3);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
script.render = render;
|
|
212
|
+
|
|
213
|
+
function $set(target, field, value) {
|
|
214
|
+
target[field] = value;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function deepExtend(origin) {
|
|
218
|
+
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
219
|
+
var mode = arguments.length > 2 ? arguments[2] : undefined;
|
|
220
|
+
var isArr = false;
|
|
221
|
+
|
|
222
|
+
for (var key in target) {
|
|
223
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
224
|
+
var clone = target[key];
|
|
225
|
+
|
|
226
|
+
if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
|
|
227
|
+
var nst = origin[key] === undefined;
|
|
228
|
+
|
|
229
|
+
if (isArr) {
|
|
230
|
+
isArr = false;
|
|
231
|
+
nst && $set(origin, key, []);
|
|
232
|
+
} else if (clone._clone && mode !== undefined) {
|
|
233
|
+
if (mode) {
|
|
234
|
+
clone = clone.getRule();
|
|
235
|
+
nst && $set(origin, key, {});
|
|
236
|
+
} else {
|
|
237
|
+
$set(origin, key, clone._clone());
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
nst && $set(origin, key, {});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
origin[key] = deepExtend(origin[key], clone, mode);
|
|
245
|
+
} else {
|
|
246
|
+
$set(origin, key, clone);
|
|
247
|
+
|
|
248
|
+
if (!is.Undef(clone)) {
|
|
249
|
+
if (!is.Undef(clone.__json)) {
|
|
250
|
+
origin[key].__json = clone.__json;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!is.Undef(clone.__origin)) {
|
|
254
|
+
origin[key].__origin = clone.__origin;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
|
|
262
|
+
return !v || !v.__ctrl;
|
|
263
|
+
}) : origin;
|
|
264
|
+
}
|
|
265
|
+
function deepCopy(value) {
|
|
266
|
+
return deepExtend({}, {
|
|
267
|
+
value: value
|
|
268
|
+
}).value;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
var _extends = Object.assign || function (a) {
|
|
272
|
+
for (var b, c = 1; c < arguments.length; c++) {
|
|
273
|
+
for (var d in b = arguments[c], b) {
|
|
274
|
+
Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return a;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
function extend() {
|
|
282
|
+
return _extends.apply(this, arguments);
|
|
283
|
+
}
|
|
284
|
+
|
|
138
285
|
function _isSlot(s) {
|
|
139
286
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
|
|
140
287
|
}
|
|
@@ -165,6 +312,7 @@
|
|
|
165
312
|
return [];
|
|
166
313
|
}
|
|
167
314
|
},
|
|
315
|
+
defaultValue: Object,
|
|
168
316
|
disabled: {
|
|
169
317
|
type: Boolean,
|
|
170
318
|
"default": false
|
|
@@ -234,8 +382,6 @@
|
|
|
234
382
|
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
235
383
|
this.removeRule(keys[total - _i2 - 1]);
|
|
236
384
|
}
|
|
237
|
-
|
|
238
|
-
this.subForm();
|
|
239
385
|
}
|
|
240
386
|
|
|
241
387
|
n.forEach(function (val, i) {
|
|
@@ -243,8 +389,7 @@
|
|
|
243
389
|
});
|
|
244
390
|
}
|
|
245
391
|
},
|
|
246
|
-
deep: true
|
|
247
|
-
flush: 'post'
|
|
392
|
+
deep: true
|
|
248
393
|
}
|
|
249
394
|
},
|
|
250
395
|
methods: {
|
|
@@ -301,6 +446,13 @@
|
|
|
301
446
|
submitBtn: false,
|
|
302
447
|
resetBtn: false
|
|
303
448
|
};
|
|
449
|
+
|
|
450
|
+
if (this.defaultValue) {
|
|
451
|
+
if (!options.formData) options.formData = {};
|
|
452
|
+
var defVal = deepCopy(this.defaultValue);
|
|
453
|
+
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
454
|
+
}
|
|
455
|
+
|
|
304
456
|
this.cacheRule[++this.len] = {
|
|
305
457
|
rule: rule,
|
|
306
458
|
options: options
|
|
@@ -316,7 +468,7 @@
|
|
|
316
468
|
var _this4 = this;
|
|
317
469
|
|
|
318
470
|
this.cacheRule[key].$f = $f;
|
|
319
|
-
this.
|
|
471
|
+
this.formData(key, $f.formData());
|
|
320
472
|
vue.nextTick(function () {
|
|
321
473
|
if (_this4.syncDisabled) {
|
|
322
474
|
$f.disabled(_this4.disabled);
|
|
@@ -325,15 +477,8 @@
|
|
|
325
477
|
_this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
|
|
326
478
|
});
|
|
327
479
|
},
|
|
328
|
-
subForm: function subForm() {
|
|
329
|
-
var _this5 = this;
|
|
330
|
-
|
|
331
|
-
this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
|
|
332
|
-
return _this5.cacheRule[k].$f;
|
|
333
|
-
}));
|
|
334
|
-
},
|
|
335
480
|
removeRule: function removeRule(key, emit) {
|
|
336
|
-
var
|
|
481
|
+
var _this5 = this;
|
|
337
482
|
|
|
338
483
|
var index = Object.keys(this.cacheRule).indexOf(key);
|
|
339
484
|
delete this.cacheRule[key];
|
|
@@ -341,7 +486,7 @@
|
|
|
341
486
|
|
|
342
487
|
if (emit) {
|
|
343
488
|
vue.nextTick(function () {
|
|
344
|
-
return
|
|
489
|
+
return _this5.$emit('remove', index);
|
|
345
490
|
});
|
|
346
491
|
}
|
|
347
492
|
},
|
|
@@ -359,30 +504,29 @@
|
|
|
359
504
|
}
|
|
360
505
|
|
|
361
506
|
this.removeRule(key, true);
|
|
362
|
-
this.subForm();
|
|
363
507
|
this.modelValue.splice(index, 1);
|
|
364
508
|
this.input(this.modelValue);
|
|
365
509
|
},
|
|
366
510
|
addIcon: function addIcon(key) {
|
|
367
|
-
return vue.createVNode(
|
|
511
|
+
return vue.createVNode(script, {
|
|
368
512
|
"key": "a".concat(key),
|
|
369
513
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
|
|
370
514
|
"onClick": this.add
|
|
371
515
|
}, null);
|
|
372
516
|
},
|
|
373
517
|
delIcon: function delIcon(index, key) {
|
|
374
|
-
var
|
|
518
|
+
var _this6 = this;
|
|
375
519
|
|
|
376
|
-
return vue.createVNode(
|
|
520
|
+
return vue.createVNode(script$1, {
|
|
377
521
|
"key": "d".concat(key),
|
|
378
522
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
|
|
379
523
|
"onClick": function onClick() {
|
|
380
|
-
return
|
|
524
|
+
return _this6.del(index, key);
|
|
381
525
|
}
|
|
382
526
|
}, null);
|
|
383
527
|
},
|
|
384
528
|
makeIcon: function makeIcon(total, index, key) {
|
|
385
|
-
var
|
|
529
|
+
var _this7 = this;
|
|
386
530
|
|
|
387
531
|
if (this.$slots.button) {
|
|
388
532
|
return this.$slots.button({
|
|
@@ -391,7 +535,7 @@
|
|
|
391
535
|
vm: this,
|
|
392
536
|
key: key,
|
|
393
537
|
del: function del() {
|
|
394
|
-
return
|
|
538
|
+
return _this7.del(index, key);
|
|
395
539
|
},
|
|
396
540
|
add: this.add
|
|
397
541
|
});
|
|
@@ -426,7 +570,7 @@
|
|
|
426
570
|
}
|
|
427
571
|
},
|
|
428
572
|
render: function render() {
|
|
429
|
-
var
|
|
573
|
+
var _this8 = this;
|
|
430
574
|
|
|
431
575
|
var keys = Object.keys(this.cacheRule);
|
|
432
576
|
var button = this.button;
|
|
@@ -434,7 +578,7 @@
|
|
|
434
578
|
return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
|
|
435
579
|
vm: this,
|
|
436
580
|
add: this.add
|
|
437
|
-
}) : vue.createVNode(
|
|
581
|
+
}) : vue.createVNode(script, {
|
|
438
582
|
"key": 1,
|
|
439
583
|
"style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
|
|
440
584
|
"onClick": this.add
|
|
@@ -443,9 +587,9 @@
|
|
|
443
587
|
}, [keys.map(function (key, index) {
|
|
444
588
|
var _slot;
|
|
445
589
|
|
|
446
|
-
var
|
|
447
|
-
rule =
|
|
448
|
-
options =
|
|
590
|
+
var _this8$cacheRule$key = _this8.cacheRule[key],
|
|
591
|
+
rule = _this8$cacheRule$key.rule,
|
|
592
|
+
options = _this8$cacheRule$key.options;
|
|
449
593
|
return vue.createVNode(vue.resolveComponent("aRow"), {
|
|
450
594
|
"align": "middle",
|
|
451
595
|
"type": "flex",
|
|
@@ -459,19 +603,20 @@
|
|
|
459
603
|
"default": function _default() {
|
|
460
604
|
return [vue.createVNode(Type, {
|
|
461
605
|
"key": key,
|
|
606
|
+
"inFor": true,
|
|
462
607
|
"onUpdate:modelValue": function onUpdateModelValue(formData) {
|
|
463
|
-
return
|
|
608
|
+
return _this8.formData(key, formData);
|
|
464
609
|
},
|
|
465
|
-
"modelValue":
|
|
610
|
+
"modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
|
|
466
611
|
"onEmit-event": function onEmitEvent(name) {
|
|
467
612
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
468
613
|
args[_key - 1] = arguments[_key];
|
|
469
614
|
}
|
|
470
615
|
|
|
471
|
-
return
|
|
616
|
+
return _this8.emitEvent(name, args, index, key);
|
|
472
617
|
},
|
|
473
618
|
"onUpdate:api": function onUpdateApi($f) {
|
|
474
|
-
return
|
|
619
|
+
return _this8.add$f(index, key, $f);
|
|
475
620
|
},
|
|
476
621
|
"rule": rule,
|
|
477
622
|
"option": options,
|
|
@@ -482,7 +627,7 @@
|
|
|
482
627
|
"span": 2,
|
|
483
628
|
"pull": 1,
|
|
484
629
|
"push": 1
|
|
485
|
-
}, _isSlot(_slot =
|
|
630
|
+
}, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
|
|
486
631
|
"default": function _default() {
|
|
487
632
|
return [_slot];
|
|
488
633
|
}
|
package/dist/index.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @form-create/component-antdv-group v3.1.
|
|
2
|
+
* @form-create/component-antdv-group v3.1.4
|
|
3
3
|
* (c) 2018-2022 xaboy
|
|
4
4
|
* Github https://github.com/xaboy/form-create with group
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcGroup={},e.Vue)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){i(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var a={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===r(e)&&null!==e&&1===e.nodeType&&!a.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){a[e]=function(t){return a.type(t,e)}}));var c=t.defineComponent({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object},data:function(){return{len:0,cacheRule:{},cacheValue:{},form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),o=n.length,r=o-e.length;if(r<0){for(var i=r;i<0;i++)this.addRule(e.length+i);for(var l=0;l<o;l++)this.setValue(n[l],e[l])}else{if(r>0){for(var u=0;u<r;u++)this.removeRule(n[o-u-1]);this.subForm()}e.forEach((function(o,r){t.setValue(n[r],e[r])}))}},deep:!0,flush:"post"}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},cache:function(e,t){this.cacheValue[e]=JSON.stringify(t)},input:function(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData:function(e,t){var n=this,r=this.cacheRule,i=Object.keys(r);if(i.filter((function(e){return r[e].$f})).length===i.length){var l=i.map((function(r){var i=e===r?t:o({},n.cacheRule[r].$f.form),l=n.field?i[n.field]||null:i;return n.cache(r,l),l}));this.input(l)}},setValue:function(e,t){var n=this.field;n&&(t=i({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,n){var r=this,i=this.formCreateInject.form.copyRules(this.rule||[]),l=this.options?o({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:i,options:l},n&&t.nextTick((function(){return r.$emit("add",i,Object.keys(r.cacheRule).length-1)}))},add$f:function(e,n,o){var r=this;this.cacheRule[n].$f=o,this.subForm(),t.nextTick((function(){r.syncDisabled&&o.disabled(r.disabled),r.$emit("itemMounted",o,Object.keys(r.cacheRule).indexOf(n))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},removeRule:function(e,n){var o=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],n&&t.nextTick((function(){return o.$emit("remove",r)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.subForm(),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return t.createVNode(t.resolveComponent("PlusCircleOutlined"),{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,n){var o=this;return t.createVNode(t.resolveComponent("MinusCircleOutlined"),{key:"d".concat(n),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return o.del(e,n)}},null)},makeIcon:function(e,t,n){var o=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return o.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,o){this.$emit.apply(this,[e].concat(l(t),[this.cacheRule[o].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,n=Object.keys(this.cacheRule),o=this.button,r=this.form;return 0===n.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode(t.resolveComponent("PlusCircleOutlined"),{key:1,style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):t.createVNode("div",{key:2},[n.map((function(l,u){var a,c=e.cacheRule[l],s=c.rule,d=c.options;return t.createVNode(t.resolveComponent("aRow"),{align:"middle",type:"flex",key:l,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[t.createVNode(t.resolveComponent("aCol"),{span:o?20:24},{default:function(){return[t.createVNode(r,{key:l,"onUpdate:modelValue":function(t){return e.formData(l,t)},modelValue:e.field?i({},e.field,e._value(e.modelValue[u])):e.modelValue[u],"onEmit-event":function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return e.emitEvent(t,o,u,l)},"onUpdate:api":function(t){return e.add$f(u,l,t)},rule:s,option:d,extendOption:!0},null)]}}),o?t.createVNode(t.resolveComponent("aCol"),{span:2,pull:1,push:1},(c=a=e.makeIcon(n.length,u,l),"function"==typeof c||"[object Object]"===Object.prototype.toString.call(c)&&!t.isVNode(c)?a:{default:function(){return[a]}})):null];var c}})}))])}});e.default=c,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcGroup={},e.Vue)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var c={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===o(e)&&null!==e&&1===e.nodeType&&!c.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0},Function:function(e){var t=this.getType(e);return"Function"===t||"AsyncFunction"===t},getType:function(e){var t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty:function(e){return null==e||(!(!Array.isArray(e)||!Array.isArray(e)||e.length)||"string"==typeof e&&!e)}};["Date","Object","String","Boolean","Array","Number"].forEach((function(e){c[e]=function(t){return c.type(t,e)}}));var u={name:"MinusCircleOutlined"},s={class:"anticon"},f=[t.createElementVNode("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),t.createElementVNode("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];u.render=function(e,n,r,o,i,l){return t.openBlock(),t.createElementBlock("span",s,f)};var d={name:"PlusCircleOutlined"},h={class:"anticon"},p=[t.createElementVNode("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),t.createElementVNode("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];function m(e,t,n){e[t]=n}function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=!1;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var i=t[o];if((r=Array.isArray(i))||c.Object(i)){var l=void 0===e[o];if(r)r=!1,l&&m(e,o,[]);else if(i._clone&&void 0!==n){if(!n){m(e,o,i._clone());continue}i=i.getRule(),l&&m(e,o,{})}else l&&m(e,o,{});e[o]=y(e[o],i,n)}else m(e,o,i),c.Undef(i)||(c.Undef(i.__json)||(e[o].__json=i.__json),c.Undef(i.__origin)||(e[o].__origin=i.__origin))}return void 0!==n&&Array.isArray(e)?e.filter((function(e){return!e||!e.__ctrl})):e}function v(e){return y({},{value:e}).value}d.render=function(e,n,r,o,i,l){return t.openBlock(),t.createElementBlock("span",h,p)};var b=Object.assign||function(e){for(var t,n=1;n<arguments.length;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&m(e,r,t[r]);return e};var g=t.defineComponent({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object},data:function(){return{len:0,cacheRule:{},cacheValue:{},form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),r=n.length,o=r-e.length;if(o<0){for(var i=o;i<0;i++)this.addRule(e.length+i);for(var l=0;l<r;l++)this.setValue(n[l],e[l])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(n[r-a-1]);e.forEach((function(r,o){t.setValue(n[o],e[o])}))}},deep:!0}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},cache:function(e,t){this.cacheValue[e]=JSON.stringify(t)},input:function(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData:function(e,t){var n=this,o=this.cacheRule,i=Object.keys(o);if(i.filter((function(e){return o[e].$f})).length===i.length){var l=i.map((function(o){var i=e===o?t:r({},n.cacheRule[o].$f.form),l=n.field?i[n.field]||null:i;return n.cache(o,l),l}));this.input(l)}},setValue:function(e,t){var n=this.field;n&&(t=i({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,n){var o=this,l=this.formCreateInject.form.copyRules(this.rule||[]),a=this.options?r({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){a.formData||(a.formData={});var c=v(this.defaultValue);!function(){b.apply(this,arguments)}(a.formData,this.field?i({},this.field,c):c)}this.cacheRule[++this.len]={rule:l,options:a},n&&t.nextTick((function(){return o.$emit("add",l,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,n,r){var o=this;this.cacheRule[n].$f=r,this.formData(n,r.formData()),t.nextTick((function(){o.syncDisabled&&r.disabled(o.disabled),o.$emit("itemMounted",r,Object.keys(o.cacheRule).indexOf(n))}))},removeRule:function(e,n){var r=this,o=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],n&&t.nextTick((function(){return r.$emit("remove",o)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return t.createVNode(d,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,n){var r=this;return t.createVNode(u,{key:"d".concat(n),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return r.del(e,n)}},null)},makeIcon:function(e,t,n){var r=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return r.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,r){this.$emit.apply(this,[e].concat(l(t),[this.cacheRule[r].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,n=Object.keys(this.cacheRule),r=this.button,o=this.form;return 0===n.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode(d,{key:1,style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):t.createVNode("div",{key:2},[n.map((function(l,a){var c,u=e.cacheRule[l],s=u.rule,f=u.options;return t.createVNode(t.resolveComponent("aRow"),{align:"middle",type:"flex",key:l,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[t.createVNode(t.resolveComponent("aCol"),{span:r?20:24},{default:function(){return[t.createVNode(o,{key:l,inFor:!0,"onUpdate:modelValue":function(t){return e.formData(l,t)},modelValue:e.field?i({},e.field,e._value(e.modelValue[a])):e.modelValue[a],"onEmit-event":function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.emitEvent(t,r,a,l)},"onUpdate:api":function(t){return e.add$f(a,l,t)},rule:s,option:f,extendOption:!0},null)]}}),r?t.createVNode(t.resolveComponent("aCol"),{span:2,pull:1,push:1},(u=c=e.makeIcon(n.length,a,l),"function"==typeof u||"[object Object]"===Object.prototype.toString.call(u)&&!t.isVNode(u)?c:{default:function(){return[c]}})):null];var u}})}))])}});e.default=g,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-create/component-antdv-group",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "@form-create/ant-design-vue 内置组件",
|
|
5
5
|
"main": "./dist/index.min.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "xaboy",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@form-create/utils": "^3.1.
|
|
33
|
+
"@form-create/utils": "^3.1.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ant-design/icons-vue": "^6.0.1"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"esm"
|
|
57
57
|
]
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "060ecdb8dd0f8893fa0e47415ef727472ffb381f"
|
|
60
60
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="anticon">
|
|
3
|
+
<svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
4
|
+
<path d="M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"
|
|
5
|
+
fill="currentColor"></path>
|
|
6
|
+
<path
|
|
7
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z"
|
|
8
|
+
fill="currentColor"></path>
|
|
9
|
+
</svg>
|
|
10
|
+
</span>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
export default {
|
|
15
|
+
name: 'MinusCircleOutlined'
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="anticon">
|
|
3
|
+
<svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
|
4
|
+
<path
|
|
5
|
+
d="M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"
|
|
6
|
+
fill="currentColor"></path>
|
|
7
|
+
<path
|
|
8
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z"
|
|
9
|
+
fill="currentColor"></path>
|
|
10
|
+
</svg>
|
|
11
|
+
</span>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'PlusCircleOutlined'
|
|
17
|
+
}
|
|
18
|
+
</script>
|
package/src/component.jsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import {hasProperty} from '@form-create/utils/lib/type';
|
|
2
2
|
import {defineComponent, markRaw, nextTick} from 'vue';
|
|
3
|
+
import MinusCircleOutlined from './MinusCircleOutlined.vue';
|
|
4
|
+
import PlusCircleOutlined from './PlusCircleOutlined.vue';
|
|
5
|
+
import {deepCopy} from '@form-create/utils/lib/deepextend';
|
|
6
|
+
import extend from '@form-create/utils/lib/extend';
|
|
3
7
|
|
|
4
8
|
const NAME = 'fcGroup';
|
|
5
9
|
|
|
@@ -26,6 +30,7 @@ export default defineComponent({
|
|
|
26
30
|
type: Array,
|
|
27
31
|
default: () => []
|
|
28
32
|
},
|
|
33
|
+
defaultValue: Object,
|
|
29
34
|
disabled: {
|
|
30
35
|
type: Boolean,
|
|
31
36
|
default: false
|
|
@@ -90,7 +95,6 @@ export default defineComponent({
|
|
|
90
95
|
for (let i = 0; i < len; i++) {
|
|
91
96
|
this.removeRule(keys[total - i - 1]);
|
|
92
97
|
}
|
|
93
|
-
this.subForm();
|
|
94
98
|
}
|
|
95
99
|
n.forEach((val, i) => {
|
|
96
100
|
this.setValue(keys[i], n[i]);
|
|
@@ -98,7 +102,6 @@ export default defineComponent({
|
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
deep: true,
|
|
101
|
-
flush: 'post',
|
|
102
105
|
}
|
|
103
106
|
},
|
|
104
107
|
methods: {
|
|
@@ -142,6 +145,11 @@ export default defineComponent({
|
|
|
142
145
|
submitBtn: false,
|
|
143
146
|
resetBtn: false,
|
|
144
147
|
};
|
|
148
|
+
if (this.defaultValue) {
|
|
149
|
+
if (!options.formData) options.formData = {};
|
|
150
|
+
const defVal = deepCopy(this.defaultValue);
|
|
151
|
+
extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
|
|
152
|
+
}
|
|
145
153
|
this.cacheRule[++this.len] = {rule, options};
|
|
146
154
|
if (emit) {
|
|
147
155
|
nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
|
|
@@ -149,7 +157,7 @@ export default defineComponent({
|
|
|
149
157
|
},
|
|
150
158
|
add$f(i, key, $f) {
|
|
151
159
|
this.cacheRule[key].$f = $f;
|
|
152
|
-
this.
|
|
160
|
+
this.formData(key, $f.formData());
|
|
153
161
|
nextTick(() => {
|
|
154
162
|
if (this.syncDisabled) {
|
|
155
163
|
$f.disabled(this.disabled);
|
|
@@ -157,9 +165,6 @@ export default defineComponent({
|
|
|
157
165
|
this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
|
|
158
166
|
});
|
|
159
167
|
},
|
|
160
|
-
subForm() {
|
|
161
|
-
this.formCreateInject.subForm(Object.keys(this.cacheRule).map(k => this.cacheRule[k].$f));
|
|
162
|
-
},
|
|
163
168
|
removeRule(key, emit) {
|
|
164
169
|
const index = Object.keys(this.cacheRule).indexOf(key);
|
|
165
170
|
delete this.cacheRule[key];
|
|
@@ -180,7 +185,6 @@ export default defineComponent({
|
|
|
180
185
|
return;
|
|
181
186
|
}
|
|
182
187
|
this.removeRule(key, true);
|
|
183
|
-
this.subForm();
|
|
184
188
|
this.modelValue.splice(index, 1);
|
|
185
189
|
this.input(this.modelValue);
|
|
186
190
|
},
|
|
@@ -246,7 +250,7 @@ export default defineComponent({
|
|
|
246
250
|
return <aRow align="middle" type="flex" key={key}
|
|
247
251
|
style="border-bottom:1px dashed #DCDFE6;margin-bottom:10px;">
|
|
248
252
|
<aCol span={button ? 20 : 24}><Type
|
|
249
|
-
key={key}
|
|
253
|
+
key={key} inFor={true}
|
|
250
254
|
onUpdate:modelValue={(formData) => this.formData(key, formData)}
|
|
251
255
|
modelValue={this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index]}
|
|
252
256
|
onEmit-event={(name, ...args) => this.emitEvent(name, args, index, key)}
|