提交 992d4e9b 作者: ZhangLingKun

优化:通知管理编辑

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