verce-vue-test 0.0.111 → 0.0.113

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.
@@ -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
+ }