// 菜单管理 import { PageContainer } from '@ant-design/pro-layout'; import type { ActionType, ProColumns } from '@jetlinks/pro-table'; import ProTable from '@jetlinks/pro-table'; import { useRef, useState } from 'react'; import { useIntl } from '@@/plugin-locale/localeExports'; import { Button, message, Tooltip } from 'antd'; import { DeleteOutlined, PlusCircleOutlined, PlusOutlined, SearchOutlined, } from '@ant-design/icons'; import { observer } from '@formily/react'; import { model } from '@formily/reactive'; import { useHistory } from 'umi'; import SearchComponent from '@/components/SearchComponent'; import Service from './service'; import type { MenuItem } from './typing'; import moment from 'moment'; import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu'; import { PermissionButton } from '@/components'; export const service = new Service('menu'); type ModelType = { visible: boolean; current: Partial; parentId: string | undefined; }; export const State = model({ visible: false, current: {}, parentId: undefined, }); export default observer(() => { const actionRef = useRef(); const intl = useIntl(); const [param, setParam] = useState({}); const history = useHistory(); const { permission } = PermissionButton.usePermission('system/Menu'); const deleteItem = async (id: string) => { const response: any = await service.remove(id); if (response.status === 200) { message.success( intl.formatMessage({ id: 'pages.data.option.success', defaultMessage: '操作成功!', }), ); } actionRef.current?.reload(); }; /** * 跳转详情页 * @param id * @param pId * @param basePath */ const pageJump = (id?: string, pId?: string, basePath?: string) => { // 跳转详情 history.push( `${getMenuPathByParams(MENUS_CODE['system/Menu/Detail'], id)}?pId=${pId || ''}&basePath=${ basePath || '' }`, ); }; const columns: ProColumns[] = [ { title: intl.formatMessage({ id: 'page.system.menu.encoding', defaultMessage: '编码', }), width: 300, dataIndex: 'code', }, { title: intl.formatMessage({ id: 'page.system.menu.name', defaultMessage: '名称', }), width: 220, dataIndex: 'name', }, { title: intl.formatMessage({ id: 'page.system.menu.url', defaultMessage: '页面地址', }), dataIndex: 'url', }, { title: intl.formatMessage({ id: 'page.system.menu.sort', defaultMessage: '排序', }), width: 80, dataIndex: 'sortIndex', valueType: 'digit', }, { title: intl.formatMessage({ id: 'page.system.menu.describe', defaultMessage: '说明', }), width: 200, dataIndex: 'describe', hideInSearch: true, }, { title: intl.formatMessage({ id: 'pages.table.createTime', defaultMessage: '创建时间', }), width: 180, valueType: 'dateTime', dataIndex: 'createTime', render: (_, record) => { return record.createTime ? moment(record.createTime).format('YYYY-MM-DD HH:mm:ss') : '-'; }, }, { title: intl.formatMessage({ id: 'pages.data.option', defaultMessage: '操作', }), valueType: 'option', width: 240, render: (_, record) => [ , { State.current = { parentId: record.id, }; // State.visible = true; pageJump('', record.id, record.url); }} > , , ], }, ]; /** * table 查询参数 * @param data */ const searchFn = (data: any) => { setParam(data); }; // const modalCancel = () => { // State.current = {}; // State.visible = false; // form.resetFields(); // }; // const saveData = async () => { // const formData = await form.validateFields(); // if (formData) { // const _data = { // ...formData, // parentId: State.current.parentId, // }; // const response: any = await service.save(_data); // if (response.status === 200) { // message.success('操作成功!'); // modalCancel(); // pageJump(response.result.id); // } else { // message.error('操作成功!'); // } // } // }; return ( { // // 重置分页及搜索参数 // actionRef.current?.reset?.(); // searchFn({}); // }} /> columns={columns} actionRef={actionRef} rowKey="id" pagination={false} search={false} params={param} request={async (params) => { const response = await service.queryMenuThree({ ...params, paging: false }); return { code: response.message, result: { data: response.result, pageIndex: 0, pageSize: 0, total: 0, }, status: response.status, }; }} headerTitle={ { pageJump(); }} key="button" icon={} type="primary" > {intl.formatMessage({ id: 'pages.data.option.add', defaultMessage: '新增', })} } /> {/**/} {/*
*/} {/* ?]+$/,*/} {/* message: '请输入英文+数字+特殊字符(`!@#$%^&*()_+-={}|\\][;\':",./<>?)',*/} {/* },*/} {/* ]}*/} {/* >*/} {/* */} {/* */} {/* */} {/* */} {/* */} {/* */} {/**/}
); });