@lambo-design/upload-file 1.0.0-beta.16 → 1.0.0-beta.17

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/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
  # Changelog
2
+ ## [1.0.0-beta.17](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design/upload-file@1.0.0-beta.16...@lambo-design/upload-file@1.0.0-beta.17) (2024-06-04)
3
+
4
+
5
+ ### ✨ Features | 新功能
6
+
7
+ * **upload-file:** 增加文件编码列表fileIdList、限制文件上传数量limitFileNum属性 ([9c0b631](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9c0b6310b797503c574a7f32e90768e9912a5c4e))
8
+
2
9
  ## [1.0.0-beta.16](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design/upload-file@1.0.0-beta.15...@lambo-design/upload-file@1.0.0-beta.16) (2024-05-31)
3
10
 
4
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/upload-file",
3
- "version": "1.0.0-beta.16",
3
+ "version": "1.0.0-beta.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
package/src/index.vue CHANGED
@@ -64,6 +64,12 @@ export default {
64
64
  type: Boolean,
65
65
  default: false
66
66
  },
67
+ //限制上传数量
68
+ limitFileNum: {
69
+ type: Number,
70
+ required: false,
71
+ default: 0
72
+ },
67
73
  //是否按钮形式
68
74
  uploadBtn: {
69
75
  type: Boolean,
@@ -88,6 +94,14 @@ export default {
88
94
  required: false,
89
95
  default: ""
90
96
  },
97
+ //文件编码列表
98
+ fileIdList: {
99
+ type: Array,
100
+ required: false,
101
+ default: () => {
102
+ return []
103
+ }
104
+ },
91
105
  //文件列表
92
106
  fileList: {
93
107
  type: Array,
@@ -145,7 +159,11 @@ export default {
145
159
  },
146
160
  methods: {
147
161
  UploadFile: function () {
148
- this.$refs.uploadInput.click();
162
+ if (this.limitFileNum !== 0 && this.resultList.length > this.limitFileNum) {
163
+ alert('最多只能上传' + this.limitFileNum + '个文件');
164
+ } else {
165
+ this.$refs.uploadInput.click();
166
+ }
149
167
  },
150
168
  readFile: function (e, num) {
151
169
  let self = this;
@@ -257,11 +275,50 @@ export default {
257
275
  this.$emit("upload-result", this.resultList, deletes);
258
276
  }
259
277
  }
278
+ },
279
+ initFileList: function (value) {
280
+ if (this.resultList.length === 0) {
281
+ let requests = []
282
+ for (const fileId of value) {
283
+ requests.push(ajax.get(config.upmsServerContext + "/oss/file/getMetaData/" + fileId))
284
+ }
285
+ Promise.all(requests).then((response) => {
286
+ response.forEach(item => {
287
+ this.resultList.push({
288
+ fileCode: item.data.data.fileId,
289
+ fileUrl: this.ossServerContext + this.ossFileGetUrl + item.data.data.fileId,
290
+ fileName: item.data.data.fileName,
291
+ fileType: item.data.data.fileName.substring(item.data.data.fileName.lastIndexOf(".") + 1),
292
+ size: item.data.data.length,
293
+ showSize: formatterSizeUnit(item.data.data.length),
294
+ otherParam: this.otherParam
295
+ })
296
+ })
297
+ });
298
+ }
299
+ },
300
+ arraysEqual(arr1, arr2) {
301
+ if (arr1.length !== arr2.length) return false;
302
+ for (let i = 0; i < arr1.length; i++) {
303
+ if (arr1[i] !== arr2[i]) return false;
304
+ }
305
+ return true;
260
306
  }
261
307
  },
262
308
  watch: {
263
- fileList: function (value) {
264
- this.resultList = this.fileList
309
+ fileList: {
310
+ handler: function (value) {
311
+ this.resultList = this.fileList
312
+ },
313
+ deep: true
314
+ },
315
+ fileIdList: {
316
+ handler: function (newValue, oldValue) {
317
+ if (newValue.length > 0 && !this.arraysEqual(newValue, oldValue)) {
318
+ this.initFileList(newValue)
319
+ }
320
+ },
321
+ deep: true
265
322
  }
266
323
  }
267
324
  }