refactor: extract image form to standalone page and implement tags view store

- Created ImageForm.vue as standalone page for add/edit image functionality
- Removed dialog-based image form from VmImages.vue
- Implemented tagsViewStore for global tab state management
- Added automatic tab closing on form cancel/back
- Fixed data persistence issue when switching between image edits
- Removed quick actions section from ImageForm
- Updated router configuration for new image form route
This commit is contained in:
2025-11-28 14:15:29 +08:00
parent 067e0539ba
commit f7c3be1d30
45 changed files with 8776 additions and 6881 deletions
+161 -108
View File
@@ -1,99 +1,93 @@
<template>
<div class="announcements-container">
<div class="page-header">
<h2>官方公告</h2>
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布公告
</el-button>
</div>
<!-- 主容器 -->
<el-card class="main-container" shadow="never">
<!-- 搜索和操作栏 -->
<div class="filter-section">
<div class="filter-content">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="公告标题">
<el-input v-model="searchForm.title" placeholder="请输入公告标题" clearable style="width: 200px" />
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
style="width: 240px"
/>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable style="width: 150px">
<el-option label="已发布" value="published" />
<el-option label="草稿" value="draft" />
<el-option label="已下线" value="offline" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
<div class="action-bar">
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布公告
</el-button>
</div>
</div>
</div>
<!-- 搜索区域 -->
<el-card class="search-card">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="公告标题">
<el-input v-model="searchForm.title" placeholder="请输入公告标题" clearable />
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
/>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
<el-option label="已发布" value="published" />
<el-option label="草稿" value="draft" />
<el-option label="已下线" value="offline" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 数据表格 -->
<div class="table-section">
<el-table
v-loading="loading"
:data="tableData"
style="width: 100%"
row-key="id"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="title" label="公告标题" min-width="200" show-overflow-tooltip />
<el-table-column prop="publisher" label="发布人" width="120" />
<el-table-column prop="publishTime" label="发布时间" width="180" />
<el-table-column prop="viewCount" label="查看数" width="100" align="center" />
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="scope">
<el-tag :type="getStatusType(scope.row.status)">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="220" fixed="right">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)">查看</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
<el-button
type="warning"
link
@click="handleChangeStatus(scope.row)"
v-if="scope.row.status !== 'offline'"
>下线</el-button>
<el-button
type="danger"
link
@click="handleDelete(scope.row)"
v-if="scope.row.status === 'offline'"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 数据表格 -->
<el-card class="table-card">
<el-table
v-loading="loading"
:data="tableData"
border
style="width: 100%"
row-key="id"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="title" label="公告标题" min-width="200" show-overflow-tooltip />
<el-table-column prop="publisher" label="发布人" width="120" align="center" />
<el-table-column prop="publishTime" label="发布时间" width="180" align="center" />
<el-table-column prop="viewCount" label="查看数" width="100" align="center" />
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="scope">
<el-tag :type="getStatusType(scope.row.status)">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="220" align="center" fixed="right">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)">
<el-icon><view /></el-icon>查看
</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">
<el-icon><edit /></el-icon>编辑
</el-button>
<el-button
type="primary"
link
@click="handleChangeStatus(scope.row)"
v-if="scope.row.status !== 'offline'"
>
<el-icon><turn-off /></el-icon>下线
</el-button>
<el-button
type="primary"
link
@click="handleDelete(scope.row)"
v-if="scope.row.status === 'offline'"
>
<el-icon><delete /></el-icon>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<!-- 分页 -->
<el-pagination
v-model:current-page="pagination.currentPage"
v-model:page-size="pagination.pageSize"
@@ -102,6 +96,8 @@
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
class="pagination"
/>
</div>
</el-card>
@@ -365,32 +361,58 @@ onMounted(() => {
<style scoped>
.announcements-container {
padding: 20px;
padding: 0;
}
.page-header {
.main-container {
border: 1px solid #e1e8ed;
background: #ffffff;
}
.filter-section {
padding: 0;
border-bottom: 1px solid #e1e8ed;
background: #fafbfc;
}
.filter-content {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.search-card {
margin-bottom: 20px;
}
.search-form {
display: flex;
padding: 16px 20px;
gap: 20px;
flex-wrap: wrap;
}
.table-card {
margin-bottom: 20px;
.search-form {
margin: 0;
flex: 1;
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.pagination-container {
margin-top: 20px;
.search-form :deep(.el-form-item) {
margin-bottom: 0;
margin-right: 12px;
}
.action-bar {
display: flex;
gap: 12px;
flex-shrink: 0;
}
.table-section {
padding: 0;
}
.pagination {
margin-top: 20px;
padding: 16px 20px;
border-top: 1px solid #e1e8ed;
background: #fafbfc;
justify-content: flex-end;
}
@@ -420,4 +442,35 @@ onMounted(() => {
line-height: 1.8;
color: #606266;
}
</style>
/* 表格样式优化 */
:deep(.el-table) {
border: none;
color: #2c3e50;
}
:deep(.el-table__header) {
background: #f8f9fa;
}
:deep(.el-table th) {
background: #f8f9fa !important;
border-bottom: 2px solid #e1e8ed;
color: #2c3e50;
font-weight: 600;
font-size: 13px;
}
:deep(.el-table td) {
border-bottom: 1px solid #f0f2f5;
color: #34495e;
}
:deep(.el-table tr:hover > td) {
background-color: #f8f9fa !important;
}
:deep(.el-card__body) {
padding: 0;
}
</style>
+142 -92
View File
@@ -1,58 +1,61 @@
<template>
<div class="news-container">
<div class="page-header">
<h2>新闻咨询</h2>
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布新闻
</el-button>
</div>
<!-- 主容器 -->
<el-card class="main-container" shadow="never">
<!-- 搜索和操作栏 -->
<div class="filter-section">
<div class="filter-content">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="新闻标题">
<el-input v-model="searchForm.title" placeholder="请输入新闻标题" clearable style="width: 200px" />
</el-form-item>
<el-form-item label="新闻分类">
<el-select v-model="searchForm.category" placeholder="请选择分类" clearable style="width: 150px">
<el-option label="产品动态" value="product" />
<el-option label="技术干货" value="technology" />
<el-option label="行业资讯" value="industry" />
<el-option label="活动公告" value="activity" />
<el-option label="其他" value="other" />
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
style="width: 240px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
<div class="action-bar">
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布新闻
</el-button>
</div>
</div>
</div>
<!-- 搜索区域 -->
<el-card class="search-card">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="新闻标题">
<el-input v-model="searchForm.title" placeholder="请输入新闻标题" clearable />
</el-form-item>
<el-form-item label="新闻分类">
<el-select v-model="searchForm.category" placeholder="请选择分类" clearable>
<el-option label="产品动态" value="product" />
<el-option label="技术干货" value="technology" />
<el-option label="行业资讯" value="industry" />
<el-option label="活动公告" value="activity" />
<el-option label="其他" value="other" />
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 新闻列表卡片 -->
<div v-loading="loading" class="news-list">
<el-card class="table-card">
<!-- 数据表格 -->
<div class="table-section">
<el-table
v-loading="loading"
:data="newsData"
border
style="width: 100%"
row-key="id"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="title" label="新闻标题" min-width="200" show-overflow-tooltip />
@@ -68,33 +71,27 @@
<el-table-column prop="viewCount" label="阅读量" width="100" align="center" />
<el-table-column label="操作" width="220" align="center" fixed="right">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)">
<el-icon><view /></el-icon>查看
</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">
<el-icon><edit /></el-icon>编辑
</el-button>
<el-button type="danger" link @click="handleDelete(scope.row)">
<el-icon><delete /></el-icon>删除
</el-button>
<el-button type="primary" link @click="handleView(scope.row)">查看</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="danger" link @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination
v-model:current-page="pagination.currentPage"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</el-card>
</div>
<el-pagination
v-model:current-page="pagination.currentPage"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="pagination.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
class="pagination"
/>
</div>
</el-card>
<!-- 新闻详情对话框 -->
<el-dialog
@@ -400,36 +397,58 @@ onMounted(() => {
<style scoped>
.news-container {
padding: 20px;
padding: 0;
}
.page-header {
.main-container {
border: 1px solid #e1e8ed;
background: #ffffff;
}
.filter-section {
padding: 0;
border-bottom: 1px solid #e1e8ed;
background: #fafbfc;
}
.filter-content {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.search-card {
margin-bottom: 20px;
}
.search-form {
display: flex;
padding: 16px 20px;
gap: 20px;
flex-wrap: wrap;
}
.news-list {
margin-bottom: 20px;
}
.table-card {
margin-bottom: 20px;
}
.pagination-container {
margin-top: 20px;
.search-form {
margin: 0;
flex: 1;
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.search-form :deep(.el-form-item) {
margin-bottom: 0;
margin-right: 12px;
}
.action-bar {
display: flex;
gap: 12px;
flex-shrink: 0;
}
.table-section {
padding: 0;
}
.pagination {
margin-top: 20px;
padding: 16px 20px;
border-top: 1px solid #e1e8ed;
background: #fafbfc;
justify-content: flex-end;
}
@@ -487,4 +506,35 @@ onMounted(() => {
margin-right: 5px;
color: #E6A23C;
}
</style>
/* 表格样式优化 */
:deep(.el-table) {
border: none;
color: #2c3e50;
}
:deep(.el-table__header) {
background: #f8f9fa;
}
:deep(.el-table th) {
background: #f8f9fa !important;
border-bottom: 2px solid #e1e8ed;
color: #2c3e50;
font-weight: 600;
font-size: 13px;
}
:deep(.el-table td) {
border-bottom: 1px solid #f0f2f5;
color: #34495e;
}
:deep(.el-table tr:hover > td) {
background-color: #f8f9fa !important;
}
:deep(.el-card__body) {
padding: 0;
}
</style>
+170 -117
View File
@@ -1,108 +1,102 @@
<template>
<div class="policies-container">
<div class="page-header">
<h2>官方政策</h2>
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布政策
</el-button>
</div>
<!-- 主容器 -->
<el-card class="main-container" shadow="never">
<!-- 搜索和操作栏 -->
<div class="filter-section">
<div class="filter-content">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="政策标题">
<el-input v-model="searchForm.title" placeholder="请输入政策标题" clearable style="width: 200px" />
</el-form-item>
<el-form-item label="政策类型">
<el-select v-model="searchForm.type" placeholder="请选择政策类型" clearable style="width: 150px">
<el-option label="服务条款" value="terms" />
<el-option label="定价政策" value="pricing" />
<el-option label="隐私政策" value="privacy" />
<el-option label="合规政策" value="compliance" />
<el-option label="其他" value="other" />
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
style="width: 240px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
<div class="action-bar">
<el-button type="primary" @click="handleAdd">
<el-icon><plus /></el-icon>发布政策
</el-button>
</div>
</div>
</div>
<!-- 搜索区域 -->
<el-card class="search-card">
<el-form :inline="true" :model="searchForm" class="search-form">
<el-form-item label="政策标题">
<el-input v-model="searchForm.title" placeholder="请输入政策标题" clearable />
</el-form-item>
<el-form-item label="政策类型">
<el-select v-model="searchForm.type" placeholder="请选择政策类型" clearable>
<el-option label="服务条款" value="terms" />
<el-option label="定价政策" value="pricing" />
<el-option label="隐私政策" value="privacy" />
<el-option label="合规政策" value="compliance" />
<el-option label="其他" value="other" />
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
v-model="searchForm.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><search /></el-icon>搜索
</el-button>
<el-button @click="resetSearch">
<el-icon><refresh /></el-icon>重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 数据表格 -->
<div class="table-section">
<el-table
v-loading="loading"
:data="tableData"
style="width: 100%"
row-key="id"
:header-cell-style="{ background: '#fafafa', color: '#333', fontWeight: 600 }"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="title" label="政策标题" min-width="200" show-overflow-tooltip />
<el-table-column prop="type" label="政策类型" width="120" align="center">
<template #default="scope">
<el-tag :type="getPolicyTypeTag(scope.row.type)">
{{ getPolicyTypeText(scope.row.type) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="publisher" label="发布人" width="120" align="center" />
<el-table-column prop="publishTime" label="发布时间" width="180" align="center" />
<el-table-column prop="effectiveTime" label="生效时间" width="180" align="center" />
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="scope">
<el-tag :type="getStatusType(scope.row.status)">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="220" align="center" fixed="right">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)">查看</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
<el-button
type="warning"
link
@click="handleChangeStatus(scope.row)"
v-if="scope.row.status === 'active'"
>下线</el-button>
<el-button
type="danger"
link
@click="handleDelete(scope.row)"
v-if="scope.row.status === 'inactive'"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 数据表格 -->
<el-card class="table-card">
<el-table
v-loading="loading"
:data="tableData"
border
style="width: 100%"
row-key="id"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="title" label="政策标题" min-width="200" show-overflow-tooltip />
<el-table-column prop="type" label="政策类型" width="120" align="center">
<template #default="scope">
<el-tag :type="getPolicyTypeTag(scope.row.type)">
{{ getPolicyTypeText(scope.row.type) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="publisher" label="发布人" width="120" align="center" />
<el-table-column prop="publishTime" label="发布时间" width="180" align="center" />
<el-table-column prop="effectiveTime" label="生效时间" width="180" align="center" />
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="scope">
<el-tag :type="getStatusType(scope.row.status)">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="220" align="center" fixed="right">
<template #default="scope">
<el-button type="primary" link @click="handleView(scope.row)">
<el-icon><view /></el-icon>查看
</el-button>
<el-button type="primary" link @click="handleEdit(scope.row)">
<el-icon><edit /></el-icon>编辑
</el-button>
<el-button
type="primary"
link
@click="handleChangeStatus(scope.row)"
v-if="scope.row.status === 'active'"
>
<el-icon><turn-off /></el-icon>下线
</el-button>
<el-button
type="primary"
link
@click="handleDelete(scope.row)"
v-if="scope.row.status === 'inactive'"
>
<el-icon><delete /></el-icon>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<!-- 分页 -->
<el-pagination
v-model:current-page="pagination.currentPage"
v-model:page-size="pagination.pageSize"
@@ -111,6 +105,8 @@
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
class="pagination"
/>
</div>
</el-card>
@@ -435,32 +431,58 @@ onMounted(() => {
<style scoped>
.policies-container {
padding: 20px;
padding: 0;
}
.page-header {
.main-container {
border: 1px solid #e1e8ed;
background: #ffffff;
}
.filter-section {
padding: 0;
border-bottom: 1px solid #e1e8ed;
background: #fafbfc;
}
.filter-content {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.search-card {
margin-bottom: 20px;
}
.search-form {
display: flex;
padding: 16px 20px;
gap: 20px;
flex-wrap: wrap;
}
.table-card {
margin-bottom: 20px;
.search-form {
margin: 0;
flex: 1;
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.pagination-container {
margin-top: 20px;
.search-form :deep(.el-form-item) {
margin-bottom: 0;
margin-right: 12px;
}
.action-bar {
display: flex;
gap: 12px;
flex-shrink: 0;
}
.table-section {
padding: 0;
}
.pagination {
margin-top: 20px;
padding: 16px 20px;
border-top: 1px solid #e1e8ed;
background: #fafbfc;
justify-content: flex-end;
}
@@ -495,4 +517,35 @@ onMounted(() => {
line-height: 1.8;
color: #606266;
}
</style>
/* 表格样式优化 */
:deep(.el-table) {
border: none;
color: #2c3e50;
}
:deep(.el-table__header) {
background: #f8f9fa;
}
:deep(.el-table th) {
background: #f8f9fa !important;
border-bottom: 2px solid #e1e8ed;
color: #2c3e50;
font-weight: 600;
font-size: 13px;
}
:deep(.el-table td) {
border-bottom: 1px solid #f0f2f5;
color: #34495e;
}
:deep(.el-table tr:hover > td) {
background-color: #f8f9fa !important;
}
:deep(.el-card__body) {
padding: 0;
}
</style>