bri-components 1.6.2 → 1.6.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "ali-oss": "^6.13.1",
34
34
  "axios": "^0.23.0",
35
- "bri-datas": "^1.4.7",
35
+ "bri-datas": "^1.5.4",
36
36
  "jshint": "^2.12.0",
37
37
  "jsonlint": "^1.6.3",
38
38
  "minio": "7.1.0",
@@ -101,20 +101,7 @@
101
101
  import uploadMixin from "./uploadMixin.js";
102
102
  import BriUploadImage from "./BriUploadImage.vue";
103
103
  import uploadList from "./uploadList.vue";
104
-
105
- const prefixCls = "ivu-upload";
106
- const fileTypesMap = {
107
- document: ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf", "xmind"],
108
- image: ["jpg", "png", "gif", "jpeg", "tiff", "swf"],
109
- video: ["flv", "rmvb", "mp4", "mvb"],
110
- audio: ["wma", "mp3", "m4a"],
111
- // text: ["log", "csv", "html", "json"],
112
- package: ["rar", "zip"]
113
- };
114
- const allFileTypes = Object.entries(fileTypesMap).reduce((arr, fileTypeArr, fileTypeIndex, map) => [
115
- ...arr,
116
- ...fileTypeArr[1]
117
- ], []);
104
+ import { fileTypes } from "../../../../data/index.js";
118
105
 
119
106
  export default {
120
107
  name: "BriUpload",
@@ -129,7 +116,7 @@
129
116
  props: {},
130
117
  data () {
131
118
  return {
132
- prefixCls: prefixCls,
119
+ prefixCls: "ivu-upload",
133
120
  dragOver: false,
134
121
 
135
122
  operationMap: {
@@ -148,11 +135,11 @@
148
135
  _fileType: "file", // "file", "image", "video"
149
136
  _showMode: this.isHeightAuto ? "old" : "inline", // 宽度为100%、且不在表格字段里的 显示老版
150
137
 
151
- _multiple: true,
152
- _useType: "drag",
138
+ _multiple: true, // 默认多选
139
+ _useType: "drag", // "drag", "select"
153
140
  _maxSize: 1024 * 1024 * 2, // 根据四局要求,限制文件为2G
154
141
  _format: [],
155
- _accept: [],
142
+ _accept: [], // 限制只能传那些文件类型,_accept有值的话,_fileType就没用了
156
143
 
157
144
  ...this.propsObj,
158
145
  ...this.commonDealPropsObj
@@ -179,28 +166,32 @@
179
166
  },
180
167
  // 限制文件格式
181
168
  accept () {
182
- const types = this.selfPropsObj._accept && this.selfPropsObj._accept.length
169
+ const types = this.selfPropsObj._accept.length
183
170
  ? this.selfPropsObj._accept
184
- : this.subType === "file"
185
- ? allFileTypes
186
- : fileTypesMap[this.subType];
171
+ : (
172
+ this.subType === "file"
173
+ ? fileTypes
174
+ : fileTypes.filter(fileTypeItem => fileTypeItem.type === this.subType)
175
+ ).map(fileTypeItem => fileTypeItem._key);
187
176
 
188
177
  return types.map(type => `.${type}`).join();
189
178
  },
190
179
  isShowEditIcon () {
191
180
  // 因为编辑name 需要这三个参数,因此没有这三个参数时不显示此按钮
192
- return this.compKey && this.appKey && this.modKey && !!(this.$getHttpPathMap({}).file && this.$getHttpPathMap({}).file.updateFileName);
181
+ return this.compKey && this.appKey && this.modKey &&
182
+ !!(this.$getHttpPathMap({}).file && this.$getHttpPathMap({}).file.updateFileName);
193
183
  },
194
184
  classes () {
195
185
  return {
196
- [`${prefixCls}`]: true,
197
- [`${prefixCls}-select`]: this.useType === "select",
198
- [`${prefixCls}-drag`]: this.useType === "drag",
199
- [`${prefixCls}-dragOver`]: this.useType === "drag" && this.dragOver,
186
+ [`${this.prefixCls}`]: true,
187
+ [`${this.prefixCls}-select`]: this.useType === "select",
188
+ [`${this.prefixCls}-drag`]: this.useType === "drag",
189
+ [`${this.prefixCls}-dragOver`]: this.useType === "drag" && this.dragOver,
200
190
  [`BriUpload-${this.showMode}-wrapper`]: true
201
191
  };
202
192
  }
203
193
  },
194
+ created () {},
204
195
  methods: {
205
196
  clickUpload () {
206
197
  if (!this.disabled) {
@@ -10,10 +10,10 @@
10
10
  <div
11
11
  v-if="files.length"
12
12
  ref="viewerImage"
13
- :class="{
14
- 'uploadList-list': true,
15
- [`uploadList-list-${subType}`]: true
16
- }"
13
+ :class="[
14
+ 'uploadList-list',
15
+ `uploadList-list-${subType}`
16
+ ]"
17
17
  >
18
18
  <div
19
19
  v-for="(fileItem, fileIndex) in files"
@@ -39,7 +39,7 @@
39
39
  </div>
40
40
 
41
41
  <!-- 展示名称 -->
42
- <p class="item-name-title">{{ fileItem.name }}</p>
42
+ <p class="item-name">{{ fileItem.name }}</p>
43
43
 
44
44
  <!-- 图标 -->
45
45
  <dsh-icons
@@ -54,7 +54,7 @@
54
54
  <!-- 无值 -->
55
55
  <div
56
56
  v-else
57
- class="uploadList-nodata"
57
+ class="uploadList-old-odata"
58
58
  >
59
59
  <span>{{ emptyShowVal }}</span>
60
60
  </div>
@@ -95,7 +95,7 @@
95
95
  </div>
96
96
 
97
97
  <!-- 展示名称 -->
98
- <p class="item-name-title">{{ fileItem.name }}</p>
98
+ <p class="item-name">{{ fileItem.name }}</p>
99
99
 
100
100
  <!-- 图标 -->
101
101
  <dsh-icons
@@ -128,11 +128,11 @@
128
128
  <dsh-dropdown
129
129
  :list="files"
130
130
  trigger="hover"
131
- class="uploadList-fileList"
131
+ class="uploadList-inline-dropdown"
132
132
  >
133
133
  <div :class="{
134
- 'uploadList-fileList-fileName': true,
135
- 'uploadList-fileList-fileName-edit': canEdit
134
+ 'uploadList-inline-dropdown-fileName': true,
135
+ 'uploadList-inline-dropdown-fileName-edit': canEdit
136
136
  }">
137
137
  {{ files.length }}个
138
138
  <Icon
@@ -144,49 +144,32 @@
144
144
  <div
145
145
  slot="dropdownItem"
146
146
  slot-scope="{ dropdownItem, dropdownIndex }"
147
- class="uploadList-fileList-fileItem"
147
+ class="uploadList-inline-dropdown-item"
148
148
  >
149
149
  <img
150
150
  v-if="dropdownItem.mimetype.includes('image')"
151
151
  :data-original="dropdownItem.url"
152
152
  :src="$imageResize(dropdownItem.url, imageResizeConfig)"
153
153
  :alt="dropdownItem.name"
154
- class="fileItem-img"
154
+ class="item-img"
155
155
  >
156
156
  <img
157
157
  v-else
158
158
  :src="getFileImage(dropdownItem)"
159
159
  :alt="dropdownItem.name"
160
- class="fileItem-img"
160
+ class="item-img"
161
161
  >
162
162
 
163
- <p class="fileItem-name-title">{{ dropdownItem.name }}</p>
163
+ <p class="item-name">{{ dropdownItem.name }}</p>
164
164
 
165
165
  <dsh-icons
166
- class="fileItem-action"
167
- item-class="fileItem-action-icon"
166
+ class="item-action"
167
+ item-class="item-action-icon"
168
168
  :list="$getOperationList(getBtns(dropdownItem))"
169
169
  @click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
170
170
  ></dsh-icons>
171
171
  </div>
172
172
  </dsh-dropdown>
173
-
174
- <div
175
- v-for="(fileItem) in files"
176
- :key="fileItem._key || fileItem._id"
177
- :class="{
178
- 'item': subType === 'image',
179
- [`item-${subType}`]: true
180
- }"
181
- >
182
- <img
183
- v-if="fileItem.mimetype.includes('image')"
184
- :data-original="fileItem.url"
185
- :src="$imageResize(fileItem.url, imageResizeConfig)"
186
- :alt="fileItem.name"
187
- style="display: none;"
188
- >
189
- </div>
190
173
  </template>
191
174
 
192
175
  <!-- 无值 -->
@@ -256,14 +239,14 @@
256
239
  // DshVideoPlayer
257
240
  },
258
241
  props: {
259
- showMode: {
260
- type: String,
261
- default: "old" // inline, old, normal
262
- },
263
242
  canEdit: {
264
243
  type: Boolean,
265
244
  default: true
266
245
  },
246
+ showMode: {
247
+ type: String,
248
+ default: "old" // old, tableList, inline
249
+ },
267
250
  files: {
268
251
  type: Array,
269
252
  default () {
@@ -330,6 +313,7 @@
330
313
  operations.canDownload.customIcon = "bri-xiazai";
331
314
  operations.canPreview.customIcon = "bri-keshi";
332
315
  }
316
+
333
317
  return this.canEdit
334
318
  ? this.$categoryMapToMap(
335
319
  operations,
@@ -475,29 +459,11 @@
475
459
  };
476
460
  </script>
477
461
 
478
- <style lang="less">
462
+ <style lang="less" scoped>
479
463
  .uploadList {
480
464
  width: 100%;
481
465
  overflow: auto;
482
466
 
483
- // 普通文件
484
- &-old {
485
- margin: 16px;
486
- }
487
-
488
- &-nodata {
489
- width: 100%;
490
- height: 100%;
491
- text-align: center;
492
- line-height: 120px;
493
- color: @placeholderColor;
494
- white-space: nowrap;
495
-
496
- span {
497
- margin-left: 5px;
498
- }
499
- }
500
-
501
467
  &-list {
502
468
  display: flex;
503
469
  flex-wrap: nowrap;
@@ -515,12 +481,6 @@
515
481
  justify-content: space-between;
516
482
  position: relative;
517
483
 
518
- &:hover {
519
- .item-action {
520
- display: flex !important;
521
- }
522
- }
523
-
524
484
  &-show {
525
485
  display: flex;
526
486
  overflow: hidden;
@@ -536,17 +496,11 @@
536
496
  }
537
497
 
538
498
  &-name {
539
- flex: 1;
540
- display: flex;
541
- max-height: 32px;
542
-
543
- &-title {
544
- padding: 0 8px;
545
- overflow: hidden;
546
- text-overflow: ellipsis;
547
- white-space: nowrap;
548
- color: @themeColor;
549
- }
499
+ padding: 0 8px;
500
+ overflow: hidden;
501
+ text-overflow: ellipsis;
502
+ white-space: nowrap;
503
+ color: @themeColor;
550
504
  }
551
505
 
552
506
  &-action {
@@ -567,11 +521,18 @@
567
521
  color: #fff;
568
522
  }
569
523
  }
524
+
525
+ &:hover {
526
+ .item-action {
527
+ display: flex !important;
528
+ }
529
+ }
570
530
  }
571
531
 
572
532
  // file 模式
573
533
  &-file {
574
534
  flex-direction: column;
535
+
575
536
  .item-file {
576
537
  flex: 0 0 100%;
577
538
  height: auto;
@@ -583,32 +544,57 @@
583
544
  margin: 0px;
584
545
  padding: 2px 0;
585
546
  background: transparent;
586
- &:hover {
587
- background: #f4f5fa;
588
- }
589
- .item-show {
590
- flex: 0 0 22px;
591
- min-height: 20px;
592
- img {
593
- width: 22px;
594
- height: 22px;
547
+
548
+ .item {
549
+ &-show {
550
+ flex: 0 0 22px;
551
+ min-height: 20px;
552
+ img {
553
+ width: 22px;
554
+ height: 22px;
555
+ }
595
556
  }
596
- }
597
- .item-name-title {
598
- color: @textColor;
599
- flex: 1;
600
- text-align: left;
601
- }
602
- .item-action {
603
- position: static;
604
- display: flex !important;
605
- background: transparent;
606
- white-space: nowrap;
607
- &-icon {
608
- color: @contentColor;
609
- width: 16px;
557
+
558
+ &-name {
559
+ flex: 1;
560
+ text-align: left;
561
+ color: @textColor;
562
+ }
563
+
564
+ &-action {
565
+ position: static;
566
+ display: flex !important;
567
+ background: transparent;
568
+ white-space: nowrap;
569
+
570
+ &-icon {
571
+ color: @contentColor;
572
+ width: 16px;
573
+ }
610
574
  }
611
575
  }
576
+
577
+ &:hover {
578
+ background: #f4f5fa;
579
+ }
580
+ }
581
+ }
582
+ }
583
+
584
+ // 普通文件
585
+ &-old {
586
+ margin: 16px;
587
+
588
+ &-nodata {
589
+ width: 100%;
590
+ height: 100%;
591
+ text-align: center;
592
+ line-height: 120px;
593
+ color: @placeholderColor;
594
+ white-space: nowrap;
595
+
596
+ span {
597
+ margin-left: 5px;
612
598
  }
613
599
  }
614
600
  }
@@ -617,6 +603,55 @@
617
603
  height: 32px;
618
604
  line-height: 32px;
619
605
 
606
+ &-dropdown {
607
+ width: 100%;
608
+
609
+ &-fileName {
610
+ cursor: pointer;
611
+
612
+ &-edit {
613
+ padding: 0 8px;
614
+ display: flex;
615
+ justify-content: space-between;
616
+ align-items: center;
617
+ }
618
+ }
619
+
620
+ &-item {
621
+ width: 100%;
622
+ display: flex;
623
+ justify-content: space-between;
624
+ align-items: center;
625
+
626
+ .item {
627
+ &-img {
628
+ width: 22px;
629
+ height: 22px;
630
+ }
631
+
632
+ &-name {
633
+ white-space: nowrap;
634
+ overflow: hidden;
635
+ text-overflow: ellipsis;
636
+ margin: 0 8px;
637
+ flex: 1;
638
+ text-align: left;
639
+ }
640
+
641
+ &-action {
642
+ display: flex;
643
+ align-items: center;
644
+ justify-content: flex-end;
645
+
646
+ &-icon {
647
+ width: 16px;
648
+ color: @contentColor;
649
+ }
650
+ }
651
+ }
652
+ }
653
+ }
654
+
620
655
  &-list {
621
656
  width: 100%;
622
657
  height: 100%;
@@ -686,53 +721,5 @@
686
721
  color: @placeholderColor;
687
722
  }
688
723
  }
689
-
690
- &-fileList {
691
- width: 100%;
692
-
693
- &-fileName {
694
- cursor: pointer;
695
-
696
- &-edit {
697
- padding: 0 8px;
698
- display: flex;
699
- justify-content: space-between;
700
- align-items: center;
701
- }
702
- }
703
- }
704
- }
705
-
706
- .DshDropdown {
707
- .uploadList-fileList-fileItem {
708
- width: 100%;
709
- display: flex;
710
- justify-content: space-between;
711
- align-items: center;
712
- .fileItem {
713
- &-img {
714
- width: 22px;
715
- height: 22px;
716
- }
717
- &-name-title {
718
- white-space: nowrap;
719
- overflow: hidden;
720
- text-overflow: ellipsis;
721
- margin: 0 8px;
722
- flex: 1;
723
- text-align: left;
724
- }
725
- &-action {
726
- display: flex;
727
- align-items: center;
728
- justify-content: flex-end;
729
- &-icon {
730
- width: 16px;
731
- color: @contentColor;
732
- }
733
- }
734
- }
735
-
736
- }
737
724
  }
738
725
  </style>
@@ -77,19 +77,16 @@ export default {
77
77
  },
78
78
 
79
79
  localUpload (file, res, callback) {
80
- let fileBody = {
81
- groupKey: this.computedGroupKey,
82
- archiveKey: this.archiveKey[this.archiveKey.length - 1]
83
- };
84
-
85
- const url = `${res.ossHost}${res.uploadPath}`;
86
80
  let formData = new FormData();
87
81
  formData.append("file_stream", file);
88
82
 
89
- axios.post(url, formData, {
83
+ axios.post(`${res.ossHost}${res.uploadPath}`, formData, {
90
84
  headers: {
91
85
  filetoken: res.filetoken,
92
- filebody: JSON.stringify(fileBody)
86
+ filebody: JSON.stringify({
87
+ groupKey: this.computedGroupKey,
88
+ archiveKey: this.archiveKey[this.archiveKey.length - 1]
89
+ })
93
90
  },
94
91
  onUploadProgress: progressEvent => {
95
92
  this.inProgress(Number((progressEvent.loaded / progressEvent.total * 100).toFixed(1)));
@@ -98,14 +95,16 @@ export default {
98
95
  this.uploadSuccess = true;
99
96
  this.percent = 100;
100
97
  setTimeout(() => {
101
- this.percent = 0;
102
98
  this.uploadSuccess = false;
99
+ this.percent = 0;
103
100
  }, 500);
101
+
104
102
  this.successCb && this.successCb(response, response.data, file);
105
103
  callback && callback(response.data);
106
104
  }).catch(error => {
107
- this.percent = 0;
108
105
  this.uploadSuccess = false;
106
+ this.percent = 0;
107
+
109
108
  this.handleError && this.handleError(error, {}, file);
110
109
  callback && callback(error);
111
110
  });
@@ -245,7 +244,6 @@ export default {
245
244
  callbackBodyType: "application/json",
246
245
  callbackBody: this.transferCallBody(callbackBody)
247
246
  };
248
-
249
247
  let newOss = {
250
248
  ...res.ossConfig,
251
249
  refreshSTSToken: async () => {
@@ -273,14 +271,16 @@ export default {
273
271
  this.uploadSuccess = true;
274
272
  this.percent = 100;
275
273
  setTimeout(() => {
276
- this.percent = 0;
277
274
  this.uploadSuccess = false;
275
+ this.percent = 0;
278
276
  }, 500);
277
+
279
278
  this.successCb && this.successCb(response, response.data, file);
280
279
  callback && callback(response.data);
281
280
  }).catch((err, response) => {
282
- this.percent = 0;
283
281
  this.uploadSuccess = false;
282
+ this.percent = 0;
283
+
284
284
  this.handleError && this.handleError(err, response, file);
285
285
  callback && callback(err);
286
286
  });
@@ -306,7 +306,6 @@ export default {
306
306
  callbackBodyType: "application/json",
307
307
  callbackBody: this.transferCallBody(callbackBody)
308
308
  };
309
-
310
309
  let newOss = {
311
310
  ...res.ossConfig,
312
311
  refreshSTSToken: async () => {
@@ -331,17 +330,19 @@ export default {
331
330
  "Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
332
331
  }
333
332
  }).then(response => {
334
- this.percent = 100;
335
333
  this.uploadSuccess = true;
334
+ this.percent = 100;
336
335
  setTimeout(() => {
337
- this.percent = 0;
338
336
  this.uploadSuccess = false;
337
+ this.percent = 0;
339
338
  }, 500);
339
+
340
340
  this.successCb && this.successCb(response, response.data, file);
341
341
  callback && callback(response.data);
342
342
  }).catch((err, response) => {
343
- this.percent = 0;
344
343
  this.uploadSuccess = false;
344
+ this.percent = 0;
345
+
345
346
  this.handleError && this.handleError(err, response, file);
346
347
  callback && callback(err);
347
348
  });
@@ -375,17 +376,17 @@ export default {
375
376
  return JSON.stringify(newObj);
376
377
  },
377
378
  // base64转换
378
- base64Encode (input) {
379
+ base64Encode (str) {
380
+ str = this.utf8Encode(str);
379
381
  let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
380
-
381
382
  let output = "";
382
383
  let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
383
384
  let i = 0;
384
- input = this.utf8Encode(input);
385
- while (i < input.length) {
386
- chr1 = input.charCodeAt(i++);
387
- chr2 = input.charCodeAt(i++);
388
- chr3 = input.charCodeAt(i++);
385
+
386
+ while (i < str.length) {
387
+ chr1 = str.charCodeAt(i++);
388
+ chr2 = str.charCodeAt(i++);
389
+ chr3 = str.charCodeAt(i++);
389
390
  enc1 = chr1 >> 2;
390
391
  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
391
392
  enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
@@ -399,6 +400,7 @@ export default {
399
400
  _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
400
401
  _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
401
402
  }
403
+
402
404
  return output;
403
405
  },
404
406
  utf8Encode (str) {
@@ -418,6 +420,7 @@ export default {
418
420
  }
419
421
 
420
422
  }
423
+
421
424
  return utftext;
422
425
  },
423
426
  // base64转blob
@@ -428,13 +431,12 @@ export default {
428
431
  } else {
429
432
  byteString = unescape(base64Data.split(",")[1]);
430
433
  }
434
+
431
435
  // 获取文件类型
432
436
  const mimeString = base64Data.split(";")[0].split(":")[1]; // mime类型
433
-
434
437
  // ArrayBuffer 对象用来表示通用的、固定长度的原始二进制数据缓冲区
435
438
  // let arrayBuffer = new ArrayBuffer(byteString.length) // 创建缓冲数组
436
439
  // let uintArr = new Uint8Array(arrayBuffer) // 创建视图
437
-
438
440
  const uintArr = new Uint8Array(byteString.length); // 创建视图
439
441
 
440
442
  for (let i = 0; i < byteString.length; i += 1) {
@@ -444,6 +446,7 @@ export default {
444
446
  const blob = new Blob([uintArr], {
445
447
  type: mimeString
446
448
  });
449
+
447
450
  // 使用 Blob 创建一个指向类型化数组的URL, URL.createObjectURL是new Blob文件的方法,可以生成一个普通的url,可以直接使用,比如用在img.src上
448
451
  return blob;
449
452
  }
package/src/data/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export {
2
- resourceData
2
+ resourceData,
3
+ fileTypes
3
4
  // regionDataMap, userIndustryData, dynDateData
4
5
  } from "bri-datas";