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 18 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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="[5,10,15]"
  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. submitId:{}
  144. };
  145. },
  146. methods: {
  147. load(tree, treeNode, resolve) {
  148. this.loadNodeMap.set(tree.cName, tree.ID)
  149. this.$axios.get(this.url+'show_model_child_api',{params:{
  150. name:tree.cName
  151. }}).then((res)=>{
  152. let TrainTaskInfo
  153. let tableData
  154. tableData= res.data
  155. for(let i=0;i<tableData.length;i++){
  156. TrainTaskInfo = JSON.parse(tableData[i].TrainTaskInfo)
  157. tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  158. tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  159. tableData[i].cName=tableData[i].Name
  160. tableData[i].Name=''
  161. tableData[i].VersionCount = ''
  162. tableData[i].Children = true
  163. }
  164. resolve(tableData)
  165. })
  166. },
  167. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  168. if(rowIndex===0){
  169. return 'background:#f5f5f6;color:#606266'
  170. }
  171. },
  172. handleSizeChange(val){
  173. this.params.pageSize = val
  174. this.getModelList()
  175. },
  176. handleCurrentChange(val){
  177. this.params.page = val
  178. this.getModelList()
  179. },
  180. showcreateVue(name,version){
  181. $('.ui.modal.second')
  182. .modal({
  183. centered: false,
  184. onShow:function(){
  185. $('#model_header').text("创建模型新版本")
  186. $('input[name="Name"]').addClass('model_disabled')
  187. $('input[name="Version"]').addClass('model_disabled')
  188. $('.ui.dimmer').css({"background-color":"rgb(136, 136, 136,0.7)"})
  189. $("#job-name").empty()
  190. $('#name').val(name)
  191. let version_string = versionAdd(version)
  192. $('#version').val(version_string)
  193. loadTrainList()
  194. },
  195. onHide:function(){
  196. document.getElementById("formId").reset();
  197. $('#choice_model').dropdown('clear')
  198. $('#choice_version').dropdown('clear')
  199. $('.ui.dimmer').css({"background-color":""})
  200. }
  201. })
  202. .modal('show')
  203. },
  204. check(){
  205. let jobid = document.getElementById("JobId").value
  206. let versionname = document.getElementById("VersionName").value
  207. let name= document.getElementById("name").value
  208. let version= document.getElementById("version").value
  209. if(jobid==""){
  210. $(".required.ten.wide.field").addClass("error")
  211. return false
  212. }else{
  213. $(".required.ten.wide.field").removeClass("error")
  214. }
  215. if(versionname==""){
  216. $(".required.six.widde.field").addClass("error")
  217. return false
  218. }else{
  219. $(".required.six.widde.field").removeClass("error")
  220. }
  221. if(name==""){
  222. $("#modelname").addClass("error")
  223. return false
  224. }else{
  225. $("#modelname").removeClass("error")
  226. }
  227. if(versionname==""){
  228. $("#verionname").addClass("error")
  229. return false
  230. }else{
  231. $("#verionname").removeClass("error")
  232. }
  233. return true
  234. },
  235. submit(){
  236. let context = this
  237. let flag= this.check()
  238. console.log(flag,context)
  239. if(flag){
  240. let data = $("#formId").serialize()
  241. $("#mask").css({"display":"block","z-index":"9999"})
  242. $.ajax({
  243. url:url_href,
  244. type:'POST',
  245. data:data,
  246. success:function(res){
  247. context.getModelList()
  248. $('.ui.modal.second').modal('hide')
  249. },
  250. error: function(xhr){
  251. // 隐藏 loading
  252. // 只有请求不正常(状态码不为200)才会执行
  253. $('.ui.error.message').text(xhr.responseText)
  254. $('.ui.error.message').css('display','block')
  255. },
  256. complete:function(xhr){
  257. $("#mask").css({"display":"none","z-index":"1"})
  258. }
  259. })
  260. }else{
  261. return false
  262. }
  263. },
  264. deleteModel(id,name){
  265. let tree={cName:name}
  266. let _this = this
  267. let flag=1
  268. $('.ui.basic.modal.first')
  269. .modal({
  270. onDeny: function() {
  271. flag = false
  272. },
  273. onApprove: function() {
  274. _this.$axios.delete(_this.url+'delete_model',{
  275. params:{
  276. ID:id
  277. }}).then((res)=>{
  278. _this.getModelList()
  279. _this.loadrefresh(tree)
  280. })
  281. flag = true
  282. },
  283. onHidden: function() {
  284. if (flag == false) {
  285. $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut();
  286. }else{
  287. $('.alert').html('删除成功').removeClass('alert-danger').addClass('alert-success').show().delay(1500).fadeOut();
  288. }
  289. }
  290. })
  291. .modal('show')
  292. },
  293. loadrefresh(tree){
  294. this.$axios.get(this.url+'show_model_child_api',{params:{
  295. name:tree.cName
  296. }}).then((res)=>{
  297. let TrainTaskInfo
  298. let tableData
  299. tableData= res.data
  300. for(let i=0;i<tableData.length;i++){
  301. TrainTaskInfo = JSON.parse(tableData[i].TrainTaskInfo)
  302. tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  303. tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  304. tableData[i].cName=tableData[i].Name
  305. tableData[i].Name=''
  306. tableData[i].VersionCount = ''
  307. tableData[i].Children = true
  308. }
  309. let id = this.loadNodeMap.get(tree.cName)
  310. this.$set(this.$refs.table.store.states.lazyTreeNodeMap, id, tableData)
  311. })
  312. },
  313. getModelList(){
  314. this.fullscreenLoading = false
  315. this.$axios.get(location.href+'_api',{
  316. params:this.params
  317. }).then((res)=>{
  318. $(".ui.grid").removeAttr("style")
  319. $("#loadContainer").removeClass("loader")
  320. let TrainTaskInfo
  321. this.tableData = res.data.data
  322. for(let i=0;i<this.tableData.length;i++){
  323. TrainTaskInfo = JSON.parse(this.tableData[i].TrainTaskInfo)
  324. this.tableData[i].cName=this.tableData[i].Name
  325. this.tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
  326. this.tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
  327. this.tableData[i].hasChildren = res.data.data[i].VersionCount===1 ? false : true
  328. }
  329. this.totalNum = res.data.count
  330. this.fullscreenLoading = false
  331. })
  332. },
  333. },
  334. computed:{
  335. loadhref(){
  336. return this.url+'downloadall?ID='
  337. },
  338. showinfoHref(){
  339. return this.url + 'show_model_info?name='
  340. },
  341. transTime(){
  342. return function(time){
  343. let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  344. let Y = date.getFullYear() + '-';
  345. let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
  346. let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
  347. let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
  348. let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
  349. let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
  350. return Y+M+D+h+m+s;
  351. }
  352. },
  353. renderSize(){
  354. return function(value){
  355. if(null==value||value==''){
  356. return "0 Bytes";
  357. }
  358. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  359. var index=0;
  360. var srcsize = parseFloat(value);
  361. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  362. var size =srcsize/Math.pow(1024,index);
  363. size=size.toFixed(2);//保留的小数位数
  364. return size+unitArr[index];
  365. }
  366. }
  367. },
  368. mounted() {
  369. this.submitId = document.getElementById("submitId")
  370. this.getModelList()
  371. this.url = location.href.split('show_model')[0]
  372. this.submitId.addEventListener("click", this.submit)
  373. },
  374. beforeDestroy() { // 实例销毁之前对点击事件进行解绑
  375. this.submitId.removeEventListener('click', this.submit);
  376. }
  377. };
  378. </script>
  379. <style scoped>
  380. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  381. background-color: #5bb973;
  382. color: #FFF;
  383. }
  384. /deep/ .el-pagination.is-background .el-pager li.active {
  385. color: #fff;
  386. cursor: default;
  387. }
  388. /deep/ .el-pagination.is-background .el-pager li:hover {
  389. color: #5bb973;
  390. }
  391. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  392. color: #5bb973;
  393. }
  394. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  395. background-color: #5bb973;
  396. color: #FFF;
  397. }
  398. /deep/ .el-pager li.active {
  399. color: #08C0B9;
  400. cursor: default;
  401. }
  402. /deep/ .el-pagination .el-pager li:hover {
  403. color: #08C0B9;
  404. }
  405. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  406. color: #08C0B9;
  407. }
  408. .text-over{
  409. overflow: hidden;
  410. text-overflow: ellipsis;
  411. vertical-align: middle;
  412. white-space: nowrap;
  413. }
  414. .el-icon-arrow-right{
  415. font-family: element-icons!important;
  416. speak: none;
  417. font-style: normal;
  418. font-weight: 400;
  419. font-feature-settings: normal;
  420. font-variant: normal;
  421. text-transform: none;
  422. line-height: 1;
  423. vertical-align: middle;
  424. display: inline-block;
  425. -webkit-font-smoothing: antialiased;
  426. -moz-osx-font-smoothing: grayscale;
  427. border: 1px solid #D4D4D5;
  428. border-radius: 50%;
  429. color: #D4D4D5;
  430. margin-right: 4px;
  431. }
  432. .el-icon-arrow-right::before{
  433. content: "\e6e0";
  434. }
  435. .expand-icon{
  436. display: inline-block;
  437. width: 20px;
  438. line-height: 20px;
  439. height: 20px;
  440. text-align: center;
  441. margin-right: 3px;
  442. font-size: 12px;
  443. }
  444. /deep/ .el-table_1_column_1.is-left .cell {padding-right: 0px !important;}
  445. /deep/ .el-table__expand-icon .el-icon-arrow-right{
  446. font-family: element-icons!important;
  447. speak: none;
  448. font-style: normal;
  449. font-weight: 400;
  450. font-feature-settings: normal;
  451. font-variant: normal;
  452. text-transform: none;
  453. line-height: 1;
  454. vertical-align: middle;
  455. display: inline-block;
  456. -webkit-font-smoothing: antialiased;
  457. -moz-osx-font-smoothing: grayscale;
  458. border: 1px solid #3291F8;
  459. border-radius: 50%;
  460. color: #3291F8;
  461. margin-right: 4px;
  462. }
  463. .space-around{
  464. display: flex;
  465. justify-content: space-around;
  466. }
  467. .disabled {
  468. cursor: default;
  469. pointer-events: none;
  470. color: rgba(0,0,0,.6) !important;
  471. opacity: .45 !important;
  472. }
  473. </style>