dpot-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
File without changes
@@ -0,0 +1,893 @@
1
+ var x = function() {
2
+ var e = this, r = e.$createElement, o = e._self._c || r;
3
+ return o("div", {
4
+ class: ["dp-check_view_", e.value.includes(e.data.code) && "dp-check_view_checked_"],
5
+ attrs: {
6
+ disabled: e.disabled
7
+ },
8
+ on: {
9
+ click: function(t) {
10
+ return t.stopPropagation(), e.handleChange.apply(null, arguments);
11
+ }
12
+ }
13
+ }, [o("span", {
14
+ staticClass: "dp-check_tag_"
15
+ }), o("span", {
16
+ staticClass: "dp-check_name_"
17
+ }, [e._v(e._s(e.data.name))])]);
18
+ }, S = [];
19
+ function h(e, r, o, t, n, s, a, l) {
20
+ var i = typeof e == "function" ? e.options : e;
21
+ r && (i.render = r, i.staticRenderFns = o, i._compiled = !0), t && (i.functional = !0), s && (i._scopeId = "data-v-" + s);
22
+ var d;
23
+ if (a ? (d = function(c) {
24
+ c = c || // cached call
25
+ this.$vnode && this.$vnode.ssrContext || // stateful
26
+ this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !c && typeof __VUE_SSR_CONTEXT__ < "u" && (c = __VUE_SSR_CONTEXT__), n && n.call(this, c), c && c._registeredComponents && c._registeredComponents.add(a);
27
+ }, i._ssrRegister = d) : n && (d = l ? function() {
28
+ n.call(
29
+ this,
30
+ (i.functional ? this.parent : this).$root.$options.shadowRoot
31
+ );
32
+ } : n), d)
33
+ if (i.functional) {
34
+ i._injectStyles = d;
35
+ var I = i.render;
36
+ i.render = function($, p) {
37
+ return d.call(p), I($, p);
38
+ };
39
+ } else {
40
+ var f = i.beforeCreate;
41
+ i.beforeCreate = f ? [].concat(f, d) : [d];
42
+ }
43
+ return {
44
+ exports: e,
45
+ options: i
46
+ };
47
+ }
48
+ const w = {
49
+ name: "dp-check",
50
+ props: {
51
+ data: {
52
+ type: Object
53
+ },
54
+ value: {
55
+ type: Array
56
+ },
57
+ disabled: {
58
+ type: Boolean
59
+ }
60
+ },
61
+ methods: {
62
+ handleChange() {
63
+ if (this.disabled)
64
+ return;
65
+ const e = this.value.includes(this.data.code) ? this.value.filter((r) => r !== this.data.code) : [...this.value, this.data.code];
66
+ this.$emit("change", e, this.data.key);
67
+ }
68
+ }
69
+ }, g = {};
70
+ var k = /* @__PURE__ */ h(
71
+ w,
72
+ x,
73
+ S,
74
+ !1,
75
+ D,
76
+ "1b8ae42a",
77
+ null,
78
+ null
79
+ );
80
+ function D(e) {
81
+ for (let r in g)
82
+ this[r] = g[r];
83
+ }
84
+ const H = /* @__PURE__ */ function() {
85
+ return k.exports;
86
+ }();
87
+ var F = function() {
88
+ var e = this, r = e.$createElement, o = e._self._c || r;
89
+ return o("div", {
90
+ class: ["dp-radio_view_", e.value === e.data.code && "dp-radio_view_checked_"],
91
+ attrs: {
92
+ disabled: e.disabled
93
+ },
94
+ on: {
95
+ click: function(t) {
96
+ return t.stopPropagation(), e.handleChange.apply(null, arguments);
97
+ }
98
+ }
99
+ }, [o("span", {
100
+ staticClass: "dp-radio_tag_"
101
+ }), o("span", {
102
+ staticClass: "dp-radio_name_"
103
+ }, [e._v(e._s(e.data.name))])]);
104
+ }, j = [];
105
+ const O = {
106
+ name: "dp-radio",
107
+ props: {
108
+ data: {
109
+ type: Object
110
+ },
111
+ value: {
112
+ type: [String, Number, Boolean]
113
+ },
114
+ disabled: {
115
+ type: Boolean
116
+ }
117
+ },
118
+ methods: {
119
+ handleChange() {
120
+ if (this.disabled)
121
+ return !1;
122
+ this.$emit("change", this.data.code, this.data.key);
123
+ }
124
+ }
125
+ }, b = {};
126
+ var R = /* @__PURE__ */ h(
127
+ O,
128
+ F,
129
+ j,
130
+ !1,
131
+ M,
132
+ "e7bf9628",
133
+ null,
134
+ null
135
+ );
136
+ function M(e) {
137
+ for (let r in b)
138
+ this[r] = b[r];
139
+ }
140
+ const T = /* @__PURE__ */ function() {
141
+ return R.exports;
142
+ }();
143
+ var E = function() {
144
+ var e = this, r = e.$createElement, o = e._self._c || r;
145
+ return o("div", {
146
+ staticClass: "dp-checkfilter_view_"
147
+ }, [o("span", {
148
+ class: [e.value.length && "dp-checkfilter_title_checked_"]
149
+ }, [e._v(e._s(e.title))]), o("span", {
150
+ staticClass: "dp-checkfilter_arrow_"
151
+ }), o("div", {
152
+ staticClass: "dp-checkfilter_option_view_"
153
+ }, [o("div", {
154
+ staticClass: "dp-checkfilter_option_list_"
155
+ }, [e.type === "check" ? e._l(e.option, function(t) {
156
+ return o("dp-check", {
157
+ key: t.code,
158
+ attrs: {
159
+ data: Object.assign({}, t, {
160
+ key: e.code
161
+ }),
162
+ value: e.value
163
+ },
164
+ on: {
165
+ change: e.handleChange
166
+ }
167
+ });
168
+ }) : e.type === "radio" ? e._l(e.option, function(t) {
169
+ return o("dp-radio", {
170
+ key: t.code,
171
+ attrs: {
172
+ data: Object.assign({}, t, {
173
+ key: e.code
174
+ }),
175
+ value: e.value[0]
176
+ },
177
+ on: {
178
+ change: e.handleChange
179
+ }
180
+ });
181
+ }) : e._e()], 2)])]);
182
+ }, W = [];
183
+ const z = {
184
+ name: "dp-checkfilter",
185
+ components: {
186
+ DpCheck: H,
187
+ DpRadio: T
188
+ },
189
+ props: {
190
+ title: {
191
+ type: String
192
+ },
193
+ code: {
194
+ type: String
195
+ },
196
+ type: {
197
+ type: String,
198
+ validator(e) {
199
+ return ["check", "radio"].includes(e);
200
+ }
201
+ },
202
+ option: {
203
+ type: Array,
204
+ default: () => []
205
+ },
206
+ value: {
207
+ type: Array,
208
+ default: () => []
209
+ }
210
+ },
211
+ methods: {
212
+ handleChange(e, r) {
213
+ this.$emit("change", { key: r, value: [e].flat() });
214
+ }
215
+ }
216
+ }, v = {};
217
+ var L = /* @__PURE__ */ h(
218
+ z,
219
+ E,
220
+ W,
221
+ !1,
222
+ P,
223
+ "20c78138",
224
+ null,
225
+ null
226
+ );
227
+ function P(e) {
228
+ for (let r in v)
229
+ this[r] = v[r];
230
+ }
231
+ const B = /* @__PURE__ */ function() {
232
+ return L.exports;
233
+ }();
234
+ var K = function() {
235
+ var e = this, r = e.$createElement, o = e._self._c || r;
236
+ return o("li", {
237
+ class: ["dp-table_header_item_ dp-table_header_item_height_", e.item.children ? "dp-table_header_item_group_" : "dp-table_header_item_border_", e.item.sortKey && "dp-table_header_item_cursor_"],
238
+ style: Object.assign({
239
+ borderColor: e.borderColor,
240
+ justifyContent: e.align
241
+ }, e.item.style, e.item.privateStyle),
242
+ on: {
243
+ click: function(t) {
244
+ return t.stopPropagation(), e.handleItemClick(e.item, e.fullCode);
245
+ }
246
+ }
247
+ }, [e._t(e.item.slot || e.item.code, function() {
248
+ return [e.item.children ? [o("div", {
249
+ staticClass: "dp-table_header_item_border_ dp-table_header_item_group_title_ dp-table_header_item_height_",
250
+ style: {
251
+ borderColor: e.borderColor,
252
+ justifyContent: e.align
253
+ }
254
+ }, [e._v(e._s(e.item.name))]), e.item.children ? o("ul", {
255
+ staticClass: "dp-table_header_item_child_",
256
+ style: {
257
+ borderColor: e.borderColor
258
+ }
259
+ }, e._l(e.item.children, function(t) {
260
+ return o("dp-table-header-item", {
261
+ key: t.code,
262
+ attrs: {
263
+ align: e.align,
264
+ fullCode: [].concat(e.fullCode, [t.code]),
265
+ item: t,
266
+ borderColor: e.borderColor,
267
+ sortInfo: e.sortInfo,
268
+ filterInfo: e.filterInfo
269
+ },
270
+ on: {
271
+ changeWidth: e.handleChildResize,
272
+ changeSort: e.handleItemClick,
273
+ changeFilter: e.handleChangeFilter
274
+ },
275
+ scopedSlots: e._u([e._l(e.$slots, function(n, s) {
276
+ return {
277
+ key: s,
278
+ fn: function() {
279
+ return [e._t(s)];
280
+ },
281
+ proxy: !0
282
+ };
283
+ })], null, !0)
284
+ });
285
+ }), 1) : e._e()] : e.item.type && e.item.option ? [o("dp-checkfilter", {
286
+ staticClass: "dp-table_header_filter_view_",
287
+ style: {
288
+ justifyContent: e.align
289
+ },
290
+ attrs: {
291
+ title: e.item.name,
292
+ code: e.item.filterKey || e.item.code,
293
+ type: e.item.type,
294
+ option: e.item.option,
295
+ value: (e.filterInfo[e.fullCode.join("_")] || {}).value
296
+ },
297
+ on: {
298
+ change: e.handleChangeFilter
299
+ }
300
+ })] : [e._v(" " + e._s(e.item.name) + " "), e.item.sortKey ? o("span", {
301
+ class: ["dp-table_header_item_sort_", e.sortInfo.target.join("_") === e.fullCode.join("_") && e.sortInfo.value === "up" && "dp-table_header_item_sort_up_", e.sortInfo.target.join("_") === e.fullCode.join("_") && e.sortInfo.value === "down" && "dp-table_header_item_sort_down_"]
302
+ }) : e._e()]];
303
+ })], 2);
304
+ }, A = [];
305
+ const N = {
306
+ name: "dp-table-header-item",
307
+ components: {
308
+ DpCheckfilter: B
309
+ },
310
+ props: {
311
+ item: {
312
+ type: Object
313
+ },
314
+ align: {
315
+ type: String
316
+ },
317
+ borderColor: {
318
+ type: String
319
+ },
320
+ sortInfo: {
321
+ type: Object
322
+ },
323
+ filterInfo: {
324
+ type: Object
325
+ },
326
+ fullCode: {
327
+ type: Array
328
+ }
329
+ },
330
+ data() {
331
+ return {
332
+ resizer: null,
333
+ widthObj: {}
334
+ };
335
+ },
336
+ methods: {
337
+ handleResize() {
338
+ this.$emit("changeWidth", { [this.fullCode.join("_")]: this.$el.offsetWidth });
339
+ },
340
+ handleChildResize(e) {
341
+ this.widthObj = { ...this.widthObj, ...e }, this.$emit("changeWidth", e);
342
+ },
343
+ handleItemClick(e, r) {
344
+ this.$emit("changeSort", { ...e }, r);
345
+ },
346
+ handleChangeFilter(e) {
347
+ this.$emit("changeFilter", { [this.fullCode.join("_")]: { target: this.fullCode, ...e, filterKey: this.item.filterKey || this.item.code, filterFn: this.item.filterFn } });
348
+ }
349
+ },
350
+ mounted() {
351
+ this.item.children || (this.resizer = new ResizeObserver(this.handleResize), this.resizer.observe(this.$el));
352
+ },
353
+ beforeUnMounted() {
354
+ this.resizer && this.resizer.unobserve(this.$el);
355
+ }
356
+ }, y = {};
357
+ var U = /* @__PURE__ */ h(
358
+ N,
359
+ K,
360
+ A,
361
+ !1,
362
+ q,
363
+ "4272af7c",
364
+ null,
365
+ null
366
+ );
367
+ function q(e) {
368
+ for (let r in y)
369
+ this[r] = y[r];
370
+ }
371
+ const V = /* @__PURE__ */ function() {
372
+ return U.exports;
373
+ }(), u = (e, r, o) => {
374
+ const t = e[o];
375
+ if (!t.isFixed || !r[t.code])
376
+ return {};
377
+ const n = (a) => typeof a == "number" ? [a] : Object.values(a).map((l) => n(l)).flat();
378
+ return { position: "sticky", left: `${e.filter((a, l) => l < o && a.isFixed).map((a) => n(r[a.code])).reduce((a, l) => parseFloat(a) + parseFloat(l), 0)}px` };
379
+ }, _ = (e, r) => {
380
+ const o = e[r[0]];
381
+ return r.length > 1 ? _(o, r.slice(1)) : o;
382
+ };
383
+ var X = function() {
384
+ var e = this, r = e.$createElement, o = e._self._c || r;
385
+ return o("ul", {
386
+ staticClass: "dp-table_header_view_",
387
+ style: {
388
+ borderColor: e.borderColor,
389
+ backgroundColor: e.bgColor
390
+ }
391
+ }, e._l(e.data, function(t, n) {
392
+ return o("dp-item", {
393
+ key: t.code,
394
+ class: [t.isFixed && "dp-table_fixed_bg_", e.isLeftScroll && "dp-table_fixed_shadow_"],
395
+ style: Object.assign({}, e.fixedStyle[n]),
396
+ attrs: {
397
+ item: t,
398
+ align: e.align,
399
+ fullCode: [t.code],
400
+ borderColor: e.borderColor,
401
+ sortInfo: e.sortInfo,
402
+ filterInfo: e.filterInfo
403
+ },
404
+ on: {
405
+ changeWidth: e.handleChangeWidthInfo,
406
+ changeSort: e.handleChangeSort,
407
+ changeFilter: e.handleChangeFilter
408
+ },
409
+ scopedSlots: e._u([e._l(e.$slots, function(s, a) {
410
+ return {
411
+ key: a,
412
+ fn: function() {
413
+ return [e._t(a)];
414
+ },
415
+ proxy: !0
416
+ };
417
+ })], null, !0)
418
+ });
419
+ }), 1);
420
+ }, G = [];
421
+ const J = {
422
+ name: "dp-table-header",
423
+ components: {
424
+ DpItem: V
425
+ },
426
+ props: {
427
+ // 表头数据
428
+ data: {
429
+ type: Array
430
+ },
431
+ // 文字对齐方向
432
+ align: {
433
+ type: String
434
+ },
435
+ // 边框色
436
+ borderColor: {
437
+ type: String
438
+ },
439
+ // 背景色
440
+ bgColor: {
441
+ type: String
442
+ },
443
+ // 是否左滚动
444
+ isLeftScroll: {
445
+ type: Boolean
446
+ },
447
+ // 排序
448
+ sortInfo: {
449
+ type: Object
450
+ },
451
+ // 筛选
452
+ filterInfo: {
453
+ type: Object
454
+ }
455
+ },
456
+ computed: {
457
+ fixedStyle() {
458
+ return this.data.map((e, r) => ({ ...u(this.data, this.widthInfo, r), backgroundColor: this.bgColor }));
459
+ }
460
+ },
461
+ data() {
462
+ return {
463
+ widthInfo: {},
464
+ timer: null
465
+ };
466
+ },
467
+ methods: {
468
+ computFixedStyle: u,
469
+ handleChangeWidthInfo(e) {
470
+ this.widthInfo = { ...this.widthInfo, ...e }, clearTimeout(this.timer), this.timer = setTimeout(() => {
471
+ this.$emit("changeWidth", this.widthInfo);
472
+ }, 300);
473
+ },
474
+ handleChangeSort(e, r) {
475
+ this.$emit("changeSort", e, r);
476
+ },
477
+ handleChangeFilter(e) {
478
+ this.$emit("changeFilter", e);
479
+ }
480
+ }
481
+ }, m = {};
482
+ var Q = /* @__PURE__ */ h(
483
+ J,
484
+ X,
485
+ G,
486
+ !1,
487
+ Y,
488
+ "2553e3f4",
489
+ null,
490
+ null
491
+ );
492
+ function Y(e) {
493
+ for (let r in m)
494
+ this[r] = m[r];
495
+ }
496
+ const Z = /* @__PURE__ */ function() {
497
+ return Q.exports;
498
+ }();
499
+ var ee = function() {
500
+ var e = this, r = e.$createElement, o = e._self._c || r;
501
+ return o("div", {
502
+ staticClass: "dp-table_view_border_",
503
+ style: {
504
+ borderColor: e.borderColor
505
+ }
506
+ }, [o("div", {
507
+ ref: "table",
508
+ staticClass: "dp-table_view_",
509
+ on: {
510
+ "&scroll": function(t) {
511
+ return e.handleScroll.apply(null, arguments);
512
+ }
513
+ }
514
+ }, [o("dp-header", {
515
+ ref: "header",
516
+ attrs: {
517
+ data: e.resultHeadData,
518
+ align: e.dir,
519
+ borderColor: e.borderColor,
520
+ bgColor: e.bgColor,
521
+ isLeftScroll: !!e.scrollLeft,
522
+ sortInfo: e.sortInfo,
523
+ filterInfo: e.filterInfo
524
+ },
525
+ on: {
526
+ changeWidth: e.handleSetWidthInfo,
527
+ changeSort: e.handleChangeSort,
528
+ changeFilter: e.handleChangeFilter
529
+ },
530
+ scopedSlots: e._u([e._l(e.$slots, function(t, n) {
531
+ return {
532
+ key: n,
533
+ fn: function() {
534
+ return [e._t(n)];
535
+ },
536
+ proxy: !0
537
+ };
538
+ })], null, !0)
539
+ }), o("div"), o("div", {
540
+ staticClass: "dp-table_body_view_",
541
+ style: {
542
+ height: e.fullHeight + "px",
543
+ paddingTop: e.beforeHeight + "px"
544
+ }
545
+ }, e._l(e.resultData, function(t) {
546
+ return o("div", {
547
+ key: t.__key,
548
+ class: ["dp-table_body_item_", t.__isTotalData && "dp-table_total_view_"],
549
+ style: Object.assign({
550
+ background: e.evenColor
551
+ }, t.style, e.hoverStyle, {
552
+ height: `${e.fullHeightInfo[t.__key]}px`
553
+ }),
554
+ on: {
555
+ mouseenter: function(n) {
556
+ return e.handleChangeFlag(!0);
557
+ },
558
+ mouseleave: function(n) {
559
+ return e.handleChangeFlag(!1);
560
+ }
561
+ }
562
+ }, [e._l(e.deepHeadData, function(n, s) {
563
+ return [t[n.code] instanceof Object ? [t[n.code].slot ? o("div", {
564
+ class: ["dp-table_body_item_group_col_", n.isFixed && "dp-table_fixed_bg_", !!e.scrollLeft && "dp-table_fixed_shadow_"],
565
+ style: Object.assign({
566
+ borderColor: e.borderColor
567
+ }, n.style, n.colStyle, {
568
+ background: e.evenColor
569
+ }, e.fixedStyle[s], e.computWidth(t[n.code]))
570
+ }, e._l([t[n.code].slot].flat(), function(a) {
571
+ return o("div", {
572
+ key: a,
573
+ staticClass: "dp-table_body_item_child_",
574
+ style: Object.assign({
575
+ borderColor: e.borderColor,
576
+ padding: e.itemPadding,
577
+ justifyContent: e.dir
578
+ }, n.style, n.colStyle, t[n.code].style, {
579
+ width: "100%"
580
+ })
581
+ }, [e._t(a, null, {
582
+ item: t
583
+ })], 2);
584
+ }), 0) : t[n.code].raw ? o("div", {
585
+ class: ["dp-table_body_item_group_col_", n.isFixed && "dp-table_fixed_bg_", !!e.scrollLeft && "dp-table_fixed_shadow_"],
586
+ style: Object.assign({
587
+ borderColor: e.borderColor
588
+ }, n.style, n.colStyle, {
589
+ background: e.evenColor
590
+ }, e.fixedStyle[s], e.computWidth(t[n.code]))
591
+ }, e._l([t[n.code].raw].flat(), function(a, l) {
592
+ return o("div", {
593
+ key: l,
594
+ staticClass: "dp-table_body_item_child_",
595
+ style: Object.assign({
596
+ borderColor: e.borderColor,
597
+ padding: e.itemPadding,
598
+ justifyContent: e.dir
599
+ }, n.style, n.colStyle, t[n.code].style, {
600
+ width: "100%"
601
+ }),
602
+ domProps: {
603
+ innerHTML: e._s(a)
604
+ }
605
+ });
606
+ }), 0) : t[n.code].value ? o("div", {
607
+ class: ["dp-table_body_item_group_col_", n.isFixed && "dp-table_fixed_bg_", !!e.scrollLeft && "dp-table_fixed_shadow_"],
608
+ style: Object.assign({
609
+ borderColor: e.borderColor
610
+ }, n.style, n.colStyle, {
611
+ background: e.evenColor
612
+ }, e.fixedStyle[s], e.computWidth(t[n.code]))
613
+ }, e._l([t[n.code].value].flat(), function(a, l) {
614
+ return o("div", {
615
+ key: l,
616
+ staticClass: "dp-table_body_item_child_",
617
+ style: Object.assign({
618
+ borderColor: e.borderColor,
619
+ padding: e.itemPadding,
620
+ justifyContent: e.dir
621
+ }, n.style, n.colStyle, t[n.code].style, {
622
+ width: "100%"
623
+ })
624
+ }, [e._v(e._s(a))]);
625
+ }), 0) : e._e()] : o("div", {
626
+ class: ["dp-table_body_item_child_", n.isFixed && "dp-table_fixed_bg_", !!e.scrollLeft && "dp-table_fixed_shadow_"],
627
+ style: Object.assign({
628
+ borderColor: e.borderColor,
629
+ padding: e.itemPadding,
630
+ justifyContent: e.dir
631
+ }, n.style, n.colStyle, {
632
+ background: e.evenColor
633
+ }, e.fixedStyle[s])
634
+ }, [e._v(e._s(t[n.code]))])];
635
+ }), t.__isTotalData ? o("span", {
636
+ staticClass: "dp-table_total_border_",
637
+ style: {
638
+ borderColor: e.borderColor
639
+ }
640
+ }) : e._e()], 2);
641
+ }), 0)], 1)]);
642
+ }, te = [];
643
+ const re = {
644
+ name: "dp-table",
645
+ components: {
646
+ DpHeader: Z
647
+ },
648
+ props: {
649
+ // 边框颜色
650
+ borderColor: {
651
+ type: String,
652
+ default: "#ebeef5"
653
+ },
654
+ // 表头背景色
655
+ bgColor: {
656
+ type: String,
657
+ default: "#f5f7fa"
658
+ },
659
+ // 偶数行背景色
660
+ evenColor: {
661
+ type: String,
662
+ default: ""
663
+ },
664
+ // hover行背景色
665
+ hoverColor: {
666
+ type: String,
667
+ default: ""
668
+ },
669
+ // 内容对齐方向
670
+ align: {
671
+ type: String,
672
+ default: "center",
673
+ validator(e) {
674
+ return ["left", "center", "right"].includes(e);
675
+ }
676
+ },
677
+ // 表头数据
678
+ headData: {
679
+ type: Array,
680
+ required: !0
681
+ },
682
+ // 表体数据
683
+ bodyData: {
684
+ type: Array,
685
+ required: !0
686
+ },
687
+ // 合计数据
688
+ totalData: {
689
+ type: Object
690
+ },
691
+ // 表体单行高度
692
+ rowHeight: {
693
+ type: Number,
694
+ default: 0
695
+ },
696
+ // 表体单元格高度
697
+ rowItemHeight: {
698
+ type: Number,
699
+ default: 48
700
+ },
701
+ // 起始序号,默认不显示序号
702
+ basicSub: {
703
+ type: Number,
704
+ default: 0
705
+ },
706
+ // 单元格内边距
707
+ itemPadding: {
708
+ type: String,
709
+ default: "0 10px"
710
+ }
711
+ },
712
+ computed: {
713
+ // 文字对齐方向
714
+ dir() {
715
+ return {
716
+ left: "flex-start",
717
+ center: "center",
718
+ right: "flex-end"
719
+ }[this.align];
720
+ },
721
+ // 组装序号表头
722
+ resultHeadData() {
723
+ const e = this.basicSub > 0 ? { name: "序号", code: "__sub", isFixed: !0, style: { width: "70px" }, privateStyle: { background: this.bgColor } } : null;
724
+ return e ? [e, ...this.headData] : this.headData;
725
+ },
726
+ // 平铺表头
727
+ deepHeadData() {
728
+ const e = [], r = (o) => {
729
+ o.children ? o.children.forEach((t) => r({ ...t, code: `${o.code}_${t.code}` })) : e.push(o);
730
+ };
731
+ return this.resultHeadData.forEach((o) => r(o)), e;
732
+ },
733
+ // 筛选后的表体数据
734
+ filterBodyData() {
735
+ const e = Object.values(this.filterInfo).filter((r) => r.value.length);
736
+ return e.length ? [...this.bodyData].filter((r) => {
737
+ let o = !0;
738
+ return e.some((t) => {
739
+ if (!t.value.includes(_(r, t.target)))
740
+ return o = !1, !0;
741
+ }), o;
742
+ }) : this.bodyData;
743
+ },
744
+ // 表体各行高度数据
745
+ fullHeightInfo() {
746
+ return this.filterBodyData.concat(this.totalData ? [this.totalData] : []).map((e, r) => {
747
+ let o = 0;
748
+ if (this.rowHeight)
749
+ o = this.rowHeight;
750
+ else if (this.rowItemHeight) {
751
+ const t = {}, n = (a, l) => {
752
+ l.children ? l.children.forEach((i) => n((a || {})[i.code], { ...i, code: `${l.code}_${i.code}` })) : t[l.code] = a;
753
+ };
754
+ this.headData.filter((a) => a.children).forEach((a) => n(e[a.code], a)), o = Math.max(...this.deepHeadData.map((a) => t[a.code] instanceof Object ? t[a.code].slot ? [t[a.code].slot].flat().length : t[a.code].raw ? [t[a.code].raw].flat().length : t[a.code].value ? [t[a.code].value].flat().length : 1 : 1)) * this.rowItemHeight;
755
+ }
756
+ return o;
757
+ });
758
+ },
759
+ // 表体渲染数据
760
+ resultData() {
761
+ return Object.keys(this.widthInfo).length < this.headData.length || !this.headData.length ? [] : (this.sortInfo.value ? [...this.filterBodyData].sort((r, o) => {
762
+ const t = _(r, this.sortInfo.target), n = _(o, this.sortInfo.target);
763
+ return this.sortInfo.value === "up" ? t - n : n - t;
764
+ }) : this.filterBodyData).slice(this.beforeIndex, this.currentIndex).concat(this.totalData ? [{ ...this.totalData, __sub: "", __isTotalData: !0 }] : []).map((r, o) => {
765
+ const t = {}, n = (s, a) => {
766
+ a.children ? a.children.forEach((l) => n((s || {})[l.code], { ...l, code: `${a.code}_${l.code}` })) : t[a.code] = s;
767
+ };
768
+ return this.headData.filter((s) => s.children).forEach((s) => n(r[s.code], s)), Object.keys(t).forEach((s) => {
769
+ if (t[s] instanceof Object && (t[s].merge || 0) > 1) {
770
+ const a = this.deepHeadData.findIndex((i) => i.code === s), l = this.deepHeadData.slice(a, a + t[s].merge);
771
+ l.forEach((i) => {
772
+ const d = t[i.code];
773
+ d instanceof Object || (t[i.code] = { value: d }), t[i.code] = { ...t[i.code], isMergeIgnored: !0 };
774
+ }), t[s].isMerge = !0, t[s].width = l.map((i) => this.widthInfo[i.code]).reduce((i, d) => i + d, 0);
775
+ }
776
+ }), {
777
+ __sub: o + parseInt(this.basicSub) + this.beforeIndex,
778
+ ...r,
779
+ ...t,
780
+ __key: o + this.beforeIndex
781
+ };
782
+ });
783
+ },
784
+ // 冻结列样式
785
+ fixedStyle() {
786
+ return this.headData.map((e, r) => u(this.resultHeadData, this.widthInfo, r));
787
+ },
788
+ // 行hover样式
789
+ hoverStyle() {
790
+ return this.headData.map((e) => this.hoverFlag ? { background: this.hoverColor } : {});
791
+ },
792
+ // 表体总高度
793
+ fullHeight() {
794
+ return this.fullHeightInfo.reduce((e, r) => e + r, 0);
795
+ },
796
+ // 计算单行高度
797
+ resultRowHeight() {
798
+ return this.rowHeight || (this.rowItemHeight * (this.bodyData.length + (this.totalData ? 1 : 0)) === this.fullHeight ? this.rowItemHeight : this.rowHeight);
799
+ },
800
+ // 前置填充高度
801
+ beforeHeight() {
802
+ return Math.max(this.resultRowHeight ? this.beforeIndex * this.resultRowHeight : this.fullHeightInfo.slice(0, this.beforeIndex).reduce((e, r) => e + r, 0), 0);
803
+ }
804
+ },
805
+ watch: {
806
+ bodyData() {
807
+ this.$refs.table.scrollTop = 0, this.$refs.table.scrollLeft = 0, this.scrollLeft = 0, this.beforeIndex = 0, this.currentIndex = 30;
808
+ }
809
+ },
810
+ data() {
811
+ return {
812
+ widthInfo: {},
813
+ scrollLeft: 0,
814
+ currentIndex: 30,
815
+ beforeIndex: 0,
816
+ timer: null,
817
+ hoverFlag: !1,
818
+ sortInfo: {
819
+ target: [],
820
+ value: null
821
+ },
822
+ filterInfo: {}
823
+ };
824
+ },
825
+ methods: {
826
+ // 计算合并单元格的宽度
827
+ computWidth(e) {
828
+ return e instanceof Object && e.isMerge ? { width: `${e.width}px` } : {};
829
+ },
830
+ // 收集表头各单元格宽度数据
831
+ handleSetWidthInfo(e) {
832
+ this.widthInfo = e;
833
+ },
834
+ // 滚动事件
835
+ handleScroll(e) {
836
+ this.scrollLeft = e.target.scrollLeft, clearTimeout(this.timer), this.timer = setTimeout(() => {
837
+ if (this.resultRowHeight)
838
+ this.beforeIndex = Math.max(Math.floor((e.target.scrollTop - this.$el.offsetHeight / 2) / this.resultRowHeight), 0), this.currentIndex = Math.max(this.beforeIndex + Math.ceil(this.$el.offsetHeight / this.resultRowHeight) * 2, 30);
839
+ else {
840
+ let r = 0, o = 0;
841
+ this.beforeIndex = this.fullHeightInfo.findIndex((t) => {
842
+ const n = r + t >= e.target.scrollTop - this.$el.offsetHeight / 2;
843
+ return n || (r += t), n;
844
+ }), o = r, this.currentIndex = Math.max(this.beforeIndex + this.fullHeightInfo.slice(this.beforeIndex).findIndex((t) => (o += t, o >= r + this.$el.offsetHeight * 2)), 30);
845
+ }
846
+ }, 10);
847
+ },
848
+ // 单行hover
849
+ handleChangeFlag(e) {
850
+ this.hoverFlag = e;
851
+ },
852
+ // 操作排序
853
+ handleChangeSort(e, r) {
854
+ if (this.sortInfo.target.join("_") === r.join("_")) {
855
+ const o = ["up", "down", null];
856
+ this.sortInfo.value = o[(o.findIndex((t) => t === (this.sortInfo.value || null)) + 1) % o.length];
857
+ } else
858
+ this.sortInfo = { target: r, value: "up", sortKey: e.sortKey, sortFn: e.sortFn || null };
859
+ this.$emit("changeSort", { key: e.sortKey, value: this.sortInfo.value });
860
+ },
861
+ // 操作筛选
862
+ handleChangeFilter(e) {
863
+ this.filterInfo = { ...this.filterInfo, ...e }, this.beforeIndex = 0, this.currentIndex = 30, this.$refs.table.scrollTop = 0, this.$emit("changeFilter", Object.values(this.filterInfo).map((r) => ({ key: r.key, value: r.value })));
864
+ }
865
+ }
866
+ }, C = {};
867
+ var oe = /* @__PURE__ */ h(
868
+ re,
869
+ ee,
870
+ te,
871
+ !1,
872
+ ne,
873
+ "c60b4a66",
874
+ null,
875
+ null
876
+ );
877
+ function ne(e) {
878
+ for (let r in C)
879
+ this[r] = C[r];
880
+ }
881
+ const ae = /* @__PURE__ */ function() {
882
+ return oe.exports;
883
+ }(), ie = [
884
+ ae
885
+ ], se = {
886
+ install: (e) => {
887
+ ie.forEach((r) => e.component(r.name, r));
888
+ }
889
+ };
890
+ export {
891
+ ae as Table,
892
+ se as default
893
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .dp-check_view_[data-v-1b8ae42a]{font-size:14px;padding:5px 10px;min-width:60px;display:flex;cursor:pointer}.dp-check_view_[data-v-1b8ae42a]:hover{background-color:#e8e8e8}.dp-check_view_[disabled][data-v-1b8ae42a]{pointer-events:none}.dp-check_tag_[data-v-1b8ae42a]{width:14px;height:14px;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;border:1px solid #999;margin-right:10px;transform:translateY(1px)}.dp-check_name_[data-v-1b8ae42a]{white-space:break-spaces}.dp-check_view_checked_ .dp-check_tag_[data-v-1b8ae42a]{border-color:#fe8227;background-color:#fe8227}.dp-check_view_checked_ .dp-check_tag_[data-v-1b8ae42a]:before{content:"";width:9px;height:5px;border-bottom:1px solid #fff;border-left:1px solid #fff;transform:rotate(-45deg) translate(1px,-1px)}.dp-check_view_checked_ .dp-check_name_[data-v-1b8ae42a]{color:#fe8227}.dp-radio_view_[data-v-e7bf9628]{font-size:14px;padding:5px 10px;min-width:60px;display:flex;cursor:pointer}.dp-radio_view_[data-v-e7bf9628]:hover{background-color:#e8e8e8}.dp-radio_view_[disabled][data-v-e7bf9628]{pointer-events:none}.dp-radio_tag_[data-v-e7bf9628]{width:14px;height:14px;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;border:1px solid #999;margin-right:10px;transform:translateY(1px)}.dp-radio_name_[data-v-e7bf9628]{white-space:break-spaces}.dp-radio_view_checked_ .dp-radio_tag_[data-v-e7bf9628]{border-color:#fe8227}.dp-radio_view_checked_ .dp-radio_tag_[data-v-e7bf9628]:before{content:"";width:10px;height:10px;border-radius:50%;background-color:#fe8227}.dp-radio_view_checked_ .dp-radio_name_[data-v-e7bf9628]{color:#fe8227}.dp-checkfilter_view_[data-v-20c78138]{display:flex;align-items:center;justify-content:center;padding:10px 0;position:relative;cursor:pointer}.dp-checkfilter_arrow_[data-v-20c78138]{position:relative;width:6px;height:6px;margin:0 10px;border-bottom:2px solid #999;border-left:2px solid #999;transform:rotate(-45deg) translateY(-2px);transition:all .1s}.dp-checkfilter_option_view_[data-v-20c78138]{overflow:hidden;visibility:hidden;position:absolute;z-index:1000;left:0;top:100%;width:100%;border-radius:5px;box-shadow:3px 3px 10px #c3c3c3;transform:scaleY(0);transform-origin:top;transition:all .1s}.dp-checkfilter_title_checked_[data-v-20c78138]{color:#fe8227}.dp-checkfilter_view_:hover .dp-checkfilter_arrow_[data-v-20c78138]{transform:rotate(135deg) translate(3px,-3px)}.dp-checkfilter_view_:hover .dp-checkfilter_option_view_[data-v-20c78138]{transform:scale(1);overflow:visible;visibility:inherit}.dp-checkfilter_option_view_[data-v-20c78138]:before{content:"";position:absolute;left:calc(50% - 4px);top:-4px;width:8px;height:8px;background-color:#fff;box-shadow:3px 3px 10px #c3c3c3;transform:rotate(45deg)}.dp-checkfilter_option_list_[data-v-20c78138]{max-height:400px;overflow:auto;border-radius:5px;background-color:#fff;position:relative;z-index:2}.dp-table_header_item_height_[data-v-4272af7c]{min-height:40px}.dp-table_header_item_[data-v-4272af7c]{white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center;justify-content:center;box-sizing:border-box;text-align:center;flex-shrink:0}.dp-table_header_item_group_[data-v-4272af7c]{flex-direction:column;align-items:stretch}.dp-table_header_item_group_title_[data-v-4272af7c]{display:flex;align-items:center;justify-content:center}.dp-table_header_item_border_[data-v-4272af7c]{border-right:1px solid;border-bottom:1px solid;padding:3px 10px}.dp-table_header_item_child_[data-v-4272af7c]{display:flex}.dp-table_header_item_sort_[data-v-4272af7c]{display:inline-flex;flex-direction:column;align-items:center;justify-content:space-between;width:16px;height:12px}.dp-table_header_item_sort_[data-v-4272af7c]:before,.dp-table_header_item_sort_[data-v-4272af7c]:after{content:"";width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent}.dp-table_header_item_sort_[data-v-4272af7c]:before{border-bottom:5px solid #999}.dp-table_header_item_sort_[data-v-4272af7c]:after{border-top:5px solid #999}.dp-table_header_item_sort_up_[data-v-4272af7c]:before{border-bottom-color:#fe8227}.dp-table_header_item_sort_down_[data-v-4272af7c]:after{border-top-color:#fe8227}.dp-table_header_item_cursor_[data-v-4272af7c]{cursor:pointer}.dp-table_header_filter_view_[data-v-4272af7c]{flex:1}.dp-table_header_view_[data-v-2553e3f4]{flex-shrink:0;display:inline-flex;border-top:1px solid;position:sticky;z-index:3;top:0;user-select:none}.dp-table_fixed_bg_[data-v-2553e3f4]{background-color:#fff}.dp-table_fixed_bg_.dp-table_fixed_shadow_[data-v-2553e3f4]{box-shadow:5px 0 8px -3px #e3e3e3}.dp-table_view_border_[data-v-c60b4a66]{border:1px solid;border-top:0;display:inline-block;max-width:100%;font-size:0}.dp-table_view_[data-v-c60b4a66]{display:inline-block;max-width:100%;overflow:auto;max-height:80vh;font-size:0;position:relative;box-sizing:border-box}.dp-table_body_view_[data-v-c60b4a66]{display:inline-flex;flex-direction:column;box-sizing:border-box;min-height:50px}.dp-table_body_view_[data-v-c60b4a66]:empty{display:flex;align-items:center;justify-content:center}.dp-table_body_view_[data-v-c60b4a66]:empty:before{content:"\6682\65e0\6570\636e";line-height:2;color:#999}.dp-table_view_>*[data-v-c60b4a66]{font-size:14px}.dp-table_body_item_[data-v-c60b4a66]{display:inline-flex}.dp-table_fixed_bg_[data-v-c60b4a66]{background-color:#fff}.dp-table_fixed_bg_.dp-table_fixed_shadow_[data-v-c60b4a66]{box-shadow:5px 0 8px -3px #e3e3e3}.dp-table_body_item_group_col_[data-v-c60b4a66]{display:flex;flex-direction:column}.dp-table_body_item_group_col_>*[data-v-c60b4a66]{flex:1}.dp-table_body_item_child_[data-v-c60b4a66]{flex-shrink:0;display:flex;align-items:center;justify-content:center;text-align:center;min-height:30px;border-right:1px solid;border-bottom:1px solid;box-sizing:border-box;overflow:hidden}.dp-table_total_view_[data-v-c60b4a66]{position:sticky;bottom:0;display:inline-flex;background-color:#fff;overflow:visible}.dp-table_total_border_[data-v-c60b4a66]{position:absolute;left:0;top:-1px;color:inherit;z-index:4;width:100%;border-top:1px solid}
package/docs/table.pdf ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "dpot-ui",
3
+ "private": false,
4
+ "version": "0.1.0",
5
+ "author": "Jeesn",
6
+ "main": "./dist/index.es.js",
7
+ "module": "./dist/index.es.js",
8
+ "style": "./dist/style.css",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.es.js",
12
+ "require": "./dist/index.es.js"
13
+ },
14
+ "./*": "./*"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "docs"
19
+ ],
20
+ "peerDependencies": {
21
+ "vue": ">=2.6.14"
22
+ }
23
+ }