@panpanzhao/component-ui 0.0.13 → 0.0.14
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/lib/component-ui.common.js +146 -486
- package/lib/components/formula.js +7 -348
- package/lib/components/table-column.js +5 -346
- package/lib/components/table-editable.js +11 -352
- package/package.json +1 -1
|
@@ -95,350 +95,9 @@ module.exports = require("@vue/babel-helper-vue-jsx-merge-props");
|
|
|
95
95
|
/***/ }),
|
|
96
96
|
|
|
97
97
|
/***/ 20:
|
|
98
|
-
/***/ (function(module,
|
|
99
|
-
|
|
100
|
-
"use strict";
|
|
101
|
-
|
|
102
|
-
// EXPORTS
|
|
103
|
-
__webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ uuid; });
|
|
104
|
-
__webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ eachTree; });
|
|
105
|
-
__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ findTree; });
|
|
106
|
-
__webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ findTreeIndex; });
|
|
107
|
-
__webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ spliceTreeSelf; });
|
|
108
|
-
|
|
109
|
-
// UNUSED EXPORTS: mapTree, getTree, filterTree, everyTree, someTree, spliceTree, getTreeDepth, getTreeAncestors, getTreeParent
|
|
110
|
-
|
|
111
|
-
// CONCATENATED MODULE: ./src/utils/helper.js
|
|
112
|
-
// 参考 https://github.com/streamich/v4-uuid
|
|
113
|
-
var str = function str() {
|
|
114
|
-
return ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
|
|
115
|
-
};
|
|
116
|
-
var uuid = function uuid() {
|
|
117
|
-
var a = str();
|
|
118
|
-
var b = str();
|
|
119
|
-
return a.slice(0, 8) + '-' + a.slice(8, 12) + '-4' + a.slice(13) + '-a' + b.slice(1, 4) + '-' + b.slice(4);
|
|
120
|
-
};
|
|
121
|
-
// CONCATENATED MODULE: ./src/utils/tree.js
|
|
122
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
123
|
-
/**
|
|
124
|
-
* 类似于 arr.map 方法,此方法主要针对类似下面示例的树形结构。
|
|
125
|
-
* [
|
|
126
|
-
* {
|
|
127
|
-
* children: []
|
|
128
|
-
* },
|
|
129
|
-
* // 其他成员
|
|
130
|
-
* ]
|
|
131
|
-
*
|
|
132
|
-
* @param {Tree} tree 树形数据
|
|
133
|
-
* @param {Function} iterator 处理函数,返回的数据会被替换成新的。
|
|
134
|
-
* @return {Tree} 返回处理过的 tree
|
|
135
|
-
*/
|
|
136
|
-
function mapTree(tree, iterator, level, depthFirst, paths) {
|
|
137
|
-
if (level === void 0) {
|
|
138
|
-
level = 1;
|
|
139
|
-
}
|
|
140
|
-
if (depthFirst === void 0) {
|
|
141
|
-
depthFirst = false;
|
|
142
|
-
}
|
|
143
|
-
if (paths === void 0) {
|
|
144
|
-
paths = [];
|
|
145
|
-
}
|
|
146
|
-
return tree.map(function (item, index) {
|
|
147
|
-
if (depthFirst) {
|
|
148
|
-
var children = item.children ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item)) : undefined;
|
|
149
|
-
children && (item = _extends({}, item, {
|
|
150
|
-
children: children
|
|
151
|
-
}));
|
|
152
|
-
item = iterator(item, index, level, paths) || _extends({}, item);
|
|
153
|
-
return item;
|
|
154
|
-
}
|
|
155
|
-
item = iterator(item, index, level, paths) || _extends({}, item);
|
|
156
|
-
if (item.children && item.children.splice) {
|
|
157
|
-
item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
|
|
158
|
-
}
|
|
159
|
-
return item;
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* 遍历树
|
|
165
|
-
* @param tree
|
|
166
|
-
* @param iterator
|
|
167
|
-
*/
|
|
168
|
-
function eachTree(tree, iterator, level, paths) {
|
|
169
|
-
if (level === void 0) {
|
|
170
|
-
level = 1;
|
|
171
|
-
}
|
|
172
|
-
if (paths === void 0) {
|
|
173
|
-
paths = [];
|
|
174
|
-
}
|
|
175
|
-
tree.map(function (item, index) {
|
|
176
|
-
var currentPath = paths.concat(item);
|
|
177
|
-
iterator(item, index, level, currentPath);
|
|
178
|
-
if (item.children && item.children.splice) {
|
|
179
|
-
eachTree(item.children, iterator, level + 1, currentPath);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 在树中查找节点。
|
|
185
|
-
* @param tree
|
|
186
|
-
* @param iterator
|
|
187
|
-
*/
|
|
188
|
-
function findTree(tree, iterator) {
|
|
189
|
-
var result = null;
|
|
190
|
-
everyTree(tree, function (item, key, level, paths) {
|
|
191
|
-
if (iterator(item, key, level, paths)) {
|
|
192
|
-
result = item;
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
return true;
|
|
196
|
-
});
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 在树中查找节点, 返回下标数组。
|
|
202
|
-
* @param tree
|
|
203
|
-
* @param iterator
|
|
204
|
-
*/
|
|
205
|
-
function findTreeIndex(tree, iterator) {
|
|
206
|
-
var idx = [];
|
|
207
|
-
findTree(tree, function (item, index, level, paths) {
|
|
208
|
-
if (iterator(item, index, level, paths)) {
|
|
209
|
-
idx = [index];
|
|
210
|
-
paths = paths.concat();
|
|
211
|
-
paths.unshift({
|
|
212
|
-
children: tree
|
|
213
|
-
});
|
|
214
|
-
for (var i = paths.length - 1; i > 0; i--) {
|
|
215
|
-
var prev = paths[i - 1];
|
|
216
|
-
var current = paths[i];
|
|
217
|
-
idx.unshift(prev.children && prev.children.indexOf(current));
|
|
218
|
-
}
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
});
|
|
223
|
-
return idx.length ? idx : undefined;
|
|
224
|
-
}
|
|
225
|
-
function getTree(tree, idx) {
|
|
226
|
-
var indexes = Array.isArray(idx) ? idx.concat() : [idx];
|
|
227
|
-
var lastIndex = indexes.pop();
|
|
228
|
-
var list = tree;
|
|
229
|
-
for (var i = 0, len = indexes.length; i < len; i++) {
|
|
230
|
-
var index = indexes[i];
|
|
231
|
-
if (!list || !list[index]) {
|
|
232
|
-
list = null;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
list = list[index].children;
|
|
236
|
-
}
|
|
237
|
-
return list ? list[lastIndex] : undefined;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* 过滤树节点
|
|
241
|
-
*
|
|
242
|
-
* @param tree
|
|
243
|
-
* @param iterator
|
|
244
|
-
*/
|
|
245
|
-
function filterTree(tree, iterator, level, depthFirst) {
|
|
246
|
-
if (level === void 0) {
|
|
247
|
-
level = 1;
|
|
248
|
-
}
|
|
249
|
-
if (depthFirst === void 0) {
|
|
250
|
-
depthFirst = false;
|
|
251
|
-
}
|
|
252
|
-
if (depthFirst) {
|
|
253
|
-
return tree.map(function (item) {
|
|
254
|
-
var children = item.children ? filterTree(item.children, iterator, level + 1, depthFirst) : undefined;
|
|
255
|
-
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
256
|
-
item = _extends({}, item, {
|
|
257
|
-
children: children
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
return item;
|
|
261
|
-
}).filter(function (item, index) {
|
|
262
|
-
return iterator(item, index, level);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
return tree.filter(function (item, index) {
|
|
266
|
-
return iterator(item, index, level);
|
|
267
|
-
}).map(function (item) {
|
|
268
|
-
if (item.children && item.children.splice) {
|
|
269
|
-
var children = filterTree(item.children, iterator, level + 1, depthFirst);
|
|
270
|
-
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
271
|
-
item = _extends({}, item, {
|
|
272
|
-
children: children
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return item;
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* 判断树中每个节点是否满足某个条件。
|
|
282
|
-
* @param tree
|
|
283
|
-
* @param iterator
|
|
284
|
-
*/
|
|
285
|
-
function everyTree(tree, iterator, level, paths, indexes) {
|
|
286
|
-
if (level === void 0) {
|
|
287
|
-
level = 1;
|
|
288
|
-
}
|
|
289
|
-
if (paths === void 0) {
|
|
290
|
-
paths = [];
|
|
291
|
-
}
|
|
292
|
-
if (indexes === void 0) {
|
|
293
|
-
indexes = [];
|
|
294
|
-
}
|
|
295
|
-
if (!Array.isArray(tree)) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
return tree.every(function (item, index) {
|
|
299
|
-
var value = iterator(item, index, level, paths, indexes);
|
|
300
|
-
if (value && item.children && item.children.splice) {
|
|
301
|
-
return everyTree(item.children, iterator, level + 1, paths.concat(item), indexes.concat(index));
|
|
302
|
-
}
|
|
303
|
-
return value;
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* 判断树中是否有某些节点满足某个条件。
|
|
309
|
-
* @param tree
|
|
310
|
-
* @param iterator
|
|
311
|
-
*/
|
|
312
|
-
function someTree(tree, iterator) {
|
|
313
|
-
var result = false;
|
|
314
|
-
everyTree(tree, function (item, key, level, paths) {
|
|
315
|
-
if (iterator(item, key, level, paths)) {
|
|
316
|
-
result = true;
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
320
|
-
});
|
|
321
|
-
return result;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* 操作树,遵循 imutable, 每次返回一个新的树。
|
|
326
|
-
* 类似数组的 splice 不同的地方这个方法不修改原始数据,
|
|
327
|
-
* 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
|
|
328
|
-
*
|
|
329
|
-
* 至于如何获取下标数组,请查看 findTreeIndex
|
|
330
|
-
*
|
|
331
|
-
* @param tree
|
|
332
|
-
* @param idx
|
|
333
|
-
* @param deleteCount
|
|
334
|
-
* @param ...items
|
|
335
|
-
*/
|
|
336
|
-
function spliceTree(tree, idx, deleteCount) {
|
|
337
|
-
if (deleteCount === void 0) {
|
|
338
|
-
deleteCount = 0;
|
|
339
|
-
}
|
|
340
|
-
var list = tree.concat();
|
|
341
|
-
for (var _len = arguments.length, items = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
342
|
-
items[_key - 3] = arguments[_key];
|
|
343
|
-
}
|
|
344
|
-
if (typeof idx === 'number') {
|
|
345
|
-
list.splice.apply(list, [idx, deleteCount].concat(items));
|
|
346
|
-
} else if (Array.isArray(idx) && idx.length) {
|
|
347
|
-
idx = idx.concat();
|
|
348
|
-
var lastIdx = idx.pop();
|
|
349
|
-
var host = idx.reduce(function (list, idx) {
|
|
350
|
-
var child = _extends({}, list[idx], {
|
|
351
|
-
children: list[idx].children ? list[idx].children.concat() : []
|
|
352
|
-
});
|
|
353
|
-
list[idx] = child;
|
|
354
|
-
return child.children;
|
|
355
|
-
}, list);
|
|
356
|
-
host.splice.apply(host, [lastIdx, deleteCount].concat(items));
|
|
357
|
-
}
|
|
358
|
-
return list;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* 计算树的深度
|
|
363
|
-
* @param tree
|
|
364
|
-
*/
|
|
365
|
-
function getTreeDepth(tree) {
|
|
366
|
-
return Math.max.apply(Math, tree.map(function (item) {
|
|
367
|
-
if (Array.isArray(item.children)) {
|
|
368
|
-
return 1 + getTreeDepth(item.children);
|
|
369
|
-
}
|
|
370
|
-
return 1;
|
|
371
|
-
}));
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* 从树中获取某个值的所有祖先
|
|
376
|
-
* @param tree
|
|
377
|
-
* @param value
|
|
378
|
-
*/
|
|
379
|
-
function getTreeAncestors(tree, value, includeSelf) {
|
|
380
|
-
if (includeSelf === void 0) {
|
|
381
|
-
includeSelf = false;
|
|
382
|
-
}
|
|
383
|
-
var ancestors = null;
|
|
384
|
-
findTree(tree, function (item, index, level, paths) {
|
|
385
|
-
if (item === value) {
|
|
386
|
-
ancestors = paths;
|
|
387
|
-
if (includeSelf) {
|
|
388
|
-
ancestors.push(item);
|
|
389
|
-
}
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
return false;
|
|
393
|
-
});
|
|
394
|
-
return ancestors;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* 从树中获取某个值的上级
|
|
399
|
-
* @param tree
|
|
400
|
-
* @param value
|
|
401
|
-
*/
|
|
402
|
-
function getTreeParent(tree, value) {
|
|
403
|
-
var ancestors = getTreeAncestors(tree, value);
|
|
404
|
-
return ancestors && ancestors.length ? ancestors[ancestors.length - 1] : null;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* 操作树,修车原来的树, 返回修改后的树。
|
|
409
|
-
* 类似数组的 splice 修改原始数据,
|
|
410
|
-
* 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。
|
|
411
|
-
*
|
|
412
|
-
* 至于如何获取下标数组,请查看 findTreeIndex
|
|
413
|
-
*
|
|
414
|
-
* @param tree
|
|
415
|
-
* @param idx
|
|
416
|
-
* @param deleteCount
|
|
417
|
-
* @param ...items
|
|
418
|
-
*/
|
|
419
|
-
function spliceTreeSelf(tree, idx, deleteCount) {
|
|
420
|
-
if (deleteCount === void 0) {
|
|
421
|
-
deleteCount = 0;
|
|
422
|
-
}
|
|
423
|
-
var list = tree;
|
|
424
|
-
for (var _len2 = arguments.length, items = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
|
|
425
|
-
items[_key2 - 3] = arguments[_key2];
|
|
426
|
-
}
|
|
427
|
-
if (typeof idx === 'number') {
|
|
428
|
-
list.splice.apply(list, [idx, deleteCount].concat(items));
|
|
429
|
-
} else if (Array.isArray(idx) && idx.length) {
|
|
430
|
-
idx = idx.concat();
|
|
431
|
-
var lastIdx = idx.pop();
|
|
432
|
-
var host = idx.reduce(function (list, idx) {
|
|
433
|
-
return list[idx] && list[idx].children || [];
|
|
434
|
-
}, list);
|
|
435
|
-
host.splice.apply(host, [lastIdx, deleteCount].concat(items));
|
|
436
|
-
}
|
|
437
|
-
return list;
|
|
438
|
-
}
|
|
439
|
-
// CONCATENATED MODULE: ./src/utils/index.js
|
|
440
|
-
|
|
98
|
+
/***/ (function(module, exports) {
|
|
441
99
|
|
|
100
|
+
module.exports = require("@panpanzhao/component-ui/lib/utils/index");
|
|
442
101
|
|
|
443
102
|
/***/ }),
|
|
444
103
|
|
|
@@ -797,8 +456,8 @@ var tree_default = /*#__PURE__*/__webpack_require__.n(tree_);
|
|
|
797
456
|
var badge_ = __webpack_require__(63);
|
|
798
457
|
var badge_default = /*#__PURE__*/__webpack_require__.n(badge_);
|
|
799
458
|
|
|
800
|
-
// EXTERNAL MODULE:
|
|
801
|
-
var
|
|
459
|
+
// EXTERNAL MODULE: external "@panpanzhao/component-ui/lib/utils/index"
|
|
460
|
+
var index_ = __webpack_require__(20);
|
|
802
461
|
|
|
803
462
|
// CONCATENATED MODULE: ./src/components/formula/src/variableList.js
|
|
804
463
|
|
|
@@ -849,7 +508,7 @@ var utils = __webpack_require__(20);
|
|
|
849
508
|
methods: {
|
|
850
509
|
handleSearch: function handleSearch(val) {
|
|
851
510
|
this.searchVal = val;
|
|
852
|
-
var filtered = Object(
|
|
511
|
+
var filtered = Object(index_["findTree"])(this.data, function (i) {
|
|
853
512
|
return ~i.label.indexOf(val);
|
|
854
513
|
});
|
|
855
514
|
this.filterVars = !val ? this.data : filtered ? [filtered] : [];
|
|
@@ -1153,7 +812,7 @@ var plugin_FormulaPlugin = /*#__PURE__*/function () {
|
|
|
1153
812
|
return;
|
|
1154
813
|
}
|
|
1155
814
|
var varMap = {};
|
|
1156
|
-
Object(
|
|
815
|
+
Object(index_["eachTree"])(variables, function (item) {
|
|
1157
816
|
if (item.value) {
|
|
1158
817
|
varMap[item.value] = item.label;
|
|
1159
818
|
}
|
|
@@ -2945,7 +2604,7 @@ var formula_ = __webpack_require__(3);
|
|
|
2945
2604
|
return;
|
|
2946
2605
|
}
|
|
2947
2606
|
var varMap = {};
|
|
2948
|
-
Object(
|
|
2607
|
+
Object(index_["eachTree"])(variables, function (item) {
|
|
2949
2608
|
if (item.value) {
|
|
2950
2609
|
var key = item.value;
|
|
2951
2610
|
varMap[key] = item.label;
|