zhangjie 2 år sedan
förälder
incheckning
2c85ed620b

+ 11 - 0
src/api.js

@@ -465,3 +465,14 @@ export const inspectionConfirmCheckGrade = datas => {
 export const logTypeList = () => {
   return $get(`/api/marklog/listTypes`);
 };
+
+// notice -------------------------->
+export const userNoticeList = datas => {
+  return $get(`/api/notice/list`, datas);
+};
+export const fetchReleaseNotice = datas => {
+  return $get(`/api/notice/release`, datas);
+};
+export const readNotice = ids => {
+  return $get(`/api/notice/rend`, { ids });
+};

+ 77 - 7
src/modules/grading/components/NoticeDialog.vue

@@ -60,11 +60,19 @@
 </template>
 
 <script>
-import { mapMutations } from "vuex";
+import { mapState, mapMutations } from "vuex";
 import { noticeList, userList } from "./data";
+import {
+  userNoticeList,
+  fetchReleaseNotice,
+  readNotice,
+  leaderMarkUserList
+} from "@/api";
+import timeMixin from "@/plugins/timeMixin";
 
 export default {
   name: "ribbon-set-dialog",
+  mixins: [timeMixin],
   data() {
     return {
       modalIsShow: false,
@@ -75,6 +83,7 @@ export default {
     };
   },
   computed: {
+    ...mapState("marker", ["curSubject"]),
     IS_MARKER() {
       return this.curUserRoleType === "MARKER";
     },
@@ -82,22 +91,83 @@ export default {
       return this.curUserRoleType === "MARK_LEADER";
     }
   },
-  mounted() {},
+  mounted() {
+    this.initData();
+  },
+  beforeDestroy() {
+    this.clearSetTs();
+  },
   methods: {
     ...mapMutations("marker", ["setShortcut", "recoverShortcut"]),
-    initData() {
-      this.$nextTick(() => {
-        this.$refs.NoticeContent.scrollTop = this.$refs.NoticeContent.offsetHeight;
-      });
+    async initData() {
+      this.getNoticeList();
+
+      if (this.IS_MARK_LEADER) {
+        this.getLeaderMarkerList();
+      }
+
+      if (this.IS_MARKER) {
+        this.addSetTime(() => {
+          this.getNewNotice();
+        }, 10 * 1000);
+      }
     },
     visibleChange(visible) {
       if (visible) {
-        this.initData();
+        this.setNoticeRead();
+        this.goToBottom();
         this.setShortcut([]);
       } else {
         this.recoverShortcut();
       }
     },
+    goToBottom() {
+      this.$nextTick(() => {
+        this.$refs.NoticeContent.scrollTop = this.$refs.NoticeContent.offsetHeight;
+      });
+    },
+    async getLeaderMarkerList() {
+      const markerId = this.$ls.get("user", { id: "" }).id;
+      const [workId, subject] = this.$route.params.subjectId.split("-");
+      const data = await leaderMarkUserList({
+        workId,
+        subject,
+        stage: this.curSubject.stage,
+        markerId
+      });
+      const users = data || [];
+      this.users = users.map(item => {
+        item.selected = false;
+        return item;
+      });
+    },
+    async getNoticeList() {
+      const data = await userNoticeList();
+      this.notices = data || [];
+    },
+    async getNewNotice() {
+      this.clearSetTs();
+
+      const resData = await fetchReleaseNotice().catch(() => {});
+      const data = resData || [];
+      const noticeIds = this.notices.map(item => item.id);
+      const validNotices = data.filter(item => noticeIds.includes(item.id));
+      if (validNotices.length) {
+        this.notices.push(...validNotices);
+        this.goToBottom();
+      }
+
+      this.addSetTime(() => {
+        this.getNewNotice();
+      }, 10 * 1000);
+    },
+    setNoticeRead() {
+      const noticeIds = this.notices
+        .filter(item => !item.readed)
+        .map(item => item.id);
+      if (!noticeIds.length) return;
+      readNotice(noticeIds);
+    },
     cancel() {
       this.modalIsShow = false;
     },

+ 1 - 1
src/modules/inspection/InspectionGrading.vue

@@ -231,7 +231,7 @@ export default {
     async getList() {
       const datas = {
         ...this.filter,
-        current: this.current,
+        page: this.current,
         size: this.size
       };
       const data = await changeLevelPaperList(datas);