| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import { Button, message, Modal, Input, Space } from 'antd'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | | ProTable, |
| | | LightFilter, |
| | | ProFormDatePicker, |
| | | } from '@ant-design/pro-components'; |
| | | import { PlusOutlined, ExportOutlined, SearchOutlined } from '@ant-design/icons'; |
| | | import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | |
| | | 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(() => { |
| | | |
| | |
| | | dataIndex: 'name', |
| | | valueType: 'text', |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='name' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '标识', |
| | | dataIndex: 'code', |
| | | valueType: 'text', |
| | | filterDropdown: (props) => <TextFilter |
| | | name='code' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '机构', |
| | | dataIndex: 'hostId$', |
| | | valueType: 'text', |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='hostId' |
| | | major='host' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '状态', |
| | | dataIndex: 'status$', |
| | | valueType: 'text', |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='status' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '正常', value: 1 }, |
| | | { 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 => ({ |
| | |
| | | }, |
| | | }, |
| | | filter: ( |
| | | <LightFilter> |
| | | <ProFormDatePicker name="startdate" label="响应日期" /> |
| | | <LightFilter |
| | | onValuesChange={(val) => { |
| | | }} |
| | | > |
| | | </LightFilter> |
| | | ), |
| | | actions: [ |
| | |
| | | </Button>, |
| | | ], |
| | | }} |
| | | // toolBarRender={() => [ |
| | | // <Button |
| | | // type="primary" |
| | | // key="save" |
| | | // onClick={async () => { |
| | | // setModalVisible(true) |
| | | // }} |
| | | // > |
| | | // <PlusOutlined /> |
| | | // 添加 |
| | | // </Button>, |
| | | // <Button |
| | | // key="export" |
| | | // onClick={async () => { |
| | | // handleExport(); |
| | | // }} |
| | | // > |
| | | // <ExportOutlined /> |
| | | // 导出 |
| | | // </Button>, |
| | | // ]} |
| | | request={(params, sorter, filter) => |
| | | Http.doPostPromise('/api/role/page', { ...params, ...searchParam }, (res) => { |
| | | return { |
| | |
| | | <FooterToolbar |
| | | extra={ |
| | | <div> |
| | | <FormattedMessage id="pages.searchTable.chosen" defaultMessage="已选择" /> |
| | | 已选择 |
| | | <a style={{ fontWeight: 600 }}>{selectedRows.length}</a> |
| | | <FormattedMessage id="pages.searchTable.item" defaultMessage="项" /> |
| | | 项 |
| | | </div> |
| | | } |
| | | > |