import { DeleteOutlined, ExportOutlined, PlusOutlined, } from '@ant-design/icons'; import { ProColumns, ActionType } from '@ant-design/pro-table'; import { useRequest } from 'ahooks'; import { Button, FormInstance, Modal, Space, Typography } from 'antd'; import React, { useRef, useState } from 'react'; import Truly from '../../components/Truly'; import { OPTIONS } from '../../constants'; import { getAppSelections } from '../../services'; import { isFalse, isTrue } from '../../utils/auth'; import EditForm from './EditForm'; import BaseTable from '../../components/BaseTable'; import { ConfigFields, delApi, exportExcelApi, getListApi } from './services'; const Page: React.FC = () => { const formRef = useRef>(); const actionRef = useRef(); const [query, setQuery] = useState(); const [selectRows, setSelectRows] = useState([]); const { data: appList } = useRequest(getAppSelections); const onDelete = (record: ConfigFields) => { Modal.confirm({ title: '操作提示', content: `是否确认删除参数名称为"${record.configName}"的数据项?`, maskClosable: true, onOk: async () => { await delApi([record.configId]); actionRef.current?.reload(); }, okText: '确定', cancelText: '取消', }); }; const onBatchDelete = () => { Modal.confirm({ title: '操作提示', content: `是否确认批量删除操作?只会删除系统内置为"否"的数据项。`, maskClosable: true, onOk: async () => { const keys = selectRows .filter((item) => item.configType === 'N') .map((item) => item.configId); await delApi(keys); actionRef.current?.reload(); }, okText: '确定', cancelText: '取消', }); }; const onExport = async () => { Modal.confirm({ title: '操作提示', content: '是否确认导出全部数据?', maskClosable: true, onOk: async () => { await exportExcelApi({ ...query }); }, okText: '确定', cancelText: '取消', }); }; const columns: ProColumns[] = [ { title: '参数主键', dataIndex: 'configId', hideInSearch: true, ellipsis: true, }, { title: '应用名称', dataIndex: 'appId', valueType: 'select', hideInSearch: true, fieldProps: { options: appList || [], }, ellipsis: true, }, { title: '参数名称', dataIndex: 'configName', ellipsis: true, }, { title: '参数键名', dataIndex: 'configKey', ellipsis: true, }, { title: '参数键值', dataIndex: 'configValue', hideInSearch: true, ellipsis: true, render(text) { return {text}; }, }, { title: '系统内置', dataIndex: 'configType', valueType: 'select', fieldProps: { options: OPTIONS.OPTIONS_CONFIG, }, ellipsis: true, }, { title: '备注', dataIndex: 'remark', hideInSearch: true, ellipsis: true, }, { title: '创建时间', key: 'showTime', dataIndex: 'createTime', valueType: 'dateTime', hideInSearch: true, ellipsis: true, }, { title: '创建时间', dataIndex: 'createTime', valueType: 'dateRange', hideInTable: true, search: { transform: (value) => { return { beginTime: value[0], endTime: value[1], }; }, }, }, { title: '操作', dataIndex: 'option', valueType: 'option', width: 120, fixed: 'right', hideInTable: isFalse( 'sysSetting:config:update', 'sysSetting:config:delete', ), render: (_, record) => ( 编辑} onOk={() => { actionRef.current?.reload(); }} > ), }, ]; return ( rowKey={'configId'} formRef={formRef} actionRef={actionRef} rowSelection={{ onChange: (selectKeys, selectRows) => setSelectRows(selectRows), }} toolBarRender={() => [ }> 新增 } onOk={() => { actionRef.current?.reload(); }} > , , , ]} columns={columns} request={async (params) => { const { current: pageNum, pageSize, ...rest } = params; const { total = 0, data = [] } = await getListApi({ ...rest, pageNum, pageSize, }); setQuery(rest); actionRef.current?.clearSelected?.(); return { data, total, }; }} /> ); }; export default Page;