From 14430554b0918625b5d98e34d4432a72286022c1 Mon Sep 17 00:00:00 2001 From: wangyan Date: Fri, 6 Feb 2026 18:37:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(notice):=20=E6=B7=BB=E5=8A=A0=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E6=A8=A1=E5=9D=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增公告相关的API接口定义,包括列表、新增、编辑、删除等功能 - 添加公告管理页面,包含列表展示和新增编辑功能 - 实现公告的富文本编辑器功能和发布范围设置 - 集成企业信息获取接口用于公告发布范围选择 - 完成公告模块的权限控制和数据交互逻辑 --- src/api/Notice/index.js | 24 +++ src/api/corpInfo/index.js | 6 + src/enumerate/namespace/index.js | 2 + src/pages/Container/Notice/Add/index.js | 150 +++++++++++++++++ src/pages/Container/Notice/List/index.js | 195 +++++++++++++++++++++++ src/pages/Container/Notice/index.js | 5 + 6 files changed, 382 insertions(+) create mode 100644 src/api/Notice/index.js create mode 100644 src/api/corpInfo/index.js create mode 100644 src/pages/Container/Notice/Add/index.js create mode 100644 src/pages/Container/Notice/List/index.js create mode 100644 src/pages/Container/Notice/index.js diff --git a/src/api/Notice/index.js b/src/api/Notice/index.js new file mode 100644 index 0000000..e3c201b --- /dev/null +++ b/src/api/Notice/index.js @@ -0,0 +1,24 @@ +import { declareRequest } from "@cqsjjb/jjb-dva-runtime"; + +export const noticeList = declareRequest( + "noticeLoading", + "Post > @/appmenu/notice/list", +); +export const noticeAdd = declareRequest( + "noticeLoading", + "Post > @/appmenu/notice/save", +); +export const noticeEdit = declareRequest( + "noticeLoading", + "Put > @/appmenu/notice/edit", +); +export const noticeDelete = declareRequest( + "noticeLoading", + "Delete > @/appmenu/notice/{id}", +); +export const noticeBatchDelete = declareRequest( + "noticeLoading", + "Delete > @/appmenu/notice/ids/{ids}", +); +export const noticeInfo = declareRequest("noticeLoading", "Get > /appmenu/notice/{id}"); +export const noticeReadStatus = declareRequest("noticeLoading", "Get > /appmenu/notice/readStatus/{noticeId}"); diff --git a/src/api/corpInfo/index.js b/src/api/corpInfo/index.js new file mode 100644 index 0000000..2bbe465 --- /dev/null +++ b/src/api/corpInfo/index.js @@ -0,0 +1,6 @@ +import { declareRequest } from "@cqsjjb/jjb-dva-runtime"; + +export const corpInfoListAll = declareRequest( + "corpInfoLoading", + "Get > /basicInfo/corpInfo/listAll", +); diff --git a/src/enumerate/namespace/index.js b/src/enumerate/namespace/index.js index 0ed8dce..991c89d 100644 --- a/src/enumerate/namespace/index.js +++ b/src/enumerate/namespace/index.js @@ -6,3 +6,5 @@ import { defineNamespace } from "@cqsjjb/jjb-dva-runtime"; export const NS_GLOBAL = defineNamespace("global"); export const NS_APP_MENU = defineNamespace("appMenu"); +export const NS_NOTICE = defineNamespace("Notice"); +export const NS_CORPINFO = defineNamespace("corpInfo"); diff --git a/src/pages/Container/Notice/Add/index.js b/src/pages/Container/Notice/Add/index.js new file mode 100644 index 0000000..4a42ec5 --- /dev/null +++ b/src/pages/Container/Notice/Add/index.js @@ -0,0 +1,150 @@ +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { Button, Form, message } from "antd"; +import { useEffect, useState } from "react"; +import Editor from "zy-react-library/components/Editor"; +import FormBuilder from "zy-react-library/components/FormBuilder"; +import Page from "zy-react-library/components/Page"; +import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender"; +import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; +import { NS_CORPINFO, NS_NOTICE } from "~/enumerate/namespace"; + +function Add(props) { + const queryParams = useGetUrlQuery(); + const [form] = Form.useForm(); + const [corpData, setCorpData] = useState([]); + const contentValue = Form.useWatch("content", form); + const publishScope = Form.useWatch("publishScope", form); + + // 当取消勾选分子公司时,清空发布部门ID + useEffect(() => { + if (publishScope && !publishScope.includes("2")) { + form.setFieldValue("deptId", undefined); + } + }, [publishScope]); + + useEffect(() => { + if (queryParams["id"]) { + props["noticeInfo"]({ id: queryParams["id"] }).then((res) => { + if (res.data) { + form.setFieldsValue(res.data); + } + }); + } + }, []); + + useEffect(() => { + props["corpInfoListAll"]({ inType: "0,1,2,6", eqUseFlag: 1 }).then((res) => { + if (res.data) { + res.data.forEach((item) => { + item.bianma = item.id; + item.name = item.corpName; + }); + } + setCorpData(res.data); + }); + }, []); + + const onSubmit = async () => { + try { + await form.validateFields(); // 触发表单校验 + } + catch { + return; // 阻止后续逻辑 + } + const values = await form.validateFields(); + if (queryParams["id"]) { + values.id = queryParams["id"]; + props["noticeEdit"](values).then((res) => { + if (res.success) { + message.success("编辑成功!"); + window.history.back(); + } + }); + } + else { + props["noticeAdd"](values).then((res) => { + if (res.success) { + message.success("新增成功!"); + window.history.back(); + } + }); + } + }; + + return ( + + + + )} + > + + { + form.setFieldValue("content", value); + }} + /> + + ), + }, + ]} + /> + + ); +} + +export default Connect([NS_NOTICE, NS_CORPINFO], true)(Add); diff --git a/src/pages/Container/Notice/List/index.js b/src/pages/Container/Notice/List/index.js new file mode 100644 index 0000000..6443046 --- /dev/null +++ b/src/pages/Container/Notice/List/index.js @@ -0,0 +1,195 @@ +import { Permission } from "@cqsjjb/jjb-common-decorator/permission"; +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { Button, Form, message, Modal, Space } from "antd"; +import { useState } from "react"; +import AddIcon from "zy-react-library/components/Icon/AddIcon"; +import Page from "zy-react-library/components/Page"; +import Search from "zy-react-library/components/Search/index"; +import Table from "zy-react-library/components/Table/index"; +import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender"; +import useTable from "zy-react-library/hooks/useTable"; +import { NS_NOTICE } from "~/enumerate/namespace"; + +function List(props) { + const [form] = Form.useForm(); + const [viewModalVisible, setViewModalVisible] = useState(false); + const [currentId, setCurrentId] = useState([]); + const { tableProps, getData } = useTable(props["noticeList"], { + form, + }); + + // 临时假权限函数,用于开发测试 + const _hasPermission = (permissionCode) => { + // 在开发环境中返回true,生产环境可以根据实际权限系统调整 + const fakePermissions = [ + "notice-add", + "notice-edit", + "notice-remove", + ]; + return fakePermissions.includes(permissionCode); + }; + + return ( + + + ( + + {_hasPermission("notice-add") && ( + + )} + + )} + columns={[ + { dataIndex: "title", title: "公告名称" }, + { dataIndex: "publishTime", title: "发布时间" }, + { dataIndex: "deptName", title: "发布部门" }, + { dataIndex: "createName", title: "发布人" }, + { + dataIndex: "publishScope", + title: "发布范围", + render: (value) => { + if (!value) + return ""; + const scopeMap = { 0: "全部", 1: "股份", 2: "分子公司", 3: "相关方" }; + return value.split(",").map(code => scopeMap[code.trim()] || code.trim()).join(", "); + }, + }, + { + dataIndex: "viewStatus", + title: "查看状态", + render: (_, record) => ( + { + }} + + > + {record.readCount || 0} + / + {record.unreadCount || 0} + + ), + }, + { + title: "操作", + align: "center", + width: 200, + render: (row, record) => ( + + {_hasPermission("notice-edit") && ( + + )} + {_hasPermission("notice-remove") && ( + + )} + + ), + }, + ]} + {...tableProps} + /> + {viewModalVisible && ( + { + setViewModalVisible(false); + setCurrentId(""); + }} + /> + )} + + ); +} +function ViewModalComponent(props) { + const [form] = Form.useForm(); + const { tableProps, getData } = useTable(props["noticeReadStatus"], { + form, + }); + + const onCancel = () => { + form.resetFields(); + props.onCancel(); + }; + return ( + + +
+ + ); +} +const ViewModal = ViewModalComponent; +export default Connect([NS_NOTICE], true)(Permission(List)); diff --git a/src/pages/Container/Notice/index.js b/src/pages/Container/Notice/index.js new file mode 100644 index 0000000..3271758 --- /dev/null +++ b/src/pages/Container/Notice/index.js @@ -0,0 +1,5 @@ +function AppMenu(props) { + return props.children; +} + +export default AppMenu;