import { PageContainer, ProTable } from '@ant-design/pro-components';
|
import { buildProTableDataSource, sendRequest, showDelConfirm, showDelConfirm1 } from '@/utils/antdUtils';
|
import { Button, message, Space, Cascader } from 'antd';
|
import { useRef, useState, useEffect } from 'react';
|
import { Access, history, useAccess } from 'umi';
|
import AddAndEdit from './components/index';
|
import ImportExcell from './components/export';
|
import { getList, deleteBanner, freeze, regionTree, enterList } from './service'
|
import { exportExcell } from '@/utils/utils'
|
const Banner = () => {
|
|
const actionRef = useRef();
|
const access = useAccess();
|
const addViewRef = useRef();
|
const modalExportRef = 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: 'gender',
|
valueEnum: {
|
1: { text: '男' },
|
0: { text: '女' },
|
}
|
},
|
{
|
title: '所在社区',
|
dataIndex: 'community',
|
renderFormItem: () => {
|
return (
|
<Cascader
|
options={items}
|
fieldNames={{ value: 'id', label: 'name' }}
|
placeholder="请选择"
|
displayRender={(label) => label[label.length - 1]}
|
// changeOnSelect={true}
|
/>
|
);
|
},
|
render: (text, record) => {
|
return record.community
|
}
|
},
|
{
|
title: '服务对象',
|
dataIndex: 'serviceTarget',
|
render: (text, record) => {
|
return record.serviceTarget
|
}
|
},
|
{
|
title: '所在党组织',
|
dataIndex: 'partyOrganization',
|
render: (text, record) => {
|
return record.partyOrganization
|
}
|
},
|
{
|
title: '创建时间',
|
dataIndex: 'createTime',
|
sorter: true,
|
hideInSearch: true,
|
},
|
{
|
title: '更新时间',
|
dataIndex: 'updateTime',
|
sorter: true,
|
hideInSearch: true,
|
},
|
{
|
title: '状态',
|
dataIndex: 'freezeStatus',
|
valueEnum: {
|
// 'all': { text: '全部' },
|
'1': { text: '已冻结' },
|
'0': { text: '正常中' },
|
}
|
},
|
{
|
title: '身份证号',
|
dataIndex: 'idNumber',
|
},
|
{
|
title: '操作',
|
hideInSearch: true,
|
render: (text, record) => {
|
return (
|
<Space>
|
<Access accessible={access['/party_member/edit']}>
|
<Button
|
type="link"
|
onClick={() => {
|
history.push(`/party/manage/add?type=edit&id=${record.id}`)
|
}}
|
>
|
编辑
|
</Button>
|
</Access>
|
<Access accessible={access['/party_member/del']}>
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm(async () => {
|
let status = await sendRequest(deleteBanner, { id: record.id })
|
if (status) {
|
actionRef.current.reload();
|
}
|
}, '确认删除所选信息吗?');
|
}}
|
>
|
删除
|
</Button>
|
</Access>
|
<Access accessible={access['/party_member/detail']}>
|
<Button
|
type="link"
|
onClick={() => {
|
history.push(`/party/manage/add?detail=true&id=${record.id}`)
|
}}
|
>
|
查看详情
|
</Button>
|
</Access>
|
<Access accessible={access['/party_member/freeze']}>
|
{record.freezeStatus == 0 && (
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm1(async () => {
|
let status = await sendRequest(freeze, { id: record.id })
|
if (status) {
|
actionRef.current.reload();
|
}
|
}, '确认冻结该党员信息吗?', '冻结', '', '确认冻结该党员信息吗?');
|
}}
|
>
|
冻结
|
</Button>
|
)}
|
|
</Access>
|
<Access accessible={access['/party_member/freeze']}>
|
{record.freezeStatus == 1 && (
|
<Button
|
type="link"
|
onClick={() => {
|
showDelConfirm1(async () => {
|
let status = await sendRequest(freeze, { id: record.id })
|
if (status) {
|
actionRef.current.reload();
|
}
|
}, '确认解冻该党员信息吗?', '解冻', '', '确认解冻该党员信息吗?');
|
}}
|
>
|
解冻
|
</Button>
|
)}
|
|
</Access>
|
</Space >
|
);
|
},
|
},
|
]
|
useEffect(() => {
|
regionTree({}).then(res => {
|
setItems(() => res.data)
|
})
|
}, [])
|
|
return <div>
|
<PageContainer title='党员管理' header={{
|
breadcrumb: {},
|
}}>
|
<ProTable
|
rowKey='id'
|
actionRef={actionRef}
|
columns={columns}
|
pagination={{
|
showSizeChanger: true,
|
showQuickJumper: true,
|
defaultPageSize: 10,
|
}}
|
request={(params, sorter) => {
|
console.log('weqweqeqwe', sorter);
|
if (sorter.createTime) {
|
params.createTimeSort = sorter.createTime === 'ascend' ? 2 : 1;
|
}
|
if (sorter.updateTime) {
|
params.updateTimeSort = sorter.updateTime === 'ascend' ? 2 : 1;
|
}
|
|
params.communityId = params.community ? params.community[params.community.length - 1] : ''
|
params.auditStatus = 1
|
setExcelParams(() => params)
|
return buildProTableDataSource(getList, params)
|
}}
|
toolBarRender={(action, selectRows) => [
|
<Space>
|
<Access accessible={access['/party_member/add']}>
|
<Button
|
type="primary"
|
onClick={() => {
|
history.push('/party/manage/add?type=add')
|
}}
|
>
|
添加
|
</Button>
|
</Access>
|
<Access accessible={access['/party_member/export']}>
|
<Button
|
type="primary"
|
onClick={() => {
|
exportExcell('党员列表', excelParams, '/api/huacheng-sangeshenbian/party-member/export')
|
}}
|
>
|
导出
|
</Button>
|
</Access>
|
<Access accessible={access['/party_member/import']}>
|
<Button
|
type="primary"
|
onClick={() => {
|
handleModalExport(true)
|
modalExportRef.current.clean()
|
}}
|
>
|
导入
|
</Button>
|
</Access>
|
</Space>
|
]}
|
/>
|
{/* 导入失败弹窗 */}
|
<AddAndEdit
|
ref={addViewRef}
|
visible={modalVisible}
|
onCancel={() => handleModalVisible(false)}
|
onSave={async (fileds) => {
|
handleModalVisible(false);
|
}}
|
onUpdate={async (fileds) => {
|
handleModalVisible(false);
|
}}
|
/>
|
|
<ImportExcell
|
ref={modalExportRef}
|
visible={modalExport}
|
onSave={async (fileds) => {
|
enterList(fileds).then(res => {
|
if (res.code == 200) {
|
if (res.data.length > 0) {
|
message.error('导入失败')
|
handleModalExport(false);
|
handleModalVisible(true)
|
actionRef.current.reload()
|
addViewRef.current.refreshData(res.data)
|
} else {
|
message.success('导入成功')
|
handleModalExport(false);
|
actionRef.current.reload()
|
}
|
}
|
})
|
}}
|
onCancel={() => handleModalExport(false)}
|
/>
|
</PageContainer>
|
</div>;
|
};
|
|
export default Banner;
|