zhangjie před 3 roky
rodič
revize
82103bd5ba

+ 11 - 2
src/modules/base/api.js

@@ -102,8 +102,17 @@ export const updateTimeTask = datas => {
 export const businessDataList = datas => {
   return $postParam("/api/exam_sync_total/page", datas);
 };
-export const downloadBusinessData = id => {
-  return $postParam("/api/exam_sync_total/download", { id });
+export const manualSync = () => {
+  return $postParam("/api/exam_sync_total/manual_sync", {});
+};
+export const downloadBusinessData = (id, writeLog) => {
+  return $postParam(
+    "/api/exam_sync_total/download",
+    { id, writeLog },
+    {
+      responseType: "blob"
+    }
+  );
 };
 export const useSceneList = datas => {
   return $postParam("/api/exam_download_record/list_use_scene", datas);

+ 1 - 1
src/modules/base/components/ModifyTask.vue

@@ -84,7 +84,7 @@ const initModalForm = {
 };
 
 export default {
-  name: "modify-template",
+  name: "modify-task",
   props: {
     instance: {
       type: Object,

+ 27 - 12
src/modules/base/views/BusinessDataManage.vue

@@ -7,6 +7,7 @@
             v-model="filter.syncDate"
             type="date"
             value-format="timestamp"
+            placeholder="同步日期"
           >
           </el-date-picker>
         </el-form-item>
@@ -18,6 +19,7 @@
         <el-button
           icon="el-icon-circle-plus-outline"
           type="primary"
+          :loading="downloading"
           @click="toSync"
         >
           人工同步数据
@@ -47,6 +49,7 @@
         <el-table-column class-name="action-column" label="操作" width="100px">
           <template slot-scope="scope">
             <el-button
+              v-if="scope.row.downloadStatus"
               class="btn-primary"
               type="text"
               @click="toDownload(scope.row)"
@@ -72,7 +75,8 @@
 </template>
 
 <script>
-import { businessDataList, downloadBusinessData } from "../api";
+import { businessDataList, downloadBusinessData, manualSync } from "../api";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "business-data-manage",
@@ -84,7 +88,7 @@ export default {
       current: 1,
       size: this.GLOBAL.pageSize,
       total: 0,
-      loading: false,
+      downloading: false,
       dataList: []
     };
   },
@@ -109,18 +113,29 @@ export default {
     search() {
       this.toPage(1);
     },
-    toSync() {},
+    async toSync() {
+      if (this.downloading) return;
+      this.downloading = true;
+      await manualSync().catch(() => {});
+      this.downloading = false;
+    },
     async toDownload(row) {
-      if (this.loading) return;
-      this.loading = true;
-      const data = await downloadBusinessData(row.id).catch(() => {});
-      this.loading = false;
-      if (!data) return;
+      if (this.downloading) return;
+      this.downloading = true;
 
-      this.$message.success(
-        "已开始下载,下载需要时间,请稍后到【下载列表】模块中查看数据"
-      );
-      this.getList();
+      const res = await downloadByApi(() => {
+        return downloadBusinessData(row.id, true);
+      }).catch(e => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
+
+      // this.$message.success(
+      //   "已开始下载,下载需要时间,请稍后到【下载列表】模块中查看数据"
+      // );
     }
   }
 };

+ 32 - 16
src/modules/base/views/DownloadManage.vue

@@ -4,7 +4,7 @@
       <el-form ref="FilterForm" label-position="left" label-width="90px" inline>
         <el-form-item label="下载时间:">
           <el-date-picker
-            v-model="filter.operateDate"
+            v-model="filter.operateTime"
             type="date"
             placeholder="下载时间"
             value-format="timestamp"
@@ -22,7 +22,13 @@
           </el-select>
         </el-form-item>
         <el-form-item label="下载用途:">
-          <el-select v-model="filter.useScene" placeholder="下载用途" clearable>
+          <el-select
+            v-model="filter.useScene"
+            placeholder="下载用途"
+            clearable
+            multiple
+            class="width-400"
+          >
             <el-option
               v-for="item in useScenes"
               :key="item.name"
@@ -55,18 +61,18 @@
           width="70"
           :index="indexMethod"
         ></el-table-column>
-        <el-table-column prop="operateDate" label="下载时间">
+        <el-table-column prop="operateTime" label="下载时间" width="170">
           <span slot-scope="scope">{{
-            scope.row.operateDate | timestampFilter
+            scope.row.operateTime | timestampFilter
           }}</span>
         </el-table-column>
         <el-table-column prop="userName" label="下载人员"></el-table-column>
-        <el-table-column prop="fileName" label="文件" min-width="200">
+        <el-table-column prop="fileName" label="文件" min-width="150">
           <template slot-scope="scope">
             <div
               class="cont-link"
               title="点击下载文件"
-              @click="toDownloadFile(scope.row)"
+              @click="toDownload(scope.row)"
             >
               {{ scope.row.fileName }}
             </div>
@@ -109,8 +115,9 @@
 
 <script>
 import { USE_TYPE, BOOLEAN_TYPE } from "../../../constants/enumerate";
-import { downloadList, useSceneList } from "../api";
+import { downloadList, useSceneList, downloadBusinessData } from "../api";
 import SignDownloadData from "../components/SignDownloadData.vue";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "student-manage",
@@ -118,9 +125,9 @@ export default {
   data() {
     return {
       filter: {
-        operateDate: "",
+        operateTime: "",
         used: null,
-        useScene: null
+        useScene: []
       },
       current: 1,
       size: this.GLOBAL.pageSize,
@@ -130,7 +137,8 @@ export default {
       curRow: {},
       BOOLEAN_TYPE,
       USE_TYPE,
-      multipleSelection: []
+      multipleSelection: [],
+      downloading: false
     };
   },
   mounted() {
@@ -148,6 +156,7 @@ export default {
         pageNumber: this.current,
         pageSize: this.size
       };
+      datas.useScene = datas.useScene.join();
       const data = await downloadList(datas);
       this.dataList = data.records;
       this.total = data.total;
@@ -168,12 +177,19 @@ export default {
       }
       this.$refs.SignDownloadData.open();
     },
-    toDownloadFile(row) {
-      if (!row.filePath) {
-        this.$message.error("文件路径不存在!");
-        return;
-      }
-      window.open(row.filePath);
+    async toDownload(row) {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return downloadBusinessData(row.examSyncTotalId, false);
+      }).catch(e => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     }
   }
 };

+ 1 - 1
src/modules/base/views/TimeTaskManage.vue

@@ -102,7 +102,7 @@
     <modify-task
       ref="ModifyTask"
       :instance="curRow"
-      :modified="getList"
+      @modified="getList"
     ></modify-task>
   </div>
 </template>

+ 8 - 14
src/modules/login/api.js

@@ -4,36 +4,30 @@ export const login = datas => {
   return $post("/api/common/login", datas);
 };
 export const getSmsCode = datas => {
-  return $post("/api/admin/common/get_verify_code", datas);
+  return $post("/api/common/get_verify_code", datas);
 };
 export const getSmsCodeForBind = datas => {
-  return $post("/api/admin/common/get_verify_code", datas);
+  return $post("/api/common/get_verify_code", datas);
 };
 export const modifyPwd = datas => {
-  return $post("/api/admin/common/get_system_time", datas);
+  return $post("/api/common/get_system_time", datas);
 };
 
 export const logout = () => {
-  return $post("/api/admin/common/logout", {});
-};
-export const sysMenu = () => {
-  return $postParam("/api/admin/common/get_menu", {});
+  return $post("/api/common/logout", {});
 };
 export const attachmentPreview = id => {
-  return $postParam("/api/admin/common/file/preview", { id });
+  return $postParam("/api/common/file/preview", { id });
 };
 export const attachmentDetail = id => {
-  return $postParam("/api/admin/common/file/get_one", { id });
+  return $postParam("/api/common/file/get_one", { id });
 };
 export const attachmentDownload = ({ id, type }) => {
-  return $postParam("/api/admin/common/file/download", { id, type });
+  return $postParam("/api/common/file/download", { id, type });
 };
 export const getEnums = type => {
-  return $postParam("/api/admin/common/get_enums", { type });
+  return $postParam("/api/common/get_enums", { type });
 };
 export const schoolList = () => {
   return $postParam("/api/basic_school/list", {});
 };
-export const getSchoolInfo = code => {
-  return $postParam("/api/admin/common/school/query_by_school_code", { code });
-};