refactor(notice): 移除临时权限函数并优化表格操作按钮

- 移除了临时假权限函数_hasPermission
- 简化了新增按钮的权限控制逻辑
- 统一了编辑和删除按钮的显示方式
- 更新了删除确认对话框的提示文案
- 调整了发布范围选择的数据结构
master
wangyan 2026-03-13 14:13:19 +08:00
parent 84bbdd8595
commit 7568638bc2
1 changed files with 34 additions and 50 deletions

View File

@ -18,17 +18,6 @@ function List(props) {
form, form,
}); });
// 临时假权限函数,用于开发测试
const _hasPermission = (permissionCode) => {
// 在开发环境中返回true生产环境可以根据实际权限系统调整
const fakePermissions = [
"notice-add",
"notice-edit",
"notice-remove",
];
return fakePermissions.includes(permissionCode);
};
return ( return (
<Page isShowAllAction={false}> <Page isShowAllAction={false}>
<Search <Search
@ -42,22 +31,20 @@ function List(props) {
name: "publishScope", name: "publishScope",
label: "发布范围", label: "发布范围",
render: FORM_ITEM_RENDER_ENUM.SELECT, render: FORM_ITEM_RENDER_ENUM.SELECT,
items: [{ bianma: "0", name: "全部" }, { bianma: "1", name: "股份" }, { bianma: "2", name: "分子公司" }, { bianma: "3", name: "相关方" }], items: [{ bianma: "1,2,3", name: "全部" }, { bianma: "1", name: "股份" }, { bianma: "2", name: "分子公司" }, { bianma: "3", name: "相关方" }],
}, },
]} ]}
/> />
<Table <Table
toolBarRender={() => ( toolBarRender={() => (
<Space> <Space>
{_hasPermission("notice-add") && ( <Button
<Button type="primary"
type="primary" icon={<AddIcon />}
icon={<AddIcon />} onClick={() => props.history.push(`./Add`)}
onClick={() => props.history.push(`./Add`)} >
> 新增
新增 </Button>
</Button>
)}
</Space> </Space>
)} )}
columns={[ columns={[
@ -104,35 +91,32 @@ function List(props) {
> >
查看 查看
</Button> </Button>
{_hasPermission("notice-edit") && (
<Button <Button
type="link" type="link"
onClick={() => props.history.push(`./Add?id=${record.id}`)} onClick={() => props.history.push(`./Add?id=${record.id}`)}
> >
编辑 编辑
</Button> </Button>
)} <Button
{_hasPermission("notice-remove") && ( type="link"
<Button danger
type="link" onClick={() => {
danger Modal.confirm({
onClick={() => { title: "是否确认删除当前公告?",
Modal.confirm({ onOk: async () => {
title: "确定删除吗?", await props["noticeDelete"]({ id: record.id }).then((res) => {
onOk: async () => { if (res.success) {
await props["noticeDelete"]({ id: record.id }).then((res) => { message.success("删除成功");
if (res.success) { getData();
message.success("删除成功"); }
getData(); });
} },
}); });
}, }}
}); >
}} 删除
> </Button>
删除
</Button>
)}
</Space> </Space>
), ),
}, },