|
- <template>
- <div>
- <div class="ui container" id="header">
- <el-row style="margin-top:15px;">
- <el-table
- :data="tableData"
- style="min-width: 100%"
- row-key="ID"
- lazy
- :load="load"
- :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
- :header-cell-style="tableHeaderStyle"
- >
- <el-table-column
- prop="Name"
- label="模型名称"
- align="left"
- min-width="18%"
- >
- <template slot-scope="scope">
- <div class="expand-icon" v-if="scope.row.hasChildren===false">
- <i class="el-icon-arrow-right"></i>
- </div>
- <!-- <i class="el-icon-time"></i> -->
- <a class="text-over" :title="scope.row.Name">{{ scope.row.Name }}</a>
- </template>
- </el-table-column>
- <el-table-column
- prop="Version"
- label="版本"
- align="center"
- min-width="6.5%"
- >
- <template slot-scope="scope">
- <span class="text-over" :title="scope.row.Version">{{ scope.row.Version}}</span>
- </template>
- </el-table-column>
-
- <el-table-column
- prop="VersionCount"
- label="版本数"
- align="center"
- min-width="7.5%"
- >
- <template slot-scope="scope">
- <span class="text-over" :title="scope.row.VersionCount">{{ scope.row.VersionCount}}</span>
- </template>
- </el-table-column>
-
- <el-table-column
- prop="Size"
- label="模型大小"
- align="center"
- min-width="10.5%"
- >
- <template slot-scope="scope">
- <span class="text-over">{{ renderSize(scope.row.Size)}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="EngineName"
- label="AI引擎"
- align="center"
- min-width="8.5%"
- >
- <template slot-scope="scope">
- <span class="text-over">{{ scope.row.EngineName}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="ComputeResource"
- label="计算资源"
- align="center"
- min-width="10.5%"
- >
- <template slot-scope="scope">
- <span class="text-over">{{ scope.row.ComputeResource}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="CreatedUnix"
- label="创建时间"
- align="center"
- min-width="13.75%"
- >
- <template slot-scope="scope">
- {{transTime(scope.row.CreatedUnix)}}
- </template>
- </el-table-column>
- <el-table-column
- prop="UserName"
- label="创建者"
- align="center"
- min-width="6.75%"
- >
- <template slot-scope="scope">
- <a :href="'/'+scope.row.UserName" :title="scope.row.UserName">
- <img class="ui avatar image" :src="scope.row.UserRelAvatarLink">
- </a>
- </template>
- </el-table-column>
-
- <el-table-column label="操作" min-width="18%" align="center">
- <template slot-scope="scope">
- <div class="space-around">
- <a @click="showcreateVue(scope.row.Name,scope.row.Version)">创建新版本</a>
- <a :href="loadhref+scope.row.ID">下载</a>
- <a @click="deleteModel(scope.row.ID)">删除</a>
- </div>
-
- </template>
- </el-table-column>
- </el-table>
- </el-row>
- <div class="ui container" style="margin-top:50px;text-align:center">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-size="pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="totalNum">
- </el-pagination>
- </div>
- </div>
- </div>
-
-
- </template>
-
- <script>
-
- const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
-
-
-
-
- export default {
- components: {
-
- },
- data() {
- return {
- currentPage:1,
- pageSize:10,
- totalNum:0,
- params:{page:0,pageSize:10},
- tableData: [],
- loading:false,
- 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},
- {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},
- {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},
- {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}],
-
- url:''
- };
- },
- methods: {
- load(tree, treeNode, resolve) {
- console.log("tree",tree)
- this.$axios.get(this.url+'show_model_child_api',{params:{
- name:tree.Name
- }}).then((res)=>{
- console.log(res)
- let TrainTaskInfo
- let tableData
- tableData= res.data
- console.log("-----tableData---",tableData)
- for(let i=0;i<res.data.count;i++){
- TrainTaskInfo = JSON.parse(res.data[i].TrainTaskInfo)
- tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
- tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
- tableData[i].Name=''
- }
- console.log("=====-----tabledata---".tableData)
- resolve(tableData)
- })
-
- },
- tableHeaderStyle({row,column,rowIndex,columnIndex}){
- if(rowIndex===0){
- return 'background:#f5f5f6;color:#606266'
- }
- },
- handleSizeChange(val){
- this.params.size = val
- this.getImageList()
- },
- handleCurrentChange(val){
- this.params.page = val
- this.getImageList()
- },
- showcreateVue(name,version){
- $('.ui.modal.second')
- .modal({
- centered: false,
- onShow:function(){
- $('.ui.dimmer').css({"background-color":"rgb(136, 136, 136,0.7)"})
- $("#job-name").empty()
- $('#name').val(name)
- let version_string = versionAdd(version)
- $('#version').val(version_string)
- loadTrainList()
- },
- onHide:function(){
- document.getElementById("formId").reset();
- $('#choice_model').dropdown('clear')
- $('#choice_version').dropdown('clear')
- $('.ui.dimmer').css({"background-color":""})
- }
- })
- .modal('show')
- },
-
- deleteModel(id){
- this.$axios.delete(this.url+'delete_model',{
- params:{
- ID:id
- }}).then((res)=>{
- console.log(res)
- this.getModelList()
- })
- },
- getModelList(){
- this.loading = true
-
- this.$axios.get(location.href+'_api',{
- params:this.params
- }).then((res)=>{
- let TrainTaskInfo
- this.tableData = res.data.data
- for(let i=0;i<res.data.count;i++){
- TrainTaskInfo = JSON.parse(res.data.data[i].TrainTaskInfo)
- this.tableData[i].EngineName = TrainTaskInfo.EngineName.split('-')[0]
- this.tableData[i].ComputeResource = TrainTaskInfo.ComputeResource
- this.tableData[i].hasChildren = res.data.data[i].VersionCount===1 ? false : true
- }
- console.log("this.tableData.",this.tableData)
- this.loading = false
- })
- },
-
- },
- computed:{
- loadhref(){
- return this.url+'downloadall?ID='
- },
- transTime(){
- return function(time){
- let date = new Date(time * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
- let Y = date.getFullYear() + '-';
- let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
- let D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
- let h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
- let m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
- let s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
- return Y+M+D+h+m+s;
- }
- },
- renderSize(){
- return function(value){
- if(null==value||value==''){
- return "0 Bytes";
- }
- var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
- var index=0;
- var srcsize = parseFloat(value);
- index=Math.floor(Math.log(srcsize)/Math.log(1024));
- var size =srcsize/Math.pow(1024,index);
- size=size.toFixed(2);//保留的小数位数
- return size+unitArr[index];
- }
- }
-
-
- },
- mounted() {
- this.getModelList()
- this.url = location.href.split('show_model')[0]
- }
-
- };
- </script>
-
- <style scoped>
-
-
-
-
-
-
- /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
- background-color: #5bb973;
- color: #FFF;
- }
- /deep/ .el-pagination.is-background .el-pager li.active {
- color: #fff;
- cursor: default;
- }
- /deep/ .el-pagination.is-background .el-pager li:hover {
- color: #5bb973;
- }
- /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
- color: #5bb973;
- }
- /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
- background-color: #5bb973;
- color: #FFF;
- }
-
- /deep/ .el-pager li.active {
- color: #08C0B9;
- cursor: default;
- }
- /deep/ .el-pagination .el-pager li:hover {
- color: #08C0B9;
- }
- /deep/ .el-pagination .el-pager li:not(.disabled):hover {
- color: #08C0B9;
- }
-
- .text-over{
- overflow: hidden;
- text-overflow: ellipsis;
- vertical-align: middle;
- white-space: nowrap;
- }
- .el-icon-arrow-right{
- font-family: element-icons!important;
- speak: none;
- font-style: normal;
- font-weight: 400;
- font-feature-settings: normal;
- font-variant: normal;
- text-transform: none;
- line-height: 1;
- vertical-align: middle;
- display: inline-block;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- border: 1px solid #D4D4D5;
- border-radius: 50%;
- color: #D4D4D5;
- margin-right: 4px;
- }
- .el-icon-arrow-right::before{
- content: "\e6e0";
- }
- .expand-icon{
- display: inline-block;
- width: 20px;
- line-height: 20px;
- height: 20px;
- text-align: center;
- margin-right: 3px;
- font-size: 12px;
- }
- /deep/ .el-table__expand-icon .el-icon-arrow-right{
- font-family: element-icons!important;
- speak: none;
- font-style: normal;
- font-weight: 400;
- font-feature-settings: normal;
- font-variant: normal;
- text-transform: none;
- line-height: 1;
- vertical-align: middle;
- display: inline-block;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- border: 1px solid #3291F8;
- border-radius: 50%;
- color: #3291F8;
- margin-right: 4px;
- }
- .space-around{
- display: flex;
- justify-content: space-around;
- }
-
- </style>
|