|
@@ -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;
|
|
|
},
|