You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

MinioUploader.vue 22 kB

5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div class="dropzone-wrapper dataset-files">
  3. <div id="dataset" class="dropzone">
  4. <div class="maxfilesize ui red message" style="display: none;margin: 2.5rem;"></div>
  5. </div>
  6. <el-button style="background-color: #21ba45;margin-top: 2rem;" type="success" :disabled="btnFlag" @click="startUpload">{{upload}}</el-button>
  7. <el-button type="info" @click="cancelDataset">{{cancel}}</el-button>
  8. <div style="margin-top: 2rem;position: relative;">
  9. <label class="el-form-item__label" style="width: 140px;position: absolute;left: -140px;">上传状态:</label>
  10. <div v-for="item in allUploadFiles" style="display:flex;padding: 0.8rem 0;border-bottom: 1px solid #e8e8e8;line-height: 1;" >
  11. <span style="flex:4 1 0%;display: flex;max-width: 80%;"><i :class="[item.status===0?'ri-checkbox-circle-line success':'ri-close-circle-line failed']" style="margin-right: 0.5rem;"></i><span class="nowrap">{{item.name}}</span></span>
  12. <span style="flex:1" v-if="item.status===0"><span style="color: #21ba45;">上传成功</span></span>
  13. <span style="flex:1" v-else-if="item.status===1">
  14. <el-tooltip class="item" effect="dark" placement="top">
  15. <div slot="content">{{item.info}}</div>
  16. <span style="color: red;cursor: pointer;">上传失败<span>(重复上传)</span></span>
  17. </el-tooltip>
  18. </span>
  19. <span style="flex:1" v-else><span style="color: red;">上传失败</span></span>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import SparkMD5 from 'spark-md5';
  26. import axios from 'axios';
  27. import qs from 'qs';
  28. import createDropzone from '../features/dropzone.js';
  29. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  30. const chunkSize = 1024 * 1024 * 64;
  31. const md5ChunkSize = 1024 * 1024 * 1;
  32. export default {
  33. props:{
  34. uploadtype:{
  35. type:Number,
  36. required:true
  37. },
  38. desc:{
  39. type:String,
  40. default:''
  41. }
  42. },
  43. data() {
  44. return {
  45. dropzoneUploader: null,
  46. maxFiles: 10,
  47. maxFilesize: 200 ,
  48. acceptedFiles: '*/*',
  49. progress: 0,
  50. status: '',
  51. dropzoneParams: {},
  52. file_status_text: '',
  53. file:{},
  54. repoPath:'',
  55. btnFlag:false,
  56. cancel:'',
  57. upload:'',
  58. uploadFiles:[],
  59. uploadFilesAddId:[],
  60. allUploadFiles:[],
  61. uploadLength:0,
  62. allUploadLength:0,
  63. };
  64. },
  65. async mounted() {
  66. this.dropzoneParams = $('div#minioUploader-params');
  67. this.file_status_text = this.dropzoneParams.data('file-status');
  68. this.status = this.dropzoneParams.data('file-init-status');
  69. this.repoPath = this.dropzoneParams.data('repopath');
  70. this.cancel = this.dropzoneParams.data('cancel');
  71. this.upload = this.dropzoneParams.data('upload');
  72. let previewTemplate = `
  73. <div class="dz-preview dz-file-preview">
  74. <div class="dz-image">
  75. <img data-dz-thumbnail />
  76. </div>
  77. <div class="dz-details">
  78. <div class="dz-size"><span data-dz-size></span></div>
  79. <div class="dz-filename"><span data-dz-name></span></div>
  80. </div>
  81. <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
  82. <div class="dz-error-message" style="line-height: 1.5;"><span data-dz-errormessage></span></div>
  83. <div class="dz-success-mark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="54" height="54"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-.997-4L6.76 11.757l1.414-1.414 2.829 2.829 5.656-5.657 1.415 1.414L11.003 16z" fill="rgba(47,204,113,1)"/></svg></div>
  84. <div class="dz-error-mark"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="54" height="54"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-9.414l2.828-2.829 1.415 1.415L13.414 12l2.829 2.828-1.415 1.415L12 13.414l-2.828 2.829-1.415-1.415L10.586 12 7.757 9.172l1.415-1.415L12 10.586z" fill="rgba(231,76,60,1)"/></svg></div>
  85. </div> `
  86. const $dropzone = $('div#dataset');
  87. const dropzoneUploader = await createDropzone($dropzone[0], {
  88. url: '/todouploader',
  89. maxFiles: this.maxFiles,
  90. maxFilesize: 1024*200,
  91. filesizeBase:1024,
  92. parallelUploads: this.maxFiles,
  93. timeout: 0,
  94. addRemoveLinks:true,
  95. // autoQueue: false,
  96. autoProcessQueue: false, //自动上传
  97. dictDefaultMessage: this.dropzoneParams.data('default-message'),
  98. dictInvalidFileType: this.dropzoneParams.data('invalid-input-type'),
  99. dictFileTooBig: this.dropzoneParams.data('file-too-big'),
  100. dictRemoveFile: this.dropzoneParams.data('remove-file'),
  101. previewTemplate:previewTemplate
  102. });
  103. dropzoneUploader.on('addedfile', (file) => {
  104. if(file.size/(1024*1024)>dropzoneUploader.options.maxFilesize){
  105. dropzoneUploader.removeFile(file)
  106. $('.maxfilesize.ui.red.message').text("单次最多上传10个文件,单个文件不超过200G")
  107. $('.maxfilesize.ui.red.message').css('display','block')
  108. }else{
  109. this.file = file
  110. $('.maxfilesize.ui.red.message').css('display','none')
  111. }
  112. });
  113. dropzoneUploader.on("removedfile",(file)=>{
  114. $('.maxfilesize.ui.red.message').css('display','none')
  115. })
  116. dropzoneUploader.on('maxfilesexceeded', function (file) {
  117. dropzoneUploader.removeFile(file)
  118. $('.maxfilesize.ui.red.message').text("单次最多上传10个文件,单个文件不超过200G")
  119. $('.maxfilesize.ui.red.message').css('display','block')
  120. });
  121. this.dropzoneUploader = dropzoneUploader;
  122. },
  123. watch:{
  124. allUploadLength(len){
  125. if(len===this.uploadFiles.length){
  126. setTimeout(() => {
  127. this.dropzoneUploader.removeAllFiles(true)
  128. this.btnFlag = false
  129. this.$emit('setcluster',this.btnFlag)
  130. }, 2000);
  131. }
  132. }
  133. },
  134. methods: {
  135. startUpload(){
  136. this.uploadFiles = this.dropzoneUploader.getQueuedFiles()
  137. if(this.uploadFiles.length===0){
  138. return
  139. }
  140. this.resetStatus()
  141. $('.dz-remove').remove()
  142. $('.maxfilesize.ui.red.message').css('display','none')
  143. this.btnFlag = true
  144. this.$emit('setcluster',this.btnFlag)
  145. this.uploadFiles.forEach(element => {
  146. element.datasetId = document.getElementById('datasetId').getAttribute('datasetId')
  147. this.computeMD5(element)
  148. });
  149. },
  150. cancelDataset(){
  151. location.href = this.repoPath
  152. this.dropzoneUploader.removeAllFiles(true)
  153. },
  154. resetStatus() {
  155. this.uploadLength = 0
  156. this.allUploadLength = 0
  157. this.allUploadFiles = []
  158. },
  159. updateProgress(file, progress) {
  160. file.previewTemplate.querySelector(
  161. '.dz-upload'
  162. ).style.width = `${progress}%`
  163. file.previewTemplate.querySelector(
  164. '.dz-upload'
  165. ).style.background = '#409eff';
  166. },
  167. uploadError(file,info){
  168. file.previewTemplate.querySelector(
  169. '.dz-error-mark'
  170. ).style.opacity = 1
  171. file.previewTemplate.querySelector(
  172. '.dz-progress'
  173. ).style.opacity = 0
  174. file.previewTemplate.querySelector(
  175. '.dz-error-message span'
  176. ).innerHTML = info
  177. file.previewTemplate.querySelector(
  178. '.dz-error-message'
  179. ).style.display = 'block'
  180. file.previewTemplate.querySelector(
  181. '.dz-details'
  182. ).onmouseover = function(){file.previewTemplate.querySelector('.dz-error-message').style.opacity = 1 }
  183. file.previewTemplate.querySelector(
  184. '.dz-details'
  185. ).onmouseout = function(){file.previewTemplate.querySelector('.dz-error-message').style.opacity = 0 }
  186. },
  187. emitDropzoneSuccess(file) {
  188. file.status = 'success';
  189. this.dropzoneUploader.emit('success', file);
  190. this.dropzoneUploader.emit('complete', file);
  191. },
  192. emitDropzoneFailed(file) {
  193. this.status = this.dropzoneParams.data('falied');
  194. file.status = 'error';
  195. this.dropzoneUploader.emit('error', file);
  196. // this.dropzoneUploader.emit('complete', file);
  197. },
  198. finishUpload(file) {
  199. console.log("finish",file)
  200. file.previewTemplate.querySelector(
  201. '.dz-success-mark'
  202. ).style.opacity = 1
  203. file.previewTemplate.querySelector(
  204. '.dz-progress'
  205. ).style.opacity = 0
  206. if(this.uploadLength === this.uploadFiles.length){
  207. setTimeout(() => {
  208. window.location.href = this.repoPath
  209. }, 1000);
  210. }
  211. },
  212. computeMD5(file) {
  213. const blobSlice =
  214. File.prototype.slice ||
  215. File.prototype.mozSlice ||
  216. File.prototype.webkitSlice,
  217. chunks = Math.ceil(file.size / chunkSize),
  218. spark = new SparkMD5.ArrayBuffer(),
  219. fileReader = new FileReader();
  220. let currentChunk = 0;
  221. const time = new Date().getTime();
  222. this.status = this.dropzoneParams.data('md5-computing');
  223. file.totalChunkCounts = chunks;
  224. if (file.size==0) {
  225. file.totalChunkCounts = 1
  226. }
  227. loadMd5Next();
  228. fileReader.onload = (e) => {
  229. fileLoaded.call(this, e);
  230. };
  231. fileReader.onerror = (err) => {
  232. console.warn('oops, something went wrong.', err);
  233. file.cancel();
  234. };
  235. function fileLoaded(e) {
  236. spark.append(e.target.result); // Append array buffer
  237. currentChunk++;
  238. if (currentChunk < chunks) {
  239. this.status = `${this.dropzoneParams.data('loading-file')} ${(
  240. (currentChunk / chunks) *
  241. 100
  242. ).toFixed(2)}% (${currentChunk}/${chunks})`;
  243. // this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2));
  244. loadMd5Next();
  245. return;
  246. }
  247. const md5 = spark.end();
  248. console.log(
  249. `MD5计算完成:${file.name} \nMD5:${md5} \n分片:${chunks} 大小:${
  250. file.size
  251. } 用时:${(new Date().getTime() - time) / 1000} s`
  252. );
  253. // this.updateProgress(file,100)
  254. spark.destroy(); // 释放缓存
  255. file.uniqueIdentifier = md5; // 将文件md5赋值给文件唯一标识
  256. file.cmd5 = false; // 取消计算md5状态
  257. this.computeMD5Success(file);
  258. }
  259. function loadNext() {
  260. const start = currentChunk * chunkSize;
  261. const end =
  262. start + chunkSize >= file.size ? file.size : start + chunkSize;
  263. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  264. }
  265. function loadMd5Next() {
  266. const start = currentChunk * chunkSize;
  267. const end =
  268. start + md5ChunkSize >= file.size ? file.size : start + md5ChunkSize;
  269. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  270. }
  271. },
  272. async computeMD5Success(md5edFile) {
  273. const file = await this.getSuccessChunks(md5edFile);
  274. try {
  275. if (file.uploadID == '' || file.uuid == '') {
  276. // 未上传过
  277. await this.newMultiUpload(file);
  278. if (file.uploadID != '' && file.uuid != '') {
  279. file.chunks = '';
  280. this.multipartUpload(file);
  281. } else {
  282. // 失败如何处理
  283. let info = "上传失败"
  284. this.allUploadLength++
  285. this.uploadError(file,info)
  286. this.allUploadFiles.push({name:file.name,status:2,info:info})
  287. return;
  288. }
  289. return;
  290. }
  291. if (file.uploaded == '1') {
  292. // 已上传成功
  293. // 秒传
  294. if (file.attachID == '0') {
  295. // 删除数据集记录,未删除文件
  296. await addAttachment(file);
  297. }
  298. //不同数据集上传同一个文件
  299. if (file.datasetID != '') {
  300. if (file.datasetName != "" && file.realName != "") {
  301. let info = `该文件已上传在数据集: ${file.datasetName}`
  302. this.uploadError(file,info)
  303. this.allUploadLength++
  304. this.allUploadFiles.push({name:file.name,status:1,info:info})
  305. return;
  306. }
  307. }
  308. console.log('文件已上传完成');
  309. this.allUploadLength++
  310. this.allUploadFiles.push({name:file.name,status:0,info:'上传成功'})
  311. this.updateProgress(file, 100);
  312. this.progress = 100;
  313. this.status = this.dropzoneParams.data('upload-complete');
  314. this.finishUpload(file);
  315. } else {
  316. // 断点续传
  317. this.multipartUpload(file);
  318. }
  319. } catch (error) {
  320. this.emitDropzoneFailed(file);
  321. console.log(error);
  322. let info = "上传失败"
  323. this.allUploadLength++
  324. this.uploadError(file,info)
  325. this.allUploadFiles.push({name:file.name,status:2,info:info})
  326. }
  327. async function addAttachment(file) {
  328. return await axios.post(
  329. '/attachments/add',
  330. qs.stringify({
  331. uuid: file.uuid,
  332. file_name: file.name,
  333. size: file.size,
  334. dataset_id: file.datasetId,
  335. type: this.uploadtype,
  336. _csrf: csrf
  337. })
  338. );
  339. }
  340. },
  341. async getSuccessChunks(file) {
  342. const params = {
  343. params: {
  344. md5: file.uniqueIdentifier,
  345. type: this.uploadtype,
  346. file_name: file.name,
  347. _csrf: csrf
  348. }
  349. };
  350. try {
  351. const response = await axios.get('/attachments/get_chunks', params);
  352. file.uploadID = response.data.uploadID;
  353. file.uuid = response.data.uuid;
  354. file.uploaded = response.data.uploaded;
  355. file.chunks = response.data.chunks;
  356. file.attachID = response.data.attachID;
  357. file.datasetID = response.data.datasetID;
  358. file.datasetName = response.data.datasetName;
  359. file.realName = response.data.fileName;
  360. return file;
  361. } catch (error) {
  362. this.emitDropzoneFailed(file);
  363. console.log('getSuccessChunks catch: ', error);
  364. return null;
  365. }
  366. },
  367. async newMultiUpload(file) {
  368. const res = await axios.get('/attachments/new_multipart', {
  369. params: {
  370. totalChunkCounts: file.totalChunkCounts,
  371. md5: file.uniqueIdentifier,
  372. size: file.size,
  373. fileType: file.type,
  374. type: this.uploadtype,
  375. file_name: file.name,
  376. _csrf: csrf
  377. }
  378. });
  379. file.uploadID = res.data.uploadID;
  380. file.uuid = res.data.uuid;
  381. },
  382. multipartUpload(file) {
  383. const blobSlice =
  384. File.prototype.slice ||
  385. File.prototype.mozSlice ||
  386. File.prototype.webkitSlice,
  387. chunks = Math.ceil(file.size / chunkSize),
  388. fileReader = new FileReader(),
  389. time = new Date().getTime();
  390. let currentChunk = 0;
  391. let _this = this
  392. function loadNext() {
  393. const start = currentChunk * chunkSize;
  394. const end =
  395. start + chunkSize >= file.size ? file.size : start + chunkSize;
  396. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  397. }
  398. function checkSuccessChunks() {
  399. const index = successChunks.indexOf((currentChunk + 1).toString());
  400. if (index == -1) {
  401. return false;
  402. }
  403. return true;
  404. }
  405. async function getUploadChunkUrl(currentChunk, partSize) {
  406. const res = await axios.get('/attachments/get_multipart_url', {
  407. params: {
  408. uuid: file.uuid,
  409. uploadID: file.uploadID,
  410. size: partSize,
  411. chunkNumber: currentChunk + 1,
  412. type: _this.uploadtype,
  413. file_name: file.name,
  414. _csrf: csrf
  415. }
  416. });
  417. urls[currentChunk] = res.data.url;
  418. }
  419. async function uploadMinio(url, e) {
  420. const res = await axios.put(url, e.target.result);
  421. delete e.target.result
  422. etags[currentChunk] = res.headers.etag;
  423. }
  424. async function uploadMinioNewMethod(url,e){
  425. var xhr = new XMLHttpRequest();
  426. xhr.open('PUT', url, false);
  427. if(_this.uploadtype===0){
  428. xhr.setRequestHeader('Content-Type', 'text/plain')
  429. xhr.send(e.target.result);
  430. var etagValue = xhr.getResponseHeader('etag');
  431. etags[currentChunk] = etagValue;
  432. }
  433. else if(_this.uploadtype===1){
  434. xhr.setRequestHeader('Content-Type', '')
  435. xhr.send(e.target.result);
  436. var etagValue = xhr.getResponseHeader('ETag');
  437. //console.log(etagValue);
  438. etags[currentChunk] = etagValue;
  439. }
  440. }
  441. async function updateChunk(currentChunk) {
  442. await axios.post(
  443. '/attachments/update_chunk',
  444. qs.stringify({
  445. uuid: file.uuid,
  446. chunkNumber: currentChunk + 1,
  447. etag: etags[currentChunk],
  448. _csrf: csrf
  449. })
  450. );
  451. }
  452. async function uploadChunk(e) {
  453. try {
  454. if (!checkSuccessChunks()) {
  455. const start = currentChunk * chunkSize;
  456. const partSize =
  457. start + chunkSize >= file.size ? file.size - start : chunkSize;
  458. // 获取分片上传url
  459. await getUploadChunkUrl(currentChunk, partSize);
  460. if (urls[currentChunk] != '') {
  461. // 上传到minio
  462. //await uploadMinio(urls[currentChunk], e);
  463. await uploadMinioNewMethod(urls[currentChunk], e);
  464. if (etags[currentChunk] != '') {
  465. // 更新数据库:分片上传结果
  466. //await updateChunk(currentChunk);
  467. } else {
  468. console.log("上传到minio uploadChunk etags[currentChunk] == ''");// TODO
  469. }
  470. } else {
  471. console.log("uploadChunk urls[currentChunk] != ''");// TODO
  472. }
  473. }
  474. } catch (error) {
  475. console.log(error);
  476. //this.emitDropzoneFailed(file);
  477. //console.log(error);
  478. throw error;
  479. }
  480. }
  481. async function completeUpload() {
  482. return await axios.post(
  483. '/attachments/complete_multipart',
  484. qs.stringify({
  485. uuid: file.uuid,
  486. uploadID: file.uploadID,
  487. file_name: file.name,
  488. size: file.size,
  489. dataset_id: file.datasetId,
  490. type: _this.uploadtype,
  491. _csrf: csrf,
  492. description:_this.desc
  493. })
  494. );
  495. }
  496. const successChunks = [];
  497. let successParts = [];
  498. successParts = file.chunks.split(',');
  499. for (let i = 0; i < successParts.length; i++) {
  500. successChunks[i] = successParts[i].split('-')[0];
  501. }
  502. const urls = []; // TODO const ?
  503. const etags = [];
  504. console.log('上传分片...');
  505. this.status = this.dropzoneParams.data('uploading');
  506. loadNext();
  507. fileReader.onload = async (e) => {
  508. try{
  509. await uploadChunk(e);
  510. }catch(err){
  511. console.log(err)
  512. let info = "上传失败"
  513. this.allUploadLength++
  514. this.uploadError(file,info)
  515. this.allUploadFiles.push({name:file.name,status:2,info:info});
  516. return;
  517. }
  518. fileReader.abort();
  519. currentChunk++;
  520. if (currentChunk < chunks) {
  521. console.log(
  522. `第${currentChunk}个分片上传完成, 开始第${currentChunk +
  523. 1}/${chunks}个分片上传`
  524. );
  525. this.progress = Math.ceil((currentChunk / chunks) * 100);
  526. this.updateProgress(file, ((currentChunk / chunks) * 100).toFixed(2));
  527. this.status = `${this.dropzoneParams.data('uploading')} ${(
  528. (currentChunk / chunks) *
  529. 100
  530. ).toFixed(2)}%`;
  531. await loadNext();
  532. } else {
  533. try{
  534. await completeUpload();
  535. }catch(err){
  536. let info = "上传失败"
  537. this.allUploadLength++
  538. this.uploadError(file,info)
  539. this.allUploadFiles.push({name:file.name,status:2,info:info})
  540. if(err){
  541. return
  542. }
  543. }
  544. console.log(
  545. `文件上传完成:${file.name} \n分片:${chunks} 大小:${
  546. file.size
  547. } 用时:${(new Date().getTime() - time) / 1000} s`
  548. );
  549. this.uploadLength++
  550. this.allUploadLength++
  551. this.allUploadFiles.push({name:file.name,status:0,info:'上传成功'})
  552. this.updateProgress(file, 100);
  553. this.progress = 100;
  554. this.status = this.dropzoneParams.data('upload-complete');
  555. this.finishUpload(file);
  556. }
  557. };
  558. }
  559. }
  560. };
  561. </script>
  562. <style>
  563. .dropzone-wrapper {
  564. margin: 0;
  565. }
  566. .ui .dropzone {
  567. border: 2px dashed #0087f5;
  568. box-shadow: none !important;
  569. padding: 0;
  570. min-height: 5rem;
  571. border-radius: 4px;
  572. }
  573. .dataset .dataset-files #dataset .dz-preview.dz-file-preview,
  574. .dataset .dataset-files #dataset .dz-preview.dz-processing {
  575. display: flex;
  576. align-items: center;
  577. }
  578. .dataset .dataset-files #dataset .dz-preview {
  579. border-bottom: 1px solid #dadce0;
  580. min-height: 0;
  581. }
  582. .upload-info{
  583. margin-top: 1em;
  584. margin-bottom: 3em;
  585. }
  586. .success{
  587. color: #21ba45;
  588. }
  589. .failed{
  590. color: red;
  591. }
  592. </style>