bri-components 1.6.1 → 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.1",
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",
@@ -23,7 +23,6 @@
23
23
  @dragover.prevent="dragOver = true"
24
24
  @dragleave.prevent="dragOver = false"
25
25
  >
26
-
27
26
  <!-- 编辑 -->
28
27
  <div
29
28
  v-if="!disabled"
@@ -102,20 +101,7 @@
102
101
  import uploadMixin from "./uploadMixin.js";
103
102
  import BriUploadImage from "./BriUploadImage.vue";
104
103
  import uploadList from "./uploadList.vue";
105
-
106
- const prefixCls = "ivu-upload";
107
- const imageType = ["jpg", "png", "gif", "jpeg", "tiff", "swf"];
108
- const documentType = ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf", "xmind"];
109
- const videoType = ["flv", "rmvb", "mp4", "mvb"];
110
- const audioType = ["wma", "mp3", "m4a"];
111
- const packageType = ["rar", "zip"];
112
- const fileTypes = [
113
- ...documentType,
114
- ...imageType,
115
- ...videoType,
116
- ...audioType,
117
- ...packageType
118
- ];
104
+ import { fileTypes } from "../../../../data/index.js";
119
105
 
120
106
  export default {
121
107
  name: "BriUpload",
@@ -130,7 +116,7 @@
130
116
  props: {},
131
117
  data () {
132
118
  return {
133
- prefixCls: prefixCls,
119
+ prefixCls: "ivu-upload",
134
120
  dragOver: false,
135
121
 
136
122
  operationMap: {
@@ -146,20 +132,21 @@
146
132
  computed: {
147
133
  selfPropsObj () {
148
134
  return {
149
- _fileType: "file", // "file", "image"
135
+ _fileType: "file", // "file", "image", "video"
150
136
  _showMode: this.isHeightAuto ? "old" : "inline", // 宽度为100%、且不在表格字段里的 显示老版
151
137
 
152
- _multiple: true,
153
- _useType: "drag",
138
+ _multiple: true, // 默认多选
139
+ _useType: "drag", // "drag", "select"
154
140
  _maxSize: 1024 * 1024 * 2, // 根据四局要求,限制文件为2G
155
141
  _format: [],
142
+ _accept: [], // 限制只能传那些文件类型,_accept有值的话,_fileType就没用了
156
143
 
157
144
  ...this.propsObj,
158
145
  ...this.commonDealPropsObj
159
146
  };
160
147
  },
161
148
  subType () {
162
- return this.selfPropsObj._fileType;
149
+ return this.selfPropsObj._fileType || "file";
163
150
  },
164
151
  showMode () {
165
152
  return this.isInTable
@@ -179,24 +166,32 @@
179
166
  },
180
167
  // 限制文件格式
181
168
  accept () {
182
- return (this.subType === "image" ? imageType : fileTypes)
183
- .map(type => `.${type}`)
184
- .join();
169
+ const types = this.selfPropsObj._accept.length
170
+ ? this.selfPropsObj._accept
171
+ : (
172
+ this.subType === "file"
173
+ ? fileTypes
174
+ : fileTypes.filter(fileTypeItem => fileTypeItem.type === this.subType)
175
+ ).map(fileTypeItem => fileTypeItem._key);
176
+
177
+ return types.map(type => `.${type}`).join();
185
178
  },
186
179
  isShowEditIcon () {
187
180
  // 因为编辑name 需要这三个参数,因此没有这三个参数时不显示此按钮
188
- 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);
189
183
  },
190
184
  classes () {
191
185
  return {
192
- [`${prefixCls}`]: true,
193
- [`${prefixCls}-select`]: this.useType === "select",
194
- [`${prefixCls}-drag`]: this.useType === "drag",
195
- [`${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,
196
190
  [`BriUpload-${this.showMode}-wrapper`]: true
197
191
  };
198
192
  }
199
193
  },
194
+ created () {},
200
195
  methods: {
201
196
  clickUpload () {
202
197
  if (!this.disabled) {
@@ -251,10 +246,7 @@
251
246
  },
252
247
  dealUpload (files) {
253
248
  if (!this.disabled) {
254
- let postFiles = Array.prototype.slice.call(files);
255
- if (!this.multipleMode) {
256
- postFiles = postFiles.slice(0, 1);
257
- }
249
+ let postFiles = this.multipleMode ? [...files] : [...files].slice(0, 1);
258
250
  postFiles.forEach(fileItem => {
259
251
  if (
260
252
  (!this.format.length || this.format.some(item => item.toLocaleLowerCase() === fileItem.name.split(".").pop().toLocaleLowerCase())) &&
@@ -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>
@@ -50,9 +50,7 @@ export default {
50
50
  handlePost (file, callback) {
51
51
  this.$https({
52
52
  url: this.computedUrlModule,
53
- params: {
54
- token: this.$route.query && this.$route.query.token
55
- },
53
+ params: {},
56
54
  callback: res => {
57
55
  this.inputType = "file";
58
56
  if (res.ossType === "ali-oss") {
@@ -79,19 +77,16 @@ export default {
79
77
  },
80
78
 
81
79
  localUpload (file, res, callback) {
82
- let fileBody = {
83
- groupKey: this.computedGroupKey,
84
- archiveKey: this.archiveKey[this.archiveKey.length - 1]
85
- };
86
-
87
- const url = `${res.ossHost}${res.uploadPath}`;
88
80
  let formData = new FormData();
89
81
  formData.append("file_stream", file);
90
82
 
91
- axios.post(url, formData, {
83
+ axios.post(`${res.ossHost}${res.uploadPath}`, formData, {
92
84
  headers: {
93
85
  filetoken: res.filetoken,
94
- filebody: JSON.stringify(fileBody)
86
+ filebody: JSON.stringify({
87
+ groupKey: this.computedGroupKey,
88
+ archiveKey: this.archiveKey[this.archiveKey.length - 1]
89
+ })
95
90
  },
96
91
  onUploadProgress: progressEvent => {
97
92
  this.inProgress(Number((progressEvent.loaded / progressEvent.total * 100).toFixed(1)));
@@ -100,14 +95,16 @@ export default {
100
95
  this.uploadSuccess = true;
101
96
  this.percent = 100;
102
97
  setTimeout(() => {
103
- this.percent = 0;
104
98
  this.uploadSuccess = false;
99
+ this.percent = 0;
105
100
  }, 500);
101
+
106
102
  this.successCb && this.successCb(response, response.data, file);
107
103
  callback && callback(response.data);
108
104
  }).catch(error => {
109
- this.percent = 0;
110
105
  this.uploadSuccess = false;
106
+ this.percent = 0;
107
+
111
108
  this.handleError && this.handleError(error, {}, file);
112
109
  callback && callback(error);
113
110
  });
@@ -247,7 +244,6 @@ export default {
247
244
  callbackBodyType: "application/json",
248
245
  callbackBody: this.transferCallBody(callbackBody)
249
246
  };
250
-
251
247
  let newOss = {
252
248
  ...res.ossConfig,
253
249
  refreshSTSToken: async () => {
@@ -275,14 +271,16 @@ export default {
275
271
  this.uploadSuccess = true;
276
272
  this.percent = 100;
277
273
  setTimeout(() => {
278
- this.percent = 0;
279
274
  this.uploadSuccess = false;
275
+ this.percent = 0;
280
276
  }, 500);
277
+
281
278
  this.successCb && this.successCb(response, response.data, file);
282
279
  callback && callback(response.data);
283
280
  }).catch((err, response) => {
284
- this.percent = 0;
285
281
  this.uploadSuccess = false;
282
+ this.percent = 0;
283
+
286
284
  this.handleError && this.handleError(err, response, file);
287
285
  callback && callback(err);
288
286
  });
@@ -308,7 +306,6 @@ export default {
308
306
  callbackBodyType: "application/json",
309
307
  callbackBody: this.transferCallBody(callbackBody)
310
308
  };
311
-
312
309
  let newOss = {
313
310
  ...res.ossConfig,
314
311
  refreshSTSToken: async () => {
@@ -333,17 +330,19 @@ export default {
333
330
  "Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
334
331
  }
335
332
  }).then(response => {
336
- this.percent = 100;
337
333
  this.uploadSuccess = true;
334
+ this.percent = 100;
338
335
  setTimeout(() => {
339
- this.percent = 0;
340
336
  this.uploadSuccess = false;
337
+ this.percent = 0;
341
338
  }, 500);
339
+
342
340
  this.successCb && this.successCb(response, response.data, file);
343
341
  callback && callback(response.data);
344
342
  }).catch((err, response) => {
345
- this.percent = 0;
346
343
  this.uploadSuccess = false;
344
+ this.percent = 0;
345
+
347
346
  this.handleError && this.handleError(err, response, file);
348
347
  callback && callback(err);
349
348
  });
@@ -377,17 +376,17 @@ export default {
377
376
  return JSON.stringify(newObj);
378
377
  },
379
378
  // base64转换
380
- base64Encode (input) {
379
+ base64Encode (str) {
380
+ str = this.utf8Encode(str);
381
381
  let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
382
-
383
382
  let output = "";
384
383
  let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
385
384
  let i = 0;
386
- input = this.utf8Encode(input);
387
- while (i < input.length) {
388
- chr1 = input.charCodeAt(i++);
389
- chr2 = input.charCodeAt(i++);
390
- 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++);
391
390
  enc1 = chr1 >> 2;
392
391
  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
393
392
  enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
@@ -401,6 +400,7 @@ export default {
401
400
  _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
402
401
  _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
403
402
  }
403
+
404
404
  return output;
405
405
  },
406
406
  utf8Encode (str) {
@@ -420,6 +420,7 @@ export default {
420
420
  }
421
421
 
422
422
  }
423
+
423
424
  return utftext;
424
425
  },
425
426
  // base64转blob
@@ -430,13 +431,12 @@ export default {
430
431
  } else {
431
432
  byteString = unescape(base64Data.split(",")[1]);
432
433
  }
434
+
433
435
  // 获取文件类型
434
436
  const mimeString = base64Data.split(";")[0].split(":")[1]; // mime类型
435
-
436
437
  // ArrayBuffer 对象用来表示通用的、固定长度的原始二进制数据缓冲区
437
438
  // let arrayBuffer = new ArrayBuffer(byteString.length) // 创建缓冲数组
438
439
  // let uintArr = new Uint8Array(arrayBuffer) // 创建视图
439
-
440
440
  const uintArr = new Uint8Array(byteString.length); // 创建视图
441
441
 
442
442
  for (let i = 0; i < byteString.length; i += 1) {
@@ -446,6 +446,7 @@ export default {
446
446
  const blob = new Blob([uintArr], {
447
447
  type: mimeString
448
448
  });
449
+
449
450
  // 使用 Blob 创建一个指向类型化数组的URL, URL.createObjectURL是new Blob文件的方法,可以生成一个普通的url,可以直接使用,比如用在img.src上
450
451
  return blob;
451
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";