Browse Source

add:学时审核新需求

Tang 3 years ago
parent
commit
9dfede9f58

+ 51 - 9
src/views/education/classManageMent/classHours/index.vue

@@ -440,15 +440,25 @@ export default {
                 this.$message.warning(res.msg + "正在操作");
                 return;
               } else {
-                //学员详情
-                this.$router.push({
-                  path: "classHoursReview",
-                  query: {
-                    id: v.gradeId,
-                    userId: v.userId,
-                    goodsId: v.goodsId,
-                  },
-                });
+                let data = {
+                  userId: v.userId,
+                  realName: v.realName,
+                  id: v.gradeId,
+                  className: v.className,
+                  goodsId: v.goodsId,
+                  goodsName: v.goodsName,
+                  keyId: `${v.userId}-${v.goodsId}-${v.gradeId}`,
+                };
+                this.checkSession(data)
+                  .then(() => {
+                    //学员详情
+                    this.$router.push({
+                      path: "classHoursReview",
+                    });
+                  })
+                  .catch(() => {
+                    this.$message.error("存在异常,请联系开发人员");
+                  });
               }
             });
         }
@@ -463,6 +473,38 @@ export default {
         }
       }
     },
+    checkSession(row) {
+      return new Promise((resolve, reject) => {
+        const SESSION = sessionStorage.getItem("hoursAudit");
+        try {
+          if (SESSION) {
+            let parseSession = JSON.parse(SESSION);
+            const STATUS = parseSession.options.some((item) => {
+              return (
+                item.userId == row.userId &&
+                item.goodsId == row.goodsId &&
+                item.id == row.id
+              );
+            });
+            if (!STATUS) {
+              parseSession.options.push(row);
+            }
+            parseSession.activeData = `${row.userId}-${row.goodsId}-${row.id}`;
+            sessionStorage.setItem("hoursAudit", JSON.stringify(parseSession));
+          } else {
+            let data = {
+              activeData: `${row.userId}-${row.goodsId}-${row.id}`,
+              options: [row],
+            };
+            sessionStorage.setItem("hoursAudit", JSON.stringify(data));
+          }
+
+          resolve();
+        } catch (error) {
+          reject();
+        }
+      });
+    },
     changeActive(int) {
       if (int == this.active) {
         return;

+ 64 - 37
src/views/education/classManageMent/classHoursReview/index.vue

@@ -1,57 +1,84 @@
 <template>
   <div id="classHoursReview">
-    <!-- <div style="margin-bottom: 10px">
-      <el-button
-        :size="size"
-        :type="active === 1 ? 'primary' : ''"
-        @click="changeActive(1)"
-        >班级学员</el-button
-      >
-      <el-button
-        :size="size"
-        :type="active === 2 ? 'primary' : ''"
-        @click="changeActive(2)"
-        >学时管理</el-button
-      >
-    </div> -->
-    <study-times />
+    <el-tabs
+      v-model="parseSession.activeData"
+      :closable="parseSession.options.length > 1"
+      @tab-remove="removeTab"
+      :before-leave="beforeLeave"
+    >
+      <el-tab-pane
+        lazy
+        v-for="(item, index) in parseSession.options"
+        :key="item.keyId"
+        :label="item.realName + '-' + item.goodsName"
+        :name="item.keyId"
+        ><study-times :key="index" :setData="item" @removeTab="removeTab"
+      /></el-tab-pane>
+    </el-tabs>
   </div>
 </template>
 
 <script>
-import studyTimes from './studyTimes.vue'
+import studyTimes from "./studyTimes.vue";
 export default {
-  components:{studyTimes},
+  name: "ClassHoursReview",
+  components: { studyTimes },
   data() {
     return {
-      size: "medium",
-      active: "",
-      
+      parseSession: {
+        options: [],
+      },
     };
   },
+  created() {
+    this.init();
+  },
+  activated() {
+    this.init();
+  },
   methods: {
-    //切换顶部BTN
-    changeActive(int) {
-      if (int === 1) {
-        this.active = int;
-        this.$router.push({
-          path: "studentMenu",
-          query: {
-            id: this.$route.query.id,
-          },
-        });
+    init() {
+      const SESSION = sessionStorage.getItem("hoursAudit");
+      if (SESSION) {
+        this.parseSession = JSON.parse(SESSION);
+      } else {
+        console.log("错误处理");
       }
-      if (int === 2) {
-        this.active = int;
-        this.$router.push({
-          path: "classHours",
-          query: {
-            id: this.$route.query.id,
-          },
+    },
+    beforeLeave(activeName) {
+      try {
+        console.log(activeName, "activeName处理");
+        this.parseSession.activeData = activeName;
+        sessionStorage.setItem("hoursAudit", JSON.stringify(this.parseSession));
+        console.log("处理成功");
+        return true;
+      } catch (error) {
+        console.log("错误处理");
+        return false;
+      }
+    },
+    removeTab(targetName) {
+      let tabs = JSON.parse(JSON.stringify(this.parseSession.options));
+      let activeName = this.parseSession.activeData;
+      if (activeName === targetName) {
+        tabs.forEach((tab, index) => {
+          if (tab.keyId === targetName) {
+            let nextTab = tabs[index + 1] || tabs[index - 1];
+            if (nextTab) {
+              activeName = nextTab.keyId;
+            }
+          }
         });
       }
+      let ary = tabs.filter((tab) => tab.keyId !== targetName);
+      this.$set(this.parseSession, "options", ary);
+      this.$set(this.parseSession, "activeData", activeName);
     },
   },
+  destroyed() {
+    sessionStorage.removeItem("hoursAudit");
+    console.log("清除");
+  },
 };
 </script>
 

+ 57 - 43
src/views/education/classManageMent/classHoursReview/studyTimes.vue

@@ -1,5 +1,5 @@
 <template>
-  <div id="classHoursReview">
+  <div id="studyTimes">
     <div class="topBoxStyle">
       <div class="dis_fs" :style="showBox ? '' : 'height:0px;'">
         <ul class="ul_ls">
@@ -19,7 +19,9 @@
             v-else
             style="width: 100%; height: 100%"
             :src="$methodsTools.splitImgHost(userData.oneInchPhotos)"
-            :preview-src-list="[$methodsTools.splitImgHost(userData.oneInchPhotos)]"
+            :preview-src-list="[
+              $methodsTools.splitImgHost(userData.oneInchPhotos),
+            ]"
           >
           </el-image>
           <div class="pos_bottom">一寸头像图</div>
@@ -35,7 +37,9 @@
             v-else
             style="width: 100%; height: 100%"
             :src="$methodsTools.splitImgHost(userData.idCardImg1)"
-            :preview-src-list="[$methodsTools.splitImgHost(userData.idCardImg1)]"
+            :preview-src-list="[
+              $methodsTools.splitImgHost(userData.idCardImg1),
+            ]"
           >
           </el-image>
           <div class="pos_bottom">身份证头像照</div>
@@ -964,6 +968,7 @@
 
 <script>
 export default {
+  props: ["setData"],
   data() {
     return {
       showBox: true,
@@ -1198,9 +1203,9 @@ export default {
   created() {
     this.$api
       .inquireGradegradelockPeriodStatus({
-        gradeId: Number(this.$route.query.id),
-        userId: Number(this.$route.query.userId),
-        goodsId: Number(this.$route.query.goodsId),
+        gradeId: Number(this.setData.id),
+        userId: Number(this.setData.userId),
+        goodsId: Number(this.setData.goodsId),
       })
       .then((res) => {
         if (res.msg) {
@@ -1208,11 +1213,20 @@ export default {
             dangerouslyUseHTMLString: true,
             showClose: false,
           }).then((result) => {
-            this.$store
-              .dispatch("tagsView/delView", this.$route)
-              .then((results) => {
-                this.$router.go(-1);
-              });
+            const SESSION = sessionStorage.getItem("hoursAudit");
+            let parseSession = {};
+            if (SESSION) {
+              parseSession = JSON.parse(SESSION);
+            }
+            if (parseSession.options.length > 1) {
+              this.$emit("removeTab",this.setData.keyId)
+            } else {
+              this.$store
+                .dispatch("tagsView/delView", this.$route)
+                .then((results) => {
+                  this.$router.go(-1);
+                });
+            }
           });
         } else {
           this.getSetTime();
@@ -1237,9 +1251,9 @@ export default {
     getSetTime() {
       this.$api
         .inquireGradegradelockPeriod({
-          gradeId: Number(this.$route.query.id),
-          userId: Number(this.$route.query.userId),
-          goodsId: Number(this.$route.query.goodsId),
+          gradeId: Number(this.setData.id),
+          userId: Number(this.setData.userId),
+          goodsId: Number(this.setData.goodsId),
         })
         .then((res) => {});
     },
@@ -1249,9 +1263,9 @@ export default {
     approvedOKFunc() {
       this.disabledBtn = true;
       let data = {
-        gradeId: Number(this.$route.query.id),
-        userId: Number(this.$route.query.userId),
-        goodsId: Number(this.$route.query.goodsId),
+        gradeId: Number(this.setData.id),
+        userId: Number(this.setData.userId),
+        goodsId: Number(this.setData.goodsId),
       };
       this.$api
         .editGradeUsereditrollconfirmPeriod(data)
@@ -1271,9 +1285,9 @@ export default {
     uploadForm() {
       this.disabledBtn = true;
       let data = {
-        gradeId: Number(this.$route.query.id),
-        userId: Number(this.$route.query.userId),
-        goodsId: Number(this.$route.query.goodsId),
+        gradeId: Number(this.setData.id),
+        userId: Number(this.setData.userId),
+        goodsId: Number(this.setData.goodsId),
         ids: this.checkList,
       };
       this.$api
@@ -1552,9 +1566,9 @@ export default {
         return;
       }
       var data = {
-        gradeId: Number(this.$route.query.id),
-        userId: Number(this.$route.query.userId),
-        goodsId: Number(this.$route.query.goodsId),
+        gradeId: Number(this.setData.id),
+        userId: Number(this.setData.userId),
+        goodsId: Number(this.setData.goodsId),
       };
       if (int === 1) {
         data.status = 1;
@@ -1576,9 +1590,9 @@ export default {
     submitOK(int, msg) {
       this.disabledBtn = true;
       var data = {
-        gradeId: Number(this.$route.query.id),
-        userId: Number(this.$route.query.userId),
-        goodsId: Number(this.$route.query.goodsId),
+        gradeId: Number(this.setData.id),
+        userId: Number(this.setData.userId),
+        goodsId: Number(this.setData.goodsId),
         ids: this.checkList,
       };
       if (int === 1) {
@@ -1622,9 +1636,9 @@ export default {
         moduleId: item.moduleId,
         chapterId: item.chapterId,
         numIndex: int,
-        userId: this.$route.query.userId,
-        goodsId: this.$route.query.goodsId,
-        gradeId: this.$route.query.id,
+        userId: this.setData.userId,
+        goodsId: this.setData.goodsId,
+        gradeId: this.setData.id,
       };
       if (item.type === 3) {
         data.sectionId = item.id;
@@ -1651,9 +1665,9 @@ export default {
         moduleId: item.moduleId,
         chapterId: item.chapterId,
         numIndex: int,
-        userId: this.$route.query.userId,
-        goodsId: this.$route.query.goodsId,
-        gradeId: this.$route.query.id,
+        userId: this.setData.userId,
+        goodsId: this.setData.goodsId,
+        gradeId: this.setData.id,
       };
       if (item.type === 3) {
         data.sectionId = item.id;
@@ -1685,9 +1699,9 @@ export default {
         moduleId: item.moduleId,
         chapterId: item.chapterId,
         numIndex: int,
-        userId: this.$route.query.userId,
-        goodsId: this.$route.query.goodsId,
-        gradeId: this.$route.query.id,
+        userId: this.setData.userId,
+        goodsId: this.setData.goodsId,
+        gradeId: this.setData.id,
       };
       if (item.type === 3) {
         data.sectionId = item.id;
@@ -1709,9 +1723,9 @@ export default {
       return new Promise((resolve, reject) => {
         this.$api
           .inquireGradegradelistUserlistPeriod({
-            gradeId: this.$route.query.id,
-            userId: this.$route.query.userId,
-            goodsId: this.$route.query.goodsId,
+            gradeId: this.setData.id,
+            userId: this.setData.userId,
+            goodsId: this.setData.goodsId,
           })
           .then((res) => {
             this.userData = res.rows[0];
@@ -1723,9 +1737,9 @@ export default {
     search() {
       var self = this;
       let data = {
-        gradeId: this.$route.query.id,
-        userId: this.$route.query.userId,
-        goodsId: this.$route.query.goodsId,
+        gradeId: this.setData.id,
+        userId: this.setData.userId,
+        goodsId: this.setData.goodsId,
       };
       this.loading = true;
       this.$api
@@ -1878,10 +1892,10 @@ export default {
     box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.2);
   }
 }
-#classHoursReview {
+#studyTimes {
   display: flex;
   flex-direction: column;
-  height: calc(100vh - 126px);
+  height: calc(100vh - 190px);
 }
 .styFlex {
   width: 80px;

+ 52 - 12
src/views/education/classManageMent/listOfhoursToBeReviewed/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="listOfhoursToBeReviewed">
-    <div style="margin-bottom:10px;">
+    <div style="margin-bottom: 10px">
       <span style="font-size: 15px; color: #666">审核状态:</span
       ><el-button
         :type="formData.periodStatus === 2 ? 'primary' : ''"
@@ -315,7 +315,6 @@ export default {
           status: 1,
         })
         .then((res) => {
-          console.log(res.rows.length);
           this.reviewListNums = res.rows.length;
         });
     },
@@ -329,7 +328,6 @@ export default {
           status: 1,
         })
         .then((res) => {
-          console.log(res.rows.length);
           this.underReiviewNums = res.rows.length;
         });
     },
@@ -345,18 +343,60 @@ export default {
             this.$message.warning(res.msg + "正在操作");
             return;
           } else {
-            //学员详情
-            this.$router.push({
-              path: "classHoursReview",
-              query: {
-                id: v.gradeId,
-                userId: v.userId,
-                goodsId: v.goodsId,
-              },
-            });
+            let data = {
+              userId: v.userId,
+              realName: v.realName,
+              id: v.gradeId,
+              className: v.className,
+              goodsId: v.goodsId,
+              goodsName: v.goodsName,
+              keyId: `${v.userId}-${v.goodsId}-${v.gradeId}`,
+            };
+            this.checkSession(data)
+              .then(() => {
+                //学员详情
+                this.$router.push({
+                  path: "classHoursReview",
+                });
+              })
+              .catch(() => {
+                this.$message.error("存在异常,请联系开发人员");
+              });
           }
         });
     },
+    checkSession(row) {
+      return new Promise((resolve, reject) => {
+        const SESSION = sessionStorage.getItem("hoursAudit");
+        try {
+          if (SESSION) {
+            let parseSession = JSON.parse(SESSION);
+            const STATUS = parseSession.options.some((item) => {
+              return (
+                item.userId == row.userId &&
+                item.goodsId == row.goodsId &&
+                item.id == row.id
+              );
+            });
+            if (!STATUS) {
+              parseSession.options.push(row);
+            }
+            parseSession.activeData = `${row.userId}-${row.goodsId}-${row.id}`;
+            sessionStorage.setItem("hoursAudit", JSON.stringify(parseSession));
+          } else {
+            let data = {
+              activeData: `${row.userId}-${row.goodsId}-${row.id}`,
+              options: [row],
+            };
+            sessionStorage.setItem("hoursAudit", JSON.stringify(data));
+          }
+
+          resolve();
+        } catch (error) {
+          reject();
+        }
+      });
+    },
     search(int) {
       this.loading = true;
       if (int === 1) {