|  | 
| 80 | 80 |  headers: { | 
| 81 | 81 |  Authorization: Ticket.get() && "Bearer " + Ticket.get().access_token | 
| 82 | 82 |  }, | 
| 83 |  | - query() {} | 
|  | 83 | + query: (file, chunk) => { | 
|  | 84 | + return { | 
|  | 85 | + ...file.params, | 
|  | 86 | + } | 
|  | 87 | + }, | 
| 84 | 88 |  }, | 
| 85 | 89 |  attrs: { | 
| 86 | 90 |  accept: ACCEPT_CONFIG.getAll() | 
| 87 | 91 |  }, | 
| 88 | 92 |  panelShow: false, //选择文件后,展示上传panel | 
| 89 | 93 |  collapse: false, | 
|  | 94 | + params: {}, | 
| 90 | 95 |  } | 
| 91 | 96 |  },  | 
| 92 | 97 |  mounted() { | 
|  | 
| 109 | 114 |  this.panelShow = true; | 
| 110 | 115 |  this.computeMD5(file); | 
| 111 | 116 |  | 
|  | 117 | + // 2022年1月10日 将额外的参数赋值到每个文件上,解决了不同文件使用不同params的需求 | 
|  | 118 | + file.params = this.params | 
|  | 119 | + | 
| 112 | 120 |  Bus.$emit('fileAdded'); | 
| 113 | 121 |  }, | 
| 114 | 122 |  onFileProgress(rootFile, file, chunk) { | 
|  | 
| 133 | 141 |  api.mergeSimpleUpload({ | 
| 134 | 142 |  tempName: res.tempName, | 
| 135 | 143 |  fileName: file.name, | 
| 136 |  | - ...this.params, | 
|  | 144 | + ...file.params, | 
| 137 | 145 |  }).then(res => { | 
| 138 | 146 |  // 文件合并成功 | 
| 139 | 147 |  Bus.$emit('fileSuccess'); | 
|  | 
| 205 | 213 |  }, | 
| 206 | 214 |  | 
| 207 | 215 |  computeMD5Success(md5, file) { | 
| 208 |  | - // 将自定义参数直接加载uploader实例的opts上 | 
| 209 |  | - Object.assign(this.uploader.opts, { | 
| 210 |  | - query: { | 
| 211 |  | - ...this.params, | 
| 212 |  | - } | 
| 213 |  | - }) | 
| 214 |  | - | 
| 215 | 216 |  file.uniqueIdentifier = md5; | 
| 216 | 217 |  file.resume(); | 
| 217 | 218 |  this.statusRemove(file.id); | 
|  | 
0 commit comments