Commit 9c23457e authored by 夏敏伟's avatar 夏敏伟

修改公告排序以及解决分页bug

parent 088256df
...@@ -3,27 +3,20 @@ ...@@ -3,27 +3,20 @@
<div class="ddkz-info-selection"> <div class="ddkz-info-selection">
<el-form ref="form" :inline="true" :model="formInfo" class="demo-form-inline"> <el-form ref="form" :inline="true" :model="formInfo" class="demo-form-inline">
<el-form-item> <el-form-item>
<el-select v-model="formInfo.day" placeholder="请选择日期" clearable> <el-select v-model="formInfo.fromUser" placeholder="请选择公告来源" clearable @change="handleChangeFromUser">
<el-option v-for="item in options" :key="item" :label="item" :value="item"> <el-option v-for="item in optionsFrom" :key="item" :label="item" :value="item">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select v-model="formInfo.fromUser" placeholder="请选择公告来源" clearable> <el-select v-model="formInfo.timeFrame" placeholder="请选择时间间隔" clearable @change="handleChangeTimeFrame">
<el-option v-for="item in optionsFrom" :key="item" :label="item" :value="item"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<img class="goBack" :src="goBack" alt="" @click="goBackFn"> <img class="goBack" :src="goBack" alt="" @click="goBackFn">
</el-form-item> </el-form-item>
<!-- <el-form-item>
<div class="searchButton"
:style="{ background: status ? 'Green' : 'gray', color: 'white' }">
<span :class="[!status ? 'el-icon-loading' : '']"></span>
{{ status ? '已连接' : '重连中' }}
</div>
</el-form-item> -->
</el-form> </el-form>
</div> </div>
<div class="ddkz-info-content"> <div class="ddkz-info-content">
...@@ -80,10 +73,12 @@ ...@@ -80,10 +73,12 @@
<el-button size="mini" type="info" @click="showPeopleList">人员列表</el-button> <el-button size="mini" type="info" @click="showPeopleList">人员列表</el-button>
</div> </div>
<div> <div>
<el-button size="mini" type="info" @click="showChatRoom" v-if="currentChatRoomInfo.status.value=='ONGOING'">聊天室</el-button> <el-button size="mini" type="info" @click="showChatRoom"
v-if="currentChatRoomInfo.status.value == 'ONGOING'">聊天室</el-button>
</div> </div>
<div> <div>
<el-button size="mini" type="info" @click="sendNotice" v-if="currentChatRoomInfo.status.value=='ONGOING'">发送公告</el-button> <el-button size="mini" type="info" @click="sendNotice"
v-if="currentChatRoomInfo.status.value == 'ONGOING'">发送公告</el-button>
<el-button size="mini" type="info" @click="sendEmail">邮箱</el-button> <el-button size="mini" type="info" @click="sendEmail">邮箱</el-button>
</div> </div>
</div> </div>
...@@ -93,7 +88,8 @@ ...@@ -93,7 +88,8 @@
<NoticeDialog ref="myNotice" :stompClient="stompClient" :currentChatRoomInfo="currentChatRoomInfo"></NoticeDialog> <NoticeDialog ref="myNotice" :stompClient="stompClient" :currentChatRoomInfo="currentChatRoomInfo"></NoticeDialog>
<ChatRoomDialog ref="myChatRoom" :currentChatRoomInfo="currentChatRoomInfo" :stompClient="stompClient"> <ChatRoomDialog ref="myChatRoom" :currentChatRoomInfo="currentChatRoomInfo" :stompClient="stompClient">
</ChatRoomDialog> </ChatRoomDialog>
<ChatRoomMemberDialog ref="mychatRoomMemberDialog" :currentChatRoomInfo="currentChatRoomInfo" @openSendEmailPage="openSendEmailPage"></ChatRoomMemberDialog> <ChatRoomMemberDialog ref="mychatRoomMemberDialog" :currentChatRoomInfo="currentChatRoomInfo"
@openSendEmailPage="openSendEmailPage"></ChatRoomMemberDialog>
<SendEmailDialog ref="myEmail" :fromUser="fromUser" :checkedUserList="checkedUserList"></SendEmailDialog> <SendEmailDialog ref="myEmail" :fromUser="fromUser" :checkedUserList="checkedUserList"></SendEmailDialog>
</div> </div>
</template> </template>
...@@ -108,7 +104,8 @@ import chatRoomMemberDialog from "@/view/ddkz/components/chatRoomMemberDialog.vu ...@@ -108,7 +104,8 @@ import chatRoomMemberDialog from "@/view/ddkz/components/chatRoomMemberDialog.vu
import sendEmailDialog from "@/view/ddkz/components/sendEmailDialog.vue"; import sendEmailDialog from "@/view/ddkz/components/sendEmailDialog.vue";
import textImg from '@/assets/img/ddkz/tool1.png'; import textImg from '@/assets/img/ddkz/tool1.png';
import excelImg from '@/assets/img/ddkz/tool5.png'; import excelImg from '@/assets/img/ddkz/tool5.png';
import { MAIL_ADDRESS } from "@/constant/user" import { MAIL_ADDRESS } from "@/constant/user";
import dayjs from "dayjs";
export default { export default {
data() { data() {
return { return {
...@@ -116,19 +113,19 @@ export default { ...@@ -116,19 +113,19 @@ export default {
excelImg: excelImg, excelImg: excelImg,
textImg: textImg, textImg: textImg,
formInfo: { formInfo: {
day: null, timeFrame: 5,
fromUser: null fromUser: null
}, },
options: [], options: [{ label: '5分钟', value: 5 }, { label: '10分钟', value: 10 }, { label: '30分钟', value: 30 }, { label: '60分钟', value: 60 }, { label: '1天', value: 1440 }],
optionsFrom: [], optionsFrom: [],
currentChatRoomInfo: {status: {}, teamInfo: {}}, currentChatRoomInfo: { status: {}, teamInfo: {} },
newsList: [], newsList: [],
publicNoticeList: [], publicNoticeList: [],
stompClient: { connected: false }, stompClient: { connected: false },
// peopleList: [], // peopleList: [],
notifications: [], notifications: [],
fromUser:'', fromUser: '',
checkedUserList:[] checkedUserList: []
// status:false // status:false
} }
}, },
...@@ -136,14 +133,14 @@ export default { ...@@ -136,14 +133,14 @@ export default {
NoticeDialog: NoticeDialog, NoticeDialog: NoticeDialog,
ChatRoomDialog: ChatRoomDialog, ChatRoomDialog: ChatRoomDialog,
ChatRoomMemberDialog: chatRoomMemberDialog, ChatRoomMemberDialog: chatRoomMemberDialog,
SendEmailDialog:sendEmailDialog SendEmailDialog: sendEmailDialog
}, },
methods: { methods: {
goBackFn() { goBackFn() {
this.$router.push({ name: '导调控制模块' }); this.$router.push({ name: '导调控制模块' });
}, },
subscribe(item) { subscribe(item) {
if(item.status.value != "ONGOING"){//未开始的聊天室禁止订阅 if (item.status.value != "ONGOING") {//未开始的聊天室禁止订阅
return; return;
} }
//取消大群聊的订阅和导演部的订阅 //取消大群聊的订阅和导演部的订阅
...@@ -174,57 +171,28 @@ export default { ...@@ -174,57 +171,28 @@ export default {
getRecordsByPagingFn(item) { getRecordsByPagingFn(item) {
getRecordsByPaging(item.id, 1, 100, '2023-01-01 00:00:00', getTime_extent(0).pre_rq_end).then(res1 => { getRecordsByPaging(item.id, 1, 100, '2023-01-01 00:00:00', getTime_extent(0).pre_rq_end).then(res1 => {
this.publicNoticeList = res1.records; this.publicNoticeList = res1.records;
this.dataOrderByParams(null, null); this.dataOrderByParams(5, null);
let newsArr = [], dayArr = [];
this.optionsFrom = []; this.optionsFrom = [];
this.publicNoticeList.forEach(item => { this.publicNoticeList.forEach(item => {
let obj = { time: '', news: [] };
if (this.optionsFrom.indexOf(item.fromUserId) == -1) { if (this.optionsFrom.indexOf(item.fromUserId) == -1) {
this.optionsFrom.push(item.fromUserId); this.optionsFrom.push(item.fromUserId);
} }
if (newsArr.some(newsArrChild => { return newsArrChild.time == item.createTime.slice(0, 10) })) {
newsArr.forEach(item1 => {
if (item1.time == item.createTime.slice(0, 10)) {
item1.news.push({ time: item.createTime, title: item.title, content: item.content, from: item.fromUserId, teamInfo: item.teamInfo });
}
})
} else {
obj.time = item.createTime.slice(0, 10);
dayArr.push(item.createTime.slice(0, 10));
this.options = dayArr;
obj.news.push({ time: item.createTime, title: item.title, content: item.content, from: item.fromUserId, teamInfo: item.teamInfo });
newsArr.push(obj);
}
}); });
}); });
}, },
dataOrderByParams(day, user) { dataOrderByParams(timeFrame, user) {
let newsArr = []; let newsArr = [];
let tmpArr = this.publicNoticeList; let tmpArr = this.publicNoticeList;
if (day == null && user != null) { if (user != null) {
tmpArr = this.publicNoticeList.filter(item => { return item.fromUserId == user }); tmpArr = this.publicNoticeList.filter(item => { return item.fromUserId == user });
} else if (day != null && user == null) {
tmpArr = this.publicNoticeList.filter(item => { return item.createTime.slice(0, 10) == day });
} else if (day != null && user != null) {
tmpArr = this.publicNoticeList.filter(item => { return item.fromUserId == user && item.createTime.slice(0, 10) == day });
} }
tmpArr.forEach(item => { tmpArr.forEach(item => {
let obj = { time: '', news: [] }; let fileUrl = item.attachment ? 'api/rest/file/viewPicture/CHAT?objectName=' + item.attachment : null;
let fileUrl = null; newsArr.push({ time: item.createTime, title: item.title, content: item.content, from: item.fromUserId, teamInfo: item.teamInfo, url: fileUrl, type: item.messageForm, attachment: item.attachment });
fileUrl = item.attachment ? 'api/rest/file/viewPicture/CHAT?objectName=' + item.attachment : null;
if (newsArr.some(newsArrChild => { return newsArrChild.time == item.createTime.slice(0, 10) })) {
newsArr.forEach(item1 => {
if (item1.time == item.createTime.slice(0, 10)) {
item1.news.push({ time: item.createTime, title: item.title, content: item.content, from: item.fromUserId, teamInfo: item.teamInfo, url: fileUrl, type: item.messageForm, attachment: item.attachment });
}
})
} else {
obj.time = item.createTime.slice(0, 10);
obj.news.push({ time: item.createTime, title: item.title, content: item.content, from: item.fromUserId, teamInfo: item.teamInfo, url: fileUrl, type: item.messageForm, attachment: item.attachment });
newsArr.push(obj);
}
}); });
this.newsList = newsArr; // this.newsList = this.splitIntoHours(tmpArr[tmpArr.length - 1].createTime, tmpArr[0].createTime, newsArr, timeFrame);
this.newsList = this.groupByTime(newsArr, timeFrame);
// console.log(this.newsList);
}, },
sendNotice() { sendNotice() {
this.$nextTick(() => { this.$nextTick(() => {
...@@ -241,7 +209,7 @@ export default { ...@@ -241,7 +209,7 @@ export default {
this.$refs.mychatRoomMemberDialog.showDialog(); this.$refs.mychatRoomMemberDialog.showDialog();
}) })
}, },
openSendEmailPage(data){ openSendEmailPage(data) {
this.checkedUserList = data; this.checkedUserList = data;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.myEmail.showDialog(); this.$refs.myEmail.showDialog();
...@@ -314,31 +282,55 @@ export default { ...@@ -314,31 +282,55 @@ export default {
}).catch(error => { }).catch(error => {
this.$message.error(error); this.$message.error(error);
}) })
}
},
watch: {
'formInfo.day'(newVal, oldVal) {
if (newVal == '') {
this.formInfo.day = null;
this.dataOrderByParams(null, this.formInfo.fromUser);
} else {
this.dataOrderByParams(newVal, this.formInfo.fromUser);
}
}, },
'formInfo.fromUser'(newVal, oldVal) { groupByTime(data, timeFrame) {
if (newVal == '') { let tmp = [], timeInterval = 0, startTime = null, endTime = null;
this.formInfo.fromUser = null; data.forEach(item => {
this.dataOrderByParams(this.formInfo.day, null); let obj = { time: '', news: [] };
} else { let timeStamp = Date.parse(item.time);
this.dataOrderByParams(this.formInfo.day, newVal); timeInterval = timeStamp % (timeFrame * 60 * 1000);
startTime = dayjs((timeStamp - timeInterval)).format('YYYY-MM-DD HH:mm:ss');
endTime = dayjs((timeStamp + (timeFrame * 60 * 1000 - timeInterval))).format('YYYY-MM-DD HH:mm:ss');
if (tmp.some(newsArrChild => { return newsArrChild.time == (startTime + ' ~ ' + endTime) })) {
tmp.forEach(item1 => {
if (item1.time == (startTime + ' ~ ' + endTime)) {
item1.news.push(item);
}
})
} else {
obj.time = startTime + ' ~ ' + endTime;
obj.news.push(item);
tmp.push(obj);
}
});
return tmp;
},
splitIntoHours(startTime, endTime, data, timeFrame) {
let start = new Date(startTime); // 将开始时间转换为日期对象
let end = new Date(endTime); // 将结束时间转换为日期对象
let hoursArray = []; // 创建空数组存放每小时的时间点
while (start < end) {
let tmp = [];
data.forEach(item => {
if (Date.parse(item.time) >= start.getTime() && Date.parse(item.time) < start.getTime() + (timeFrame * 60 * 1000)) {
tmp.push(item);
}
})
hoursArray.unshift(tmp); // 添加当前时间到数组中
start.setMinutes(start.getMinutes() + timeFrame); // 设置下一次循环的起始时间(+5分钟)
} }
let returnData = hoursArray.filter(item => item.length > 0);
return returnData;
}, },
// 'stompClient.connected':{
// handler(newVal,oldVal){ handleChangeFromUser(val) {
// this.status = newVal; // debugger
// }, this.formInfo.timeFrame = 5;
// immediate:true this.dataOrderByParams(5, val ? val : null);
// } },
handleChangeTimeFrame(val) {
this.dataOrderByParams(val, this.formInfo.fromUser);
}
}, },
computed: { computed: {
userInfo() { userInfo() {
...@@ -359,6 +351,7 @@ export default { ...@@ -359,6 +351,7 @@ export default {
//获取当前公告列表 //获取当前公告列表
this.getRecordsByPagingFn(this.currentChatRoomInfo); this.getRecordsByPagingFn(this.currentChatRoomInfo);
this.fromUser = this.userInfo.email; this.fromUser = this.userInfo.email;
this.formInfo.timeFrame = 5;
} }
} }
</script> </script>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<div class="pagination-div"> <div class="pagination-div">
<el-pagination class="myPagination" background layout="total, sizes, prev, pager, next, jumper" <el-pagination class="myPagination" background layout="total, sizes, prev, pager, next, jumper"
:current-page="pageObj.currentPage" :total="pageObj.total" @current-change="handleCurrentChange" :current-page="pageObj.currentPage" :total="pageObj.total" @current-change="handleCurrentChange"
@size-change="handleSizeChange" :page-size="pageObj.everySize" :page-sizes="[10, 20, 50, 100]"> @size-change="handleSizeChange" :page-size="pageObj.pageSize" :page-sizes="[10, 20, 50, 100]">
</el-pagination> </el-pagination>
</div> </div>
</div> </div>
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
meetingList: [], meetingList: [],
pageObj: { pageObj: {
currentPage: 1, currentPage: 1,
everySize: 10, pageSize: 10,
total: 0 total: 0
} }
} }
...@@ -107,7 +107,7 @@ export default { ...@@ -107,7 +107,7 @@ export default {
}, },
handleSizeChange(pageSize) { handleSizeChange(pageSize) {
this.pageObj.everySize = pageSize; this.pageObj.pageSize = pageSize;
this.searchChatList(); this.searchChatList();
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment