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",
|
"noticeLoading",
|
||||||
"Delete > @/appmenu/notice/ids/{ids}",
|
"Delete > @/appmenu/notice/ids/{ids}",
|
||||||
);
|
);
|
||||||
export const noticeInfo = declareRequest("noticeLoading", "Get > /appmenu/notice/{id}");
|
export const noticeInfo = declareRequest(
|
||||||
export const noticeReadStatus = declareRequest("noticeLoading", "Get > /appmenu/notice/readStatus/{noticeId}");
|
"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 contentValue = Form.useWatch("content", form);
|
||||||
const publishScope = Form.useWatch("publishScope", form);
|
const publishScope = Form.useWatch("publishScope", form);
|
||||||
|
|
||||||
|
// 判断是否为只读模式
|
||||||
|
const isReadOnly = queryParams["readonly"] === "true";
|
||||||
|
|
||||||
// 当取消勾选分子公司时,清空发布部门ID
|
// 当取消勾选分子公司时,清空发布部门ID
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (publishScope && !publishScope.includes("2")) {
|
if (publishScope && !publishScope.includes("2")) {
|
||||||
|
|
@ -26,15 +29,26 @@ function Add(props) {
|
||||||
if (queryParams["id"]) {
|
if (queryParams["id"]) {
|
||||||
props["noticeInfo"]({ id: queryParams["id"] }).then((res) => {
|
props["noticeInfo"]({ id: queryParams["id"] }).then((res) => {
|
||||||
if (res.data) {
|
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(() => {
|
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) {
|
if (res.data) {
|
||||||
|
console.log(res.data);
|
||||||
res.data.forEach((item) => {
|
res.data.forEach((item) => {
|
||||||
item.bianma = item.id;
|
item.bianma = item.id;
|
||||||
item.name = item.corpName;
|
item.name = item.corpName;
|
||||||
|
|
@ -52,6 +66,15 @@ function Add(props) {
|
||||||
return; // 阻止后续逻辑
|
return; // 阻止后续逻辑
|
||||||
}
|
}
|
||||||
const values = await form.validateFields();
|
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"]) {
|
if (queryParams["id"]) {
|
||||||
values.id = queryParams["id"];
|
values.id = queryParams["id"];
|
||||||
props["noticeEdit"](values).then((res) => {
|
props["noticeEdit"](values).then((res) => {
|
||||||
|
|
@ -73,8 +96,8 @@ function Add(props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
headerTitle={queryParams["id"] ? "编辑" : "新增"}
|
headerTitle={isReadOnly ? "查看" : queryParams["id"] ? "编辑" : "新增"}
|
||||||
extraActionButtons={(
|
extraActionButtons={!isReadOnly && (
|
||||||
<div style={{ textAlign: "center", height: 50, marginTop: 15 }} className="no-print">
|
<div style={{ textAlign: "center", height: 50, marginTop: 15 }} className="no-print">
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|
@ -93,6 +116,7 @@ function Add(props) {
|
||||||
span={24}
|
span={24}
|
||||||
showActionButtons={false}
|
showActionButtons={false}
|
||||||
onFinish={onSubmit}
|
onFinish={onSubmit}
|
||||||
|
disabled={isReadOnly}
|
||||||
options={[
|
options={[
|
||||||
{ name: "title", label: "公告标题", required: true },
|
{ name: "title", label: "公告标题", required: true },
|
||||||
{
|
{
|
||||||
|
|
@ -107,7 +131,7 @@ function Add(props) {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "deptId",
|
name: "publishCorpinfoIds",
|
||||||
label: "选择分子公司",
|
label: "选择分子公司",
|
||||||
required: publishScope && publishScope.includes("2"),
|
required: publishScope && publishScope.includes("2"),
|
||||||
hidden: !publishScope || !publishScope.includes("2"),
|
hidden: !publishScope || !publishScope.includes("2"),
|
||||||
|
|
@ -122,21 +146,24 @@ function Add(props) {
|
||||||
label: "是否需要回复",
|
label: "是否需要回复",
|
||||||
required: true,
|
required: true,
|
||||||
render: "radio",
|
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: "publishTime", label: "发布时间", required: true, render: FORM_ITEM_RENDER_ENUM.DATETIME },
|
||||||
{
|
{
|
||||||
name: "content",
|
name: "content",
|
||||||
label: "公告正文",
|
label: "公告内容",
|
||||||
required: true,
|
required: true,
|
||||||
customizeRender: true,
|
customizeRender: true,
|
||||||
render: (
|
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
|
<Editor
|
||||||
value={contentValue || ""}
|
value={contentValue || ""}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
|
if (!isReadOnly) {
|
||||||
form.setFieldValue("content", value);
|
form.setFieldValue("content", value);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
|
disabled={isReadOnly}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ function List(props) {
|
||||||
onFinish={getData}
|
onFinish={getData}
|
||||||
options={[
|
options={[
|
||||||
{ name: "title", label: "公告名称" },
|
{ name: "title", label: "公告名称" },
|
||||||
{ name: "deptName", label: "部门名称" },
|
{ name: "departmentName", label: "部门名称" },
|
||||||
{
|
{
|
||||||
name: "publishScope",
|
name: "publishScope",
|
||||||
label: "发布范围",
|
label: "发布范围",
|
||||||
|
|
@ -63,16 +63,16 @@ function List(props) {
|
||||||
columns={[
|
columns={[
|
||||||
{ dataIndex: "title", title: "公告名称" },
|
{ dataIndex: "title", title: "公告名称" },
|
||||||
{ dataIndex: "publishTime", title: "发布时间" },
|
{ dataIndex: "publishTime", title: "发布时间" },
|
||||||
{ dataIndex: "deptName", title: "发布部门" },
|
{ dataIndex: "departmentName", title: "发布部门" },
|
||||||
{ dataIndex: "createName", title: "发布人" },
|
{ dataIndex: "createName", title: "发布人" },
|
||||||
{
|
{
|
||||||
dataIndex: "publishScope",
|
dataIndex: "publishScope",
|
||||||
title: "发布范围",
|
title: "发布范围",
|
||||||
render: (value) => {
|
render: (_, record) => {
|
||||||
if (!value)
|
if (!record.publishScope)
|
||||||
return "";
|
return "";
|
||||||
const scopeMap = { 0: "全部", 1: "股份", 2: "分子公司", 3: "相关方" };
|
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
|
<span
|
||||||
style={{ color: "#00BCD4", cursor: "pointer" }}
|
style={{ color: "#00BCD4", cursor: "pointer" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setCurrentId(record.id);
|
||||||
|
setViewModalVisible(true);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
>
|
>
|
||||||
{record.readCount || 0}
|
{record.alreadyReadCount || 0}
|
||||||
/
|
/
|
||||||
{record.unreadCount || 0}
|
{record.shouldReadCount || 0}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -97,6 +98,12 @@ function List(props) {
|
||||||
width: 200,
|
width: 200,
|
||||||
render: (row, record) => (
|
render: (row, record) => (
|
||||||
<Space>
|
<Space>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
onClick={() => props.history.push(`./Add?id=${record.id}&readonly=true`)}
|
||||||
|
>
|
||||||
|
查看
|
||||||
|
</Button>
|
||||||
{_hasPermission("notice-edit") && (
|
{_hasPermission("notice-edit") && (
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue