@form-create/component-elm-group 3.2.34 → 3.3.0-alpha.0
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 +284 -636
- package/dist/index.js +7 -776
- package/dist/index.min.js +7 -4
- package/package.json +52 -48
- package/src/component.jsx +14 -12
- package/dist/index.esm.min.js +0 -7
package/dist/index.js
CHANGED
|
@@ -1,779 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* FormCreate 低代码表单渲染器
|
|
3
|
+
* @form-create/component-elm-group v3.3.0
|
|
4
|
+
* (c) 2018-2026 xaboy
|
|
5
|
+
* Github https://github.com/xaboy/form-create
|
|
6
|
+
* Site https://form-create.com/
|
|
5
7
|
* Released under the MIT License.
|
|
6
8
|
*/
|
|
7
|
-
(function (
|
|
8
|
-
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FcGroup = {}, global.Vue));
|
|
11
|
-
})(this, (function (exports, vue) { 'use strict';
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) {
|
|
14
|
-
var keys = Object.keys(object);
|
|
15
|
-
|
|
16
|
-
if (Object.getOwnPropertySymbols) {
|
|
17
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
-
|
|
19
|
-
if (enumerableOnly) {
|
|
20
|
-
symbols = symbols.filter(function (sym) {
|
|
21
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
keys.push.apply(keys, symbols);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return keys;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _objectSpread2(target) {
|
|
32
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
33
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
34
|
-
|
|
35
|
-
if (i % 2) {
|
|
36
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
37
|
-
_defineProperty(target, key, source[key]);
|
|
38
|
-
});
|
|
39
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
40
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
41
|
-
} else {
|
|
42
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
43
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return target;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _typeof(obj) {
|
|
52
|
-
"@babel/helpers - typeof";
|
|
53
|
-
|
|
54
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
55
|
-
_typeof = function (obj) {
|
|
56
|
-
return typeof obj;
|
|
57
|
-
};
|
|
58
|
-
} else {
|
|
59
|
-
_typeof = function (obj) {
|
|
60
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return _typeof(obj);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _defineProperty(obj, key, value) {
|
|
68
|
-
if (key in obj) {
|
|
69
|
-
Object.defineProperty(obj, key, {
|
|
70
|
-
value: value,
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
obj[key] = value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return obj;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function _toConsumableArray(arr) {
|
|
83
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _arrayWithoutHoles(arr) {
|
|
87
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _iterableToArray(iter) {
|
|
91
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
95
|
-
if (!o) return;
|
|
96
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
97
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
98
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
99
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
100
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _arrayLikeToArray(arr, len) {
|
|
104
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
105
|
-
|
|
106
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
107
|
-
|
|
108
|
-
return arr2;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _nonIterableSpread() {
|
|
112
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
var is = {
|
|
116
|
-
type: function type(arg, _type) {
|
|
117
|
-
return Object.prototype.toString.call(arg) === '[object ' + _type + ']';
|
|
118
|
-
},
|
|
119
|
-
Undef: function Undef(v) {
|
|
120
|
-
return v === undefined || v === null;
|
|
121
|
-
},
|
|
122
|
-
Element: function Element(arg) {
|
|
123
|
-
return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !is.Object(arg);
|
|
124
|
-
},
|
|
125
|
-
trueArray: function trueArray(data) {
|
|
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;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
|
|
149
|
-
is[t] = function (arg) {
|
|
150
|
-
return is.type(arg, t);
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
function hasProperty(rule, k) {
|
|
154
|
-
return {}.hasOwnProperty.call(rule, k);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function $set(target, field, value) {
|
|
158
|
-
target[field] = value;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function deepExtend(origin) {
|
|
162
|
-
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
163
|
-
var mode = arguments.length > 2 ? arguments[2] : undefined;
|
|
164
|
-
var isArr = false;
|
|
165
|
-
|
|
166
|
-
for (var key in target) {
|
|
167
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
168
|
-
var clone = target[key];
|
|
169
|
-
|
|
170
|
-
if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
|
|
171
|
-
var nst = origin[key] === undefined;
|
|
172
|
-
|
|
173
|
-
if (isArr) {
|
|
174
|
-
isArr = false;
|
|
175
|
-
nst && $set(origin, key, []);
|
|
176
|
-
} else if (clone._clone && mode !== undefined) {
|
|
177
|
-
if (mode) {
|
|
178
|
-
clone = clone.getRule();
|
|
179
|
-
nst && $set(origin, key, {});
|
|
180
|
-
} else {
|
|
181
|
-
$set(origin, key, clone._clone());
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
nst && $set(origin, key, {});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
origin[key] = deepExtend(origin[key], clone, mode);
|
|
189
|
-
} else {
|
|
190
|
-
$set(origin, key, clone);
|
|
191
|
-
|
|
192
|
-
if (!is.Undef(clone)) {
|
|
193
|
-
if (!is.Undef(clone.__json)) {
|
|
194
|
-
origin[key].__json = clone.__json;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!is.Undef(clone.__origin)) {
|
|
198
|
-
origin[key].__origin = clone.__origin;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
|
|
206
|
-
return !v || !v.__ctrl;
|
|
207
|
-
}) : origin;
|
|
208
|
-
}
|
|
209
|
-
function deepCopy(value) {
|
|
210
|
-
return deepExtend({}, {
|
|
211
|
-
value: value
|
|
212
|
-
}).value;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var _extends = Object.assign || function (a) {
|
|
216
|
-
for (var b, c = 1; c < arguments.length; c++) {
|
|
217
|
-
for (var d in b = arguments[c], b) {
|
|
218
|
-
Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return a;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
function extend() {
|
|
226
|
-
return _extends.apply(this, arguments);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function styleInject(css, ref) {
|
|
230
|
-
if ( ref === void 0 ) ref = {};
|
|
231
|
-
var insertAt = ref.insertAt;
|
|
232
|
-
|
|
233
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
234
|
-
|
|
235
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
236
|
-
var style = document.createElement('style');
|
|
237
|
-
style.type = 'text/css';
|
|
238
|
-
|
|
239
|
-
if (insertAt === 'top') {
|
|
240
|
-
if (head.firstChild) {
|
|
241
|
-
head.insertBefore(style, head.firstChild);
|
|
242
|
-
} else {
|
|
243
|
-
head.appendChild(style);
|
|
244
|
-
}
|
|
245
|
-
} else {
|
|
246
|
-
head.appendChild(style);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (style.styleSheet) {
|
|
250
|
-
style.styleSheet.cssText = css;
|
|
251
|
-
} else {
|
|
252
|
-
style.appendChild(document.createTextNode(css));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
var css_248z = "._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:\"\";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:\"\";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}._fc-group._fc-group-card{display:flex;flex-direction:column;gap:16px;width:100%}._fc-group._fc-group-card._fc-group-disabled ._fc-group-add,._fc-group._fc-group-card._fc-group-disabled ._fc-group-btn{cursor:not-allowed;opacity:.5}._fc-group._fc-group-card ._fc-group-container{background:#fff;border:1px solid #f0f0f0;border-radius:6px;display:flex;flex-direction:column;margin:0;overflow:hidden;padding:0;position:relative}._fc-group._fc-group-card ._fc-group-header{align-items:center;background:#fafafa;border-bottom:1px solid #f0f0f0;display:flex;justify-content:space-between;padding:16px 20px 12px}._fc-group._fc-group-card ._fc-group-idx{align-items:center;background:#f0f0f0;border:1px solid #e0e0e0;border-radius:6px;color:#666;display:flex;flex-shrink:0;font-size:12px;font-weight:500;height:24px;justify-content:center;margin-right:12px;position:static;width:24px}._fc-group._fc-group-card ._fc-group-title{color:rgba(0,0,0,.85);flex:1;font-size:14px;font-weight:500;line-height:1.5715}._fc-group._fc-group-card ._fc-group-handle{align-items:center;background-color:transparent;border:none;border-radius:0;bottom:auto;display:flex;flex-direction:row;flex-shrink:0;gap:4px;margin-left:12px;padding:0;position:static;right:auto}._fc-group._fc-group-card ._fc-group-btn{align-items:center;background:#fff;border:1px solid #d9d9d9;border-radius:4px;color:rgba(0,0,0,.45);cursor:pointer;display:flex;height:24px;justify-content:center;position:relative;width:24px}._fc-group._fc-group-card ._fc-group-btn:hover{background:#f0f8ff;border-color:#1890ff;color:#1890ff}._fc-group._fc-group-card ._fc-group-btn:active{border-color:#096dd9;color:#096dd9}._fc-group._fc-group-card ._fc-group-arrow{position:relative}._fc-group._fc-group-card ._fc-group-arrow:before{border-left:1px solid;border-top:1px solid;content:\"\";height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%) rotate(45deg);width:5px}._fc-group._fc-group-card ._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group._fc-group-card ._fc-group-sort{align-items:center;display:flex;flex-direction:column;height:24px;justify-content:center;position:relative}._fc-group._fc-group-card ._fc-group-sort:after,._fc-group._fc-group-card ._fc-group-sort:before{border-left:1px solid;border-top:1px solid;content:\"\";height:4px;left:50%;position:absolute;transform:translateX(-50%);width:4px}._fc-group._fc-group-card ._fc-group-sort:before{top:6px;transform:translateX(-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-sort:after{bottom:6px;transform:translateX(-50%) rotate(225deg)}._fc-group._fc-group-card ._fc-group-sort-down,._fc-group._fc-group-card ._fc-group-sort-up{cursor:pointer;height:12px;left:0;position:absolute;right:0;z-index:1}._fc-group._fc-group-card ._fc-group-sort-up{top:0}._fc-group._fc-group-card ._fc-group-sort-down{bottom:0}._fc-group._fc-group-card ._fc-group-sort-down:hover,._fc-group._fc-group-card ._fc-group-sort-up:hover{background:rgba(24,144,255,.1)}._fc-group._fc-group-card ._fc-group-plus-minus{background:#409eff;border-color:#409eff;color:#fff;height:24px;position:relative;width:24px}._fc-group._fc-group-card ._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-plus-minus:after,._fc-group._fc-group-card ._fc-group-plus-minus:before{background-color:currentColor;content:\"\";height:1px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:8px}._fc-group._fc-group-card ._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus{background:#f56c6c;border-color:#f56c6c}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:hover{background:#f78989;border-color:#f78989}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group._fc-group-card ._fc-group-content{padding:20px}._fc-group._fc-group-card ._fc-group-add{align-items:center;background:#fff;border:1px solid #d9d9d9;border-radius:4px;color:rgba(0,0,0,.45);cursor:pointer;display:flex;height:24px;justify-content:center;position:relative;width:24px}._fc-group._fc-group-card ._fc-group-add:hover{background:#f0f8ff;border-color:#409eff;color:#409eff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus{background:#409eff;border-color:#409eff;color:#fff;height:24px;width:24px}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:after,._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before{background-color:currentColor;content:\"\";height:1px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:8px}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-empty{color:rgba(0,0,0,.45);font-size:14px;padding:40px 20px;text-align:center}@media (max-width:768px){._fc-group._fc-group-card ._fc-group-container{border-left:none;border-radius:0;border-right:none;margin:0 -8px}._fc-group._fc-group-card ._fc-group-header{padding:12px 16px 8px}._fc-group._fc-group-card ._fc-group-content{padding:16px}._fc-group._fc-group-card ._fc-group-handle{gap:2px}._fc-group._fc-group-card ._fc-group-btn{height:22px;width:22px}}";
|
|
257
|
-
styleInject(css_248z);
|
|
258
|
-
|
|
259
|
-
function isPromise(value) {
|
|
260
|
-
return value && _typeof(value) === 'object' && typeof value.then === 'function';
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function toPromise(value) {
|
|
264
|
-
if (isPromise(value)) {
|
|
265
|
-
return value;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return Promise.resolve(value);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
var NAME = 'fcGroup';
|
|
272
|
-
var Group = vue.defineComponent({
|
|
273
|
-
name: NAME,
|
|
274
|
-
props: {
|
|
275
|
-
field: String,
|
|
276
|
-
rule: Array,
|
|
277
|
-
expand: Number,
|
|
278
|
-
options: Object,
|
|
279
|
-
button: {
|
|
280
|
-
type: Boolean,
|
|
281
|
-
"default": true
|
|
282
|
-
},
|
|
283
|
-
max: {
|
|
284
|
-
type: Number,
|
|
285
|
-
"default": 0
|
|
286
|
-
},
|
|
287
|
-
min: {
|
|
288
|
-
type: Number,
|
|
289
|
-
"default": 0
|
|
290
|
-
},
|
|
291
|
-
modelValue: {
|
|
292
|
-
type: Array,
|
|
293
|
-
"default": function _default() {
|
|
294
|
-
return [];
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
defaultValue: Object,
|
|
298
|
-
sortBtn: {
|
|
299
|
-
type: Boolean,
|
|
300
|
-
"default": true
|
|
301
|
-
},
|
|
302
|
-
disabled: {
|
|
303
|
-
type: Boolean,
|
|
304
|
-
"default": false
|
|
305
|
-
},
|
|
306
|
-
syncDisabled: {
|
|
307
|
-
type: Boolean,
|
|
308
|
-
"default": true
|
|
309
|
-
},
|
|
310
|
-
title: {
|
|
311
|
-
type: [String, Function],
|
|
312
|
-
"default": null
|
|
313
|
-
},
|
|
314
|
-
type: {
|
|
315
|
-
type: String,
|
|
316
|
-
"default": 'default'
|
|
317
|
-
},
|
|
318
|
-
onBeforeRemove: {
|
|
319
|
-
type: Function,
|
|
320
|
-
"default": function _default() {}
|
|
321
|
-
},
|
|
322
|
-
onBeforeAdd: {
|
|
323
|
-
type: Function,
|
|
324
|
-
"default": function _default() {}
|
|
325
|
-
},
|
|
326
|
-
formCreateInject: Object,
|
|
327
|
-
parse: Function
|
|
328
|
-
},
|
|
329
|
-
data: function data() {
|
|
330
|
-
return {
|
|
331
|
-
len: 0,
|
|
332
|
-
cacheRule: {},
|
|
333
|
-
cacheValue: {},
|
|
334
|
-
sort: [],
|
|
335
|
-
form: vue.markRaw(this.formCreateInject.form.$form())
|
|
336
|
-
};
|
|
337
|
-
},
|
|
338
|
-
emits: ['update:modelValue', 'change', 'itemMounted', 'remove', 'add'],
|
|
339
|
-
watch: {
|
|
340
|
-
rule: {
|
|
341
|
-
handler: function handler(n, o) {
|
|
342
|
-
var _this = this;
|
|
343
|
-
|
|
344
|
-
Object.keys(this.cacheRule).forEach(function (v) {
|
|
345
|
-
var item = _this.cacheRule[v];
|
|
346
|
-
|
|
347
|
-
if (item.$f) {
|
|
348
|
-
var val = item.$f.formData();
|
|
349
|
-
|
|
350
|
-
if (n === o) {
|
|
351
|
-
item.$f.deferSyncValue(function () {
|
|
352
|
-
deepExtend(item.rule, n);
|
|
353
|
-
item.$f.setValue(val);
|
|
354
|
-
}, true);
|
|
355
|
-
} else {
|
|
356
|
-
var _val = item.$f.formData();
|
|
357
|
-
|
|
358
|
-
item.$f.once('reloading', function () {
|
|
359
|
-
item.$f.setValue(_val);
|
|
360
|
-
});
|
|
361
|
-
item.rule = deepCopy(n);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
},
|
|
366
|
-
deep: true
|
|
367
|
-
},
|
|
368
|
-
expand: function expand(n) {
|
|
369
|
-
var d = n - this.modelValue.length;
|
|
370
|
-
|
|
371
|
-
if (d > 0) {
|
|
372
|
-
this.expandRule(d);
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
modelValue: {
|
|
376
|
-
handler: function handler(n) {
|
|
377
|
-
var _this2 = this;
|
|
378
|
-
|
|
379
|
-
n = n || [];
|
|
380
|
-
var keys = this.sort,
|
|
381
|
-
total = keys.length,
|
|
382
|
-
len = total - n.length;
|
|
383
|
-
|
|
384
|
-
if (len < 0) {
|
|
385
|
-
for (var i = len; i < 0; i++) {
|
|
386
|
-
this.addRule(n.length + i, true);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
for (var _i = 0; _i < total; _i++) {
|
|
390
|
-
this.setValue(keys[_i], n[_i]);
|
|
391
|
-
}
|
|
392
|
-
} else {
|
|
393
|
-
if (len > 0) {
|
|
394
|
-
for (var _i2 = 0; _i2 < len; _i2++) {
|
|
395
|
-
this.removeRule(keys[total - _i2 - 1]);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
n.forEach(function (val, i) {
|
|
400
|
-
_this2.setValue(keys[i], n[i]);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
deep: true
|
|
405
|
-
}
|
|
406
|
-
},
|
|
407
|
-
methods: {
|
|
408
|
-
_value: function _value(v) {
|
|
409
|
-
return v && hasProperty(v, this.field) ? v[this.field] : v;
|
|
410
|
-
},
|
|
411
|
-
cache: function cache(k, val) {
|
|
412
|
-
this.cacheValue[k] = JSON.stringify(val);
|
|
413
|
-
},
|
|
414
|
-
input: function input(value) {
|
|
415
|
-
this.$emit('update:modelValue', value);
|
|
416
|
-
this.$emit('change', value);
|
|
417
|
-
},
|
|
418
|
-
formData: function formData(key, _formData) {
|
|
419
|
-
var _this3 = this;
|
|
420
|
-
|
|
421
|
-
var cacheRule = this.cacheRule;
|
|
422
|
-
var keys = this.sort;
|
|
423
|
-
|
|
424
|
-
if (keys.filter(function (k) {
|
|
425
|
-
return cacheRule[k] && cacheRule[k].$f;
|
|
426
|
-
}).length !== keys.length) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
var value = keys.map(function (k) {
|
|
431
|
-
var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
|
|
432
|
-
var value = _this3.field ? data[_this3.field] || null : data;
|
|
433
|
-
|
|
434
|
-
_this3.cache(k, value);
|
|
435
|
-
|
|
436
|
-
return value;
|
|
437
|
-
});
|
|
438
|
-
this.input(value);
|
|
439
|
-
},
|
|
440
|
-
setValue: function setValue(key, value) {
|
|
441
|
-
var field = this.field;
|
|
442
|
-
|
|
443
|
-
if (field) {
|
|
444
|
-
value = _defineProperty({}, field, this._value(value));
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
this.cacheRule[key].$f && this.cacheRule[key].$f.coverValue(value);
|
|
452
|
-
this.cache(key, value);
|
|
453
|
-
},
|
|
454
|
-
addRule: function addRule(i, emit) {
|
|
455
|
-
var _this4 = this;
|
|
456
|
-
|
|
457
|
-
var rule = this.formCreateInject.form.copyRules(this.rule || []);
|
|
458
|
-
var options = this.options ? _objectSpread2({}, this.options) : {
|
|
459
|
-
submitBtn: false,
|
|
460
|
-
resetBtn: false
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
if (this.defaultValue) {
|
|
464
|
-
if (!options.formData) options.formData = {};
|
|
465
|
-
var defVal = deepCopy(this.defaultValue);
|
|
466
|
-
extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
this.parse && this.parse({
|
|
470
|
-
rule: rule,
|
|
471
|
-
options: options,
|
|
472
|
-
index: this.sort.length
|
|
473
|
-
});
|
|
474
|
-
this.cacheRule[++this.len] = {
|
|
475
|
-
rule: rule,
|
|
476
|
-
options: options
|
|
477
|
-
};
|
|
478
|
-
this.sort = Object.keys(this.cacheRule);
|
|
479
|
-
|
|
480
|
-
if (emit) {
|
|
481
|
-
vue.nextTick(function () {
|
|
482
|
-
return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
add$f: function add$f(i, key, $f) {
|
|
487
|
-
var _this5 = this;
|
|
488
|
-
|
|
489
|
-
this.cacheRule[key].$f = $f;
|
|
490
|
-
vue.nextTick(function () {
|
|
491
|
-
_this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
|
|
492
|
-
});
|
|
493
|
-
},
|
|
494
|
-
removeRule: function removeRule(key, emit) {
|
|
495
|
-
var _this6 = this;
|
|
496
|
-
|
|
497
|
-
var index = Object.keys(this.cacheRule).indexOf(key);
|
|
498
|
-
delete this.cacheRule[key];
|
|
499
|
-
delete this.cacheValue[key];
|
|
500
|
-
this.sort = Object.keys(this.cacheRule);
|
|
501
|
-
|
|
502
|
-
if (emit) {
|
|
503
|
-
vue.nextTick(function () {
|
|
504
|
-
return _this6.$emit('remove', index);
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
},
|
|
508
|
-
add: function add(i) {
|
|
509
|
-
if (this.disabled || false === this.onBeforeAdd(this.modelValue)) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
var value = _toConsumableArray(this.modelValue);
|
|
514
|
-
|
|
515
|
-
value.push(this.defaultValue ? deepCopy(this.defaultValue) : this.field ? null : {});
|
|
516
|
-
this.input(value);
|
|
517
|
-
},
|
|
518
|
-
del: function del(index, key) {
|
|
519
|
-
var _this7 = this;
|
|
520
|
-
|
|
521
|
-
if (this.disabled) {
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
var del = function del() {
|
|
526
|
-
_this7.removeRule(key, true);
|
|
527
|
-
|
|
528
|
-
var value = _toConsumableArray(_this7.modelValue);
|
|
529
|
-
|
|
530
|
-
value.splice(index, 1);
|
|
531
|
-
|
|
532
|
-
_this7.input(value);
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
toPromise(this.onBeforeRemove(this.modelValue, index)).then(function (res) {
|
|
536
|
-
if (false !== res) {
|
|
537
|
-
del();
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
},
|
|
541
|
-
addIcon: function addIcon(key) {
|
|
542
|
-
return vue.createVNode("div", {
|
|
543
|
-
"class": "_fc-group-btn _fc-group-plus-minus",
|
|
544
|
-
"onClick": this.add
|
|
545
|
-
}, null);
|
|
546
|
-
},
|
|
547
|
-
delIcon: function delIcon(index, key) {
|
|
548
|
-
var _this8 = this;
|
|
549
|
-
|
|
550
|
-
return vue.createVNode("div", {
|
|
551
|
-
"class": "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
|
|
552
|
-
"onClick": function onClick() {
|
|
553
|
-
return _this8.del(index, key);
|
|
554
|
-
}
|
|
555
|
-
}, null);
|
|
556
|
-
},
|
|
557
|
-
sortUpIcon: function sortUpIcon(index) {
|
|
558
|
-
var _this9 = this;
|
|
559
|
-
|
|
560
|
-
return vue.createVNode("div", {
|
|
561
|
-
"class": "_fc-group-btn _fc-group-arrow _fc-group-up",
|
|
562
|
-
"onClick": function onClick() {
|
|
563
|
-
return _this9.changeSort(index, -1);
|
|
564
|
-
}
|
|
565
|
-
}, null);
|
|
566
|
-
},
|
|
567
|
-
sortDownIcon: function sortDownIcon(index) {
|
|
568
|
-
var _this10 = this;
|
|
569
|
-
|
|
570
|
-
return vue.createVNode("div", {
|
|
571
|
-
"class": "_fc-group-btn _fc-group-arrow _fc-group-down",
|
|
572
|
-
"onClick": function onClick() {
|
|
573
|
-
return _this10.changeSort(index, 1);
|
|
574
|
-
}
|
|
575
|
-
}, null);
|
|
576
|
-
},
|
|
577
|
-
changeSort: function changeSort(index, sort) {
|
|
578
|
-
var _this11 = this;
|
|
579
|
-
|
|
580
|
-
var a = this.sort[index];
|
|
581
|
-
this.sort[index] = this.sort[index + sort];
|
|
582
|
-
this.sort[index + sort] = a;
|
|
583
|
-
this.formCreateInject.subForm(this.sort.map(function (k) {
|
|
584
|
-
return _this11.cacheRule[k].$f;
|
|
585
|
-
}));
|
|
586
|
-
this.formData(0);
|
|
587
|
-
},
|
|
588
|
-
sortIcon: function sortIcon(index, total) {
|
|
589
|
-
var _this12 = this;
|
|
590
|
-
|
|
591
|
-
var canMoveUp = index > 0;
|
|
592
|
-
var canMoveDown = index < total - 1;
|
|
593
|
-
|
|
594
|
-
if (!canMoveUp && !canMoveDown) {
|
|
595
|
-
return null;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
if (canMoveUp && canMoveDown) {
|
|
599
|
-
// 显示合并的上下箭头按钮
|
|
600
|
-
return vue.createVNode("div", {
|
|
601
|
-
"class": "_fc-group-btn _fc-group-sort"
|
|
602
|
-
}, [vue.createVNode("div", {
|
|
603
|
-
"class": "_fc-group-sort-up",
|
|
604
|
-
"onClick": function onClick() {
|
|
605
|
-
return _this12.changeSort(index, -1);
|
|
606
|
-
}
|
|
607
|
-
}, null), vue.createVNode("div", {
|
|
608
|
-
"class": "_fc-group-sort-down",
|
|
609
|
-
"onClick": function onClick() {
|
|
610
|
-
return _this12.changeSort(index, 1);
|
|
611
|
-
}
|
|
612
|
-
}, null)]);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
if (canMoveUp) {
|
|
616
|
-
return this.sortUpIcon(index);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
if (canMoveDown) {
|
|
620
|
-
return this.sortDownIcon(index);
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
makeIcon: function makeIcon(total, index, key) {
|
|
624
|
-
var _this13 = this;
|
|
625
|
-
|
|
626
|
-
if (this.$slots.button) {
|
|
627
|
-
return this.$slots.button({
|
|
628
|
-
total: total,
|
|
629
|
-
index: index,
|
|
630
|
-
vm: this,
|
|
631
|
-
key: key,
|
|
632
|
-
del: function del() {
|
|
633
|
-
return _this13.del(index, key);
|
|
634
|
-
},
|
|
635
|
-
add: this.add
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
var btn = [];
|
|
640
|
-
|
|
641
|
-
if ((!this.max || total < this.max) && total === index + 1) {
|
|
642
|
-
btn.push(this.addIcon(key));
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
if (total > this.min) {
|
|
646
|
-
btn.push(this.delIcon(index, key));
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
if (this.sortBtn) {
|
|
650
|
-
var sortBtn = this.sortIcon(index, total);
|
|
651
|
-
|
|
652
|
-
if (sortBtn) {
|
|
653
|
-
btn.push(sortBtn);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
return btn;
|
|
658
|
-
},
|
|
659
|
-
expandRule: function expandRule(n) {
|
|
660
|
-
for (var i = 0; i < n; i++) {
|
|
661
|
-
this.modelValue.push(this.field ? null : {});
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
this.input(_toConsumableArray(this.modelValue));
|
|
665
|
-
},
|
|
666
|
-
getTitle: function getTitle(index, key) {
|
|
667
|
-
if (typeof this.title === 'function') {
|
|
668
|
-
return this.title(index, this.modelValue[index], key);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (typeof this.title === 'string') {
|
|
672
|
-
return this.title.replace('{index}', index + 1);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
return false;
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
created: function created() {
|
|
679
|
-
var d = (this.expand || 0) - this.modelValue.length;
|
|
680
|
-
|
|
681
|
-
for (var i = 0; i < this.modelValue.length; i++) {
|
|
682
|
-
this.addRule(i);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
if (d > 0) {
|
|
686
|
-
this.expandRule(d);
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
|
-
render: function render() {
|
|
690
|
-
var _this14 = this;
|
|
691
|
-
|
|
692
|
-
var keys = this.sort;
|
|
693
|
-
var button = this.button;
|
|
694
|
-
var Type = this.form;
|
|
695
|
-
var disabled = this.disabled;
|
|
696
|
-
var isCardType = this.type === 'card';
|
|
697
|
-
var children = keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
|
|
698
|
-
vm: this,
|
|
699
|
-
add: this.add
|
|
700
|
-
}) : vue.createVNode("div", {
|
|
701
|
-
"key": 'a_def',
|
|
702
|
-
"class": "_fc-group-plus-minus _fc-group-add fc-clock",
|
|
703
|
-
"onClick": this.add
|
|
704
|
-
}, null) : keys.map(function (key, index) {
|
|
705
|
-
var _this14$cacheRule$key = _this14.cacheRule[key],
|
|
706
|
-
rule = _this14$cacheRule$key.rule,
|
|
707
|
-
options = _this14$cacheRule$key.options;
|
|
708
|
-
var btn = button && !disabled ? _this14.makeIcon(keys.length, index, key) : [];
|
|
709
|
-
|
|
710
|
-
var title = _this14.getTitle(index, key);
|
|
711
|
-
|
|
712
|
-
if (isCardType) {
|
|
713
|
-
return vue.createVNode("div", {
|
|
714
|
-
"class": "_fc-group-container",
|
|
715
|
-
"key": key
|
|
716
|
-
}, [vue.createVNode("div", {
|
|
717
|
-
"class": "_fc-group-header"
|
|
718
|
-
}, [title === false ? vue.createVNode("div", {
|
|
719
|
-
"class": "_fc-group-idx"
|
|
720
|
-
}, [index + 1]) : null, title !== false ? vue.createVNode("div", {
|
|
721
|
-
"class": "_fc-group-title"
|
|
722
|
-
}, [title]) : null, vue.createVNode("div", {
|
|
723
|
-
"class": "_fc-group-handle fc-clock"
|
|
724
|
-
}, [btn.length ? btn : null])]), vue.createVNode("div", {
|
|
725
|
-
"class": "_fc-group-content"
|
|
726
|
-
}, [vue.createVNode(Type, vue.mergeProps({
|
|
727
|
-
"key": key
|
|
728
|
-
}, _objectSpread2(_objectSpread2({}, _this14.$attrs), {}, {
|
|
729
|
-
disabled: disabled,
|
|
730
|
-
'onUpdate:modelValue': function onUpdateModelValue(formData) {
|
|
731
|
-
return _this14.formData(key, formData);
|
|
732
|
-
},
|
|
733
|
-
'onUpdate:api': function onUpdateApi($f) {
|
|
734
|
-
return _this14.add$f(index, key, $f);
|
|
735
|
-
},
|
|
736
|
-
inFor: true,
|
|
737
|
-
modelValue: _this14.field ? _defineProperty({}, _this14.field, _this14._value(_this14.modelValue[index])) : _this14.modelValue[index],
|
|
738
|
-
rule: rule,
|
|
739
|
-
option: options,
|
|
740
|
-
extendOption: true
|
|
741
|
-
})), null)])]);
|
|
742
|
-
} else {
|
|
743
|
-
return vue.createVNode("div", {
|
|
744
|
-
"class": "_fc-group-container",
|
|
745
|
-
"key": key
|
|
746
|
-
}, [vue.createVNode(Type, vue.mergeProps({
|
|
747
|
-
"key": key
|
|
748
|
-
}, _objectSpread2(_objectSpread2({}, _this14.$attrs), {}, {
|
|
749
|
-
disabled: disabled,
|
|
750
|
-
'onUpdate:modelValue': function onUpdateModelValue(formData) {
|
|
751
|
-
return _this14.formData(key, formData);
|
|
752
|
-
},
|
|
753
|
-
'onUpdate:api': function onUpdateApi($f) {
|
|
754
|
-
return _this14.add$f(index, key, $f);
|
|
755
|
-
},
|
|
756
|
-
inFor: true,
|
|
757
|
-
modelValue: _this14.field ? _defineProperty({}, _this14.field, _this14._value(_this14.modelValue[index])) : _this14.modelValue[index],
|
|
758
|
-
rule: rule,
|
|
759
|
-
option: options,
|
|
760
|
-
extendOption: true
|
|
761
|
-
})), null), vue.createVNode("div", {
|
|
762
|
-
"class": "_fc-group-idx"
|
|
763
|
-
}, [index + 1]), btn.length ? vue.createVNode("div", {
|
|
764
|
-
"class": "_fc-group-handle fc-clock"
|
|
765
|
-
}, [btn]) : null]);
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
return vue.createVNode("div", {
|
|
769
|
-
"key": 'con',
|
|
770
|
-
"class": '_fc-group ' + (disabled ? '_fc-group-disabled' : '') + (isCardType ? ' _fc-group-card' : '')
|
|
771
|
-
}, [children]);
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
exports["default"] = Group;
|
|
776
|
-
|
|
777
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
778
|
-
|
|
779
|
-
}));
|
|
9
|
+
(function(){"use strict";try{if(typeof document!="undefined"){var r=document.createElement("style");r.appendChild(document.createTextNode('._fc-group{display:flex;min-height:38px;justify-content:center;flex-direction:column;width:100%}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;border-radius:5px;margin:5px 5px 25px;padding:20px 20px 25px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}._fc-group._fc-group-card{display:flex;flex-direction:column;width:100%;gap:16px}._fc-group._fc-group-card._fc-group-disabled ._fc-group-btn,._fc-group._fc-group-card._fc-group-disabled ._fc-group-add{cursor:not-allowed;opacity:.5}._fc-group._fc-group-card ._fc-group-container{position:relative;background:#fff;border:1px solid #f0f0f0;border-radius:6px;overflow:hidden;display:flex;flex-direction:column;padding:0;margin:0}._fc-group._fc-group-card ._fc-group-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px 12px;border-bottom:1px solid #f0f0f0;background:#fafafa}._fc-group._fc-group-card ._fc-group-idx{display:flex;align-items:center;justify-content:center;width:24px;height:24px;background:#f0f0f0;color:#666;border-radius:6px;font-size:12px;font-weight:500;margin-right:12px;flex-shrink:0;position:static;border:1px solid #e0e0e0}._fc-group._fc-group-card ._fc-group-title{flex:1;font-size:14px;font-weight:500;color:#000000d9;line-height:1.5715}._fc-group._fc-group-card ._fc-group-handle{display:flex;align-items:center;gap:4px;margin-left:12px;flex-shrink:0;position:static;bottom:auto;right:auto;border-radius:0;border:none;padding:0;background-color:transparent;flex-direction:row}._fc-group._fc-group-card ._fc-group-btn{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-btn:hover{color:#1890ff;border-color:#1890ff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-btn:active{color:#096dd9;border-color:#096dd9}._fc-group._fc-group-card ._fc-group-arrow{position:relative}._fc-group._fc-group-card ._fc-group-arrow:before{content:"";position:absolute;top:50%;left:50%;width:5px;height:5px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%,-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group._fc-group-card ._fc-group-sort{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:24px}._fc-group._fc-group-card ._fc-group-sort:before,._fc-group._fc-group-card ._fc-group-sort:after{content:"";position:absolute;left:50%;width:4px;height:4px;border-left:1px solid currentColor;border-top:1px solid currentColor;transform:translate(-50%)}._fc-group._fc-group-card ._fc-group-sort:before{top:6px;transform:translate(-50%) rotate(45deg)}._fc-group._fc-group-card ._fc-group-sort:after{bottom:6px;transform:translate(-50%) rotate(225deg)}._fc-group._fc-group-card ._fc-group-sort-up,._fc-group._fc-group-card ._fc-group-sort-down{position:absolute;left:0;right:0;height:12px;cursor:pointer;z-index:1}._fc-group._fc-group-card ._fc-group-sort-up{top:0}._fc-group._fc-group-card ._fc-group-sort-down{bottom:0}._fc-group._fc-group-card ._fc-group-sort-up:hover,._fc-group._fc-group-card ._fc-group-sort-down:hover{background:#1890ff1a}._fc-group._fc-group-card ._fc-group-plus-minus{position:relative;background:#409eff;border-color:#409eff;color:#fff;width:24px;height:24px}._fc-group._fc-group-card ._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus{background:#f56c6c;border-color:#f56c6c}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:hover{background:#f78989;border-color:#f78989}._fc-group._fc-group-card ._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group._fc-group-card ._fc-group-content{padding:20px}._fc-group._fc-group-card ._fc-group-add{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;color:#00000073;position:relative}._fc-group._fc-group-card ._fc-group-add:hover{color:#409eff;border-color:#409eff;background:#f0f8ff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus{width:24px;height:24px;background:#409eff;border-color:#409eff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:hover{background:#66b1ff;border-color:#66b1ff;color:#fff}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before,._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:8px;height:1px;background-color:currentColor;transform:translate(-50%,-50%)}._fc-group._fc-group-card ._fc-group-add._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group._fc-group-card ._fc-group-empty{text-align:center;padding:40px 20px;color:#00000073;font-size:14px}@media (max-width: 768px){._fc-group._fc-group-card ._fc-group-container{margin:0 -8px;border-radius:0;border-left:none;border-right:none}._fc-group._fc-group-card ._fc-group-header{padding:12px 16px 8px}._fc-group._fc-group-card ._fc-group-content{padding:16px}._fc-group._fc-group-card ._fc-group-handle{gap:2px}._fc-group._fc-group-card ._fc-group-btn{width:22px;height:22px}}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
10
|
+
(function(i,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n(require("vue")):typeof define=="function"&&define.amd?define(["vue"],n):(i=typeof globalThis!="undefined"?globalThis:i||self,i.FcGroup=n(i.Vue))})(this,function(i){"use strict";var I=Object.defineProperty,B=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var j=(i,n,u)=>n in i?I(i,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[n]=u,f=(i,n)=>{for(var u in n||(n={}))D.call(n,u)&&j(i,u,n[u]);if(R)for(var u of R(n))S.call(n,u)&&j(i,u,n[u]);return i},y=(i,n)=>B(i,C(n));const n={type(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef(e){return e==null},Element(e){return typeof e=="object"&&e!==null&&e.nodeType===1&&!n.Object(e)},trueArray(e){return Array.isArray(e)&&e.length>0},Function(e){const t=this.getType(e);return t==="Function"||t==="AsyncFunction"},getType(e){const t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty(e){return e==null||Array.isArray(e)&&Array.isArray(e)&&!e.length?!0:typeof e=="string"&&!e}};["Date","Object","String","Boolean","Array","Number"].forEach(e=>{n[e]=function(t){return n.type(t,e)}});function u(e,t){return{}.hasOwnProperty.call(e,t)}function d(e,t,o){e[t]=o}function m(e,t={},o){let s=!1;for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let l=t[r];if((s=Array.isArray(l))||n.Object(l)){let c=e[r]===void 0;s?(s=!1,c&&d(e,r,[])):l._clone&&o!==void 0||c&&d(e,r,{}),e[r]=m(e[r],l,o)}else d(e,r,l),n.Undef(l)||(n.Undef(l.__json)||(e[r].__json=l.__json),n.Undef(l.__origin)||(e[r].__origin=l.__origin))}return o!==void 0&&Array.isArray(e)?e.filter(r=>!r||!r.__ctrl):e}function g(e){return m({},{value:e}).value}const $=Object.assign||function(e){for(let t,o=1;o<arguments.length;o++)for(let s in t=arguments[o],t)Object.prototype.hasOwnProperty.call(t,s)&&d(e,s,t[s]);return e};function N(){return $.apply(this,arguments)}function O(e){return e&&typeof e=="object"&&typeof e.then=="function"}function A(e){return O(e)?e:Promise.resolve(e)}return i.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:()=>[]},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},title:{type:[String,Function],default:null},type:{type:String,default:"default"},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},formCreateInject:Object,parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:i.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler(e,t){Object.keys(this.cacheRule).forEach(o=>{const s=this.cacheRule[o];if(s.$f){const r=s.$f.formData();if(e===t)s.$f.deferSyncValue(()=>{m(s.rule,e),s.$f.setValue(r)},!0);else{const l=s.$f.formData();s.$f.once("reloading",()=>{s.$f.setValue(l)}),s.rule=g(e)}}})},deep:!0},expand(e){let t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler(e){e=e||[];let t=this.sort,o=t.length,s=o-e.length;if(s<0){for(let r=s;r<0;r++)this.addRule(e.length+r,!0);for(let r=0;r<o;r++)this.setValue(t[r],e[r])}else{if(s>0)for(let r=0;r<s;r++)this.removeRule(t[o-r-1]);e.forEach((r,l)=>{this.setValue(t[l],e[l])})}},deep:!0}},methods:{_value(e){return e&&u(e,this.field)?e[this.field]:e},cache(e,t){this.cacheValue[e]=JSON.stringify(t)},input(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData(e,t){const o=this.cacheRule,s=this.sort;if(s.filter(l=>o[l]&&o[l].$f).length!==s.length)return;const r=s.map(l=>{const c=e===l?t:f({},this.cacheRule[l].$f.form),a=this.field?n.Undef(c[this.field])?null:c[this.field]:c;return this.cache(l,a),a});this.input(r)},setValue(e,t){const o=this.field;o&&(t={[o]:this._value(t)}),this.cacheValue[e]!==JSON.stringify(o?t[o]:t)&&(this.cacheRule[e].$f&&this.cacheRule[e].$f.coverValue(t),this.cache(e,t))},addRule(e,t){const o=this.formCreateInject.form.copyRules(this.rule||[]),s=this.options?f({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){s.formData||(s.formData={});const r=g(this.defaultValue);N(s.formData,this.field?{[this.field]:r}:r)}this.parse&&this.parse({rule:o,options:s,index:this.sort.length}),this.cacheRule[++this.len]={rule:o,options:s},this.sort=Object.keys(this.cacheRule),t&&i.nextTick(()=>this.$emit("add",o,Object.keys(this.cacheRule).length-1))},add$f(e,t,o){this.cacheRule[t].$f=o,i.nextTick(()=>{this.$emit("itemMounted",o,Object.keys(this.cacheRule).indexOf(t))})},removeRule(e,t){const o=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],this.sort=Object.keys(this.cacheRule),t&&i.nextTick(()=>this.$emit("remove",o))},add(e){if(this.disabled||this.onBeforeAdd(this.modelValue)===!1)return;const t=[...this.modelValue];t.push(this.defaultValue?g(this.defaultValue):this.field?null:{}),this.input(t)},del(e,t){if(this.disabled)return;const o=()=>{this.removeRule(t,!0);const s=[...this.modelValue];s.splice(e,1),this.input(s)};A(this.onBeforeRemove(this.modelValue,e)).then(s=>{s!==!1&&o()})},addIcon(e){return i.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon(e,t){return i.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:()=>this.del(e,t)},null)},sortUpIcon(e){return i.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:()=>this.changeSort(e,-1)},null)},sortDownIcon(e){return i.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:()=>this.changeSort(e,1)},null)},changeSort(e,t){const o=this.sort[e];this.sort[e]=this.sort[e+t],this.sort[e+t]=o,this.formCreateInject.subForm(this.sort.map(s=>this.cacheRule[s].$f)),this.formData(0)},sortIcon(e,t){const o=e>0,s=e<t-1,r=[];return!o&&!s?r:this.type==="card"&&o&&s?(r.push(i.createVNode("div",{class:"_fc-group-btn _fc-group-sort"},[i.createVNode("div",{class:" _fc-group-sort-up",onClick:()=>this.changeSort(e,-1)},null),i.createVNode("div",{class:" _fc-group-sort-down",onClick:()=>this.changeSort(e,1)},null)])),r):(o&&r.push(this.sortUpIcon(e)),s&&r.push(this.sortDownIcon(e)),r)},makeIcon(e,t,o){if(this.$slots.button)return this.$slots.button({total:e,index:t,vm:this,key:o,del:()=>this.del(t,o),add:this.add});const s=[];if((!this.max||e<this.max)&&e===t+1&&s.push(this.addIcon(o)),e>this.min&&s.push(this.delIcon(t,o)),this.sortBtn){const r=this.sortIcon(t,e);r&&s.push(...r)}return s},expandRule(e){for(let t=0;t<e;t++)this.modelValue.push(this.field?null:{});this.input([...this.modelValue])},getTitle(e,t){return typeof this.title=="function"?this.title(e,this.modelValue[e],t):typeof this.title=="string"?this.title.replace("{index}",e+1):!1}},created(){const e=(this.expand||0)-this.modelValue.length;for(let t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render(){const e=this.sort,t=this.button,o=this.form,s=this.disabled,r=this.type==="card",l=e.length===0?this.$slots.default?this.$slots.default({vm:this,add:this.add}):i.createVNode("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):e.map((c,a)=>{const{rule:_,options:b}=this.cacheRule[c],p=t&&!s?this.makeIcon(e.length,a,c):[],V=this.getTitle(a,c);return r?i.createVNode("div",{class:"_fc-group-container",key:c},[i.createVNode("div",{class:"_fc-group-header"},[V===!1?i.createVNode("div",{class:"_fc-group-idx"},[a+1]):null,V!==!1?i.createVNode("div",{class:"_fc-group-title"},[V]):null,i.createVNode("div",{class:"_fc-group-handle fc-clock"},[p.length?p:null])]),i.createVNode("div",{class:"_fc-group-content"},[i.createVNode(o,i.mergeProps({key:c},y(f({},this.$attrs),{disabled:s,"onUpdate:modelValue":h=>this.formData(c,h),"onUpdate:api":h=>this.add$f(a,c,h),inFor:!0,modelValue:this.field?{[this.field]:this._value(this.modelValue[a])}:this.modelValue[a],rule:_,option:b,extendOption:!0})),null)])]):i.createVNode("div",{class:"_fc-group-container",key:c},[i.createVNode(o,i.mergeProps({key:c},y(f({},this.$attrs),{disabled:s,"onUpdate:modelValue":h=>this.formData(c,h),"onUpdate:api":h=>this.add$f(a,c,h),inFor:!0,modelValue:this.field?{[this.field]:this._value(this.modelValue[a])}:this.modelValue[a],rule:_,option:b,extendOption:!0})),null),i.createVNode("div",{class:"_fc-group-idx"},[a+1]),p.length?i.createVNode("div",{class:"_fc-group-handle fc-clock"},[p]):null])});return i.createVNode("div",{key:"con",class:"_fc-group "+(s?"_fc-group-disabled":"")+(r?" _fc-group-card":"")},[l])}})});
|