| | |
| | | import { useRef, useState } from 'react'; |
| | | import { Access, history, useAccess } from 'umi'; |
| | | import AddAndEdit from './components/index'; |
| | | import { getList, updateStatus, deleteBanner } from './service' |
| | | import { getList, updateStatus, deleteBanner, add, Edit } from './service' |
| | | const Banner = () => { |
| | | |
| | | const actionRef = useRef(); |
| | |
| | | <Button |
| | | type="link" |
| | | onClick={() => { |
| | | history.push(`/marketing/banner/add?id=${record.id}&edit=true`); |
| | | addViewRef.current.clean(); |
| | | addViewRef.current.refreshData({ ...record, type: 'edit' }); |
| | | handleModalVisible(true); |
| | | }} |
| | | > |
| | | 编辑 |
| | |
| | | ] |
| | | |
| | | return <div> |
| | | <PageContainer title='banner管理'> |
| | | <PageContainer title='banner管理' header={{ |
| | | breadcrumb: {}, |
| | | }}> |
| | | <ProTable |
| | | rowKey='id' |
| | | actionRef={actionRef} |
| | |
| | | <Button |
| | | type="primary" |
| | | onClick={() => { |
| | | addViewRef.current.clean(); |
| | | addViewRef.current.refreshData({}); |
| | | handleModalVisible(true); |
| | | }} |
| | |
| | | ]} |
| | | /> |
| | | <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(); |
| | | } |
| | | }} |
| | | /> |
| | | 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>; |
| | | }; |