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.

modelmanage-local-create-2.vue 26 kB

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
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
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
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
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
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
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
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
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
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
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. <template>
  2. <div>
  3. <div class="header">
  4. <span class="title">{{ type == '1' ? $t('modelManage.addModelFiles') : $t('modelManage.uploadModelFiles') }}</span>
  5. </div>
  6. <div class="content ui form">
  7. <div class="guide-c" v-if="type != '1'">
  8. <div class="step">
  9. <div class="num">1</div>
  10. <div class="txt">{{$t('modelManage.createModel')}}</div>
  11. </div>
  12. <div class="line"></div>
  13. <div class="step focused">
  14. <div class="num">2</div>
  15. <div class="txt">{{$t('modelManage.uploadModelFiles')}}</div>
  16. </div>
  17. </div>
  18. <div class="row-c">
  19. <div class="row">
  20. <div class="r-title"><label class="required">{{$t('modelManage.modelName')}}</label></div>
  21. <div class="r-content">
  22. <el-input size="medium" class="input-disabled" v-model="state.name" :placeholder="$t('modelManage.pleaseInputModelName')" readonly>
  23. </el-input>
  24. </div>
  25. </div>
  26. <div class="row" style="align-items:flex-start;">
  27. <div class="r-title"><label class="required">{{$t('modelManage.fileUpload')}}</label></div>
  28. <div class="r-content">
  29. <div style="position:relative">
  30. <form class="dropzone" ref="dropzoneRef">
  31. <div class="dropzon-err-tips ui red message" v-show="showUploadErr" style="display:none;margin:2.5rem">
  32. {{ uploadErrTxt }}</div>
  33. </form>
  34. <div class="not-allowed-placeholder" v-show="uploading"></div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="row" style="margin-top:10px">
  39. <div class="r-title"><label></label></div>
  40. <div class="r-content">
  41. <el-button size="medium" class="green" @click="submit" :disabled="uploading">{{$t('modelManage.upload')}}</el-button>
  42. <el-button size="medium" @click="cancel">{{$t('modelManage.cancel')}}</el-button>
  43. </div>
  44. </div>
  45. <div class="row" style="align-items:flex-start;">
  46. <div class="r-title"><label>{{$t('modelManage.uploadStatus')}}:</label></div>
  47. <div class="r-content">
  48. <div v-for="(item, index) in uploadFiles" :key="item.upload.uuid" class="datast-upload-progress">
  49. <span class="dataset-name nowrap" :title="item.name">{{ item.name }}</span>
  50. <div class="dataset-progress">
  51. <el-progress :text-inside="true" :stroke-width="14" :percentage="uploadStatusList[index].progress">
  52. </el-progress>
  53. </div>
  54. <div class="dataset-status nowrap">
  55. <div class="status-flex">
  56. <i v-if="uploadStatusList[index].infoCode === 1 || uploadStatusList[index].infoCode === 2"
  57. class="ri-close-circle-line failed"></i>
  58. <i v-if="uploadStatusList[index].infoCode === 0" class="ri-checkbox-circle-line success"></i>
  59. <span>{{ uploadStatusList[index].status }}</span>
  60. <el-tooltip v-if="uploadStatusList[index].infoCode === 1" class="item" effect="dark" placement="top">
  61. <div slot="content"> {{ uploadStatusList[index].failedInfo }} </div>
  62. <i style="font-size: 16px; margin-left: 0.5rem; cursor: pointer" class="ri-question-fill"></i>
  63. </el-tooltip>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import 'dropzone/dist/dropzone.css';
  75. import Dropzone from 'dropzone';
  76. import SparkMD5 from "spark-md5";
  77. import { getModelInfoByName, getChunks, getNewMultipart, getMultipartUrl, setCompleteMultipart } from '~/apis/modules/modelmanage';
  78. import { getUrlSearchParams } from '~/utils';
  79. Dropzone.autoDiscover = false;
  80. const uploadChunkSize = 1024 * 1024 * 64;
  81. const md5ChunkSize = 1024 * 1024 * 64;
  82. const maxFileSize = 10;
  83. const maxModelFilesSize = 200 * 1024 * 1024 * 1024; // 200 GB
  84. export default {
  85. data() {
  86. return {
  87. dropzoneHandler: null,
  88. type: '0', // 1-修改,其它-新增
  89. state: {
  90. type: '',
  91. id: '',
  92. name: '',
  93. version: '',
  94. engine: '',
  95. label: '',
  96. description: '',
  97. size: '',
  98. },
  99. originData: null,
  100. showUploadErr: false,
  101. uploadErrTxt: '',
  102. defaultErrTxt: this.$t('modelManage.modelFileUploadErrTips'),
  103. uploadFiles: [],
  104. uploadLength: 0,
  105. uploadSuccessLength: 0,
  106. uploadStatusList: [],
  107. uploading: false,
  108. };
  109. },
  110. components: {},
  111. methods: {
  112. initModelData() {
  113. const urlParams = getUrlSearchParams();
  114. if (urlParams.name && urlParams.id) {
  115. this.type = urlParams.type || '0';
  116. this.state.name = urlParams.name;
  117. this.state.id = urlParams.id;
  118. this.loading = true;
  119. getModelInfoByName({
  120. repo: location.pathname.split('/').slice(0, 3).join('/'),
  121. name: urlParams.name,
  122. id: urlParams.id
  123. }).then(res => {
  124. this.loading = false;
  125. const list = res.data;
  126. if (list && list.length) {
  127. const data = list[0];
  128. this.state.type = data.type;
  129. this.state.id = data.id;
  130. this.state.name = data.name;
  131. this.state.version = data.version;
  132. this.state.engine = data.engine.toString();
  133. this.state.label = data.label;
  134. this.state.description = data.description;
  135. this.state.size = data.size || 0;
  136. this.originData = data;
  137. } else {
  138. this.cancel();
  139. }
  140. }).catch(err => {
  141. this.loading = false;
  142. console.log(err);
  143. this.cancel();
  144. });
  145. } else {
  146. this.cancel();
  147. }
  148. },
  149. initDropZone() {
  150. this.dropzoneHandler = new Dropzone(this.$refs.dropzoneRef, {
  151. url: '/',
  152. maxFiles: 10,
  153. parallelUploads: 20,
  154. uploadMultiple: true,
  155. maxFilesize: maxModelFilesSize,
  156. timeout: 0,
  157. addRemoveLinks: true,
  158. autoProcessQueue: false,
  159. dictDefaultMessage: this.$t('modelManage.modelFileUploadDefaultTips'),
  160. dictFileTooBig: this.$t('modelManage.fileIstoBig'),
  161. dictRemoveFile: this.$t('modelManage.removeFile'),
  162. dictMaxFilesExceeded: this.defaultErrTxt,
  163. });
  164. this.dropzoneHandler.on("addedfile", file => {
  165. this.checkFiles(file);
  166. });
  167. this.dropzoneHandler.on("removedfile", file => {
  168. this.checkFiles();
  169. });
  170. },
  171. showUploadErrInfo(state, info) {
  172. if (state) {
  173. this.uploadErrTxt = info;
  174. this.showUploadErr = true;
  175. } else {
  176. this.uploadErrTxt = '';
  177. this.showUploadErr = false;
  178. }
  179. },
  180. checkFiles(file) {
  181. const fileList = this.dropzoneHandler.getAcceptedFiles();
  182. const filesSize = fileList.reduce((acc, item, index) => acc + item.size, 0) + (file ? file.size : 0);
  183. const filesCount = fileList.length + (file ? 1 : 0);
  184. const allfilesSize = filesSize + this.state.size;
  185. if (filesCount > maxFileSize || allfilesSize > maxModelFilesSize) {
  186. this.showUploadErrInfo(true, this.defaultErrTxt);
  187. return false;
  188. }
  189. this.showUploadErrInfo(false);
  190. return true;
  191. },
  192. resetFileStatus() {
  193. this.uploadFiles = [];
  194. this.uploadLength = 0;
  195. this.uploadSuccessLength = 0;
  196. this.uploadStatusList = [];
  197. },
  198. updateFileStatus(file, status, progress, infoCode, failedInfo = "") {
  199. this.uploadStatusList.forEach((item, index) => {
  200. if (item.uploadUuid === file.upload.uuid) {
  201. this.uploadStatusList[index].status = status;
  202. this.uploadStatusList[index].progress = progress;
  203. this.uploadStatusList[index].infoCode = infoCode;
  204. this.uploadStatusList[index].failedInfo = failedInfo;
  205. }
  206. });
  207. },
  208. calcFileMd5(file) {
  209. const blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
  210. const chunkSize = md5ChunkSize;
  211. const chunks = Math.ceil(file.size / chunkSize);
  212. const spark = new SparkMD5.ArrayBuffer();
  213. const fileReader = new FileReader();
  214. file.totalChunkCounts = chunks;
  215. if (file.size == 0) {
  216. file.totalChunkCounts = 1;
  217. }
  218. let currentChunk = 0;
  219. this.uploadStatusList.push({
  220. uploadUuid: file.upload.uuid,
  221. name: file.name,
  222. status: this.$t('modelManage.calcFileMd5'),
  223. progress: 0,
  224. infoCode: 3,
  225. });
  226. return new Promise((resolve, reject) => {
  227. fileReader.onload = function (e) {
  228. spark.append(e.target.result);
  229. currentChunk++;
  230. if (currentChunk < chunks) {
  231. loadNext();
  232. } else {
  233. const md5 = spark.end();
  234. spark.destroy();
  235. file.uniqueIdentifier = md5;
  236. resolve(md5);
  237. }
  238. };
  239. fileReader.onerror = function (e) {
  240. console.warn(file.name + ': calcFileMd5 went wrong.');
  241. reject(e);
  242. };
  243. function loadNext() {
  244. const start = currentChunk * chunkSize;
  245. const end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
  246. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  247. }
  248. loadNext();
  249. });
  250. },
  251. getChunksInfo(file) {
  252. return getChunks({
  253. md5: file.uniqueIdentifier,
  254. type: this.state.type,
  255. modeluuid: this.state.id,
  256. file_name: file.name,
  257. scene: 'model',
  258. }).then(res => {
  259. const data = res.data;
  260. file.uploadID = data.uploadID;
  261. file.uuid = data.uuid;
  262. file.uploaded = data.uploaded;
  263. file.chunks = data.chunks;
  264. file.attachID = data.attachID;
  265. file._modelUuid = data.modeluuid;
  266. file._modelName = data.modelName;
  267. file.realName = data.fileName;
  268. return file;
  269. }).catch(err => {
  270. console.info('getChunksInfo', err);
  271. return err;
  272. });
  273. },
  274. newUpload(file) {
  275. return getNewMultipart({
  276. totalChunkCounts: file.totalChunkCounts,
  277. md5: file.uniqueIdentifier,
  278. size: file.size,
  279. fileType: file.type,
  280. type: this.state.type,
  281. file_name: file.name,
  282. scene: 'model',
  283. modeluuid: file.modelUuid,
  284. }).then(res => {
  285. const data = res.data;
  286. file.uploadID = data.uploadID;
  287. file.uuid = data.uuid;
  288. if (file.uploadID && file.uuid) {
  289. file.chunks = '';
  290. this.breakpointUpload(file);
  291. } else {
  292. this.uploadError(file, info);
  293. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 0, 2);
  294. }
  295. return file;
  296. }).catch(err => {
  297. console.log('getNewMultipart', err);
  298. this.uploadError(file, info);
  299. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 0, 2);
  300. return err;
  301. });
  302. },
  303. breakpointUpload(file) {
  304. const blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
  305. const fileReader = new FileReader();
  306. const time = new Date().getTime();
  307. const chunkSize = uploadChunkSize;
  308. const chunks = Math.ceil(file.size / chunkSize);
  309. const _this = this;
  310. let currentChunk = 0;
  311. const successChunks = [];
  312. const successParts = file.chunks.split(",");
  313. for (let i = 0; i < successParts.length; i++) {
  314. successChunks[i] = successParts[i].split("-")[0];
  315. }
  316. const urls = [];
  317. const etags = [];
  318. const checkSuccessChunks = () => {
  319. const index = successChunks.indexOf((currentChunk + 1).toString());
  320. if (index == -1) {
  321. return false;
  322. }
  323. return true;
  324. }
  325. const getUploadChunkUrl = async (currentChunk, partSize) => {
  326. const res = await getMultipartUrl({
  327. uuid: file.uuid,
  328. uploadID: file.uploadID,
  329. size: partSize,
  330. chunkNumber: currentChunk + 1,
  331. type: _this.state.type,
  332. file_name: file.name,
  333. scene: 'model',
  334. });
  335. urls[currentChunk] = res.data.url;
  336. };
  337. const uploadMinioNewMethod = async (url, e) => {
  338. const xhr = new XMLHttpRequest();
  339. xhr.open("PUT", url, false);
  340. if (_this.state.type == 0) {
  341. xhr.setRequestHeader("Content-Type", "text/plain");
  342. xhr.send(e.target.result);
  343. const etagValue = xhr.getResponseHeader("etag");
  344. etags[currentChunk] = etagValue;
  345. } else if (_this.state.type == 1) {
  346. xhr.setRequestHeader("Content-Type", "");
  347. xhr.send(e.target.result);
  348. const etagValue = xhr.getResponseHeader("ETag");
  349. etags[currentChunk] = etagValue;
  350. }
  351. }
  352. const uploadChunk = async (e) => {
  353. try {
  354. if (!checkSuccessChunks()) {
  355. const start = currentChunk * chunkSize;
  356. const partSize = start + chunkSize >= file.size ? file.size - start : chunkSize;
  357. // 获取分片上传url
  358. await getUploadChunkUrl(currentChunk, partSize);
  359. if (urls[currentChunk] != '') {
  360. await uploadMinioNewMethod(urls[currentChunk], e);
  361. if (etags[currentChunk] != '') {
  362. } else {
  363. console.log("上传到minio uploadChunk etags[currentChunk] == ''"); // TODO
  364. }
  365. } else {
  366. console.log("uploadChunk urls[currentChunk] != ''"); // TODO
  367. }
  368. }
  369. } catch (error) {
  370. console.log(error);
  371. }
  372. }
  373. const completeUpload = async () => {
  374. return await setCompleteMultipart({
  375. uuid: file.uuid,
  376. uploadID: file.uploadID,
  377. file_name: file.name,
  378. size: file.size,
  379. type: _this.state.type,
  380. scene: 'model',
  381. modeluuid: file.modelUuid,
  382. });
  383. }
  384. function loadNext() {
  385. const start = currentChunk * chunkSize;
  386. const end = start + chunkSize >= file.size ? file.size : start + chunkSize;
  387. fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  388. }
  389. fileReader.onload = async (e) => {
  390. try {
  391. await uploadChunk(e);
  392. fileReader.abort();
  393. currentChunk++;
  394. if (currentChunk < chunks) {
  395. console.log(`第${currentChunk}个分片上传完成, 开始第${currentChunk + 1}/${chunks}个分片上传`);
  396. this.updateFileStatus(file, this.$t('modelManage.uploading'), Number(((currentChunk / chunks) * 100).toFixed(2)), 3);
  397. loadNext();
  398. } else {
  399. try {
  400. await completeUpload();
  401. console.log(`文件上传完成:${file.name} \n分片:${chunks} 大小:${file.size} 用时:${(new Date().getTime() - time) / 1000} s`);
  402. this.uploadLength++;
  403. this.uploadSuccessLength++;
  404. this.updateFileStatus(file, this.$t('modelManage.uploadSuccess'), 100, 0);
  405. this.uploadSuccess(file);
  406. } catch (err) {
  407. const info = this.$t('modelManage.uploadFailed');
  408. console.log(info, file)
  409. this.uploadLength++;
  410. this.uploadError(file, info);
  411. this.updateFileStatus(file, info, Number(((currentChunk / chunks) * 100).toFixed(2)) - 1, 2);
  412. }
  413. }
  414. } catch (err) {
  415. console.log(err);
  416. const info = this.$t('modelManage.uploadFailed');
  417. console.log(info, file)
  418. this.uploadLength++;
  419. this.uploadError(file, info);
  420. this.updateFileStatus(file, info, Number(((currentChunk / chunks) * 100).toFixed(2)) - 1, 2);
  421. }
  422. };
  423. console.log("上传分片...");
  424. loadNext();
  425. },
  426. uploadError(file, info) {
  427. file.previewTemplate.querySelector('.dz-success-mark').style.opacity = 0;
  428. file.previewTemplate.querySelector('.dz-error-mark').style.opacity = 1;
  429. file.previewTemplate.querySelector('.dz-error-message span').innerHTML = info;
  430. file.previewTemplate.querySelector(".dz-error-message").style.display = 'block';
  431. file.previewTemplate.querySelector(".dz-details").onmouseover = () => {
  432. file.previewTemplate.querySelector('.dz-error-message').style.opacity = 1;
  433. };
  434. file.previewTemplate.querySelector(".dz-details").onmouseout = () => {
  435. file.previewTemplate.querySelector('.dz-error-message').style.opacity = 0;
  436. };
  437. this.uploadFinishCheck(file);
  438. },
  439. uploadSuccess(file) {
  440. file.previewTemplate.querySelector('.dz-error-mark').style.opacity = 0;
  441. file.previewTemplate.querySelector('.dz-error-message span').innerHTML = '';
  442. file.previewTemplate.querySelector('.dz-success-mark').style.opacity = 1;
  443. file.previewTemplate.querySelector(".dz-error-message").style.display = 'none';
  444. file.previewTemplate.querySelector(".dz-details").onmouseover = null;
  445. file.previewTemplate.querySelector(".dz-details").onmouseout = null;
  446. this.uploadFinishCheck(file);
  447. },
  448. uploadFinishCheck(file) {
  449. console.log('uploadFinishCheck', file, this.uploadLength, '/', this.uploadFiles.length);
  450. if (this.uploadLength === this.uploadFiles.length) {
  451. console.log('All file has finish, success ' + this.uploadSuccessLength);
  452. this.uploading = false;
  453. if (this.uploadSuccessLength == this.uploadLength) {
  454. window.setTimeout(() => {
  455. this.goDetail();
  456. }, 1000);
  457. } else {
  458. if (this.uploadSuccessLength > 0) {
  459. this.initModelData();
  460. }
  461. }
  462. }
  463. },
  464. submit() {
  465. const fileList = this.dropzoneHandler.getAcceptedFiles();
  466. if (!fileList.length) return;
  467. if (!this.checkFiles()) return;
  468. this.resetFileStatus();
  469. this.uploadFiles = fileList;
  470. this.uploading = true;
  471. for (let i = 0, iLen = fileList.length; i < iLen; i++) {
  472. const file = fileList[i];
  473. file.modelUuid = this.state.id;
  474. file.modelName = this.state.name;
  475. this.calcFileMd5(file).then(res => { // 计算MD5
  476. this.getChunksInfo(file).then(res => { // 获取Chunk信息
  477. if (file.uploadID == '' || file.uuid == '') { // 未上传过
  478. this.newUpload(file);
  479. } else if (file.uploaded == '1') { // 已上传成功
  480. if (file.attachID == '0') { // 删除数据集记录,未删除文件
  481. // await addAttachment(file);
  482. console.log(`file.attachID == '0'`);
  483. }
  484. this.uploadLength++;
  485. // 同一模型上传同一个文件
  486. if (file._modelUuid) {
  487. const info = `${this.$t('modelManage.fileHasAlreadyInTheModel')} ${file._modelName}`;
  488. this.uploadError(file, info);
  489. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 0, 1, info);
  490. } else { // 秒传
  491. this.uploadSuccessLength++;
  492. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 100, 0);
  493. this.uploadSuccess(file);
  494. }
  495. console.log(file.name, '文件处理完成');
  496. } else { // 断点续传
  497. this.breakpointUpload(file);
  498. }
  499. }).catch(err => {
  500. console.info('getChunksInfo', err);
  501. this.uploadLength++;
  502. this.uploadError(file, this.$t('modelManage.uploadFailed'));
  503. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 0, 2);
  504. });
  505. }).catch(err => {
  506. console.info('calcFileMd5', err);
  507. this.uploadLength++;
  508. this.uploadError(file, this.$t('modelManage.uploadFailed'));
  509. this.updateFileStatus(file, this.$t('modelManage.uploadFailed'), 0, 2);
  510. });
  511. }
  512. },
  513. cancel() {
  514. if (this.type == '1') {
  515. this.goDetail();
  516. return;
  517. }
  518. const list = window.location.href.split('/');
  519. list.pop();
  520. list.push('show_model');
  521. window.location.href = list.join('/');
  522. },
  523. goDetail() {
  524. const list = window.location.href.split('/');
  525. list.pop();
  526. list.push('show_model_info');
  527. window.location.href = list.join('/') + '?name=' + this.state.name;
  528. }
  529. },
  530. mounted() {
  531. this.initModelData();
  532. this.initDropZone();
  533. },
  534. beforeDestroy() {
  535. },
  536. };
  537. </script>
  538. <style scoped lang="less">
  539. .header {
  540. height: 45px;
  541. border-color: rgb(212, 212, 213);
  542. border-width: 1px;
  543. border-style: solid;
  544. border-radius: 5px 5px 0px 0px;
  545. font-size: 14px;
  546. background: rgb(240, 240, 240);
  547. display: flex;
  548. align-items: center;
  549. .title {
  550. font-weight: 600;
  551. font-size: 16px;
  552. color: rgb(16, 16, 16);
  553. margin-left: 10px;
  554. }
  555. }
  556. .content {
  557. margin-top: -1px;
  558. border-color: rgb(212, 212, 213);
  559. border-width: 1px;
  560. border-style: solid;
  561. padding: 30px 0;
  562. border-top: none;
  563. .guide-c {
  564. display: flex;
  565. align-items: center;
  566. justify-content: center;
  567. margin-bottom: 20px;
  568. .step {
  569. display: flex;
  570. align-items: center;
  571. color: rgb(136, 136, 136);
  572. .num {
  573. border: 1px solid rgb(136, 136, 136);
  574. width: 34px;
  575. height: 34px;
  576. font-size: 24px;
  577. text-align: center;
  578. line-height: 34px;
  579. border-radius: 17px;
  580. margin-right: 8px;
  581. }
  582. .txt {
  583. font-weight: 600;
  584. }
  585. &.focused {
  586. color: rgb(22, 132, 252);
  587. .num {
  588. border-color: rgb(22, 132, 252);
  589. }
  590. }
  591. }
  592. .line {
  593. height: 2px;
  594. width: 50px;
  595. background-color: rgb(187, 187, 187);
  596. margin: 0 10px;
  597. }
  598. }
  599. .row-c {
  600. display: flex;
  601. align-items: center;
  602. justify-content: center;
  603. flex-direction: column;
  604. margin: 0 auto;
  605. .row {
  606. width: 100%;
  607. display: flex;
  608. align-items: center;
  609. margin: 8px 0;
  610. margin-left: -190px;
  611. .r-title {
  612. text-align: right;
  613. font-size: .92857143em;
  614. font-weight: 700;
  615. color: rgba(0, 0, 0, .87);
  616. width: 200px;
  617. margin-right: 28px;
  618. position: relative;
  619. .required {
  620. &::after {
  621. position: absolute;
  622. margin: -0.2em 0 0 0.2em;
  623. content: '*';
  624. color: #db2828;
  625. }
  626. }
  627. }
  628. .r-content {
  629. flex: 1;
  630. .cluster-type-btn {
  631. display: flex;
  632. align-items: center;
  633. justify-content: center;
  634. border: 1px solid #DCDFE6;
  635. height: 36px;
  636. padding: 10px;
  637. cursor: pointer;
  638. border-radius: 4px;
  639. .icon {
  640. margin-right: 5px;
  641. }
  642. &.focused {
  643. border-color: rgb(50, 145, 248);
  644. color: rgb(50, 145, 248);
  645. cursor: default;
  646. .icon {
  647. :not([stroke]) {
  648. fill: rgb(50, 145, 248);
  649. }
  650. }
  651. }
  652. }
  653. }
  654. }
  655. }
  656. }
  657. .not-allowed-placeholder {
  658. position: absolute;
  659. width: 100%;
  660. height: 100%;
  661. z-index: 20;
  662. cursor: no-drop;
  663. top: 0;
  664. }
  665. .dropzone {
  666. min-height: 186px !important;
  667. /deep/ .dz-default.dz-message {
  668. margin: 76px 0 !important;
  669. }
  670. /deep/ .dz-remove {
  671. margin-top: 10px !important;
  672. }
  673. }
  674. .input-disabled {
  675. /deep/ .el-input__inner {
  676. background-color: #f5f5f6 !important;
  677. color: #888888 !important;
  678. }
  679. }
  680. /deep/ .dz-progress {
  681. display: none;
  682. }
  683. .success {
  684. color: #21ba45;
  685. font-size: 16px;
  686. margin-right: 0.5rem;
  687. }
  688. .failed {
  689. color: red;
  690. font-size: 16px;
  691. margin-right: 0.5rem;
  692. }
  693. .datast-upload-progress {
  694. display: flex;
  695. align-items: center;
  696. }
  697. .datast-upload-progress .dataset-name {
  698. text-align: right;
  699. width: 200px;
  700. margin-right: 1rem;
  701. }
  702. .datast-upload-progress .dataset-progress {
  703. flex: 1;
  704. }
  705. .datast-upload-progress .dataset-status {
  706. width: 100px;
  707. margin-left: 1rem;
  708. }
  709. .datast-upload-progress .dataset-status .status-flex {
  710. display: flex;
  711. align-items: center;
  712. }
  713. /deep/ .el-progress-bar__inner {
  714. background-color: #21ba45;
  715. }
  716. .el-select-dropdown__item.selected {
  717. color: #85b7d9;
  718. }
  719. /deep/ .el-button {
  720. background-color: #e0e1e2;
  721. color: rgba(0, 0, 0, .6);
  722. border-color: transparent;
  723. transition: opacity .1s ease, background-color .1s ease, color .1s ease, box-shadow .1s ease, background .1s ease, -webkit-box-shadow .1s ease;
  724. will-change: auto;
  725. -webkit-tap-highlight-color: transparent;
  726. &:hover {
  727. border-color: transparent;
  728. background-color: #cacbcd;
  729. color: rgba(0, 0, 0, .8);
  730. }
  731. &:focus {
  732. background-color: #cacbcd;
  733. color: rgba(0, 0, 0, .8);
  734. border-color: transparent;
  735. }
  736. &:active {
  737. background-color: #babbbc;
  738. color: rgba(0, 0, 0, .9);
  739. border-color: transparent;
  740. }
  741. &.green {
  742. background-color: #5bb973;
  743. color: #fff;
  744. &:hover {
  745. background-color: #16ab39;
  746. border-color: transparent;
  747. }
  748. &:focus {
  749. background-color: #0ea432;
  750. border-color: transparent;
  751. }
  752. &:active {
  753. background-color: #198f35;
  754. border-color: transparent;
  755. }
  756. }
  757. }
  758. /deep/ .el-select {
  759. .is-focus {
  760. .el-input__inner {
  761. border-color: #85b7d9;
  762. }
  763. }
  764. }
  765. /deep/ .el-input__inner {
  766. &:focus {
  767. border-color: #85b7d9;
  768. }
  769. }
  770. /deep/ .el-textarea__inner {
  771. &:focus {
  772. border-color: #85b7d9;
  773. }
  774. }
  775. </style>