Преглед изворни кода

孙浩博,fixed:传统算法训练训练

seamew пре 1 година
родитељ
комит
3d97f324de

+ 1 - 1
src/views/modules/alg/alg-add.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog :title="'新增算法'" :close-on-click-modal="false" :visible.sync="visible">
-    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
+    <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
       label-width="100px">
 
       <el-form-item label="选择算法" size="mini">

+ 10 - 11
src/views/modules/alg/algcreate1.vue

@@ -21,10 +21,16 @@
         </el-radio-group>
       </el-form-item>
       <el-form-item label="文件" size="mini">
-        <el-upload class="upload-demo" action="#" :on-preview="handlePreview"
-          :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="10" :on-exceed="handleExceed"
+        <el-upload 
+          class="upload-demo" 
+          action="" 
+          :before-remove="beforeRemove" 
+          multiple 
+          :limit="10" 
+          :on-exceed="handleExceed"
           :on-change="fileChange"
-          :file-list="fileList">
+          :file-list="fileList"
+          :auto-upload="false">
           <el-button size="small" type="primary">点击上传</el-button>
           <div slot="tip" class="el-upload__tip">请上传代码文件</div>
         </el-upload>
@@ -343,12 +349,6 @@ export default {
       });
     },
     // 以下4个函数是文件上传功能的
-    handleRemove(file, fileList) {
-      console.log(file, fileList);
-    },
-    handlePreview(file) {
-      console.log(file);
-    },
     handleExceed(files, fileList) {
       Message.warning(
         `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
@@ -361,8 +361,7 @@ export default {
     },
     // 文件改变时
     fileChange(file, fileList) {
-        this.fileList=fileList;
-        this.fileList.append(file);
+        this.fileList.push(file);
     },
   },
 };

+ 2 - 2
src/views/modules/alg/algs.vue

@@ -70,7 +70,7 @@
     </el-pagination>
     <!-- 弹窗, 新增 / 修改 -->
     <Watch v-if="newWatchVisible" ref="newWatch" @refreshDataList="getDataList"></Watch>
-    <Add v-if="addVisible" ref="addS" @refreshDataList="getDataList"></Add>
+    <!-- <Add v-if="addVisible" ref="addS" @refreshDataList="getDataList"></Add> -->
     <!-- <alg-add v-if="addVisible" ref="addS" @refreshDataList="getDataList"></alg-add> -->
     <AlgAdd v-if="addVisible" ref="addS" @refreshDataList="getDataList"></AlgAdd>
     <Watch v-if="newWatchVisible" ref="newWatch" @refreshDataList="getDataList"></Watch>
@@ -272,7 +272,7 @@ export default {
                 },
               });
               this.pageIndex = 1;
-              getDataList();
+              this.getDataList();
             } else {
               Message.error(data.msg);
             }

+ 1 - 1
src/views/modules/alg/train-add.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog :title="'新建训练任务'" :close-on-click-modal="false" :visible.sync="visible">
-    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
+    <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
       label-width="100px">
 
       <el-form-item label="选择算法" size="mini">

+ 26 - 25
src/views/modules/alg/train-create-tradition.vue

@@ -8,7 +8,7 @@
     </el-breadcrumb>
     <el-divider class="divi"></el-divider>
 
-    <el-tabs v-model="activeName" @tab-click="handleClick">
+    <el-tabs v-model="activeName">
       <el-tab-pane label="信息选择" name="first">
 
         <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="180px">
@@ -18,7 +18,7 @@
           </el-form-item>
 
           <el-form-item label="选择类别" prop="calssSelected">
-            <el-select v-model="dataForm.calssSelected" placeholder="选择类别" @change="getAlgs()">
+            <el-select v-model="dataForm.calssSelected" placeholder="选择类别" @change="getAlgs(dataForm.calssSelected)">
               <el-option v-for="data in classification" :key="data.categoryName" :label="data.categoryName" :value="data.categoryName">
               </el-option>
             </el-select>
@@ -52,7 +52,7 @@
       </el-tab-pane>
 
       <el-tab-pane label="资源设置" name="second">
-        <el-form :model="dataForm2" :rules="dataRule" ref="dataset" label-width="180px">
+        <el-form :rules="dataRule" ref="dataset" label-width="180px">
 
           <el-form-item label="指定cpu">
             <el-select v-model="cpuSelected" multiple placeholder="选择容器运行在哪些cpu上">
@@ -310,32 +310,33 @@ export default {
       });
     },
     //当选择的类别改变时,先清空所选算法,再重新获得所选新类别对应的算法
-    getAlgs(){
-      console.log(this.dataForm.calssSelected);
-      this.$refs["dataForm"].validate();
+    getAlgs(calssSelected){
+      // console.log(calssSelected);
+      // this.$refs["dataForm"].validate();
       this.dataForm.algSelected=null;
       this.dataForm.fileSelected=null;
-      this.$http({
-        url: this.$http.adornUrl("/algs/selectOnCreateMission"),
-        method: "get",
-        params: this.$http.adornParams({
-          classificationtag: this.dataForm.calssSelected,
-          frameId:-1
-        }),
-      }).then(({ data }) => {
-        if (data && data.code === 0) {
-          this.algs = data.list;
-        } else {
-          this.algs = [];
-        }
-      });
+      if (calssSelected != null && calssSelected != "") {
+        this.$http({
+          url: this.$http.adornUrl("/algs/selectOnCreateMission"),
+          method: "get",
+          params: this.$http.adornParams({
+            classificationtag: calssSelected,
+            frameId:-1
+          }),
+        }).then(({ data }) => {
+          if (data && data.code === 0) {
+            this.algs = data.list;
+          } else {
+            this.algs = [];
+          }
+        }).catch((e)=>{});
+      }
     },
 
     //当选择的算法改变时,先清空所选文件,再重新获得所选新算法对应的文件
     getFiles(){
-      this.$refs["dataForm"].validate();
+      // this.$refs["dataForm"].validate();
       this.dataForm.fileSelected=null;
-      var algId=this.dataForm.algSelected;
       this.$http({
         url: this.$http.adornUrl("/algs/listFiles"),
         method: "get",
@@ -354,15 +355,15 @@ export default {
 
     //当训练任务名称改变时,对表单进行验证
     missNameChange(){
-      this.$refs["dataForm"].validate();
+      // this.$refs["dataForm"].validate();
     },
     //当选择的文件改变时,对表单进行验证
     fileChange(){
-      this.$refs["dataForm"].validate();
+      // this.$refs["dataForm"].validate();
     },
     //当选择的内存改变时,对表单进行验证
     memoryChange(){
-      this.$refs["dataForm"].validate();
+      // this.$refs["dataForm"].validate();
     },
     
 

+ 1 - 1
src/views/modules/alg/train-create.vue

@@ -11,7 +11,7 @@
     <el-tabs v-model="activeName" @tab-click="handleClick">
       <el-tab-pane label="信息选择" name="first">
 
-        <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="180px">
+        <el-form :model="dataForm" ref="dataForm" label-width="180px">
 
           <el-form-item label="训练任务名称" prop="missName">
             <el-input v-model="dataForm.missName" placeholder="请输入训练任务名称" @change="missNameChange()"></el-input>

+ 145 - 167
src/views/modules/alg/train-file-watch.vue

@@ -1,197 +1,175 @@
 <template>
-  <el-dialog :title=" '查看模板'" :close-on-click-modal="false" :visible.sync="visible">
-    
+  <el-dialog :title="'查看模板'" :close-on-click-modal="false" :visible.sync="visible">
     <div class="">
-
-    <div class="trainFileWatchContainer">
-      <codemirror
-        ref="cm"
-        v-model="code"
-        :options="cmOptions"
-        class="trainFileWatch"
-      ></codemirror>
+      <div class="trainFileWatchContainer">
+        <codemirror ref="cm" v-model="code" :options="cmOptions" class="trainFileWatch"></codemirror>
+      </div>
     </div>
-    
-  </div>
   </el-dialog>
 </template>
 
 <script>
 // 全局引入vue-codemirror
-  import {codemirror} from 'vue-codemirror';
-  // 引入css文件
-  import 'codemirror/lib/codemirror.css'
-  // 引入主题 可以从 codemirror/theme/ 下引入多个
-  import 'codemirror/theme/idea.css'
-  // 引入语言模式 可以从 codemirror/mode/ 下引入多个
-  import 'codemirror/mode/sql/sql.js';
-  import 'codemirror/mode/python/python.js'
-  import 'codemirror/mode/javascript/javascript.js'
-
-  // 搜索功能
-  // find:Ctrl-F (PC), Cmd-F (Mac)
-  // findNext:Ctrl-G (PC), Cmd-G (Mac)
-  // findPrev:Shift-Ctrl-G (PC), Shift-Cmd-G (Mac)
-  // replace:Shift-Ctrl-F (PC), Cmd-Alt-F (Mac)
-  // replaceAll:Shift-Ctrl-R (PC), Shift-Cmd-Alt-F (Mac)
-  import 'codemirror/addon/dialog/dialog.css'
-  import 'codemirror/addon/dialog/dialog'
-  import 'codemirror/addon/search/searchcursor'
-  import 'codemirror/addon/search/search'
-  import 'codemirror/addon/search/jump-to-line'
-  import 'codemirror/addon/search/matchesonscrollbar'
-  import 'codemirror/addon/search/match-highlighter'
-
-
-  // 代码提示功能 具体语言可以从 codemirror/addon/hint/ 下引入多个
-  import 'codemirror/addon/hint/show-hint.css';
-  import 'codemirror/addon/hint/show-hint';
-  import 'codemirror/addon/hint/sql-hint';
-  import 'codemirror/addon/hint/anyword-hint';
-  import "codemirror/addon/hint/javascript-hint.js";
-  import "codemirror/addon/lint/javascript-lint.js"; 
-  import 'codemirror/addon/lint/lint'
-  import 'codemirror/addon/lint/lint.css'
-
-  // 高亮行功能
-  import 'codemirror/addon/selection/active-line'
-  import 'codemirror/addon/selection/selection-pointer'
-
-  // 调整scrollbar样式功能
-  import 'codemirror/addon/scroll/simplescrollbars.css'
-  import 'codemirror/addon/scroll/simplescrollbars'
-
-  // 自动括号匹配功能
-  import 'codemirror/addon/edit/matchbrackets'
-  import 'codemirror/addon/edit/closebrackets'
-
-  // 全屏功能 由于项目复杂,自带的全屏功能一般不好使
-  import 'codemirror/addon/display/fullscreen.css'
-  import 'codemirror/addon/display/fullscreen'
-
-  // 显示自动刷新
-  import 'codemirror/addon/display/autorefresh'
-
-  // 多语言支持?
-  import 'codemirror/addon/mode/overlay'
-  import 'codemirror/addon/mode/multiplex'
-
-
-  // 代码段折叠功能
-  import 'codemirror/addon/fold/foldcode'
-  import 'codemirror/addon/fold/foldgutter'
-  import 'codemirror/addon/fold/foldgutter.css'
-
-  import 'codemirror/addon/fold/brace-fold.js'
-  import 'codemirror/addon/fold/comment-fold.js'
-  import 'codemirror/addon/fold/xml-fold.js';
-  import 'codemirror/addon/fold/indent-fold.js';
-  import 'codemirror/addon/fold/markdown-fold.js';
-  import 'codemirror/addon/fold/comment-fold.js';
-
-  // merge功能
-  import 'codemirror/addon/merge/merge.css'
-  import 'codemirror/addon/merge/merge'
-  // google DiffMatchPatch
-  import DiffMatchPatch from 'diff-match-patch'
-  // DiffMatchPatch config with global
-  window.diff_match_patch = DiffMatchPatch;
-  window.DIFF_DELETE = -1;
-  window.DIFF_INSERT = 1;
-  window.DIFF_EQUAL = 0;
+import { codemirror } from "vue-codemirror";
+// 引入css文件
+import "codemirror/lib/codemirror.css";
+// 引入主题 可以从 codemirror/theme/ 下引入多个
+import "codemirror/theme/idea.css";
+// 引入语言模式 可以从 codemirror/mode/ 下引入多个
+import "codemirror/mode/sql/sql.js";
+import "codemirror/mode/python/python.js";
+import "codemirror/mode/javascript/javascript.js";
+
+// 搜索功能
+// find:Ctrl-F (PC), Cmd-F (Mac)
+// findNext:Ctrl-G (PC), Cmd-G (Mac)
+// findPrev:Shift-Ctrl-G (PC), Shift-Cmd-G (Mac)
+// replace:Shift-Ctrl-F (PC), Cmd-Alt-F (Mac)
+// replaceAll:Shift-Ctrl-R (PC), Shift-Cmd-Alt-F (Mac)
+import "codemirror/addon/dialog/dialog.css";
+import "codemirror/addon/dialog/dialog";
+import "codemirror/addon/search/searchcursor";
+import "codemirror/addon/search/search";
+import "codemirror/addon/search/jump-to-line";
+import "codemirror/addon/search/matchesonscrollbar";
+import "codemirror/addon/search/match-highlighter";
+
+// 代码提示功能 具体语言可以从 codemirror/addon/hint/ 下引入多个
+import "codemirror/addon/hint/show-hint.css";
+import "codemirror/addon/hint/show-hint";
+import "codemirror/addon/hint/sql-hint";
+import "codemirror/addon/hint/anyword-hint";
+import "codemirror/addon/hint/javascript-hint.js";
+import "codemirror/addon/lint/javascript-lint.js";
+import "codemirror/addon/lint/lint";
+import "codemirror/addon/lint/lint.css";
+
+// 高亮行功能
+import "codemirror/addon/selection/active-line";
+import "codemirror/addon/selection/selection-pointer";
+
+// 调整scrollbar样式功能
+import "codemirror/addon/scroll/simplescrollbars.css";
+import "codemirror/addon/scroll/simplescrollbars";
+
+// 自动括号匹配功能
+import "codemirror/addon/edit/matchbrackets";
+import "codemirror/addon/edit/closebrackets";
+
+// 全屏功能 由于项目复杂,自带的全屏功能一般不好使
+import "codemirror/addon/display/fullscreen.css";
+import "codemirror/addon/display/fullscreen";
+
+// 显示自动刷新
+import "codemirror/addon/display/autorefresh";
+
+// 多语言支持?
+import "codemirror/addon/mode/overlay";
+import "codemirror/addon/mode/multiplex";
+
+// 代码段折叠功能
+import "codemirror/addon/fold/foldcode";
+import "codemirror/addon/fold/foldgutter";
+import "codemirror/addon/fold/foldgutter.css";
+
+import "codemirror/addon/fold/brace-fold.js";
+import "codemirror/addon/fold/comment-fold.js";
+import "codemirror/addon/fold/xml-fold.js";
+import "codemirror/addon/fold/indent-fold.js";
+import "codemirror/addon/fold/markdown-fold.js";
+import "codemirror/addon/fold/comment-fold.js";
+
+// merge功能
+import "codemirror/addon/merge/merge.css";
+import "codemirror/addon/merge/merge";
+// google DiffMatchPatch
+import DiffMatchPatch from "diff-match-patch";
+// DiffMatchPatch config with global
+window.diff_match_patch = DiffMatchPatch;
+window.DIFF_DELETE = -1;
+window.DIFF_INSERT = 1;
+window.DIFF_EQUAL = 0;
 
 export default {
-  name:'Simple',
-  components:{
+  name: "Simple",
+  components: {
     codemirror
   },
   data() {
     return {
       visible: false,
-      code:'',
-      insertCode:'',
+      code: "",
+      insertCode: "",
       cmOptions: {
-          // 语言及语法模式
-          mode: 'text/x-python',
-          // 主题
-          theme: 'idea',
-          //只读
-          readOnly:'nocursor',
-          // 显示行数
-          line: true,
-          lineNumbers: true,
-          // 软换行
-          lineWrapping: true,
-          // tab宽度
-          tabSize: 4,
-          
-          foldGutter: true, // 启用行槽中的代码折叠
-          
-          autoCloseBrackets: true, // 自动闭合符号
-          styleActiveLine: true, // 显示选中行的样式
-          
-          
-          lint: true,
-          gutters: [
-              "CodeMirror-lint-markers",//代码错误检测
-              "CodeMirror-linenumbers",
-              "CodeMirror-foldgutter",//展开收起
-          ],
-          hintOptions: {
-            // 避免由于提示列表只有一个提示信息时,自动填充
-            completeSingle: false,
-            // 不同的语言支持从配置中读取自定义配置 sql语言允许配置表和字段信息,用于代码提示
-            tables: {
-              "table1": ["c1", "c2"],
-            },
-          },
-          
-          // 高亮行功能
-          styleActiveLine: true,
-          // 调整scrollbar样式功能
-          scrollbarStyle: 'overlay',
-          // 自动括号匹配功能
-          matchBrackets: true
-        }
+        // 语言及语法模式
+        mode: "text/x-python",
+        // 主题
+        theme: "idea",
+        //只读
+        readOnly: "nocursor",
+        // 显示行数
+        line: true,
+        lineNumbers: true,
+        // 软换行
+        lineWrapping: true,
+        // tab宽度
+        tabSize: 4,
+
+        foldGutter: true, // 启用行槽中的代码折叠
+
+        autoCloseBrackets: true, // 自动闭合符号
+        styleActiveLine: true, // 显示选中行的样式
+
+        lint: true,
+        gutters: [
+          "CodeMirror-lint-markers", //代码错误检测
+          "CodeMirror-linenumbers",
+          "CodeMirror-foldgutter" //展开收起
+        ],
+        hintOptions: {
+          // 避免由于提示列表只有一个提示信息时,自动填充
+          completeSingle: false,
+          // 不同的语言支持从配置中读取自定义配置 sql语言允许配置表和字段信息,用于代码提示
+          tables: {
+            table1: ["c1", "c2"]
+          }
+        },
+
+        // 高亮行功能
+        styleActiveLine: true,
+        // 调整scrollbar样式功能
+        scrollbarStyle: "overlay",
+        // 自动括号匹配功能
+        matchBrackets: true
+      }
     };
   },
   methods: {
-    init(algorithmNameToVersion,verisionToFile,fileName) {
-      
-      this.algorithmNameToVersion=algorithmNameToVersion;
-      this.verisionToFile=verisionToFile;
-      this.fileName=fileName;
+    init(algorithmNameToVersion, verisionToFile, algFrameId, fileName) {
+      this.visible = true;
       this.$http({
-          url:this.$http.adornUrl('/minio/readUrlContent'),
-          method:'get',
-          params:this.$http.adornParams({
-            algorithmNameToVersion:this.algorithmNameToVersion,
-            verisionToFile:this.verisionToFile,
-            fileName:this.fileName
-          }),
-        }).then(({data})=>{
-          this.code=data;
-          this.visible = true;
-          
+        url: this.$http.adornUrl("/minio/readUrlContent"),
+        method: "get",
+        params: this.$http.adornParams({
+          algorithmNameToVersion,
+          verisionToFile,
+          algFrameId,
+          fileName
+        })
+      }).then(({ data }) => {
+        this.code = data;
+        this.visible = true;
       });
-
-      
-    },
-  },
-  mounted(){
-
-    
+    }
   },
-
+  mounted() {}
 };
 </script>
-<style>
-.trainFileWatchContainer{
+<style scope>
+.trainFileWatchContainer {
   height: 600px;
 }
 .CodeMirror {
   height: 600px;
 }
-
-
 </style>

+ 155 - 129
src/views/modules/alg/train-watch.vue

@@ -10,39 +10,27 @@
     
 
     <el-tabs v-model="activeName" @tab-click="handleClick">
-
       <el-tab-pane label="日志" name="first">
-
         <div class="codemirrorContainer"
           v-loading="loading"
           element-loading-text="拼命加载中"
           element-loading-spinner="el-icon-loading"
           element-loading-background="rgba(0, 0, 0, 0.8)">
-
-
           <codemirror
             ref="cm"
             v-model="output"
             :options="cmOptions"
           ></codemirror>
-        
         </div>
-        
-
-
       </el-tab-pane>
 
       <el-tab-pane label="算法监控" name="second">
         <iframe class="iframe" v-bind:src="url" scrolling="no" frameborder="0">
-
         </iframe>
-        
-        <!-- <img class="iframe" src="./tensorboard.png"> -->
-        
       </el-tab-pane>
 
       <el-tab-pane label="算法代码" name="third">
-        <el-table :data="pythonFiles" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
+        <el-table :data="pythonFiles" border v-loading="dataListLoading"
           style="width: 100%;">
           <el-table-column type="selection" header-align="center" align="center" width="50">
           </el-table-column>
@@ -63,7 +51,7 @@
             </template>
           </el-table-column>
         </el-table>
-        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
+        <el-pagination :current-page="pageIndex"
           :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="pythonFilesTotalPage"
           layout="total, sizes, prev, pager, next, jumper">
         </el-pagination>
@@ -71,7 +59,7 @@
 
 
       <el-tab-pane label="数据集" name="forth">
-        <el-table :data="datasetFiles" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
+        <el-table :data="datasetFiles" border v-loading="dataListLoading"
           style="width: 100%;">
           <el-table-column type="selection" header-align="center" align="center" width="50">
           </el-table-column>
@@ -92,13 +80,13 @@
             </template>
           </el-table-column>
         </el-table>
-        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
+        <el-pagination :current-page="pageIndex"
           :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="datasetFilesTotalPage"
           layout="total, sizes, prev, pager, next, jumper">
         </el-pagination>
       </el-tab-pane>
     </el-tabs>
-    <TrainFileWatch v-if="trainFileWatchVisible" ref="trainFileWatch"></TrainFileWatch>
+    <TrainFileWatch ref="trainFileWatch"></TrainFileWatch>
   </div>
 </template>
 
@@ -175,7 +163,6 @@ export default {
   },
   data() {
     return {
-      trainFileWatchVisible:false,
       dataList: [],
       pythonFiles:[],
       datasetFiles:[],
@@ -183,7 +170,6 @@ export default {
       pageSize: 10,
       pythonFilesTotalPage: 0,
       datasetFilesTotalPage: 0,
-
       algorithmNameToVersion: null,
       verisionToFile:null,
       loading:true,
@@ -192,7 +178,8 @@ export default {
       algorithmTrainingId:null,
       missStatus:null,
       output:"",
-      url:"",
+      url: undefined,
+      dataListLoading: false,
       cmOptions: {
           // 语言及语法模式
           //mode: 'text/x-python',
@@ -219,158 +206,197 @@ export default {
     };
   },
   activated() {
-    let algorithmTrainingId=this.$route.query.algorithmTrainingId;
-    let missStatus=this.$route.query.missStatus;
-    this.init(algorithmTrainingId,missStatus);
+    this.init(this.$route.query.algorithmTrainingId, this.$route.query.missStatus);
     //如果状态不是待开始或者暂停中,就去轮询访问日志
-    if(missStatus!=1&&missStatus!=7){
-      this.timer=window.setInterval(()=>{
-      setTimeout(()=>{
-        console.log("执行定时任务");
-        this.getOutput();
-      },0)
-    },1000);
-    }
+    // if(missStatus!=1&&missStatus!=7){
+    //   this.timer=window.setInterval(()=>{
+    //   setTimeout(()=>{
+    //     console.log("执行定时任务");
+    //     this.getOutput();
+    //   },0)
+    // },1000);
+    // }
     
   }, 
   methods: {
-      init(id,missStatus){
-          this.loading=true;
-          this.activeName="first";
-          this.algorithmTrainingId=id;
-          this.missStatus=missStatus;
-          this.output="";
-          this.pythonFiles=[];
-          this.datasetFiles=[];
-          if(missStatus!=1)
-            this.getOutput();
-          else{
-            this.output="该训练任务未运行";
-            this.loading=false;
-          };
-        //根据algorithmTrainingId获得algId及versionId
-        this.$http({
-          url:this.$http.adornUrl('/algstrain/getAlgIdVersionId'),
-          method:'get',
-          params:this.$http.adornParams({
-            algorithmTrainingId:this.algorithmTrainingId
-          }),
-        }).then(({data})=>{
-          this.algorithmNameToVersion=data.algorithmNameToVersion;
-          this.verisionToFile=data.verisionToFile;
-          this.getDataList();
-        });
-        //this.getDataList();
+    // 初始化方法
+    init(id, missStatus) {
+      this.loading = true;
+      this.activeName = "first";
+      this.algorithmTrainingId = id;
+      this.missStatus = missStatus;
+      this.output = "";
+      this.pythonFiles = [];
+      this.datasetFiles = [];
+      if (missStatus != 1) {
+        this.getOutput();
+      }
+      else {
+        this.output = "该训练任务未运行";
+        this.loading = false;
+      };
+      // // 根据algorithmTrainingId获得algId及versionId
+      // this.$http({
+      //   url:this.$http.adornUrl('/algstrain/getAlgIdVersionId'),
+      //   method:'get',
+      //   params:this.$http.adornParams({
+      //     algorithmTrainingId:this.algorithmTrainingId
+      //   }),
+      // }).then(({data})=>{
+      //   console.log('data :>> ', data);
+      //   this.algorithmNameToVersion=data.algorithmNameToVersion;
+      //   this.verisionToFile=data.verisionToFile;
+      //   // this.getDataList();
+      // });
+      // //this.getDataList();
     },
     
     redirectHandle() {
       this.$router.replace({ path: "/alg-algs" });
     },
-    getOutput(){
+    // 获取输出日志
+    getOutput() {
       this.$http({
-          url:this.$http.adornUrl('/algstrain/getOutput'),
-          method:'get',
-          params:this.$http.adornParams({
-            algorithmTrainingId:this.algorithmTrainingId
-          }),
-        }).then(({data})=>{
-          this.$nextTick(()=>{
-              this.output=data.output;
-              this.loading=false;
-            });
-        });
+        url:this.$http.adornUrl('/algstrain/getOutput'),
+        method:'get',
+        params:this.$http.adornParams({
+          algorithmTrainingId:this.algorithmTrainingId
+        }),
+      }).then(({data})=>{
+        this.output=data.output;
+        this.loading=false;
+      });
     },
-    
     handleClick(tab, event) {
-        console.log(tab, event);
-        if(tab.name == 'second'){
-        	console.log("切换到算法监控")
+      if (tab.name === "first") {
+        this.getOutput();
+      } else if (tab.name === "second") {
+        if (this.url == undefined || this.url == null) {
           this.$http({
             url: this.$http.adornUrl("/algstrain/info/" + this.algorithmTrainingId),
             method: "get",
             params: this.$http.adornParams(),
           }).then(({ data }) => {
             if (data && data.code === 0) {
-              this.url=data.algTrain.ipAddress;
-
+              this.url = data.algTrain.ipAddress;
             }
           });
         }
+      } else {
+        if (this.pythonFiles.length == 0 || this.pythonFiles == null) {
+          this.getDataList();
+        }
+      }
     },
 
     // 获取代码文件列表
-    getDataList() {
-        this.dataListLoading = true;
-        this.$http({
-          url: this.$http.adornUrl("/algstrain/listFiles/"),
-          method: "get",
-          params: this.$http.adornParams({
-            page: this.pageIndex,
-            limit: this.pageSize,
-            algorithmNameToVersion:this.algorithmNameToVersion,
-            verisionToFile:this.verisionToFile
-          }),
-        }).then(({ data }) => {
-          if (data && data.code === 0) {
-            this.pythonFiles = data.pythonFiles;
-            this.datasetFiles = data.datasetFiles;
-            this.pythonFilesTotalPage = data.pythonFiles.length;
-          } else {
-            this.pythonFiles = [];
-            this.datasetFiles = [];
-            this.pythonFilesTotalPage = 0;
-            this.datasetFilesTotalPage = 0;
-          }
-          this.dataListLoading = false;
-        });
+    async getDataList() {
+      this.dataListLoading = true;
+      const { data } = await this.$http({
+        url:this.$http.adornUrl('/algstrain/getAlgIdVersionId'),
+        method:'get',
+        params:this.$http.adornParams({
+          algorithmTrainingId: this.algorithmTrainingId
+        }),
+      });
+
+      if (data.code != 0) {
+        this.dataListLoading = false;
+        return;
+      }
+      // console.log('data :>> ', data);
+      this.algorithmNameToVersion = data.algTrain.algorithmId;
+      this.verisionToFile = data.algTrain.versionId;
+      this.algFrameId = data.algTrain.algFrameId;
+      this.categoryName = data.category.categoryName;
+      const res = await this.$http({
+        url: this.$http.adornUrl("/algstrain/listFiles/"),
+        method: "get",
+        params: this.$http.adornParams({
+          page: this.pageIndex,
+          limit: this.pageSize,
+          algorithmNameToVersion: this.algorithmNameToVersion,
+          verisionToFile: this.verisionToFile,
+          algFrameId: this.algFrameId
+        }),
+      })
+      if (res.data.code != 0) {
+        this.dataListLoading = false;
+        this.pythonFiles = [];
+        this.datasetFiles = [];
+        this.pythonFilesTotalPage = 0;
+        this.datasetFilesTotalPage = 0;
+        return;
+      }
+      this.pythonFiles = res.data.pythonFiles;
+      this.datasetFiles = res.data.datasetFiles;
+      this.pythonFilesTotalPage = res.data.pythonFiles.length;
+      this.dataListLoading = false;
+      // this.dataListLoading = true;
+      // this.$http({
+      //   url: this.$http.adornUrl("/algstrain/listFiles/"),
+      //   method: "get",
+      //   params: this.$http.adornParams({
+      //     page: this.pageIndex,
+      //     limit: this.pageSize,
+      //     algorithmNameToVersion:this.algorithmNameToVersion,
+      //     verisionToFile:this.verisionToFile
+      //   }),
+      // }).then(({ data }) => {
+      //   if (data && data.code === 0) {
+      //     this.pythonFiles = data.pythonFiles;
+      //     this.datasetFiles = data.datasetFiles;
+      //     this.pythonFilesTotalPage = data.pythonFiles.length;
+      //   } else {
+      //     this.pythonFiles = [];
+      //     this.datasetFiles = [];
+      //     this.pythonFilesTotalPage = 0;
+      //     this.datasetFilesTotalPage = 0;
+      //   }
+      //   this.dataListLoading = false;
+      // });
     },
 
     //查看代码文件
-    watchFile(fileName){
-      this.trainFileWatchVisible=true;
-      this.$nextTick(() => {
-        this.$refs.trainFileWatch.init(this.algorithmNameToVersion,this.verisionToFile,fileName);
-      });
+    watchFile(fileName) {
+      this.$refs.trainFileWatch.init(this.algorithmNameToVersion, this.verisionToFile, this.algFrameId, fileName);
     },
     //下载数据集
-    downloadDataset(filename){
+    downloadDataset(filename) {
       this.$http({
-          url:this.$http.adornUrl('/dataset/downloadDataset'),
-          method:'get',
-          params:this.$http.adornParams({
-            datasetName:filename
-          }),
-        }).then(({data})=>{
-          if(data&&data.code===0){
-              window.location.href=data.downloadUrl;
-          }else{
-              Message.error('下载失败');
-          }
-        });
+        url:this.$http.adornUrl('/dataset/downloadDataset'),
+        method:'get',
+        params:this.$http.adornParams({
+          datasetName: filename,
+          categoryName: this.categoryName || "",
+          bucketName: "algorithm"
+        }),
+      }).then(({data}) => {
+        if (data && data.code === 0) {
+            window.location.href = data.downloadUrl;
+        } else {
+            Message.error('下载失败');
+        }
+      });
     },
-    
   },
-  
   mounted(){
-    
     this.$refs.cm.codemirror.setSize("auto", (document.documentElement.clientHeight - 200) + "px");
     this.$nextTick(() => {
-    window.addEventListener('resize', () => {
+      window.addEventListener('resize', () => {
         //监听浏览器窗口大小改变
         //浏览器变化执行动作
         this.$refs.cm.codemirror.setSize("auto", (document.documentElement.clientHeight - 200) + "px")
       });
-    });
-    
-    
+    }); 
   },
   //切换路由时,清楚定时器
   beforeRouteLeave(to, from, next){
     next();
-    if (this.timer) {
-      clearInterval(this.timer);
-      this.timer = null;
-    }
+    // if (this.timer) {
+    //   clearInterval(this.timer);
+    //   this.timer = null;
+    // }
   },
 
 };

+ 2 - 0
src/views/modules/visi/com/single-file-upLoad.vue

@@ -62,6 +62,7 @@ export default {
   },
   methods: {
     close() {
+      this.fileList = [];
       this.$router.replace({ path: "/visi-dataset" });
     },
     upLoadNumberWrong() {
@@ -96,6 +97,7 @@ export default {
           message: "上传完毕",
           type: "success"
         });
+        this.fileList = [];
         this.$router.replace({ path: "/visi-dataset" });
       } else {
         Message({

+ 45 - 14
src/views/modules/visi/dataset.vue

@@ -68,7 +68,7 @@
           <el-button v-if="isAuth('dataset:delete')" type="text" size="small"
             @click="deleteHandle(scope.row)">
             删除</el-button>
-          <el-button type="text" size="small" @click="downloadDataset(scope.row.datasetName)">下载
+          <el-button type="text" size="small" @click="downloadDataset(scope.row.datasetName, scope.row.categoryName)">下载
           </el-button>
         </template>
       </el-table-column>
@@ -565,7 +565,7 @@ export default {
       }).catch(() => {})
     },
     // 下载数据集
-    downloadDataset (filename) {
+    downloadDataset (filename, categoryName) {
       MessageBox.confirm(`是否下载该数据集?`, '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -575,19 +575,50 @@ export default {
         if (this.status === '2') {
           urls = this.$http.adornUrl('/datasetdy/downloadDataset')
         }
-        this.$http({
-          url: urls,
-          method: 'get',
-          params: this.$http.adornParams({
-            datasetName: filename + '.csv'
+        if (categoryName === "文件夹") {
+          this.$http({
+            url: urls,
+            method: 'get',
+            params: this.$http.adornParams({
+              datasetName: categoryName.includes("文件") ? filename : filename + '.csv',
+              categoryName
+            })
+          }).then(({data}) => {
+            const byteCharacters = atob(data.download);
+            const byteNumbers = new Array(byteCharacters.length);
+            for (let i = 0; i < byteCharacters.length; i++) {
+              byteNumbers[i] = byteCharacters.charCodeAt(i);
+            }
+            const byteArray = new Uint8Array(byteNumbers);
+            const blob = new Blob([byteArray], { type: 'application/zip' });
+            // 创建一个临时URL  
+            const url = window.URL.createObjectURL(blob);
+            // 创建一个a标签并设置下载属性
+            const link = document.createElement('a');
+            link.href = url;
+            link.download = filename + ".zip";
+            // 模拟点击下载链接
+            link.click();
+
+            // 释放临时的 URL 对象
+            window.URL.revokeObjectURL(url);
           })
-        }).then(({data}) => {
-          if (data && data.code === 0) {
-            window.location.href = data.downloadUrl
-          } else {
-            Message.error('下载失败 : ' + data.msg)
-          }
-        })
+        } else {
+          this.$http({
+            url: urls,
+            method: 'get',
+            params: this.$http.adornParams({
+              datasetName: categoryName.includes("文件") ? filename : filename + '.csv',
+              categoryName
+            })
+          }).then(({data}) => {
+            if (data && data.code === 0) {
+              window.location.href = data.downloadUrl
+            } else {
+              Message.error('下载失败 : ' + data.msg)
+            }
+          })
+        }
       }).catch(() => {})
     },
     // 弹出数据集预处理框