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.

Model.vue 24 kB

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
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
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
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 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
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 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
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 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
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <div>
  3. <div class="ui container" id="header">
  4. <el-row style="margin-top: 15px">
  5. <el-table
  6. ref="table"
  7. :data="tableData"
  8. style="min-width: 100%"
  9. row-key="rowKey"
  10. lazy
  11. :load="load"
  12. :tree-props="{ children: 'Children', hasChildren: 'hasChildren' }"
  13. :header-cell-style="tableHeaderStyle"
  14. >
  15. <el-table-column
  16. prop="name"
  17. :label="i18n.model_name"
  18. align="left"
  19. min-width="20%"
  20. >
  21. <template slot-scope="scope">
  22. <div class="expand-icon" v-if="scope.row.hasChildren === false">
  23. <i class="el-icon-arrow-right"></i>
  24. </div>
  25. <!-- <i class="el-icon-time"></i> -->
  26. <span v-if="!scope.row.Children" :class="scope.row.modelType == '1' ? 'm-local' : 'm-online'">{{ scope.row.modelType == '1' ? i18n.local : i18n.online }}</span>
  27. <a
  28. class="text-over"
  29. :href="showinfoHref + encodeURIComponent(scope.row.name)"
  30. :title="scope.row.name"
  31. >{{ scope.row.name }}</a
  32. >
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. prop="version"
  37. :label="i18n.model_version"
  38. align="center"
  39. min-width="6%"
  40. >
  41. <template slot-scope="scope">
  42. <span class="text-over" :title="scope.row.version">{{
  43. scope.row.version
  44. }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. prop="versionCount"
  49. :label="i18n.model_version_num"
  50. align="center"
  51. min-width="7%"
  52. >
  53. <template slot-scope="scope">
  54. <span class="text-over" :title="scope.row.versionCount">{{
  55. scope.row.versionCount
  56. }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="size"
  61. :label="i18n.model_size"
  62. align="center"
  63. min-width="10%"
  64. >
  65. <template slot-scope="scope">
  66. <span class="text-over">{{ renderSize(scope.row.size) }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. prop="engineName"
  71. :label="i18n.model_egine"
  72. align="center"
  73. min-width="8%"
  74. >
  75. <template slot-scope="scope">
  76. <span class="text-over" :title="scope.row.engineName">{{
  77. scope.row.engineName
  78. }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="computeResource"
  83. :label="i18n.model_compute_resource"
  84. align="center"
  85. min-width="8%"
  86. >
  87. <template slot-scope="scope">
  88. <span class="text-over">{{ scope.row.computeResource }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. prop="isPrivate"
  93. :label="i18n.model_status"
  94. align="center"
  95. min-width="6.75%"
  96. >
  97. <template slot-scope="scope">
  98. <span class="text-over" :title="scope.row.status_title">
  99. <i style="vertical-align: middle" :class="scope.row.status"></i
  100. ></span>
  101. <span class="text-over" :title="scope.row.isPrivate">
  102. {{transStatus(scope.row.isPrivate)}}
  103. </span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. prop="createdUnix"
  108. :label="i18n.model_create_time"
  109. align="center"
  110. min-width="13.75%"
  111. >
  112. <template slot-scope="scope">
  113. {{ transTime(scope.row.createdUnix) }}
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. prop="userName"
  118. :label="i18n.model_creator"
  119. align="center"
  120. min-width="6.75%"
  121. >
  122. <template slot-scope="scope">
  123. <a
  124. :href="!scope.row.userName ? '#' : '/' + scope.row.userName"
  125. :title="scope.row.userName || defaultAvatarName"
  126. >
  127. <img
  128. class="ui avatar image"
  129. :src="scope.row.userRelAvatarLink || defaultAvatar"
  130. />
  131. </a>
  132. </template>
  133. </el-table-column>
  134. <el-table-column
  135. :label="i18n.model_operation"
  136. min-width="15%"
  137. align="center"
  138. >
  139. <template slot-scope="scope">
  140. <div class="space-around" >
  141. <a class="op-btn"
  142. v-show="scope.row.modelType == 1"
  143. :href="url + 'create_local_model_1?type=1&name=' + encodeURIComponent(scope.row.name) + '&id=' + scope.row.id"
  144. :class="{ disabled: !scope.row.isCanOper }"
  145. >{{ i18n.modify }}</a>
  146. <a class="op-btn" v-show="scope.row.modelType != 1" style="color:transparent;cursor:default;" >{{ i18n.modify }}</a>
  147. <a class="op-btn" v-show="repoIsPrivate == false && scope.row.isPrivate==true && scope.row.isCanOper" @click="
  148. modifyModelStatus(scope.row.id, scope.row.cName, scope.row.rowKey,false)
  149. ">{{ i18n.modelaccess_setpublic }}</a>
  150. <a class="op-btn" v-show="repoIsPrivate == false && scope.row.isPrivate==false && scope.row.isCanOper" @click="
  151. modifyModelStatus(scope.row.id, scope.row.cName, scope.row.rowKey,true)
  152. ">{{ i18n.modelaccess_setprivate }}</a>
  153. <a class="op-btn"
  154. :href="loadhref + scope.row.id"
  155. :class="{ disabled: !scope.row.isCanDownload }"
  156. >{{ i18n.model_download }}</a>
  157. <a class="op-btn"
  158. :class="{ disabled: !scope.row.isCanDelete }"
  159. @click="
  160. deleteModel(scope.row.id, scope.row.cName, scope.row.rowKey)
  161. "
  162. >{{ i18n.model_delete }}</a>
  163. </div>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. </el-row>
  168. <div class="ui container" style="margin-top: 50px; text-align: center">
  169. <el-pagination
  170. background
  171. @size-change="handleSizeChange"
  172. @current-change="handleCurrentChange"
  173. :current-page="currentPage"
  174. :page-sizes="[5, 10, 15]"
  175. :page-size="pageSize"
  176. layout="total, sizes, prev, pager, next, jumper"
  177. :total="totalNum"
  178. >
  179. </el-pagination>
  180. </div>
  181. </div>
  182. </div>
  183. </template>
  184. <script>
  185. import { modifyModelStatus } from '~/apis/modules/modelmanage';
  186. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  187. const REPOISPRIVATE = window.REPO_IS_PRIVATE;
  188. export default {
  189. components: {},
  190. data() {
  191. return {
  192. i18n: {},
  193. currentPage: 1,
  194. pageSize: 10,
  195. totalNum: 0,
  196. params: { page: 0, pageSize: 10 },
  197. tableData: [],
  198. url: "",
  199. isLoading: true,
  200. loadNodeMap: new Map(),
  201. submitId: {},
  202. repo: location.pathname.split('/').slice(0, 3).join('/'),
  203. defaultAvatar: "/user/avatar/Ghost/-1",
  204. defaultAvatarName: "Ghost",
  205. data: "",
  206. timer: null,
  207. timerFlag: false,
  208. repoIsPrivate: REPOISPRIVATE,
  209. };
  210. },
  211. methods: {
  212. load(tree, treeNode, resolve) {
  213. try {
  214. this.loadNodeMap.set(tree.cName, { tree, treeNode, resolve });
  215. this.$axios
  216. .get(this.url + "show_model_child_api", {
  217. params: {
  218. name: tree.cName,
  219. },
  220. })
  221. .then((res) => {
  222. let trainTaskInfo;
  223. let tableData;
  224. tableData = res.data;
  225. for (let i = 0; i < tableData.length; i++) {
  226. trainTaskInfo = JSON.parse(tableData[i].trainTaskInfo || '{}');
  227. tableData[i].engineName = this.getEngineName(tableData[i]);
  228. // tableData[i].computeResource = trainTaskInfo.ComputeResource;
  229. tableData[i].computeResource = tableData[i].type == '0' ? 'CPU/GPU' : 'NPU';
  230. tableData[i].cName = tableData[i].name;
  231. tableData[i].rowKey = tableData[i].id + Math.random();
  232. tableData[i].name = "";
  233. tableData[i].versionCount = "";
  234. tableData[i].Children = true;
  235. }
  236. resolve(tableData || []);
  237. });
  238. } catch (e) {
  239. this.loading = false;
  240. }
  241. },
  242. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  243. if (rowIndex === 0) {
  244. return "background:#f5f5f6;color:#606266";
  245. }
  246. },
  247. handleSizeChange(val) {
  248. this.params.pageSize = val;
  249. this.getModelList();
  250. },
  251. handleCurrentChange(val) {
  252. this.params.page = val;
  253. this.getModelList();
  254. },
  255. showcreateVue(name, version, label) {
  256. let title = this.i18n.model_create_version_title;
  257. $(".ui.modal.second")
  258. .modal({
  259. centered: false,
  260. onShow: function () {
  261. $("#model_header").text(title);
  262. $('input[name="name"]').addClass("model_disabled");
  263. $('input[name="name"]').attr("readonly", "readonly");
  264. $('input[name="modelSelectedFile"]').attr("readonly", "readonly");
  265. $('input[name="version"]').addClass("model_disabled");
  266. $(".ui.dimmer").css({
  267. "background-color": "rgb(136, 136, 136,0.7)",
  268. });
  269. $("#job-name").empty();
  270. $("#name").val(name);
  271. $("#label").val(label);
  272. let version_string = versionAdd(version);
  273. $("#version").val(version_string);
  274. loadTrainList();
  275. },
  276. onHide: function () {
  277. document.getElementById("formId").reset();
  278. $('input[name="name"]').removeClass("model_disabled");
  279. $('input[name="name"]').removeAttr("readonly");
  280. $('input[name="modelSelectedFile"]').removeAttr("readonly");
  281. var cityObj = $("#modelSelectedFile");
  282. cityObj.attr("value", "");
  283. $("#choice_model").dropdown("clear");
  284. $("#choice_version").dropdown("clear");
  285. $("#choice_Engine").dropdown("clear");
  286. $(".ui.dimmer").css({ "background-color": "" });
  287. $(".ui.error.message").text();
  288. $(".ui.error.message").css("display", "none");
  289. },
  290. })
  291. .modal("show");
  292. },
  293. check() {
  294. let jobid = document.getElementById("jobId").value;
  295. let versionname = document.getElementById("versionName").value;
  296. let name = document.getElementById("name").value;
  297. let version = document.getElementById("version").value;
  298. let modelSelectedFile =
  299. document.getElementById("modelSelectedFile").value;
  300. if (jobid == "") {
  301. $(".required.ten.wide.field").addClass("error");
  302. return false;
  303. } else {
  304. $(".required.ten.wide.field").removeClass("error");
  305. }
  306. if (modelSelectedFile == "") {
  307. $("#modelSelectedFile").addClass("error");
  308. return false;
  309. } else {
  310. $("#modelSelectedFile").removeClass("error");
  311. }
  312. if (versionname == "") {
  313. $(".required.six.widde.field").addClass("error");
  314. return false;
  315. } else {
  316. $(".required.six.widde.field").removeClass("error");
  317. }
  318. if (name == "") {
  319. $("#modelname").addClass("error");
  320. return false;
  321. } else {
  322. $("#modelname").removeClass("error");
  323. }
  324. if (versionname == "") {
  325. $("#verionname").addClass("error");
  326. return false;
  327. } else {
  328. $("#verionname").removeClass("error");
  329. }
  330. return true;
  331. },
  332. submit() {
  333. let context = this;
  334. let flag = this.check();
  335. if (flag) {
  336. let cName = $("input[name='name']").val();
  337. let version = $("input[name='version']").val();
  338. let data = $("#formId").serialize();
  339. const initModel = $("input[name='initModel']").val();
  340. let url_href =
  341. version === "0.0.1"
  342. ? context.url_create_newModel
  343. : context.url_create_newVersion;
  344. $("#mask").css({ display: "block", "z-index": "9999" });
  345. $.ajax({
  346. url: url_href,
  347. type: "POST",
  348. data: data,
  349. success: function (res) {
  350. context.getModelList();
  351. $("input[name='modelSelectedFile']").val("");
  352. $(".ui.modal.second").modal("hide");
  353. if (initModel === "0") {
  354. location.reload();
  355. }
  356. },
  357. error: function (xhr) {
  358. // 隐藏 loading
  359. // 只有请求不正常(状态码不为200)才会执行
  360. $(".ui.error.message").text(xhr.responseText);
  361. $(".ui.error.message").css("display", "block");
  362. },
  363. complete: function (xhr) {
  364. $("#mask").css({ display: "none", "z-index": "1" });
  365. },
  366. });
  367. } else {
  368. return false;
  369. }
  370. },
  371. loadrefresh(row) {
  372. const store = this.$refs.table.store;
  373. if (!this.loadNodeMap.get(row.cName)) {
  374. const parent = store.states.data;
  375. const index = parent.findIndex((child) => child.rowKey == row.rowKey);
  376. this.getModelList();
  377. } else {
  378. let { tree, treeNode, resolve } = this.loadNodeMap.get(row.cName);
  379. const keys = Object.keys(store.states.lazyTreeNodeMap);
  380. if (keys.includes(row.rowKey)) {
  381. this.getModelList();
  382. } else {
  383. let parentRow = store.states.data.find(
  384. (child) => child.cName == row.cName
  385. );
  386. let childrenIndex = store.states.lazyTreeNodeMap[
  387. parentRow.rowKey
  388. ].findIndex((child) => child.rowKey == row.rowKey);
  389. parentRow.versionCount = parentRow.versionCount - 1;
  390. const parent = store.states.lazyTreeNodeMap[parentRow.rowKey];
  391. if (parent.length === 1) {
  392. this.getModelList();
  393. } else {
  394. parent.splice(childrenIndex, 1);
  395. }
  396. }
  397. }
  398. },
  399. modifyModelStatus(id, name, rowKey,isPrivate) {
  400. let data = {'id':id,'isPrivate':isPrivate,'repo':this.repo};
  401. modifyModelStatus(data).then(res => {
  402. res = res.data;
  403. if (res && res.code == '0') {
  404. this.getModelList();
  405. } else {
  406. this.$message({
  407. type: 'error',
  408. message: this.$t('modelManage.infoModificationFailed'),
  409. });
  410. }
  411. }).catch(err => {
  412. console.log(err);
  413. this.$message({
  414. type: 'error',
  415. message: this.$t('modelManage.infoModificationFailed'),
  416. });
  417. });
  418. },
  419. },
  420. deleteModel(id, name, rowKey) {
  421. let row = { cName: name, id: id, rowKey: rowKey };
  422. let _this = this;
  423. let flag = 1;
  424. $(".ui.basic.modal.first")
  425. .modal({
  426. onDeny: function () {
  427. flag = false;
  428. },
  429. onApprove: function () {
  430. _this.$axios
  431. .delete(_this.url + "delete_model", {
  432. params: {
  433. id: id,
  434. },
  435. })
  436. .then((res) => {
  437. _this.loadrefresh(row);
  438. // _this.getModelList()
  439. });
  440. flag = true;
  441. },
  442. onHidden: function () {
  443. if (flag == false) {
  444. $(".alert")
  445. .html("您已取消操作")
  446. .removeClass("alert-success")
  447. .addClass("alert-danger")
  448. .show()
  449. .delay(1500)
  450. .fadeOut();
  451. } else {
  452. $(".alert")
  453. .html("删除成功")
  454. .removeClass("alert-danger")
  455. .addClass("alert-success")
  456. .show()
  457. .delay(1500)
  458. .fadeOut();
  459. }
  460. },
  461. })
  462. .modal("show");
  463. },
  464. getEngineName(model) {
  465. if (model.engine == 0) {
  466. return "PyTorch";
  467. } else if (model.engine == 1 || model.engine == 121) {
  468. return "TensorFlow";
  469. } else if (
  470. model.engine == 2 ||
  471. model.engine == 122 ||
  472. model.engine == 35
  473. ) {
  474. return "MindSpore";
  475. } else if (model.engine == 4) {
  476. return "PaddlePaddle";
  477. } else if (model.engine == 5) {
  478. return "OneFlow";
  479. } else if (model.engine == 6) {
  480. return "MXNet";
  481. } else {
  482. return "Other";
  483. }
  484. },
  485. intervalModelist() {
  486. if (!this.timerFlag) {
  487. this.timer = setInterval(() => {
  488. this.getModelList();
  489. }, 10000);
  490. }
  491. },
  492. getModelList() {
  493. let countStatus = 0;
  494. try {
  495. this.loadNodeMap.clear();
  496. this.$axios
  497. .get(this.url + "show_model_api", {
  498. params: this.params,
  499. })
  500. .then((res) => {
  501. $(".ui.grid").removeAttr("style");
  502. $("#loadContainer").removeClass("loader");
  503. let trainTaskInfo;
  504. this.tableData = res.data.data;
  505. for (let i = 0; i < this.tableData.length; i++) {
  506. trainTaskInfo = JSON.parse(this.tableData[i].trainTaskInfo || '{}');
  507. this.tableData[i].cName = this.tableData[i].name;
  508. this.tableData[i].rowKey = this.tableData[i].id + Math.random();
  509. this.tableData[i].engineName = this.getEngineName(
  510. this.tableData[i]
  511. );
  512. // this.tableData[i].computeResource = trainTaskInfo.ComputeResource;
  513. this.tableData[i].computeResource = this.tableData[i].type == '0' ? 'CPU/GPU' : 'NPU';
  514. this.tableData[i].hasChildren = res.data.data[i].versionCount === 1 ? false : true;
  515. if (this.tableData[i].status !== 1) {
  516. countStatus++;
  517. }
  518. switch (this.tableData[i].status) {
  519. case 1:
  520. this.tableData[i].status = "WAITING";
  521. this.tableData[i].status_title = this.i18n.model_wait;
  522. break;
  523. case 2:
  524. this.tableData[i].status = "FAILED";
  525. this.tableData[i].status_title = this.tableData[i].statusDesc;
  526. break;
  527. default:
  528. this.tableData[i].status = "SUCCEEDED";
  529. this.tableData[i].status_title = this.i18n.model_success;
  530. break;
  531. }
  532. }
  533. this.totalNum = res.data.count;
  534. if (countStatus === this.tableData.length) {
  535. clearInterval(this.timer);
  536. this.timer = null;
  537. this.timerFlag = false;
  538. } else {
  539. this.intervalModelist();
  540. this.timerFlag = true;
  541. }
  542. })
  543. .catch((err) => {
  544. console.log(err);
  545. });
  546. } catch (e) {
  547. console.log(e);
  548. }
  549. },
  550. },
  551. computed: {
  552. loadhref() {
  553. return this.url + "downloadall?id=";
  554. },
  555. showinfoHref() {
  556. return this.url + "show_model_info?name=";
  557. },
  558. transStatus(){
  559. return function (state) {
  560. if(state){
  561. return this.i18n.modelaccess_private;
  562. }
  563. return this.i18n.modelaccess_public;
  564. }
  565. },
  566. transTime() {
  567. return function (time) {
  568. let date = new Date(time * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  569. let Y = date.getFullYear() + "-";
  570. let M =
  571. (date.getMonth() + 1 < 10
  572. ? "0" + (date.getMonth() + 1)
  573. : date.getMonth() + 1) + "-";
  574. let D =
  575. (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  576. let h =
  577. (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) +
  578. ":";
  579. let m =
  580. (date.getMinutes() < 10
  581. ? "0" + date.getMinutes()
  582. : date.getMinutes()) + ":";
  583. let s =
  584. date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  585. return Y + M + D + h + m + s;
  586. };
  587. },
  588. renderSize() {
  589. return function (value) {
  590. if (null == value || value == "") {
  591. return "0 Bytes";
  592. }
  593. var unitArr = new Array(
  594. "Bytes",
  595. "KB",
  596. "MB",
  597. "GB",
  598. "TB",
  599. "PB",
  600. "EB",
  601. "ZB",
  602. "YB"
  603. );
  604. var index = 0;
  605. var srcsize = parseFloat(value);
  606. index = Math.floor(Math.log(srcsize) / Math.log(1024));
  607. var size = srcsize / Math.pow(1024, index);
  608. size = size.toFixed(2); //保留的小数位数
  609. return size + unitArr[index];
  610. };
  611. },
  612. },
  613. mounted() {
  614. this.submitId = document.getElementById("submitId");
  615. this.intervalModelist();
  616. this.url = location.href.split("show_model")[0];
  617. this.submitId.addEventListener("click", this.submit);
  618. this.url_create_newVersion = this.url + "create_model";
  619. this.url_create_newModel = this.url + "create_new_model";
  620. },
  621. created() {
  622. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  623. this.i18n = this.$locale.US;
  624. } else {
  625. this.i18n = this.$locale.CN;
  626. }
  627. this.getModelList();
  628. },
  629. beforeDestroy() {
  630. // 实例销毁之前对点击事件进行解绑
  631. this.submitId.removeEventListener("click", this.submit);
  632. clearInterval(this.timer);
  633. },
  634. };
  635. </script>
  636. <style scoped>
  637. .text-over {
  638. overflow: hidden;
  639. text-overflow: ellipsis;
  640. vertical-align: middle;
  641. white-space: nowrap;
  642. }
  643. .m-local {
  644. background-color: rgb(22, 132, 252);
  645. color: white;
  646. padding: 2px 3px;
  647. border-radius: 4px;
  648. font-size: 12px;
  649. margin-right: 2px;
  650. }
  651. .m-online {
  652. background-color: rgb(91, 185, 115);
  653. color: white;
  654. padding: 2px 3px;
  655. border-radius: 4px;
  656. font-size: 12px;
  657. margin-right: 2px;
  658. }
  659. .el-icon-arrow-right {
  660. font-family: element-icons !important;
  661. speak: none;
  662. font-style: normal;
  663. font-weight: 400;
  664. font-feature-settings: normal;
  665. font-variant: normal;
  666. text-transform: none;
  667. line-height: 1;
  668. vertical-align: middle;
  669. display: inline-block;
  670. -webkit-font-smoothing: antialiased;
  671. -moz-osx-font-smoothing: grayscale;
  672. border: 1px solid #d4d4d5;
  673. border-radius: 50%;
  674. color: #d4d4d5;
  675. margin-right: 4px;
  676. }
  677. .el-icon-arrow-right::before {
  678. content: "\e6e0";
  679. }
  680. .expand-icon {
  681. display: inline-block;
  682. width: 20px;
  683. line-height: 20px;
  684. height: 20px;
  685. text-align: center;
  686. margin-right: 3px;
  687. font-size: 12px;
  688. }
  689. /deep/ .el-table_1_column_1.is-left .cell {
  690. padding-right: 0px !important;
  691. white-space: nowrap;
  692. }
  693. /deep/ .el-table__expand-icon .el-icon-arrow-right {
  694. font-family: element-icons !important;
  695. speak: none;
  696. font-style: normal;
  697. font-weight: 400;
  698. font-feature-settings: normal;
  699. font-variant: normal;
  700. text-transform: none;
  701. line-height: 1;
  702. vertical-align: middle;
  703. display: inline-block;
  704. -webkit-font-smoothing: antialiased;
  705. -moz-osx-font-smoothing: grayscale;
  706. border: 1px solid #3291f8;
  707. border-radius: 50%;
  708. color: #3291f8;
  709. margin-right: 4px;
  710. }
  711. .space-around {
  712. display: flex;
  713. justify-content: space-around;
  714. }
  715. .op-btn-c {
  716. text-align: right;
  717. padding-right: 20px;
  718. }
  719. .op-btn {
  720. margin: 0 0 0 5px;
  721. }
  722. .disabled {
  723. cursor: default;
  724. pointer-events: none;
  725. color: rgba(0, 0, 0, 0.6) !important;
  726. opacity: 0.45 !important;
  727. }
  728. </style>