ConsultantPicker.jsx 629B

1234567891011121314151617181920212223242526272829
  1. import React, { useEffect, useState } from 'react'
  2. import { getCardList } from '@/services/card'
  3. import Picker from '@/components/Picker'
  4. export default (props) => {
  5. const { buildingId } = props
  6. const [dicts, setDicts] = useState([])
  7. useEffect(() => {
  8. if (buildingId) {
  9. const params = {
  10. pageNumber: 1,
  11. pageSize: 50,
  12. buildingId,
  13. }
  14. getCardList(params).then((res) => {
  15. const { records } = res
  16. setDicts(records || [])
  17. })
  18. } else {
  19. setDicts([])
  20. }
  21. }, [buildingId])
  22. return (
  23. <Picker kv={['name', 'id']} dicts={dicts} {...props} />
  24. )
  25. }