<template>
|
<view class="box" >
|
<!-- 自定义导航栏 -->
|
<view class="navBarBox fix">
|
<!-- 状态栏占位 -->
|
<view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
|
<!-- 真正的导航栏内容 -->
|
<view class="navBar" >
|
<view class="barText">{{user.name}}收到的工作通知</view>
|
<!-- <view style="flex: 1;" @click="loginOut">退出</view> -->
|
</view>
|
</view>
|
<!-- 页面内容 -->
|
<view style="display: flex;flex-direction: column;">
|
<view class="buttonGroup">
|
<view style="display: flex;">
|
<view v-for="(button, index) in buttons" :key="index" class="buttonItem"
|
:class="{ 'active': selectedSaleAnalysis === button.label,
|
'red': button.label === 'red',
|
'orange':button.label === 'orange',
|
'yellow':button.label === 'yellow',
|
'blue': button.label === 'blue'}"
|
@click="handleButtonClick(button)">
|
{{ button.name }}
|
</view>
|
</view>
|
<view class="switchBtn">
|
<text style="margin-right: 7px;">是否紧临</text>
|
<u-switch v-model="checked" size="20" @change="clickSwitch"></u-switch>
|
</view>
|
</view>
|
<view class="noticeList">
|
<view class="listHead">
|
<u-checkbox-group style="margin-left: 15px;">
|
<u-checkbox v-model="isReadOnly" @change="chooseRead"></u-checkbox>只显示未读
|
</u-checkbox-group>
|
</view>
|
<view class="listContent" v-if="noticeList.length > 0" >
|
<view v-for="(item, index) in noticeList" :key="index" class="itemContent" >
|
<view class="content" v-if="item.isRead" >
|
<text style="color:rgb(17, 204, 33);" @click="toDetail(item)">[已读]</text>
|
<text @click="toDetail(item)">[{{item.colorContent}}]</text>
|
<text @click="toDetail(item)">{{item.title}},{{item.content}}</text>
|
<view v-if="item.isRead" style="float: right; width: 80px;margin-top: 3px;">
|
<u-button @click="toDetail(item)"v-if="item.buttonContent == '已叫应'" size="mini" style="margin-bottom: 10px;background-color:rgb(17, 204, 33);color: white;">
|
{{item.buttonContent}}
|
</u-button>
|
<u-button v-else-if="item.buttonContent == '未叫应'" type="error" size="mini" style="margin-bottom: 10px;" @click="openDialog(item)">
|
{{item.buttonContent}}
|
</u-button>
|
<u-button @click="toDetail(item)" v-else type="error" size="mini" style="margin-bottom: 10px;">
|
{{item.buttonContent}}
|
</u-button>
|
</view>
|
</view>
|
<view class="contentNoRead" v-else>
|
<u-badge :is-dot="true" type="error" style="position: absolute;"></u-badge>
|
<text style="color: red;margin-left:10px;" @click="toDetail(item)">[未读]</text>
|
<text @click="toDetail(item)">[{{item.colorContent}}]</text>
|
<text @click="toDetail(item)">{{item.title}},{{item.content}}</text>
|
<view style="float: right; width: 80px;margin-top: 3px;">
|
<u-button @click="toDetail(item)" v-if="item.buttonContent == '已叫应'" size="mini" style="margin-bottom: 10px;background-color:rgb(17, 204, 33);color: white;">
|
{{item.buttonContent}}
|
</u-button>
|
<u-button v-else-if="item.buttonContent == '未叫应'" type="error" size="mini" style="margin-bottom: 10px;" @click="openDialog(item)">
|
{{item.buttonContent}}
|
</u-button>
|
<u-button @click="toDetail(item)" v-else type="error" size="mini" style="margin-bottom: 10px;">
|
{{item.buttonContent}}
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-else>
|
<u-empty
|
mode="data"
|
icon="http://cdn.uviewui.com/uview/empty/data.png"
|
margin-top="50%">
|
</u-empty>
|
</view>
|
</view>
|
</view>
|
<dia ref="showDialog" @close="close"></dia>
|
<tabBar :currentPagePath="page" :tabBarList="tabBarLists"></tabBar>
|
</view>
|
</template>
|
|
<script>
|
import { getNotice, update } from '../../../api/notice';
|
import dia from './dialog.vue';
|
import tabBar from '../tabBarIndex.vue'
|
export default {
|
components:{
|
dia,
|
tabBar
|
},
|
data() {
|
return {
|
tabBarLists: [],
|
// 状态栏高度
|
statusBarHeight: 0,
|
checked: true,
|
isReadOnly: false,
|
showDialog: false,
|
data: {
|
pageIndex: 1,
|
pageSize: 1000,
|
searchParams: {
|
emergType: 1,//1-紧急;2-常规
|
warningLevel: 1,//1-红色预警;2-橙色预警;3-黄色预警;4-蓝色预警
|
readStatus: null//0-未读,1-已读
|
}
|
},
|
buttons: [{
|
label: 'red',
|
name: '红'
|
},
|
{
|
label: 'orange',
|
name: '橙'
|
},
|
{
|
label: 'yellow',
|
name: '黄'
|
},
|
{
|
label: 'blue',
|
name: '蓝'
|
},
|
],
|
selectedSaleAnalysis: 'red',
|
noticeListCopy: [],
|
noticeListCopyRead:[],
|
noticeList: [],
|
user: {
|
name: ''
|
},
|
page: 'pages/tabBar/notice/notice'
|
}
|
},
|
onShow () {
|
this.tabBarLists = uni.getStorageSync('tabBarList');
|
this.user.name = uni.getStorageSync('user').realName + uni.getStorageSync('user').name;
|
// this.selectedSaleAnalysis = 'red',
|
this.getNoticeList();
|
// this.page = this.$route.meta.pagePath;
|
},
|
onLoad() {
|
//获取手机状态栏高度
|
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
|
uni.hideTabBar();
|
// uni.startPullDownRefresh();
|
},
|
methods: {
|
getNoticeList() {
|
this.data.searchParams.readStatus = this.isReadOnly ? 0 : null;
|
this.data.searchParams.emergType = this.checked ? 1 : 2;
|
this.data.searchParams.warningLevel = this.selectedSaleAnalysis =='red' ? 1 : this.selectedSaleAnalysis =='orange' ? 2: this.selectedSaleAnalysis =='yellow'? 3 : 4;
|
getNotice(this.data).then(res => {
|
console.log("res",res);
|
if (res.code == 100) {
|
this.noticeList = res.data ? res.data : [];
|
this.noticeListCopy = this.noticeList;
|
if (this.noticeList.length > 0) {
|
this.noticeList.forEach((item, index) => {
|
this.noticeList[index].isRead = item.readStatus == 1 ? true : false;
|
this.noticeList[index].colorContent = item.warningLevel == 1 ? '红色预警': item.warningLevel == 2 ? '橙色预警': item.warningLevel == 3 ? '黄色预警':'蓝色预警';
|
this.noticeList[index].buttonContent = item.responseStatus == 1 ? '待叫应': item.responseStatus == 2 ? '已叫应' : '超时未叫应';
|
});
|
}
|
}
|
})
|
},
|
handleButtonClick(button) {
|
this.selectedSaleAnalysis = button.label;
|
this.getNoticeList();
|
},
|
chooseRead(e) {
|
this.isReadOnly = e;
|
this.getNoticeList();
|
// if(e) {
|
// this.noticeList = this.noticeList.filter(item => item.isRead == false);
|
// }else {
|
// this.getNoticeList();
|
// }
|
},
|
toDetail(item) {
|
console.log("item",item)
|
if (item.readStatus === 0) {
|
this.updateReadStatus(item);
|
}
|
uni.navigateTo({
|
url: `/pages/tabBar/notice/detail?data=` + encodeURIComponent(JSON.stringify(item))
|
})
|
},
|
updateReadStatus(item) {
|
update({id: item.id}).then(res => {});
|
},
|
openDialog(item){
|
this.$refs.showDialog.id = item.id;
|
this.$refs.showDialog.open();
|
console.log("点击",this.showDialog)
|
},
|
close(){
|
console.log("触发close")
|
this.getNoticeList();
|
},
|
loginOut() {
|
uni.removeStorageSync('tk');
|
uni.removeStorageSync('uid');
|
uni.removeStorageSync('user');
|
uni.navigateTo({
|
url: `/pages/index/index`
|
})
|
},
|
//下拉刷新
|
onPullDownRefresh() {
|
console.log('refresh');
|
setTimeout(() => {
|
uni.stopPullDownRefresh();
|
this.getNoticeList();
|
}, 1000);
|
},
|
clickSwitch(e) {
|
this.getNoticeList();
|
}
|
}
|
}
|
</script>
|
|
<style>
|
.box {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 100%;
|
}
|
.fix{
|
position: sticky;
|
top: 0;
|
left: 0;
|
right: 0;
|
width: 100%;
|
z-index: 1;
|
}
|
.navBarBox .navBar {
|
background-color:lightgrey;
|
height: 40px;
|
display: flex;
|
flex-direction: row;
|
justify-content: center;
|
align-items: center;
|
}
|
.barText{
|
/* margin-left: 20px; */
|
text-align: center;
|
width: 85%;
|
font-size: 16px;
|
/* text-align: center; */
|
font-weight: 600;
|
}
|
.statusBar{
|
background-color:lightgrey;
|
}
|
/* .navBarBox .navBar .logo {
|
width: 82rpx;
|
height: 82rpx;
|
margin-right: 10rpx;
|
} */
|
.buttonGroup{
|
margin: 18px 12px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
.buttonItem{
|
margin-left:5px;
|
color: white;
|
display: flex;
|
flex-direction: row;
|
justify-content: center;
|
align-items: center;
|
width: 47px;
|
height: 30px;
|
border-radius: 5px;
|
}
|
.active {
|
border: 1px solid gray;
|
}
|
.red {
|
background-color: red;
|
}
|
.orange {
|
background-color: rgb(251, 158, 13);
|
}
|
.yellow {
|
background-color: rgb(255, 223, 37);
|
}
|
.blue {
|
background-color: rgb(2, 167, 240);
|
}
|
.switchBtn{
|
display: flex;
|
align-items: center;
|
}
|
|
.listHead{
|
display: flex;
|
align-items: center;
|
background-color:lightgrey;
|
height: 35px;
|
}
|
.listContent{
|
display: flex;
|
flex-direction: column;
|
padding: 10px 10px;
|
}
|
.itemContent{
|
font-size: 16px;
|
color: gray;
|
margin-top: 10px;
|
border-bottom: 1px solid lightgrey;
|
|
}
|
.content{
|
text-overflow: ellipsis;
|
overflow: hidden;
|
white-space: nowrap;
|
}
|
.contentNoRead{
|
font-size: 14px;
|
}
|
</style>
|