natasha 2 роки тому
батько
коміт
89a04c7527
1 змінених файлів з 47 додано та 4 видалено
  1. 47 4
      src/views/organize_manage/BatchImport.vue

+ 47 - 4
src/views/organize_manage/BatchImport.vue

@@ -61,7 +61,7 @@
         <template v-else>
             <div class="log-box" v-if="resultData">
                 <p>上传文件 {{fileList[0].name}}</p>
-                <p>用时 00:02:32</p>
+                <p>用时 {{realFormatSecond(uploadTime)}}</p>
                 <p>成功上传 <span class="color-green">{{resultData.success_count}}</span> 条记录,失败 <span class="color-red">{{resultData.cur_count}}</span> 条</p>
                 <div class="border"></div>
                 <p :class="[item.is_success==='true'?'color-green':'color-red']" v-for="(item,index) in execute_log_list" :key="index">
@@ -72,7 +72,7 @@
     </div>
     <div class="batch-box-bottom">
         <template v-if="tabsIndex===0">
-            <a class="downLoad" target="_blank" :href="resultData.execute_report_file_url">下载模板</a>
+            <a class="downLoad" target="_blank" :href="''">下载模板</a>
             <div class="btn-box">
                 <el-button @click="closeDialog" size="small">取消</el-button>
                 <el-button type="primary" :key="3" :disabled="!uploadFlag&&!file_id||(resultData&&resultData.is_finish==='true')" v-if="!uploading&&!isStop&&(resultData&&resultData.is_finish==='true'||!resultData)" @click="handleUpload" v-loading="loading"><svg-icon icon-class="upload"></svg-icon>开始上传</el-button>
@@ -115,6 +115,8 @@ export default {
       timer: null,
       resultData: null, // 上传结果数据
       execute_log_list: [], // 日志列表
+      uploadTime: 0,
+      uploadTimer: null,
     };
   },
   watch: {},
@@ -147,10 +149,14 @@ export default {
         return false; // 必须返回false
       }
       this.alreadyFile = true
+      this.uploadTimer = setInterval(() => {
+        this.uploadTime++    
+      }, 1000);
     },
     handleSuccess(response, file, fileList) {
       if (response.status == 1) {
         this.progressFlag = false
+        clearInterval(this.uploadTimer);
         this.file_id = response.file_info_list[0].file_id
         this.uploadFlag = true
         this.fileList = fileList
@@ -176,6 +182,8 @@ export default {
         this.progressFlag = false
         this.percentage = 0
         this.alreadyUpload = ''
+        this.uploadTime = 0
+        clearInterval(this.uploadTimer);
       }
     },
     handleErmoveFile(){
@@ -194,7 +202,7 @@ export default {
         this.resultData = null
         this.sameUser = 'false'
         this.coverUser = []
-        this.$forceUpdate()
+        this.uploadTime = 0
     },
     uploadVideoProcess(event, file, fileList) {
         this.fileList = fileList
@@ -310,7 +318,42 @@ export default {
     handleExportLog(){
         let href = this.resultData.execute_report_file_url
         window.open(href, "_blank");
-    }
+    },
+    // 将整数转换成 时:分:秒的格式
+    realFormatSecond(value) {
+      let theTime = parseInt(value); // 秒
+      let theTime1 = 0; // 分
+      let theTime2 = 0; // 小时
+      if (theTime > 60) {
+        theTime1 = parseInt(theTime / 60);
+        theTime = parseInt(theTime % 60);
+        if (theTime1 > 60) {
+          theTime2 = parseInt(theTime1 / 60);
+          theTime1 = parseInt(theTime1 % 60);
+        }
+      }
+      let result = String(parseInt(theTime));
+      if (result < 10) {
+        result = "0" + result;
+      }
+      if (theTime1 > 0) {
+        result = String(parseInt(theTime1)) + ":" + result;
+        if (theTime1 < 10) {
+          result = "0" + result;
+        }
+      } else {
+        result = "00:" + result;
+      }
+      if (theTime2 > 0) {
+        result = String(parseInt(theTime2)) + ":" + result;
+        if (theTime2 < 10) {
+          result = "0" + result;
+        }
+      } else {
+        result = "00:" + result;
+      }
+      return result;
+    },
   },
   created() {
   },