提交 4b053a2a 作者: ZhangLingKun

功能:宣传中心问题修复

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