zhangjie 2 سال پیش
والد
کامیت
cbda1df58a

BIN
extra/database/client.rdb


+ 6 - 0
src/App.vue

@@ -5,8 +5,14 @@
 </template>
 
 <script>
+import initStoreMixin from "./mixins/initStoreMixin";
+
 export default {
   name: "app",
+  mixins: [initStoreMixin],
+  created() {
+    this.initStore();
+  },
   data() {
     return {};
   }

+ 0 - 14
src/mixins/initStoreMixin.js

@@ -11,20 +11,6 @@ export default {
     async setLastLoginUser(user) {
       await db.setDict("lastLoginUser", JSON.stringify(user));
     },
-    async initStartCountTime(subjects) {
-      const storeStartCountTime = await db.getDict("startCountTime", "");
-
-      let startCountTime = {};
-      if (storeStartCountTime) {
-        startCountTime = JSON.parse(storeStartCountTime);
-        this.$store.commit("client/setStartCountTime", startCountTime);
-      } else {
-        subjects.map(subject => {
-          startCountTime[subject.id] = 0;
-        });
-        this.$store.dispatch("client/updateStartCountTime", startCountTime);
-      }
-    },
     async initStore() {
       const storeDict = await db.getAllDict();
       const needInitDict = [

+ 1 - 1
src/mixins/uploadTaskMixin.js

@@ -41,7 +41,7 @@ export default {
           this.taskSetTs.push(
             setTimeout(() => {
               this.initUploadTask();
-            }, 0.5 * 1000)
+            }, 1 * 1000)
           );
         },
         uploadErrorCallBack: curUploadTask => {

+ 23 - 18
src/modules/client/components/ScanTaskDialog.vue

@@ -6,7 +6,7 @@
     width="550px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
-    :show-close="false"
+    :show-close="true"
     append-to-body
     @open="visibleChange"
   >
@@ -14,10 +14,10 @@
       ref="modalFormComp"
       :model="modalForm"
       :rules="rules"
-      label-width="120"
+      label-width="120px"
     >
       <el-form-item label="课程名称:">
-        {{ task.courseName }}({{ task.courseCode }})
+        {{ task.courseName }}
       </el-form-item>
       <el-form-item prop="preScanCount" label="预扫张数:">
         <el-input-number
@@ -80,6 +80,7 @@ export default {
     return {
       modalIsShow: false,
       loading: false,
+      user: this.$ls.get("user", {}),
       scanStatus: "INIT", // INIT:初始状态,START:已开始,PAUSE:已暂停
       modalForm: {
         preScanCount: undefined
@@ -98,8 +99,8 @@ export default {
     };
   },
   computed: {
-    user() {
-      return this.$store.state.user;
+    taskBound() {
+      return this.user.id === this.task.scanUserId;
     }
   },
   beforeDestroy() {
@@ -130,10 +131,12 @@ export default {
       if (this.loading) return;
       this.loading = true;
 
-      await bingScanUser({
-        paperScanTaskId: this.task.id,
-        userId: this.user.id
-      });
+      if (!this.taskBound) {
+        await bingScanUser({
+          paperScanTaskId: this.task.id,
+          userId: this.user.id
+        });
+      }
 
       this.scaningImageList = [];
       this.scanStatus = "START";
@@ -153,7 +156,7 @@ export default {
       setTimeout(() => {
         this.scanStatus = "PAUSE";
         console.log("扫描仪停止");
-      }, 5 * 1000);
+      }, 1 * 1000);
     },
     async confirm() {
       this.scaningImageList = getPreUploadFilesAutoSerial(this.GLOBAL.input);
@@ -200,19 +203,21 @@ export default {
     async saveScanImage() {
       for (let i = 0, len = this.scaningImageList.length; i < len; i++) {
         const files = this.scaningImageList[i];
-        const ouputImageList = saveOutputImage([
-          files.frontFile,
-          files.versoFile
-        ]);
+        const ouputImageList = saveOutputImage(
+          [files.frontFile, files.versoFile],
+          {
+            taskId: this.task.id
+          }
+        );
         const fileInfo = {
           taskId: this.task.id,
-          taskName: this.task.name,
-          courseCode: this.task.courseCode,
+          taskName: this.task.scanTaskName,
+          courseCode: "",
           courseName: this.task.courseName,
-          teachingClassName: this.task.teachingClassName,
+          teachingClassName: this.task.teachClazzName,
           frontOriginImgPath: ouputImageList[0],
           versoOriginImgPath: ouputImageList[1],
-          clientUserId: this.user.userId,
+          clientUserId: this.user.id,
           clientUsername: this.user.name,
           clientUserLoginTime: this.user.loginTime
         };

+ 12 - 10
src/modules/client/components/ScanTaskProcessDialog.vue

@@ -14,10 +14,10 @@
       ref="modalFormComp"
       :model="modalForm"
       :rules="rules"
-      label-width="120"
+      label-width="120px"
     >
       <el-form-item label="课程名称:">
-        {{ task.courseName }}({{ task.courseCode }})
+        {{ task.courseName }}
       </el-form-item>
       <el-form-item prop="preScanCount" label="预扫张数:">
         <el-input-number
@@ -201,19 +201,21 @@ export default {
     async saveScanImage() {
       for (let i = 0, len = this.scaningImageList.length; i < len; i++) {
         const files = this.scaningImageList[i];
-        const ouputImageList = saveOutputImage([
-          files.frontFile,
-          files.versoFile
-        ]);
+        const ouputImageList = saveOutputImage(
+          [files.frontFile, files.versoFile],
+          {
+            taskId: this.task.id
+          }
+        );
         const fileInfo = {
           taskId: this.task.id,
-          taskName: this.task.name,
-          courseCode: this.task.courseCode,
+          taskName: this.task.scanTaskName,
+          courseCode: "",
           courseName: this.task.courseName,
-          teachingClassName: this.task.teachingClassName,
+          teachingClassName: this.task.teachClazzName,
           frontOriginImgPath: ouputImageList[0],
           versoOriginImgPath: ouputImageList[1],
-          clientUserId: this.user.userId,
+          clientUserId: this.user.id,
           clientUsername: this.user.name,
           clientUserLoginTime: this.user.loginTime
         };

+ 19 - 15
src/modules/client/views/TaskManage.vue

@@ -64,32 +64,29 @@
     <div class="part-box part-box-pad">
       <el-table ref="TableList" size="medium" :data="dataList">
         <el-table-column
-          prop="taskId"
+          prop="id"
           label="任务ID"
           min-width="160"
         ></el-table-column>
         <el-table-column
-          prop="taskName"
+          prop="scanTaskName"
           label="任务名称"
           min-width="160"
         ></el-table-column>
-        <el-table-column prop="courseName" label="课程(代码)" min-width="200">
-          <template slot-scope="scope">
-            {{ scope.row.courseName }}({{ scope.row.courseCode }})
-          </template>
+        <el-table-column prop="courseName" label="课程" min-width="200">
         </el-table-column>
         <el-table-column
-          prop="userName"
+          prop="teachClazzName"
           label="教学班"
           min-width="100"
         ></el-table-column>
         <el-table-column
-          prop="userName"
+          prop="studentCount"
           label="学生数"
           min-width="100"
         ></el-table-column>
         <el-table-column
-          prop="userName"
+          prop="scanCount"
           label="已扫描数量"
           min-width="100"
         ></el-table-column>
@@ -173,17 +170,24 @@ export default {
       teachingClassList: []
     };
   },
+  mounted() {
+    this.search();
+  },
   methods: {
     search() {
       this.cacheData[this.curTab] = {};
       this.toPage(1);
     },
     async getList() {
-      const datas = {
-        ...this.filter,
+      let datas = {
         pageNumber: this.current,
         pageSize: this.size
       };
+      if (this.curTab === "all") {
+        datas = { ...datas, ...this.filter };
+      } else {
+        datas = { ...datas, isMine: true };
+      }
       const data = await taskListPage(datas);
       this.dataList = data.records;
       this.total = data.total;
@@ -209,11 +213,11 @@ export default {
       } else {
         this.toPage(1);
       }
+    },
+    toScan(row) {
+      this.curRow = row;
+      this.$refs.ScanTaskProcessDialog.open();
     }
-  },
-  toScan(row) {
-    this.curRow = row;
-    this.$refs.ScanTaskProcessDialog.open();
   }
 };
 </script>

+ 1 - 7
src/modules/login/views/Login.vue

@@ -50,14 +50,12 @@
 
 <script>
 import { password } from "@/plugins/formRules";
-import initStoreMixin from "../../../mixins/initStoreMixin";
 import { formatDate } from "../../../plugins/utils";
 import { login } from "../api";
 import { Base64 } from "@/plugins/crypto";
 
 export default {
   name: "login",
-  mixins: [initStoreMixin],
   data() {
     return {
       loginModel: {
@@ -89,13 +87,8 @@ export default {
   },
   mounted() {
     this.$ls.clear();
-    this.initData();
   },
   methods: {
-    async initData() {
-      await this.initStore();
-      this.loginModel.schoolCode = this.$ls.get("schoolCode");
-    },
     toSet() {
       this.$router.push({ name: "Setting" });
     },
@@ -105,6 +98,7 @@ export default {
         this.$message.error("请先配置域名!");
         return;
       }
+      this.loginModel.schoolCode = this.$ls.get("schoolCode");
 
       const valid = await this.$refs.loginForm.validate().catch(() => {});
       if (!valid) return;

+ 2 - 2
src/plugins/axios.js

@@ -32,7 +32,7 @@ var queue = [];
 axios.interceptors.request.use(
   config => {
     // 显示loading提示
-    if (!queue.length && !config["silentRequest"]) {
+    if (!queue.length && !config["slientRequest"]) {
       load = Message({
         customClass: "el-message-loading",
         iconClass: "el-message__icon el-icon-loading",
@@ -141,7 +141,7 @@ const mdData = datas => {
  * @param {Object} error 请求失败时的错误信息
  */
 const errorCallback = (error, config = {}) => {
-  const slientRequest = config && config["silentRequest"];
+  const slientRequest = config && config["slientRequest"];
   if (slientRequest) {
     return error;
   }

+ 4 - 2
src/plugins/imageOcr.js

@@ -8,6 +8,7 @@ const path = require("path");
  * @param {String} paperInfo 保持文件名称
  */
 export function saveOutputImage(scaningImageList, paperInfo) {
+  console.log(scaningImageList);
   let outputOriginPaths = [];
   for (let i = 0; i < scaningImageList.length; i++) {
     const imagePath = scaningImageList[i];
@@ -20,6 +21,7 @@ export function saveOutputImage(scaningImageList, paperInfo) {
 }
 
 function saveOriginImage(imagePath, paperInfo) {
+  console.log(imagePath);
   const outputDir = path.join(getOutputDir("origin"), paperInfo.taskId + "");
 
   if (!fs.existsSync(outputDir)) makeDirSync(outputDir);
@@ -62,8 +64,8 @@ export function getPreUploadFilesAutoSerial(dir) {
   let imageList = [];
   const len = Math.ceil(files.length / 2);
   for (let i = 0; i < len; i++) {
-    const frontFile = files[i];
-    const versoFile = files[i + 1];
+    const frontFile = path.join(dir, files[2 * i]);
+    const versoFile = path.join(dir, files[2 * i + 1]);
     imageList.push({
       frontFile,
       versoFile

+ 16 - 3
src/plugins/imageUpload.js

@@ -23,7 +23,7 @@ function toUploadImg(options) {
   formData.append("versoMd5", versoMd5);
   formData.append("versoFile", versoFile);
 
-  formData.append("taskId", options.taskId);
+  formData.append("paperScanTaskId", options.taskId);
   formData.append("scanUserId", options.clientUserId);
 
   return uploadFormalImage(formData);
@@ -49,6 +49,8 @@ function getFileAdnMd5(filepath) {
 //   return fsHash.digest("hex");
 // }
 
+let messageInst = null;
+
 class UploadTask {
   constructor({
     taskList,
@@ -84,7 +86,7 @@ class UploadTask {
     return this.taskList.shift();
   }
 
-  async startUploadTask() {
+  startUploadTask() {
     this.taskRunning = true;
 
     this.addSetTime(() => {
@@ -103,10 +105,21 @@ class UploadTask {
 
     let uploadResult = true;
     await toUploadImg(curTask).catch(() => {
-      Message.error("上传异常");
+      if (messageInst) {
+        messageInst.close();
+        messageInst = null;
+      }
+      messageInst = Message.error({
+        message: "上传异常",
+        offset: 1
+      });
       uploadResult = false;
     });
     if (uploadResult) {
+      if (messageInst) {
+        messageInst.close();
+        messageInst = null;
+      }
       this.uploadSuccessCallback(curTask);
     } else {
       this.uploadErrorCallBack(curTask);