feat(notice): 实现公告模块的只读查看模式和数据格式优化
- 添加只读模式判断功能,支持通过readonly参数控制页面编辑状态 - 优化公告数据的序列化处理,实现发布范围和分子公司字段的数组与字符串转换 - 更新公告API接口,将noticeReadStatus方法从GET改为POST请求 - 修改公告列表页面的字段映射,统一使用departmentName替代deptName字段 - 优化公告列表的发布范围显示逻辑,修复渲染异常问题 - 添加公告查看按钮,支持以只读模式查看公告详情 - 在编辑器组件中添加禁用状态控制,确保只读模式下无法编辑内容 - 调整公告统计数据显示,使用alreadyReadCount和shouldReadCount字段替换原有计数方式master
parent
7e04624ab7
commit
c3f054ca19
|
|
@ -20,5 +20,11 @@ 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}");
|
||||
export const noticeInfo = declareRequest(
|
||||
"noticeLoading",
|
||||
"Get > /appmenu/notice/{id}",
|
||||
);
|
||||
export const noticeReadStatus = declareRequest(
|
||||
"noticeLoading",
|
||||
"Post > @/appmenu/notice/noticeReadStatus",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ function Add(props) {
|
|||
const contentValue = Form.useWatch("content", form);
|
||||
const publishScope = Form.useWatch("publishScope", form);
|
||||
|
||||
// 判断是否为只读模式
|
||||
const isReadOnly = queryParams["readonly"] === "true";
|
||||
|
||||
// 当取消勾选分子公司时,清空发布部门ID
|
||||
useEffect(() => {
|
||||
if (publishScope && !publishScope.includes("2")) {
|
||||
|
|
@ -26,15 +29,26 @@ function Add(props) {
|
|||
if (queryParams["id"]) {
|
||||
props["noticeInfo"]({ id: queryParams["id"] }).then((res) => {
|
||||
if (res.data) {
|
||||
form.setFieldsValue(res.data);
|
||||
// 处理编辑时的数据格式
|
||||
const formData = { ...res.data };
|
||||
// 将逗号分隔的字符串转换为数组
|
||||
if (formData.publishScope && typeof formData.publishScope === "string") {
|
||||
formData.publishScope = formData.publishScope.split(",");
|
||||
}
|
||||
if (formData.publishCorpinfoIds && typeof formData.publishCorpinfoIds === "string") {
|
||||
formData.publishCorpinfoIds = formData.publishCorpinfoIds.split(",");
|
||||
}
|
||||
form.setFieldsValue(formData);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
props["corpInfoListAll"]({ inType: "0,1,2,6", eqUseFlag: 1 }).then((res) => {
|
||||
console.log(props);
|
||||
props["corpInfoListAll"]({ inType: "0,1,6", eqUseFlag: 1 }).then((res) => {
|
||||
if (res.data) {
|
||||
console.log(res.data);
|
||||
res.data.forEach((item) => {
|
||||
item.bianma = item.id;
|
||||
item.name = item.corpName;
|
||||
|
|
@ -52,6 +66,15 @@ function Add(props) {
|
|||
return; // 阻止后续逻辑
|
||||
}
|
||||
const values = await form.validateFields();
|
||||
|
||||
// 将通知范围数组转换为字符串
|
||||
if (values.publishScope && Array.isArray(values.publishScope)) {
|
||||
values.publishScope = values.publishScope.join(",");
|
||||
}
|
||||
// 将分子公司数组转换为字符串
|
||||
if (values.publishCorpinfoIds && Array.isArray(values.publishCorpinfoIds)) {
|
||||
values.publishCorpinfoIds = values.publishCorpinfoIds.join(",");
|
||||
}
|
||||
if (queryParams["id"]) {
|
||||
values.id = queryParams["id"];
|
||||
props["noticeEdit"](values).then((res) => {
|
||||
|
|
@ -73,8 +96,8 @@ function Add(props) {
|
|||
|
||||
return (
|
||||
<Page
|
||||
headerTitle={queryParams["id"] ? "编辑" : "新增"}
|
||||
extraActionButtons={(
|
||||
headerTitle={isReadOnly ? "查看" : queryParams["id"] ? "编辑" : "新增"}
|
||||
extraActionButtons={!isReadOnly && (
|
||||
<div style={{ textAlign: "center", height: 50, marginTop: 15 }} className="no-print">
|
||||
<Button
|
||||
type="primary"
|
||||
|
|
@ -93,6 +116,7 @@ function Add(props) {
|
|||
span={24}
|
||||
showActionButtons={false}
|
||||
onFinish={onSubmit}
|
||||
disabled={isReadOnly}
|
||||
options={[
|
||||
{ name: "title", label: "公告标题", required: true },
|
||||
{
|
||||
|
|
@ -107,7 +131,7 @@ function Add(props) {
|
|||
],
|
||||
},
|
||||
{
|
||||
name: "deptId",
|
||||
name: "publishCorpinfoIds",
|
||||
label: "选择分子公司",
|
||||
required: publishScope && publishScope.includes("2"),
|
||||
hidden: !publishScope || !publishScope.includes("2"),
|
||||
|
|
@ -122,21 +146,24 @@ function Add(props) {
|
|||
label: "是否需要回复",
|
||||
required: true,
|
||||
render: "radio",
|
||||
items: [{ bianma: "1", name: "是" }, { bianma: "0", name: "否" }],
|
||||
items: [{ bianma: 1, name: "是" }, { bianma: 0, name: "否" }],
|
||||
},
|
||||
{ name: "publishTime", label: "发布时间", required: true, render: FORM_ITEM_RENDER_ENUM.DATETIME },
|
||||
{
|
||||
name: "content",
|
||||
label: "公告正文",
|
||||
label: "公告内容",
|
||||
required: true,
|
||||
customizeRender: true,
|
||||
render: (
|
||||
<Form.Item name="content" label="公告正文" labelCol={{ span: 2 }} wrapperCol={{ span: 22 }} rules={[{ required: true }]}>
|
||||
<Form.Item name="content" label="公告内容" labelCol={{ span: 2 }} wrapperCol={{ span: 22 }} rules={[{ required: true }]}>
|
||||
<Editor
|
||||
value={contentValue || ""}
|
||||
onChange={(value) => {
|
||||
if (!isReadOnly) {
|
||||
form.setFieldValue("content", value);
|
||||
}
|
||||
}}
|
||||
disabled={isReadOnly}
|
||||
/>
|
||||
</Form.Item>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function List(props) {
|
|||
onFinish={getData}
|
||||
options={[
|
||||
{ name: "title", label: "公告名称" },
|
||||
{ name: "deptName", label: "部门名称" },
|
||||
{ name: "departmentName", label: "部门名称" },
|
||||
{
|
||||
name: "publishScope",
|
||||
label: "发布范围",
|
||||
|
|
@ -63,16 +63,16 @@ function List(props) {
|
|||
columns={[
|
||||
{ dataIndex: "title", title: "公告名称" },
|
||||
{ dataIndex: "publishTime", title: "发布时间" },
|
||||
{ dataIndex: "deptName", title: "发布部门" },
|
||||
{ dataIndex: "departmentName", title: "发布部门" },
|
||||
{ dataIndex: "createName", title: "发布人" },
|
||||
{
|
||||
dataIndex: "publishScope",
|
||||
title: "发布范围",
|
||||
render: (value) => {
|
||||
if (!value)
|
||||
render: (_, record) => {
|
||||
if (!record.publishScope)
|
||||
return "";
|
||||
const scopeMap = { 0: "全部", 1: "股份", 2: "分子公司", 3: "相关方" };
|
||||
return value.split(",").map(code => scopeMap[code.trim()] || code.trim()).join(", ");
|
||||
return record.publishScope.split(",").map(code => scopeMap[code.trim()] || code.trim()).join(", ");
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -82,12 +82,13 @@ function List(props) {
|
|||
<span
|
||||
style={{ color: "#00BCD4", cursor: "pointer" }}
|
||||
onClick={() => {
|
||||
setCurrentId(record.id);
|
||||
setViewModalVisible(true);
|
||||
}}
|
||||
|
||||
>
|
||||
{record.readCount || 0}
|
||||
{record.alreadyReadCount || 0}
|
||||
/
|
||||
{record.unreadCount || 0}
|
||||
{record.shouldReadCount || 0}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
|
|
@ -97,6 +98,12 @@ function List(props) {
|
|||
width: 200,
|
||||
render: (row, record) => (
|
||||
<Space>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => props.history.push(`./Add?id=${record.id}&readonly=true`)}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
{_hasPermission("notice-edit") && (
|
||||
<Button
|
||||
type="link"
|
||||
|
|
|
|||
Loading…
Reference in New Issue