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