| | |
| | | import { Button, message, Space } from 'antd'; |
| | | import { useRef, useState } from 'react'; |
| | | import { Access, history, useAccess } from 'umi'; |
| | | import AddAndEdit from './components/index'; |
| | | import { getList, updateStatus, deleteBanner } from './service' |
| | | const Banner = () => { |
| | | |
| | | const actionRef = useRef(); |
| | | const access = useAccess(); |
| | | const addViewRef = useRef(); |
| | | const [modalVisible, handleModalVisible] = useState(false); |
| | | |
| | | const columns = [ |
| | | { |
| | | title: 'banner名称', |
| | | dataIndex: 'bannerName' |
| | | dataIndex: 'name' |
| | | }, |
| | | // { |
| | | // title: '添加时间', |
| | | // dataIndex: 'createTime', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: '排序', |
| | | // dataIndex: 'sortNum', |
| | | // hideInSearch: true, |
| | | // }, |
| | | // { |
| | | // title: '状态', |
| | | // dataIndex: 'listingStatus', |
| | | // valueEnum: { |
| | | // '上架中': { text: '上架中' }, |
| | | // '已下架' : { text: '已下架' }, |
| | | // } |
| | | // }, |
| | | { |
| | | title: '操作', |
| | | hideInSearch: true, |
| | |
| | | 删除 |
| | | </Button> |
| | | </Access> |
| | | {/* <Button |
| | | type="link" |
| | | onClick={() => { |
| | | history.push( `/marketing/banner/add?id=${record.id}&detail=true`); |
| | | }} |
| | | > |
| | | 查看详情 |
| | | </Button> |
| | | { |
| | | record.listingStatus == '已下架' && |
| | | <Button |
| | | type="link" |
| | | onClick={() => { |
| | | showDelConfirm(async () => { |
| | | let status = await sendRequest(updateStatus, { id: record.id, listingStatus: '上架中' }) |
| | | if (status) { |
| | | actionRef.current.reload(); |
| | | } |
| | | }, '确认上架所选信息吗?'); |
| | | }} |
| | | > |
| | | 上架 |
| | | </Button> |
| | | } |
| | | { |
| | | record.listingStatus == '上架中' && |
| | | <Button |
| | | type="link" |
| | | onClick={async () => { |
| | | showDelConfirm(async () => { |
| | | let status = await sendRequest(updateStatus, { id: record.id, listingStatus: '已下架' }) |
| | | if (status) { |
| | | actionRef.current.reload(); |
| | | } |
| | | }, '确认下架所选信息吗?'); |
| | | }} |
| | | > |
| | | 下架 |
| | | </Button> |
| | | } */} |
| | | </Space > |
| | | ); |
| | | }, |
| | |
| | | defaultPageSize: 10, |
| | | }} |
| | | request={(params) => { |
| | | params.bannerType = Number(params.bannerType) |
| | | return buildProTableDataSource(getList, params) |
| | | }} |
| | | toolBarRender={(action, selectRows) => [ |
| | |
| | | <Button |
| | | type="primary" |
| | | onClick={() => { |
| | | history.push({ |
| | | pathname: `/marketing/banner/add`, |
| | | }); |
| | | addViewRef.current.refreshData({}); |
| | | handleModalVisible(true); |
| | | }} |
| | | > |
| | | 添加 |
| | |
| | | </Space> |
| | | ]} |
| | | /> |
| | | <AddAndEdit |
| | | ref={addViewRef} |
| | | visible={modalVisible} |
| | | onCancel={() => handleModalVisible(false)} |
| | | onSave={async (fileds) => { |
| | | const success = await sendRequest(add, fileds); |
| | | if (success) { |
| | | handleModalVisible(false); |
| | | actionRef.current.reload(); |
| | | } |
| | | }} |
| | | onUpdate={async (fileds) => { |
| | | const success = await sendRequest(Edit, fileds); |
| | | if (success) { |
| | | handleModalVisible(false); |
| | | actionRef.current.reload(); |
| | | } |
| | | }} |
| | | /> |
| | | </PageContainer> |
| | | </div>; |
| | | }; |