refactor(enterpriseZone): 优化公告查看功能
- 移除 ElMessageBox 弹框显示方式- 添加详情页面和列表页面切换逻辑 - 优化公告内容展示样式 - 增加返回列表按钮
This commit is contained in:
parent
14f9a8182e
commit
f394d50cbf
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import NavMenu from 'components/Navmenu/index.vue'
|
import NavMenu from 'components/Navmenu/index.vue'
|
||||||
import { ElMessageBox } from 'element-plus'
|
|
||||||
import {
|
import {
|
||||||
getListApi, //列表
|
getListApi, //列表
|
||||||
} from 'http/api/info'
|
} from 'http/api/info'
|
||||||
|
|
||||||
const leaseList = ref([
|
const leaseList = ref([
|
||||||
{
|
{
|
||||||
noticeContent: '',
|
noticeContent: '',
|
||||||
|
|
@ -11,6 +11,14 @@ const leaseList = ref([
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// 添加控制显示详情的状态
|
||||||
|
const showDetail = ref(false)
|
||||||
|
const currentNotice = ref({
|
||||||
|
noticeContent: '',
|
||||||
|
noticeTitle: '',
|
||||||
|
createTime: ''
|
||||||
|
})
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
leaseList.value = []
|
leaseList.value = []
|
||||||
const { data: res }: any = await getListApi()
|
const { data: res }: any = await getListApi()
|
||||||
|
|
@ -20,13 +28,18 @@ const getList = async () => {
|
||||||
|
|
||||||
const handleRowClick = (row: any) => {
|
const handleRowClick = (row: any) => {
|
||||||
console.log('🚀 ~ handleRowClick ~ row', row)
|
console.log('🚀 ~ handleRowClick ~ row', row)
|
||||||
// 弹框显示消息内容
|
// 设置当前选中的公告并显示详情页面
|
||||||
ElMessageBox.alert(row.noticeContent, '消息内容', {
|
currentNotice.value = {
|
||||||
showConfirmButton: false,
|
noticeContent: decodeURIComponent(row.noticeContent),
|
||||||
showCancelButton: true,
|
noticeTitle: row.noticeTitle,
|
||||||
cancelButtonText: '关闭',
|
createTime: row.createTime
|
||||||
dangerouslyUseHTMLString: true,
|
}
|
||||||
})
|
showDetail.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回列表
|
||||||
|
const handleBack = () => {
|
||||||
|
showDetail.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
@ -39,25 +52,96 @@ onMounted(() => {
|
||||||
<NavMenu />
|
<NavMenu />
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<el-table
|
<!-- 列表页面 -->
|
||||||
:data="leaseList"
|
<div v-if="!showDetail">
|
||||||
style="width: 100%"
|
<el-table
|
||||||
:header-cell-style="{ background: '#00a288', color: '#fff' }"
|
:data="leaseList"
|
||||||
@row-click="handleRowClick"
|
style="width: 100%"
|
||||||
>
|
:header-cell-style="{ background: '#00a288', color: '#fff' }"
|
||||||
<el-table-column align="center" type="index" label="序号" width="80" />
|
@row-click="handleRowClick"
|
||||||
<el-table-column align="center" prop="createTime" label="消息发布时间" />
|
>
|
||||||
<el-table-column align="center" prop="noticeContent" label="公告标题">
|
<el-table-column align="center" type="index" label="序号" width="80" />
|
||||||
<template #default="{ row }">
|
<el-table-column align="center" prop="createTime" label="消息发布时间" />
|
||||||
<div v-html="row.noticeTitle"></div>
|
<el-table-column align="center" prop="noticeContent" label="公告标题">
|
||||||
</template>
|
<template #default="{ row }">
|
||||||
</el-table-column>
|
<div v-html="row.noticeTitle"></div>
|
||||||
</el-table>
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 详情页面 -->
|
||||||
|
<div v-else class="detail-container">
|
||||||
|
<div class="detail-header">
|
||||||
|
<el-button @click="handleBack" style="margin-bottom: 20px;color: #00a288;">
|
||||||
|
<el-icon><ArrowLeft /></el-icon>
|
||||||
|
返回列表
|
||||||
|
</el-button>
|
||||||
|
<h2 class="detail-title" v-html="currentNotice.noticeTitle"></h2>
|
||||||
|
<p class="detail-time">发布时间:{{ currentNotice.createTime }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="detail-content">
|
||||||
|
<div v-html="currentNotice.noticeContent"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
height: 600px;
|
height: 600px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-container {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-header {
|
||||||
|
border-bottom: 1px solid #e4e7ed;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
margin: 10px 0;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-time {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-content {
|
||||||
|
background: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-content :deep(img) {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-content :deep(p) {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-content :deep(h1),
|
||||||
|
.detail-content :deep(h2),
|
||||||
|
.detail-content :deep(h3),
|
||||||
|
.detail-content :deep(h4),
|
||||||
|
.detail-content :deep(h5),
|
||||||
|
.detail-content :deep(h6) {
|
||||||
|
margin: 20px 0 15px 0;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue