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 15 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div>
  3. <div class="ui container" id="header">
  4. <el-row style="margin-top:15px;" v-loading.fullscreen.lock="fullscreenLoading">
  5. <el-table
  6. ref="table"
  7. :data="tableData"
  8. style="min-width: 100%"
  9. row-key="ID"
  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="模型名称"
  18. align="left"
  19. min-width="18%"
  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. <a class="text-over" :href="showinfoHref+scope.row.Name" :title="scope.row.Name">{{ scope.row.Name }}</a>
  27. </template>
  28. </el-table-column>
  29. <el-table-column
  30. prop="Version"
  31. label="版本"
  32. align="center"
  33. min-width="6.5%"
  34. >
  35. <template slot-scope="scope">
  36. <span class="text-over" :title="scope.row.Version">{{ scope.row.Version}}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. prop="VersionCount"
  41. label="版本数"
  42. align="center"
  43. min-width="7.5%"
  44. >
  45. <template slot-scope="scope">
  46. <span class="text-over" :title="scope.row.VersionCount">{{ scope.row.VersionCount}}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. prop="Size"
  51. label="模型大小"
  52. align="center"
  53. min-width="10.5%"
  54. >
  55. <template slot-scope="scope">
  56. <span class="text-over">{{ renderSize(scope.row.Size)}}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="EngineName"
  61. label="AI引擎"
  62. align="center"
  63. min-width="8.5%"
  64. >
  65. <template slot-scope="scope">
  66. <span class="text-over">{{ scope.row.EngineName}}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. prop="ComputeResource"
  71. label="计算资源"
  72. align="center"
  73. min-width="10.5%"
  74. >
  75. <template slot-scope="scope">
  76. <span class="text-over">{{ scope.row.ComputeResource}}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column
  80. prop="CreatedUnix"
  81. label="创建时间"
  82. align="center"
  83. min-width="13.75%"
  84. >
  85. <template slot-scope="scope">
  86. {{transTime(scope.row.CreatedUnix)}}
  87. </template>
  88. </el-table-column>
  89. <el-table-column
  90. prop="UserName"
  91. label="创建者"
  92. align="center"
  93. min-width="6.75%"
  94. >
  95. <template slot-scope="scope">
  96. <a :href="'/'+scope.row.UserName" :title="scope.row.UserName">
  97. <img class="ui avatar image" :src="scope.row.UserRelAvatarLink">
  98. </a>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="操作" min-width="18%" align="center">
  102. <template slot-scope="scope">
  103. <div class="space-around">
  104. <a :style="{visibility:!scope.row.Children ? 'visible':'hidden'}" :class="{'disabled':!scope.row.IsCanOper}" @click="showcreateVue(scope.row.Name,scope.row.Version)">创建新版本</a>
  105. <a :href="loadhref+scope.row.ID" :class="{'disabled':!scope.row.IsCanOper}">下载</a>
  106. <a :class="{'disabled':!scope.row.IsCanOper}" @click="deleteModel(scope.row.ID,scope.row.cName)">删除</a>
  107. </div>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </el-row>
  112. <div class="ui container" style="margin-top:50px;text-align:center">
  113. <el-pagination
  114. background
  115. @size-change="handleSizeChange"
  116. @current-change="handleCurrentChange"
  117. :current-page="currentPage"
  118. :page-sizes="[10]"
  119. :page-size="pageSize"
  120. layout="total, sizes, prev, pager, next, jumper"
  121. :total="totalNum">
  122. </el-pagination>
  123. </div>
  124. </div>
  125. </div>
  126. </template>
  127. <script>
  128. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  129. export default {
  130. components: {
  131. },
  132. data() {
  133. return {
  134. currentPage:1,
  135. pageSize:10,
  136. totalNum:0,
  137. params:{page:0,pageSize:10},
  138. tableData: [],
  139. fullscreenLoading: false,
  140. url:'',
  141. isLoading:true,
  142. loadNodeMap:new Map()
  143. };
  144. },
  145. methods: {
  146. load(tree, treeNode, resolve) {
  147. this.loadNodeMap.set(tree.cName, tree.ID)
  148. this.$axios.get(this.url+'show_model_child_api',{params:{
  149. name:tree.cName
  150. }}).then((res)=>{
  151. let TrainTaskInfo
  152. let tableData
  153. tableData= res.data
  154. for(let i=0;i<tableData.length;i++){
  155. TrainTaskInfo = JSON.parse(tableData[i].TrainTaskInfo)
  156. tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  157. tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  158. tableData[i].cName=tableData[i].Name
  159. tableData[i].Name=''
  160. tableData[i].VersionCount = ''
  161. tableData[i].Children = true
  162. }
  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.getModelList()
  174. },
  175. handleCurrentChange(val){
  176. this.params.page = val
  177. this.getModelList()
  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,name){
  201. let tree={cName:name}
  202. let _this = this
  203. let flag=1
  204. $('.ui.basic.modal.first')
  205. .modal({
  206. onDeny: function() {
  207. flag = false
  208. },
  209. onApprove: function() {
  210. _this.$axios.delete(_this.url+'delete_model',{
  211. params:{
  212. ID:id
  213. }}).then((res)=>{
  214. _this.getModelList()
  215. _this.loadrefresh(tree)
  216. })
  217. flag = true
  218. },
  219. onHidden: function() {
  220. if (flag == false) {
  221. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  222. }
  223. }
  224. })
  225. .modal('show')
  226. },
  227. loadrefresh(tree){
  228. this.$axios.get(this.url+'show_model_child_api',{params:{
  229. name:tree.cName
  230. }}).then((res)=>{
  231. let TrainTaskInfo
  232. let tableData
  233. tableData= res.data
  234. for(let i=0;i<tableData.length;i++){
  235. TrainTaskInfo = JSON.parse(tableData[i].TrainTaskInfo)
  236. tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  237. tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  238. tableData[i].cName=tableData[i].Name
  239. tableData[i].Name=''
  240. tableData[i].VersionCount = ''
  241. tableData[i].Children = true
  242. }
  243. let id = this.loadNodeMap.get(tree.cName)
  244. this.$set(this.$refs.table.store.states.lazyTreeNodeMap, id, tableData)
  245. })
  246. },
  247. getModelList(){
  248. this.fullscreenLoading = false
  249. this.$axios.get(location.href+'_api',{
  250. params:this.params
  251. }).then((res)=>{
  252. $("#loadContainer").removeClass("loader")
  253. let TrainTaskInfo
  254. this.tableData = res.data.data
  255. for(let i=0;i<this.tableData.length;i++){
  256. TrainTaskInfo = JSON.parse(this.tableData[i].TrainTaskInfo)
  257. this.tableData[i].cName=this.tableData[i].Name
  258. this.tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  259. this.tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  260. this.tableData[i].hasChildren = res.data.data[i].VersionCount===1 ? false : true
  261. }
  262. this.totalNum = res.data.count
  263. this.fullscreenLoading = false
  264. })
  265. },
  266. },
  267. computed:{
  268. loadhref(){
  269. return this.url+'downloadall?ID='
  270. },
  271. showinfoHref(){
  272. return this.url + 'show_model_info?name='
  273. },
  274. transTime(){
  275. return function(time){
  276. let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  277. let Y = date.getFullYear() + '-';
  278. let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
  279. let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  280. let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  281. let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  282. let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  283. return Y+M+D+h+m+s;
  284. }
  285. },
  286. renderSize(){
  287. return function(value){
  288. if(null==value||value==''){
  289. return "0 Bytes";
  290. }
  291. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  292. var index=0;
  293. var srcsize = parseFloat(value);
  294. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  295. var size =srcsize/Math.pow(1024,index);
  296. size=size.toFixed(2);//保留的小数位数
  297. return size+unitArr[index];
  298. }
  299. }
  300. },
  301. mounted() {
  302. this.getModelList()
  303. this.url = location.href.split('show_model')[0]
  304. }
  305. };
  306. </script>
  307. <style scoped>
  308. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  309. background-color: #5bb973;
  310. color: #FFF;
  311. }
  312. /deep/ .el-pagination.is-background .el-pager li.active {
  313. color: #fff;
  314. cursor: default;
  315. }
  316. /deep/ .el-pagination.is-background .el-pager li:hover {
  317. color: #5bb973;
  318. }
  319. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  320. color: #5bb973;
  321. }
  322. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  323. background-color: #5bb973;
  324. color: #FFF;
  325. }
  326. /deep/ .el-pager li.active {
  327. color: #08C0B9;
  328. cursor: default;
  329. }
  330. /deep/ .el-pagination .el-pager li:hover {
  331. color: #08C0B9;
  332. }
  333. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  334. color: #08C0B9;
  335. }
  336. .text-over{
  337. overflow: hidden;
  338. text-overflow: ellipsis;
  339. vertical-align: middle;
  340. white-space: nowrap;
  341. }
  342. .el-icon-arrow-right{
  343. font-family: element-icons!important;
  344. speak: none;
  345. font-style: normal;
  346. font-weight: 400;
  347. font-feature-settings: normal;
  348. font-variant: normal;
  349. text-transform: none;
  350. line-height: 1;
  351. vertical-align: middle;
  352. display: inline-block;
  353. -webkit-font-smoothing: antialiased;
  354. -moz-osx-font-smoothing: grayscale;
  355. border: 1px solid #D4D4D5;
  356. border-radius: 50%;
  357. color: #D4D4D5;
  358. margin-right: 4px;
  359. }
  360. .el-icon-arrow-right::before{
  361. content: "\e6e0";
  362. }
  363. .expand-icon{
  364. display: inline-block;
  365. width: 20px;
  366. line-height: 20px;
  367. height: 20px;
  368. text-align: center;
  369. margin-right: 3px;
  370. font-size: 12px;
  371. }
  372. /deep/ .el-table_1_column_1.is-left .cell {padding-right: 0px !important;}
  373. /deep/ .el-table__expand-icon .el-icon-arrow-right{
  374. font-family: element-icons!important;
  375. speak: none;
  376. font-style: normal;
  377. font-weight: 400;
  378. font-feature-settings: normal;
  379. font-variant: normal;
  380. text-transform: none;
  381. line-height: 1;
  382. vertical-align: middle;
  383. display: inline-block;
  384. -webkit-font-smoothing: antialiased;
  385. -moz-osx-font-smoothing: grayscale;
  386. border: 1px solid #3291F8;
  387. border-radius: 50%;
  388. color: #3291F8;
  389. margin-right: 4px;
  390. }
  391. .space-around{
  392. display: flex;
  393. justify-content: space-around;
  394. }
  395. .disabled {
  396. cursor: default;
  397. pointer-events: none;
  398. color: rgba(0,0,0,.6) !important;
  399. opacity: .45 !important;
  400. }
  401. </style>