index.jsx 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { useMemo, useRef, useCallback, useState } from 'react'
  2. import {Button} from 'antd'
  3. import apis from '@/services/apis'
  4. import AuthButton from '@/components/AuthButton';
  5. import QueryTable from '@/components/QueryTable'
  6. import getTableColumns from './tableColumns'
  7. import { router } from 'umi';
  8. import getSearchFields from './searchFields'//searchbox
  9. export default (props) => {
  10. const ref = useRef()
  11. const [page, setPage] = useState({current: 1, pageSize: 10})
  12. const toEdit = useCallback((row) => {
  13. //
  14. router.push({
  15. pathname: '/building/Developers/Edit',
  16. query: {
  17. id: row?.id || undefined,
  18. },
  19. });
  20. }, [])
  21. const onDelete = useCallback((row) => {}, [])//格式
  22. const searchFields = useMemo(getSearchFields, [])//搜索框
  23. const tableColumns = useMemo(() => {
  24. return getTableColumns({
  25. page,//可无
  26. onEdit:(e)=>toEdit(e),
  27. onDelete,
  28. })
  29. }, [page])
  30. const actionRender = () => {
  31. return (
  32. //name 名字错误
  33. <AuthButton name="admin.tdBuildingType.add" noRight={null}>
  34. <Button type="primary" icon="plus" onClick={toEdit} >
  35. 新增
  36. </Button>
  37. </AuthButton>
  38. );
  39. };
  40. return (
  41. <>
  42. <QueryTable
  43. //搜索组件
  44. rowKey="buildingId"
  45. api={apis.building.getList}
  46. columns={tableColumns}
  47. actionRender={actionRender}
  48. searchFields={searchFields}
  49. />
  50. </>
  51. )
  52. }