-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83cca58
commit 808d339
Showing
6 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import CommunitySelector from '@/components/CommunitySelector'; | ||
import { fetchDriedFishList } from '@/services/dried-fish'; | ||
import { PlusOutlined } from '@ant-design/icons'; | ||
import type { ActionType, ProColumns } from '@ant-design/pro-components'; | ||
import { PageContainer, ProTable } from '@ant-design/pro-components'; | ||
import { Button } from 'antd'; | ||
import { useRef } from 'react'; | ||
import { OPERATIONS } from '@/pages/commonSettings'; | ||
// import Create from './components/Create'; | ||
// import Delete from './components/Delete'; | ||
// import Edit from './components/Edit'; | ||
import { CAROUSEL_COLUMNS } from './settings'; | ||
|
||
const DriedFish: React.FC = () => { | ||
const actionRef = useRef<ActionType>(); | ||
// const [currentCarousel, setCurrentCarousel] = useState({}); | ||
// const [createVisible, setCreateVisible] = useState(false); | ||
// const [deleteVisible, setDeleteVisible] = useState(false); | ||
// const [editVisible, setEditVisible] = useState(false); | ||
|
||
const requestTable = async ( | ||
params: any & { | ||
pageSize: number; | ||
current: number; | ||
}, | ||
) => { | ||
const data = await fetchDriedFishList({ | ||
...params, | ||
page: params.current - 1, | ||
}); | ||
return { | ||
data: data.plans, | ||
success: true, | ||
total: data.total, | ||
}; | ||
}; | ||
|
||
const access = localStorage.getItem('access'); | ||
|
||
const columns: ProColumns[] = [ | ||
...CAROUSEL_COLUMNS, | ||
{ | ||
...OPERATIONS, | ||
width: 200, | ||
render: () => ( | ||
<> | ||
<Button | ||
type="link" | ||
size="small" | ||
key="complete" | ||
onClick={() => { | ||
// setCurrentCarousel(record); | ||
// setEditVisible(true); | ||
}} | ||
> | ||
完成计划 | ||
</Button> | ||
<Button | ||
type="link" | ||
size="small" | ||
key="detail" | ||
onClick={() => { | ||
// setCurrentCarousel(record); | ||
// setEditVisible(true); | ||
}} | ||
> | ||
详情 | ||
</Button> | ||
<Button | ||
type="link" | ||
size="small" | ||
key="edit" | ||
onClick={() => { | ||
// setCurrentCarousel(record); | ||
// setEditVisible(true); | ||
}} | ||
> | ||
编辑 | ||
</Button> | ||
<Button | ||
type="link" | ||
size="small" | ||
danger | ||
key="delete" | ||
onClick={() => { | ||
// setCurrentCarousel(record); | ||
// setDeleteVisible(true); | ||
}} | ||
> | ||
删除 | ||
</Button> | ||
</> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<PageContainer> | ||
{access === 'superAdmin' ? <CommunitySelector actionRef={actionRef} /> : <></>} | ||
<ProTable<API.RuleListItem, API.PageParams> | ||
headerTitle="小鱼干计划信息" | ||
actionRef={actionRef} | ||
rowKey="id" | ||
search={false} | ||
toolBarRender={() => [ | ||
<Button | ||
type="primary" | ||
key="primary" | ||
onClick={() => { | ||
// setCreateVisible(true); | ||
}} | ||
> | ||
<PlusOutlined /> | ||
新建 | ||
</Button>, | ||
]} | ||
request={requestTable} | ||
columns={columns} | ||
pagination={{ | ||
pageSize: 20, | ||
}} | ||
/> | ||
{/* <Create open={createVisible} setCreateVisible={setCreateVisible} actionRef={actionRef} /> | ||
<Delete | ||
open={deleteVisible} | ||
setDeleteVisible={setDeleteVisible} | ||
actionRef={actionRef} | ||
currentCarousel={currentCarousel} | ||
/> | ||
<Edit | ||
open={editVisible} | ||
setEditVisible={setEditVisible} | ||
actionRef={actionRef} | ||
currentCarousel={currentCarousel} | ||
/> */} | ||
</PageContainer> | ||
); | ||
}; | ||
|
||
export default DriedFish; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { NAME, USER } from '@/pages/commonSettings'; | ||
import type { ProColumns } from '@ant-design/pro-components'; | ||
import { Progress, Tag } from 'antd'; | ||
|
||
const MAX_ORDER = 10; | ||
|
||
const transferType = (type: number) => { | ||
let newType; | ||
switch (type) { | ||
case 0: | ||
newType = '加餐'; | ||
break; | ||
case 1: | ||
newType = '绝育'; | ||
break; | ||
case 2: | ||
newType = '治病'; | ||
break; | ||
case 3: | ||
newType = '其他'; | ||
break; | ||
default: | ||
newType = ''; | ||
} | ||
return newType; | ||
}; | ||
|
||
const PLAN_COLOR = new Map([ | ||
[0, '#108ee9'], | ||
[1, '#f50'], | ||
[2, '#87d068'], | ||
[3, 'default'], | ||
]); | ||
|
||
export const PLAN_TYPE: ProColumns = { | ||
title: '计划类型', | ||
dataIndex: 'planType', | ||
hideInSearch: true, | ||
render: (_: any) => <Tag color={PLAN_COLOR.get(_)}>{transferType(_)}</Tag>, | ||
}; | ||
|
||
export const PLAN_PROGRESS: ProColumns = { | ||
title: '计划进度', | ||
dataIndex: 'planType', | ||
hideInSearch: true, | ||
render: (_, record) => ( | ||
<div style={{ paddingRight: 20 }}> | ||
<Progress percent={record.nowFish / record.maxFish} size="small" /> | ||
</div> | ||
), | ||
}; | ||
|
||
export const CAROUSEL_COLUMNS = [ | ||
{ | ||
order: MAX_ORDER + 8, | ||
...NAME, | ||
title: '计划名', | ||
width: 80, | ||
}, | ||
{ | ||
order: MAX_ORDER + 6, | ||
...PLAN_TYPE, | ||
width: 50, | ||
}, | ||
{ | ||
order: MAX_ORDER + 4, | ||
...PLAN_PROGRESS, | ||
width: 180, | ||
}, | ||
{ | ||
order: MAX_ORDER + 2, | ||
...USER, | ||
width: 100, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { request } from '@umijs/max'; | ||
import { DEFAULT_URL } from '.'; | ||
|
||
/** | ||
* 获取轮播图列表 | ||
* @param params | ||
* @returns | ||
*/ | ||
export const fetchDriedFishList = async ( | ||
params: { | ||
page?: number; | ||
}, | ||
options?: { [key: string]: any }, | ||
) => | ||
request(`${DEFAULT_URL}/plan/get_plan_previews`, { | ||
method: 'GET', | ||
params: { | ||
...params, | ||
}, | ||
...(options || {}), | ||
}); | ||
|
||
/** | ||
* 新增轮播图 | ||
* @param params | ||
* @returns | ||
*/ | ||
// export const createCarousel = async (data: any, options?: { [key: string]: any }) => { | ||
// return request(`${DEFAULT_URL}/notice/new_news`, { | ||
// method: 'POST', | ||
// data: { | ||
// ...data, | ||
// }, | ||
// ...(options || {}), | ||
// }); | ||
// }; | ||
|
||
/** | ||
* 删除轮播图 | ||
* @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 || {}), | ||
// }); | ||
// }; | ||
|
||
/** | ||
* 编辑轮播图 | ||
* @param params | ||
* @returns | ||
*/ | ||
// export const editCarousel = async (data: any, options?: { [key: string]: any }) => { | ||
// return request(`${DEFAULT_URL}/notice/new_news`, { | ||
// method: 'POST', | ||
// data: { | ||
// ...data, | ||
// }, | ||
// ...(options || {}), | ||
// }); | ||
// }; |