@form-create/component-antdv-group 3.1.2 → 3.1.5

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.1.2
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.
@@ -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', 'Function', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
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
  };
@@ -187,6 +206,78 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
187
206
 
188
207
  script.render = render;
189
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
+
190
281
  function _isSlot(s) {
191
282
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
192
283
  }
@@ -217,6 +308,7 @@ var Group = defineComponent({
217
308
  return [];
218
309
  }
219
310
  },
311
+ defaultValue: Object,
220
312
  disabled: {
221
313
  type: Boolean,
222
314
  "default": false
@@ -286,8 +378,6 @@ var Group = defineComponent({
286
378
  for (var _i2 = 0; _i2 < len; _i2++) {
287
379
  this.removeRule(keys[total - _i2 - 1]);
288
380
  }
289
-
290
- this.subForm();
291
381
  }
292
382
 
293
383
  n.forEach(function (val, i) {
@@ -295,8 +385,7 @@ var Group = defineComponent({
295
385
  });
296
386
  }
297
387
  },
298
- deep: true,
299
- flush: 'post'
388
+ deep: true
300
389
  }
301
390
  },
302
391
  methods: {
@@ -353,6 +442,13 @@ var Group = defineComponent({
353
442
  submitBtn: false,
354
443
  resetBtn: false
355
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
+
356
452
  this.cacheRule[++this.len] = {
357
453
  rule: rule,
358
454
  options: options
@@ -368,7 +464,7 @@ var Group = defineComponent({
368
464
  var _this4 = this;
369
465
 
370
466
  this.cacheRule[key].$f = $f;
371
- this.subForm();
467
+ this.formData(key, $f.formData());
372
468
  nextTick(function () {
373
469
  if (_this4.syncDisabled) {
374
470
  $f.disabled(_this4.disabled);
@@ -377,15 +473,8 @@ var Group = defineComponent({
377
473
  _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
378
474
  });
379
475
  },
380
- subForm: function subForm() {
381
- var _this5 = this;
382
-
383
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
384
- return _this5.cacheRule[k].$f;
385
- }));
386
- },
387
476
  removeRule: function removeRule(key, emit) {
388
- var _this6 = this;
477
+ var _this5 = this;
389
478
 
390
479
  var index = Object.keys(this.cacheRule).indexOf(key);
391
480
  delete this.cacheRule[key];
@@ -393,7 +482,7 @@ var Group = defineComponent({
393
482
 
394
483
  if (emit) {
395
484
  nextTick(function () {
396
- return _this6.$emit('remove', index);
485
+ return _this5.$emit('remove', index);
397
486
  });
398
487
  }
399
488
  },
@@ -411,7 +500,6 @@ var Group = defineComponent({
411
500
  }
412
501
 
413
502
  this.removeRule(key, true);
414
- this.subForm();
415
503
  this.modelValue.splice(index, 1);
416
504
  this.input(this.modelValue);
417
505
  },
@@ -423,18 +511,18 @@ var Group = defineComponent({
423
511
  }, null);
424
512
  },
425
513
  delIcon: function delIcon(index, key) {
426
- var _this7 = this;
514
+ var _this6 = this;
427
515
 
428
516
  return createVNode(script$1, {
429
517
  "key": "d".concat(key),
430
518
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
431
519
  "onClick": function onClick() {
432
- return _this7.del(index, key);
520
+ return _this6.del(index, key);
433
521
  }
434
522
  }, null);
435
523
  },
436
524
  makeIcon: function makeIcon(total, index, key) {
437
- var _this8 = this;
525
+ var _this7 = this;
438
526
 
439
527
  if (this.$slots.button) {
440
528
  return this.$slots.button({
@@ -443,7 +531,7 @@ var Group = defineComponent({
443
531
  vm: this,
444
532
  key: key,
445
533
  del: function del() {
446
- return _this8.del(index, key);
534
+ return _this7.del(index, key);
447
535
  },
448
536
  add: this.add
449
537
  });
@@ -478,7 +566,7 @@ var Group = defineComponent({
478
566
  }
479
567
  },
480
568
  render: function render() {
481
- var _this9 = this;
569
+ var _this8 = this;
482
570
 
483
571
  var keys = Object.keys(this.cacheRule);
484
572
  var button = this.button;
@@ -495,9 +583,9 @@ var Group = defineComponent({
495
583
  }, [keys.map(function (key, index) {
496
584
  var _slot;
497
585
 
498
- var _this9$cacheRule$key = _this9.cacheRule[key],
499
- rule = _this9$cacheRule$key.rule,
500
- options = _this9$cacheRule$key.options;
586
+ var _this8$cacheRule$key = _this8.cacheRule[key],
587
+ rule = _this8$cacheRule$key.rule,
588
+ options = _this8$cacheRule$key.options;
501
589
  return createVNode(resolveComponent("aRow"), {
502
590
  "align": "middle",
503
591
  "type": "flex",
@@ -511,19 +599,20 @@ var Group = defineComponent({
511
599
  "default": function _default() {
512
600
  return [createVNode(Type, {
513
601
  "key": key,
602
+ "inFor": true,
514
603
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
515
- return _this9.formData(key, formData);
604
+ return _this8.formData(key, formData);
516
605
  },
517
- "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
606
+ "modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
518
607
  "onEmit-event": function onEmitEvent(name) {
519
608
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
520
609
  args[_key - 1] = arguments[_key];
521
610
  }
522
611
 
523
- return _this9.emitEvent(name, args, index, key);
612
+ return _this8.emitEvent(name, args, index, key);
524
613
  },
525
614
  "onUpdate:api": function onUpdateApi($f) {
526
- return _this9.add$f(index, key, $f);
615
+ return _this8.add$f(index, key, $f);
527
616
  },
528
617
  "rule": rule,
529
618
  "option": options,
@@ -534,7 +623,7 @@ var Group = defineComponent({
534
623
  "span": 2,
535
624
  "pull": 1,
536
625
  "push": 1
537
- }, _isSlot(_slot = _this9.makeIcon(keys.length, index, key)) ? _slot : {
626
+ }, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
538
627
  "default": function _default() {
539
628
  return [_slot];
540
629
  }
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.1.2
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{openBlock as e,createElementBlock as t,createElementVNode as n,defineComponent as r,markRaw as o,nextTick as i,createVNode as l,resolveComponent as u,isVNode as a}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 m(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 m(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 m(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 m(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 p={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&&!p.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){p[e]=function(t){return p.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,u){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)];g.render=function(n,r,o,i,l,u){return e(),t("span",O,j)};var w=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[]}},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 u=0;u<o;u++)this.removeRule(n[r-u-1]);this.subForm()}e.forEach((function(r,o){t.setValue(n[o],e[o])}))}},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,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};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.subForm(),i((function(){r.syncDisabled&&n.disabled(r.disabled),r.$emit("itemMounted",n,Object.keys(r.cacheRule).indexOf(t))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},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.subForm(),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(u("aRow"),{align:"middle",type:"flex",key:o,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[l(u("aCol"),{span:n?20:24},{default:function(){return[l(r,{key:o,"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(u("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)&&!a(s)?c:{default:function(){return[c]}})):null];var s}})}))])}});export{w as default};
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
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', 'Function', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
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
  };
@@ -191,6 +210,78 @@
191
210
 
192
211
  script.render = render;
193
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
+
194
285
  function _isSlot(s) {
195
286
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
196
287
  }
@@ -221,6 +312,7 @@
221
312
  return [];
222
313
  }
223
314
  },
315
+ defaultValue: Object,
224
316
  disabled: {
225
317
  type: Boolean,
226
318
  "default": false
@@ -290,8 +382,6 @@
290
382
  for (var _i2 = 0; _i2 < len; _i2++) {
291
383
  this.removeRule(keys[total - _i2 - 1]);
292
384
  }
293
-
294
- this.subForm();
295
385
  }
296
386
 
297
387
  n.forEach(function (val, i) {
@@ -299,8 +389,7 @@
299
389
  });
300
390
  }
301
391
  },
302
- deep: true,
303
- flush: 'post'
392
+ deep: true
304
393
  }
305
394
  },
306
395
  methods: {
@@ -357,6 +446,13 @@
357
446
  submitBtn: false,
358
447
  resetBtn: false
359
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
+
360
456
  this.cacheRule[++this.len] = {
361
457
  rule: rule,
362
458
  options: options
@@ -372,7 +468,7 @@
372
468
  var _this4 = this;
373
469
 
374
470
  this.cacheRule[key].$f = $f;
375
- this.subForm();
471
+ this.formData(key, $f.formData());
376
472
  vue.nextTick(function () {
377
473
  if (_this4.syncDisabled) {
378
474
  $f.disabled(_this4.disabled);
@@ -381,15 +477,8 @@
381
477
  _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
382
478
  });
383
479
  },
384
- subForm: function subForm() {
385
- var _this5 = this;
386
-
387
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
388
- return _this5.cacheRule[k].$f;
389
- }));
390
- },
391
480
  removeRule: function removeRule(key, emit) {
392
- var _this6 = this;
481
+ var _this5 = this;
393
482
 
394
483
  var index = Object.keys(this.cacheRule).indexOf(key);
395
484
  delete this.cacheRule[key];
@@ -397,7 +486,7 @@
397
486
 
398
487
  if (emit) {
399
488
  vue.nextTick(function () {
400
- return _this6.$emit('remove', index);
489
+ return _this5.$emit('remove', index);
401
490
  });
402
491
  }
403
492
  },
@@ -415,7 +504,6 @@
415
504
  }
416
505
 
417
506
  this.removeRule(key, true);
418
- this.subForm();
419
507
  this.modelValue.splice(index, 1);
420
508
  this.input(this.modelValue);
421
509
  },
@@ -427,18 +515,18 @@
427
515
  }, null);
428
516
  },
429
517
  delIcon: function delIcon(index, key) {
430
- var _this7 = this;
518
+ var _this6 = this;
431
519
 
432
520
  return vue.createVNode(script$1, {
433
521
  "key": "d".concat(key),
434
522
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
435
523
  "onClick": function onClick() {
436
- return _this7.del(index, key);
524
+ return _this6.del(index, key);
437
525
  }
438
526
  }, null);
439
527
  },
440
528
  makeIcon: function makeIcon(total, index, key) {
441
- var _this8 = this;
529
+ var _this7 = this;
442
530
 
443
531
  if (this.$slots.button) {
444
532
  return this.$slots.button({
@@ -447,7 +535,7 @@
447
535
  vm: this,
448
536
  key: key,
449
537
  del: function del() {
450
- return _this8.del(index, key);
538
+ return _this7.del(index, key);
451
539
  },
452
540
  add: this.add
453
541
  });
@@ -482,7 +570,7 @@
482
570
  }
483
571
  },
484
572
  render: function render() {
485
- var _this9 = this;
573
+ var _this8 = this;
486
574
 
487
575
  var keys = Object.keys(this.cacheRule);
488
576
  var button = this.button;
@@ -499,9 +587,9 @@
499
587
  }, [keys.map(function (key, index) {
500
588
  var _slot;
501
589
 
502
- var _this9$cacheRule$key = _this9.cacheRule[key],
503
- rule = _this9$cacheRule$key.rule,
504
- options = _this9$cacheRule$key.options;
590
+ var _this8$cacheRule$key = _this8.cacheRule[key],
591
+ rule = _this8$cacheRule$key.rule,
592
+ options = _this8$cacheRule$key.options;
505
593
  return vue.createVNode(vue.resolveComponent("aRow"), {
506
594
  "align": "middle",
507
595
  "type": "flex",
@@ -515,19 +603,20 @@
515
603
  "default": function _default() {
516
604
  return [vue.createVNode(Type, {
517
605
  "key": key,
606
+ "inFor": true,
518
607
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
519
- return _this9.formData(key, formData);
608
+ return _this8.formData(key, formData);
520
609
  },
521
- "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
610
+ "modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
522
611
  "onEmit-event": function onEmitEvent(name) {
523
612
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
524
613
  args[_key - 1] = arguments[_key];
525
614
  }
526
615
 
527
- return _this9.emitEvent(name, args, index, key);
616
+ return _this8.emitEvent(name, args, index, key);
528
617
  },
529
618
  "onUpdate:api": function onUpdateApi($f) {
530
- return _this9.add$f(index, key, $f);
619
+ return _this8.add$f(index, key, $f);
531
620
  },
532
621
  "rule": rule,
533
622
  "option": options,
@@ -538,7 +627,7 @@
538
627
  "span": 2,
539
628
  "pull": 1,
540
629
  "push": 1
541
- }, _isSlot(_slot = _this9.makeIcon(keys.length, index, key)) ? _slot : {
630
+ }, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
542
631
  "default": function _default() {
543
632
  return [_slot];
544
633
  }
package/dist/index.min.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.1.2
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 c(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 c(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 c(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 c(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 u={name:"MinusCircleOutlined"},s={class:"anticon"},d=[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,o,r,i,l){return t.openBlock(),t.createElementBlock("span",s,d)};var f={name:"PlusCircleOutlined"},h={class:"anticon"},m=[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)];f.render=function(e,n,o,r,i,l){return t.openBlock(),t.createElementBlock("span",h,m)};var p=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 c=0;c<r;c++)this.removeRule(n[o-c-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(f,{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(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 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(f,{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,c){var a,u=e.cacheRule[l],s=u.rule,d=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: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[c])):e.modelValue[c],"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,c,l)},"onUpdate:api":function(t){return e.add$f(c,l,t)},rule:s,option:d,extendOption:!0},null)]}}),o?t.createVNode(t.resolveComponent("aCol"),{span:2,pull:1,push:1},(u=a=e.makeIcon(n.length,c,l),"function"==typeof u||"[object Object]"===Object.prototype.toString.call(u)&&!t.isVNode(u)?a:{default:function(){return[a]}})):null];var u}})}))])}});e.default=p,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.2",
3
+ "version": "3.1.5",
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.2"
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": "e95ebb3f256032d0a7bb64e739b721fbf58b80ff"
59
+ "gitHead": "b5de4ac94ee1ca6cc33170dc5894a4a715a7e491"
60
60
  }
package/src/component.jsx CHANGED
@@ -2,9 +2,12 @@ import {hasProperty} from '@form-create/utils/lib/type';
2
2
  import {defineComponent, markRaw, nextTick} from 'vue';
3
3
  import MinusCircleOutlined from './MinusCircleOutlined.vue';
4
4
  import PlusCircleOutlined from './PlusCircleOutlined.vue';
5
+ import {deepCopy} from '@form-create/utils/lib/deepextend';
6
+ import extend from '@form-create/utils/lib/extend';
5
7
 
6
8
  const NAME = 'fcGroup';
7
9
 
10
+
8
11
  export default defineComponent({
9
12
  name: NAME,
10
13
  props: {
@@ -28,6 +31,7 @@ export default defineComponent({
28
31
  type: Array,
29
32
  default: () => []
30
33
  },
34
+ defaultValue: Object,
31
35
  disabled: {
32
36
  type: Boolean,
33
37
  default: false
@@ -92,7 +96,6 @@ export default defineComponent({
92
96
  for (let i = 0; i < len; i++) {
93
97
  this.removeRule(keys[total - i - 1]);
94
98
  }
95
- this.subForm();
96
99
  }
97
100
  n.forEach((val, i) => {
98
101
  this.setValue(keys[i], n[i]);
@@ -100,7 +103,6 @@ export default defineComponent({
100
103
  }
101
104
  },
102
105
  deep: true,
103
- flush: 'post',
104
106
  }
105
107
  },
106
108
  methods: {
@@ -144,6 +146,11 @@ export default defineComponent({
144
146
  submitBtn: false,
145
147
  resetBtn: false,
146
148
  };
149
+ if (this.defaultValue) {
150
+ if (!options.formData) options.formData = {};
151
+ const defVal = deepCopy(this.defaultValue);
152
+ extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
153
+ }
147
154
  this.cacheRule[++this.len] = {rule, options};
148
155
  if (emit) {
149
156
  nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
@@ -151,7 +158,7 @@ export default defineComponent({
151
158
  },
152
159
  add$f(i, key, $f) {
153
160
  this.cacheRule[key].$f = $f;
154
- this.subForm();
161
+ this.formData(key, $f.formData());
155
162
  nextTick(() => {
156
163
  if (this.syncDisabled) {
157
164
  $f.disabled(this.disabled);
@@ -159,9 +166,6 @@ export default defineComponent({
159
166
  this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
160
167
  });
161
168
  },
162
- subForm() {
163
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(k => this.cacheRule[k].$f));
164
- },
165
169
  removeRule(key, emit) {
166
170
  const index = Object.keys(this.cacheRule).indexOf(key);
167
171
  delete this.cacheRule[key];
@@ -182,7 +186,6 @@ export default defineComponent({
182
186
  return;
183
187
  }
184
188
  this.removeRule(key, true);
185
- this.subForm();
186
189
  this.modelValue.splice(index, 1);
187
190
  this.input(this.modelValue);
188
191
  },
@@ -248,7 +251,7 @@ export default defineComponent({
248
251
  return <aRow align="middle" type="flex" key={key}
249
252
  style="border-bottom:1px dashed #DCDFE6;margin-bottom:10px;">
250
253
  <aCol span={button ? 20 : 24}><Type
251
- key={key}
254
+ key={key} inFor={true}
252
255
  onUpdate:modelValue={(formData) => this.formData(key, formData)}
253
256
  modelValue={this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index]}
254
257
  onEmit-event={(name, ...args) => this.emitEvent(name, args, index, key)}