| | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import { Button, message, Modal } from 'antd'; |
| | | import { FooterToolbar, PageContainer, ProTable } from '@ant-design/pro-components'; |
| | | import { |
| | | FooterToolbar, PageContainer, ProTable, LightFilter, |
| | | ProFormDatePicker, |
| | | } from '@ant-design/pro-components'; |
| | | import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [modalVisible, setModalVisible] = useState(false); |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | const [searchParam, setSearchParam] = useState({}); |
| | | |
| | | const intl = useIntl(); |
| | | |
| | |
| | | |
| | | const columns = [ |
| | | { |
| | | title: 'No', |
| | | dataIndex: 'index', |
| | | valueType: 'indexBorder', |
| | | width: 48, |
| | | }, |
| | | { |
| | | title: '姓名', |
| | | dataIndex: 'name', |
| | | valueType: 'text', |
| | | copyable: true, |
| | | }, |
| | | { |
| | | title: '标识', |
| | |
| | | <PageContainer> |
| | | <div style={{ width: '100%', float: 'right' }}> |
| | | <ProTable |
| | | headerTitle={intl.formatMessage({ |
| | | id: 'pages.searchTable.title', |
| | | defaultMessage: '信息', |
| | | })} |
| | | cardBordered |
| | | key="role" |
| | | rowKey="id" |
| | | actionRef={actionRef} |
| | | formRef={formTableRef} |
| | | rowKey="id" |
| | | key="role" |
| | | search={{ |
| | | labelWidth: 120, |
| | | columns={columns} |
| | | cardBordered |
| | | dateFormatter="string" |
| | | search={false} |
| | | toolbar={{ |
| | | search: { |
| | | onSearch: (value) => { |
| | | setSearchParam(prevState => ({ |
| | | ...prevState, |
| | | condition: value |
| | | })); |
| | | actionRef.current?.reload(); |
| | | }, |
| | | }, |
| | | filter: ( |
| | | <LightFilter> |
| | | <ProFormDatePicker name="startdate" label="响应日期" /> |
| | | </LightFilter> |
| | | ), |
| | | actions: [ |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | 添加 |
| | | </Button>, |
| | | <Button |
| | | key="export" |
| | | onClick={async () => { |
| | | handleExport(); |
| | | }} |
| | | > |
| | | <ExportOutlined /> |
| | | 导出 |
| | | </Button>, |
| | | ], |
| | | }} |
| | | toolBarRender={() => [ |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | 添加 |
| | | </Button>, |
| | | <Button |
| | | key="export" |
| | | onClick={async () => { |
| | | handleExport(); |
| | | }} |
| | | > |
| | | <ExportOutlined /> |
| | | 导出 |
| | | </Button>, |
| | | ]} |
| | | request={(params) => |
| | | Http.doPostPromise('/api/role/page', params, (res) => { |
| | | // 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) => { |
| | | console.log({ ...params, ...searchParam }); |
| | | console.log(filter); |
| | | return { |
| | | data: res.data.records, |
| | | total: res.data.total, |
| | |
| | | } |
| | | }) |
| | | } |
| | | columns={columns} |
| | | rowSelection={{ |
| | | onChange: (ids, rows) => { |
| | | setSelectedRows(rows); |
| | | } |
| | | }} |
| | | columnsState={{ |
| | | persistenceKey: 'pro-table-role', |
| | | persistenceType: 'localStorage', |
| | | defaultValue: { |
| | | option: { fixed: 'right', disable: true }, |
| | | }, |
| | | onChange(value) { |
| | | }, |
| | | }} |
| | | /> |
| | | </div> |
| | | |
| | | |
| | | {selectedRows?.length > 0 && ( |
| | | <FooterToolbar |
| | | extra={ |