| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | |
| | | import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | import { TextFilter, SelectFilter } from '@/components/TableSearch' |
| | | import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' |
| | | |
| | | const handleSave = async (val) => { |
| | | const hide = message.loading('正在添加'); |
| | | try { |
| | | const resp = await Http.doPost('api/role/save', val); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('添加成功'); |
| | | return true; |
| | |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('添加失败请重试!'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | |
| | | const hide = message.loading('正在更新'); |
| | | try { |
| | | const resp = await Http.doPost('api/role/update', val); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('更新成功'); |
| | | return true; |
| | |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('配置失败请重试!'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | |
| | | const hide = message.loading('正在删除'); |
| | | try { |
| | | const resp = await Http.doPost('api/role/remove/' + rows.map((row) => row.id).join(',')); |
| | | hide(); |
| | | if (resp.code === 200) { |
| | | message.success('删除成功'); |
| | | return true; |
| | |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('删除失败,请重试'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleExport = async () => { |
| | | const hide = message.loading('正在导出'); |
| | | try { |
| | | await Http.doPost('api/role/export'); |
| | | hide(); |
| | | const resp = await Http.doPostBlob('api/role/export'); |
| | | const blob = new Blob([resp], { type: 'application/vnd.ms-excel' }); |
| | | window.location.href = window.URL.createObjectURL(blob); |
| | | message.success('导出成功'); |
| | | return true; |
| | | } catch (error) { |
| | | hide(); |
| | | message.error('导出失败,请重试'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | |
| | | const [modalVisible, setModalVisible] = useState(false); |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | const [searchParam, setSearchParam] = useState({}); |
| | | |
| | | const intl = useIntl(); |
| | | |
| | | useEffect(() => { |
| | | |
| | |
| | | />, |
| | | }, |
| | | { |
| | | title: '公司', |
| | | title: '机构', |
| | | dataIndex: 'hostId$', |
| | | valueType: 'text', |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='hostId' |
| | | major='host' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '状态', |
| | |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | />, |
| | | |
| | | }, |
| | | { |
| | | title: '修改时间', |
| | | dataIndex: 'updateTime$', |
| | | valueType: 'text', |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='updateTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: '220px', |
| | | width: 140, |
| | | valueType: 'option', |
| | | render: (_, record) => [ |
| | | <Button |
| | |
| | | columns={columns} |
| | | cardBordered |
| | | dateFormatter="string" |
| | | pagination={{ pageSize: 20 }} |
| | | search={false} |
| | | toolbar={{ |
| | | multipleLine: true, |
| | | search: { |
| | | onSearch: (value) => { |
| | | setSearchParam(prevState => ({ |
| | |
| | | <FooterToolbar |
| | | extra={ |
| | | <div> |
| | | <FormattedMessage id="pages.searchTable.chosen" defaultMessage="已选择" /> |
| | | 已选择 |
| | | <a style={{ fontWeight: 600 }}>{selectedRows.length}</a> |
| | | <FormattedMessage id="pages.searchTable.item" defaultMessage="项" /> |
| | | 项 |
| | | </div> |
| | | } |
| | | > |