index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { ActionType } from "@ant-design/pro-components"
  2. import { columns } from "./tableConfig"
  3. import { useAjax } from "@/Hook/useAjax"
  4. import { useRef, useState } from "react"
  5. import { Button, Modal } from "antd"
  6. import { shelfLisOfPage } from "@/services/miniApp/miniAppUser"
  7. import { useModel } from "@umijs/max"
  8. import MyProTable from "@/components/MyProTable"
  9. type Props={
  10. data: {
  11. id: number
  12. }
  13. }
  14. const Page: React.FC<Props> = (props) => {
  15. const {initialState} = useModel('@@initialState')
  16. const [open, setOpen] = useState(false)
  17. const actionRef = useRef<ActionType>();
  18. let getList = useAjax((params) => shelfLisOfPage(params), { type: 'table' })
  19. return <>
  20. <Button
  21. size="small"
  22. type="link"
  23. onClick={()=>{setOpen(true)}}
  24. >书架列表</Button>
  25. <Modal
  26. open={open}
  27. footer={false}
  28. onCancel={()=>{setOpen(false)}}
  29. title={"书架列表"}
  30. width={"50%"}
  31. destroyOnClose
  32. >
  33. <MyProTable<any, any>
  34. actionRef={actionRef}
  35. scroll={{ x: true ,y:'50vh'}}
  36. headerTitle={false}
  37. rowKey={(r) => r.id}
  38. search={false}
  39. params={{
  40. appId:initialState?.selectApp?.id,
  41. userId:props.data.id
  42. }}
  43. request={async (params) => {
  44. if (params?.appId) {
  45. return await getList.run(params)
  46. }
  47. }}
  48. columns={columns()}
  49. // bordered
  50. />
  51. </Modal>
  52. </>
  53. }
  54. export default Page