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

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

parent 088256df
......@@ -3,27 +3,20 @@
<div class="ddkz-info-selection">
<el-form ref="form" :inline="true" :model="formInfo" class="demo-form-inline">
<el-form-item>
<el-select v-model="formInfo.day" placeholder="请选择日期" clearable>
<el-option v-for="item in options" :key="item" :label="item" :value="item">
<el-select v-model="formInfo.fromUser" placeholder="请选择公告来源" clearable @change="handleChangeFromUser">
<el-option v-for="item in optionsFrom" :key="item" :label="item" :value="item">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select v-model="formInfo.fromUser" placeholder="请选择公告来源" clearable>
<el-option v-for="item in optionsFrom" :key="item" :label="item" :value="item">
<el-select v-model="formInfo.timeFrame" placeholder="请选择时间间隔" clearable @change="handleChangeTimeFrame">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<img class="goBack" :src="goBack" alt="" @click="goBackFn">
</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>
</div>
<div class="ddkz-info-content">
......@@ -80,10 +73,12 @@
<el-button size="mini" type="info" @click="showPeopleList">人员列表</el-button>
</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>
<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>
</div>
</div>
......@@ -93,7 +88,8 @@
<NoticeDialog ref="myNotice" :stompClient="stompClient" :currentChatRoomInfo="currentChatRoomInfo"></NoticeDialog>
<ChatRoomDialog ref="myChatRoom" :currentChatRoomInfo="currentChatRoomInfo" :stompClient="stompClient">
</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>
</div>
</template>
......@@ -108,7 +104,8 @@ import chatRoomMemberDialog from "@/view/ddkz/components/chatRoomMemberDialog.vu
import sendEmailDialog from "@/view/ddkz/components/sendEmailDialog.vue";
import textImg from '@/assets/img/ddkz/tool1.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 {
data() {
return {
......@@ -116,19 +113,19 @@ export default {
excelImg: excelImg,
textImg: textImg,
formInfo: {
day: null,
timeFrame: 5,
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: [],
currentChatRoomInfo: {status: {}, teamInfo: {}},
currentChatRoomInfo: { status: {}, teamInfo: {} },
newsList: [],
publicNoticeList: [],
stompClient: { connected: false },
// peopleList: [],
notifications: [],
fromUser:'',
checkedUserList:[]
fromUser: '',
checkedUserList: []
// status:false
}
},
......@@ -136,14 +133,14 @@ export default {
NoticeDialog: NoticeDialog,
ChatRoomDialog: ChatRoomDialog,
ChatRoomMemberDialog: chatRoomMemberDialog,
SendEmailDialog:sendEmailDialog
SendEmailDialog: sendEmailDialog
},
methods: {
goBackFn() {
this.$router.push({ name: '导调控制模块' });
},
subscribe(item) {
if(item.status.value != "ONGOING"){//未开始的聊天室禁止订阅
if (item.status.value != "ONGOING") {//未开始的聊天室禁止订阅
return;
}
//取消大群聊的订阅和导演部的订阅
......@@ -174,57 +171,28 @@ export default {
getRecordsByPagingFn(item) {
getRecordsByPaging(item.id, 1, 100, '2023-01-01 00:00:00', getTime_extent(0).pre_rq_end).then(res1 => {
this.publicNoticeList = res1.records;
this.dataOrderByParams(null, null);
let newsArr = [], dayArr = [];
this.dataOrderByParams(5, null);
this.optionsFrom = [];
this.publicNoticeList.forEach(item => {
let obj = { time: '', news: [] };
if (this.optionsFrom.indexOf(item.fromUserId) == -1) {
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 tmpArr = this.publicNoticeList;
if (day == null && user != null) {
if (user != null) {
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 => {
let obj = { time: '', news: [] };
let fileUrl = null;
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);
}
let fileUrl = item.attachment ? 'api/rest/file/viewPicture/CHAT?objectName=' + item.attachment : 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 });
});
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() {
this.$nextTick(() => {
......@@ -241,7 +209,7 @@ export default {
this.$refs.mychatRoomMemberDialog.showDialog();
})
},
openSendEmailPage(data){
openSendEmailPage(data) {
this.checkedUserList = data;
this.$nextTick(() => {
this.$refs.myEmail.showDialog();
......@@ -314,31 +282,55 @@ export default {
}).catch(error => {
this.$message.error(error);
})
}
},
watch: {
'formInfo.day'(newVal, oldVal) {
if (newVal == '') {
this.formInfo.day = null;
this.dataOrderByParams(null, this.formInfo.fromUser);
groupByTime(data, timeFrame) {
let tmp = [], timeInterval = 0, startTime = null, endTime = null;
data.forEach(item => {
let obj = { time: '', news: [] };
let timeStamp = Date.parse(item.time);
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 {
this.dataOrderByParams(newVal, this.formInfo.fromUser);
obj.time = startTime + ' ~ ' + endTime;
obj.news.push(item);
tmp.push(obj);
}
});
return tmp;
},
'formInfo.fromUser'(newVal, oldVal) {
if (newVal == '') {
this.formInfo.fromUser = null;
this.dataOrderByParams(this.formInfo.day, null);
} else {
this.dataOrderByParams(this.formInfo.day, newVal);
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){
// this.status = newVal;
// },
// immediate:true
// }
handleChangeFromUser(val) {
// debugger
this.formInfo.timeFrame = 5;
this.dataOrderByParams(5, val ? val : null);
},
handleChangeTimeFrame(val) {
this.dataOrderByParams(val, this.formInfo.fromUser);
}
},
computed: {
userInfo() {
......@@ -359,6 +351,7 @@ export default {
//获取当前公告列表
this.getRecordsByPagingFn(this.currentChatRoomInfo);
this.fromUser = this.userInfo.email;
this.formInfo.timeFrame = 5;
}
}
</script>
......
......@@ -35,7 +35,7 @@
<div class="pagination-div">
<el-pagination class="myPagination" background layout="total, sizes, prev, pager, next, jumper"
: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>
</div>
</div>
......@@ -62,7 +62,7 @@ export default {
meetingList: [],
pageObj: {
currentPage: 1,
everySize: 10,
pageSize: 10,
total: 0
}
}
......@@ -107,7 +107,7 @@ export default {
},
handleSizeChange(pageSize) {
this.pageObj.everySize = pageSize;
this.pageObj.pageSize = pageSize;
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