Skip to content

Commit

Permalink
feat: 删除小鱼干计划
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanCheng committed Nov 21, 2023
1 parent 80c20e1 commit 4e7e838
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
41 changes: 41 additions & 0 deletions src/pages/CommunityAdmin/DriedFish/components/Delete/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { deletePlan } from '@/services/dried-fish';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Modal, Space } from 'antd';

const Delete = ({ open, setDeleteVisible, actionRef, currentDriedFish }: any) => {
const handleDelete = async () => {
const success = await deletePlan({ planId: currentDriedFish });
if (success) {
setDeleteVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
};

const handleCancel = () => {
setDeleteVisible(false);
};

return (
<Modal
title={
<Space>
<ExclamationCircleOutlined />
删除小鱼干计划
</Space>
}
open={open}
okText="确认"
okType="danger"
cancelText="取消"
centered
onOk={handleDelete}
onCancel={handleCancel}
>
确定删除这条小鱼干计划吗?
</Modal>
);
};

export default Delete;
12 changes: 5 additions & 7 deletions src/pages/CommunityAdmin/DriedFish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Button } from 'antd';
import { useRef, useState } from 'react';
import { OPERATIONS } from '@/pages/commonSettings';
import Create from './components/Create';
// import Delete from './components/Delete';
import Delete from './components/Delete';
import Edit from './components/Edit';
import View from './components/View';
import { CAROUSEL_COLUMNS } from './settings';
Expand All @@ -16,7 +16,7 @@ const DriedFish: React.FC = () => {
const actionRef = useRef<ActionType>();
const [currentDriedFish, setCurrentDriedFish] = useState({});
const [createVisible, setCreateVisible] = useState(false);
// const [deleteVisible, setDeleteVisible] = useState(false);
const [deleteVisible, setDeleteVisible] = useState(false);
const [editVisible, setEditVisible] = useState(false);
const [viewVisible, setViewVisible] = useState(false);
const [includeGlobalPlan, setIncludeGlobalPlan] = useState(0);
Expand Down Expand Up @@ -77,8 +77,8 @@ const DriedFish: React.FC = () => {
danger
key="delete"
onClick={() => {
// setCurrentCarousel(record);
// setDeleteVisible(true);
setCurrentDriedFish(record.id);
setDeleteVisible(true);
}}
>
删除
Expand Down Expand Up @@ -131,14 +131,12 @@ const DriedFish: React.FC = () => {
}}
/>
<Create open={createVisible} setCreateVisible={setCreateVisible} actionRef={actionRef} />
{/*
<Delete
open={deleteVisible}
setDeleteVisible={setDeleteVisible}
actionRef={actionRef}
currentCarousel={currentCarousel}
currentDriedFish={currentDriedFish}
/>
*/}
<Edit
open={editVisible}
setEditVisible={setEditVisible}
Expand Down
18 changes: 9 additions & 9 deletions src/services/dried-fish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export const createPlan = async (data: any, options?: { [key: string]: any }) =>
* @param params
* @returns
*/
// export const deleteCarousel = async (data: any, options?: { [key: string]: any }) => {
// return request(`${DEFAULT_URL}/notice/remove_news`, {
// method: 'POST',
// data: {
// ...data,
// },
// ...(options || {}),
// });
// };
export const deletePlan = async (data: any, options?: { [key: string]: any }) => {
return request(`${DEFAULT_URL}/plan/delete_plan`, {
method: 'POST',
data: {
...data,
},
...(options || {}),
});
};

/**
* 编辑小鱼干计划
Expand Down

0 comments on commit 4e7e838

Please sign in to comment.