import { PageContainer, ProTable } from '@ant-design/pro-components';
|
import { buildProTableDataSource, sendRequest, showDelConfirm } from '@/utils/antdUtils';
|
import { Button, message, Space, Cascader } from 'antd';
|
import { useRef, useState } from 'react';
|
import { Access, history, useAccess } from 'umi';
|
import AddAndEdit from './components/index';
|
import ImportExcell from './components/export';
|
import { getList, updateStatus, deleteBanner, add, Edit } from './service'
|
import { exportExcell } from '@/utils/utils'
|
const Banner = () => {
|
|
const actionRef = useRef();
|
const access = useAccess();
|
const addViewRef = useRef();
|
const [modalVisible, handleModalVisible] = useState(false);
|
const [items, setItems] = useState([]);
|
const [excelParams, setExcelParams] = useState({});
|
|
const [modalExport, handleModalExport] = useState(false);
|
|
const columns = [
|
{
|
title: '姓名',
|
dataIndex: 'name'
|
},
|
{
|
title: '性别',
|
hideInSearch: true,
|
dataIndex: 'name'
|
},
|
{
|
title: '所在社区',
|
dataIndex: 'name',
|
renderFormItem: () => {
|
return (
|
<Cascader
|
options={items}
|
fieldNames={{ value: 'key', label: 'name' }}
|
placeholder="请选择"
|
displayRender={(label) => label[label.length - 1]}
|
changeOnSelect={true}
|
/>
|
);
|
},
|
},
|
{
|
title: '服务对象',
|
dataIndex: 'name'
|
},
|
{
|
title: '所在党组织',
|
dataIndex: 'name'
|
},
|
{
|
title: '状态',
|
dataIndex: 'status',
|
valueEnum: {
|
0: { text: '全部' },
|
1: { text: '正常中' },
|
2: { text: '已冻结' },
|
}
|
},
|
{
|
title: '操作',
|
hideInSearch: true,
|
render: (text, record) => {
|
return (
|
<Space>
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/edit']}> */}
|
<Button
|
type="link"
|
onClick={() => {
|
history.push(`/party/manage/add?type=edit&id=${record.id}`)
|
}}
|
>
|
编辑
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm(async () => {
|
// let status = await sendRequest(deleteBanner, record.id)
|
// if (status) {
|
// actionRef.current.reload();
|
// }
|
}, '确认删除所选信息吗?');
|
}}
|
>
|
删除
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
|
<Button
|
type="link"
|
onClick={() => {
|
history.push(`/party/manage/add?detail=true&id=${record.id}`)
|
}}
|
>
|
查看详情
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm(async () => {
|
// let status = await sendRequest(deleteBanner, record.id)
|
// if (status) {
|
// actionRef.current.reload();
|
// }
|
}, '确认冻结该党员信息吗?');
|
}}
|
>
|
冻结
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/del']}> */}
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm(async () => {
|
// let status = await sendRequest(deleteBanner, record.id)
|
// if (status) {
|
// actionRef.current.reload();
|
// }
|
}, '确认解冻该党员信息吗?');
|
}}
|
>
|
解冻
|
</Button>
|
{/* </Access> */}
|
</Space >
|
);
|
},
|
},
|
]
|
|
return <div>
|
<PageContainer title='党员管理' header={{
|
breadcrumb: {},
|
}}>
|
<ProTable
|
rowKey='id'
|
actionRef={actionRef}
|
columns={columns}
|
pagination={{
|
showSizeChanger: true,
|
showQuickJumper: true,
|
defaultPageSize: 10,
|
}}
|
request={(params) => {
|
params.status = (params.status && params.status != 0) ? params.status : '';
|
setExcelParams(() => params)
|
return buildProTableDataSource(getList, params)
|
}}
|
toolBarRender={(action, selectRows) => [
|
<Space>
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
|
<Button
|
type="primary"
|
onClick={() => {
|
history.push('/party/manage/add?type=add')
|
}}
|
>
|
添加
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
|
<Button
|
type="primary"
|
onClick={() => {
|
// exportExcell('党员列表', excelParams, '/promotion/mgt/coupon/receive-detail/export')
|
}}
|
>
|
导出
|
</Button>
|
{/* </Access> */}
|
{/* <Access accessible={access['/work_order_transaction_management/banner_management/add']}> */}
|
<Button
|
type="primary"
|
onClick={() => {
|
// history.push('/party/manage/add?type=add')
|
handleModalExport(true)
|
}}
|
>
|
导入
|
</Button>
|
{/* </Access> */}
|
</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();
|
// }
|
}}
|
/>
|
|
<ImportExcell
|
visible={modalExport}
|
onSave={async (fileds) => {
|
console.log('上传文件数据', fileds);
|
handleModalExport(false);
|
handleModalVisible(true)
|
// const success = await sendRequest(enable, fileds);
|
// if (success) {
|
// handleModalExport(false);
|
|
// // actionRef.current.reload();
|
// // listCheck({ checkType: checktype, }).then(res => {
|
// // console.log('一键导入数据', res)
|
|
// // })
|
// }
|
}}
|
onCancel={() => handleModalExport(false)}
|
/>
|
</PageContainer>
|
</div>;
|
};
|
|
export default Banner;
|