@form-create/component-antdv-group 3.1.0 → 3.1.3
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 +162 -6
- package/dist/index.esm.min.js +2 -2
- package/dist/index.js +161 -5
- 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 +11 -0
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.3
|
|
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
|
|
@@ -297,6 +445,13 @@ var Group = defineComponent({
|
|
|
297
445
|
submitBtn: false,
|
|
298
446
|
resetBtn: false
|
|
299
447
|
};
|
|
448
|
+
|
|
449
|
+
if (this.defaultValue) {
|
|
450
|
+
if (!options.formData) options.formData = {};
|
|
451
|
+
var defVal = deepCopy(this.defaultValue);
|
|
452
|
+
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
453
|
+
}
|
|
454
|
+
|
|
300
455
|
this.cacheRule[++this.len] = {
|
|
301
456
|
rule: rule,
|
|
302
457
|
options: options
|
|
@@ -313,6 +468,7 @@ var Group = defineComponent({
|
|
|
313
468
|
|
|
314
469
|
this.cacheRule[key].$f = $f;
|
|
315
470
|
this.subForm();
|
|
471
|
+
this.formData(key, $f.formData());
|
|
316
472
|
nextTick(function () {
|
|
317
473
|
if (_this4.syncDisabled) {
|
|
318
474
|
$f.disabled(_this4.disabled);
|
|
@@ -360,7 +516,7 @@ var Group = defineComponent({
|
|
|
360
516
|
this.input(this.modelValue);
|
|
361
517
|
},
|
|
362
518
|
addIcon: function addIcon(key) {
|
|
363
|
-
return createVNode(
|
|
519
|
+
return createVNode(script, {
|
|
364
520
|
"key": "a".concat(key),
|
|
365
521
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
|
|
366
522
|
"onClick": this.add
|
|
@@ -369,7 +525,7 @@ var Group = defineComponent({
|
|
|
369
525
|
delIcon: function delIcon(index, key) {
|
|
370
526
|
var _this7 = this;
|
|
371
527
|
|
|
372
|
-
return createVNode(
|
|
528
|
+
return createVNode(script$1, {
|
|
373
529
|
"key": "d".concat(key),
|
|
374
530
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
|
|
375
531
|
"onClick": function onClick() {
|
|
@@ -430,7 +586,7 @@ var Group = defineComponent({
|
|
|
430
586
|
return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
|
|
431
587
|
vm: this,
|
|
432
588
|
add: this.add
|
|
433
|
-
}) : createVNode(
|
|
589
|
+
}) : createVNode(script, {
|
|
434
590
|
"key": 1,
|
|
435
591
|
"style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
|
|
436
592
|
"onClick": this.add
|
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.3
|
|
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 as e,markRaw as t,nextTick as n,createVNode as o,resolveComponent as r,isVNode as i}from"vue";function l(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 u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e){return a="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},a(e)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){return function(e){if(Array.isArray(e))return f(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 f(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 f(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 f(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 d={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===a(e)&&null!==e&&1===e.nodeType&&!d.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){d[e]=function(t){return d.type(t,e)}}));var h=e({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(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,o=this.cacheRule,r=Object.keys(o);if(r.filter((function(e){return o[e].$f})).length===r.length){var i=r.map((function(o){var r=e===o?t:u({},n.cacheRule[o].$f.form),i=n.field?r[n.field]||null:r;return n.cache(o,i),i}));this.input(i)}},setValue:function(e,t){var n=this.field;n&&(t=c({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,t){var o=this,r=this.formCreateInject.form.copyRules(this.rule||[]),i=this.options?u({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:r,options:i},t&&n((function(){return o.$emit("add",r,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,t,o){var r=this;this.cacheRule[t].$f=o,this.subForm(),n((function(){r.syncDisabled&&o.disabled(r.disabled),r.$emit("itemMounted",o,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 o=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],t&&n((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 o(r("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,t){var n=this;return o(r("MinusCircleOutlined"),{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 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(s(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,t=Object.keys(this.cacheRule),n=this.button,l=this.form;return 0===t.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):o(r("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):o("div",{key:2},[t.map((function(u,a){var s,f=e.cacheRule[u],d=f.rule,h=f.options;return o(r("aRow"),{align:"middle",type:"flex",key:u,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[o(r("aCol"),{span:n?20:24},{default:function(){return[o(l,{key:u,"onUpdate:modelValue":function(t){return e.formData(u,t)},modelValue:e.field?c({},e.field,e._value(e.modelValue[a])):e.modelValue[a],"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,a,u)},"onUpdate:api":function(t){return e.add$f(a,u,t)},rule:d,option:h,extendOption:!0},null)]}}),n?o(r("aCol"),{span:2,pull:1,push:1},(f=s=e.makeIcon(t.length,a,u),"function"==typeof f||"[object Object]"===Object.prototype.toString.call(f)&&!i(f)?s:{default:function(){return[s]}})):null];var f}})}))])}});export{h 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 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},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){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,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))||p.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),p.Undef(i)||(p.Undef(i.__json)||(e[o].__json=i.__json),p.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]);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};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.subForm(),this.formData(t,n.formData()),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(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,"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.3
|
|
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
|
|
@@ -301,6 +449,13 @@
|
|
|
301
449
|
submitBtn: false,
|
|
302
450
|
resetBtn: false
|
|
303
451
|
};
|
|
452
|
+
|
|
453
|
+
if (this.defaultValue) {
|
|
454
|
+
if (!options.formData) options.formData = {};
|
|
455
|
+
var defVal = deepCopy(this.defaultValue);
|
|
456
|
+
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
457
|
+
}
|
|
458
|
+
|
|
304
459
|
this.cacheRule[++this.len] = {
|
|
305
460
|
rule: rule,
|
|
306
461
|
options: options
|
|
@@ -317,6 +472,7 @@
|
|
|
317
472
|
|
|
318
473
|
this.cacheRule[key].$f = $f;
|
|
319
474
|
this.subForm();
|
|
475
|
+
this.formData(key, $f.formData());
|
|
320
476
|
vue.nextTick(function () {
|
|
321
477
|
if (_this4.syncDisabled) {
|
|
322
478
|
$f.disabled(_this4.disabled);
|
|
@@ -364,7 +520,7 @@
|
|
|
364
520
|
this.input(this.modelValue);
|
|
365
521
|
},
|
|
366
522
|
addIcon: function addIcon(key) {
|
|
367
|
-
return vue.createVNode(
|
|
523
|
+
return vue.createVNode(script, {
|
|
368
524
|
"key": "a".concat(key),
|
|
369
525
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
|
|
370
526
|
"onClick": this.add
|
|
@@ -373,7 +529,7 @@
|
|
|
373
529
|
delIcon: function delIcon(index, key) {
|
|
374
530
|
var _this7 = this;
|
|
375
531
|
|
|
376
|
-
return vue.createVNode(
|
|
532
|
+
return vue.createVNode(script$1, {
|
|
377
533
|
"key": "d".concat(key),
|
|
378
534
|
"style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
|
|
379
535
|
"onClick": function onClick() {
|
|
@@ -434,7 +590,7 @@
|
|
|
434
590
|
return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
|
|
435
591
|
vm: this,
|
|
436
592
|
add: this.add
|
|
437
|
-
}) : vue.createVNode(
|
|
593
|
+
}) : vue.createVNode(script, {
|
|
438
594
|
"key": 1,
|
|
439
595
|
"style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
|
|
440
596
|
"onClick": this.add
|
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.3
|
|
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"},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)];function p(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&&p(e,o,[]);else if(i._clone&&void 0!==n){if(!n){p(e,o,i._clone());continue}i=i.getRule(),l&&p(e,o,{})}else l&&p(e,o,{});e[o]=y(e[o],i,n)}else p(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 b(e){return y({},{value:e}).value}d.render=function(e,n,r,o,i,l){return t.openBlock(),t.createElementBlock("span",h,m)};var v=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)&&p(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]);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,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=b(this.defaultValue);!function(){v.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.subForm(),this.formData(n,r.formData()),t.nextTick((function(){o.syncDisabled&&r.disabled(o.disabled),o.$emit("itemMounted",r,Object.keys(o.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 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.subForm(),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,"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.3",
|
|
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": "7188700dc7590edc798b756d6d4d353b9b004512"
|
|
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
|
|
@@ -142,6 +147,11 @@ export default defineComponent({
|
|
|
142
147
|
submitBtn: false,
|
|
143
148
|
resetBtn: false,
|
|
144
149
|
};
|
|
150
|
+
if (this.defaultValue) {
|
|
151
|
+
if (!options.formData) options.formData = {};
|
|
152
|
+
const defVal = deepCopy(this.defaultValue);
|
|
153
|
+
extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
|
|
154
|
+
}
|
|
145
155
|
this.cacheRule[++this.len] = {rule, options};
|
|
146
156
|
if (emit) {
|
|
147
157
|
nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
|
|
@@ -150,6 +160,7 @@ export default defineComponent({
|
|
|
150
160
|
add$f(i, key, $f) {
|
|
151
161
|
this.cacheRule[key].$f = $f;
|
|
152
162
|
this.subForm();
|
|
163
|
+
this.formData(key, $f.formData());
|
|
153
164
|
nextTick(() => {
|
|
154
165
|
if (this.syncDisabled) {
|
|
155
166
|
$f.disabled(this.disabled);
|