verce-vue-test 0.0.111 → 0.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.111",
3
+ "version": "0.0.112",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -55,6 +55,7 @@ const searchableMenus: MenuSearchItem[] = [
55
55
  { value: '人民币匡算', path: '/rmb-estimation' },
56
56
  { value: '资金驾驶舱', path: '/fund-cockpit' },
57
57
  { value: '通知公告', path: '/notice-announcement' },
58
+ { value: '公告管理', path: '/notice-management' },
58
59
  { value: '占位符页面', path: '/placeholder' },
59
60
  { value: '关于', path: '/about' },
60
61
  ]
@@ -84,7 +85,13 @@ function toggleCollapse() {
84
85
  <template>
85
86
  <RouterView v-if="isFullscreenRoute" />
86
87
 
87
- <el-container v-else style="height: 100vh">
88
+ <el-container
89
+ v-else
90
+ :style="{
91
+ height: '100vh',
92
+ '--app-aside-width': isCollapse ? '64px' : '200px',
93
+ }"
94
+ >
88
95
  <el-aside :width="isCollapse ? '64px' : '200px'" style="background-color: #304156; transition: width 0.3s; overflow: hidden; height: 100vh">
89
96
  <div style="height: 50px; display: flex; align-items: center; padding-left: 20px; color: #fff; font-size: 16px; font-weight: bold; white-space: nowrap; overflow: hidden">
90
97
  <span v-if="!isCollapse">管理系统</span>
@@ -199,6 +206,10 @@ function toggleCollapse() {
199
206
  <el-icon><Bell /></el-icon>
200
207
  <span>通知公告</span>
201
208
  </el-menu-item>
209
+ <el-menu-item index="/notice-management">
210
+ <el-icon><EditPen /></el-icon>
211
+ <span>公告管理</span>
212
+ </el-menu-item>
202
213
  <el-menu-item index="/placeholder">
203
214
  <el-icon><Document /></el-icon>
204
215
  <span>占位符页面</span>
@@ -0,0 +1,153 @@
1
+ import baseHttpClient from '@/utils/baseHttpClient'
2
+
3
+ export type AnnouncementRecord = {
4
+ annouId: string
5
+ orgNo: string | null
6
+ annouTitle: string
7
+ annouSts: string
8
+ topFlag: string
9
+ createUserId: string | null
10
+ updateUserId: string | null
11
+ createTm: string
12
+ updateTm: string
13
+ annouLimitFlag: string
14
+ annouConte: string
15
+ effDt: string | null
16
+ expireDt: string | null
17
+ }
18
+
19
+ export type AnnouncementDetailRecord = AnnouncementRecord & {
20
+ orgList: unknown[]
21
+ roleList: unknown[]
22
+ userList: unknown[]
23
+ }
24
+
25
+ type AnnouncementPageData = {
26
+ total: number
27
+ list: AnnouncementRecord[]
28
+ pageNum: number
29
+ pageSize: number
30
+ size: number
31
+ pages: number
32
+ }
33
+
34
+ type AnnouncementResponse = {
35
+ code: string
36
+ message: string
37
+ data: AnnouncementPageData
38
+ }
39
+
40
+ type AnnouncementDetailResponse = {
41
+ code: string
42
+ message: string
43
+ data: Partial<AnnouncementDetailRecord>
44
+ }
45
+
46
+ export type AnnouncementPageResult = {
47
+ total: number
48
+ list: AnnouncementRecord[]
49
+ currentPage: number
50
+ pageSize: number
51
+ }
52
+
53
+ function toPositiveInteger(value: unknown, field: string) {
54
+ const number = Number(value)
55
+ if (!Number.isInteger(number) || number < 1) {
56
+ throw new Error(`公告接口返回的 ${field} 无效`)
57
+ }
58
+ return number
59
+ }
60
+
61
+ function normalizeRecord(source: Partial<AnnouncementRecord>): AnnouncementRecord {
62
+ const annouId = String(source.annouId ?? '').trim()
63
+ if (!annouId) throw new Error('公告接口返回的 annouId 为空')
64
+
65
+ return {
66
+ annouId,
67
+ orgNo: source.orgNo == null ? null : String(source.orgNo),
68
+ annouTitle: String(source.annouTitle ?? ''),
69
+ annouSts: String(source.annouSts ?? ''),
70
+ topFlag: String(source.topFlag ?? '0'),
71
+ createUserId: source.createUserId == null ? null : String(source.createUserId),
72
+ updateUserId: source.updateUserId == null ? null : String(source.updateUserId),
73
+ createTm: String(source.createTm ?? ''),
74
+ updateTm: String(source.updateTm ?? ''),
75
+ annouLimitFlag: String(source.annouLimitFlag ?? '0'),
76
+ annouConte: String(source.annouConte ?? ''),
77
+ effDt: source.effDt == null ? null : String(source.effDt),
78
+ expireDt: source.expireDt == null ? null : String(source.expireDt),
79
+ }
80
+ }
81
+
82
+ /** 查询公告管理列表,分页字段严格使用接口规定的 currentPage/pageSize。 */
83
+ export async function queryAnnouncements(
84
+ currentPage: number,
85
+ pageSize: number,
86
+ signal?: AbortSignal,
87
+ ): Promise<AnnouncementPageResult> {
88
+ const query = new URLSearchParams({
89
+ currentPage: String(currentPage),
90
+ pageSize: String(pageSize),
91
+ })
92
+ const response = await baseHttpClient.get<AnnouncementResponse>(
93
+ `/uaa/announcement/get?${query.toString()}`,
94
+ { signal },
95
+ )
96
+
97
+ if (response.code !== '0000') {
98
+ throw new Error(response.message || '公告查询失败')
99
+ }
100
+ if (!response.data || !Array.isArray(response.data.list)) {
101
+ throw new Error('公告接口返回结构不正确')
102
+ }
103
+
104
+ const total = Number(response.data.total)
105
+ if (!Number.isInteger(total) || total < 0) {
106
+ throw new Error('公告接口返回的 total 无效')
107
+ }
108
+
109
+ return {
110
+ total,
111
+ list: response.data.list.map(normalizeRecord),
112
+ currentPage: toPositiveInteger(response.data.pageNum || currentPage, 'pageNum'),
113
+ pageSize: toPositiveInteger(response.data.pageSize || pageSize, 'pageSize'),
114
+ }
115
+ }
116
+
117
+ /** 根据 annouId 查询公告详情。 */
118
+ export async function queryAnnouncementDetail(
119
+ annouId: string,
120
+ signal?: AbortSignal,
121
+ ): Promise<AnnouncementDetailRecord> {
122
+ const normalizedId = String(annouId ?? '').trim()
123
+ if (!normalizedId) {
124
+ throw new Error('公告 annouId 不能为空')
125
+ }
126
+
127
+ const query = new URLSearchParams({ annouId: normalizedId })
128
+ const response = await baseHttpClient.get<AnnouncementDetailResponse>(
129
+ `/uaa/announcement/get/id?${query.toString()}`,
130
+ { signal },
131
+ )
132
+
133
+ if (response.code !== '0000') {
134
+ throw new Error(response.message || '公告详情查询失败')
135
+ }
136
+ if (!response.data || typeof response.data !== 'object' || Array.isArray(response.data)) {
137
+ throw new Error('公告详情接口返回结构不正确')
138
+ }
139
+
140
+ const listFields = ['orgList', 'roleList', 'userList'] as const
141
+ for (const field of listFields) {
142
+ if (response.data[field] !== undefined && !Array.isArray(response.data[field])) {
143
+ throw new Error(`公告详情接口返回的 ${field} 无效`)
144
+ }
145
+ }
146
+
147
+ return {
148
+ ...normalizeRecord(response.data),
149
+ orgList: response.data.orgList ?? [],
150
+ roleList: response.data.roleList ?? [],
151
+ userList: response.data.userList ?? [],
152
+ }
153
+ }
@@ -136,6 +136,21 @@ const router = createRouter({
136
136
  name: 'noticeDetail',
137
137
  component: () => import('../views/NoticeDetailView.vue'),
138
138
  },
139
+ {
140
+ path: '/notice-management',
141
+ name: 'noticeManagement',
142
+ component: () => import('../views/notice-management/index.vue'),
143
+ },
144
+ {
145
+ path: '/notice-management/create',
146
+ name: 'noticeManagementCreate',
147
+ component: () => import('../views/notice-management/edit.vue'),
148
+ },
149
+ {
150
+ path: '/notice-management/:id/edit',
151
+ name: 'noticeManagementEdit',
152
+ component: () => import('../views/notice-management/edit.vue'),
153
+ },
139
154
  {
140
155
  path: '/placeholder',
141
156
  name: 'placeholder',
@@ -792,17 +792,31 @@ onBeforeUnmount(() => {
792
792
  <el-table-column
793
793
  column-key="operation"
794
794
  label="操作"
795
- width="248"
795
+ width="280"
796
796
  fixed="right"
797
797
  align="center"
798
798
  disabled
799
799
  >
800
800
  <template #default="{ row }">
801
801
  <div class="row-actions">
802
- <el-button link type="primary" :icon="EditPen" @click.stop="openEditEditor(row)">
802
+ <el-button
803
+ link
804
+ type="primary"
805
+ :icon="EditPen"
806
+ :disabled="Boolean(getEditRestriction(row))"
807
+ :title="getEditRestriction(row)"
808
+ @click.stop="openEditEditor(row)"
809
+ >
803
810
  修改
804
811
  </el-button>
805
- <el-button link type="danger" :icon="Delete" @click.stop="handleDelete(row)">
812
+ <el-button
813
+ link
814
+ type="danger"
815
+ :icon="Delete"
816
+ :disabled="Boolean(getDeleteRestriction(row))"
817
+ :title="getDeleteRestriction(row)"
818
+ @click.stop="handleDelete(row)"
819
+ >
806
820
  删除
807
821
  </el-button>
808
822
  <el-button
@@ -1106,6 +1120,11 @@ onBeforeUnmount(() => {
1106
1120
  white-space: nowrap;
1107
1121
  }
1108
1122
 
1123
+ .row-actions .el-button {
1124
+ width: 78px;
1125
+ justify-content: center;
1126
+ }
1127
+
1109
1128
  .row-actions .el-button + .el-button {
1110
1129
  margin-left: 0;
1111
1130
  }
@@ -0,0 +1,33 @@
1
+ import baseHttpClient from '@/utils/baseHttpClient'
2
+ import { queryAnnouncementDetail, queryAnnouncements } from '@/api/announcement'
3
+
4
+ import type {
5
+ NoticeDetail,
6
+ NoticeListQuery,
7
+ NoticeListResponse,
8
+ NoticePayload,
9
+ } from './types'
10
+
11
+ export async function getNoticeList(query: NoticeListQuery): Promise<NoticeListResponse> {
12
+ const response = await queryAnnouncements(query.currentPage, query.pageSize)
13
+ return {
14
+ resultList: response.list,
15
+ totalCount: response.total,
16
+ }
17
+ }
18
+
19
+ export function getNoticeDetail(id: number | string) {
20
+ return queryAnnouncementDetail(String(id))
21
+ }
22
+
23
+ export function createNotice(payload: NoticePayload) {
24
+ return baseHttpClient.post<NoticeDetail>('/notices', payload)
25
+ }
26
+
27
+ export function updateNotice(id: number | string, payload: NoticePayload) {
28
+ return baseHttpClient.put<NoticeDetail>(`/notices/${id}`, payload)
29
+ }
30
+
31
+ export function deleteNotice(id: number | string) {
32
+ return baseHttpClient.delete<{ success: boolean; message: string }>(`/notices/${id}`)
33
+ }
@@ -0,0 +1,310 @@
1
+ <script setup lang="ts">
2
+ import { nextTick, ref, watch } from 'vue'
3
+ import {
4
+ Link,
5
+ List,
6
+ Reading,
7
+ RefreshLeft,
8
+ Tickets,
9
+ } from '@element-plus/icons-vue'
10
+
11
+ const props = withDefaults(defineProps<{
12
+ modelValue?: string
13
+ disabled?: boolean
14
+ }>(), {
15
+ modelValue: '',
16
+ disabled: false,
17
+ })
18
+
19
+ const emit = defineEmits<{
20
+ 'update:modelValue': [value: string]
21
+ change: [value: string]
22
+ }>()
23
+
24
+ const editorRef = ref<HTMLElement>()
25
+ const sourceMode = ref(false)
26
+ const localHtml = ref(props.modelValue)
27
+
28
+ watch(
29
+ () => props.modelValue,
30
+ (value) => {
31
+ if (value === localHtml.value) return
32
+ localHtml.value = value
33
+ syncEditorHtml()
34
+ },
35
+ )
36
+
37
+ function syncEditorHtml() {
38
+ void nextTick(() => {
39
+ if (editorRef.value && editorRef.value.innerHTML !== localHtml.value) {
40
+ editorRef.value.innerHTML = localHtml.value
41
+ }
42
+ })
43
+ }
44
+
45
+ function emitValue(value: string) {
46
+ localHtml.value = value
47
+ emit('update:modelValue', value)
48
+ emit('change', value)
49
+ }
50
+
51
+ function handleEditorInput() {
52
+ emitValue(editorRef.value?.innerHTML ?? '')
53
+ }
54
+
55
+ function handleSourceInput(value: string) {
56
+ emitValue(value)
57
+ }
58
+
59
+ function runCommand(command: string, value?: string) {
60
+ if (props.disabled) return
61
+ editorRef.value?.focus()
62
+ document.execCommand(command, false, value)
63
+ handleEditorInput()
64
+ }
65
+
66
+ function setBlock(tag: 'p' | 'h2' | 'blockquote' | 'pre') {
67
+ runCommand('formatBlock', tag)
68
+ }
69
+
70
+ function insertLink() {
71
+ const url = window.prompt('请输入链接地址')
72
+ if (!url) return
73
+ runCommand('createLink', url)
74
+ }
75
+
76
+ function toggleSourceMode() {
77
+ sourceMode.value = !sourceMode.value
78
+ if (!sourceMode.value) syncEditorHtml()
79
+ }
80
+
81
+ syncEditorHtml()
82
+ </script>
83
+
84
+ <template>
85
+ <div class="rich-text-editor" :class="{ 'is-disabled': disabled }">
86
+ <div class="editor-toolbar" aria-label="正文编辑工具栏">
87
+ <div class="toolbar-group">
88
+ <button type="button" title="正文" @mousedown.prevent @click="setBlock('p')">正文</button>
89
+ <button type="button" title="二级标题" @mousedown.prevent @click="setBlock('h2')">标题</button>
90
+ <button class="text-tool is-bold" type="button" title="加粗" @mousedown.prevent @click="runCommand('bold')">B</button>
91
+ <button class="text-tool is-italic" type="button" title="斜体" @mousedown.prevent @click="runCommand('italic')">I</button>
92
+ <button class="text-tool is-underline" type="button" title="下划线" @mousedown.prevent @click="runCommand('underline')">U</button>
93
+ </div>
94
+
95
+ <span class="toolbar-divider"></span>
96
+
97
+ <div class="toolbar-group">
98
+ <button type="button" title="无序列表" @mousedown.prevent @click="runCommand('insertUnorderedList')">
99
+ <el-icon><List /></el-icon>
100
+ </button>
101
+ <button type="button" title="有序列表" @mousedown.prevent @click="runCommand('insertOrderedList')">
102
+ <el-icon><Tickets /></el-icon>
103
+ </button>
104
+ <button type="button" title="引用" @mousedown.prevent @click="setBlock('blockquote')">
105
+ <el-icon><Reading /></el-icon>
106
+ </button>
107
+ <button type="button" title="代码块" @mousedown.prevent @click="setBlock('pre')">&lt;/&gt;</button>
108
+ <button type="button" title="插入链接" @mousedown.prevent @click="insertLink">
109
+ <el-icon><Link /></el-icon>
110
+ </button>
111
+ </div>
112
+
113
+ <span class="toolbar-divider"></span>
114
+
115
+ <div class="toolbar-group">
116
+ <button type="button" title="清除格式" @mousedown.prevent @click="runCommand('removeFormat')">
117
+ <el-icon><RefreshLeft /></el-icon>
118
+ </button>
119
+ </div>
120
+
121
+ <button
122
+ class="source-toggle"
123
+ :class="{ 'is-active': sourceMode }"
124
+ type="button"
125
+ @click="toggleSourceMode"
126
+ >
127
+ {{ sourceMode ? '返回编辑' : 'HTML' }}
128
+ </button>
129
+ </div>
130
+
131
+ <el-input
132
+ v-if="sourceMode"
133
+ :model-value="localHtml"
134
+ class="source-editor"
135
+ type="textarea"
136
+ :rows="16"
137
+ :disabled="disabled"
138
+ placeholder="请输入公告正文 HTML"
139
+ @update:model-value="handleSourceInput"
140
+ />
141
+
142
+ <div
143
+ v-else
144
+ ref="editorRef"
145
+ class="editor-content"
146
+ :contenteditable="disabled ? 'false' : 'true'"
147
+ data-placeholder="请输入公告正文,可使用上方工具栏设置标题、列表、引用和链接"
148
+ @input="handleEditorInput"
149
+ @blur="handleEditorInput"
150
+ ></div>
151
+ </div>
152
+ </template>
153
+
154
+ <style scoped>
155
+ .rich-text-editor {
156
+ overflow: hidden;
157
+ border: 1px solid #dcdfe6;
158
+ border-radius: 8px;
159
+ background: #ffffff;
160
+ transition: border-color 0.2s, box-shadow 0.2s;
161
+ }
162
+
163
+ .rich-text-editor:focus-within {
164
+ border-color: #409eff;
165
+ box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.12);
166
+ }
167
+
168
+ .rich-text-editor.is-disabled {
169
+ background: #f5f7fa;
170
+ }
171
+
172
+ .editor-toolbar {
173
+ display: flex;
174
+ align-items: center;
175
+ gap: 6px;
176
+ min-height: 46px;
177
+ padding: 6px 10px;
178
+ border-bottom: 1px solid #e8ecf2;
179
+ background: #f8fafc;
180
+ }
181
+
182
+ .toolbar-group {
183
+ display: inline-flex;
184
+ align-items: center;
185
+ gap: 3px;
186
+ }
187
+
188
+ .editor-toolbar button {
189
+ display: inline-flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ min-width: 32px;
193
+ height: 32px;
194
+ padding: 0 8px;
195
+ border: 0;
196
+ border-radius: 5px;
197
+ color: #4d5b70;
198
+ background: transparent;
199
+ cursor: pointer;
200
+ font: inherit;
201
+ font-size: 13px;
202
+ }
203
+
204
+ .editor-toolbar button:hover,
205
+ .editor-toolbar button.is-active {
206
+ color: #1677ff;
207
+ background: #eaf3ff;
208
+ }
209
+
210
+ .text-tool.is-bold {
211
+ font-weight: 800;
212
+ }
213
+
214
+ .text-tool.is-italic {
215
+ font-family: Georgia, serif;
216
+ font-style: italic;
217
+ }
218
+
219
+ .text-tool.is-underline {
220
+ text-decoration: underline;
221
+ }
222
+
223
+ .toolbar-divider {
224
+ width: 1px;
225
+ height: 22px;
226
+ margin: 0 2px;
227
+ background: #dfe5ed;
228
+ }
229
+
230
+ .source-toggle {
231
+ margin-left: auto;
232
+ }
233
+
234
+ .editor-content {
235
+ min-height: 360px;
236
+ padding: 22px 24px;
237
+ outline: none;
238
+ color: #1f2937;
239
+ font-size: 15px;
240
+ line-height: 1.9;
241
+ }
242
+
243
+ .editor-content:empty::before {
244
+ color: #a8abb2;
245
+ content: attr(data-placeholder);
246
+ pointer-events: none;
247
+ }
248
+
249
+ .editor-content :deep(p) {
250
+ margin: 0 0 14px;
251
+ }
252
+
253
+ .editor-content :deep(h2) {
254
+ margin: 24px 0 10px;
255
+ color: #172033;
256
+ font-size: 18px;
257
+ line-height: 1.6;
258
+ }
259
+
260
+ .editor-content :deep(blockquote) {
261
+ margin: 16px 0;
262
+ padding: 10px 14px;
263
+ border-left: 4px solid #409eff;
264
+ color: #52627a;
265
+ background: #f4f8ff;
266
+ }
267
+
268
+ .editor-content :deep(pre) {
269
+ overflow-x: auto;
270
+ margin: 16px 0;
271
+ padding: 14px 16px;
272
+ border-radius: 6px;
273
+ color: #e2e8f0;
274
+ background: #172033;
275
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
276
+ line-height: 1.65;
277
+ }
278
+
279
+ .editor-content :deep(a) {
280
+ color: #1677ff;
281
+ }
282
+
283
+ .source-editor {
284
+ display: block;
285
+ padding: 12px;
286
+ }
287
+
288
+ .source-editor :deep(.el-textarea__inner) {
289
+ border: 0;
290
+ box-shadow: none;
291
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
292
+ line-height: 1.65;
293
+ resize: vertical;
294
+ }
295
+
296
+ @media (max-width: 720px) {
297
+ .editor-toolbar {
298
+ flex-wrap: wrap;
299
+ }
300
+
301
+ .source-toggle {
302
+ margin-left: 0;
303
+ }
304
+
305
+ .editor-content {
306
+ min-height: 300px;
307
+ padding: 18px;
308
+ }
309
+ }
310
+ </style>
@@ -0,0 +1,403 @@
1
+ <script setup lang="ts">
2
+ import { computed, onMounted, reactive, ref } from 'vue'
3
+ import { useRoute, useRouter } from 'vue-router'
4
+ import { ArrowLeft, Check } from '@element-plus/icons-vue'
5
+ import { ElMessage } from 'element-plus'
6
+ import type { FormInstance, FormRules } from 'element-plus'
7
+
8
+ import NoticeRichTextEditor from './components/NoticeRichTextEditor.vue'
9
+ import { createNotice, getNoticeDetail, updateNotice } from './api'
10
+
11
+ const route = useRoute()
12
+ const router = useRouter()
13
+ const formRef = ref<FormInstance>()
14
+ const pageLoading = ref(false)
15
+ const submitting = ref(false)
16
+
17
+ const noticeId = computed(() => {
18
+ const id = String(route.params.id ?? '').trim()
19
+ return id || undefined
20
+ })
21
+ const isEdit = computed(() => noticeId.value !== undefined)
22
+ const pageTitle = computed(() => (isEdit.value ? '编辑公告' : '新增公告'))
23
+
24
+ const form = reactive({
25
+ title: '',
26
+ publishTime: createDefaultPublishTime(),
27
+ pinned: false,
28
+ contentHtml: '',
29
+ })
30
+
31
+ const rules: FormRules = {
32
+ title: [
33
+ { required: true, message: '请输入公告标题', trigger: 'blur' },
34
+ { max: 300, message: '公告标题不能超过 300 个字符', trigger: 'blur' },
35
+ ],
36
+ publishTime: [
37
+ { required: true, message: '请选择发布时间', trigger: 'change' },
38
+ ],
39
+ }
40
+
41
+ function pad(value: number) {
42
+ return String(value).padStart(2, '0')
43
+ }
44
+
45
+ function createDefaultPublishTime() {
46
+ const now = new Date()
47
+ return [
48
+ now.getFullYear(),
49
+ '-',
50
+ pad(now.getMonth() + 1),
51
+ '-',
52
+ pad(now.getDate()),
53
+ ' ',
54
+ pad(now.getHours()),
55
+ ':',
56
+ pad(now.getMinutes()),
57
+ ':00',
58
+ ].join('')
59
+ }
60
+
61
+ function hasContent(html: string) {
62
+ const container = document.createElement('div')
63
+ container.innerHTML = html
64
+ return Boolean(container.textContent?.trim() || container.querySelector('img, video, iframe'))
65
+ }
66
+
67
+ async function loadDetail() {
68
+ if (!noticeId.value) return
69
+ pageLoading.value = true
70
+ try {
71
+ const detail = await getNoticeDetail(noticeId.value)
72
+ form.title = detail.annouTitle
73
+ form.publishTime = detail.createTm || createDefaultPublishTime()
74
+ form.pinned = detail.topFlag === '1'
75
+ form.contentHtml = detail.annouConte
76
+ } catch (error) {
77
+ ElMessage.error(error instanceof Error ? error.message : '公告详情加载失败')
78
+ } finally {
79
+ pageLoading.value = false
80
+ }
81
+ }
82
+
83
+ async function handleSubmit() {
84
+ if (!formRef.value) return
85
+
86
+ try {
87
+ await formRef.value.validate()
88
+ } catch {
89
+ return
90
+ }
91
+
92
+ if (!hasContent(form.contentHtml)) {
93
+ ElMessage.warning('请输入公告正文')
94
+ return
95
+ }
96
+
97
+ submitting.value = true
98
+ try {
99
+ const payload = {
100
+ title: form.title.trim(),
101
+ date: form.publishTime.slice(0, 10),
102
+ publishTime: form.publishTime,
103
+ pinned: form.pinned,
104
+ contentHtml: form.contentHtml,
105
+ }
106
+
107
+ if (noticeId.value) {
108
+ await updateNotice(noticeId.value, payload)
109
+ ElMessage.success('公告更新成功')
110
+ } else {
111
+ await createNotice(payload)
112
+ ElMessage.success('公告新增成功')
113
+ }
114
+
115
+ await router.push({ name: 'noticeManagement' })
116
+ } catch (error) {
117
+ ElMessage.error(error instanceof Error ? error.message : '公告保存失败')
118
+ } finally {
119
+ submitting.value = false
120
+ }
121
+ }
122
+
123
+ function handleCancel() {
124
+ void router.push({ name: 'noticeManagement' })
125
+ }
126
+
127
+ onMounted(loadDetail)
128
+ </script>
129
+
130
+ <template>
131
+ <main v-loading="pageLoading" class="notice-edit-page">
132
+ <section class="page-heading">
133
+ <button class="back-button" type="button" @click="handleCancel">
134
+ <el-icon><ArrowLeft /></el-icon>
135
+ </button>
136
+ <div>
137
+ <p class="heading-path">公告管理 / {{ pageTitle }}</p>
138
+ <h1>{{ pageTitle }}</h1>
139
+ <p>完善公告信息并编辑正文内容</p>
140
+ </div>
141
+ </section>
142
+
143
+ <el-form
144
+ ref="formRef"
145
+ :model="form"
146
+ :rules="rules"
147
+ label-position="top"
148
+ class="notice-form"
149
+ >
150
+ <el-card class="form-card basic-card" shadow="never">
151
+ <template #header>
152
+ <div class="card-heading">
153
+ <span class="card-step">01</span>
154
+ <div>
155
+ <strong>基本信息</strong>
156
+ <small>设置公告标题与展示规则</small>
157
+ </div>
158
+ </div>
159
+ </template>
160
+
161
+ <div class="basic-form-grid">
162
+ <el-form-item label="公告标题" prop="title" class="title-field">
163
+ <el-input
164
+ v-model="form.title"
165
+ maxlength="300"
166
+ show-word-limit
167
+ clearable
168
+ placeholder="请输入公告标题"
169
+ />
170
+ </el-form-item>
171
+ <el-form-item label="发布时间" prop="publishTime">
172
+ <el-date-picker
173
+ v-model="form.publishTime"
174
+ type="datetime"
175
+ value-format="YYYY-MM-DD HH:mm:ss"
176
+ placeholder="请选择发布时间"
177
+ style="width: 100%"
178
+ />
179
+ </el-form-item>
180
+ <el-form-item label="置顶设置">
181
+ <div class="pinned-setting">
182
+ <el-switch
183
+ v-model="form.pinned"
184
+ inline-prompt
185
+ active-text="是"
186
+ inactive-text="否"
187
+ />
188
+ <span>{{ form.pinned ? '该公告将在列表顶部优先展示' : '按发布时间参与列表排序' }}</span>
189
+ </div>
190
+ </el-form-item>
191
+ </div>
192
+ </el-card>
193
+
194
+ <el-card class="form-card content-card" shadow="never">
195
+ <template #header>
196
+ <div class="card-heading">
197
+ <span class="card-step">02</span>
198
+ <div>
199
+ <strong>公告正文</strong>
200
+ <small>支持基础排版及 HTML 源码编辑</small>
201
+ </div>
202
+ </div>
203
+ </template>
204
+
205
+ <el-form-item class="content-form-item" required>
206
+ <NoticeRichTextEditor v-model="form.contentHtml" />
207
+ </el-form-item>
208
+ </el-card>
209
+
210
+ <div class="form-actions">
211
+ <el-button @click="handleCancel">取消</el-button>
212
+ <el-button
213
+ type="primary"
214
+ :icon="Check"
215
+ :loading="submitting"
216
+ @click="handleSubmit"
217
+ >
218
+ {{ isEdit ? '保存修改' : '发布公告' }}
219
+ </el-button>
220
+ </div>
221
+ </el-form>
222
+ </main>
223
+ </template>
224
+
225
+ <style scoped>
226
+ .notice-edit-page {
227
+ min-height: 100%;
228
+ padding: 22px 22px 96px;
229
+ color: #1f2937;
230
+ background:
231
+ radial-gradient(circle at 88% 3%, rgba(64, 158, 255, 0.08), transparent 22%),
232
+ #f5f7fa;
233
+ font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
234
+ }
235
+
236
+ .page-heading {
237
+ display: flex;
238
+ align-items: center;
239
+ gap: 14px;
240
+ margin: 0 auto 18px;
241
+ max-width: 1180px;
242
+ }
243
+
244
+ .back-button {
245
+ display: inline-flex;
246
+ flex: 0 0 auto;
247
+ align-items: center;
248
+ justify-content: center;
249
+ width: 36px;
250
+ height: 36px;
251
+ border: 1px solid #dfe5ed;
252
+ border-radius: 8px;
253
+ color: #52627a;
254
+ background: #ffffff;
255
+ cursor: pointer;
256
+ }
257
+
258
+ .back-button:hover {
259
+ border-color: #409eff;
260
+ color: #409eff;
261
+ }
262
+
263
+ .heading-path {
264
+ margin: 0 0 2px !important;
265
+ color: #8b98aa !important;
266
+ font-size: 12px !important;
267
+ }
268
+
269
+ .page-heading h1 {
270
+ margin: 0;
271
+ color: #172033;
272
+ font-size: 24px;
273
+ line-height: 1.4;
274
+ }
275
+
276
+ .page-heading p {
277
+ margin: 2px 0 0;
278
+ color: #8491a5;
279
+ font-size: 13px;
280
+ }
281
+
282
+ .notice-form {
283
+ max-width: 1180px;
284
+ margin: 0 auto;
285
+ }
286
+
287
+ .form-card {
288
+ border: 1px solid #e4e9f0;
289
+ border-radius: 8px;
290
+ }
291
+
292
+ .form-card + .form-card {
293
+ margin-top: 16px;
294
+ }
295
+
296
+ .form-card :deep(.el-card__header) {
297
+ padding: 16px 20px;
298
+ border-bottom-color: #edf0f5;
299
+ }
300
+
301
+ .form-card :deep(.el-card__body) {
302
+ padding: 22px 24px 6px;
303
+ }
304
+
305
+ .card-heading {
306
+ display: flex;
307
+ align-items: center;
308
+ gap: 11px;
309
+ }
310
+
311
+ .card-step {
312
+ display: inline-flex;
313
+ align-items: center;
314
+ justify-content: center;
315
+ width: 34px;
316
+ height: 34px;
317
+ border-radius: 8px;
318
+ color: #1677ff;
319
+ background: #eaf3ff;
320
+ font-size: 12px;
321
+ font-weight: 700;
322
+ letter-spacing: 0.04em;
323
+ }
324
+
325
+ .card-heading div {
326
+ display: flex;
327
+ flex-direction: column;
328
+ gap: 2px;
329
+ }
330
+
331
+ .card-heading strong {
332
+ color: #273247;
333
+ font-size: 16px;
334
+ }
335
+
336
+ .card-heading small {
337
+ color: #9aa5b5;
338
+ font-size: 12px;
339
+ font-weight: 400;
340
+ }
341
+
342
+ .basic-form-grid {
343
+ display: grid;
344
+ grid-template-columns: minmax(0, 1fr) 260px;
345
+ column-gap: 24px;
346
+ }
347
+
348
+ .title-field {
349
+ grid-column: 1 / -1;
350
+ }
351
+
352
+ .pinned-setting {
353
+ display: flex;
354
+ align-items: center;
355
+ gap: 12px;
356
+ min-height: 32px;
357
+ color: #8491a5;
358
+ font-size: 13px;
359
+ }
360
+
361
+ .content-card :deep(.el-card__body) {
362
+ padding-bottom: 22px;
363
+ }
364
+
365
+ .content-form-item {
366
+ margin-bottom: 0;
367
+ }
368
+
369
+ .content-form-item :deep(.el-form-item__content) {
370
+ display: block;
371
+ }
372
+
373
+ .form-actions {
374
+ position: fixed;
375
+ z-index: 20;
376
+ right: 0;
377
+ bottom: 0;
378
+ left: var(--app-aside-width, 200px);
379
+ display: flex;
380
+ justify-content: flex-end;
381
+ gap: 8px;
382
+ padding: 14px 24px;
383
+ border-top: 1px solid #e1e6ed;
384
+ background: rgba(255, 255, 255, 0.94);
385
+ box-shadow: 0 -8px 24px rgba(31, 41, 55, 0.04);
386
+ backdrop-filter: blur(12px);
387
+ }
388
+
389
+ @media (max-width: 900px) {
390
+ .notice-edit-page {
391
+ padding: 16px 16px 92px;
392
+ }
393
+
394
+ .basic-form-grid {
395
+ grid-template-columns: 1fr;
396
+ }
397
+
398
+ .title-field {
399
+ grid-column: auto;
400
+ }
401
+
402
+ }
403
+ </style>
@@ -0,0 +1,299 @@
1
+ <script setup lang="ts">
2
+ import { onMounted, reactive, ref } from 'vue'
3
+ import { useRouter } from 'vue-router'
4
+ import { Delete, EditPen, Plus, Refresh } from '@element-plus/icons-vue'
5
+ import { ElMessage, ElMessageBox } from 'element-plus'
6
+
7
+ import { deleteNotice, getNoticeList } from './api'
8
+ import type { NoticeListItem } from './types'
9
+
10
+ const router = useRouter()
11
+ const loading = ref(false)
12
+ const deletingId = ref<string>()
13
+ const tableData = ref<NoticeListItem[]>([])
14
+ const total = ref(0)
15
+
16
+ const pagination = reactive({
17
+ currentPage: 1,
18
+ pageSize: 10,
19
+ })
20
+
21
+ async function loadList() {
22
+ loading.value = true
23
+ try {
24
+ const response = await getNoticeList({
25
+ currentPage: pagination.currentPage,
26
+ pageSize: pagination.pageSize,
27
+ })
28
+ tableData.value = response.resultList
29
+ total.value = response.totalCount
30
+ } catch (error) {
31
+ ElMessage.error(error instanceof Error ? error.message : '公告列表加载失败')
32
+ } finally {
33
+ loading.value = false
34
+ }
35
+ }
36
+
37
+ function handleCreate() {
38
+ void router.push({ name: 'noticeManagementCreate' })
39
+ }
40
+
41
+ function handleEdit(row: NoticeListItem) {
42
+ void router.push({
43
+ name: 'noticeManagementEdit',
44
+ params: { id: row.annouId },
45
+ })
46
+ }
47
+
48
+ async function handleDelete(row: NoticeListItem) {
49
+ try {
50
+ await ElMessageBox.confirm(
51
+ `删除后无法恢复,确认删除公告“${row.annouTitle}”吗?`,
52
+ '删除公告',
53
+ {
54
+ confirmButtonText: '确认删除',
55
+ cancelButtonText: '取消',
56
+ type: 'warning',
57
+ },
58
+ )
59
+ deletingId.value = row.annouId
60
+ await deleteNotice(row.annouId)
61
+ ElMessage.success('公告删除成功')
62
+
63
+ if (tableData.value.length === 1 && pagination.currentPage > 1) {
64
+ pagination.currentPage -= 1
65
+ }
66
+ await loadList()
67
+ } catch (error) {
68
+ if (error !== 'cancel' && error !== 'close') {
69
+ ElMessage.error(error instanceof Error ? error.message : '公告删除失败')
70
+ }
71
+ } finally {
72
+ deletingId.value = undefined
73
+ }
74
+ }
75
+
76
+ function handlePageSizeChange() {
77
+ pagination.currentPage = 1
78
+ void loadList()
79
+ }
80
+
81
+ onMounted(loadList)
82
+ </script>
83
+
84
+ <template>
85
+ <main class="notice-management-page">
86
+ <section class="page-heading">
87
+ <div>
88
+ <p class="heading-eyebrow">CONTENT CENTER</p>
89
+ <h1>公告管理</h1>
90
+ <p class="heading-description">统一维护平台通知内容、发布时间与置顶状态</p>
91
+ </div>
92
+ <el-button type="primary" :icon="Plus" @click="handleCreate">新增公告</el-button>
93
+ </section>
94
+
95
+ <el-card class="table-card" shadow="never">
96
+ <template #header>
97
+ <div class="table-card__header">
98
+ <div>
99
+ <span class="table-card__title">公告列表</span>
100
+ <span class="table-card__count">共 {{ total }} 条</span>
101
+ </div>
102
+ <el-button :icon="Refresh" :loading="loading" @click="loadList">刷新</el-button>
103
+ </div>
104
+ </template>
105
+
106
+ <el-table
107
+ v-loading="loading"
108
+ :data="tableData"
109
+ row-key="annouId"
110
+ class="notice-table"
111
+ empty-text="暂无公告数据"
112
+ >
113
+ <el-table-column type="index" label="序号" width="72" align="center">
114
+ <template #default="{ $index }">
115
+ {{ (pagination.currentPage - 1) * pagination.pageSize + $index + 1 }}
116
+ </template>
117
+ </el-table-column>
118
+ <el-table-column prop="annouTitle" label="公告标题" min-width="360" show-overflow-tooltip>
119
+ <template #default="{ row }">
120
+ <div class="notice-title-cell">
121
+ <span v-if="row.topFlag === '1'" class="pinned-mark">置顶</span>
122
+ <span class="notice-title-text">{{ row.annouTitle }}</span>
123
+ </div>
124
+ </template>
125
+ </el-table-column>
126
+ <el-table-column prop="annouSts" label="公告状态" width="110" align="center">
127
+ <template #default="{ row }">
128
+ <el-tag :type="row.annouSts === '0' ? 'success' : 'info'" effect="light">
129
+ {{ row.annouSts }}
130
+ </el-tag>
131
+ </template>
132
+ </el-table-column>
133
+ <el-table-column label="发布时间" width="180">
134
+ <template #default="{ row }">
135
+ {{ row.createTm || '—' }}
136
+ </template>
137
+ </el-table-column>
138
+ <el-table-column prop="createUserId" label="创建人" width="140" show-overflow-tooltip />
139
+ <el-table-column label="操作" width="168" fixed="right" align="center">
140
+ <template #default="{ row }">
141
+ <el-button link type="primary" :icon="EditPen" @click="handleEdit(row)">编辑</el-button>
142
+ <el-button
143
+ link
144
+ type="danger"
145
+ :icon="Delete"
146
+ :loading="deletingId === row.annouId"
147
+ @click="handleDelete(row)"
148
+ >
149
+ 删除
150
+ </el-button>
151
+ </template>
152
+ </el-table-column>
153
+ </el-table>
154
+
155
+ <div class="pagination-bar">
156
+ <el-pagination
157
+ v-model:current-page="pagination.currentPage"
158
+ v-model:page-size="pagination.pageSize"
159
+ :page-sizes="[10, 20, 50]"
160
+ :total="total"
161
+ background
162
+ layout="total, sizes, prev, pager, next, jumper"
163
+ @current-change="loadList"
164
+ @size-change="handlePageSizeChange"
165
+ />
166
+ </div>
167
+ </el-card>
168
+ </main>
169
+ </template>
170
+
171
+ <style scoped>
172
+ .notice-management-page {
173
+ min-height: 100%;
174
+ padding: 22px;
175
+ color: #1f2937;
176
+ background:
177
+ radial-gradient(circle at 92% 2%, rgba(64, 158, 255, 0.07), transparent 24%),
178
+ #f5f7fa;
179
+ font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
180
+ }
181
+
182
+ .page-heading {
183
+ display: flex;
184
+ align-items: center;
185
+ justify-content: space-between;
186
+ gap: 24px;
187
+ margin-bottom: 18px;
188
+ }
189
+
190
+ .heading-eyebrow {
191
+ margin: 0 0 4px;
192
+ color: #8b98aa;
193
+ font-size: 10px;
194
+ font-weight: 700;
195
+ letter-spacing: 0.14em;
196
+ }
197
+
198
+ .page-heading h1 {
199
+ margin: 0;
200
+ color: #172033;
201
+ font-size: 24px;
202
+ line-height: 1.4;
203
+ font-weight: 700;
204
+ }
205
+
206
+ .heading-description {
207
+ margin: 4px 0 0;
208
+ color: #8491a5;
209
+ font-size: 13px;
210
+ }
211
+
212
+ .table-card {
213
+ border: 1px solid #e4e9f0;
214
+ border-radius: 8px;
215
+ }
216
+
217
+ .table-card :deep(.el-card__header) {
218
+ padding: 16px 20px;
219
+ border-bottom-color: #edf0f5;
220
+ }
221
+
222
+ .table-card :deep(.el-card__body) {
223
+ padding: 0 20px 18px;
224
+ }
225
+
226
+ .table-card__header {
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: space-between;
230
+ }
231
+
232
+ .table-card__title {
233
+ color: #273247;
234
+ font-size: 16px;
235
+ font-weight: 600;
236
+ }
237
+
238
+ .table-card__count {
239
+ margin-left: 10px;
240
+ color: #9aa5b5;
241
+ font-size: 13px;
242
+ }
243
+
244
+ .table-card__hint {
245
+ color: #a0a9b8;
246
+ font-size: 12px;
247
+ }
248
+
249
+ .notice-table {
250
+ --el-table-header-bg-color: #f8fafc;
251
+ --el-table-header-text-color: #667085;
252
+ --el-table-row-hover-bg-color: #f6f9fe;
253
+ }
254
+
255
+ .notice-title-cell {
256
+ display: flex;
257
+ align-items: center;
258
+ min-width: 0;
259
+ gap: 10px;
260
+ }
261
+
262
+ .pinned-mark {
263
+ flex: 0 0 auto;
264
+ padding: 2px 7px;
265
+ border-radius: 4px;
266
+ color: #e5484d;
267
+ background: #fff0f0;
268
+ font-size: 12px;
269
+ line-height: 20px;
270
+ }
271
+
272
+ .notice-title-text {
273
+ overflow: hidden;
274
+ color: #273247;
275
+ font-weight: 500;
276
+ text-overflow: ellipsis;
277
+ white-space: nowrap;
278
+ }
279
+
280
+ .pagination-bar {
281
+ display: flex;
282
+ justify-content: flex-end;
283
+ padding-top: 18px;
284
+ }
285
+
286
+ @media (max-width: 900px) {
287
+ .notice-management-page {
288
+ padding: 16px;
289
+ }
290
+
291
+ .page-heading {
292
+ align-items: flex-end;
293
+ }
294
+
295
+ .table-card__hint {
296
+ display: none;
297
+ }
298
+ }
299
+ </style>
@@ -0,0 +1,43 @@
1
+ export type NoticeListItem = {
2
+ annouId: string
3
+ orgNo: string | null
4
+ annouTitle: string
5
+ annouSts: string
6
+ topFlag: string
7
+ createUserId: string | null
8
+ updateUserId: string | null
9
+ createTm: string
10
+ updateTm: string
11
+ annouLimitFlag: string
12
+ annouConte: string
13
+ effDt: string | null
14
+ expireDt: string | null
15
+ }
16
+
17
+ export type NoticeDetail = {
18
+ id: number | string
19
+ title: string
20
+ date: string
21
+ publishTime: string
22
+ views: number
23
+ pinned: boolean
24
+ contentHtml: string
25
+ }
26
+
27
+ export type NoticeListQuery = {
28
+ currentPage: number
29
+ pageSize: number
30
+ }
31
+
32
+ export type NoticeListResponse = {
33
+ resultList: NoticeListItem[]
34
+ totalCount: number
35
+ }
36
+
37
+ export type NoticePayload = {
38
+ title: string
39
+ date: string
40
+ publishTime: string
41
+ pinned: boolean
42
+ contentHtml: string
43
+ }