el-crud-page 1.0.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.
@@ -0,0 +1,3615 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ElCrudPage = {}, global.Vue));
5
+ })(this, (function (exports, Vue) { 'use strict';
6
+
7
+ function ___$insertStylesToHeader(css) {
8
+ if (!css) {
9
+ return
10
+ }
11
+ if (typeof window === 'undefined') {
12
+ return
13
+ }
14
+
15
+ const style = document.createElement('style');
16
+
17
+ style.setAttribute('type', 'text/css');
18
+ style.innerHTML = css;
19
+ document.head.appendChild(style);
20
+ return css
21
+ }
22
+
23
+ function _arrayLikeToArray(r, a) {
24
+ (null == a || a > r.length) && (a = r.length);
25
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
26
+ return n;
27
+ }
28
+ function _arrayWithHoles(r) {
29
+ if (Array.isArray(r)) return r;
30
+ }
31
+ function _arrayWithoutHoles(r) {
32
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
33
+ }
34
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
35
+ try {
36
+ var i = n[a](c),
37
+ u = i.value;
38
+ } catch (n) {
39
+ return void e(n);
40
+ }
41
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
42
+ }
43
+ function _asyncToGenerator(n) {
44
+ return function () {
45
+ var t = this,
46
+ e = arguments;
47
+ return new Promise(function (r, o) {
48
+ var a = n.apply(t, e);
49
+ function _next(n) {
50
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
51
+ }
52
+ function _throw(n) {
53
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
54
+ }
55
+ _next(void 0);
56
+ });
57
+ };
58
+ }
59
+ function _defineProperty(e, r, t) {
60
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
61
+ value: t,
62
+ enumerable: !0,
63
+ configurable: !0,
64
+ writable: !0
65
+ }) : e[r] = t, e;
66
+ }
67
+ function _iterableToArray(r) {
68
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
69
+ }
70
+ function _iterableToArrayLimit(r, l) {
71
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
72
+ if (null != t) {
73
+ var e,
74
+ n,
75
+ i,
76
+ u,
77
+ a = [],
78
+ f = !0,
79
+ o = !1;
80
+ try {
81
+ if (i = (t = t.call(r)).next, 0 === l) {
82
+ if (Object(t) !== t) return;
83
+ f = !1;
84
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
85
+ } catch (r) {
86
+ o = !0, n = r;
87
+ } finally {
88
+ try {
89
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
90
+ } finally {
91
+ if (o) throw n;
92
+ }
93
+ }
94
+ return a;
95
+ }
96
+ }
97
+ function _nonIterableRest() {
98
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
99
+ }
100
+ function _nonIterableSpread() {
101
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
102
+ }
103
+ function ownKeys(e, r) {
104
+ var t = Object.keys(e);
105
+ if (Object.getOwnPropertySymbols) {
106
+ var o = Object.getOwnPropertySymbols(e);
107
+ r && (o = o.filter(function (r) {
108
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
109
+ })), t.push.apply(t, o);
110
+ }
111
+ return t;
112
+ }
113
+ function _objectSpread2(e) {
114
+ for (var r = 1; r < arguments.length; r++) {
115
+ var t = null != arguments[r] ? arguments[r] : {};
116
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
117
+ _defineProperty(e, r, t[r]);
118
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
119
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
120
+ });
121
+ }
122
+ return e;
123
+ }
124
+ function _regenerator() {
125
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
126
+ var e,
127
+ t,
128
+ r = "function" == typeof Symbol ? Symbol : {},
129
+ n = r.iterator || "@@iterator",
130
+ o = r.toStringTag || "@@toStringTag";
131
+ function i(r, n, o, i) {
132
+ var c = n && n.prototype instanceof Generator ? n : Generator,
133
+ u = Object.create(c.prototype);
134
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
135
+ var i,
136
+ c,
137
+ u,
138
+ f = 0,
139
+ p = o || [],
140
+ y = !1,
141
+ G = {
142
+ p: 0,
143
+ n: 0,
144
+ v: e,
145
+ a: d,
146
+ f: d.bind(e, 4),
147
+ d: function (t, r) {
148
+ return i = t, c = 0, u = e, G.n = r, a;
149
+ }
150
+ };
151
+ function d(r, n) {
152
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
153
+ var o,
154
+ i = p[t],
155
+ d = G.p,
156
+ l = i[2];
157
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
158
+ }
159
+ if (o || r > 1) return a;
160
+ throw y = !0, n;
161
+ }
162
+ return function (o, p, l) {
163
+ if (f > 1) throw TypeError("Generator is already running");
164
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
165
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
166
+ try {
167
+ if (f = 2, i) {
168
+ if (c || (o = "next"), t = i[o]) {
169
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
170
+ if (!t.done) return t;
171
+ u = t.value, c < 2 && (c = 0);
172
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
173
+ i = e;
174
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
175
+ } catch (t) {
176
+ i = e, c = 1, u = t;
177
+ } finally {
178
+ f = 1;
179
+ }
180
+ }
181
+ return {
182
+ value: t,
183
+ done: y
184
+ };
185
+ };
186
+ }(r, o, i), !0), u;
187
+ }
188
+ var a = {};
189
+ function Generator() {}
190
+ function GeneratorFunction() {}
191
+ function GeneratorFunctionPrototype() {}
192
+ t = Object.getPrototypeOf;
193
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
194
+ return this;
195
+ }), t),
196
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
197
+ function f(e) {
198
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
199
+ }
200
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
201
+ return this;
202
+ }), _regeneratorDefine(u, "toString", function () {
203
+ return "[object Generator]";
204
+ }), (_regenerator = function () {
205
+ return {
206
+ w: i,
207
+ m: f
208
+ };
209
+ })();
210
+ }
211
+ function _regeneratorDefine(e, r, n, t) {
212
+ var i = Object.defineProperty;
213
+ try {
214
+ i({}, "", {});
215
+ } catch (e) {
216
+ i = 0;
217
+ }
218
+ _regeneratorDefine = function (e, r, n, t) {
219
+ function o(r, n) {
220
+ _regeneratorDefine(e, r, function (e) {
221
+ return this._invoke(r, n, e);
222
+ });
223
+ }
224
+ r ? i ? i(e, r, {
225
+ value: n,
226
+ enumerable: !t,
227
+ configurable: !t,
228
+ writable: !t
229
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
230
+ }, _regeneratorDefine(e, r, n, t);
231
+ }
232
+ function _slicedToArray(r, e) {
233
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
234
+ }
235
+ function _toConsumableArray(r) {
236
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
237
+ }
238
+ function _toPrimitive(t, r) {
239
+ if ("object" != typeof t || !t) return t;
240
+ var e = t[Symbol.toPrimitive];
241
+ if (void 0 !== e) {
242
+ var i = e.call(t, r || "default");
243
+ if ("object" != typeof i) return i;
244
+ throw new TypeError("@@toPrimitive must return a primitive value.");
245
+ }
246
+ return ("string" === r ? String : Number)(t);
247
+ }
248
+ function _toPropertyKey(t) {
249
+ var i = _toPrimitive(t, "string");
250
+ return "symbol" == typeof i ? i : i + "";
251
+ }
252
+ function _typeof(o) {
253
+ "@babel/helpers - typeof";
254
+
255
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
256
+ return typeof o;
257
+ } : function (o) {
258
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
259
+ }, _typeof(o);
260
+ }
261
+ function _unsupportedIterableToArray(r, a) {
262
+ if (r) {
263
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
264
+ var t = {}.toString.call(r).slice(8, -1);
265
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
266
+ }
267
+ }
268
+
269
+ var toString = Object.prototype.toString;
270
+ function kindOf(val) {
271
+ if (val === void 0) return 'undefined';
272
+ if (val === null) return 'null';
273
+ var type = _typeof(val);
274
+ if (type === 'boolean') return 'boolean';
275
+ if (type === 'string') return 'string';
276
+ if (type === 'number') return 'number';
277
+ if (type === 'symbol') return 'symbol';
278
+ if (type === 'function') {
279
+ return isGeneratorFn(val) ? 'generatorfunction' : 'function';
280
+ }
281
+ if (isArray$1(val)) return 'array';
282
+ if (isBuffer(val)) return 'buffer';
283
+ if (isArguments(val)) return 'arguments';
284
+ if (isDate(val)) return 'date';
285
+ if (isError(val)) return 'error';
286
+ if (isRegexp(val)) return 'regexp';
287
+ switch (ctorName(val)) {
288
+ case 'Symbol':
289
+ return 'symbol';
290
+ case 'Promise':
291
+ return 'promise';
292
+
293
+ // Set, Map, WeakSet, WeakMap
294
+ case 'WeakMap':
295
+ return 'weakmap';
296
+ case 'WeakSet':
297
+ return 'weakset';
298
+ case 'Map':
299
+ return 'map';
300
+ case 'Set':
301
+ return 'set';
302
+
303
+ // 8-bit typed arrays
304
+ case 'Int8Array':
305
+ return 'int8array';
306
+ case 'Uint8Array':
307
+ return 'uint8array';
308
+ case 'Uint8ClampedArray':
309
+ return 'uint8clampedarray';
310
+
311
+ // 16-bit typed arrays
312
+ case 'Int16Array':
313
+ return 'int16array';
314
+ case 'Uint16Array':
315
+ return 'uint16array';
316
+
317
+ // 32-bit typed arrays
318
+ case 'Int32Array':
319
+ return 'int32array';
320
+ case 'Uint32Array':
321
+ return 'uint32array';
322
+ case 'Float32Array':
323
+ return 'float32array';
324
+ case 'Float64Array':
325
+ return 'float64array';
326
+ }
327
+ if (isGeneratorObj(val)) {
328
+ return 'generator';
329
+ }
330
+
331
+ // Non-plain objects
332
+ type = toString.call(val);
333
+ switch (type) {
334
+ case '[object Object]':
335
+ return 'object';
336
+ // iterators
337
+ case '[object Map Iterator]':
338
+ return 'mapiterator';
339
+ case '[object Set Iterator]':
340
+ return 'setiterator';
341
+ case '[object String Iterator]':
342
+ return 'stringiterator';
343
+ case '[object Array Iterator]':
344
+ return 'arrayiterator';
345
+ }
346
+
347
+ // other
348
+ return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
349
+ }
350
+ function ctorName(val) {
351
+ return typeof val.constructor === 'function' ? val.constructor.name : null;
352
+ }
353
+ function isArray$1(val) {
354
+ if (Array.isArray) return Array.isArray(val);
355
+ return val instanceof Array;
356
+ }
357
+ function isError(val) {
358
+ return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
359
+ }
360
+ function isDate(val) {
361
+ if (val instanceof Date) return true;
362
+ return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
363
+ }
364
+ function isRegexp(val) {
365
+ if (val instanceof RegExp) return true;
366
+ return typeof val.flags === 'string' && typeof val.ignoreCase === 'boolean' && typeof val.multiline === 'boolean' && typeof val.global === 'boolean';
367
+ }
368
+ function isGeneratorFn(name, val) {
369
+ return ctorName(name) === 'GeneratorFunction';
370
+ }
371
+ function isGeneratorObj(val) {
372
+ return typeof val["throw"] === 'function' && typeof val["return"] === 'function' && typeof val.next === 'function';
373
+ }
374
+ function isArguments(val) {
375
+ try {
376
+ if (typeof val.length === 'number' && typeof val.callee === 'function') {
377
+ return true;
378
+ }
379
+ } catch (err) {
380
+ if (err.message.indexOf('callee') !== -1) {
381
+ return true;
382
+ }
383
+ }
384
+ return false;
385
+ }
386
+
387
+ /**
388
+ * If you need to support Safari 5-7 (8-10 yr-old browser),
389
+ * take a look at https://github.com/feross/is-buffer
390
+ */
391
+
392
+ function isBuffer(val) {
393
+ if (val.constructor && typeof val.constructor.isBuffer === 'function') {
394
+ return val.constructor.isBuffer(val);
395
+ }
396
+ return false;
397
+ }
398
+
399
+ /*!
400
+ * shallow-clone <https://github.com/jonschlinkert/shallow-clone>
401
+ *
402
+ * Copyright (c) 2015-present, Jon Schlinkert.
403
+ * Released under the MIT License.
404
+ */
405
+
406
+ var valueOf = Symbol.prototype.valueOf;
407
+ function clone(val, deep) {
408
+ switch (kindOf(val)) {
409
+ case 'array':
410
+ return val.slice();
411
+ case 'object':
412
+ return Object.assign({}, val);
413
+ case 'date':
414
+ return new val.constructor(Number(val));
415
+ case 'map':
416
+ return new Map(val);
417
+ case 'set':
418
+ return new Set(val);
419
+ case 'buffer':
420
+ return cloneBuffer(val);
421
+ case 'symbol':
422
+ return cloneSymbol(val);
423
+ case 'arraybuffer':
424
+ return cloneArrayBuffer(val);
425
+ case 'float32array':
426
+ case 'float64array':
427
+ case 'int16array':
428
+ case 'int32array':
429
+ case 'int8array':
430
+ case 'uint16array':
431
+ case 'uint32array':
432
+ case 'uint8clampedarray':
433
+ case 'uint8array':
434
+ return cloneTypedArray(val);
435
+ case 'regexp':
436
+ return cloneRegExp(val);
437
+ case 'error':
438
+ return Object.create(val);
439
+ default:
440
+ {
441
+ return val;
442
+ }
443
+ }
444
+ }
445
+ function cloneRegExp(val) {
446
+ var flags = val.flags !== void 0 ? val.flags : /\w+$/.exec(val) || void 0;
447
+ var re = new val.constructor(val.source, flags);
448
+ re.lastIndex = val.lastIndex;
449
+ return re;
450
+ }
451
+ function cloneArrayBuffer(val) {
452
+ var res = new val.constructor(val.byteLength);
453
+ new Uint8Array(res).set(new Uint8Array(val));
454
+ return res;
455
+ }
456
+ function cloneTypedArray(val, deep) {
457
+ return new val.constructor(val.buffer, val.byteOffset, val.length);
458
+ }
459
+ function cloneBuffer(val) {
460
+ var len = val.length;
461
+ var buf = Buffer.allocUnsafe ? Buffer.allocUnsafe(len) : Buffer.from(len);
462
+ val.copy(buf);
463
+ return buf;
464
+ }
465
+ function cloneSymbol(val) {
466
+ return valueOf ? Object(valueOf.call(val)) : {};
467
+ }
468
+
469
+ /*!
470
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
471
+ *
472
+ * Copyright (c) 2014-2017, Jon Schlinkert.
473
+ * Released under the MIT License.
474
+ */
475
+
476
+ function isObject$1(o) {
477
+ return Object.prototype.toString.call(o) === '[object Object]';
478
+ }
479
+ function isPlainObject(o) {
480
+ var ctor, prot;
481
+ if (isObject$1(o) === false) return false;
482
+
483
+ // If has modified constructor
484
+ ctor = o.constructor;
485
+ if (ctor === undefined) return true;
486
+
487
+ // If has modified prototype
488
+ prot = ctor.prototype;
489
+ if (isObject$1(prot) === false) return false;
490
+
491
+ // If constructor does not have an Object-specific method
492
+ if (prot.hasOwnProperty('isPrototypeOf') === false) {
493
+ return false;
494
+ }
495
+
496
+ // Most likely a plain Object
497
+ return true;
498
+ }
499
+
500
+ function cloneDeep(val, instanceClone) {
501
+ switch (kindOf(val)) {
502
+ case 'object':
503
+ return cloneObjectDeep(val, instanceClone);
504
+ case 'array':
505
+ return cloneArrayDeep(val, instanceClone);
506
+ default:
507
+ {
508
+ return clone(val);
509
+ }
510
+ }
511
+ }
512
+ function cloneObjectDeep(val, instanceClone) {
513
+ if (typeof instanceClone === 'function') {
514
+ return instanceClone(val);
515
+ }
516
+ if (instanceClone || isPlainObject(val)) {
517
+ var res = val.constructor !== undefined ? new val.constructor() : Object.create(null);
518
+ for (var key in val) {
519
+ res[key] = cloneDeep(val[key], instanceClone);
520
+ }
521
+ return res;
522
+ }
523
+ return val;
524
+ }
525
+ function cloneArrayDeep(val, instanceClone) {
526
+ var res = new val.constructor(val.length);
527
+ for (var i = 0; i < val.length; i++) {
528
+ res[i] = cloneDeep(val[i], instanceClone);
529
+ }
530
+ return res;
531
+ }
532
+
533
+ Math.easeInOutQuad = function (t, b, c, d) {
534
+ t /= d / 2;
535
+ if (t < 1) {
536
+ return c / 2 * t * t + b;
537
+ }
538
+ t--;
539
+ return -c / 2 * (t * (t - 2) - 1) + b;
540
+ };
541
+
542
+ // requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
543
+ var requestAnimFrame = function () {
544
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) {
545
+ window.setTimeout(callback, 1000 / 60);
546
+ };
547
+ }();
548
+
549
+ /**
550
+ * Because it's so fucking difficult to detect the scrolling element, just move them all
551
+ * @param {number} amount
552
+ */
553
+ function move(amount) {
554
+ document.documentElement.scrollTop = amount;
555
+ document.body.parentNode.scrollTop = amount;
556
+ document.body.scrollTop = amount;
557
+ }
558
+ function position() {
559
+ return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop;
560
+ }
561
+
562
+ /**
563
+ * @param {number} to
564
+ * @param {number} duration
565
+ * @param {Function} callback
566
+ */
567
+ function scrollTo(to, duration, callback) {
568
+ var start = position();
569
+ var change = to - start;
570
+ var increment = 20;
571
+ var currentTime = 0;
572
+ duration = typeof duration === 'undefined' ? 500 : duration;
573
+ var _animateScroll = function animateScroll() {
574
+ // increment the time
575
+ currentTime += increment;
576
+ // find the value with the quadratic in-out easing function
577
+ var val = Math.easeInOutQuad(currentTime, start, change, duration);
578
+ // move the document.body
579
+ move(val);
580
+ // do the animation unless its over
581
+ if (currentTime < duration) {
582
+ requestAnimFrame(_animateScroll);
583
+ } else {
584
+ if (callback && typeof callback === 'function') {
585
+ // the animation is done so lets callback
586
+ callback();
587
+ }
588
+ }
589
+ };
590
+ _animateScroll();
591
+ }
592
+
593
+ function isArray(value) {
594
+ if (typeof Array.isArray === "function") {
595
+ return Array.isArray(value);
596
+ } else {
597
+ return Object.prototype.toString.call(value) === "[object Array]";
598
+ }
599
+ }
600
+ function isObject(value) {
601
+ return Object.prototype.toString.call(value) === "[object Object]";
602
+ }
603
+ function isFunction(value) {
604
+ return typeof value === "function";
605
+ }
606
+ function isString(value) {
607
+ return typeof value === "string";
608
+ }
609
+ function isPromise(value) {
610
+ return value && _typeof(value) === 'object' && typeof value.then === 'function' && typeof value["catch"] === 'function';
611
+ }
612
+
613
+ /**
614
+ * @param {Function} func
615
+ * @param {number} wait
616
+ * @param {boolean} immediate
617
+ * @return {*}
618
+ */
619
+ function debounce(func, wait, immediate) {
620
+ var timeout, args, context, timestamp, result;
621
+ var _later = function later() {
622
+ // 据上一次触发时间间隔
623
+ var last = +new Date() - timestamp;
624
+
625
+ // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
626
+ if (last < wait && last > 0) {
627
+ timeout = setTimeout(_later, wait - last);
628
+ } else {
629
+ timeout = null;
630
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
631
+ if (!immediate) {
632
+ result = func.apply(context, args);
633
+ if (!timeout) context = args = null;
634
+ }
635
+ }
636
+ };
637
+ return function () {
638
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
639
+ args[_key] = arguments[_key];
640
+ }
641
+ context = this;
642
+ timestamp = +new Date();
643
+ var callNow = immediate && !timeout;
644
+ // 如果延时不存在,重新设定延时
645
+ if (!timeout) timeout = setTimeout(_later, wait);
646
+ if (callNow) {
647
+ result = func.apply(context, args);
648
+ context = args = null;
649
+ }
650
+ return result;
651
+ };
652
+ }
653
+ function toLine(name) {
654
+ return name.replace(/([A-Z])/g, "_$1").toLowerCase();
655
+ }
656
+
657
+ // ...删除固定创建的 __inst ...
658
+ var __vue = Vue; // Vue
659
+
660
+ /**
661
+ * Parse JSX, filter params
662
+ * options 增加 inst 参数,代表外部传入的 Vue 实例
663
+ * @param {*} vnode
664
+ * @param {{inst, scope, prop, children, $scopedSlots}} options
665
+ */
666
+ var parse_jsx = function parse_jsx(vnode) {
667
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
668
+ var inst = options.inst,
669
+ scope = options.scope,
670
+ prop = options.prop,
671
+ $scopedSlots = options.$scopedSlots,
672
+ _options$children = options.children,
673
+ children = _options$children === void 0 ? [] : _options$children;
674
+ var h = inst.$createElement;
675
+ if (vnode.name.indexOf("slot-") == 0) {
676
+ var rn = $scopedSlots[vnode.name];
677
+ if (rn) {
678
+ return rn({
679
+ scope: scope
680
+ });
681
+ } else {
682
+ return "错误";
683
+ }
684
+ }
685
+ if (vnode.render) {
686
+ if (!inst.$root.$options.components[vnode.name]) {
687
+ __vue.component(vnode.name, cloneDeep(vnode));
688
+ }
689
+
690
+ // Avoid props prompts { type:null }
691
+ delete vnode.props;
692
+ }
693
+ var keys = ["class", "style", "props", "attrs", "domProps", "on", "nativeOn", "directives", "scopedSlots", "slot", "key", "ref", "refInFor"];
694
+
695
+ // Avoid loop update
696
+ var data = cloneDeep(vnode);
697
+ for (var i in data) {
698
+ if (!keys.includes(i)) {
699
+ delete data[i];
700
+ }
701
+ }
702
+ if (scope) {
703
+ if (!data.attrs) {
704
+ data.attrs = {};
705
+ }
706
+ if (!data.on) {
707
+ data.on = {};
708
+ }
709
+ if (!data.props) {
710
+ data.props = {};
711
+ }
712
+
713
+ // 添加作用域
714
+ data.props.scope = scope;
715
+
716
+ // 输入事件
717
+ var onInput = data.on.input;
718
+
719
+ // 设置默认值
720
+ data.attrs.value = scope[prop];
721
+
722
+ // 监听输入事件
723
+ data.on.input = function (val) {
724
+ inst.$set(scope, prop, val);
725
+ if (onInput) {
726
+ onInput(val);
727
+ }
728
+ };
729
+ }
730
+ return h(vnode.name, cloneDeep(data), children);
731
+ };
732
+
733
+ /**
734
+ * Render vNode
735
+ * options 允许 inst 为空,通过调用者的 this 获取 Vue 实例
736
+ * @param {*} vnode
737
+ * @param {{inst?, prop, scope, $scopedSlots}} options
738
+ */
739
+ function renderNode(vnode, options) {
740
+ // 如果 options.inst 为空,则尝试用调用者上下文的 this
741
+ var prop = options.prop,
742
+ scope = options.scope,
743
+ $scopedSlots = options.$scopedSlots;
744
+ var inst = options.inst || this;
745
+ var h = inst.$createElement;
746
+ if (!vnode) {
747
+ return null;
748
+ }
749
+
750
+ // When slot or tagName
751
+ if (isString(vnode)) {
752
+ return parse_jsx({
753
+ name: vnode
754
+ }, {
755
+ inst: inst,
756
+ prop: prop,
757
+ scope: scope,
758
+ $scopedSlots: $scopedSlots
759
+ });
760
+ }
761
+
762
+ // When customeize render function
763
+ if (isFunction(vnode)) {
764
+ return vnode({
765
+ scope: scope,
766
+ h: h
767
+ });
768
+ }
769
+ // When jsx
770
+ if (isObject(vnode)) {
771
+ if (isObject(vnode.name)) {
772
+ var component = vnode.name;
773
+ var curComponent = Object.values(inst.$options.components).find(function (item) {
774
+ return item == vnode;
775
+ });
776
+ if (curComponent) {
777
+ vnode.name = curComponent.name;
778
+ } else {
779
+ var componentName = component.name || "component_" + Math.random().toString(36).substr(2, 9);
780
+ inst.$options.components[componentName] = component;
781
+ vnode.name = componentName;
782
+ console.log(componentName);
783
+ }
784
+ }
785
+ if (vnode.context) {
786
+ return vnode;
787
+ }
788
+ if (vnode.name) {
789
+ // Handle general component
790
+ var keys = ["el-select", "el-radio-group", "el-checkbox-group"];
791
+ if (keys.includes(vnode.name)) {
792
+ var _options = vnode.options;
793
+ if (isFunction(_options)) {
794
+ _options = _options(scope);
795
+ }
796
+
797
+ // Append component children
798
+ var children = (_options || []).map(function (e, i) {
799
+ if (vnode.name === "el-select") {
800
+ var label, value;
801
+ if (isString(e)) {
802
+ label = value = e;
803
+ } else if (isObject(e)) {
804
+ label = e.label;
805
+ value = e.value;
806
+ } else {
807
+ return "错误";
808
+ }
809
+ return h("el-option", {
810
+ "props": _objectSpread2({}, _objectSpread2({
811
+ key: i,
812
+ label: label,
813
+ value: value
814
+ }, e.props))
815
+ });
816
+ } else if (vnode.name === "el-radio-group") {
817
+ return h("el-radio", {
818
+ "props": _objectSpread2({}, _objectSpread2({
819
+ key: i,
820
+ label: e.value
821
+ }, e.props))
822
+ }, [e.label]);
823
+ } else if (vnode.name === "el-checkbox-group") {
824
+ if (typeof scope[prop] === 'undefined') {
825
+ inst.$set(scope, prop, []);
826
+ }
827
+ return h("el-checkbox", {
828
+ "props": _objectSpread2({}, _objectSpread2({
829
+ key: i,
830
+ label: e.value
831
+ }, e.props))
832
+ }, [e.label]);
833
+ } else {
834
+ return null;
835
+ }
836
+ });
837
+ return parse_jsx(vnode, {
838
+ inst: inst,
839
+ prop: prop,
840
+ scope: scope,
841
+ children: children
842
+ });
843
+ } else {
844
+ return parse_jsx(vnode, {
845
+ inst: inst,
846
+ prop: prop,
847
+ scope: scope,
848
+ $scopedSlots: $scopedSlots
849
+ });
850
+ }
851
+ } else {
852
+ return "错误";
853
+ }
854
+ }
855
+ }
856
+
857
+ // 组件说明:TableColumn 用于在 CRUD 表格中动态渲染列,支持嵌套子列,处理字典与格式化展示。
858
+ var TableColumn = {
859
+ // 组件名称
860
+ name: "TableColumn",
861
+ data: function data() {
862
+ return {
863
+ // emit:{},
864
+ actionMap: {
865
+ info: {
866
+ label: "详情",
867
+ type: "text",
868
+ action: "info",
869
+ icon: "el-icon-document"
870
+ },
871
+ update: {
872
+ label: "编辑",
873
+ type: "text",
874
+ action: "update",
875
+ icon: "el-icon-edit"
876
+ },
877
+ "delete": {
878
+ label: "删除",
879
+ type: "text",
880
+ action: "delete",
881
+ icon: "el-icon-delete"
882
+ }
883
+ }
884
+ };
885
+ },
886
+ props: {
887
+ // 列配置对象,包含列属性、子列、格式化函数等
888
+ column: {
889
+ type: Object,
890
+ required: true
891
+ },
892
+ // 行索引生成方法,用于动态生成行号
893
+ indexMethod: {
894
+ type: Function,
895
+ required: false
896
+ }
897
+ },
898
+ computed: {
899
+ // 判断当前列是否包含子列
900
+ hasChildren: function hasChildren() {
901
+ return this.column.children && this.column.children.length > 0;
902
+ },
903
+ // 生成并返回列的属性集合,默认居中对齐
904
+ columnProps: function columnProps() {
905
+ return Object.assign({}, this.column, {
906
+ align: this.column.align || "center"
907
+ });
908
+ },
909
+ // 生成唯一的列 key,用于 Vue 渲染优化
910
+ columnKey: function columnKey() {
911
+ return "crud-table-column-" + (this.column.prop || Math.random());
912
+ }
913
+ },
914
+ mounted: function mounted() {},
915
+ methods: {
916
+ // 根据传入值查找并返回字典中对应的对象
917
+ getDict: function getDict(value) {
918
+ var _this = this;
919
+ if (isPromise(this.column.dict)) {
920
+ this.column.dict.then(function (dict) {
921
+ _this.column.dict = dict;
922
+ });
923
+ return null;
924
+ }
925
+ // this.column.dict 如果 this.column.dict 是个 function
926
+ // 则调用 this.column.dict(value) 返回字典对象
927
+ if (typeof this.column.dict === "function") {
928
+ return this.column.dict(value).find(function (d) {
929
+ return d.value == value;
930
+ });
931
+ }
932
+ if (this.column.dict) {
933
+ var _this$column$dict;
934
+ return (_this$column$dict = this.column.dict) === null || _this$column$dict === void 0 ? void 0 : _this$column$dict.find(function (d) {
935
+ return d.value == value;
936
+ });
937
+ }
938
+ return null;
939
+ },
940
+ // 检查传入的值是否严格为 null
941
+ isNull: function isNull(val) {
942
+ return val === null;
943
+ },
944
+ renderNode: function renderNode$1(vnode, options) {
945
+ return renderNode.call(this, vnode, options);
946
+ },
947
+ renderSelection: function renderSelection(h) {
948
+ return h("el-table-column", {
949
+ key: this.columnKey,
950
+ props: Object.assign({}, this.columnProps, {
951
+ index: this.indexMethod
952
+ })
953
+ }, []);
954
+ },
955
+ // 渲染操作列
956
+ renderActions: function renderActions(h) {
957
+ var _this2 = this;
958
+ return h("el-table-column", {
959
+ key: this.columnKey,
960
+ props: Object.assign({}, this.columnProps, {
961
+ index: this.indexMethod
962
+ }),
963
+ scopedSlots: {
964
+ "default": function _default(scope) {
965
+ var _actions;
966
+ var actions = _this2.column.actions;
967
+ if (isFunction(_this2.column.actions)) {
968
+ actions = _this2.column.actions({
969
+ scope: scope,
970
+ h: h
971
+ });
972
+ }
973
+ return (_actions = actions) === null || _actions === void 0 ? void 0 : _actions.map(function (action) {
974
+ // 自定义渲染函数
975
+ if (isFunction(action)) {
976
+ return action({
977
+ scope: scope,
978
+ h: h
979
+ });
980
+ }
981
+ // 预设的操作映射
982
+ if (isString(action)) {
983
+ action = _this2.actionMap[action];
984
+ if (!action) {
985
+ return null;
986
+ }
987
+ }
988
+ // action 如果是数组 创建 更多 按钮列表
989
+ if (isArray(action)) {
990
+ return h("el-dropdown", {
991
+ props: {
992
+ trigger: "hover"
993
+ // size: "mini"
994
+ },
995
+ on: {
996
+ command: function command(e) {
997
+ _this2.$emit("action", e, scope);
998
+ }
999
+ },
1000
+ style: {
1001
+ right: "auto",
1002
+ "margin-left": "10px"
1003
+ }
1004
+ }, [h("span", {
1005
+ "class": "el-dropdown-link",
1006
+ style: "margin-left: 0"
1007
+ }, ["更多", h("i", {
1008
+ "class": "el-icon-arrow-down el-icon--right"
1009
+ })]), h("el-dropdown-menu", {
1010
+ slot: "dropdown"
1011
+ }, action.map(function (item) {
1012
+ var _item = item;
1013
+ // 预设的操作映射
1014
+ if (isString(_item)) {
1015
+ _item = _this2.actionMap[_item];
1016
+ if (!_item) {
1017
+ return null;
1018
+ }
1019
+ }
1020
+ return h("el-dropdown-item", {
1021
+ props: {
1022
+ command: _item.action,
1023
+ icon: _item.icon,
1024
+ disabled: _item.disabled
1025
+ }
1026
+ }, _item.label);
1027
+ }))]);
1028
+ }
1029
+
1030
+ // 渲染 action 按钮
1031
+ return h("el-button", {
1032
+ props: {
1033
+ type: action.type || "text",
1034
+ size: action.size || "mini",
1035
+ icon: action.icon || "",
1036
+ disabled: action.disabled || false
1037
+ },
1038
+ on: {
1039
+ click: function click(e) {
1040
+ _this2.$emit("action", action.action, scope);
1041
+ }
1042
+ }
1043
+ }, action.label);
1044
+ }).filter(function (item) {
1045
+ return item;
1046
+ });
1047
+ }
1048
+ }
1049
+ }, []);
1050
+ }
1051
+ },
1052
+ // 动态渲染函数,根据列配置渲染 el-table-column
1053
+ render: function render(h) {
1054
+ var _this3 = this;
1055
+ if (this.column.hidden) {
1056
+ if (typeof this.column.hidden === "function") {
1057
+ // 如果 hidden 是函数,则调用函数判断是否隐藏
1058
+ if (this.column.hidden(this.column)) {
1059
+ return null;
1060
+ }
1061
+ }
1062
+ }
1063
+ if (this.column.visible === false) {
1064
+ return null;
1065
+ }
1066
+ if (this.column.type === "selection" || this.column.type === "index") {
1067
+ // 对于 selection 类型,直接传递 props 让 Element 内部处理选中状态
1068
+ return this.renderSelection(h);
1069
+ } else if (this.column.type === "action") {
1070
+ // 对于 action 类型,渲染操作列
1071
+ return this.renderActions(h);
1072
+ }
1073
+ return h("el-table-column", {
1074
+ key: this.columnKey,
1075
+ props: Object.assign({}, this.columnProps, {
1076
+ index: this.indexMethod
1077
+ }),
1078
+ scopedSlots: {
1079
+ // 自定义表头渲染:支持 slot 覆盖默认表头
1080
+ header: function header(scope) {
1081
+ return _this3.$scopedSlots["header-" + _this3.column.prop] ? _this3.$scopedSlots["header-" + _this3.column.prop](scope) : scope.column.label;
1082
+ },
1083
+ // 自定义单元格渲染:支持 slot、组件、格式化函数或字典
1084
+ "default": function _default(scope) {
1085
+ var content;
1086
+ // 检查是否有自定义 slot 渲染
1087
+ if (_this3.$scopedSlots["column-" + _this3.column.prop]) {
1088
+ content = _this3.$scopedSlots["column-" + _this3.column.prop]({
1089
+ scope: scope,
1090
+ column: _this3.column
1091
+ });
1092
+ } else if (_this3.column.component) {
1093
+ // 通过 renderNode 调用渲染组件,确保 this 指向当前实例
1094
+ content = _this3.renderNode(_this3.column.component, {
1095
+ prop: _this3.column.prop,
1096
+ scope: scope
1097
+ });
1098
+ } else if (_this3.column.formatter) {
1099
+ content = _this3.column.formatter(scope.row, scope.column, scope.row[_this3.column.prop], scope.$index);
1100
+ } else if (_this3.column.dict) {
1101
+ var dictItem = _this3.getDict(scope.row[_this3.column.prop]);
1102
+ if (dictItem !== null && dictItem !== void 0 && dictItem.label) {
1103
+ content = h("el-tag", {
1104
+ props: {
1105
+ size: "mini",
1106
+ disableTransitions: true,
1107
+ type: dictItem.type
1108
+ // effect: "dark"
1109
+ }
1110
+ }, dictItem.label);
1111
+ } else {
1112
+ content = scope.row[_this3.column.prop];
1113
+ }
1114
+ } else if (_this3.isNull(scope.row[_this3.column.prop])) {
1115
+ content = scope.emptyText;
1116
+ } else {
1117
+ content = scope.row[_this3.column.prop];
1118
+ }
1119
+ return content;
1120
+ }
1121
+ }
1122
+ },
1123
+ // 若有子列则递归渲染
1124
+ this.hasChildren ? this.column.children.map(function (child, idx) {
1125
+ return h(TableColumn, {
1126
+ key: idx,
1127
+ props: {
1128
+ column: child,
1129
+ indexMethod: _this3.indexMethod
1130
+ },
1131
+ on: _this3.$listeners
1132
+ });
1133
+ }) : []);
1134
+ }
1135
+ };
1136
+
1137
+ // 支持自身递归调用(递归组件)
1138
+ TableColumn.components = {
1139
+ TableColumn: TableColumn
1140
+ };
1141
+
1142
+ //
1143
+ //
1144
+ //
1145
+ //
1146
+ //
1147
+ //
1148
+ //
1149
+ //
1150
+ //
1151
+
1152
+ var script$5 = {
1153
+ name: "CrudTable",
1154
+ components: {
1155
+ CrudTableColumn: TableColumn
1156
+ },
1157
+ inject: ["crud"],
1158
+ props: {
1159
+ columns: {
1160
+ type: Array,
1161
+ "default": function _default() {
1162
+ return [];
1163
+ }
1164
+ },
1165
+ on: {
1166
+ type: Object,
1167
+ "default": function _default() {
1168
+ return {};
1169
+ }
1170
+ },
1171
+ data: {
1172
+ type: Array,
1173
+ "default": function _default() {
1174
+ return [];
1175
+ }
1176
+ }
1177
+ },
1178
+ data: function data() {
1179
+ return {
1180
+ emit: {},
1181
+ defaultProps: {
1182
+ stripe: true,
1183
+ size: "mini"
1184
+ }
1185
+ };
1186
+ },
1187
+ computed: {
1188
+ // 将外部传入的 props 与 crud 内部样式合并
1189
+ combinedProps: function combinedProps() {
1190
+ return Object.assign({}, this.defaultProps, this.$attrs);
1191
+ },
1192
+ // 将各事件处理函数合并,包括 emit 与 on 上的回调
1193
+ combinedEvents: function combinedEvents() {
1194
+ return Object.assign({}, {
1195
+ "selection-change": this.onSelectionChange,
1196
+ "sort-change": this.onSortChange,
1197
+ "row-contextmenu": this.onRowContextMenu
1198
+ }, this.emit, this.on);
1199
+ },
1200
+ baseIndex: function baseIndex() {
1201
+ var _this$crud;
1202
+ if ((_this$crud = this.crud) !== null && _this$crud !== void 0 && _this$crud.pagination) {
1203
+ var _this$crud2, _this$crud3;
1204
+ return (((_this$crud2 = this.crud) === null || _this$crud2 === void 0 || (_this$crud2 = _this$crud2.pagination) === null || _this$crud2 === void 0 ? void 0 : _this$crud2.pageNum) - 1) * ((_this$crud3 = this.crud) === null || _this$crud3 === void 0 || (_this$crud3 = _this$crud3.pagination) === null || _this$crud3 === void 0 ? void 0 : _this$crud3.pageSize);
1205
+ } else {
1206
+ return 0;
1207
+ }
1208
+ }
1209
+ },
1210
+ mounted: function mounted() {
1211
+ this.bindEmits();
1212
+ this.bindMethods();
1213
+ },
1214
+ methods: {
1215
+ // 绑定 el-table 回调
1216
+ bindEmits: function bindEmits() {
1217
+ var _this = this;
1218
+ var emits = ["select", "select-all", "cell-mouse-enter", "cell-mouse-leave", "cell-click", "cell-dblclick", "row-click", "row-contextmenu", "row-dblclick", "header-click", "header-contextmenu", "filter-change", "current-change", "header-dragend", "expand-change"];
1219
+ emits.forEach(function (name) {
1220
+ _this.emit[name] = function () {
1221
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1222
+ args[_key] = arguments[_key];
1223
+ }
1224
+ _this.$emit.apply(_this, [name].concat(args));
1225
+ };
1226
+ });
1227
+ },
1228
+ // 绑定 el-table 事件
1229
+ bindMethods: function bindMethods() {
1230
+ var _this2 = this;
1231
+ var methods = ["clearSelection", "toggleRowSelection", "toggleAllSelection", "toggleRowExpansion", "setCurrentRow", "clearSort", "clearFilter", "doLayout", "sort"];
1232
+ methods.forEach(function (n) {
1233
+ _this2[n] = _this2.$refs["table"][n];
1234
+ });
1235
+ },
1236
+ onSelectionChange: function onSelectionChange(selection) {
1237
+ this.$emit("selection-change", selection);
1238
+ },
1239
+ onSortChange: function onSortChange(_ref) {
1240
+ var prop = _ref.prop,
1241
+ order = _ref.order;
1242
+ this.$emit("sort-change", {
1243
+ prop: prop,
1244
+ order: order
1245
+ });
1246
+ },
1247
+ onRowContextMenu: function onRowContextMenu(row, column, event) {
1248
+ this.$emit("row-contextmenu", row, column, event);
1249
+ },
1250
+ onRowAction: function onRowAction(action, scope) {
1251
+ this.$emit("row-action", action, scope);
1252
+ this.$emit("row-".concat(action), scope);
1253
+ }
1254
+ }
1255
+ };
1256
+
1257
+ function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
1258
+ if (typeof shadowMode !== 'boolean') {
1259
+ createInjectorSSR = createInjector;
1260
+ createInjector = shadowMode;
1261
+ shadowMode = false;
1262
+ }
1263
+ // Vue.extend constructor export interop.
1264
+ const options = typeof script === 'function' ? script.options : script;
1265
+ // render functions
1266
+ if (template && template.render) {
1267
+ options.render = template.render;
1268
+ options.staticRenderFns = template.staticRenderFns;
1269
+ options._compiled = true;
1270
+ // functional template
1271
+ if (isFunctionalTemplate) {
1272
+ options.functional = true;
1273
+ }
1274
+ }
1275
+ // scopedId
1276
+ if (scopeId) {
1277
+ options._scopeId = scopeId;
1278
+ }
1279
+ let hook;
1280
+ if (moduleIdentifier) {
1281
+ // server build
1282
+ hook = function (context) {
1283
+ // 2.3 injection
1284
+ context =
1285
+ context || // cached call
1286
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
1287
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
1288
+ // 2.2 with runInNewContext: true
1289
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
1290
+ context = __VUE_SSR_CONTEXT__;
1291
+ }
1292
+ // inject component styles
1293
+ if (style) {
1294
+ style.call(this, createInjectorSSR(context));
1295
+ }
1296
+ // register component module identifier for async chunk inference
1297
+ if (context && context._registeredComponents) {
1298
+ context._registeredComponents.add(moduleIdentifier);
1299
+ }
1300
+ };
1301
+ // used by ssr in case component is cached and beforeCreate
1302
+ // never gets called
1303
+ options._ssrRegister = hook;
1304
+ }
1305
+ else if (style) {
1306
+ hook = shadowMode
1307
+ ? function (context) {
1308
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
1309
+ }
1310
+ : function (context) {
1311
+ style.call(this, createInjector(context));
1312
+ };
1313
+ }
1314
+ if (hook) {
1315
+ if (options.functional) {
1316
+ // register for functional component in vue file
1317
+ const originalRender = options.render;
1318
+ options.render = function renderWithStyleInjection(h, context) {
1319
+ hook.call(context);
1320
+ return originalRender(h, context);
1321
+ };
1322
+ }
1323
+ else {
1324
+ // inject component registration as beforeCreate hook
1325
+ const existing = options.beforeCreate;
1326
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
1327
+ }
1328
+ }
1329
+ return script;
1330
+ }
1331
+
1332
+ const isOldIE = typeof navigator !== 'undefined' &&
1333
+ /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
1334
+ function createInjector(context) {
1335
+ return (id, style) => addStyle(id, style);
1336
+ }
1337
+ let HEAD;
1338
+ const styles = {};
1339
+ function addStyle(id, css) {
1340
+ const group = isOldIE ? css.media || 'default' : id;
1341
+ const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
1342
+ if (!style.ids.has(id)) {
1343
+ style.ids.add(id);
1344
+ let code = css.source;
1345
+ if (css.map) {
1346
+ // https://developer.chrome.com/devtools/docs/javascript-debugging
1347
+ // this makes source maps inside style tags work properly in Chrome
1348
+ code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
1349
+ // http://stackoverflow.com/a/26603875
1350
+ code +=
1351
+ '\n/*# sourceMappingURL=data:application/json;base64,' +
1352
+ btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
1353
+ ' */';
1354
+ }
1355
+ if (!style.element) {
1356
+ style.element = document.createElement('style');
1357
+ style.element.type = 'text/css';
1358
+ if (css.media)
1359
+ style.element.setAttribute('media', css.media);
1360
+ if (HEAD === undefined) {
1361
+ HEAD = document.head || document.getElementsByTagName('head')[0];
1362
+ }
1363
+ HEAD.appendChild(style.element);
1364
+ }
1365
+ if ('styleSheet' in style.element) {
1366
+ style.styles.push(code);
1367
+ style.element.styleSheet.cssText = style.styles
1368
+ .filter(Boolean)
1369
+ .join('\n');
1370
+ }
1371
+ else {
1372
+ const index = style.ids.size - 1;
1373
+ const textNode = document.createTextNode(code);
1374
+ const nodes = style.element.childNodes;
1375
+ if (nodes[index])
1376
+ style.element.removeChild(nodes[index]);
1377
+ if (nodes.length)
1378
+ style.element.insertBefore(textNode, nodes[index]);
1379
+ else
1380
+ style.element.appendChild(textNode);
1381
+ }
1382
+ }
1383
+ }
1384
+
1385
+ /* script */
1386
+ var __vue_script__$5 = script$5;
1387
+
1388
+ /* template */
1389
+ var __vue_render__$4 = function __vue_render__() {
1390
+ var _vm = this;
1391
+ var _h = _vm.$createElement;
1392
+ var _c = _vm._self._c || _h;
1393
+ return _c("el-table", _vm._g(_vm._b({
1394
+ ref: "table",
1395
+ staticClass: "crud-table",
1396
+ attrs: {
1397
+ data: _vm.data
1398
+ }
1399
+ }, "el-table", _vm.combinedProps, false), _vm.combinedEvents), _vm._l(_vm.columns, function (column) {
1400
+ return !column["v-hasPermi"] || !column["v-hasPermi"].length || _vm.$auth.hasPermiOr(column["v-hasPermi"] || []) ? _c("crud-table-column", {
1401
+ attrs: {
1402
+ indexMethod: function indexMethod(index) {
1403
+ return _vm.baseIndex + 1 + index;
1404
+ },
1405
+ column: column
1406
+ },
1407
+ on: {
1408
+ action: _vm.onRowAction
1409
+ }
1410
+ }) : _vm._e();
1411
+ }), 1);
1412
+ };
1413
+ var __vue_staticRenderFns__$4 = [];
1414
+ __vue_render__$4._withStripped = true;
1415
+
1416
+ /* style */
1417
+ var __vue_inject_styles__$5 = function __vue_inject_styles__(inject) {
1418
+ if (!inject) return;
1419
+ inject("data-v-eea78022_0", {
1420
+ source: ".crud-table[data-v-eea78022] .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */",
1421
+ map: {
1422
+ "version": 3,
1423
+ "sources": ["/Users/tonwe/git/el-crud-page/src/table.vue", "table.vue"],
1424
+ "names": [],
1425
+ "mappings": "AAsJA;EACA,YAAA;EACA,cAAA;ACrJA;;AAEA,oCAAoC",
1426
+ "file": "table.vue",
1427
+ "sourcesContent": ["<!-- crud table 组件 -->\n<template>\n <el-table :data=\"data\" class=\"crud-table\" ref=\"table\" v-bind=\"combinedProps\" v-on=\"combinedEvents\">\n <crud-table-column v-for=\"column in columns\" :indexMethod=\"(index)=>( baseIndex + 1 + index )\"\n v-if=\"!column[`v-hasPermi`] || !column[`v-hasPermi`].length || $auth.hasPermiOr(column[`v-hasPermi`] || [])\"\n :column=\"column\" @action=\"onRowAction\">\n </crud-table-column>\n </el-table>\n</template>\n<script>\n\n\n/**\n * CRUD table组件\n */\n\nimport CrudTableColumn from \"./tableColumn.js\";\n\nexport default {\n name: \"CrudTable\",\n components: {\n CrudTableColumn\n },\n inject: [\"crud\"],\n props: {\n columns: {\n type: Array,\n default: () => []\n },\n on: {\n type: Object,\n default: () => {\n return {};\n }\n },\n data: {\n type: Array,\n default: () => {\n return [];\n }\n }\n },\n data() {\n return {\n emit: {},\n defaultProps: {\n stripe: true,\n size: \"mini\",\n }\n };\n },\n computed: {\n // 将外部传入的 props 与 crud 内部样式合并\n combinedProps() {\n return Object.assign({}, this.defaultProps, this.$attrs);\n },\n // 将各事件处理函数合并,包括 emit 与 on 上的回调\n combinedEvents() {\n return Object.assign(\n {},\n {\n \"selection-change\": this.onSelectionChange,\n \"sort-change\": this.onSortChange,\n \"row-contextmenu\": this.onRowContextMenu\n },\n this.emit,\n this.on\n );\n },\n baseIndex(){\n if( this.crud?.pagination ){\n return (this.crud?.pagination?.pageNum-1) * this.crud?.pagination?.pageSize;\n }else{\n return 0;\n }\n }\n },\n mounted() {\n this.bindEmits();\n this.bindMethods();\n },\n methods: {\n // 绑定 el-table 回调\n bindEmits() {\n const emits = [\n \"select\",\n \"select-all\",\n \"cell-mouse-enter\",\n \"cell-mouse-leave\",\n \"cell-click\",\n \"cell-dblclick\",\n \"row-click\",\n \"row-contextmenu\",\n \"row-dblclick\",\n \"header-click\",\n \"header-contextmenu\",\n \"filter-change\",\n \"current-change\",\n \"header-dragend\",\n \"expand-change\"\n ];\n\n emits.forEach((name) => {\n this.emit[name] = (...args) => {\n this.$emit(name, ...args);\n };\n });\n },\n\n // 绑定 el-table 事件\n bindMethods() {\n const methods = [\n \"clearSelection\",\n \"toggleRowSelection\",\n \"toggleAllSelection\",\n \"toggleRowExpansion\",\n \"setCurrentRow\",\n \"clearSort\",\n \"clearFilter\",\n \"doLayout\",\n \"sort\"\n ];\n\n methods.forEach((n) => {\n this[n] = this.$refs[\"table\"][n];\n });\n },\n onSelectionChange(selection) {\n this.$emit(\"selection-change\", selection);\n },\n onSortChange({ prop, order }) {\n this.$emit(\"sort-change\", { prop, order });\n },\n onRowContextMenu(row, column, event) {\n this.$emit(\"row-contextmenu\", row, column, event);\n },\n onRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n this.$emit(`row-${action}`, scope);\n }\n }\n\n}\n</script>\n\n<style scoped lang=\"scss\">\n.crud-table {\n &::v-deep {\n .el-table__body-wrapper {\n .el-table__cell {\n .cell:empty::after {\n content: '/';\n color: #c0c4cc;\n }\n }\n }\n }\n}\n</style>\n", ".crud-table::v-deep .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */"]
1428
+ },
1429
+ media: undefined
1430
+ });
1431
+ };
1432
+ /* scoped */
1433
+ var __vue_scope_id__$5 = "data-v-eea78022";
1434
+ /* module identifier */
1435
+ var __vue_module_identifier__$5 = undefined;
1436
+ /* functional template */
1437
+ var __vue_is_functional_template__$5 = false;
1438
+ /* style inject SSR */
1439
+
1440
+ /* style inject shadow dom */
1441
+
1442
+ var __vue_component__$5 = /*#__PURE__*/normalizeComponent({
1443
+ render: __vue_render__$4,
1444
+ staticRenderFns: __vue_staticRenderFns__$4
1445
+ }, __vue_inject_styles__$5, __vue_script__$5, __vue_scope_id__$5, __vue_is_functional_template__$5, __vue_module_identifier__$5, false, createInjector, undefined, undefined);
1446
+
1447
+ //
1448
+ //
1449
+ //
1450
+ //
1451
+ //
1452
+ //
1453
+ //
1454
+ //
1455
+ //
1456
+ //
1457
+ //
1458
+ //
1459
+ //
1460
+ //
1461
+ //
1462
+ //
1463
+ //
1464
+ //
1465
+ //
1466
+ //
1467
+ //
1468
+ //
1469
+ //
1470
+ //
1471
+ //
1472
+ //
1473
+ //
1474
+ //
1475
+ //
1476
+ //
1477
+ //
1478
+ //
1479
+ //
1480
+
1481
+ var script$4 = {
1482
+ name: "RightToolbar",
1483
+ inject: ["crud"],
1484
+ data: function data() {
1485
+ return {
1486
+ // 显隐数据
1487
+ value: [],
1488
+ // 弹出层标题
1489
+ title: "显示/隐藏",
1490
+ // 是否显示弹出层
1491
+ open: false,
1492
+ // 本地列数据副本(用于拖拽)
1493
+ localColumns: []
1494
+ };
1495
+ },
1496
+ props: {
1497
+ /* 是否显示检索条件 */
1498
+ showSearch: {
1499
+ type: Boolean,
1500
+ "default": true
1501
+ },
1502
+ /* 显隐列信息 */
1503
+ columns: {
1504
+ type: Array
1505
+ },
1506
+ /* 是否显示检索图标 */
1507
+ search: {
1508
+ type: Boolean,
1509
+ "default": true
1510
+ },
1511
+ /* 显隐列类型(transfer穿梭框、checkbox复选框) */
1512
+ showColumnsType: {
1513
+ type: String,
1514
+ "default": "checkbox"
1515
+ },
1516
+ /* 右外边距 */
1517
+ gutter: {
1518
+ type: Number,
1519
+ "default": 10
1520
+ }
1521
+ },
1522
+ computed: {
1523
+ style: function style() {
1524
+ var ret = {};
1525
+ if (this.gutter) {
1526
+ ret.marginRight = "".concat(this.gutter / 2, "px");
1527
+ }
1528
+ return ret;
1529
+ }
1530
+ },
1531
+ watch: {
1532
+ columns: {
1533
+ handler: function handler(newVal) {
1534
+ // 当 columns prop 变化时,更新本地副本
1535
+ this.localColumns = newVal ? _toConsumableArray(newVal) : [];
1536
+ },
1537
+ immediate: true,
1538
+ deep: true
1539
+ }
1540
+ },
1541
+ created: function created() {
1542
+ if (this.showColumnsType == 'transfer') {
1543
+ // 显隐列初始默认隐藏列
1544
+ for (var item in this.columns) {
1545
+ if (this.columns[item].visible === false) {
1546
+ this.value.push(parseInt(item));
1547
+ }
1548
+ }
1549
+ }
1550
+ },
1551
+ methods: {
1552
+ // 搜索
1553
+ toggleSearch: function toggleSearch() {
1554
+ this.$emit("update:showSearch", !this.showSearch);
1555
+ },
1556
+ // 刷新
1557
+ refresh: function refresh() {
1558
+ this.$emit("queryTable");
1559
+ },
1560
+ // 右侧列表元素变化
1561
+ dataChange: function dataChange(data) {
1562
+ for (var item in this.columns) {
1563
+ var key = this.columns[item].key;
1564
+ this.columns[item].visible = !data.includes(key);
1565
+ }
1566
+ },
1567
+ // 打开显隐列dialog
1568
+ showColumn: function showColumn() {
1569
+ this.open = true;
1570
+ },
1571
+ // 勾选
1572
+ checkboxChange: function checkboxChange(event, item) {
1573
+ item.visible = event;
1574
+ // 通知父组件更新
1575
+ this.$emit('update:columns', this.localColumns);
1576
+ },
1577
+ // 拖拽结束
1578
+ onDragEnd: function onDragEnd(event) {
1579
+ // 拖拽结束后,通知父组件列顺序已改变
1580
+ this.$emit('update:columns', this.localColumns);
1581
+ this.$emit('columns-order-changed', this.localColumns);
1582
+ }
1583
+ }
1584
+ };
1585
+
1586
+ /* script */
1587
+ var __vue_script__$4 = script$4;
1588
+
1589
+ /* template */
1590
+ var __vue_render__$3 = function __vue_render__() {
1591
+ var _vm = this;
1592
+ var _h = _vm.$createElement;
1593
+ var _c = _vm._self._c || _h;
1594
+ return _c("div", {
1595
+ staticClass: "top-right-btn",
1596
+ style: _vm.style
1597
+ }, [_c("div", {
1598
+ staticClass: "flex flex-row items-center"
1599
+ }, [_vm.search ? _c("el-tooltip", {
1600
+ staticClass: "item",
1601
+ attrs: {
1602
+ effect: "dark",
1603
+ content: _vm.showSearch ? "隐藏搜索" : "显示搜索",
1604
+ placement: "top"
1605
+ }
1606
+ }, [_c("el-button", {
1607
+ attrs: {
1608
+ size: "mini",
1609
+ circle: "",
1610
+ icon: "el-icon-search"
1611
+ },
1612
+ on: {
1613
+ click: function click($event) {
1614
+ return _vm.toggleSearch();
1615
+ }
1616
+ }
1617
+ })], 1) : _vm._e(), _vm._v(" "), _c("el-tooltip", {
1618
+ staticClass: "item",
1619
+ attrs: {
1620
+ effect: "dark",
1621
+ content: "刷新",
1622
+ placement: "top"
1623
+ }
1624
+ }, [_c("el-button", {
1625
+ attrs: {
1626
+ size: "mini",
1627
+ circle: "",
1628
+ icon: "el-icon-refresh"
1629
+ },
1630
+ on: {
1631
+ click: function click($event) {
1632
+ return _vm.refresh();
1633
+ }
1634
+ }
1635
+ })], 1), _vm._v(" "), _vm.columns ? _c("el-tooltip", {
1636
+ staticClass: "item",
1637
+ attrs: {
1638
+ effect: "dark",
1639
+ content: "显隐列",
1640
+ placement: "top"
1641
+ }
1642
+ }, [_vm.showColumnsType == "transfer" ? _c("el-button", {
1643
+ attrs: {
1644
+ size: "mini",
1645
+ circle: "",
1646
+ icon: "el-icon-menu"
1647
+ },
1648
+ on: {
1649
+ click: function click($event) {
1650
+ return _vm.showColumn();
1651
+ }
1652
+ }
1653
+ }) : _vm._e(), _vm._v(" "), _vm.showColumnsType == "checkbox" ? _c("el-dropdown", {
1654
+ staticStyle: {
1655
+ "padding-left": "12px"
1656
+ },
1657
+ attrs: {
1658
+ trigger: "click",
1659
+ "hide-on-click": false
1660
+ }
1661
+ }, [_c("el-button", {
1662
+ attrs: {
1663
+ size: "mini",
1664
+ circle: "",
1665
+ icon: "el-icon-menu"
1666
+ }
1667
+ }), _vm._v(" "), _c("el-dropdown-menu", {
1668
+ attrs: {
1669
+ slot: "dropdown"
1670
+ },
1671
+ slot: "dropdown"
1672
+ }, [_vm._l(_vm.columns, function (item) {
1673
+ return item.type != "index" && item.type != "selection" && typeof item.visible !== "undefined" ? _c("el-dropdown-item", {
1674
+ key: item.key
1675
+ }, [_c("el-checkbox", {
1676
+ attrs: {
1677
+ checked: item.visible,
1678
+ label: item.label
1679
+ },
1680
+ on: {
1681
+ change: function change($event) {
1682
+ return _vm.checkboxChange($event, item);
1683
+ }
1684
+ }
1685
+ })], 1) : _vm._e();
1686
+ })], 2)], 1) : _vm._e()], 1) : _vm._e()], 1), _vm._v(" "), _c("el-dialog", {
1687
+ attrs: {
1688
+ title: _vm.title,
1689
+ visible: _vm.open,
1690
+ "append-to-body": ""
1691
+ },
1692
+ on: {
1693
+ "update:visible": function updateVisible($event) {
1694
+ _vm.open = $event;
1695
+ }
1696
+ }
1697
+ }, [_c("el-transfer", {
1698
+ attrs: {
1699
+ titles: ["显示", "隐藏"],
1700
+ data: _vm.columns
1701
+ },
1702
+ on: {
1703
+ change: _vm.dataChange
1704
+ },
1705
+ model: {
1706
+ value: _vm.value,
1707
+ callback: function callback($$v) {
1708
+ _vm.value = $$v;
1709
+ },
1710
+ expression: "value"
1711
+ }
1712
+ })], 1)], 1);
1713
+ };
1714
+ var __vue_staticRenderFns__$3 = [];
1715
+ __vue_render__$3._withStripped = true;
1716
+
1717
+ /* style */
1718
+ var __vue_inject_styles__$4 = function __vue_inject_styles__(inject) {
1719
+ if (!inject) return;
1720
+ inject("data-v-d5778a5c_0", {
1721
+ source: "[data-v-d5778a5c] .el-transfer__button {\n border-radius: 50%;\n padding: 12px;\n display: block;\n margin-left: 0px;\n}\n[data-v-d5778a5c] .el-transfer__button:first-child {\n margin-bottom: 10px;\n}\n.drag-item[data-v-d5778a5c] {\n padding: 8px;\n cursor: move;\n border-bottom: 1px solid #ebeef5;\n display: flex;\n align-items: center;\n}\n.drag-item[data-v-d5778a5c]:hover {\n background-color: #f5f7fa;\n}\n.drag-handle[data-v-d5778a5c] {\n color: #909399;\n}\n.drag-handle[data-v-d5778a5c]:hover {\n color: #409eff;\n}\n\n/*# sourceMappingURL=rightToolbar.vue.map */",
1722
+ map: {
1723
+ "version": 3,
1724
+ "sources": ["/Users/tonwe/git/el-crud-page/src/rightToolbar.vue", "rightToolbar.vue"],
1725
+ "names": [],
1726
+ "mappings": "AA4IA;EACA,kBAAA;EACA,aAAA;EACA,cAAA;EACA,gBAAA;AC3IA;AD6IA;EACA,mBAAA;AC1IA;AD6IA;EACA,YAAA;EACA,YAAA;EACA,gCAAA;EACA,aAAA;EACA,mBAAA;AC1IA;AD4IA;EACA,yBAAA;AC1IA;AD8IA;EACA,cAAA;AC3IA;AD6IA;EACA,cAAA;AC3IA;;AAEA,2CAA2C",
1727
+ "file": "rightToolbar.vue",
1728
+ "sourcesContent": ["<template>\n <div class=\"top-right-btn\" :style=\"style\">\n <div class=\"flex flex-row items-center\">\n <el-tooltip class=\"item\" effect=\"dark\" :content=\"showSearch ? '隐藏搜索' : '显示搜索'\" placement=\"top\" v-if=\"search\">\n <el-button size=\"mini\" circle icon=\"el-icon-search\" @click=\"toggleSearch()\" />\n </el-tooltip>\n <el-tooltip class=\"item\" effect=\"dark\" content=\"刷新\" placement=\"top\">\n <el-button size=\"mini\" circle icon=\"el-icon-refresh\" @click=\"refresh()\" />\n </el-tooltip>\n <el-tooltip class=\"item\" effect=\"dark\" content=\"显隐列\" placement=\"top\" v-if=\"columns\">\n <el-button size=\"mini\" circle icon=\"el-icon-menu\" @click=\"showColumn()\" v-if=\"showColumnsType == 'transfer'\"/>\n <el-dropdown trigger=\"click\" :hide-on-click=\"false\" style=\"padding-left: 12px\" v-if=\"showColumnsType == 'checkbox'\">\n <el-button size=\"mini\" circle icon=\"el-icon-menu\" />\n <el-dropdown-menu slot=\"dropdown\">\n <template >\n <el-dropdown-item v-for=\"item in columns\" :key=\"item.key\" v-if=\"item.type!=`index` && item.type!=`selection` && (typeof item.visible) !== `undefined` \">\n <el-checkbox :checked=\"item.visible\" @change=\"checkboxChange($event, item)\" :label=\"item.label\" />\n </el-dropdown-item>\n </template>\n </el-dropdown-menu>\n </el-dropdown>\n </el-tooltip>\n </div>\n <el-dialog :title=\"title\" :visible.sync=\"open\" append-to-body>\n <el-transfer\n :titles=\"['显示', '隐藏']\"\n v-model=\"value\"\n :data=\"columns\"\n @change=\"dataChange\"\n ></el-transfer>\n </el-dialog>\n </div>\n </template>\n <script>\n export default {\n name: \"RightToolbar\",\n inject: [\"crud\"],\n data() {\n return {\n // 显隐数据\n value: [],\n // 弹出层标题\n title: \"显示/隐藏\",\n // 是否显示弹出层\n open: false,\n // 本地列数据副本(用于拖拽)\n localColumns: [],\n };\n },\n props: {\n /* 是否显示检索条件 */\n showSearch: {\n type: Boolean,\n default: true,\n },\n /* 显隐列信息 */\n columns: {\n type: Array,\n },\n /* 是否显示检索图标 */\n search: {\n type: Boolean,\n default: true,\n },\n /* 显隐列类型(transfer穿梭框、checkbox复选框) */\n showColumnsType: {\n type: String,\n default: \"checkbox\",\n },\n /* 右外边距 */\n gutter: {\n type: Number,\n default: 10,\n },\n },\n computed: {\n style() {\n const ret = {};\n if (this.gutter) {\n ret.marginRight = `${this.gutter / 2}px`;\n }\n return ret;\n }\n },\n watch: {\n columns: {\n handler(newVal) {\n // 当 columns prop 变化时,更新本地副本\n this.localColumns = newVal ? [...newVal] : [];\n },\n immediate: true,\n deep: true\n }\n },\n created() {\n if (this.showColumnsType == 'transfer') {\n // 显隐列初始默认隐藏列\n for (let item in this.columns) {\n if (this.columns[item].visible === false) {\n this.value.push(parseInt(item));\n }\n }\n }\n },\n methods: {\n // 搜索\n toggleSearch() {\n this.$emit(\"update:showSearch\", !this.showSearch);\n },\n // 刷新\n refresh() {\n this.$emit(\"queryTable\");\n },\n // 右侧列表元素变化\n dataChange(data) {\n for (let item in this.columns) {\n const key = this.columns[item].key;\n this.columns[item].visible = !data.includes(key);\n }\n },\n // 打开显隐列dialog\n showColumn() {\n this.open = true;\n },\n // 勾选\n checkboxChange(event, item) {\n item.visible = event;\n // 通知父组件更新\n this.$emit('update:columns', this.localColumns);\n },\n // 拖拽结束\n onDragEnd(event) {\n // 拖拽结束后,通知父组件列顺序已改变\n this.$emit('update:columns', this.localColumns);\n this.$emit('columns-order-changed', this.localColumns);\n }\n },\n };\n </script>\n <style lang=\"scss\" scoped>\n ::v-deep .el-transfer__button {\n border-radius: 50%;\n padding: 12px;\n display: block;\n margin-left: 0px;\n }\n ::v-deep .el-transfer__button:first-child {\n margin-bottom: 10px;\n }\n \n .drag-item {\n padding: 8px;\n cursor: move;\n border-bottom: 1px solid #ebeef5;\n display: flex;\n align-items: center;\n \n &:hover {\n background-color: #f5f7fa;\n }\n }\n \n .drag-handle {\n color: #909399;\n \n &:hover {\n color: #409eff;\n }\n }\n \n </style>\n ", "::v-deep .el-transfer__button {\n border-radius: 50%;\n padding: 12px;\n display: block;\n margin-left: 0px;\n}\n\n::v-deep .el-transfer__button:first-child {\n margin-bottom: 10px;\n}\n\n.drag-item {\n padding: 8px;\n cursor: move;\n border-bottom: 1px solid #ebeef5;\n display: flex;\n align-items: center;\n}\n.drag-item:hover {\n background-color: #f5f7fa;\n}\n\n.drag-handle {\n color: #909399;\n}\n.drag-handle:hover {\n color: #409eff;\n}\n\n/*# sourceMappingURL=rightToolbar.vue.map */"]
1729
+ },
1730
+ media: undefined
1731
+ });
1732
+ };
1733
+ /* scoped */
1734
+ var __vue_scope_id__$4 = "data-v-d5778a5c";
1735
+ /* module identifier */
1736
+ var __vue_module_identifier__$4 = undefined;
1737
+ /* functional template */
1738
+ var __vue_is_functional_template__$4 = false;
1739
+ /* style inject SSR */
1740
+
1741
+ /* style inject shadow dom */
1742
+
1743
+ var __vue_component__$4 = /*#__PURE__*/normalizeComponent({
1744
+ render: __vue_render__$3,
1745
+ staticRenderFns: __vue_staticRenderFns__$3
1746
+ }, __vue_inject_styles__$4, __vue_script__$4, __vue_scope_id__$4, __vue_is_functional_template__$4, __vue_module_identifier__$4, false, createInjector, undefined, undefined);
1747
+
1748
+ var script$3 = {
1749
+ props: {
1750
+ // queryParams: {
1751
+ // type: Object,
1752
+ // required: true
1753
+ // },
1754
+ queryItems: {
1755
+ type: Array,
1756
+ required: true
1757
+ },
1758
+ size: {
1759
+ type: String,
1760
+ "default": 'mini'
1761
+ },
1762
+ labelWidth: {
1763
+ type: Number,
1764
+ "default": 80
1765
+ },
1766
+ inputWidth: {
1767
+ type: Number,
1768
+ "default": 200
1769
+ },
1770
+ lineClamp: {
1771
+ type: Number,
1772
+ "default": 1
1773
+ },
1774
+ inline: {
1775
+ type: Boolean,
1776
+ "default": true
1777
+ }
1778
+ },
1779
+ watch: {
1780
+ queryItems: {
1781
+ handler: function handler(val) {
1782
+ this.reset();
1783
+ },
1784
+ deep: true,
1785
+ immediate: true
1786
+ }
1787
+ },
1788
+ created: function created() {},
1789
+ data: function data() {
1790
+ return {
1791
+ queryParams: {},
1792
+ queryFormItems: [],
1793
+ formMaxHeight: 0,
1794
+ expand: false,
1795
+ needExpand: false,
1796
+ // 用于展示窗口大小变化绑定
1797
+ $_sidebarElm: null,
1798
+ $_resizeHandler: null
1799
+ };
1800
+ },
1801
+ computed: {
1802
+ labelWidthStr: function labelWidthStr() {
1803
+ if (typeof this.labelWidth === 'number') {
1804
+ return this.labelWidth + 'px';
1805
+ }
1806
+ return this.labelWidth + 'px';
1807
+ },
1808
+ inputStyle: function inputStyle() {
1809
+ return {
1810
+ width: this.inputWidth + 'px'
1811
+ };
1812
+ },
1813
+ dateRangeStyle: function dateRangeStyle() {
1814
+ return {
1815
+ width: this.inputWidth * 2 + this.labelWidth + 10 + 'px'
1816
+ };
1817
+ }
1818
+ },
1819
+ mounted: function mounted() {
1820
+ var _this = this;
1821
+ this.$nextTick(function () {
1822
+ _this.formMaxHeight = _this.measureHeight() * _this.lineClamp;
1823
+ // this.handleNeedExpand()
1824
+ _this.redraw();
1825
+ _this.bindResize();
1826
+ setTimeout(function () {
1827
+ _this.$_resizeHandler && _this.$_resizeHandler();
1828
+ }, 100);
1829
+ });
1830
+ },
1831
+ activated: function activated() {
1832
+ if (!this.$_resizeHandler) {
1833
+ this.bindResize();
1834
+ }
1835
+ },
1836
+ beforeDestroy: function beforeDestroy() {
1837
+ this.unbindResize();
1838
+ },
1839
+ deactivated: function deactivated() {
1840
+ this.unbindResize();
1841
+ },
1842
+ methods: {
1843
+ $_sidebarResizeHandler: function $_sidebarResizeHandler(e) {
1844
+ if (e.propertyName === 'width') {
1845
+ this.$_resizeHandler();
1846
+ }
1847
+ },
1848
+ // 展示窗口大小变化绑定
1849
+ bindResize: function bindResize() {
1850
+ var _this2 = this;
1851
+ this.$_resizeHandler = debounce(function () {
1852
+ _this2.drawTime = 0;
1853
+ _this2.queryFormItems.forEach(function (item) {
1854
+ item.hidden = false;
1855
+ });
1856
+ _this2.$nextTick(function () {
1857
+ _this2.handleNeedExpand();
1858
+ _this2.redraw();
1859
+ });
1860
+ }, 100);
1861
+ window.addEventListener('resize', this.$_resizeHandler);
1862
+ this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0];
1863
+ this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler);
1864
+ },
1865
+ // unbindResize
1866
+ unbindResize: function unbindResize() {
1867
+ window.removeEventListener('resize', this.$_resizeHandler);
1868
+ this.$_resizeHandler = null;
1869
+ this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler);
1870
+ },
1871
+ handelExpand: function handelExpand() {
1872
+ this.drawTime = 0;
1873
+ this.expand = !this.expand;
1874
+ this.$_resizeHandler();
1875
+ },
1876
+ handleNeedExpand: function handleNeedExpand() {
1877
+ var _this$$refs;
1878
+ var $queryForm = (_this$$refs = this.$refs) === null || _this$$refs === void 0 || (_this$$refs = _this$$refs.queryForm) === null || _this$$refs === void 0 ? void 0 : _this$$refs.$el;
1879
+ var scrollHeight = $queryForm.scrollHeight;
1880
+ if (this.formMaxHeight < scrollHeight) {
1881
+ this.needExpand = true;
1882
+ } else {
1883
+ this.needExpand = false;
1884
+ }
1885
+ },
1886
+ //
1887
+ redraw: function redraw() {
1888
+ var _this$$refs2,
1889
+ _this3 = this;
1890
+ if (typeof this.drawTime == 'undefined') {
1891
+ this.drawTime = 0;
1892
+ }
1893
+ if (this.drawTime > 60) {
1894
+ return;
1895
+ }
1896
+ // 确保DOM完全渲染后再执行某些操作
1897
+ var $queryForm = (_this$$refs2 = this.$refs) === null || _this$$refs2 === void 0 || (_this$$refs2 = _this$$refs2.queryForm) === null || _this$$refs2 === void 0 ? void 0 : _this$$refs2.$el;
1898
+ if ($queryForm) {
1899
+ $queryForm.style.overflow = "hidden";
1900
+ }
1901
+ this.$nextTick(function () {
1902
+ var scrollHeight = $queryForm.scrollHeight;
1903
+ var clientHeight = $queryForm.clientHeight;
1904
+ if (scrollHeight > clientHeight) {
1905
+ _this3.drawTime++;
1906
+ var noHiddenItems = _this3.queryFormItems.filter(function (item) {
1907
+ return !item.hidden;
1908
+ });
1909
+ var lastItem = noHiddenItems.find(function (item, index) {
1910
+ return noHiddenItems.length - 1 == index;
1911
+ });
1912
+ if (lastItem) {
1913
+ _this3.$set(lastItem, 'hidden', true);
1914
+ _this3.redraw();
1915
+ }
1916
+ }
1917
+ // 判断是否有滚动条
1918
+ });
1919
+ },
1920
+ //测量单行高度 + margin-top + margin-bottom
1921
+ measureHeight: function measureHeight() {
1922
+ var queryFormBtn = this.$refs.queryFormBtn;
1923
+ if (queryFormBtn) {
1924
+ var queryFormBtnHeight = queryFormBtn.$el.clientHeight || 29;
1925
+ var queryFormItemsMarginTop = parseInt(window.getComputedStyle(queryFormBtn.$el).marginTop);
1926
+ var queryFormItemsMarginBottom = parseInt(window.getComputedStyle(queryFormBtn.$el).marginBottom);
1927
+ return queryFormBtnHeight + queryFormItemsMarginTop + queryFormItemsMarginBottom;
1928
+ }
1929
+ },
1930
+ reset: function reset() {
1931
+ var _this4 = this;
1932
+ this.queryItems.forEach(function (item) {
1933
+ _this4.$set(_this4.queryParams, item.prop, null);
1934
+ });
1935
+ this.queryFormItems = this.queryItems.map(function (item) {
1936
+ var placeholder = item.placeholder;
1937
+ if (!placeholder) {
1938
+ switch (item.type) {
1939
+ case 'input':
1940
+ placeholder = '请输入' + item.label;
1941
+ break;
1942
+ default:
1943
+ placeholder = '请选择' + item.label;
1944
+ }
1945
+ }
1946
+ return _objectSpread2(_objectSpread2({}, item), {}, {
1947
+ placeholder: placeholder,
1948
+ hidden: false
1949
+ });
1950
+ });
1951
+ },
1952
+ resetQuery: function resetQuery() {
1953
+ var _this$$refs$queryForm;
1954
+ (_this$$refs$queryForm = this.$refs.queryForm) === null || _this$$refs$queryForm === void 0 || _this$$refs$queryForm.resetFields();
1955
+ this.handleQuery();
1956
+ },
1957
+ handleQuery: function handleQuery() {
1958
+ this.$emit('queryTable', this.queryParams);
1959
+ }
1960
+ }
1961
+ };
1962
+
1963
+ /* script */
1964
+ var __vue_script__$3 = script$3;
1965
+
1966
+ /* template */
1967
+ var __vue_render__$2 = function __vue_render__() {
1968
+ var _vm = this;
1969
+ var _h = _vm.$createElement;
1970
+ var _c = _vm._self._c || _h;
1971
+ return _vm.queryItems.length ? _c("div", {
1972
+ staticClass: "container-main el-crud-query"
1973
+ }, [_c("el-form", {
1974
+ ref: "queryForm",
1975
+ staticClass: "el-crud-query-form",
1976
+ style: {
1977
+ maxHeight: _vm.expand ? "" : _vm.formMaxHeight + "px"
1978
+ },
1979
+ attrs: {
1980
+ model: _vm.queryParams,
1981
+ size: _vm.size,
1982
+ inline: _vm.inline,
1983
+ "label-width": _vm.labelWidthStr
1984
+ },
1985
+ nativeOn: {
1986
+ submit: function submit($event) {
1987
+ $event.preventDefault();
1988
+ }
1989
+ }
1990
+ }, [_vm._l(_vm.queryFormItems, function (item) {
1991
+ return _c("el-form-item", {
1992
+ directives: [{
1993
+ name: "show",
1994
+ rawName: "v-show",
1995
+ value: _vm.expand || !item.hidden,
1996
+ expression: "expand || !item.hidden"
1997
+ }],
1998
+ key: item.prop,
1999
+ attrs: {
2000
+ label: item.label,
2001
+ prop: item.prop
2002
+ }
2003
+ }, [item.type === "input" ? _c("el-input", {
2004
+ style: _vm.inputStyle,
2005
+ attrs: {
2006
+ placeholder: item.placeholder,
2007
+ clearable: ""
2008
+ },
2009
+ nativeOn: {
2010
+ keyup: function keyup($event) {
2011
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
2012
+ return null;
2013
+ }
2014
+ return _vm.handleQuery.apply(null, arguments);
2015
+ }
2016
+ },
2017
+ model: {
2018
+ value: _vm.queryParams[item.prop],
2019
+ callback: function callback($$v) {
2020
+ _vm.$set(_vm.queryParams, item.prop, $$v);
2021
+ },
2022
+ expression: "queryParams[item.prop]"
2023
+ }
2024
+ }) : item.type === "select" ? _c("el-select", {
2025
+ style: _vm.inputStyle,
2026
+ attrs: {
2027
+ placeholder: item.placeholder,
2028
+ clearable: "",
2029
+ filterable: ""
2030
+ },
2031
+ on: {
2032
+ "visible-change": function visibleChange($event) {
2033
+ return item.visibleChange && item.visibleChange($event, _vm.queryParams);
2034
+ }
2035
+ },
2036
+ model: {
2037
+ value: _vm.queryParams[item.prop],
2038
+ callback: function callback($$v) {
2039
+ _vm.$set(_vm.queryParams, item.prop, $$v);
2040
+ },
2041
+ expression: "queryParams[item.prop]"
2042
+ }
2043
+ }, [typeof item.options === "function" ? _vm._l(item.options(), function (option) {
2044
+ return _c("el-option", {
2045
+ key: option.value,
2046
+ attrs: {
2047
+ label: option.label,
2048
+ value: option.value
2049
+ }
2050
+ });
2051
+ }) : _vm._l(item.options, function (option) {
2052
+ return _c("el-option", {
2053
+ key: option.value,
2054
+ attrs: {
2055
+ label: option.label,
2056
+ value: option.value
2057
+ }
2058
+ });
2059
+ })], 2) : item.type === "date" ? _c("el-date-picker", {
2060
+ style: item.range ? _vm.dateRangeStyle : _vm.inputStyle,
2061
+ attrs: {
2062
+ type: item.range ? "daterange" : "date",
2063
+ placeholder: item.placeholder,
2064
+ clearable: "",
2065
+ "start-placeholder": item["startPlaceholder"] || "开始日期",
2066
+ "end-placeholder": item["endPlaceholder"] || "结束日期",
2067
+ "range-separator": item["rangeSeparator"],
2068
+ "value-format": item["valueFormat"] || "yyyy-MM-dd"
2069
+ },
2070
+ model: {
2071
+ value: _vm.queryParams[item.prop],
2072
+ callback: function callback($$v) {
2073
+ _vm.$set(_vm.queryParams, item.prop, $$v);
2074
+ },
2075
+ expression: "queryParams[item.prop]"
2076
+ }
2077
+ }) : item.type === "datetime" ? _c("el-date-picker", {
2078
+ style: item.range ? _vm.dateRangeStyle : _vm.inputStyle,
2079
+ attrs: {
2080
+ type: item.range ? "datetimerange" : "datetime",
2081
+ placeholder: item.placeholder,
2082
+ clearable: "",
2083
+ "start-placeholder": item["startPlaceholder"] || "开始时间",
2084
+ "end-placeholder": item["endPlaceholder"] || "结束时间",
2085
+ "range-separator": item["rangeSeparator"],
2086
+ "value-format": item["valueFormat"] || "yyyy-MM-dd HH:mm:ss"
2087
+ },
2088
+ model: {
2089
+ value: _vm.queryParams[item.prop],
2090
+ callback: function callback($$v) {
2091
+ _vm.$set(_vm.queryParams, item.prop, $$v);
2092
+ },
2093
+ expression: "queryParams[item.prop]"
2094
+ }
2095
+ }) : _vm._e()], 1);
2096
+ }), _vm._v(" "), _c("el-form-item", {
2097
+ ref: "queryFormBtn",
2098
+ attrs: {
2099
+ label: " "
2100
+ }
2101
+ }, [_c("el-button", {
2102
+ attrs: {
2103
+ type: "primary",
2104
+ icon: "el-icon-search"
2105
+ },
2106
+ on: {
2107
+ click: _vm.handleQuery
2108
+ }
2109
+ }, [_vm._v("搜索")]), _vm._v(" "), _c("el-button", {
2110
+ attrs: {
2111
+ icon: "el-icon-refresh"
2112
+ },
2113
+ on: {
2114
+ click: _vm.resetQuery
2115
+ }
2116
+ }, [_vm._v("重置")]), _vm._v(" "), _vm.needExpand ? _c("el-button", {
2117
+ attrs: {
2118
+ type: "text"
2119
+ },
2120
+ on: {
2121
+ click: _vm.handelExpand
2122
+ }
2123
+ }, [_c("span", [_vm._v("更多")]), _vm._v(" "), _c("i", {
2124
+ "class": _vm.expand ? "el-icon-arrow-up" : "el-icon-arrow-down"
2125
+ })]) : _vm._e()], 1)], 2)], 1) : _vm._e();
2126
+ };
2127
+ var __vue_staticRenderFns__$2 = [];
2128
+ __vue_render__$2._withStripped = true;
2129
+
2130
+ /* style */
2131
+ var __vue_inject_styles__$3 = function __vue_inject_styles__(inject) {
2132
+ if (!inject) return;
2133
+ inject("data-v-ba1b80d0_0", {
2134
+ source: ".container-main[data-v-ba1b80d0] {\n background-color: #fff;\n}\n.el-crud-query[data-v-ba1b80d0] {\n overflow: hidden;\n padding: 10px;\n}\n.el-crud-query .el-crud-query-form[data-v-ba1b80d0] {\n margin-bottom: -10px;\n}\n.el-crud-query .el-crud-query-form[data-v-ba1b80d0] .el-form-item--mini.el-form-item, .el-crud-query .el-crud-query-form[data-v-ba1b80d0] .el-form-item--small.el-form-item {\n margin-bottom: 10px;\n}\n\n/*# sourceMappingURL=queryForm.vue.map */",
2135
+ map: {
2136
+ "version": 3,
2137
+ "sources": ["/Users/tonwe/git/el-crud-page/src/queryForm.vue", "queryForm.vue"],
2138
+ "names": [],
2139
+ "mappings": "AAgUA;EACA,sBAAA;AC/TA;ADiUA;EACA,gBAAA;EACA,aAAA;AC9TA;AD+TA;EACA,oBAAA;AC7TA;ADgUA;EACA,mBAAA;AC9TA;;AAEA,wCAAwC",
2140
+ "file": "queryForm.vue",
2141
+ "sourcesContent": ["<template>\n <!-- \n \n queryItems: [\n // input string\n {\n label: \"项目名称\",\n prop: \"name\",\n type: \"input\",\n placeholder: \"请输入项目名称\",\n },\n // select\n {\n label: \"申办单位\",\n prop: \"sponsorId\",\n type: \"select\",\n placeholder: \"请选择申办单位\",\n options: [],\n },\n // date日期\n {\n label: \"创建日期\",\n prop: [\"createDateStart\", \"createDateEnd\"],\n type: \"date\",\n range: true,\n placeholder: \"请选择创建日期\",\n },\n // datetime 时间\n {\n label: \"更新时间\",\n prop: \"updateTime\",\n type: \"datetime\",\n placeholder: \"请选择更新时间\",\n },\n ],\n \n -->\n <div class=\"container-main el-crud-query\" v-if=\"queryItems.length\">\n <el-form :model=\"queryParams\" :size=\"size\" :style=\"{ maxHeight: expand ? '' : (formMaxHeight + 'px') }\"\n ref=\"queryForm\" :inline=\"inline\" :label-width=\"labelWidthStr\" class=\"el-crud-query-form\" @submit.native.prevent>\n <el-form-item v-for=\"item in queryFormItems\" v-show=\"expand || !item.hidden\" :label=\"item.label\"\n :prop=\"item.prop\" :key=\"item.prop\">\n <el-input v-if=\"item.type === 'input'\" v-model=\"queryParams[item.prop]\" :placeholder=\"item.placeholder\"\n clearable @keyup.enter.native=\"handleQuery\" :style=\"inputStyle\"></el-input>\n <el-select v-else-if=\"item.type === 'select'\" v-model=\"queryParams[item.prop]\"\n :placeholder=\"item.placeholder\" clearable filterable\n @visible-change=\"($event) => item.visibleChange && item.visibleChange($event, queryParams)\"\n :style=\"inputStyle\">\n \n <template v-if=\"typeof item.options === 'function'\">\n <el-option v-for=\"option in item.options()\" :key=\"option.value\" :label=\"option.label\" :value=\"option.value\"></el-option>\n </template>\n <template v-else>\n <el-option v-for=\"option in item.options\" :key=\"option.value\" :label=\"option.label\" :value=\"option.value\"></el-option>\n </template>\n\n </el-select>\n\n <el-date-picker v-else-if=\"item.type === 'date'\" :type=\"item.range ? 'daterange' : 'date'\"\n v-model=\"queryParams[item.prop]\" :placeholder=\"item.placeholder\" clearable\n :start-placeholder=\"item['startPlaceholder'] || '开始日期'\"\n :end-placeholder=\"item['endPlaceholder'] || '结束日期'\" :range-separator=\"item['rangeSeparator']\"\n :value-format=\"item['valueFormat'] || 'yyyy-MM-dd'\"\n :style=\"item.range ? dateRangeStyle : inputStyle\"></el-date-picker>\n <el-date-picker v-else-if=\"item.type === 'datetime'\" :type=\"item.range ? 'datetimerange' : 'datetime'\"\n v-model=\"queryParams[item.prop]\" :placeholder=\"item.placeholder\" clearable\n :start-placeholder=\"item['startPlaceholder'] || '开始时间'\"\n :end-placeholder=\"item['endPlaceholder'] || '结束时间'\" :range-separator=\"item['rangeSeparator']\"\n :value-format=\"item['valueFormat'] || 'yyyy-MM-dd HH:mm:ss'\"\n :style=\"item.range ? dateRangeStyle : inputStyle\"></el-date-picker>\n </el-form-item>\n <el-form-item label=\" \" ref=\"queryFormBtn\">\n <el-button type=\"primary\" icon=\"el-icon-search\" @click=\"handleQuery\">搜索</el-button>\n <el-button icon=\"el-icon-refresh\" @click=\"resetQuery\">重置</el-button>\n <el-button type=\"text\" @click=\"handelExpand\" v-if=\"needExpand\">\n <span>更多</span>\n <i :class=\"expand ? 'el-icon-arrow-up' : 'el-icon-arrow-down'\"></i>\n </el-button>\n </el-form-item>\n </el-form>\n </div>\n\n</template>\n\n<script>\n\nimport { debounce } from './utils'\nexport default {\n props: {\n\n // queryParams: {\n // type: Object,\n // required: true\n // },\n queryItems: {\n type: Array,\n required: true\n },\n size: {\n type: String,\n default: 'mini'\n },\n labelWidth: {\n type: Number,\n default: 80\n },\n inputWidth: {\n type: Number,\n default: 200\n },\n lineClamp: {\n type: Number,\n default: 1\n },\n inline: {\n type: Boolean,\n default: true\n }\n\n },\n watch: {\n queryItems: {\n handler(val) {\n this.reset()\n },\n deep: true,\n immediate: true\n }\n },\n created() {\n \n },\n data() {\n return {\n queryParams: {},\n queryFormItems: [],\n formMaxHeight: 0,\n expand: false,\n needExpand: false,\n // 用于展示窗口大小变化绑定\n $_sidebarElm: null,\n $_resizeHandler: null\n }\n },\n computed: {\n labelWidthStr() {\n if (typeof this.labelWidth === 'number') {\n return this.labelWidth + 'px';\n }\n return this.labelWidth + 'px';\n },\n inputStyle() {\n return {\n width: this.inputWidth + 'px'\n };\n },\n dateRangeStyle() {\n return {\n width: (this.inputWidth * 2 + this.labelWidth + 10) + 'px'\n };\n }\n },\n mounted() {\n this.$nextTick(() => {\n this.formMaxHeight = this.measureHeight() * this.lineClamp; \n // this.handleNeedExpand()\n this.redraw();\n this.bindResize();\n setTimeout(() => {\n this.$_resizeHandler && this.$_resizeHandler();\n }, 100);\n \n });\n\n },\n activated() {\n if (!this.$_resizeHandler) {\n this.bindResize();\n }\n },\n beforeDestroy() {\n this.unbindResize();\n },\n deactivated() {\n this.unbindResize();\n },\n methods: {\n $_sidebarResizeHandler(e) {\n if (e.propertyName === 'width') {\n this.$_resizeHandler()\n }\n },\n // 展示窗口大小变化绑定\n bindResize() {\n this.$_resizeHandler = debounce(() => {\n this.drawTime = 0;\n this.queryFormItems.forEach(item => {\n item.hidden = false;\n });\n this.$nextTick(() => {\n this.handleNeedExpand()\n this.redraw();\n })\n\n }, 100)\n\n window.addEventListener('resize', this.$_resizeHandler);\n this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]\n this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)\n\n\n },\n // unbindResize \n unbindResize() {\n window.removeEventListener('resize', this.$_resizeHandler)\n this.$_resizeHandler = null\n this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)\n },\n handelExpand() {\n this.drawTime = 0;\n this.expand = !this.expand;\n this.$_resizeHandler();\n\n },\n handleNeedExpand() {\n const $queryForm = this.$refs?.queryForm?.$el;\n let scrollHeight = $queryForm.scrollHeight;\n if ( this.formMaxHeight < scrollHeight) {\n this.needExpand = true;\n } else {\n this.needExpand = false;\n }\n\n },\n // \n redraw() {\n if (typeof this.drawTime == 'undefined') {\n this.drawTime = 0;\n }\n if (this.drawTime > 60) {\n return;\n }\n // 确保DOM完全渲染后再执行某些操作\n const $queryForm = this.$refs?.queryForm?.$el;\n if ($queryForm) {\n $queryForm.style.overflow = \"hidden\";\n }\n this.$nextTick(() => {\n let scrollHeight = $queryForm.scrollHeight;\n let clientHeight = $queryForm.clientHeight;\n if (scrollHeight > clientHeight) {\n this.drawTime++;\n let noHiddenItems = this.queryFormItems.filter(item => !item.hidden);\n let lastItem = noHiddenItems.find((item, index) => (noHiddenItems.length - 1 == index))\n if (lastItem) {\n this.$set(lastItem, 'hidden', true);\n this.redraw();\n }\n\n }\n // 判断是否有滚动条\n\n });\n\n\n },\n\n //测量单行高度 + margin-top + margin-bottom\n measureHeight() {\n let queryFormBtn = this.$refs.queryFormBtn;\n if(queryFormBtn){\n let queryFormBtnHeight = queryFormBtn.$el.clientHeight || 29;\n let queryFormItemsMarginTop = parseInt(window.getComputedStyle(queryFormBtn.$el).marginTop);\n let queryFormItemsMarginBottom = parseInt(window.getComputedStyle(queryFormBtn.$el).marginBottom);\n return queryFormBtnHeight + queryFormItemsMarginTop + queryFormItemsMarginBottom\n }\n \n },\n\n reset() {\n this.queryItems.forEach(item => {\n this.$set(this.queryParams, item.prop, null);\n });\n this.queryFormItems = this.queryItems.map(item => {\n let placeholder = item.placeholder;\n if( !placeholder){\n\n switch (item.type) {\n case 'input':\n placeholder = '请输入' + item.label;\n break;\n default:\n placeholder = '请选择' + item.label;\n }\n\n }\n\n\n return {\n ...item,\n placeholder,\n hidden: false\n }\n }); \n },\n resetQuery() {\n\n this.$refs.queryForm?.resetFields();\n this.handleQuery();\n },\n handleQuery() {\n this.$emit('queryTable', this.queryParams);\n }\n\n }\n}\n\n</script>\n\n<style scoped lang=\"scss\">\n.container-main{\n background-color: #fff;\n}\n.el-crud-query{\n overflow: hidden;\n padding: 10px;\n .el-crud-query-form {\n margin-bottom: -10px;\n\n &::v-deep {\n .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item{\n margin-bottom: 10px;\n }\n }\n }\n}\n\n\n</style>\n", ".container-main {\n background-color: #fff;\n}\n\n.el-crud-query {\n overflow: hidden;\n padding: 10px;\n}\n.el-crud-query .el-crud-query-form {\n margin-bottom: -10px;\n}\n.el-crud-query .el-crud-query-form::v-deep .el-form-item--mini.el-form-item, .el-crud-query .el-crud-query-form::v-deep .el-form-item--small.el-form-item {\n margin-bottom: 10px;\n}\n\n/*# sourceMappingURL=queryForm.vue.map */"]
2142
+ },
2143
+ media: undefined
2144
+ });
2145
+ };
2146
+ /* scoped */
2147
+ var __vue_scope_id__$3 = "data-v-ba1b80d0";
2148
+ /* module identifier */
2149
+ var __vue_module_identifier__$3 = undefined;
2150
+ /* functional template */
2151
+ var __vue_is_functional_template__$3 = false;
2152
+ /* style inject SSR */
2153
+
2154
+ /* style inject shadow dom */
2155
+
2156
+ var __vue_component__$3 = /*#__PURE__*/normalizeComponent({
2157
+ render: __vue_render__$2,
2158
+ staticRenderFns: __vue_staticRenderFns__$2
2159
+ }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, false, createInjector, undefined, undefined);
2160
+
2161
+ //
2162
+ //
2163
+ //
2164
+ //
2165
+ //
2166
+ //
2167
+ //
2168
+ //
2169
+ //
2170
+ //
2171
+ //
2172
+ //
2173
+ //
2174
+ //
2175
+ //
2176
+ //
2177
+ //
2178
+
2179
+ var script$2 = {
2180
+ name: 'Pagination',
2181
+ props: {
2182
+ total: {
2183
+ required: true,
2184
+ type: Number
2185
+ },
2186
+ page: {
2187
+ type: Number,
2188
+ "default": 1
2189
+ },
2190
+ limit: {
2191
+ type: Number,
2192
+ "default": 20
2193
+ },
2194
+ pageSizes: {
2195
+ type: Array,
2196
+ "default": function _default() {
2197
+ return [10, 20, 30, 50];
2198
+ }
2199
+ },
2200
+ // 移动端页码按钮的数量端默认值5
2201
+ pagerCount: {
2202
+ type: Number,
2203
+ "default": document.body.clientWidth < 992 ? 5 : 7
2204
+ },
2205
+ layout: {
2206
+ type: String,
2207
+ "default": 'total, sizes, prev, pager, next, jumper'
2208
+ },
2209
+ background: {
2210
+ type: Boolean,
2211
+ "default": true
2212
+ },
2213
+ autoScroll: {
2214
+ type: Boolean,
2215
+ "default": true
2216
+ },
2217
+ hidden: {
2218
+ type: Boolean,
2219
+ "default": false
2220
+ }
2221
+ },
2222
+ data: function data() {
2223
+ return {};
2224
+ },
2225
+ computed: {
2226
+ currentPage: {
2227
+ get: function get() {
2228
+ return this.page;
2229
+ },
2230
+ set: function set(val) {
2231
+ this.$emit('update:page', val);
2232
+ }
2233
+ },
2234
+ pageSize: {
2235
+ get: function get() {
2236
+ return this.limit;
2237
+ },
2238
+ set: function set(val) {
2239
+ this.$emit('update:limit', val);
2240
+ }
2241
+ }
2242
+ },
2243
+ methods: {
2244
+ handleSizeChange: function handleSizeChange(val) {
2245
+ if (this.currentPage * val > this.total) {
2246
+ this.currentPage = 1;
2247
+ }
2248
+ this.$emit('pagination', {
2249
+ page: this.currentPage,
2250
+ limit: val
2251
+ });
2252
+ if (this.autoScroll) {
2253
+ scrollTo(0, 800);
2254
+ }
2255
+ },
2256
+ handleCurrentChange: function handleCurrentChange(val) {
2257
+ this.$emit('pagination', {
2258
+ page: val,
2259
+ limit: this.pageSize
2260
+ });
2261
+ if (this.autoScroll) {
2262
+ scrollTo(0, 800);
2263
+ }
2264
+ }
2265
+ }
2266
+ };
2267
+
2268
+ /* script */
2269
+ var __vue_script__$2 = script$2;
2270
+
2271
+ /* template */
2272
+ var __vue_render__$1 = function __vue_render__() {
2273
+ var _vm = this;
2274
+ var _h = _vm.$createElement;
2275
+ var _c = _vm._self._c || _h;
2276
+ return _c("div", {
2277
+ staticClass: "pagination-container",
2278
+ "class": {
2279
+ hidden: _vm.hidden
2280
+ }
2281
+ }, [_c("el-pagination", _vm._b({
2282
+ attrs: {
2283
+ background: _vm.background,
2284
+ "current-page": _vm.currentPage,
2285
+ "page-size": _vm.pageSize,
2286
+ layout: _vm.layout,
2287
+ "page-sizes": _vm.pageSizes,
2288
+ "pager-count": _vm.pagerCount,
2289
+ total: _vm.total
2290
+ },
2291
+ on: {
2292
+ "update:currentPage": function updateCurrentPage($event) {
2293
+ _vm.currentPage = $event;
2294
+ },
2295
+ "update:current-page": function updateCurrentPage($event) {
2296
+ _vm.currentPage = $event;
2297
+ },
2298
+ "update:pageSize": function updatePageSize($event) {
2299
+ _vm.pageSize = $event;
2300
+ },
2301
+ "update:page-size": function updatePageSize($event) {
2302
+ _vm.pageSize = $event;
2303
+ },
2304
+ "size-change": _vm.handleSizeChange,
2305
+ "current-change": _vm.handleCurrentChange
2306
+ }
2307
+ }, "el-pagination", _vm.$attrs, false))], 1);
2308
+ };
2309
+ var __vue_staticRenderFns__$1 = [];
2310
+ __vue_render__$1._withStripped = true;
2311
+
2312
+ /* style */
2313
+ var __vue_inject_styles__$2 = function __vue_inject_styles__(inject) {
2314
+ if (!inject) return;
2315
+ inject("data-v-7ec7699b_0", {
2316
+ source: "\n.pagination-container[data-v-7ec7699b] {\n background: #fff;\n padding: 32px 16px;\n}\n.pagination-container.hidden[data-v-7ec7699b] {\n display: none;\n}\n",
2317
+ map: {
2318
+ "version": 3,
2319
+ "sources": ["/Users/tonwe/git/el-crud-page/src/pagination.vue"],
2320
+ "names": [],
2321
+ "mappings": ";AA0GA;EACA,gBAAA;EACA,kBAAA;AACA;AACA;EACA,aAAA;AACA",
2322
+ "file": "pagination.vue",
2323
+ "sourcesContent": ["<template>\n <div :class=\"{'hidden':hidden}\" class=\"pagination-container\">\n <el-pagination\n :background=\"background\"\n :current-page.sync=\"currentPage\"\n :page-size.sync=\"pageSize\"\n :layout=\"layout\"\n :page-sizes=\"pageSizes\"\n :pager-count=\"pagerCount\"\n :total=\"total\"\n v-bind=\"$attrs\"\n @size-change=\"handleSizeChange\"\n @current-change=\"handleCurrentChange\"\n />\n </div>\n</template>\n\n<script>\nimport { scrollTo } from './utils/scroll-to'\n\nexport default {\n name: 'Pagination',\n props: {\n total: {\n required: true,\n type: Number\n },\n page: {\n type: Number,\n default: 1\n },\n limit: {\n type: Number,\n default: 20\n },\n pageSizes: {\n type: Array,\n default() {\n return [10, 20, 30, 50]\n }\n },\n // 移动端页码按钮的数量端默认值5\n pagerCount: {\n type: Number,\n default: document.body.clientWidth < 992 ? 5 : 7\n },\n layout: {\n type: String,\n default: 'total, sizes, prev, pager, next, jumper'\n },\n background: {\n type: Boolean,\n default: true\n },\n autoScroll: {\n type: Boolean,\n default: true\n },\n hidden: {\n type: Boolean,\n default: false\n }\n },\n data() {\n return {\n };\n },\n computed: {\n currentPage: {\n get() {\n return this.page\n },\n set(val) {\n this.$emit('update:page', val)\n }\n },\n pageSize: {\n get() {\n return this.limit\n },\n set(val) {\n this.$emit('update:limit', val)\n }\n }\n },\n methods: {\n handleSizeChange(val) {\n if (this.currentPage * val > this.total) {\n this.currentPage = 1\n }\n this.$emit('pagination', { page: this.currentPage, limit: val })\n if (this.autoScroll) {\n scrollTo(0, 800)\n }\n },\n handleCurrentChange(val) {\n this.$emit('pagination', { page: val, limit: this.pageSize })\n if (this.autoScroll) {\n scrollTo(0, 800)\n }\n }\n }\n}\n</script>\n\n<style scoped>\n.pagination-container {\n background: #fff;\n padding: 32px 16px;\n}\n.pagination-container.hidden {\n display: none;\n}\n</style>\n"]
2324
+ },
2325
+ media: undefined
2326
+ });
2327
+ };
2328
+ /* scoped */
2329
+ var __vue_scope_id__$2 = "data-v-7ec7699b";
2330
+ /* module identifier */
2331
+ var __vue_module_identifier__$2 = undefined;
2332
+ /* functional template */
2333
+ var __vue_is_functional_template__$2 = false;
2334
+ /* style inject SSR */
2335
+
2336
+ /* style inject shadow dom */
2337
+
2338
+ var __vue_component__$2 = /*#__PURE__*/normalizeComponent({
2339
+ render: __vue_render__$1,
2340
+ staticRenderFns: __vue_staticRenderFns__$1
2341
+ }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, false, createInjector, undefined, undefined);
2342
+
2343
+ var script$1 = {
2344
+ components: {
2345
+ CrudTable: __vue_component__$5,
2346
+ RightToolbar: __vue_component__$4,
2347
+ QueryForm: __vue_component__$3,
2348
+ Pagination: __vue_component__$2
2349
+ },
2350
+ name: 'Crud',
2351
+ provide: function provide() {
2352
+ return {
2353
+ crud: this
2354
+ };
2355
+ },
2356
+ props: {
2357
+ queryParamsMethod: {
2358
+ type: Function
2359
+ },
2360
+ columns: {
2361
+ type: Array,
2362
+ "default": function _default() {
2363
+ return [];
2364
+ }
2365
+ },
2366
+ queryItems: {
2367
+ type: Array,
2368
+ "default": function _default() {
2369
+ return [];
2370
+ }
2371
+ },
2372
+ queryLineClamp: {
2373
+ type: Number,
2374
+ "default": 1
2375
+ },
2376
+ queryLabelWidth: {
2377
+ type: Number,
2378
+ "default": 80
2379
+ },
2380
+ queryInputWidth: {
2381
+ type: Number,
2382
+ "default": 210
2383
+ },
2384
+ queryInline: {
2385
+ type: Boolean,
2386
+ "default": true
2387
+ },
2388
+ buttons: {
2389
+ type: Array | Function,
2390
+ "default": function _default() {
2391
+ return [];
2392
+ }
2393
+ },
2394
+ tabPanes: {
2395
+ type: Array,
2396
+ "default": function _default() {
2397
+ return [];
2398
+ }
2399
+ },
2400
+ defaultSort: {
2401
+ type: Object,
2402
+ "default": function _default() {
2403
+ return {
2404
+ prop: undefined,
2405
+ order: undefined
2406
+ };
2407
+ }
2408
+ },
2409
+ highlightCol: {
2410
+ type: Boolean,
2411
+ "default": false
2412
+ },
2413
+ resizable: {
2414
+ type: Boolean,
2415
+ "default": false
2416
+ },
2417
+ border: {
2418
+ type: Boolean,
2419
+ "default": false
2420
+ }
2421
+ },
2422
+ watch: {
2423
+ tabPanes: {
2424
+ handler: function handler(val) {
2425
+ if (val.length) {
2426
+ this.tabQuery.tabKey = val[0].name;
2427
+ }
2428
+ },
2429
+ deep: true,
2430
+ immediate: true
2431
+ },
2432
+ "tabQuery.tabKey": {
2433
+ handler: function handler(val) {
2434
+ this.$emit("tabChange", val);
2435
+ }
2436
+ }
2437
+ },
2438
+ computed: {
2439
+ actionButtons: function actionButtons() {
2440
+ var buts = this.buttons;
2441
+ if (typeof buts === 'function') {
2442
+ return buts(this.selections);
2443
+ } else if (buts !== null && buts !== void 0 && buts.length) {
2444
+ return buts;
2445
+ }
2446
+ return [];
2447
+ }
2448
+ },
2449
+ data: function data() {
2450
+ return {
2451
+ listLoading: false,
2452
+ showSearch: true,
2453
+ selections: [],
2454
+ data: [],
2455
+ service: {
2456
+ // 增删改查导出
2457
+ add: null,
2458
+ update: null,
2459
+ "delete": null,
2460
+ page: null,
2461
+ info: null,
2462
+ list: null,
2463
+ "export": null
2464
+ },
2465
+ // 服务
2466
+ queryParams: {
2467
+ // pageNum: 1,
2468
+ // pageSize: 10
2469
+ },
2470
+ // 查询参数
2471
+
2472
+ tabQuery: {
2473
+ tabKey: undefined
2474
+ },
2475
+ // 参数
2476
+ filterParams: {},
2477
+ // 过滤参数
2478
+ pagination: {
2479
+ pageNum: 1,
2480
+ pageSize: 10
2481
+ },
2482
+ orderParams: {
2483
+ orderByRowName: undefined,
2484
+ orderByRule: undefined
2485
+ },
2486
+ total: 0
2487
+ };
2488
+ },
2489
+ created: function created() {},
2490
+ methods: {
2491
+ handleTabClick: function handleTabClick(tab) {
2492
+ this.tabQuery.tabKey = tab.name;
2493
+ this.refresh();
2494
+ },
2495
+ handleSelectionChange: function handleSelectionChange(e) {
2496
+ this.selections = e;
2497
+ },
2498
+ handleQuery: function handleQuery(query) {
2499
+ this.queryParams = query;
2500
+ this.refresh();
2501
+ },
2502
+ handleButtonClick: function handleButtonClick(item) {
2503
+ this.$emit("action", item.action, this.selections);
2504
+ },
2505
+ handleRowAction: function handleRowAction(action, scope) {
2506
+ this.$emit("row-action", action, scope);
2507
+ if (action === 'delete' && this.service["delete"]) {
2508
+ this["delete"](scope);
2509
+ }
2510
+ },
2511
+ handleSortChange: function handleSortChange(column) {
2512
+ this.orderParams.orderByRowName = toLine(column.prop);
2513
+ if (column.order == "descending") {
2514
+ this.orderParams.orderByRule = "desc";
2515
+ } else if (column.order == "ascending") {
2516
+ this.orderParams.orderByRule = "asc";
2517
+ } else {
2518
+ this.orderParams.orderByRule = undefined;
2519
+ this.orderParams.orderByRowName = undefined;
2520
+ }
2521
+ this.refresh();
2522
+ },
2523
+ // 服务
2524
+ setService: function setService(service) {
2525
+ this.service = Object.assign(this.service, service);
2526
+ },
2527
+ // 设置列
2528
+ setColumns: function setColumns(columns) {
2529
+ this.columns = columns;
2530
+ },
2531
+ // 设置数据
2532
+ setData: function setData(data) {
2533
+ // this.crud.data = data;
2534
+ },
2535
+ // 获得查询参数
2536
+ getParams: function getParams() {
2537
+ var _this = this;
2538
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2539
+ var _orderParams;
2540
+ var defaultSort, orderParams, orderByRowName, orderByRule, params;
2541
+ return _regenerator().w(function (_context) {
2542
+ while (1) switch (_context.n) {
2543
+ case 0:
2544
+ defaultSort = _this.defaultSort;
2545
+ orderParams = _this.orderParams;
2546
+ if (!((_orderParams = orderParams) !== null && _orderParams !== void 0 && _orderParams.orderByRowName) && defaultSort !== null && defaultSort !== void 0 && defaultSort.prop) {
2547
+ orderByRowName = toLine(defaultSort.prop);
2548
+ orderByRule = defaultSort.order;
2549
+ if (defaultSort.order == "descending") {
2550
+ orderByRule = "desc";
2551
+ } else if (defaultSort.order == "ascending") {
2552
+ orderByRule = "asc";
2553
+ }
2554
+ orderParams = {
2555
+ orderByRowName: orderByRowName,
2556
+ orderByRule: orderByRule
2557
+ };
2558
+ }
2559
+ params = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, _this.queryParams), _this.pagination), _this.tabQuery), orderParams);
2560
+ if (!_this.queryParamsMethod) {
2561
+ _context.n = 2;
2562
+ break;
2563
+ }
2564
+ _context.n = 1;
2565
+ return _this.queryParamsMethod(params);
2566
+ case 1:
2567
+ return _context.a(2, _context.v);
2568
+ case 2:
2569
+ return _context.a(2, params);
2570
+ }
2571
+ }, _callee);
2572
+ }))();
2573
+ },
2574
+ // 刷新列表数据
2575
+ refresh: function refresh() {
2576
+ var _this2 = this;
2577
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
2578
+ var queryParams, _yield$_this2$service, code, rows, total, _t;
2579
+ return _regenerator().w(function (_context2) {
2580
+ while (1) switch (_context2.p = _context2.n) {
2581
+ case 0:
2582
+ _this2.listLoading = true;
2583
+ _context2.p = 1;
2584
+ _context2.n = 2;
2585
+ return _this2.getParams();
2586
+ case 2:
2587
+ queryParams = _context2.v;
2588
+ _context2.n = 3;
2589
+ return _this2.service.page(queryParams);
2590
+ case 3:
2591
+ _yield$_this2$service = _context2.v;
2592
+ code = _yield$_this2$service.code;
2593
+ rows = _yield$_this2$service.rows;
2594
+ total = _yield$_this2$service.total;
2595
+ if (code === 200) {
2596
+ _this2.data = rows;
2597
+ _this2.total = total;
2598
+ }
2599
+ _context2.n = 5;
2600
+ break;
2601
+ case 4:
2602
+ _context2.p = 4;
2603
+ _t = _context2.v;
2604
+ console.log(_t);
2605
+ case 5:
2606
+ _this2.listLoading = false;
2607
+ case 6:
2608
+ return _context2.a(2);
2609
+ }
2610
+ }, _callee2, null, [[1, 4]]);
2611
+ }))();
2612
+ },
2613
+ // 删除
2614
+ "delete": function _delete(_ref) {
2615
+ var _this3 = this;
2616
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
2617
+ var row, id, _yield$_this3$service, code, _t2;
2618
+ return _regenerator().w(function (_context3) {
2619
+ while (1) switch (_context3.p = _context3.n) {
2620
+ case 0:
2621
+ row = _ref.row;
2622
+ _context3.p = 1;
2623
+ id = row === null || row === void 0 ? void 0 : row.id;
2624
+ _context3.n = 2;
2625
+ return _this3.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
2626
+ confirmButtonText: '确定',
2627
+ cancelButtonText: '取消',
2628
+ type: 'warning'
2629
+ });
2630
+ case 2:
2631
+ _context3.n = 3;
2632
+ return _this3.service["delete"](id);
2633
+ case 3:
2634
+ _yield$_this3$service = _context3.v;
2635
+ code = _yield$_this3$service.code;
2636
+ if (code === 200) {
2637
+ _this3.refresh();
2638
+ _this3.$message({
2639
+ type: 'success',
2640
+ message: '操作成功!'
2641
+ });
2642
+ }
2643
+ _context3.n = 5;
2644
+ break;
2645
+ case 4:
2646
+ _context3.p = 4;
2647
+ _t2 = _context3.v;
2648
+ console.log(_t2);
2649
+ case 5:
2650
+ return _context3.a(2);
2651
+ }
2652
+ }, _callee3, null, [[1, 4]]);
2653
+ }))();
2654
+ }
2655
+ }
2656
+ };
2657
+
2658
+ /* script */
2659
+ var __vue_script__$1 = script$1;
2660
+
2661
+ /* template */
2662
+ var __vue_render__ = function __vue_render__() {
2663
+ var _vm = this;
2664
+ var _h = _vm.$createElement;
2665
+ var _c = _vm._self._c || _h;
2666
+ return _c("div", {
2667
+ staticClass: "el-crud"
2668
+ }, [_vm._t("query", function () {
2669
+ return [_vm.queryItems && _vm.queryItems.length ? _c("query-form", {
2670
+ directives: [{
2671
+ name: "show",
2672
+ rawName: "v-show",
2673
+ value: _vm.showSearch,
2674
+ expression: "showSearch"
2675
+ }],
2676
+ attrs: {
2677
+ queryItems: _vm.queryItems,
2678
+ lineClamp: _vm.queryLineClamp,
2679
+ "label-width": _vm.queryLabelWidth,
2680
+ "input-width": _vm.queryInputWidth,
2681
+ inline: _vm.queryInline
2682
+ },
2683
+ on: {
2684
+ queryTable: _vm.handleQuery
2685
+ }
2686
+ }) : _vm._e()];
2687
+ }, {
2688
+ queryItems: _vm.queryItems,
2689
+ lineClamp: _vm.queryLineClamp,
2690
+ labelWidth: _vm.queryLabelWidth,
2691
+ inputWidth: _vm.queryInputWidth,
2692
+ inline: _vm.queryInline
2693
+ }), _vm._v(" "), _c("div", {
2694
+ staticClass: "container-main",
2695
+ "class": {
2696
+ pt5: _vm.tabPanes.length > 0
2697
+ }
2698
+ }, [_vm._t("tabQuery", function () {
2699
+ return [_vm.tabPanes.length > 0 ? _c("el-tabs", {
2700
+ staticClass: "top-tab-query",
2701
+ attrs: {
2702
+ value: _vm.tabQuery.tabKey
2703
+ },
2704
+ on: {
2705
+ "tab-click": _vm.handleTabClick
2706
+ }
2707
+ }, _vm._l(_vm.tabPanes, function (item) {
2708
+ return _c("el-tab-pane", {
2709
+ key: item.name,
2710
+ attrs: {
2711
+ label: item.label,
2712
+ name: item.name
2713
+ }
2714
+ });
2715
+ }), 1) : _vm._e()];
2716
+ }), _vm._v(" "), _c("div", {
2717
+ staticClass: "flex justify-between el-crud-toolbar"
2718
+ }, [_vm._t("buttons", function () {
2719
+ return [_c("div", _vm._l(_vm.actionButtons, function (item) {
2720
+ return _c("el-button", {
2721
+ attrs: {
2722
+ size: item.size,
2723
+ plain: item.plain,
2724
+ disabled: item.disabled,
2725
+ type: item.type,
2726
+ icon: item.icon
2727
+ },
2728
+ on: {
2729
+ click: function click($event) {
2730
+ return _vm.handleButtonClick(item);
2731
+ }
2732
+ }
2733
+ }, [_vm._v(_vm._s(item.text))]);
2734
+ }), 1)];
2735
+ }, {
2736
+ selections: _vm.selections
2737
+ }), _vm._v(" "), _vm._t("toolbar", function () {
2738
+ return [_c("right-toolbar", {
2739
+ attrs: {
2740
+ showSearch: _vm.showSearch,
2741
+ columns: _vm.columns,
2742
+ search: !!(_vm.queryItems && _vm.queryItems.length)
2743
+ },
2744
+ on: {
2745
+ "update:showSearch": function updateShowSearch($event) {
2746
+ _vm.showSearch = $event;
2747
+ },
2748
+ "update:show-search": function updateShowSearch($event) {
2749
+ _vm.showSearch = $event;
2750
+ },
2751
+ queryTable: _vm.refresh
2752
+ }
2753
+ })];
2754
+ }, {
2755
+ columns: _vm.columns,
2756
+ showSearch: _vm.showSearch
2757
+ })], 2), _vm._v(" "), _vm._t("default", function () {
2758
+ return [_c("crud-table", {
2759
+ directives: [{
2760
+ name: "loading",
2761
+ rawName: "v-loading",
2762
+ value: _vm.listLoading,
2763
+ expression: "listLoading"
2764
+ }],
2765
+ attrs: {
2766
+ size: "mini",
2767
+ highlightCol: _vm.highlightCol,
2768
+ resizable: _vm.resizable,
2769
+ border: _vm.border,
2770
+ columns: _vm.columns,
2771
+ data: _vm.data,
2772
+ "default-sort": _vm.defaultSort
2773
+ },
2774
+ on: {
2775
+ "selection-change": _vm.handleSelectionChange,
2776
+ "row-action": _vm.handleRowAction,
2777
+ "sort-change": _vm.handleSortChange
2778
+ }
2779
+ })];
2780
+ }, {
2781
+ data: _vm.data
2782
+ }), _vm._v(" "), _vm._t("pagination", function () {
2783
+ return [_c("pagination", {
2784
+ directives: [{
2785
+ name: "show",
2786
+ rawName: "v-show",
2787
+ value: _vm.total > 0,
2788
+ expression: "total > 0"
2789
+ }],
2790
+ attrs: {
2791
+ total: _vm.total,
2792
+ page: _vm.pagination.pageNum,
2793
+ limit: _vm.pagination.pageSize
2794
+ },
2795
+ on: {
2796
+ "update:page": function updatePage($event) {
2797
+ return _vm.$set(_vm.pagination, "pageNum", $event);
2798
+ },
2799
+ "update:limit": function updateLimit($event) {
2800
+ return _vm.$set(_vm.pagination, "pageSize", $event);
2801
+ },
2802
+ pagination: _vm.refresh
2803
+ }
2804
+ })];
2805
+ }, {
2806
+ total: _vm.total,
2807
+ pagination: _vm.pagination
2808
+ })], 2)], 2);
2809
+ };
2810
+ var __vue_staticRenderFns__ = [];
2811
+ __vue_render__._withStripped = true;
2812
+
2813
+ /* style */
2814
+ var __vue_inject_styles__$1 = function __vue_inject_styles__(inject) {
2815
+ if (!inject) return;
2816
+ inject("data-v-7449f835_0", {
2817
+ source: ".top-tab-query[data-v-7449f835] {\n margin-bottom: 10px;\n}\n.top-tab-query[data-v-7449f835] .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */",
2818
+ map: {
2819
+ "version": 3,
2820
+ "sources": ["/Users/tonwe/git/el-crud-page/src/index.vue", "index.vue"],
2821
+ "names": [],
2822
+ "mappings": "AA2UA;EACA,mBAAA;AC1UA;AD6UA;EACA,SAAA;AC3UA;;AAEA,oCAAoC",
2823
+ "file": "index.vue",
2824
+ "sourcesContent": ["<!-- crud组件 主要用于子组件的上下文传递 -->\n<!-- \n 搜索组件配置 queryItems 可配置\n 搜索及重置事件 queryTable \n \n 切换组件配置 tabPanes 可配置\n 切换参数 tabQuery \n \n 按钮组件配置 buttons 可配置\n 右侧工具条\n 表格列配置 columns 可配置\n 表格数据\n 分页数据\n -->\n<template>\n\n <div class=\"el-crud\">\n <!-- 搜索过滤插槽 -->\n <slot name=\"query\" :queryItems=\"queryItems\" :lineClamp=\"queryLineClamp\" :labelWidth=\"queryLabelWidth\"\n :inputWidth=\"queryInputWidth\" :inline=\"queryInline\">\n <query-form v-show=\"showSearch\" v-if=\"queryItems && queryItems.length\" :queryItems=\"queryItems\"\n :lineClamp=\"queryLineClamp\" :label-width=\"queryLabelWidth\" :input-width=\"queryInputWidth\" :inline=\"queryInline\"\n @queryTable=\"handleQuery\" />\n </slot>\n <div class=\"container-main\" :class=\"{ pt5: tabPanes.length > 0 }\">\n <slot name=\"tabQuery\">\n <el-tabs class=\"top-tab-query\" v-if=\"tabPanes.length > 0\" :value=\"tabQuery.tabKey\"\n @tab-click=\"handleTabClick\">\n <el-tab-pane :label=\"item.label\" :name=\"item.name\" v-for=\"item in tabPanes\"\n :key=\"item.name\"></el-tab-pane>\n </el-tabs>\n </slot>\n <!-- 工具条插槽 -->\n <div class=\"flex justify-between el-crud-toolbar\">\n <slot name=\"buttons\" :selections=\"selections\">\n <div>\n <el-button :size=\"item.size\" @click=\"handleButtonClick(item)\" v-for=\"item in actionButtons\"\n :plain=\"item.plain\" :disabled=\"item.disabled\" :type=\"item.type\" :icon=\"item.icon\">{{\n item.text\n }}</el-button>\n </div>\n </slot>\n <slot name=\"toolbar\" :columns=\"columns\" :showSearch=\"showSearch\">\n <right-toolbar :showSearch.sync=\"showSearch\" @queryTable=\"refresh\" :columns=\"columns\"\n :search=\"!!(queryItems && queryItems.length)\"></right-toolbar>\n </slot>\n </div>\n <!-- 默认插槽 并传 data -->\n <slot :data=\"data\">\n <crud-table v-loading=\"listLoading\" size=\"mini\" @selection-change=\"handleSelectionChange\"\n :highlightCol=\"highlightCol\" :resizable=\"resizable\" :border=\"border\" :columns=\"columns\" :data=\"data\"\n @row-action=\"handleRowAction\" @sort-change=\"handleSortChange\"\n :default-sort=\"defaultSort\"></crud-table>\n </slot>\n <!-- 分页插槽 并传 total queryParams -->\n <slot name=\"pagination\" :total=\"total\" :pagination=\"pagination\">\n <pagination v-show=\"total > 0\" :total=\"total\" :page.sync=\"pagination.pageNum\"\n :limit.sync=\"pagination.pageSize\" @pagination=\"refresh\" />\n </slot>\n </div>\n\n </div>\n\n</template>\n\n\n<script>\nimport CrudTable from \"./table.vue\";\nimport RightToolbar from \"./rightToolbar.vue\";\nimport QueryForm from \"./queryForm.vue\";\nimport Pagination from \"./pagination.vue\"\nimport { toLine } from \"./utils\";\n\nexport default {\n components: {\n CrudTable, RightToolbar, QueryForm, Pagination\n },\n name: 'Crud',\n provide() {\n return {\n crud: this\n };\n },\n props: {\n queryParamsMethod: {\n type: Function\n },\n columns: {\n type: Array,\n default: () => []\n },\n queryItems: {\n type: Array,\n default: () => []\n },\n queryLineClamp: {\n type: Number,\n default: 1\n },\n queryLabelWidth: {\n type: Number,\n default: 80\n },\n queryInputWidth: {\n type: Number,\n default: 210\n },\n queryInline: {\n type: Boolean,\n default: true\n },\n buttons: {\n type: Array | Function,\n default: () => []\n },\n tabPanes: {\n type: Array,\n default: () => []\n },\n defaultSort: {\n type: Object,\n default: () => {\n return {\n prop: undefined,\n order: undefined\n }\n }\n },\n highlightCol: {\n type: Boolean,\n default: false\n },\n resizable: {\n type: Boolean,\n default: false\n },\n border: {\n type: Boolean,\n default: false\n }\n },\n watch: {\n tabPanes: {\n handler(val) {\n if (val.length) {\n\n this.tabQuery.tabKey = val[0].name\n }\n },\n deep: true,\n immediate: true\n },\n \"tabQuery.tabKey\": {\n handler(val) {\n this.$emit(\"tabChange\", val);\n },\n\n }\n },\n computed: {\n actionButtons() {\n let buts = this.buttons;\n if (typeof buts === 'function') {\n return buts(this.selections);\n } else if (buts?.length) {\n return buts\n }\n return []\n }\n },\n data() {\n return {\n listLoading: false,\n showSearch: true,\n selections: [],\n data: [],\n service: { // 增删改查导出\n add: null,\n update: null,\n delete: null,\n page: null,\n info: null,\n list: null,\n export: null,\n }, // 服务\n queryParams: {\n // pageNum: 1,\n // pageSize: 10\n }, // 查询参数\n\n tabQuery: {\n tabKey: undefined\n }, // 参数\n filterParams: {}, // 过滤参数\n pagination: {\n pageNum: 1,\n pageSize: 10\n },\n orderParams: {\n orderByRowName: undefined,\n orderByRule: undefined\n },\n total: 0,\n\n }\n },\n created() {\n },\n methods: {\n handleTabClick(tab) {\n this.tabQuery.tabKey = tab.name\n this.refresh()\n },\n handleSelectionChange(e) {\n this.selections = e\n },\n handleQuery(query) {\n this.queryParams = query;\n this.refresh()\n },\n handleButtonClick(item) {\n this.$emit(\"action\", item.action, this.selections);\n },\n handleRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n if (action === 'delete' && this.service.delete) {\n this.delete(scope)\n }\n },\n handleSortChange(column) {\n this.orderParams.orderByRowName = toLine(column.prop);\n if (column.order == \"descending\") {\n this.orderParams.orderByRule = \"desc\";\n } else if (column.order == \"ascending\") {\n this.orderParams.orderByRule = \"asc\";\n } else {\n this.orderParams.orderByRule = undefined;\n this.orderParams.orderByRowName = undefined;\n }\n this.refresh();\n },\n // 服务\n setService(service) {\n this.service = Object.assign(this.service, service);\n },\n // 设置列\n setColumns(columns) {\n this.columns = columns;\n },\n // 设置数据\n setData(data) {\n // this.crud.data = data;\n },\n // 获得查询参数\n async getParams() {\n const defaultSort = this.defaultSort;\n let orderParams = this.orderParams;\n\n if (!orderParams?.orderByRowName && defaultSort?.prop) {\n const orderByRowName = toLine(defaultSort.prop);\n let orderByRule = defaultSort.order;\n\n if (defaultSort.order == \"descending\") {\n orderByRule = \"desc\";\n } else if (defaultSort.order == \"ascending\") {\n orderByRule = \"asc\";\n }\n\n orderParams = {\n orderByRowName,\n orderByRule\n }\n }\n\n let params = { ...this.queryParams, ...this.pagination, ...this.tabQuery, ...orderParams }\n\n\n\n if (this.queryParamsMethod) {\n return await this.queryParamsMethod(params);\n }\n return params;\n },\n // 刷新列表数据\n async refresh() {\n this.listLoading = true;\n try {\n const queryParams = await this.getParams();\n const { code, rows, total } = await this.service.page(queryParams);\n if (code === 200) {\n this.data = rows;\n this.total = total;\n }\n\n } catch (error) {\n console.log(error);\n }\n this.listLoading = false;\n },\n // 删除\n async delete({ row }) {\n try {\n let id = row?.id;\n await this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {\n confirmButtonText: '确定',\n cancelButtonText: '取消',\n type: 'warning'\n })\n const { code } = await this.service.delete(id);\n if (code === 200) {\n this.refresh();\n this.$message({\n type: 'success',\n message: '操作成功!'\n });\n }\n } catch (error) {\n console.log(error);\n\n }\n\n\n }\n\n }\n\n}\n\n</script>\n\n<style scoped lang=\"scss\">\n.top-tab-query {\n margin-bottom: 10px;\n\n &::v-deep {\n .el-tabs__header {\n margin: 0;\n }\n }\n}\n</style>", ".top-tab-query {\n margin-bottom: 10px;\n}\n.top-tab-query::v-deep .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */"]
2825
+ },
2826
+ media: undefined
2827
+ });
2828
+ };
2829
+ /* scoped */
2830
+ var __vue_scope_id__$1 = "data-v-7449f835";
2831
+ /* module identifier */
2832
+ var __vue_module_identifier__$1 = undefined;
2833
+ /* functional template */
2834
+ var __vue_is_functional_template__$1 = false;
2835
+ /* style inject SSR */
2836
+
2837
+ /* style inject shadow dom */
2838
+
2839
+ var __vue_component__$1 = /*#__PURE__*/normalizeComponent({
2840
+ render: __vue_render__,
2841
+ staticRenderFns: __vue_staticRenderFns__
2842
+ }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, createInjector, undefined, undefined);
2843
+
2844
+ function getDefaultExportFromCjs (x) {
2845
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2846
+ }
2847
+
2848
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}var normalMerge=["attrs","props","domProps"],toArrayMerge=["class","style","directives"],functionalMerge=["on","nativeOn"],mergeJsxProps=function(a){return a.reduce(function(c,a){for(var b in a)if(!c[b])c[b]=a[b];else if(-1!==normalMerge.indexOf(b))c[b]=_extends({},c[b],a[b]);else if(-1!==toArrayMerge.indexOf(b)){var d=c[b]instanceof Array?c[b]:[c[b]],e=a[b]instanceof Array?a[b]:[a[b]];c[b]=[].concat(d,e);}else if(-1!==functionalMerge.indexOf(b)){for(var f in a[b])if(c[b][f]){var g=c[b][f]instanceof Array?c[b][f]:[c[b][f]],h=a[b][f]instanceof Array?a[b][f]:[a[b][f]];c[b][f]=[].concat(g,h);}else c[b][f]=a[b][f];}else if("hook"===b)for(var i in a[b])c[b][i]=c[b][i]?mergeFn(c[b][i],a[b][i]):a[b][i];else c[b]=a[b];return c},{})},mergeFn=function(a,b){return function(){a&&a.apply(this,arguments),b&&b.apply(this,arguments);}};var helper=mergeJsxProps;
2849
+
2850
+ var _mergeJSXProps7 = /*@__PURE__*/getDefaultExportFromCjs(helper);
2851
+
2852
+ var format = {
2853
+ number: function number(value) {
2854
+ var result;
2855
+ if (isArray(value)) {
2856
+ result = value.map(Number).map(function (item) {
2857
+ return isNaN(item) ? undefined : item;
2858
+ });
2859
+ } else {
2860
+ result = Number(value);
2861
+ if (isNaN(result)) {
2862
+ result = undefined;
2863
+ }
2864
+ }
2865
+ return result;
2866
+ },
2867
+ string: function string(value) {
2868
+ return isArray(value) ? value.map(String) : String(value);
2869
+ },
2870
+ split: function split(value) {
2871
+ return isString(value) ? value.split(",").filter(Boolean) : value;
2872
+ },
2873
+ join: function join(value) {
2874
+ return isArray(value) ? value.join(",") : value;
2875
+ },
2876
+ "boolean": function boolean(value) {
2877
+ return Boolean(value);
2878
+ },
2879
+ booleanNumber: function booleanNumber(value) {
2880
+ return Boolean(value) ? 1 : 0;
2881
+ },
2882
+ datetimerange: function datetimerange(value, form, method) {
2883
+ if (method == "bind") {
2884
+ return [form.startTime, form.endTime];
2885
+ } else {
2886
+ var _ref = value || [],
2887
+ _ref2 = _slicedToArray(_ref, 2),
2888
+ startTime = _ref2[0],
2889
+ endTime = _ref2[1];
2890
+ form.startTime = startTime;
2891
+ form.endTime = endTime;
2892
+ return undefined;
2893
+ }
2894
+ },
2895
+ splitJoin: function splitJoin(value, _, method) {
2896
+ if (method == "bind") {
2897
+ return isString(value) ? value.split(",").filter(Boolean) : value;
2898
+ } else {
2899
+ return isArray(value) ? value.join(",") : value;
2900
+ }
2901
+ }
2902
+ };
2903
+ function parse(method, _ref3) {
2904
+ var value = _ref3.value,
2905
+ pipe = _ref3.pipe,
2906
+ form = _ref3.form;
2907
+ if (!pipe) {
2908
+ return value;
2909
+ }
2910
+ var pipes = [];
2911
+ if (isString(pipe)) {
2912
+ if (format[pipe]) {
2913
+ pipes = [pipe];
2914
+ } else {
2915
+ console.error("".concat(pipe, " is not found."));
2916
+ return value;
2917
+ }
2918
+ } else if (isArray(pipe)) {
2919
+ pipes = pipe;
2920
+ } else if (isObject(pipe)) {
2921
+ pipes = isArray(pipe[method]) ? pipe[method] : [pipe[method]];
2922
+ } else if (isFunction(pipe)) {
2923
+ pipes = [pipe];
2924
+ } else {
2925
+ console.error("Hook data error!");
2926
+ return value;
2927
+ }
2928
+ var d = value;
2929
+ pipes.forEach(function (e) {
2930
+ if (isString(e)) {
2931
+ d = format[e](d, form, method);
2932
+ } else if (isFunction(e)) {
2933
+ d = e(d, form);
2934
+ }
2935
+ });
2936
+ return d;
2937
+ }
2938
+ var valueHook = {
2939
+ bind: function bind(value, pipe, form) {
2940
+ return parse("bind", {
2941
+ value: value,
2942
+ pipe: pipe,
2943
+ form: form
2944
+ });
2945
+ },
2946
+ submit: function submit(value, pipe, form) {
2947
+ return parse("submit", {
2948
+ value: value,
2949
+ pipe: pipe,
2950
+ form: form
2951
+ });
2952
+ }
2953
+ };
2954
+
2955
+ // type FormItems = { // 表单项配置
2956
+ // label: string; // 标签
2957
+ // prop: string; // 字段名
2958
+
2959
+ // options?: { value: string; label: string; disabled?: boolean }[] || ()=>[]; // 字典数据
2960
+ // rules?: any[]; // 验证规则
2961
+
2962
+ // children?: FormItems[];
2963
+ // hidden?: boolean; // 是否隐藏
2964
+ // help?: string; // 帮助信息
2965
+
2966
+ // span?: number; // 栅格占据的列数
2967
+ // labelWidth?: string; // formitem 标签宽度
2968
+
2969
+ // component?: VNode;
2970
+ // };
2971
+ // type VNodeFunction = ({ scope,h }) => VNode | ({ scope,h }) =><div>{ scope }</div> | <div />;
2972
+
2973
+ // type VNodeObject = {
2974
+ // name?: string | Component; // 组件名 | 组件引用
2975
+ // options?: any[]; // 选项
2976
+ // attrs?: any; // 属性
2977
+ // on?: any; // 事件
2978
+ // props?: any; // 属性
2979
+ // [key: string]: any;
2980
+ // };
2981
+ // type VNode = string | VNodeFunction | VNodeObject;
2982
+
2983
+ var script = {
2984
+ props: {
2985
+ // 表单配置项,可以从外部传入
2986
+ formItems: {
2987
+ type: Array,
2988
+ "default": function _default() {
2989
+ return [];
2990
+ }
2991
+ },
2992
+ // 初始表单数据
2993
+ initialFormData: {
2994
+ type: Object,
2995
+ "default": function _default() {
2996
+ return {};
2997
+ }
2998
+ },
2999
+ // 按钮配置
3000
+ buttons: {
3001
+ type: Object,
3002
+ "default": function _default() {
3003
+ return {
3004
+ submit: {
3005
+ show: true,
3006
+ text: '提交',
3007
+ type: 'primary',
3008
+ loading: false
3009
+ },
3010
+ cancel: {
3011
+ show: true,
3012
+ text: '取消',
3013
+ type: 'default'
3014
+ }
3015
+ };
3016
+ }
3017
+ },
3018
+ // 按钮位置
3019
+ buttonPosition: {
3020
+ type: String,
3021
+ "default": 'right',
3022
+ // center, left, right
3023
+ validator: function validator(value) {
3024
+ return ['center', 'left', 'right'].includes(value);
3025
+ }
3026
+ },
3027
+ // 是否显示按钮区域
3028
+ showButtons: {
3029
+ type: Boolean,
3030
+ "default": true
3031
+ },
3032
+ readonly: {
3033
+ type: Boolean
3034
+ },
3035
+ labelWidth: {
3036
+ type: String,
3037
+ "default": '80px'
3038
+ },
3039
+ column: {
3040
+ type: Number,
3041
+ "default": 2
3042
+ },
3043
+ gutter: {
3044
+ type: Number,
3045
+ "default": 10
3046
+ },
3047
+ size: {
3048
+ type: String,
3049
+ "default": 'small'
3050
+ }
3051
+ // value: {
3052
+ // type: Object,
3053
+ // default: () => ({})
3054
+ // },
3055
+ },
3056
+ data: function data() {
3057
+ return {
3058
+ form: {},
3059
+ // 如果没有传入formItems,则使用默认配置
3060
+ items: [],
3061
+ activeName: 'first',
3062
+ submitLoading: false
3063
+ };
3064
+ },
3065
+ computed: {
3066
+ // 从items中提取所有字段的规则
3067
+ formRules: function formRules() {
3068
+ var rules = {};
3069
+
3070
+ // 递归提取规则函数
3071
+ var _extractRules = function extractRules(nodes) {
3072
+ if (!nodes || !nodes.length) return;
3073
+ nodes.forEach(function (node) {
3074
+ // 如果节点有children,递归处理
3075
+ if (node.children && node.children.length) {
3076
+ _extractRules(node.children);
3077
+ }
3078
+
3079
+ // 如果是表单字段且有规则,添加到规则对象
3080
+ if (node.prop && node.rules) {
3081
+ rules[node.prop] = node.rules;
3082
+ }
3083
+ });
3084
+ };
3085
+
3086
+ // 对所有配置项提取规则
3087
+ _extractRules(this.items);
3088
+ return rules;
3089
+ },
3090
+ // 按钮区域样式
3091
+ buttonAreaStyle: function buttonAreaStyle() {
3092
+ return {
3093
+ textAlign: this.buttonPosition,
3094
+ marginTop: '20px'
3095
+ };
3096
+ },
3097
+ // label宽度
3098
+ labelStyle: function labelStyle() {
3099
+ return {
3100
+ width: this.labelWidth,
3101
+ textAlign: 'center'
3102
+ };
3103
+ }
3104
+ },
3105
+ watch: {
3106
+ // 监听外部传入的表单数据变化
3107
+ initialFormData: {
3108
+ handler: function handler(val) {
3109
+ this.form = JSON.parse(JSON.stringify(val));
3110
+ },
3111
+ immediate: true,
3112
+ deep: true
3113
+ },
3114
+ // 监听外部传入的表单配置变化
3115
+ formItems: {
3116
+ handler: function handler(val) {
3117
+ if (val && val.length) {
3118
+ this.items = val;
3119
+ }
3120
+ },
3121
+ immediate: true,
3122
+ deep: true
3123
+ },
3124
+ // 监听外部传入的value变化
3125
+ // value: {
3126
+ // handler(val) {
3127
+ // this.form = JSON.parse(JSON.stringify(val)) || {};
3128
+ // },
3129
+ // immediate: true,
3130
+ // deep: true
3131
+ // },
3132
+ // v-model绑定的值变化时,更新表单数据
3133
+ form: {
3134
+ handler: function handler(val) {
3135
+ this.$emit('input', val);
3136
+ },
3137
+ deep: true
3138
+ }
3139
+ },
3140
+ methods: {
3141
+ // 处理表单输入事件
3142
+ handleInput: function handleInput(prop, value) {
3143
+ this.$set(this.form, prop, value);
3144
+ // 触发change事件,将变更通知给父组件
3145
+ this.$emit('field-change', {
3146
+ prop: prop,
3147
+ value: value,
3148
+ form: this.form
3149
+ });
3150
+ },
3151
+ // 递归渲染函数 - 根据节点类型渲染不同内容
3152
+ renderNode: function renderNode(node, index) {
3153
+ // 如果是只读模式,使用只读渲染函数
3154
+ if (this.readonly) {
3155
+ return this.renderReadOnlyNode(node, index);
3156
+ }
3157
+
3158
+ // 如果是输入字段(没有type或没有children,则视为字段)
3159
+ if (!node.type || !node.children && node.prop) {
3160
+ return this.renderField(node, index);
3161
+ }
3162
+
3163
+ // 根据节点类型渲染
3164
+ switch (node.type) {
3165
+ case 'tab':
3166
+ return this.renderTab(node, index);
3167
+ case 'group':
3168
+ return this.renderGroup(node, index);
3169
+ default:
3170
+ // 默认当作字段渲染
3171
+ return this.renderField(node, index);
3172
+ }
3173
+ },
3174
+ // 只读模式 - 递归渲染函数
3175
+ renderReadOnlyNode: function renderReadOnlyNode(node, index) {
3176
+ if (!node.type || !node.children && node.prop) {
3177
+ return this.renderReadOnlyField(node, index);
3178
+ }
3179
+ switch (node.type) {
3180
+ case 'tab':
3181
+ return this.renderReadOnlyTab(node, index);
3182
+ case 'group':
3183
+ return this.renderReadOnlyGroup(node, index);
3184
+ default:
3185
+ return this.renderReadOnlyField(node, index);
3186
+ }
3187
+ },
3188
+ // 只读模式 - 渲染标签页
3189
+ renderReadOnlyTab: function renderReadOnlyTab(tab, index) {
3190
+ var h = this.$createElement;
3191
+ return h("el-tab-pane", _mergeJSXProps7([{
3192
+ "key": tab.name || index,
3193
+ "attrs": {
3194
+ "label": tab.label,
3195
+ "name": tab.name || index
3196
+ }
3197
+ }, tab.props]), [this.renderReadOnlyChildren(tab.children)]);
3198
+ },
3199
+ // 只读模式 - 渲染分组
3200
+ renderReadOnlyGroup: function renderReadOnlyGroup(group, index) {
3201
+ var h = this.$createElement;
3202
+ return h("div", _mergeJSXProps7([{
3203
+ "class": ['el-form-group', group.className],
3204
+ "key": index
3205
+ }, group.props]), [h("el-descriptions", {
3206
+ "attrs": {
3207
+ "title": group.title,
3208
+ "border": true,
3209
+ "column": this.column,
3210
+ "size": this.size,
3211
+ "labelStyle": this.labelStyle
3212
+ }
3213
+ }, [this.renderReadOnlyDescriptionItems(group.children)])]);
3214
+ },
3215
+ // 只读模式 - 渲染字段
3216
+ renderReadOnlyField: function renderReadOnlyField(field, index) {
3217
+ var h = this.$createElement;
3218
+ // 如果字段被配置为隐藏,则不渲染
3219
+ if (field.hidden) {
3220
+ return null;
3221
+ }
3222
+
3223
+ // 获取字段值
3224
+ var value = this.form[field.prop];
3225
+
3226
+ // 处理显示值
3227
+ var displayValue = value;
3228
+
3229
+ // 处理不同类型的字段显示值
3230
+ if (field.options && Array.isArray(field.options)) {
3231
+ var option = field.options.find(function (opt) {
3232
+ return opt.value === value;
3233
+ });
3234
+ if (option) {
3235
+ displayValue = option.label;
3236
+ }
3237
+ }
3238
+
3239
+ // 如果处于顶层(不在group内),则需要包装在el-descriptions中
3240
+ if (!field._inGroup) {
3241
+ return h("el-col", {
3242
+ "attrs": {
3243
+ "span": 24 / this.column || field.span || 12
3244
+ },
3245
+ "key": field.prop || index
3246
+ }, [h("el-descriptions", {
3247
+ "attrs": {
3248
+ "labelStyle": this.labelStyle,
3249
+ "border": true,
3250
+ "column": this.column,
3251
+ "size": this.size
3252
+ }
3253
+ }, [h("el-descriptions-item", {
3254
+ "attrs": {
3255
+ "label": field.label || ''
3256
+ }
3257
+ }, [displayValue || '-'])])]);
3258
+ }
3259
+ // 在group内部的字段直接返回
3260
+ return h("el-descriptions-item", {
3261
+ "attrs": {
3262
+ "label": field.label || ''
3263
+ }
3264
+ }, [displayValue || '-']);
3265
+ },
3266
+ // 只读模式 - 渲染描述项
3267
+ renderReadOnlyDescriptionItems: function renderReadOnlyDescriptionItems(children) {
3268
+ var _this = this;
3269
+ if (!children || !children.length) {
3270
+ return null;
3271
+ }
3272
+ return children.map(function (child) {
3273
+ // 标记字段在group内部
3274
+ child._inGroup = true;
3275
+ return _this.renderReadOnlyField(child);
3276
+ });
3277
+ },
3278
+ // 只读模式 - 渲染子节点
3279
+ renderReadOnlyChildren: function renderReadOnlyChildren(children) {
3280
+ var _this2 = this;
3281
+ var h = this.$createElement;
3282
+ // 如果没有子节点,返回空
3283
+ if (!children || !children.length) {
3284
+ return null;
3285
+ }
3286
+
3287
+ // 检查第一个子节点类型,判断是否需要包装
3288
+ var firstChild = children[0];
3289
+
3290
+ // 如果第一个子节点是group,不需要额外包装
3291
+ if (firstChild.type === 'group') {
3292
+ return children.map(function (child, index) {
3293
+ return _this2.renderReadOnlyNode(child, index);
3294
+ });
3295
+ }
3296
+
3297
+ // 如果子节点不是输入字段,也不是分组,则直接渲染
3298
+ if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {
3299
+ return children.map(function (child, index) {
3300
+ return _this2.renderReadOnlyNode(child, index);
3301
+ });
3302
+ }
3303
+
3304
+ // 如果是普通字段(非group),则包装在el-descriptions中
3305
+ return h("el-descriptions", {
3306
+ "attrs": {
3307
+ "border": true,
3308
+ "column": this.column,
3309
+ "size": this.size,
3310
+ "labelStyle": this.labelStyle
3311
+ }
3312
+ }, [children.map(function (child, index) {
3313
+ child._inGroup = true;
3314
+ return _this2.renderReadOnlyNode(child, index);
3315
+ })]);
3316
+ },
3317
+ // 渲染标签页
3318
+ renderTab: function renderTab(tab, index) {
3319
+ var h = this.$createElement;
3320
+ return h("el-tab-pane", _mergeJSXProps7([{
3321
+ "key": tab.name || index,
3322
+ "attrs": {
3323
+ "label": tab.label,
3324
+ "name": tab.name || index
3325
+ }
3326
+ }, tab.props]), [this.renderChildren(tab.children)]);
3327
+ },
3328
+ // 渲染分组
3329
+ renderGroup: function renderGroup(group, index) {
3330
+ var h = this.$createElement;
3331
+ return h("div", _mergeJSXProps7([{
3332
+ "class": ['el-form-group', group.className],
3333
+ "key": index
3334
+ }, group.props]), [group.title && h("div", {
3335
+ "class": "el-form-group__title"
3336
+ }, [group.title]), h("div", [this.renderChildren(group.children)])]);
3337
+ },
3338
+ // 渲染各种表单控件
3339
+ renderFormControl: function renderFormControl(field) {
3340
+ var _field$hook;
3341
+ var component = field.component;
3342
+ if (isString(field.component)) {
3343
+ component = {
3344
+ name: field.component,
3345
+ attrs: {
3346
+ placeholder: field.placeholder || "\u8BF7\u8F93\u5165".concat(field.label),
3347
+ clearable: typeof field.clearable !== 'undefined' ? field.clearable : true
3348
+ }
3349
+ };
3350
+ }
3351
+ if (!isFunction(field.component)) {
3352
+ if (field.component === 'el-select') {
3353
+ component.attrs = _objectSpread2(_objectSpread2({}, component.attrs), {}, {
3354
+ placeholder: field.placeholder || "\u8BF7\u9009\u62E9".concat(field.label),
3355
+ filterable: true
3356
+ });
3357
+ }
3358
+ }
3359
+ if ((_field$hook = field.hook) !== null && _field$hook !== void 0 && (_field$hook = _field$hook.bind) !== null && _field$hook !== void 0 && _field$hook.length) {
3360
+ var _field$hook2;
3361
+ var value = valueHook.bind(this.form[field.prop], (_field$hook2 = field.hook) === null || _field$hook2 === void 0 ? void 0 : _field$hook2.bind, this.form);
3362
+ this.$set(this.form, field.prop, value);
3363
+ }
3364
+ // component 渲染 { prop: this.column.prop, scope: scope }
3365
+ return renderNode.call(this, component, {
3366
+ prop: field.prop,
3367
+ scope: this.form
3368
+ });
3369
+ },
3370
+ // 渲染字段
3371
+ renderField: function renderField(field, index) {
3372
+ var h = this.$createElement;
3373
+ // 如果字段被配置为隐藏,则不渲染
3374
+ if (field.hidden) {
3375
+ return null;
3376
+ }
3377
+ return h("el-col", {
3378
+ "attrs": {
3379
+ "span": 24 / this.column || field.span || 12
3380
+ },
3381
+ "key": field.prop || index
3382
+ }, [h("el-form-item", _mergeJSXProps7([{
3383
+ "attrs": {
3384
+ "label": field.label,
3385
+ "prop": field.prop,
3386
+ "rules": field.rules,
3387
+ "labelWidth": field.labelWidth || this.labelWidth
3388
+ }
3389
+ }, field.formItemProps]), [this.renderFormControl(field), field.help && h("div", {
3390
+ "class": "form-item-help"
3391
+ }, [field.help])])]);
3392
+ },
3393
+ // 渲染子节点
3394
+ renderChildren: function renderChildren(children) {
3395
+ var h = this.$createElement;
3396
+ // 如果没有子节点,返回空
3397
+ if (!children || !children.length) {
3398
+ return null;
3399
+ }
3400
+
3401
+ // 检查第一个子节点类型,判断是否需要包装
3402
+ var firstChild = children[0];
3403
+
3404
+ // 如果第一个子节点是group,不需要额外包装
3405
+ if (firstChild.type === 'group') {
3406
+ return children.map(this.renderNode);
3407
+ }
3408
+
3409
+ // 如果子节点不是输入字段,也不是分组,则直接渲染
3410
+ if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {
3411
+ return children.map(this.renderNode);
3412
+ }
3413
+
3414
+ // 其他情况(子节点是输入字段)包装在row中
3415
+ return h("el-row", {
3416
+ "attrs": {
3417
+ "gutter": this.gutter
3418
+ }
3419
+ }, [children.map(this.renderNode)]);
3420
+ },
3421
+ // 判断是否有标签页
3422
+ hasTabs: function hasTabs() {
3423
+ return this.items && this.items.some(function (item) {
3424
+ return item.type === 'tab';
3425
+ });
3426
+ },
3427
+ // 渲染按钮区域
3428
+ renderButtons: function renderButtons() {
3429
+ var h = this.$createElement;
3430
+ if (!this.showButtons || this.readonly) return null;
3431
+ return h("div", {
3432
+ "class": "form-button-area",
3433
+ "style": this.buttonAreaStyle
3434
+ }, [this.buttons.cancel && this.buttons.cancel.show && h("el-button", _mergeJSXProps7([{
3435
+ "on": {
3436
+ "click": this.handleCancel
3437
+ },
3438
+ "attrs": {
3439
+ "type": this.buttons.cancel.type
3440
+ }
3441
+ }, this.buttons.cancel.props]), [this.buttons.cancel.text]), this.buttons.submit && this.buttons.submit.show && h("el-button", _mergeJSXProps7([{
3442
+ "on": {
3443
+ "click": this.handleSubmit
3444
+ },
3445
+ "attrs": {
3446
+ "type": this.buttons.submit.type,
3447
+ "loading": this.submitLoading || this.buttons.submit.loading
3448
+ }
3449
+ }, this.buttons.submit.props]), [this.buttons.submit.text])]);
3450
+ },
3451
+ // 处理提交
3452
+ handleSubmit: function handleSubmit() {
3453
+ var _this3 = this;
3454
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3455
+ var formData, _t;
3456
+ return _regenerator().w(function (_context) {
3457
+ while (1) switch (_context.p = _context.n) {
3458
+ case 0:
3459
+ _context.p = 0;
3460
+ _this3.submitLoading = true;
3461
+ // 表单验证
3462
+ _context.n = 1;
3463
+ return _this3.validate();
3464
+ case 1:
3465
+ formData = _context.v;
3466
+ // 发出提交事件
3467
+ _this3.$emit('submit', formData);
3468
+
3469
+ // return formData;
3470
+ _context.n = 3;
3471
+ break;
3472
+ case 2:
3473
+ _context.p = 2;
3474
+ _t = _context.v;
3475
+ _this3.$emit('submit-error', _t);
3476
+ return _context.a(2, Promise.reject(_t));
3477
+ case 3:
3478
+ _this3.submitLoading = false;
3479
+ case 4:
3480
+ return _context.a(2);
3481
+ }
3482
+ }, _callee, null, [[0, 2]]);
3483
+ }))();
3484
+ },
3485
+ // 处理取消
3486
+ handleCancel: function handleCancel() {
3487
+ this.$emit('cancel');
3488
+ },
3489
+ // 表单验证方法
3490
+ validate: function validate() {
3491
+ var _this4 = this;
3492
+ return new Promise(function (resolve, reject) {
3493
+ _this4.$refs.form.validate(function (valid) {
3494
+ if (valid) {
3495
+ resolve(_this4.form);
3496
+ } else {
3497
+ reject(new Error('表单验证失败'));
3498
+ }
3499
+ });
3500
+ });
3501
+ },
3502
+ // 重置表单
3503
+ resetForm: function resetForm() {
3504
+ this.form = JSON.parse(JSON.stringify(this.initialFormData)) || {};
3505
+ this.$refs.form.resetFields();
3506
+ this.$emit('form-reset', this.form);
3507
+ },
3508
+ // 获取表单数据
3509
+ getFormData: function getFormData() {
3510
+ return this.form;
3511
+ }
3512
+ },
3513
+ render: function render() {
3514
+ var _this5 = this;
3515
+ var h = arguments[0];
3516
+ if (this.readonly) {
3517
+ // 只读模式渲染
3518
+ return h("div", {
3519
+ "class": "dynamic-form-container readonly"
3520
+ }, [this.hasTabs() ? // 渲染标签页结构
3521
+ h("el-tabs", {
3522
+ "directives": [{
3523
+ name: "on",
3524
+ value: this.$listeners
3525
+ }],
3526
+ "model": {
3527
+ value: _this5.activeName,
3528
+ callback: function callback($$v) {
3529
+ _this5.activeName = $$v;
3530
+ }
3531
+ }
3532
+ }, [this.items.map(function (item, index) {
3533
+ return _this5.renderReadOnlyNode(item, index);
3534
+ })]) :
3535
+ // 非标签页结构,直接渲染
3536
+ this.renderReadOnlyChildren(this.items)]);
3537
+ }
3538
+ var formProps = _objectSpread2({
3539
+ model: this.form,
3540
+ rules: this.formRules
3541
+ }, this.$attrs);
3542
+ // 如果没有配置项,渲染空表单
3543
+ if (!this.items || !this.items.length) {
3544
+ return h("div", {
3545
+ "class": "dynamic-form-container"
3546
+ }, [h("el-form", {
3547
+ "ref": "form",
3548
+ "props": _objectSpread2({}, formProps)
3549
+ })]);
3550
+ }
3551
+ return h("div", {
3552
+ "class": "dynamic-form-container"
3553
+ }, [h("el-form", {
3554
+ "ref": "form",
3555
+ "props": _objectSpread2({}, formProps)
3556
+ }, [this.hasTabs() ? // 渲染标签页结构
3557
+ h("el-tabs", {
3558
+ "directives": [{
3559
+ name: "on",
3560
+ value: this.$listeners
3561
+ }],
3562
+ "model": {
3563
+ value: _this5.activeName,
3564
+ callback: function callback($$v) {
3565
+ _this5.activeName = $$v;
3566
+ }
3567
+ }
3568
+ }, [this.items.map(this.renderNode)]) :
3569
+ // 非标签页结构,直接渲染
3570
+ this.renderChildren(this.items), this.renderButtons()])]);
3571
+ }
3572
+ };
3573
+
3574
+ /* script */
3575
+ var __vue_script__ = script;
3576
+
3577
+ /* template */
3578
+
3579
+ /* style */
3580
+ var __vue_inject_styles__ = function __vue_inject_styles__(inject) {
3581
+ if (!inject) return;
3582
+ inject("data-v-ef86d32c_0", {
3583
+ source: "@charset \"UTF-8\";\n.dynamic-form-container[data-v-ef86d32c] {\n padding: 20px;\n}\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-input,\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-select {\n width: 100%;\n}\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-input__inner {\n width: 100%;\n}\n.el-form-group[data-v-ef86d32c] {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n.el-form-group__title[data-v-ef86d32c] {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n.form-button-area[data-v-ef86d32c] {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n.form-button-area .el-button + .el-button[data-v-ef86d32c] {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly .el-descriptions__body[data-v-ef86d32c] {\n background-color: #fafafa;\n}\n.dynamic-form-container.readonly .el-descriptions-item__label[data-v-ef86d32c] {\n font-weight: bold;\n}\n.dynamic-form-container.readonly .el-descriptions-item__content[data-v-ef86d32c] {\n word-break: break-all;\n}\n\n/*# sourceMappingURL=form.vue.map */",
3584
+ map: {
3585
+ "version": 3,
3586
+ "sources": ["form.vue", "/Users/tonwe/git/el-crud-page/src/form.vue"],
3587
+ "names": [],
3588
+ "mappings": "AAAA,gBAAgB;ACqlBhB;EACA,aAAA;ADnlBA;AC2lBA;;EAEA,WAAA;ADzlBA;AC2lBA;EACA,WAAA;ADzlBA;AComBA;EACA,mBAAA;EACA,mBAAA;EACA,gCAAA;ADjmBA;AComBA;EACA,iBAAA;EACA,mBAAA;EACA,eAAA;EACA,cAAA;ADjmBA;AComBA;EACA,iBAAA;EACA,6BAAA;ADjmBA;AComBA;EACA,iBAAA;ADjmBA;;AComBA,WAAA;AAEA;EACA,yBAAA;ADlmBA;ACqmBA;EACA,iBAAA;ADnmBA;ACsmBA;EACA,qBAAA;ADpmBA;;AAEA,mCAAmC",
3589
+ "file": "form.vue",
3590
+ "sourcesContent": ["@charset \"UTF-8\";\n.dynamic-form-container {\n padding: 20px;\n}\n.dynamic-form-container .el-form .el-form-item::v-deep .el-input,\n.dynamic-form-container .el-form .el-form-item::v-deep .el-select {\n width: 100%;\n}\n.dynamic-form-container .el-form .el-form-item::v-deep .el-input__inner {\n width: 100%;\n}\n\n.el-form-group {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n\n.el-form-group__title {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n\n.form-button-area {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n\n.form-button-area .el-button + .el-button {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly .el-descriptions__body {\n background-color: #fafafa;\n}\n.dynamic-form-container.readonly .el-descriptions-item__label {\n font-weight: bold;\n}\n.dynamic-form-container.readonly .el-descriptions-item__content {\n word-break: break-all;\n}\n\n/*# sourceMappingURL=form.vue.map */", "<script lang=\"jsx\">\nimport { renderNode } from \"./utils/vnode\"\nimport { isObject, isString ,isFunction} from \"./utils/index\"\nimport valueHook from \"./utils/value-hook\"\n\n// type FormItems = { // 表单项配置\n// label: string; // 标签\n// prop: string; // 字段名\n\n// options?: { value: string; label: string; disabled?: boolean }[] || ()=>[]; // 字典数据\n// rules?: any[]; // 验证规则\n\n// children?: FormItems[];\n// hidden?: boolean; // 是否隐藏\n// help?: string; // 帮助信息\n\n// span?: number; // 栅格占据的列数\n// labelWidth?: string; // formitem 标签宽度 \n\n// component?: VNode;\n// };\n// type VNodeFunction = ({ scope,h }) => VNode | ({ scope,h }) =><div>{ scope }</div> | <div />;\n\n// type VNodeObject = { \n// name?: string | Component; // 组件名 | 组件引用\n// options?: any[]; // 选项\n// attrs?: any; // 属性\n// on?: any; // 事件\n// props?: any; // 属性\n// [key: string]: any;\n// };\n// type VNode = string | VNodeFunction | VNodeObject;\n\n\nexport default {\n props: {\n // 表单配置项,可以从外部传入\n formItems: {\n type: Array,\n default: () => []\n },\n // 初始表单数据\n initialFormData: {\n type: Object,\n default: () => ({})\n },\n // 按钮配置\n buttons: {\n type: Object,\n default: () => ({\n submit: {\n show: true,\n text: '提交',\n type: 'primary',\n loading: false\n },\n cancel: {\n show: true,\n text: '取消',\n type: 'default'\n }\n })\n },\n // 按钮位置\n buttonPosition: {\n type: String,\n default: 'right', // center, left, right\n validator: value => ['center', 'left', 'right'].includes(value)\n },\n // 是否显示按钮区域\n showButtons: {\n type: Boolean,\n default: true\n },\n readonly: {\n type: Boolean\n },\n labelWidth: {\n type: String,\n default: '80px'\n },\n column: {\n type: Number,\n default: 2\n },\n gutter: {\n type: Number,\n default: 10\n },\n size: {\n type: String,\n default: 'small'\n },\n // value: {\n // type: Object,\n // default: () => ({})\n // },\n\n\n },\n\n data() {\n return {\n form: {},\n // 如果没有传入formItems,则使用默认配置\n items: [],\n activeName: 'first',\n submitLoading: false\n\n }\n },\n\n computed: {\n // 从items中提取所有字段的规则\n formRules() {\n const rules = {};\n\n // 递归提取规则函数\n const extractRules = (nodes) => {\n if (!nodes || !nodes.length) return;\n\n nodes.forEach(node => {\n // 如果节点有children,递归处理\n if (node.children && node.children.length) {\n extractRules(node.children);\n }\n\n // 如果是表单字段且有规则,添加到规则对象\n if (node.prop && node.rules) {\n rules[node.prop] = node.rules;\n }\n });\n };\n\n // 对所有配置项提取规则\n extractRules(this.items);\n\n return rules;\n },\n // 按钮区域样式\n buttonAreaStyle() {\n return {\n textAlign: this.buttonPosition,\n marginTop: '20px'\n };\n },\n // label宽度\n labelStyle() {\n return {\n width: this.labelWidth,\n textAlign: 'center'\n };\n },\n\n\n },\n\n watch: {\n // 监听外部传入的表单数据变化\n initialFormData: {\n handler(val) {\n this.form = JSON.parse(JSON.stringify(val));\n },\n immediate: true,\n deep: true\n },\n // 监听外部传入的表单配置变化\n formItems: {\n handler(val) {\n if (val && val.length) {\n this.items = val;\n }\n },\n immediate: true,\n deep: true\n },\n // 监听外部传入的value变化\n // value: {\n // handler(val) {\n // this.form = JSON.parse(JSON.stringify(val)) || {};\n // },\n // immediate: true,\n // deep: true\n // },\n // v-model绑定的值变化时,更新表单数据\n form: {\n handler(val) {\n this.$emit('input', val);\n },\n deep: true\n }\n },\n\n methods: {\n // 处理表单输入事件\n handleInput(prop, value) {\n this.$set(this.form, prop, value);\n // 触发change事件,将变更通知给父组件\n this.$emit('field-change', { prop, value, form: this.form });\n },\n\n // 递归渲染函数 - 根据节点类型渲染不同内容\n renderNode(node, index) {\n // 如果是只读模式,使用只读渲染函数\n if (this.readonly) {\n return this.renderReadOnlyNode(node, index);\n }\n\n // 如果是输入字段(没有type或没有children,则视为字段)\n if (!node.type || (!node.children && node.prop)) {\n return this.renderField(node, index);\n }\n\n // 根据节点类型渲染\n switch (node.type) {\n case 'tab':\n return this.renderTab(node, index);\n case 'group':\n return this.renderGroup(node, index);\n default:\n // 默认当作字段渲染\n return this.renderField(node, index);\n }\n },\n\n // 只读模式 - 递归渲染函数\n renderReadOnlyNode(node, index) {\n if (!node.type || (!node.children && node.prop)) {\n return this.renderReadOnlyField(node, index);\n }\n switch (node.type) {\n case 'tab':\n return this.renderReadOnlyTab(node, index);\n case 'group':\n return this.renderReadOnlyGroup(node, index);\n default:\n return this.renderReadOnlyField(node, index);\n }\n },\n\n // 只读模式 - 渲染标签页\n renderReadOnlyTab(tab, index) {\n return (\n <el-tab-pane\n key={tab.name || index}\n label={tab.label}\n name={tab.name || index}\n {...tab.props}\n >\n {this.renderReadOnlyChildren(tab.children)}\n </el-tab-pane>\n );\n },\n\n // 只读模式 - 渲染分组\n renderReadOnlyGroup(group, index) {\n return (\n <div class={['el-form-group', group.className]} key={index} {...group.props}>\n <el-descriptions\n title={group.title}\n border\n column={this.column}\n size={this.size}\n labelStyle={this.labelStyle}\n >\n {this.renderReadOnlyDescriptionItems(group.children)}\n </el-descriptions>\n </div>\n );\n },\n\n // 只读模式 - 渲染字段\n renderReadOnlyField(field, index) {\n // 如果字段被配置为隐藏,则不渲染\n if (field.hidden) {\n return null;\n }\n\n // 获取字段值\n const value = this.form[field.prop];\n\n // 处理显示值\n let displayValue = value;\n\n // 处理不同类型的字段显示值\n if (field.options && Array.isArray(field.options)) {\n const option = field.options.find(opt => opt.value === value);\n if (option) {\n displayValue = option.label;\n }\n }\n\n // 如果处于顶层(不在group内),则需要包装在el-descriptions中\n if (!field._inGroup) {\n return (\n <el-col span={24 / this.column || field.span || 12} key={field.prop || index}>\n <el-descriptions labelStyle={this.labelStyle} border column={this.column} size={this.size}>\n <el-descriptions-item label={field.label || ''}>\n {displayValue || '-'}\n </el-descriptions-item>\n </el-descriptions>\n </el-col>\n );\n }\n // 在group内部的字段直接返回\n return (\n <el-descriptions-item label={field.label || ''}>\n {displayValue || '-'}\n </el-descriptions-item>\n );\n },\n\n // 只读模式 - 渲染描述项\n renderReadOnlyDescriptionItems(children) {\n if (!children || !children.length) {\n return null;\n }\n\n return children.map(child => {\n // 标记字段在group内部\n child._inGroup = true;\n return this.renderReadOnlyField(child);\n });\n },\n\n // 只读模式 - 渲染子节点\n renderReadOnlyChildren(children) {\n // 如果没有子节点,返回空\n if (!children || !children.length) {\n return null;\n }\n\n // 检查第一个子节点类型,判断是否需要包装\n const firstChild = children[0];\n\n // 如果第一个子节点是group,不需要额外包装\n if (firstChild.type === 'group') {\n return children.map((child, index) => this.renderReadOnlyNode(child, index));\n }\n\n // 如果子节点不是输入字段,也不是分组,则直接渲染\n if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {\n return children.map((child, index) => this.renderReadOnlyNode(child, index));\n }\n\n // 如果是普通字段(非group),则包装在el-descriptions中\n return (\n <el-descriptions border column={this.column} size={this.size} labelStyle={this.labelStyle}>\n {children.map((child, index) => {\n child._inGroup = true;\n return this.renderReadOnlyNode(child, index);\n })}\n </el-descriptions>\n );\n },\n\n // 渲染标签页\n renderTab(tab, index) {\n return (\n <el-tab-pane\n key={tab.name || index}\n label={tab.label}\n name={tab.name || index}\n {...tab.props}\n >\n {this.renderChildren(tab.children)}\n </el-tab-pane>\n );\n },\n\n // 渲染分组\n renderGroup(group, index) {\n return (\n <div class={['el-form-group', group.className]} key={index} {...group.props}>\n {group.title && <div class=\"el-form-group__title\">{group.title}</div>}\n <div>\n {this.renderChildren(group.children)}\n </div>\n </div>\n );\n },\n\n // 渲染各种表单控件\n renderFormControl(field) {\n let component = field.component;\n if (isString(field.component)) {\n component = {\n name: field.component,\n attrs: {\n placeholder: field.placeholder || `请输入${field.label}`,\n clearable: typeof field.clearable !== 'undefined' ? field.clearable : true,\n }\n }\n }\n if ( !isFunction(field.component)) {\n if (field.component === 'el-select') {\n component.attrs = {\n ...component.attrs,\n placeholder: field.placeholder || `请选择${field.label}`,\n filterable: true,\n\n }\n } \n }\n\n if( field.hook?.bind?.length ){\n let value = valueHook.bind(this.form[ field.prop ], field.hook?.bind , this.form)\n this.$set(this.form, field.prop, value)\n }\n // component 渲染 { prop: this.column.prop, scope: scope }\n return renderNode.call(this, component, {\n prop: field.prop,\n scope: this.form\n });\n\n },\n\n // 渲染字段\n renderField(field, index) {\n // 如果字段被配置为隐藏,则不渲染\n if (field.hidden) {\n return null;\n }\n return (\n <el-col span={24 / this.column || field.span || 12} key={field.prop || index}>\n <el-form-item\n label={field.label}\n prop={field.prop}\n rules={field.rules} // 直接使用字段自身的规则\n labelWidth={field.labelWidth || this.labelWidth}\n {...field.formItemProps}\n >\n {this.renderFormControl(field)}\n {field.help && <div class=\"form-item-help\">{field.help}</div>}\n </el-form-item>\n </el-col>\n );\n },\n\n // 渲染子节点\n renderChildren(children) {\n // 如果没有子节点,返回空\n if (!children || !children.length) {\n return null;\n }\n\n // 检查第一个子节点类型,判断是否需要包装\n const firstChild = children[0];\n\n // 如果第一个子节点是group,不需要额外包装\n if (firstChild.type === 'group') {\n return children.map(this.renderNode);\n }\n\n // 如果子节点不是输入字段,也不是分组,则直接渲染\n if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {\n return children.map(this.renderNode);\n }\n\n // 其他情况(子节点是输入字段)包装在row中\n return <el-row gutter={this.gutter}>{children.map(this.renderNode)}</el-row>;\n },\n\n // 判断是否有标签页\n hasTabs() {\n return this.items && this.items.some(item => item.type === 'tab');\n },\n\n // 渲染按钮区域\n renderButtons() {\n if (!this.showButtons || this.readonly) return null;\n\n return (\n <div class=\"form-button-area\" style={this.buttonAreaStyle}>\n {this.buttons.cancel && this.buttons.cancel.show && (\n <el-button\n onClick={this.handleCancel}\n type={this.buttons.cancel.type}\n {...this.buttons.cancel.props}\n >\n {this.buttons.cancel.text}\n </el-button>\n )}\n {this.buttons.submit && this.buttons.submit.show && (\n <el-button\n onClick={this.handleSubmit}\n type={this.buttons.submit.type}\n loading={this.submitLoading || (this.buttons.submit.loading)}\n {...this.buttons.submit.props}\n >\n {this.buttons.submit.text}\n </el-button>\n )}\n </div>\n );\n },\n\n // 处理提交\n async handleSubmit() {\n try {\n this.submitLoading = true;\n // 表单验证\n const formData = await this.validate();\n // 发出提交事件\n this.$emit('submit', formData);\n\n // return formData;\n } catch (error) {\n this.$emit('submit-error', error);\n return Promise.reject(error);\n }\n this.submitLoading = false;\n },\n\n // 处理取消\n handleCancel() {\n this.$emit('cancel');\n },\n\n // 表单验证方法\n validate() {\n return new Promise((resolve, reject) => {\n this.$refs.form.validate(valid => {\n if (valid) {\n resolve(this.form);\n } else {\n reject(new Error('表单验证失败'));\n }\n });\n });\n },\n\n // 重置表单\n resetForm() {\n this.form = JSON.parse(JSON.stringify(this.initialFormData)) || {};\n this.$refs.form.resetFields();\n this.$emit('form-reset', this.form);\n },\n\n // 获取表单数据\n getFormData() {\n return this.form;\n }\n },\n\n render() {\n\n if (this.readonly) {\n // 只读模式渲染\n return (\n <div class=\"dynamic-form-container readonly\">\n {this.hasTabs() ? (\n // 渲染标签页结构\n <el-tabs v-on={this.$listeners} v-model={this.activeName}>\n {this.items.map((item, index) => this.renderReadOnlyNode(item, index))}\n </el-tabs>\n ) : (\n // 非标签页结构,直接渲染\n this.renderReadOnlyChildren(this.items)\n )}\n </div>\n );\n }\n\n const formProps = {\n model: this.form,\n rules: this.formRules,\n ...this.$attrs\n };\n // 如果没有配置项,渲染空表单\n if (!this.items || !this.items.length) {\n return <div class=\"dynamic-form-container\"><el-form ref=\"form\" {...{ props: formProps }}></el-form></div>;\n }\n\n return (\n <div class=\"dynamic-form-container\">\n <el-form ref=\"form\" {...{ props: formProps }}>\n {this.hasTabs() ? (\n // 渲染标签页结构\n <el-tabs v-on={this.$listeners} v-model={this.activeName}>\n {this.items.map(this.renderNode)}\n </el-tabs>\n ) : (\n // 非标签页结构,直接渲染\n this.renderChildren(this.items)\n )}\n\n {/* 渲染按钮区域 */}\n {this.renderButtons()}\n </el-form>\n </div>\n );\n }\n}\n</script>\n\n<style scoped lang=\"scss\">\n.dynamic-form-container {\n padding: 20px;\n\n .el-form{\n \n\n .el-form-item {\n \n &::v-deep{\n .el-input,\n .el-select{\n width: 100%;\n }\n .el-input__inner {\n width: 100%;\n }\n }\n\n }\n\n \n\n }\n}\n\n.el-form-group {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n\n.el-form-group__title {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n\n.form-button-area {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n\n.form-button-area .el-button+.el-button {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly {\n .el-descriptions__body {\n background-color: #fafafa;\n }\n\n .el-descriptions-item__label {\n font-weight: bold;\n }\n\n .el-descriptions-item__content {\n word-break: break-all;\n }\n}\n</style>\n"]
3591
+ },
3592
+ media: undefined
3593
+ });
3594
+ };
3595
+ /* scoped */
3596
+ var __vue_scope_id__ = "data-v-ef86d32c";
3597
+ /* module identifier */
3598
+ var __vue_module_identifier__ = undefined;
3599
+ /* functional template */
3600
+ var __vue_is_functional_template__ = undefined;
3601
+ /* style inject SSR */
3602
+
3603
+ /* style inject shadow dom */
3604
+
3605
+ var __vue_component__ = /*#__PURE__*/normalizeComponent({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, createInjector, undefined, undefined);
3606
+
3607
+ ___$insertStylesToHeader(".el-crud .flex {\n display: flex;\n}\n.el-crud .inline-flex {\n display: inline-flex;\n}\n.el-crud .hidden {\n display: none;\n}\n.el-crud .block {\n display: block;\n}\n.el-crud .inline-block {\n display: inline-block;\n}\n.el-crud .flex-row {\n flex-direction: row;\n}\n.el-crud .flex-row-reverse {\n flex-direction: row-reverse;\n}\n.el-crud .flex-col {\n flex-direction: column;\n}\n.el-crud .flex-col-reverse {\n flex-direction: column-reverse;\n}\n.el-crud .flex-wrap {\n flex-wrap: wrap;\n}\n.el-crud .flex-nowrap {\n flex-wrap: nowrap;\n}\n.el-crud .flex-wrap-reverse {\n flex-wrap: wrap-reverse;\n}\n.el-crud .justify-start {\n justify-content: flex-start;\n}\n.el-crud .justify-end {\n justify-content: flex-end;\n}\n.el-crud .justify-center {\n justify-content: center;\n}\n.el-crud .justify-between {\n justify-content: space-between;\n}\n.el-crud .justify-around {\n justify-content: space-around;\n}\n.el-crud .justify-evenly {\n justify-content: space-evenly;\n}\n.el-crud .items-start {\n align-items: flex-start;\n}\n.el-crud .items-end {\n align-items: flex-end;\n}\n.el-crud .items-center {\n align-items: center;\n}\n.el-crud .items-baseline {\n align-items: baseline;\n}\n.el-crud .items-stretch {\n align-items: stretch;\n}\n.el-crud .content-start {\n align-content: flex-start;\n}\n.el-crud .content-end {\n align-content: flex-end;\n}\n.el-crud .content-center {\n align-content: center;\n}\n.el-crud .content-between {\n align-content: space-between;\n}\n.el-crud .content-around {\n align-content: space-around;\n}\n.el-crud .content-evenly {\n align-content: space-evenly;\n}\n.el-crud .self-auto {\n align-self: auto;\n}\n.el-crud .self-start {\n align-self: flex-start;\n}\n.el-crud .self-end {\n align-self: flex-end;\n}\n.el-crud .self-center {\n align-self: center;\n}\n.el-crud .self-stretch {\n align-self: stretch;\n}\n.el-crud .flex-1 {\n flex: 1 1 0%;\n}\n.el-crud .flex-auto {\n flex: 1 1 auto;\n}\n.el-crud .flex-initial {\n flex: 0 1 auto;\n}\n.el-crud .flex-none {\n flex: none;\n}\n.el-crud .grow {\n flex-grow: 1;\n}\n.el-crud .grow-0 {\n flex-grow: 0;\n}\n.el-crud .shrink {\n flex-shrink: 1;\n}\n.el-crud .shrink-0 {\n flex-shrink: 0;\n}\n.el-crud .w-full {\n width: 100%;\n}\n.el-crud .w-auto {\n width: auto;\n}\n.el-crud .h-full {\n height: 100%;\n}\n.el-crud .h-auto {\n height: auto;\n}\n.el-crud .h-screen {\n height: 100vh;\n}\n.el-crud .m-0 {\n margin: 0;\n}\n.el-crud .m-auto {\n margin: auto;\n}\n.el-crud .mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n.el-crud .my-auto {\n margin-top: auto;\n margin-bottom: auto;\n}\n.el-crud .text-left {\n text-align: left;\n}\n.el-crud .text-center {\n text-align: center;\n}\n.el-crud .text-right {\n text-align: right;\n}\n.el-crud .text-justify {\n text-align: justify;\n}\n.el-crud .font-normal {\n font-weight: 400;\n}\n.el-crud .font-medium {\n font-weight: 500;\n}\n.el-crud .font-semibold {\n font-weight: 600;\n}\n.el-crud .font-bold {\n font-weight: 700;\n}\n.el-crud .overflow-hidden {\n overflow: hidden;\n}\n.el-crud .overflow-auto {\n overflow: auto;\n}\n.el-crud .overflow-scroll {\n overflow: scroll;\n}\n.el-crud .overflow-x-auto {\n overflow-x: auto;\n}\n.el-crud .overflow-y-auto {\n overflow-y: auto;\n}\n.el-crud .relative {\n position: relative;\n}\n.el-crud .absolute {\n position: absolute;\n}\n.el-crud .fixed {\n position: fixed;\n}\n.el-crud .sticky {\n position: sticky;\n}\n.el-crud .cursor-pointer {\n cursor: pointer;\n}\n.el-crud .cursor-not-allowed {\n cursor: not-allowed;\n}\n.el-crud-toolbar {\n margin-top: 10px;\n}\n.el-crud .crud-table {\n margin-top: 10px;\n}\n\n/*# sourceMappingURL=output.css.map */");
3608
+
3609
+ exports.Crud = __vue_component__$1;
3610
+ exports.CrudForm = __vue_component__;
3611
+ exports.CrudTable = __vue_component__$5;
3612
+ exports.QueryForm = __vue_component__$3;
3613
+
3614
+ }));
3615
+ //# sourceMappingURL=index.umd.js.map