Parcourir la source

图片在处理完成

zhangjie il y a 3 ans
Parent
commit
c7b5749da4

+ 1 - 1
src/assets/styles/base.less

@@ -96,7 +96,7 @@ select {
 }
 ::-webkit-scrollbar-thumb {
   border-radius: 8px;
-  background: #999;
+  background: rgb(80, 79, 79);
 }
 ::-webkit-scrollbar-corner {
   background: transparent;

+ 24 - 1
src/assets/styles/manage.less

@@ -231,6 +231,7 @@
     overflow-y: auto;
     overflow-x: hidden;
     border-top-right-radius: 20px;
+    border-bottom-right-radius: 20px;
   }
   .task-item {
     padding: 6px 10px 6px 30px;
@@ -269,11 +270,31 @@
   }
   .task-progress {
     position: absolute;
-    height: 24px;
+    height: 20px;
     top: 0;
     left: 190px;
     right: 0;
     z-index: 9;
+    display: flex;
+    justify-content: space-between;
+
+    &-tips {
+      flex-grow: 0;
+      padding-right: 20px;
+      font-size: 12px;
+      line-height: 20px;
+      height: 20px;
+
+      span {
+        margin: 0 2px;
+      }
+    }
+    &-body {
+      flex-grow: 1;
+    }
+    .ivu-progress {
+      vertical-align: top;
+    }
   }
   .ivu-progress-inner {
     background-color: @background;
@@ -309,6 +330,7 @@
         background-color: @background;
         height: 400px;
         margin-bottom: 10px;
+        border-radius: 8px;
       }
     }
   }
@@ -318,6 +340,7 @@
     position: relative;
     background-color: @background;
     height: 100%;
+    border-radius: 8px;
 
     .part-head {
       position: absolute;

+ 5 - 2
src/assets/styles/pages.less

@@ -33,6 +33,9 @@
       &:nth-of-type(2) {
         background-color: @purple-color;
       }
+      &:nth-of-type(3) {
+        background-color: @brown-color;
+      }
     }
   }
 }
@@ -158,7 +161,7 @@
   height: 100%;
   &-cont {
     position: relative;
-    width: calc(100% - 300px);
+    width: calc(100% - 250px);
     height: 100%;
     &-disabled::before {
       content: "";
@@ -183,7 +186,7 @@
     position: absolute;
     width: 240px;
     top: 50%;
-    right: 30px;
+    right: 0;
     transform: translateY(-50%);
   }
   &-spin {

+ 4 - 0
src/modules/client/views/ActionType.vue

@@ -7,6 +7,7 @@
       <ul>
         <li @click="toClient">试卷采集</li>
         <li @click="toPaperManage">图片旋转</li>
+        <li @click="toCropperTask">图片再处理</li>
       </ul>
     </div>
   </div>
@@ -24,6 +25,9 @@ export default {
     },
     toPaperManage() {
       this.$router.push({ name: "PaperManage" });
+    },
+    toCropperTask() {
+      this.$router.push({ name: "CropperTaskManage" });
     }
   }
 };

+ 13 - 3
src/modules/cropper-task/CropperTaskDetailDialog.vue

@@ -33,7 +33,13 @@
       </div>
       <div class="task-main">
         <div class="task-progress">
-          <Progress :percent="taskProgress" />
+          <div class="task-progress-tips">
+            <span>{{ finishedCount }}</span
+            ><span>/</span><span>{{ taskCount }}</span>
+          </div>
+          <div class="task-progress-body">
+            <Progress :percent="taskProgress" />
+          </div>
         </div>
         <div class="task-body">
           <div class="task-body-item task-org">
@@ -57,8 +63,9 @@
             </div>
             <div
               v-if="curTaskImagesPath && !curTask.isFinished"
-              class="task-action"
+              class="task-action box-justify"
             >
+              <h5>处理结果</h5>
               <Button
                 type="primary"
                 :disabled="loading"
@@ -120,6 +127,8 @@ export default {
     visibleChange(visible) {
       if (visible) {
         this.initData();
+      } else {
+        this.$emit("modified");
       }
     },
     cancel() {
@@ -182,7 +191,8 @@ export default {
         sheetPath,
         imagesPath,
         thumbsPath,
-        key: randomCode()
+        key: randomCode(),
+        compressRate: this.GLOBAL.compressRate
       };
       this.curTaskImagesPath = fs.existsSync(this.curTask.imagesPath)
         ? this.curTask.imagesPath

+ 9 - 1
src/modules/cropper-task/CropperTaskManage.vue

@@ -18,6 +18,7 @@
     <cropper-task-detail-dialog
       ref="CropperTaskDetailDialog"
       :cropper-task="curTask"
+      @modified="getList"
     ></cropper-task-detail-dialog>
     <!-- ModifyCropperTask -->
     <modify-cropper-task
@@ -29,7 +30,11 @@
 </template>
 
 <script>
-import { getCropperTaskList, deleteCropperTaskById } from "../../plugins/db";
+import {
+  getCropperTaskList,
+  deleteCropperTaskById,
+  deleteCropperTaskDetail
+} from "../../plugins/db";
 import CropperTaskDetailDialog from "./CropperTaskDetailDialog";
 import ModifyCropperTask from "./ModifyCropperTask";
 
@@ -97,6 +102,7 @@ export default {
             const actions = [
               {
                 name: "编辑",
+                disabled: !!param.row.finishedCount,
                 action: () => {
                   this.toEdit(param.row);
                 }
@@ -150,7 +156,9 @@ export default {
       });
     },
     async toDel(id) {
+      await deleteCropperTaskDetail(id);
       await deleteCropperTaskById(id);
+      this.getList();
       this.$Message.success("删除成功!");
     }
   }

+ 33 - 20
src/modules/cropper-task/taskUtils.js

@@ -67,14 +67,32 @@ export const getInputFirstPaper = folderPath => {
   });
 };
 
-export function saveCropperImage(paperInfo, collectConfig) {
+function saveThumbsImage(imgPath, outputThumbsPath) {
+  const outputThumbsDir = path.dirname(outputThumbsPath);
+  if (!fs.existsSync(outputThumbsDir)) makeDirSync(outputThumbsDir);
+
+  // slice图:完整处理流程
+  let imgObj = gm(imgPath);
+
+  // 生成缩略图
+  imgObj.resize(500).quality(80);
+
+  return new Promise((resolve, reject) => {
+    imgObj.write(outputThumbsPath, function(err) {
+      if (err) {
+        reject(err);
+        return;
+      }
+      resolve(outputThumbsPath);
+    });
+  });
+}
+
+function saveSliceImage(paperInfo, collectConfig) {
   const imgPath = paperInfo.filepath;
   const outputSlicelPath = paperInfo.imagesPath;
   const outputSliceDir = path.dirname(outputSlicelPath);
   if (!fs.existsSync(outputSliceDir)) makeDirSync(outputSliceDir);
-  const outputThumbsPath = paperInfo.thumbsPath;
-  const outputThumbsDir = path.dirname(outputThumbsPath);
-  if (!fs.existsSync(outputThumbsDir)) makeDirSync(outputThumbsDir);
 
   const { codeArea, coverArea, tailorTailorArea, imageRotate } = collectConfig;
 
@@ -122,22 +140,17 @@ export function saveCropperImage(paperInfo, collectConfig) {
         reject(err);
         return;
       }
-
-      // 生成缩略图
-      imgObj.resize(500).quality(80);
-      imgObj.write(outputThumbsPath, function(err) {
-        if (err) {
-          reject(err);
-          return;
-        }
-
-        imgObj.resize(500).quality(80);
-
-        resolve({
-          imagesPath: outputSlicelPath,
-          thumbsPath: outputThumbsPath
-        });
-      });
+      resolve(outputSlicelPath);
     });
   });
 }
+
+export async function saveCropperImage(paperInfo, collectConfig) {
+  const outputSlicelPath = await saveSliceImage(paperInfo, collectConfig);
+  const outputThumbsPath = await saveThumbsImage(
+    outputSlicelPath,
+    paperInfo.thumbsPath
+  );
+
+  return { outputSlicelPath, outputThumbsPath };
+}

+ 0 - 2
src/plugins/db.js

@@ -599,7 +599,6 @@ export function addCropperTask(params) {
 
   return new Promise((resolve, reject) => {
     db.run(sql, datas, function(err) {
-      console.log(err);
       if (err) reject(err);
       resolve(this.lastID);
     });
@@ -717,7 +716,6 @@ export function addCropperTaskDetail(paramList) {
 
   return new Promise((resolve, reject) => {
     db.run(sql, function(err) {
-      console.log(err);
       if (err) reject(err);
       resolve(true);
     });

+ 1 - 0
src/views/Home.vue

@@ -58,6 +58,7 @@ export default {
         PaperExport: "Login",
         ActionType: "Login",
         PaperManage: "ActionType",
+        CropperTaskManage: "ActionType",
         Subject: "ActionType",
         Camera: "Subject",
         ScanArea: "Camera",

+ 1 - 2
src/views/Login.vue

@@ -158,8 +158,7 @@ export default {
 
       if (data.roleCode === "ADMIN") {
         this.$router.push({
-          name: "CropperTaskManage"
-          // name: "PaperExport"
+          name: "PaperExport"
         });
         return;
       }