bri-components 1.6.7 → 1.6.9

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.
@@ -1,150 +1,106 @@
1
1
  <template>
2
2
  <div :class="{
3
3
  uploadList: true,
4
- [`uploadList-${showMode}`]: true
4
+ [`uploadList-${mode}`]: true
5
5
  }">
6
6
  <!-- 有值 -->
7
7
  <template v-if="files.length">
8
- <!-- 在表格中展开、普通文本模式 -->
8
+ <!-- 框内方式 且 文件类型 -->
9
+ <dsh-dropdown
10
+ v-if="['fileinline'].includes(mode)"
11
+ ref="dshdropdown"
12
+ class="dropdown"
13
+ :list="files"
14
+ trigger="hover"
15
+ @click.native.stop="0"
16
+ >
17
+ <div :class="{
18
+ 'num': true,
19
+ 'num--edit': canEdit
20
+ }">
21
+ {{ files.length }}个
22
+
23
+ <Icon
24
+ v-if="canEdit"
25
+ type="ios-arrow-down"
26
+ />
27
+ </div>
28
+
29
+ <div
30
+ slot="dropdownItem"
31
+ slot-scope="{ dropdownItem, dropdownIndex }"
32
+ class="uploadList-fileinline-item"
33
+ >
34
+ <img
35
+ class="item-img"
36
+ :data-original="getImgDataOriginal(dropdownItem)"
37
+ :src="getFileImage(dropdownItem)"
38
+ :alt="dropdownItem.name"
39
+ >
40
+
41
+ <p class="item-name">{{ dropdownItem.name }}</p>
42
+
43
+ <dsh-icons
44
+ class="item-action"
45
+ item-class="item-action-icon"
46
+ :list="$getOperationList(getBtns(dropdownItem))"
47
+ @click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
48
+ ></dsh-icons>
49
+ </div>
50
+ </dsh-dropdown>
51
+
9
52
  <div
10
- v-if="['old', 'tableList'].includes(showMode)"
53
+ v-else
11
54
  ref="viewerImage"
12
- :class="{
13
- 'uploadList-list-image': subType === 'image',
14
- 'uploadList-list-file': subType !== 'image'
55
+ class="list"
56
+ :style="{
57
+ padding: ['image', 'file'].includes(mode) ? listPadding : undefined
15
58
  }"
59
+ @click.stop="0"
16
60
  >
17
61
  <div
18
62
  v-for="(fileItem, fileIndex) in files"
19
63
  :key="fileItem._key || fileItem._id"
20
64
  class="item"
21
65
  >
22
- <!-- 展示图 -->
23
- <template>
24
- <img
25
- v-if="fileItem.mimetype.includes('image')"
26
- class="item-img"
27
- :data-original="fileItem.url"
28
- :src="$imageResize(fileItem.url, imageResizeConfig)"
29
- :alt="fileItem.name"
30
- >
31
- <img
32
- v-else
33
- class="item-img"
34
- :src="getFileImage(fileItem)"
35
- :alt="fileItem.name"
36
- >
37
- </template>
66
+ <!-- 展示图 / 视频 -->
67
+ <div v-if="fileItem.mimetype.includes('video/mp4') && ['single'].includes(mode)">
68
+ <dsh-video-player :src="fileItem.url"></dsh-video-player>
69
+ </div>
70
+ <img
71
+ v-else
72
+ class="item-img"
73
+ :data-original="getImgDataOriginal(fileItem)"
74
+ :src="getFileImage(fileItem)"
75
+ :alt="fileItem.name"
76
+ >
38
77
 
39
78
  <!-- 展示名称 -->
40
- <p class="item-name">{{ fileItem.name }}</p>
79
+ <p
80
+ v-if="['image', 'file'].includes(mode)"
81
+ class="item-name"
82
+ >{{ fileItem.name }}</p>
41
83
 
42
84
  <!-- 图标 -->
43
85
  <dsh-icons
44
- class="item-action"
86
+ :class="{
87
+ 'item-action': true,
88
+ 'item-action-top': fileItem.mimetype.includes('video/mp4') && ['single'].includes(mode)
89
+ }"
45
90
  item-class="item-action-icon"
46
91
  :list="$getOperationList(getBtns(fileItem))"
47
92
  @click="$dispatchEvent($event, fileItem, fileIndex)"
48
93
  ></dsh-icons>
49
94
  </div>
50
95
  </div>
51
-
52
- <!-- 框内方式 -->
53
- <template v-else>
54
- <!-- 图片类型 -->
55
- <div
56
- v-if="subType === 'image'"
57
- ref="viewerImage"
58
- class="uploadList-inline-list"
59
- >
60
- <div
61
- v-for="(fileItem, fileIndex) in files"
62
- :key="fileItem.url"
63
- class="item"
64
- >
65
- <template>
66
- <img
67
- v-if="fileItem.mimetype.includes('image')"
68
- :data-original="fileItem.url"
69
- :src="$imageResize(fileItem.url, imageResizeConfig)"
70
- :alt="fileItem.name"
71
- >
72
- <img
73
- v-else
74
- :src="getFileImage(fileItem)"
75
- :alt="fileItem.name"
76
- >
77
- </template>
78
-
79
- <dsh-icons
80
- class="item-action"
81
- item-class="item-action-icon"
82
- :list="$getOperationList(getBtns(fileItem))"
83
- @click="$dispatchEvent($event, fileItem, fileIndex)"
84
- ></dsh-icons>
85
- </div>
86
- </div>
87
-
88
- <!-- 文件类型 -->
89
- <div v-else>
90
- <dsh-dropdown
91
- ref="dshdropdown"
92
- class="uploadList-inline-dropdown"
93
- :list="files"
94
- trigger="hover"
95
- >
96
- <div :class="{
97
- 'uploadList-inline-dropdown-fileName': true,
98
- 'uploadList-inline-dropdown-fileName-edit': canEdit
99
- }">
100
- {{ files.length }}个
101
- <Icon
102
- v-if="canEdit"
103
- type="ios-arrow-down"
104
- />
105
- </div>
106
-
107
- <div
108
- slot="dropdownItem"
109
- slot-scope="{ dropdownItem, dropdownIndex }"
110
- class="uploadList-inline-dropdown-item"
111
- >
112
- <template>
113
- <img
114
- v-if="dropdownItem.mimetype.includes('image')"
115
- class="item-img"
116
- :data-original="dropdownItem.url"
117
- :src="$imageResize(dropdownItem.url, imageResizeConfig)"
118
- :alt="dropdownItem.name"
119
- >
120
- <img
121
- v-else
122
- class="item-img"
123
- :src="getFileImage(dropdownItem)"
124
- :alt="dropdownItem.name"
125
- >
126
- </template>
127
-
128
- <p class="item-name">{{ dropdownItem.name }}</p>
129
-
130
- <dsh-icons
131
- class="item-action"
132
- item-class="item-action-icon"
133
- :list="$getOperationList(getBtns(dropdownItem))"
134
- @click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
135
- ></dsh-icons>
136
- </div>
137
- </dsh-dropdown>
138
- </div>
139
- </template>
140
96
  </template>
141
97
 
142
98
  <!-- 无值 -->
143
99
  <div
144
100
  v-else
145
101
  :class="{
146
- 'uploadList-nodata-old': ['old'].includes(showMode),
147
- 'uploadList-nodata': !['old'].includes(showMode)
102
+ 'uploadList-nodata': !mode.includes('inline'),
103
+ 'uploadList-nodata-inline': mode.includes('inline')
148
104
  }"
149
105
  >
150
106
  <span>{{ emptyShowVal }}</span>
@@ -155,23 +111,26 @@
155
111
  <script>
156
112
  import Viewer from "viewerjs";
157
113
  import axios from "axios";
158
- // import DshVideoPlayer from "../../../other/DshVideoPlayer.vue";
114
+ import DshVideoPlayer from "../../../other/DshVideoPlayer.vue";
159
115
 
160
116
  export default {
161
117
  name: "uploadList",
162
118
  mixins: [],
163
119
  components: {
164
- // DshVideoPlayer
120
+ DshVideoPlayer
165
121
  },
166
122
  props: {
123
+ mode: {
124
+ type: String,
125
+ default: "file",
126
+ validator (val) {
127
+ return ["single", "image", "file", "imageinline", "fileinline"].includes(val);
128
+ }
129
+ },
167
130
  canEdit: {
168
131
  type: Boolean,
169
132
  default: true
170
133
  },
171
- showMode: {
172
- type: String,
173
- default: "old" // old, tableList, inline
174
- },
175
134
  files: {
176
135
  type: Array,
177
136
  default () {
@@ -184,19 +143,23 @@
184
143
  return {};
185
144
  }
186
145
  },
146
+ listPadding: String,
187
147
  isShowEditIcon: Boolean,
188
148
  emptyShowVal: String
189
149
  },
190
150
  data () {
191
151
  return {
192
- imageResizeConfig: {}
152
+ canPreviewMimeTypes: [
153
+ "image", "video/mp4",
154
+ "application/pdf", "wordprocessingml.document", "spreadsheetml.sheet", // excel
155
+ "text/plain", "application/json", "application/octet-stream", // 日志.log
156
+ // "text/csv", // 好像是便签,如果预览会直接下载
157
+ // "application/zip",
158
+ "application/msword", "application/vnd.ms-powerpoint", "presentationml.presentation"
159
+ ]
193
160
  };
194
161
  },
195
162
  computed: {
196
- subType () {
197
- return this.propsObj._fileType;
198
- },
199
-
200
163
  allOperationMap () {
201
164
  return {
202
165
  canDelete: {
@@ -209,9 +172,9 @@
209
172
  },
210
173
  event: "clickDeleteItem"
211
174
  },
212
- canEdit: {
175
+ canUpdateName: {
213
176
  name: "编辑",
214
- type: "canEdit",
177
+ type: "canUpdateName",
215
178
  customIcon: "bico-bianji",
216
179
  size: "14",
217
180
  event: "clickEdit"
@@ -237,7 +200,7 @@
237
200
  // comp_web图标前缀与其他不同,需特殊处理
238
201
  if (this.propsObj._pageType === "comp") {
239
202
  operations.canDelete.customIcon = "bri-shanchu";
240
- operations.canEdit.customIcon = "bri-bianji";
203
+ operations.canUpdateName.customIcon = "bri-bianji";
241
204
  operations.canDownload.customIcon = "bri-xiazai";
242
205
  operations.canPreview.customIcon = "bri-keshi";
243
206
  }
@@ -246,12 +209,12 @@
246
209
  ? this.$categoryMapToMap(
247
210
  operations,
248
211
  undefined,
249
- this.isShowEditIcon ? [] : ["canEdit"]
212
+ this.isShowEditIcon ? [] : ["canUpdateName"]
250
213
  )
251
214
  : this.$categoryMapToMap(
252
215
  operations,
253
216
  undefined,
254
- ["canDelete", "canEdit"]
217
+ ["canDelete", "canUpdateName"]
255
218
  );
256
219
  }
257
220
  },
@@ -278,7 +241,8 @@
278
241
  zIndex: 2147483647
279
242
  });
280
243
  viewer.show();
281
- } else {
244
+ }
245
+ else {
282
246
  window.open(fileItem.url);
283
247
  }
284
248
  },
@@ -344,44 +308,41 @@
344
308
  });
345
309
  },
346
310
 
311
+ /* 加工方法 */
347
312
  // 获取不同类型文件的图片
348
313
  getFileImage (fileItem) {
349
- if (!fileItem.mimetype) {
350
- return this.$imageSrcMap.fileType.other;
351
- } else if (fileItem.mimetype.includes("image")) {
352
- return fileItem.url; // 压缩图片:将图片最长的边限制在100像素,短边按比例处理
353
- } else if (fileItem.mimetype.includes("text/plain")) {
354
- return this.$imageSrcMap.fileType.text;
355
- } else if (fileItem.mimetype.includes("application/pdf")) {
356
- return this.$imageSrcMap.fileType.pdf;
357
- } else if (fileItem.mimetype.includes("wordprocessingml.document") || fileItem.mimetype.includes("application/msword")) {
358
- return this.$imageSrcMap.fileType.doc;
359
- } else if (fileItem.mimetype.includes("presentationml.presentation") || fileItem.mimetype.includes("application/vnd.ms-powerpoint")) {
360
- return this.$imageSrcMap.fileType.ppt;
361
- } else if (fileItem.mimetype.includes("spreadsheetml.sheet")) {
362
- return this.$imageSrcMap.fileType.excel;
363
- } else if (fileItem.mimetype.includes("application/x-zip-compressed")) {
364
- return this.$imageSrcMap.fileType.zip;
365
- } else if (fileItem.mimetype.includes("application/x-rar-compressed")) {
366
- return this.$imageSrcMap.fileType.rar;
314
+ const arrList = [
315
+ ["image", fileItem.url], // 压缩图片:将图片最长的边限制在100像素,短边按比例处理
316
+ ["text/plain", "text"],
317
+ ["application/pdf", "pdf"],
318
+ ["wordprocessingml.document", "doc"],
319
+ ["application/msword", "doc"],
320
+ ["presentationml.presentation", "ppt"],
321
+ ["application/vnd.ms-powerpoint", "ppt"],
322
+ ["spreadsheetml.sheet", "excel"],
323
+ ["application/x-zip-compressed", "zip"],
324
+ ["application/x-rar-compressed", "rar"]
325
+ ];
326
+ if (fileItem.mimetype) {
327
+ const arrItem = arrList.find(arrItem => fileItem.mimetype.includes(arrItem[0])) || ["other", "other"];
328
+ return arrItem[0] === "image"
329
+ ? fileItem.url
330
+ : this.$imageSrcMap.fileType[arrItem[1]];
367
331
  } else {
368
332
  return this.$imageSrcMap.fileType.other;
369
333
  }
370
334
  },
335
+ getImgDataOriginal (fileItem) {
336
+ return fileItem.mimetype.includes("image")
337
+ ? fileItem.url
338
+ : undefined;
339
+ },
371
340
  getBtns (fileItem) {
372
- return [
373
- "image", "video/mp4",
374
- "text/plain",
375
- // "text/csv", // 好像是便签,如果预览会直接下载
376
- "application/pdf", "wordprocessingml.document", "spreadsheetml.sheet", // excel
377
- "application/octet-stream", // 日志 .log
378
- // "application/zip",
379
- "application/msword",
380
- "application/vnd.ms-powerpoint",
381
- "presentationml.presentation"
382
- ].some(type => fileItem.mimetype.includes(type))
383
- ? undefined
384
- : ["canDelete", "canEdit", "canDownload"];
341
+ return ["single"].includes(this.mode)
342
+ ? ["canDelete", "canDownload", "canPreview"]
343
+ : this.canPreviewMimeTypes.some(type => fileItem.mimetype.includes(type))
344
+ ? ["canDelete", "canUpdateName", "canDownload", "canPreview"]
345
+ : ["canDelete", "canUpdateName", "canDownload"];
385
346
  }
386
347
  }
387
348
  };
@@ -400,13 +361,62 @@
400
361
 
401
362
  .uploadList {
402
363
  width: 100%;
403
- overflow: auto;
364
+ height: 100%;
365
+
366
+ // 单个
367
+ &-single {
368
+ .list {
369
+ width: 100%;
370
+ height: 100%;
371
+ overflow: hidden;
372
+
373
+ .item {
374
+ width: 100%;
375
+ height: 100%;
376
+ position: relative;
377
+
378
+ &-img {
379
+ width: 100%;
380
+ }
381
+
382
+ &-action {
383
+ display: none;
384
+ position: absolute;
385
+ top: 0px;
386
+ bottom: 0px;
387
+ left: 0px;
388
+ right: 0px;
389
+ background-color: @placeholderColor;
390
+
391
+ &-top {
392
+ bottom: calc(100% - 50px);
393
+ }
394
+ }
404
395
 
405
- &-list {
406
- // 其它子类型时
407
- &-image {
396
+ &:hover {
397
+ .item-action {
398
+ display: flex;
399
+ justify-content: center;
400
+ align-items: center;
401
+
402
+ &-top {
403
+ justify-content: flex-end;
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+ }
410
+
411
+ // 图片类型时
412
+ &-image {
413
+ .list {
414
+ width: 100%;
415
+ height: 100%;
416
+ overflow: auto;
408
417
  display: flex;
409
- flex-wrap: nowrap;
418
+ flex-wrap: wrap;
419
+ align-content: flex-start;
410
420
 
411
421
  .item {
412
422
  flex: 0 0 120px;
@@ -424,7 +434,6 @@
424
434
  &-img {
425
435
  flex: 1;
426
436
  min-height: 50px;
427
- overflow: hidden;
428
437
  }
429
438
 
430
439
  &-name {
@@ -454,12 +463,14 @@
454
463
  }
455
464
  }
456
465
  }
466
+ }
457
467
 
458
- // file子类型时
459
- &-file {
460
- display: flex;
461
- flex-direction: column;
462
- // flex-wrap: nowrap;
468
+ // 其它子类型时
469
+ &-file {
470
+ .list {
471
+ width: 100%;
472
+ height: 100%;
473
+ overflow: auto;
463
474
 
464
475
  .item {
465
476
  flex: 0 0 100%;
@@ -480,18 +491,17 @@
480
491
 
481
492
  &-name {
482
493
  flex: 1;
483
- min-width: 100px;
494
+ min-width: 80px;
484
495
  padding: 2px 8px;
485
496
  text-align: left;
486
497
  color: @textColor;
487
- // white-space: normal;
498
+ white-space: normal;
488
499
  word-wrap: break-word; /* 或 overflow-wrap: break-word; */
489
500
  word-break: break-all; /* 这会在任何字符边界处断行 */
490
501
  overflow: hidden;
491
502
  }
492
503
 
493
504
  &-action {
494
- // width: 80px;
495
505
  background: transparent;
496
506
  white-space: nowrap;
497
507
  position: static;
@@ -505,82 +515,19 @@
505
515
  }
506
516
  }
507
517
 
508
- &-nodata {
509
- padding-left: 7px;
510
- line-height: 32px;
511
- color: @placeholderColor;
512
-
513
- &-old {
514
- width: 100%;
515
- height: 100%;
516
- text-align: center;
517
- line-height: 120px;
518
- color: @placeholderColor;
519
- white-space: nowrap;
520
- }
521
- }
522
-
523
- &-old {
524
- margin: 16px;
525
- }
526
-
527
- &-inline {
518
+ &-imageinline {
519
+ width: 100%;
528
520
  height: 32px;
529
521
  line-height: 32px;
530
522
 
531
- &-dropdown {
532
- width: 100%;
533
-
534
- &-fileName {
535
- cursor: pointer;
536
-
537
- &-edit {
538
- padding: 0 8px;
539
- display: flex;
540
- justify-content: space-between;
541
- align-items: center;
542
- }
543
- }
544
-
545
- &-item {
546
- width: 100%;
547
- display: flex;
548
- justify-content: space-between;
549
- align-items: center;
550
-
551
- .item {
552
- &-img {
553
- width: 22px;
554
- height: 22px;
555
- }
556
-
557
- &-name {
558
- flex: 1;
559
- margin: 0 8px;
560
- text-align: left;
561
- // white-space: normal;
562
- // word-wrap: break-word; /* 或 overflow-wrap: break-word; */
563
- word-break: break-all; /* 这会在任何字符边界处断行 */
564
- overflow: hidden;
565
- }
566
-
567
- &-action {
568
- display: flex;
569
- align-items: center;
570
- justify-content: flex-end;
571
- }
572
- }
573
- }
574
- }
575
-
576
- &-list {
523
+ .list {
577
524
  width: 100%;
578
525
  height: 100%;
579
526
  padding-left: 3px;
580
- display: flex;
581
- flex-wrap: nowrap;
582
527
  overflow-x: auto;
583
528
  overflow-y: hidden;
529
+ display: flex;
530
+ flex-wrap: nowrap;
584
531
 
585
532
  .item {
586
533
  flex: 0 0 32px;
@@ -590,7 +537,7 @@
590
537
  text-align: center;
591
538
  position: relative;
592
539
 
593
- img {
540
+ &-img {
594
541
  max-width: 100%;
595
542
  max-height: 100%;
596
543
  margin: auto;
@@ -619,58 +566,131 @@
619
566
  }
620
567
  }
621
568
  }
569
+
570
+ &-fileinline {
571
+ height: 32px;
572
+ line-height: 32px;
573
+
574
+ .dropdown {
575
+ width: 100%;
576
+
577
+ .num {
578
+ padding: 0 8px;
579
+ cursor: pointer;
580
+
581
+ &--edit {
582
+ display: flex;
583
+ justify-content: space-between;
584
+ align-items: center;
585
+ }
586
+ }
587
+ }
588
+ }
589
+
590
+ &-nodata {
591
+ width: 100%;
592
+ height: 100%;
593
+ text-align: center;
594
+ line-height: 120px;
595
+ color: @placeholderColor;
596
+ white-space: nowrap;
597
+
598
+ &-inline {
599
+ padding-left: 7px;
600
+ line-height: 32px;
601
+ color: @placeholderColor;
602
+ }
603
+ }
622
604
  }
623
605
  </style>
624
606
  <style lang="less">
625
607
  .uploadList {
626
- &-list {
627
- &-image {
628
- .item {
629
- &-action {
630
- &-icon {
631
- width: 22px;
632
- height: 22px;
633
- line-height: 22px;
634
- color: #fff;
635
- }
608
+ &-single {
609
+ .item {
610
+ &-action {
611
+ &-icon {
612
+ width: 40px;
613
+ height: 40px;
614
+ line-height: 40px;
615
+ font-size: 24px !important;
616
+ color: #fff;
636
617
  }
637
618
  }
638
619
  }
620
+ }
639
621
 
640
- // file类型时
641
- &-file {
642
- .item {
643
- &-action {
644
- &-icon {
645
- width: 16px;
646
- color: @themeColor;
647
- }
622
+ &-image {
623
+ .item {
624
+ &-action {
625
+ &-icon {
626
+ width: 22px;
627
+ height: 22px;
628
+ line-height: 22px;
629
+ font-size: 18px !important;
630
+ color: #fff;
648
631
  }
649
632
  }
650
633
  }
651
634
  }
652
635
 
653
- &-inline {
654
- &-dropdown-item {
655
- .item {
656
- &-action {
657
- &-icon {
658
- width: 16px;
659
- color: @themeColor;
660
- }
636
+ &-file {
637
+ .item {
638
+ &-action {
639
+ &-icon {
640
+ width: 16px;
641
+ height: 16px;
642
+ // line-height: 16px;
643
+ // font-size: 16px !important;
644
+ color: @themeColor;
661
645
  }
662
646
  }
663
647
  }
648
+ }
664
649
 
665
- &-list {
666
- .item {
667
- &-action {
668
- &-icon {
669
- width: 16px;
670
- height: 16px;
671
- margin: 0px;
672
- font-size: 16px !important;
673
- }
650
+ &-imageinline {
651
+ .item {
652
+ &-action {
653
+ &-icon {
654
+ width: 16px;
655
+ height: 16px;
656
+ margin: 0px;
657
+ line-height: 16px;
658
+ font-size: 14px !important;
659
+ }
660
+ }
661
+ }
662
+ }
663
+
664
+ &-fileinline-item {
665
+ width: 100%;
666
+ display: flex;
667
+ justify-content: space-between;
668
+ align-items: center;
669
+
670
+ .item {
671
+ &-img {
672
+ width: 22px;
673
+ height: 22px;
674
+ }
675
+
676
+ &-name {
677
+ flex: 1;
678
+ margin: 0 8px;
679
+ text-align: left;
680
+ white-space: normal;
681
+ word-wrap: break-word; /* 或 overflow-wrap: break-word; */
682
+ word-break: break-all; /* 这会在任何字符边界处断行 */
683
+ overflow: hidden;
684
+ }
685
+
686
+ &-action {
687
+ display: flex;
688
+ align-items: center;
689
+ justify-content: flex-end;
690
+
691
+ &-icon {
692
+ width: 16px;
693
+ color: @themeColor;
674
694
  }
675
695
  }
676
696
  }