|
@@ -21,7 +21,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div
|
|
|
- v-for="user in users"
|
|
|
+ v-for="user in markers"
|
|
|
:key="user.id"
|
|
|
class="user-item"
|
|
|
@click="selectUser(user)"
|
|
@@ -36,22 +36,27 @@
|
|
|
</div>
|
|
|
<div class="notice-body">
|
|
|
<div ref="NoticeContent" class="notice-content">
|
|
|
+ <div v-if="hasMore" class="notice-item notice-more" @click="nextPage">
|
|
|
+ 获取更多
|
|
|
+ </div>
|
|
|
<div v-for="notice in notices" :key="notice.id" class="notice-item">
|
|
|
<div class="notice-item-head">
|
|
|
<span class="notice-head-users">
|
|
|
- {{ notice.sendUsers.map(item => item.name).join(",") }}
|
|
|
+ {{ notice.relateUsers }}
|
|
|
</span>
|
|
|
<span class="notice-head-time">
|
|
|
- {{ notice.createTime | timestampFilter }}
|
|
|
+ {{ notice.createTime }}
|
|
|
</span>
|
|
|
</div>
|
|
|
<div class="notice-item-content" v-html="notice.content"></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-if="IS_MARK_LEADER" class="notice-send">
|
|
|
- <textarea placeholder="请输入"></textarea>
|
|
|
+ <textarea placeholder="请输入" v-model="content"></textarea>
|
|
|
<div class="notice-send-footer">
|
|
|
- <Button type="primary">发送</Button>
|
|
|
+ <Button type="primary" :loading="loading" @click="toSend"
|
|
|
+ >发送</Button
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -61,11 +66,12 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapState, mapMutations } from "vuex";
|
|
|
-import { noticeList, userList } from "./data";
|
|
|
import {
|
|
|
- userNoticeList,
|
|
|
- fetchReleaseNotice,
|
|
|
+ userSendNoticeList,
|
|
|
+ userReceiveNoticeList,
|
|
|
+ fetchReleaseUnreadNotice,
|
|
|
readNotice,
|
|
|
+ sendNotice,
|
|
|
leaderMarkUserList
|
|
|
} from "@/api";
|
|
|
import timeMixin from "@/plugins/timeMixin";
|
|
@@ -75,11 +81,19 @@ export default {
|
|
|
mixins: [timeMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
+ workId: "",
|
|
|
+ subject: "",
|
|
|
modalIsShow: false,
|
|
|
curUserRoleType: this.$ls.get("user", { role: "" }).role,
|
|
|
userSelectAll: false,
|
|
|
- users: userList,
|
|
|
- notices: noticeList
|
|
|
+ markers: [],
|
|
|
+ notices: [],
|
|
|
+ current: 0,
|
|
|
+ size: 10,
|
|
|
+ content: "",
|
|
|
+ hasMore: false,
|
|
|
+ fetching: false,
|
|
|
+ loading: false
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -92,7 +106,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- // this.initData();
|
|
|
+ const [workId, subject] = this.$route.params.subjectId.split("-");
|
|
|
+ this.workId = workId;
|
|
|
+ this.subject = subject;
|
|
|
+
|
|
|
+ this.initData();
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.clearSetTs();
|
|
@@ -100,13 +118,14 @@ export default {
|
|
|
methods: {
|
|
|
...mapMutations("marker", ["setShortcut", "recoverShortcut"]),
|
|
|
async initData() {
|
|
|
- this.getNoticeList();
|
|
|
-
|
|
|
if (this.IS_MARK_LEADER) {
|
|
|
this.getLeaderMarkerList();
|
|
|
+ this.getLeaderMarkerNoticeList();
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (this.IS_MARKER) {
|
|
|
+ this.getMarkerNoticeList();
|
|
|
this.addSetTime(() => {
|
|
|
this.getNewNotice();
|
|
|
}, 10 * 1000);
|
|
@@ -114,7 +133,9 @@ export default {
|
|
|
},
|
|
|
visibleChange(visible) {
|
|
|
if (visible) {
|
|
|
- this.setNoticeRead();
|
|
|
+ if (this.IS_MARKER) {
|
|
|
+ this.setNoticeRead();
|
|
|
+ }
|
|
|
this.goToBottom();
|
|
|
this.setShortcut([]);
|
|
|
} else {
|
|
@@ -128,33 +149,98 @@ export default {
|
|
|
},
|
|
|
async getLeaderMarkerList() {
|
|
|
const markerId = this.$ls.get("user", { id: "" }).id;
|
|
|
- const [workId, subject] = this.$route.params.subjectId.split("-");
|
|
|
const data = await leaderMarkUserList({
|
|
|
- workId,
|
|
|
- subject,
|
|
|
+ workId: this.workId,
|
|
|
+ subject: this.subject,
|
|
|
stage: this.curSubject.stage,
|
|
|
markerId
|
|
|
});
|
|
|
- const users = data || [];
|
|
|
- this.users = users.map(item => {
|
|
|
+ const markers = data || [];
|
|
|
+ this.markers = markers.map(item => {
|
|
|
item.selected = false;
|
|
|
return item;
|
|
|
});
|
|
|
},
|
|
|
- async getNoticeList() {
|
|
|
- const data = await userNoticeList();
|
|
|
- this.notices = data || [];
|
|
|
+ async nextPage() {
|
|
|
+ if (this.fetching) return;
|
|
|
+ this.fetching = true;
|
|
|
+
|
|
|
+ this.current++;
|
|
|
+ if (this.IS_MARKER) {
|
|
|
+ await this.getMarkerNoticeList().catch(() => {});
|
|
|
+ } else {
|
|
|
+ await this.getLeaderMarkerNoticeList().catch(() => {});
|
|
|
+ }
|
|
|
+ this.fetching = false;
|
|
|
+ },
|
|
|
+ async getLeaderMarkerNoticeList() {
|
|
|
+ const sendUserId = this.$ls.get("user", { id: "" }).id;
|
|
|
+ const lastId = this.notices.length ? this.notices.slice(-1)[0].id : null;
|
|
|
+ const data = await userSendNoticeList({
|
|
|
+ subject: this.subject,
|
|
|
+ stage: this.curSubject.stage,
|
|
|
+ sendUserId,
|
|
|
+ lastId,
|
|
|
+ page: this.current,
|
|
|
+ size: this.size
|
|
|
+ });
|
|
|
+ const notices = data.content.map(item => {
|
|
|
+ item.receiveUser = JSON.parse(item.receiveUser);
|
|
|
+ item.relateUsers = item.receiveUser.map(user => user.name).join(",");
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ notices.reverse();
|
|
|
+ this.hasMore = this.current + 1 < data.totalPages;
|
|
|
+ this.notices = [...notices, ...this.notices];
|
|
|
+ },
|
|
|
+ parseMarkerNotice(info) {
|
|
|
+ return {
|
|
|
+ ...info.message,
|
|
|
+ id: info.id,
|
|
|
+ read: info.read,
|
|
|
+ relateUsers: info.message.sendUserName
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async getMarkerNoticeList() {
|
|
|
+ const receiveUserId = this.$ls.get("user", { id: "" }).id;
|
|
|
+ const lastId = this.notices.length ? this.notices.slice(-1)[0].id : null;
|
|
|
+ const data = await userReceiveNoticeList({
|
|
|
+ subject: this.subject,
|
|
|
+ stage: this.curSubject.stage,
|
|
|
+ receiveUserId,
|
|
|
+ lastId,
|
|
|
+ page: this.current,
|
|
|
+ size: this.size
|
|
|
+ });
|
|
|
+ const notices = data.content.map(item => {
|
|
|
+ return this.parseMarkerNotice(item);
|
|
|
+ });
|
|
|
+ notices.reverse();
|
|
|
+ this.hasMore = this.current + 1 < data.totalPages;
|
|
|
+ this.notices = [...notices, ...this.notices];
|
|
|
},
|
|
|
async getNewNotice() {
|
|
|
this.clearSetTs();
|
|
|
|
|
|
- const resData = await fetchReleaseNotice().catch(() => {});
|
|
|
+ const receiveUserId = this.$ls.get("user", { id: "" }).id;
|
|
|
+ const resData = await fetchReleaseUnreadNotice({
|
|
|
+ subject: this.subject,
|
|
|
+ stage: this.curSubject.stage,
|
|
|
+ receiveUserId
|
|
|
+ }).catch(() => {});
|
|
|
const data = resData || [];
|
|
|
const noticeIds = this.notices.map(item => item.id);
|
|
|
- const validNotices = data.filter(item => noticeIds.includes(item.id));
|
|
|
+ const validNotices = data
|
|
|
+ .filter(item => !noticeIds.includes(item.id))
|
|
|
+ .map(item => this.parseMarkerNotice(item));
|
|
|
if (validNotices.length) {
|
|
|
this.notices.push(...validNotices);
|
|
|
+ this.open();
|
|
|
this.goToBottom();
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.setNoticeRead();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
this.addSetTime(() => {
|
|
@@ -163,7 +249,7 @@ export default {
|
|
|
},
|
|
|
setNoticeRead() {
|
|
|
const noticeIds = this.notices
|
|
|
- .filter(item => !item.readed)
|
|
|
+ .filter(item => !item.read)
|
|
|
.map(item => item.id);
|
|
|
if (!noticeIds.length) return;
|
|
|
readNotice(noticeIds);
|
|
@@ -175,7 +261,7 @@ export default {
|
|
|
this.modalIsShow = true;
|
|
|
},
|
|
|
selectChange() {
|
|
|
- this.userSelectAll = !this.users.some(item => !item.selected);
|
|
|
+ this.userSelectAll = !this.markers.some(item => !item.selected);
|
|
|
},
|
|
|
selectUser(user) {
|
|
|
user.selected = !user.selected;
|
|
@@ -183,9 +269,51 @@ export default {
|
|
|
},
|
|
|
selectAll() {
|
|
|
this.userSelectAll = !this.userSelectAll;
|
|
|
- this.users.forEach(user => {
|
|
|
+ this.markers.forEach(user => {
|
|
|
user.selected = this.userSelectAll;
|
|
|
});
|
|
|
+ },
|
|
|
+ async toSend() {
|
|
|
+ if (!this.content) {
|
|
|
+ this.$Message.error("请输入内容");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const user = this.$ls.get("user", { id: "", name: "" });
|
|
|
+ const markers = this.markers
|
|
|
+ .filter(item => item.selected)
|
|
|
+ .map(item => {
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ name: item.name
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!markers.length) {
|
|
|
+ this.$Message.error("请选择评卷员");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ subject: this.subject,
|
|
|
+ stage: this.curSubject.stage,
|
|
|
+ sendUserId: user.id,
|
|
|
+ sendUserName: user.name,
|
|
|
+ content: this.content,
|
|
|
+ markers
|
|
|
+ };
|
|
|
+ const res = await sendNotice(data).catch(() => {});
|
|
|
+ this.loading = false;
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ this.content = "";
|
|
|
+ res.receiveUser = JSON.parse(res.receiveUser);
|
|
|
+ res.relateUsers = res.receiveUser.map(item => item.name).join(",");
|
|
|
+ this.notices.push({ ...res });
|
|
|
+ this.goToBottom();
|
|
|
}
|
|
|
}
|
|
|
};
|