123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import React, { useMemo, useRef, useCallback, useState } from 'react'
- import {Button} from 'antd'
- import apis from '@/services/apis'
- import AuthButton from '@/components/AuthButton';
- import QueryTable from '@/components/QueryTable'
- import getTableColumns from './tableColumns'
- import { router } from 'umi';
- import getSearchFields from './searchFields'//searchbox
-
- export default (props) => {
- const ref = useRef()
- const [page, setPage] = useState({current: 1, pageSize: 10})
- const toEdit = useCallback((row) => {
- //
- router.push({
- pathname: '/building/Developers/Edit',
- query: {
- id: row?.id || undefined,
- },
- });
- }, [])
-
- const onDelete = useCallback((row) => {}, [])//格式
- const searchFields = useMemo(getSearchFields, [])//搜索框
-
- const tableColumns = useMemo(() => {
- return getTableColumns({
- page,//可无
- onEdit:(e)=>toEdit(e),
- onDelete,
- })
- }, [page])
-
- const actionRender = () => {
- return (
- //name 名字错误
- <AuthButton name="admin.tdBuildingType.add" noRight={null}>
- <Button type="primary" icon="plus" onClick={toEdit} >
- 新增
- </Button>
- </AuthButton>
- );
- };
-
- return (
- <>
- <QueryTable
- //搜索组件
- rowKey="buildingId"
- api={apis.building.getList}
- columns={tableColumns}
- actionRender={actionRender}
- searchFields={searchFields}
- />
- </>
- )
- }
|