bri-components 1.6.1 → 1.6.2

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.2",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -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"
@@ -104,18 +103,18 @@
104
103
  import uploadList from "./uploadList.vue";
105
104
 
106
105
  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
- ];
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
+ ], []);
119
118
 
120
119
  export default {
121
120
  name: "BriUpload",
@@ -146,20 +145,21 @@
146
145
  computed: {
147
146
  selfPropsObj () {
148
147
  return {
149
- _fileType: "file", // "file", "image"
148
+ _fileType: "file", // "file", "image", "video"
150
149
  _showMode: this.isHeightAuto ? "old" : "inline", // 宽度为100%、且不在表格字段里的 显示老版
151
150
 
152
151
  _multiple: true,
153
152
  _useType: "drag",
154
153
  _maxSize: 1024 * 1024 * 2, // 根据四局要求,限制文件为2G
155
154
  _format: [],
155
+ _accept: [],
156
156
 
157
157
  ...this.propsObj,
158
158
  ...this.commonDealPropsObj
159
159
  };
160
160
  },
161
161
  subType () {
162
- return this.selfPropsObj._fileType;
162
+ return this.selfPropsObj._fileType || "file";
163
163
  },
164
164
  showMode () {
165
165
  return this.isInTable
@@ -179,9 +179,13 @@
179
179
  },
180
180
  // 限制文件格式
181
181
  accept () {
182
- return (this.subType === "image" ? imageType : fileTypes)
183
- .map(type => `.${type}`)
184
- .join();
182
+ const types = this.selfPropsObj._accept && this.selfPropsObj._accept.length
183
+ ? this.selfPropsObj._accept
184
+ : this.subType === "file"
185
+ ? allFileTypes
186
+ : fileTypesMap[this.subType];
187
+
188
+ return types.map(type => `.${type}`).join();
185
189
  },
186
190
  isShowEditIcon () {
187
191
  // 因为编辑name 需要这三个参数,因此没有这三个参数时不显示此按钮
@@ -251,10 +255,7 @@
251
255
  },
252
256
  dealUpload (files) {
253
257
  if (!this.disabled) {
254
- let postFiles = Array.prototype.slice.call(files);
255
- if (!this.multipleMode) {
256
- postFiles = postFiles.slice(0, 1);
257
- }
258
+ let postFiles = this.multipleMode ? [...files] : [...files].slice(0, 1);
258
259
  postFiles.forEach(fileItem => {
259
260
  if (
260
261
  (!this.format.length || this.format.some(item => item.toLocaleLowerCase() === fileItem.name.split(".").pop().toLocaleLowerCase())) &&
@@ -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") {