提交 4b053a2a 作者: ZhangLingKun

功能:宣传中心问题修复

上级 4d5b6f33
...@@ -60,9 +60,9 @@ export type insertModuleInfo = InterFunction< ...@@ -60,9 +60,9 @@ export type insertModuleInfo = InterFunction<
export type updateModuleInfo = InterFunction< export type updateModuleInfo = InterFunction<
{ {
id: number; id: number;
moduleCode: string; moduleCode?: string;
moduleName: string; moduleName?: string;
moduleType: number; moduleType?: number;
remark?: string; remark?: string;
}, },
NonNullable<unknown> NonNullable<unknown>
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Form, Input, Select, Table, Image, Modal, message } from 'antd'; import { Button, Form, Input, Select, Table, Image, Modal, message } from 'antd';
import { listBannerInfoPage } from '~/api/interface/commonType'; import { listBannerInfoPage, updateModuleInfo } from '~/api/interface/commonType';
import { InterListType, InterReqListType } from '~/api/interface'; import { InterListType, InterReqListType, InterReqType } from '~/api/interface';
import { useLocation, useNavigate } from 'react-router-dom'; import { useLocation, useNavigate } from 'react-router-dom';
import qs from 'query-string'; import qs from 'query-string';
import { ArrowDownOutlined, ArrowUpOutlined, PlusOutlined } from '@ant-design/icons'; import { ArrowDownOutlined, ArrowUpOutlined, PlusOutlined } from '@ant-design/icons';
...@@ -41,7 +41,7 @@ const bannerType = [ ...@@ -41,7 +41,7 @@ const bannerType = [
const MaterielManageDetail = () => { const MaterielManageDetail = () => {
const { confirm } = Modal; const { confirm } = Modal;
// 表单钩子 // 表单钩子
const [form] = Form.useForm<ReqType>(); const [form] = Form.useForm<InterReqType<updateModuleInfo>>();
// 路由钩子 // 路由钩子
const location = useLocation(); const location = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
...@@ -101,8 +101,11 @@ const MaterielManageDetail = () => { ...@@ -101,8 +101,11 @@ const MaterielManageDetail = () => {
onOk: async () => { onOk: async () => {
const res = await CommonAPI.removeBannerInfo({ id: record.id }); const res = await CommonAPI.removeBannerInfo({ id: record.id });
if (res && res.code === '200') { if (res && res.code === '200') {
paginationChange(pagination.current, pagination.pageSize); message.success('删除成功');
await message.success('删除成功'); paginationChange(
tableData.length === 1 ? pagination.current - 1 : pagination.current,
pagination.pageSize,
);
} }
}, },
}); });
...@@ -164,6 +167,31 @@ const MaterielManageDetail = () => { ...@@ -164,6 +167,31 @@ const MaterielManageDetail = () => {
getAllData().then(); getAllData().then();
} }
}; };
// 修改提交数据
const handleEdit = () => {
form
.validateFields()
.then(async (values) => {
const res = await CommonAPI.updateModuleInfo({
...values,
id: Number(qs.parse(location.search).id),
});
if (res && res.code === '200') {
message.success('修改成功');
getTableList().then();
getAllData().then();
} else {
window.location.reload();
}
})
.catch((err) => {
message
.warning({
content: err.errorFields[0].errors[0],
})
.then();
});
};
// componentDidMount // componentDidMount
useEffect(() => { useEffect(() => {
query = {}; query = {};
...@@ -268,7 +296,9 @@ const MaterielManageDetail = () => { ...@@ -268,7 +296,9 @@ const MaterielManageDetail = () => {
justifyContent: 'space-around', justifyContent: 'space-around',
}} }}
> >
<Button type={'primary'}>修改</Button> <Button type={'primary'} onClick={handleEdit}>
修改
</Button>
<Button type={'primary'} onClick={handleBack}> <Button type={'primary'} onClick={handleBack}>
返回 返回
</Button> </Button>
......
...@@ -99,8 +99,11 @@ const MaterielManageView = () => { ...@@ -99,8 +99,11 @@ const MaterielManageView = () => {
onOk: async () => { onOk: async () => {
const res = await CommonAPI.removeModuleInfo({ id: record.id }); const res = await CommonAPI.removeModuleInfo({ id: record.id });
if (res && res.code === '200') { if (res && res.code === '200') {
paginationChange(pagination.current, pagination.pageSize); message.success('删除成功');
await message.success('删除成功'); paginationChange(
tableData.length === 1 ? pagination.current - 1 : pagination.current,
pagination.pageSize,
);
} }
}, },
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论