From 8a228763c7d6cc7e8349345ee13c4f34e7945b8e Mon Sep 17 00:00:00 2001
From: Kven <2955163637@qq.com>
Date: Mon, 23 Dec 2024 13:56:00 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E5=85=AC=E5=91=8A=E6=A8=A1=E5=9D=97):=20?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=AC=E5=91=8A=E5=A2=9E=E5=88=A0=E6=94=B9?=
=?UTF-8?q?=E6=9F=A5=E5=92=8C=E7=94=A8=E6=88=B7=E5=85=AC=E5=91=8A=E5=B1=95?=
=?UTF-8?q?=E7=A4=BA=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1.新增公告增删改查功能
2.新增用户页面公告展示功能
---
src/api/bulletin-mgmt.ts | 105 ++++++
src/api/bulletins.ts | 26 ++
.../bulletin/components/bulletin-edit.vue | 254 +++++++++++++++
.../system/bulletin/components/detail.vue | 148 +++++++++
.../noticeSet => system/bulletin}/index.vue | 301 +++++++++++-------
.../user/bulletins/components/detail.vue | 148 +++++++++
.../notice => user/bulletins}/index.vue | 226 +++++--------
7 files changed, 940 insertions(+), 268 deletions(-)
create mode 100644 src/api/bulletin-mgmt.ts
create mode 100644 src/api/bulletins.ts
create mode 100644 src/views/system/bulletin/components/bulletin-edit.vue
create mode 100644 src/views/system/bulletin/components/detail.vue
rename src/views/{notification/noticeSet => system/bulletin}/index.vue (59%)
create mode 100644 src/views/user/bulletins/components/detail.vue
rename src/views/{notification/notice => user/bulletins}/index.vue (53%)
diff --git a/src/api/bulletin-mgmt.ts b/src/api/bulletin-mgmt.ts
new file mode 100644
index 0000000..39f0c48
--- /dev/null
+++ b/src/api/bulletin-mgmt.ts
@@ -0,0 +1,105 @@
+import axios from 'axios';
+
+export interface BulletinCreateRecord {
+ title: string;
+ top: boolean;
+ content: string;
+ remark: string;
+ attachmentIds?: string[];
+}
+
+
+export interface BulletinRecord extends BulletinCreateRecord {
+ id: number;
+ state: string;
+ publishTime: string;
+ createTime: string;
+
+}
+
+export interface BulletinsRecord {
+ title?: string;
+ state?: string[];
+ publishTimeBegin?: string[];
+ publishTimeEnd?: string[];
+ total?: number;
+ current: number;
+ pages: number;
+}
+
+export interface AttachmentRecord {
+ type: string;
+ file: any;
+}
+
+
+// 查看详情
+export function queryBulletinListAll(id: number) {
+ return axios.get(`/api/rest/bulletin/${id}`);
+}
+
+// 分页查询
+export function queryBulletinList(data: BulletinsRecord) {
+ return axios({
+ url: '/api/rest/bulletin',
+ method: 'get',
+ params: data,
+ });
+}
+
+// 添加公告
+export function create(data: BulletinCreateRecord) {
+ return axios.post(`/api/rest/bulletin`, data);
+}
+
+// 更新公告
+export function update(data: BulletinRecord) {
+ return axios.patch(`/api/rest/bulletin/${data.id}`, data);
+}
+
+// 置顶状态
+export function toggle(id: number) {
+ return axios.patch(`/api/rest/bulletin/${id}/toggle-top`);
+}
+
+// 发布编辑
+export function publish(data: number[]) {
+ return axios.patch(`/api/rest/bulletin/publish`, data);
+}
+
+// 关闭公告
+export function close(id: number) {
+ return axios.patch(`/api/rest/bulletin/${id}/toggleClose`);
+}
+
+// 删除公告
+export function remove(id: number) {
+ return axios.delete(`/api/rest/bulletin/${id}`);
+}
+
+// 添加附件
+export function addAttachments(data: any) {
+ return axios({
+ method: 'post',
+ url: '/api/rest/attachment',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ data,
+ })
+}
+
+// 获取附件信息
+export function addAttachment(id: string) {
+ return axios.get(`/api/rest/attachment/find/${id}`);
+}
+
+// 删除附件
+export function deleteAttachment(id: string) {
+ return axios.delete(`/api/rest/attachment/delete/${id}`);
+}
+
+// 获取部门树
+export function queryDeptTreeList() {
+ return axios.get(`/api/deptTree`);
+}
diff --git a/src/api/bulletins.ts b/src/api/bulletins.ts
new file mode 100644
index 0000000..fc1582a
--- /dev/null
+++ b/src/api/bulletins.ts
@@ -0,0 +1,26 @@
+import axios from 'axios';
+
+export interface BulletinsRecord {
+ title?: string;
+ state?: number[];
+ top?: boolean;
+ publishTimeBegin?: string[];
+ publishTimeEnd?: string[];
+ total?: number;
+ size: number;
+ isRead?: boolean;
+ current: number;
+}
+
+// 查看详情
+export function queryBulletinsListAll(id: number) {
+ return axios.get(`/api/rest/bulletin/self/${id}`);
+}
+// 分页查询
+export function queryBulletinsList(data: BulletinsRecord) {
+ return axios({
+ url: '/api/rest/bulletin/self',
+ method: 'get',
+ params: data,
+ });
+}
\ No newline at end of file
diff --git a/src/views/system/bulletin/components/bulletin-edit.vue b/src/views/system/bulletin/components/bulletin-edit.vue
new file mode 100644
index 0000000..784f5ee
--- /dev/null
+++ b/src/views/system/bulletin/components/bulletin-edit.vue
@@ -0,0 +1,254 @@
+
+
+
+ 新建
+
+
+
+ 修改
+
+
+
+ {{ modalTitle }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![上传文件]()
+
{{ file.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确定
+
+
+
+
+
+
+
+
diff --git a/src/views/system/bulletin/components/detail.vue b/src/views/system/bulletin/components/detail.vue
new file mode 100644
index 0000000..1ee0267
--- /dev/null
+++ b/src/views/system/bulletin/components/detail.vue
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/notification/noticeSet/index.vue b/src/views/system/bulletin/index.vue
similarity index 59%
rename from src/views/notification/noticeSet/index.vue
rename to src/views/system/bulletin/index.vue
index 9615485..28d83ce 100644
--- a/src/views/notification/noticeSet/index.vue
+++ b/src/views/system/bulletin/index.vue
@@ -14,55 +14,40 @@
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
@@ -89,14 +74,12 @@
-
+
+
+
+ 发布
+
-
-
-
-
- 导出
-
-
+
-
+
@@ -122,14 +105,14 @@
v-for="item in densityList"
:key="item.value"
:value="item.value"
- :class="{ active: item.value === sizeof }"
+ :class="{ active: item.value === size }"
>
{{ item.name }}
-
+
-
- {{ rowIndex + 1 + (pagination.current - 1) * pagination.size }}
+
+
-
+
+ {{ dayjs(record.publishTime).format('YYYY-MM-DD HH:mm') }}
+
+
+ 已发布
+ 编辑中
+ 已关闭
+
+
+
+
+
+
+
+
-
- 详情
-
-
-
+
+ 详情
+
+
-
+
+
+ 删除
+
+
+
-
- 删除
-
-
+
+
+ 切换状态
+
+
diff --git a/src/views/user/bulletins/components/detail.vue b/src/views/user/bulletins/components/detail.vue
new file mode 100644
index 0000000..32a4af0
--- /dev/null
+++ b/src/views/user/bulletins/components/detail.vue
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/notification/notice/index.vue b/src/views/user/bulletins/index.vue
similarity index 53%
rename from src/views/notification/notice/index.vue
rename to src/views/user/bulletins/index.vue
index a55450f..e333890 100644
--- a/src/views/notification/notice/index.vue
+++ b/src/views/user/bulletins/index.vue
@@ -1,6 +1,6 @@
-
+
@@ -14,55 +14,37 @@
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
@@ -93,30 +75,26 @@
:columns="(cloneColumns as TableColumnData[])"
:data="renderData"
:bordered="false"
- :size="size"
+ :size="sizeof"
+ :style="highlightRow"
style="margin-bottom: 40px"
:filter-icon-align-left="alignLeft"
@change="handleSortChange"
@page-change="onPageChange"
>
-
- {{ rowIndex + 1 + (pagination.current - 1) * pagination.size }}
+
+ {{ dayjs(record.publishTime).format('YYYY-MM-DD HH:mm') }}
-
-
+
+ {{ record.isRead == true? '已读' : '未读' }}
详情
@@ -127,7 +105,7 @@
import { computed, ref, watch } from 'vue';
- import { useI18n } from 'vue-i18n';
import useLoading from '@/hooks/loading';
- import { UserRecord, UserParams } from '@/api/user';
+ import dayjs from 'dayjs';
import { Pagination } from '@/types/global';
import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
- import { useUserStore } from '@/store';
- import { Message } from '@arco-design/web-vue';
+ import { useBulletinsStore } from '@/store';
+ import router from '@/router';
import useTableOption from '@/hooks/table-option';
- import NoticeEdit from '@/views/notification/noticeSet/components/notice-edit.vue';
+ import { BulletinsRecord } from '@/api/bulletins';
const generateFormModel = () => {
return {
title: '',
- states: '',
+ state: '',
publishTimeBegin: '',
publishTimeEnd: '',
};
};
const { loading, setLoading } = useLoading(true);
- const { t } = useI18n();
- const renderData = ref([]);
+ const renderData = ref([]);
const formModel = ref(generateFormModel());
const {
@@ -178,42 +154,30 @@
} = useTableOption();
const sizeof=useTableOption().size;
- const userStore = useUserStore();
+ const bulletinsStore = useBulletinsStore();
- const pagination: Pagination = {
- page: 1,
+ const pagination: any = {
size: 10,
- current: 1,
- total: null,
+ current: 1
};
const columns = computed(() => [
- {
- title: '序号',
- dataIndex: 'index',
- slotName: 'index',
- width: 60,
- },
{
title: '标题',
dataIndex: 'title',
+ },
+ {
+ title: '时间',
+ dataIndex: 'publishTime',
+ slotName: 'publishTime',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
- title: t('时间'),
- dataIndex: 'publishTimeBegin',
- sortable: {
- sortDirections: ['ascend', 'descend'],
- },
- },
- {
- title: t('状态'),
- dataIndex: 'states',
- sortable: {
- sortDirections: ['ascend', 'descend'],
- },
+ title: '状态',
+ dataIndex: 'isRead',
+ slotName: 'isRead',
},
{
title: '操作',
@@ -223,27 +187,26 @@
]);
const statusOptions = computed(() => [
{
- label: t('已发布'),
+ label: '已读',
value: 'true',
},
{
- label: t('未发布'),
+ label: '未读',
value: 'false',
},
]);
// 获取公告列表
const fetchData = async (
- params: UserParams = { page: 1, size: 10, current: 1 }
+ params: BulletinsRecord = { size: 10, current: 1 }
) => {
setLoading(true);
try {
- const res = await userStore.getUserList(params);
+ const res = await bulletinsStore.getBulletinsList(params);
renderData.value = res.data.records;
pagination.page = res.data.page;
pagination.current = res.data.current;
pagination.total = res.data.total;
- pagination.size = res.data.size;
} catch (err) {
// you can report use errorHandler or other
} finally {
@@ -251,12 +214,35 @@
}
};
+ // 高亮行
+ const highlightRow = (record: BulletinsRecord) => {
+ if (record.top === true) {
+ console.log('record', record);
+ return 'background-color: yellow;';
+ }
+ return '';
+ };
+
+ // 时间范围
+ const timeRangs = (dateString: string[]) => {
+ // eslint-disable-next-line prefer-destructuring
+ formModel.value.publishTimeBegin = dateString[0];
+ // eslint-disable-next-line prefer-destructuring
+ formModel.value.publishTimeEnd = dateString[1];
+ };
+
+ // 详情
+ const handleRead = async (record: BulletinsRecord) => {
+ // await bulletinsStore.readBulletins({ id: record.id });
+ await router.push({ name: 'Details', params: { id: record.id } });
+ };
+
// 查询
const search = () => {
fetchData({
...pagination,
...formModel.value,
- } as unknown as UserParams);
+ } as unknown as BulletinsRecord);
};
// 分页发生改变
@@ -267,8 +253,8 @@
};
// 数据条数改变
- const onSizeChange = (size: number) => {
- pagination.size = size;
+ const onSizeChange = (total: number) => {
+ pagination.total = total;
search();
};
@@ -283,36 +269,8 @@
const alignLeft = ref(false);
const handleSortChange = (data: any, extra: any, currentDataSource: any) => {};
- // 是否启用
- const enabledStatus = async (record: string) => {
- record.enabled = !record.enabled;
- const res = await userStore.enabledUser(record.id);
- if (res.status === 200) {
- Message.success({
- content: t('modify.status.sucess'),
- duration: 3 * 1000,
- });
- } else {
- Message.error({
- content: t('modify.status.fail'),
- duration: 3 * 1000,
- });
- }
- };
+ watch(() => columns.value, deepClone, { deep: true, immediate: true });
- // 删除
- // const handleDelete = async (record: UserRecord) => {
- // const res = await userStore.removeUser(record.id);
- // if (res.status === 200) {
- // Message.success({
- // content: '删除成功',
- // duration: 5 * 1000,
- // });
- // search();
- // }
- // };
-
- watch(() => columns.value, deepClone, { deep: true, immediate: true });
\ No newline at end of file