<template>
|
<div class="container">
|
<div class="main-content">
|
<div class="list">
|
<div v-for="item in state.dataList">
|
<div>
|
<div><img src="src/assets/images/article.png"></div>
|
<div>{{item.title}}</div>
|
</div>
|
<span>
|
{{item.updateTime}}
|
</span>
|
</div>
|
</div>
|
<div class="pag-container">
|
<el-pagination
|
v-model:current-page="state.querys.pageNum"
|
v-model:page-size="state.querys.pageSize"
|
:page-sizes="[10,15,20,25]"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="state.total"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import {onMounted, ref, reactive, watch, onUnmounted, defineExpose} from "vue"
|
import { getNotice } from '@/api/home/homePage'
|
import useUserStore from '@/store/modules/user'
|
import {ElMessage} from "element-plus";
|
|
const route = useRoute()
|
const router = useRouter()
|
|
const state = reactive({
|
dataList: [],
|
querys:{
|
title: '',
|
content: '',
|
pageNum: 1,
|
pageSize: 10
|
},
|
total: null
|
})
|
|
const redirect = ref(undefined);
|
|
onMounted(()=>{
|
getData()
|
})
|
|
onUnmounted(()=>{
|
|
})
|
|
watch(route, (newRoute) => {
|
redirect.value = newRoute.query && newRoute.query.redirect;
|
}, { immediate: true });
|
|
const handleSizeChange = (val) => {
|
state.querys.pageSize = val
|
getData()
|
}
|
const handleCurrentChange = (val) => {
|
state.querys.pageNum = val
|
getData()
|
}
|
|
const getData = async ()=>{
|
const res = await getNotice(state.querys)
|
if(res.code == 200){
|
state.dataList = res.data.list
|
state.total = res.data.total
|
}else{
|
ElMessage.warning(res.message)
|
}
|
}
|
|
defineExpose({
|
getData
|
})
|
|
</script>
|
|
<style lang='scss' scoped>
|
.container {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
margin-top: 170px;
|
|
.main-content{
|
width: 1200px;
|
margin: 20px 0;
|
background: #fff;
|
border-radius: 4px;
|
box-shadow: 1px 1px 3px rgba(0,0,0,.04);
|
padding: 0 10px;
|
color: #333;
|
|
.list{
|
padding: 15px 0;
|
max-height: calc(100vh - 350px);
|
overflow-y: auto;
|
|
&>div{
|
display: flex;
|
padding: 10px;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1px dashed #ebeef5;
|
cursor: pointer;
|
border-radius: 4px;
|
font-size: 16px;
|
|
&>div{
|
display: flex;
|
align-items: center;
|
|
div:first-of-type{
|
width: 40px;
|
height: 40px;
|
margin-right: 10px;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
|
img{
|
width: 28px;
|
height: 28px;
|
}
|
}
|
div:last-of-type{
|
width: 1000px;
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
font-family: "PingFang SC";
|
}
|
}
|
span{
|
color: #999;
|
}
|
&:hover{
|
background: #f5f5f5;
|
}
|
&:active{
|
background: #425f9f;
|
color: #fff;
|
}
|
}
|
}
|
|
.pag-container{
|
width: 100%;
|
height: 80px;
|
display: flex;
|
align-items: center;
|
justify-content: right;
|
}
|
}
|
}
|
</style>
|