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

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