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 14 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div>
  3. <div class="ui container" id="header">
  4. <el-row style="margin-top:15px;">
  5. <el-table
  6. :data="tableData"
  7. style="min-width: 100%"
  8. row-key="ID"
  9. lazy
  10. :load="load"
  11. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  12. :header-cell-style="tableHeaderStyle"
  13. >
  14. <el-table-column
  15. prop="Name"
  16. label="模型名称"
  17. align="left"
  18. min-width="18%"
  19. >
  20. <template slot-scope="scope">
  21. <div class="expand-icon" v-if="scope.row.hasChildren===false">
  22. <i class="el-icon-arrow-right"></i>
  23. </div>
  24. <!-- <i class="el-icon-time"></i> -->
  25. <a class="text-over" :title="scope.row.Name">{{ scope.row.Name }}</a>
  26. </template>
  27. </el-table-column>
  28. <el-table-column
  29. prop="Version"
  30. label="版本"
  31. align="center"
  32. min-width="6.5%"
  33. >
  34. <template slot-scope="scope">
  35. <span class="text-over" :title="scope.row.Version">{{ scope.row.Version}}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column
  39. prop="VersionCount"
  40. label="版本数"
  41. align="center"
  42. min-width="7.5%"
  43. >
  44. <template slot-scope="scope">
  45. <span class="text-over" :title="scope.row.VersionCount">{{ scope.row.VersionCount}}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column
  49. prop="Size"
  50. label="模型大小"
  51. align="center"
  52. min-width="10.5%"
  53. >
  54. <template slot-scope="scope">
  55. <span class="text-over">{{ renderSize(scope.row.Size)}}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. prop="EngineName"
  60. label="AI引擎"
  61. align="center"
  62. min-width="8.5%"
  63. >
  64. <template slot-scope="scope">
  65. <span class="text-over">{{ scope.row.EngineName}}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column
  69. prop="ComputeResource"
  70. label="计算资源"
  71. align="center"
  72. min-width="10.5%"
  73. >
  74. <template slot-scope="scope">
  75. <span class="text-over">{{ scope.row.ComputeResource}}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="CreatedUnix"
  80. label="创建时间"
  81. align="center"
  82. min-width="13.75%"
  83. >
  84. <template slot-scope="scope">
  85. {{transTime(scope.row.CreatedUnix)}}
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. prop="UserName"
  90. label="创建者"
  91. align="center"
  92. min-width="6.75%"
  93. >
  94. <template slot-scope="scope">
  95. <a :href="'/'+scope.row.UserName" :title="scope.row.UserName">
  96. <img class="ui avatar image" :src="scope.row.UserRelAvatarLink">
  97. </a>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" min-width="18%" align="center">
  101. <template slot-scope="scope">
  102. <div class="space-around">
  103. <a @click="showcreateVue(scope.row.Name,scope.row.Version)">创建新版本</a>
  104. <a :href="loadhref+scope.row.ID">下载</a>
  105. <a @click="deleteModel(scope.row.ID)">删除</a>
  106. </div>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </el-row>
  111. <div class="ui container" style="margin-top:50px;text-align:center">
  112. <el-pagination
  113. background
  114. @size-change="handleSizeChange"
  115. @current-change="handleCurrentChange"
  116. :current-page="currentPage"
  117. :page-size="pageSize"
  118. layout="total, sizes, prev, pager, next, jumper"
  119. :total="totalNum">
  120. </el-pagination>
  121. </div>
  122. </div>
  123. </div>
  124. </template>
  125. <script>
  126. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  127. export default {
  128. components: {
  129. },
  130. data() {
  131. return {
  132. currentPage:1,
  133. pageSize:10,
  134. totalNum:0,
  135. params:{page:0,pageSize:10},
  136. tableData: [],
  137. loading:false,
  138. tableData1:[{id:"27",name:"Model-abcd",version:"0.0.3",version_count:'20',modelsize:"20MB",aiengine:'Mindspore',computesource:'NPU',createtime:'2020-1-2 12:06:01',creator:'zhoupz',hasChildren: true},
  139. {id:"28",name:"Model-abcd",version:"0.0.3",version_count:'20',modelsize:"20MB",aiengine:'Mindspore',computesource:'NPU',createtime:'2020-1-2 12:06:01',creator:'zhoupz',hasChildren: false},
  140. {id:"29",name:"Model-abcd",version:"0.0.3",version_count:'20',modelsize:"20MB",aiengine:'Mindspore',computesource:'NPU',createtime:'2020-1-2 12:06:01',creator:'zhoupz',hasChildren: false},
  141. {id:"30",name:"Model-abcd",version:"0.0.3",version_count:'20',modelsize:"20MB",aiengine:'Mindspore',computesource:'NPU',createtime:'2020-1-2 12:06:01',creator:'zhoupz',hasChildren: false}],
  142. url:''
  143. };
  144. },
  145. methods: {
  146. load(tree, treeNode, resolve) {
  147. console.log("tree",tree)
  148. this.$axios.get(this.url+'show_model_child_api',{params:{
  149. name:tree.Name
  150. }}).then((res)=>{
  151. console.log(res)
  152. let TrainTaskInfo
  153. let tableData
  154. tableData= res.data
  155. console.log("-----tableData---",tableData)
  156. for(let i=0;i<res.data.count;i++){
  157. TrainTaskInfo = JSON.parse(res.data[i].TrainTaskInfo)
  158. tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  159. tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  160. tableData[i].Name=''
  161. }
  162. console.log("=====-----tabledata---".tableData)
  163. resolve(tableData)
  164. })
  165. },
  166. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  167. if(rowIndex===0){
  168. return 'background:#f5f5f6;color:#606266'
  169. }
  170. },
  171. handleSizeChange(val){
  172. this.params.size = val
  173. this.getImageList()
  174. },
  175. handleCurrentChange(val){
  176. this.params.page = val
  177. this.getImageList()
  178. },
  179. showcreateVue(name,version){
  180. $('.ui.modal.second')
  181. .modal({
  182. centered: false,
  183. onShow:function(){
  184. $('.ui.dimmer').css({"background-color":"rgb(136, 136, 136,0.7)"})
  185. $("#job-name").empty()
  186. $('#name').val(name)
  187. let version_string = versionAdd(version)
  188. $('#version').val(version_string)
  189. loadTrainList()
  190. },
  191. onHide:function(){
  192. document.getElementById("formId").reset();
  193. $('#choice_model').dropdown('clear')
  194. $('#choice_version').dropdown('clear')
  195. $('.ui.dimmer').css({"background-color":""})
  196. }
  197. })
  198. .modal('show')
  199. },
  200. deleteModel(id){
  201. this.$axios.delete(this.url+'delete_model',{
  202. params:{
  203. ID:id
  204. }}).then((res)=>{
  205. console.log(res)
  206. this.getModelList()
  207. })
  208. },
  209. getModelList(){
  210. this.loading = true
  211. this.$axios.get(location.href+'_api',{
  212. params:this.params
  213. }).then((res)=>{
  214. let TrainTaskInfo
  215. this.tableData = res.data.data
  216. for(let i=0;i<res.data.count;i++){
  217. TrainTaskInfo = JSON.parse(res.data.data[i].TrainTaskInfo)
  218. this.tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  219. this.tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  220. this.tableData[i].hasChildren = res.data.data[i].VersionCount===1 ? false : true
  221. }
  222. console.log("this.tableData.",this.tableData)
  223. this.loading = false
  224. })
  225. },
  226. },
  227. computed:{
  228. loadhref(){
  229. return this.url+'downloadall?ID='
  230. },
  231. transTime(){
  232. return function(time){
  233. let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  234. let Y = date.getFullYear() + '-';
  235. let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
  236. let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  237. let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  238. let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  239. let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  240. return Y+M+D+h+m+s;
  241. }
  242. },
  243. renderSize(){
  244. return function(value){
  245. if(null==value||value==''){
  246. return "0 Bytes";
  247. }
  248. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  249. var index=0;
  250. var srcsize = parseFloat(value);
  251. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  252. var size =srcsize/Math.pow(1024,index);
  253. size=size.toFixed(2);//保留的小数位数
  254. return size+unitArr[index];
  255. }
  256. }
  257. },
  258. mounted() {
  259. this.getModelList()
  260. this.url = location.href.split('show_model')[0]
  261. }
  262. };
  263. </script>
  264. <style scoped>
  265. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  266. background-color: #5bb973;
  267. color: #FFF;
  268. }
  269. /deep/ .el-pagination.is-background .el-pager li.active {
  270. color: #fff;
  271. cursor: default;
  272. }
  273. /deep/ .el-pagination.is-background .el-pager li:hover {
  274. color: #5bb973;
  275. }
  276. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  277. color: #5bb973;
  278. }
  279. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  280. background-color: #5bb973;
  281. color: #FFF;
  282. }
  283. /deep/ .el-pager li.active {
  284. color: #08C0B9;
  285. cursor: default;
  286. }
  287. /deep/ .el-pagination .el-pager li:hover {
  288. color: #08C0B9;
  289. }
  290. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  291. color: #08C0B9;
  292. }
  293. .text-over{
  294. overflow: hidden;
  295. text-overflow: ellipsis;
  296. vertical-align: middle;
  297. white-space: nowrap;
  298. }
  299. .el-icon-arrow-right{
  300. font-family: element-icons!important;
  301. speak: none;
  302. font-style: normal;
  303. font-weight: 400;
  304. font-feature-settings: normal;
  305. font-variant: normal;
  306. text-transform: none;
  307. line-height: 1;
  308. vertical-align: middle;
  309. display: inline-block;
  310. -webkit-font-smoothing: antialiased;
  311. -moz-osx-font-smoothing: grayscale;
  312. border: 1px solid #D4D4D5;
  313. border-radius: 50%;
  314. color: #D4D4D5;
  315. margin-right: 4px;
  316. }
  317. .el-icon-arrow-right::before{
  318. content: "\e6e0";
  319. }
  320. .expand-icon{
  321. display: inline-block;
  322. width: 20px;
  323. line-height: 20px;
  324. height: 20px;
  325. text-align: center;
  326. margin-right: 3px;
  327. font-size: 12px;
  328. }
  329. /deep/ .el-table__expand-icon .el-icon-arrow-right{
  330. font-family: element-icons!important;
  331. speak: none;
  332. font-style: normal;
  333. font-weight: 400;
  334. font-feature-settings: normal;
  335. font-variant: normal;
  336. text-transform: none;
  337. line-height: 1;
  338. vertical-align: middle;
  339. display: inline-block;
  340. -webkit-font-smoothing: antialiased;
  341. -moz-osx-font-smoothing: grayscale;
  342. border: 1px solid #3291F8;
  343. border-radius: 50%;
  344. color: #3291F8;
  345. margin-right: 4px;
  346. }
  347. .space-around{
  348. display: flex;
  349. justify-content: space-around;
  350. }
  351. </style>