提交 992d4e9b 作者: ZhangLingKun

优化:通知管理编辑

上级 df72cd35
...@@ -106,6 +106,10 @@ export class ResourceManageAPI { ...@@ -106,6 +106,10 @@ export class ResourceManageAPI {
static insertSystemMessage: insertSystemMessage = (params) => static insertSystemMessage: insertSystemMessage = (params) =>
axios.post('/userapp/message/insertSystemMessage', params); axios.post('/userapp/message/insertSystemMessage', params);
// 后台发布消息——修改系统消息
static updateSystemMessage: insertSystemMessage = (params) =>
axios.post('/userapp/message/insertSystemMessage', params);
// 后台——删除消息 // 后台——删除消息
static removeMessage: removeMessage = (params) => static removeMessage: removeMessage = (params) =>
axios.get('/userapp/message/removeMessage', { params }); axios.get('/userapp/message/removeMessage', { params });
......
import React from 'react'; import React, { useEffect } from 'react';
import { Form, Input, message, Modal, ModalProps } from 'antd'; import { Form, Input, message, Modal, ModalProps } from 'antd';
import { InterReqType } from '~/api/interface'; import { InterReqType } from '~/api/interface';
import { insertSystemMessage } from '~/api/interface/resourceManageType'; import { insertSystemMessage } from '~/api/interface/resourceManageType';
...@@ -29,7 +29,12 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void ...@@ -29,7 +29,12 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void
}; };
// 提交数据 // 提交数据
const handleSubmit = async (values: ReqType) => { const handleSubmit = async (values: ReqType) => {
const res = await ResourceManageAPI.insertSystemMessage(values); const res = await ResourceManageAPI[
props.data?.id ? 'updateSystemMessage' : 'insertSystemMessage'
]({
...props.data,
...values,
});
if (res && res.code === '200') { if (res && res.code === '200') {
message.success('操作成功'); message.success('操作成功');
handleClose(); handleClose();
...@@ -40,6 +45,11 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void ...@@ -40,6 +45,11 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void
form.resetFields(); form.resetFields();
props.onCancel?.(); props.onCancel?.();
}; };
// 组件挂载
useEffect(() => {
if (!props.data) return;
form.setFieldsValue(props.data);
}, [props.data]);
return ( return (
<Modal {...props} width={680} onOk={handleOk} onCancel={handleClose}> <Modal {...props} width={680} onOk={handleOk} onCancel={handleClose}>
<Form <Form
...@@ -59,7 +69,7 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void ...@@ -59,7 +69,7 @@ const AddEditModalView: React.FC<ModalProps & { data?: any; onCancel: () => void
wrapperCol={{ span: 22 }} wrapperCol={{ span: 22 }}
> >
<RichText <RichText
richTextContent={form.getFieldValue('content') || ''} richTextContent={form.getFieldValue('content') || props?.data?.content}
onChange={(e) => form.setFieldValue('content', e)} onChange={(e) => form.setFieldValue('content', e)}
height={250} height={250}
/> />
......
...@@ -22,6 +22,8 @@ const NoticeManageView = () => { ...@@ -22,6 +22,8 @@ const NoticeManageView = () => {
pageSize: 10, pageSize: 10,
totalCount: 0, totalCount: 0,
}); });
// 编辑的内容
const [recordData, setRecordData] = useState<ListType[0]>();
// 加载列表 // 加载列表
const getTableList = async (value = {}) => { const getTableList = async (value = {}) => {
// 只需要修改这个地方的接口即可 // 只需要修改这个地方的接口即可
...@@ -98,7 +100,13 @@ const NoticeManageView = () => { ...@@ -98,7 +100,13 @@ const NoticeManageView = () => {
width: '200px', width: '200px',
render: (_text, record) => ( render: (_text, record) => (
<> <>
<Button type={'link'} disabled> <Button
type={'link'}
onClick={() => {
setRecordData(record);
setAddEditModalVisible(true);
}}
>
编辑 编辑
</Button> </Button>
<Button type={'link'} danger onClick={() => handleDelete(record)}> <Button type={'link'} danger onClick={() => handleDelete(record)}>
...@@ -139,11 +147,13 @@ const NoticeManageView = () => { ...@@ -139,11 +147,13 @@ const NoticeManageView = () => {
}} }}
/> />
<AddEditModalView <AddEditModalView
title={'新增通知'} title={recordData?.id ? '编辑通知' : '新增通知'}
open={addEditModalVisible} open={addEditModalVisible}
data={recordData}
onCancel={() => { onCancel={() => {
setAddEditModalVisible(false); setAddEditModalVisible(false);
paginationChange(pagination.pageNo, pagination.pageSize); paginationChange(pagination.pageNo, pagination.pageSize);
setRecordData(undefined);
}} }}
/> />
</> </>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论