浏览代码

fix: 图片旋转bug

zhangjie 10 月之前
父节点
当前提交
0b9b3cc62a
共有 1 个文件被更改,包括 27 次插入5 次删除
  1. 27 5
      src/modules/record/components/ArchivesDetailStudentDialog.vue

+ 27 - 5
src/modules/record/components/ArchivesDetailStudentDialog.vue

@@ -57,7 +57,12 @@
           </div>
           <div class="archives-student-mid">
             <el-divider></el-divider>
-            <el-button v-if="showFix" type="primary" size="small" @click="toFix"
+            <el-button
+              v-if="showFix"
+              type="primary"
+              size="small"
+              :disabled="!canFix"
+              @click="toFix"
               >纠错</el-button
             >
             <el-button
@@ -149,6 +154,11 @@ export default {
       curPage: {},
     };
   },
+  computed: {
+    canFix() {
+      return Boolean(this.multipleSelection.length || this.curImage.url);
+    },
+  },
   methods: {
     async reloadData() {
       this.initData();
@@ -157,9 +167,12 @@ export default {
     initData() {
       this.imageList = [];
       this.pageList = [];
+      this.studentInfo = {};
+      this.multipleSelection = [];
       this.curImage = { url: "" };
       this.curImageRotate = 0;
       this.curImageIndex = 0;
+      this.curPage = {};
     },
     cancel() {
       this.modalIsShow = false;
@@ -171,7 +184,7 @@ export default {
       this.$emit("close");
     },
     handleSelectionChange(vals) {
-      this.multipleSelection = vals;
+      this.multipleSelection = vals.map((item) => item.paperLibraryId);
     },
     async getImageList() {
       const resData = await studentPictureList({
@@ -188,12 +201,19 @@ export default {
     // actions
     toFix() {
       if (this.multipleSelection.length) {
+        // 从最新的列表中取数据
+        const pageList = this.pageList
+          .filter((item) =>
+            this.multipleSelection.includes(item.paperLibraryId)
+          )
+          .map((item) => {
+            return { ...item, paperScanTaskId: this.student.paperScanTaskId };
+          });
+
         this.studentInfo = {
           ...this.student,
           curPagePaperIndex: 0,
-          pageList: this.multipleSelection.map((item) => {
-            return { ...item, paperScanTaskId: this.student.paperScanTaskId };
-          }),
+          pageList,
         };
         this.$refs.LibraryDialog.open();
         return;
@@ -236,6 +256,7 @@ export default {
       if (!res) return;
       this.curImageRotate = 0;
       this.updateImageSource(this.curImage.url, uncacheUrl(this.curImage.url));
+      this.$message.success("保存成功!");
     },
     updateImageSource(oldUrl, newUrl) {
       const curPage = this.pageList.find((item) =>
@@ -246,6 +267,7 @@ export default {
 
       const imgIndex = this.imageList.indexOf(oldUrl);
       this.imageList[imgIndex] = newUrl;
+      this.curImage.url = newUrl;
     },
     async toDelete() {
       const res = await this.$confirm(`确认要删除当前页已扫描数据?`, "提示", {