index.js 888 B

12345678910111213141516171819202122232425262728293031
  1. import { Select } from "antd";
  2. import { connect } from "dva";
  3. import router from 'umi/router';
  4. import { webSiteContactRelation } from "@/utils/utils"
  5. const SiteSelector = ({ siteList, currentSite, dispatch }) => {
  6. const handleChange = (value) => {
  7. dispatch({ type: "global/setCurrentSite", payload: value });
  8. dispatch({ type: "global/setCurrentContactType", payload: webSiteContactRelation[value] });
  9. };
  10. return (
  11. siteList.length ? (
  12. <Select
  13. value={currentSite}
  14. style={{ width: 150 }}
  15. onChange={handleChange}
  16. >
  17. {siteList.map((site) => (
  18. <Select.Option key={site.name} value={site.value}>
  19. {site.title}
  20. </Select.Option>
  21. ))}
  22. </Select>
  23. ) : null
  24. );
  25. };
  26. export default connect(({ global }) => ({
  27. siteList: global.siteList,
  28. currentSite: global.currentSite,
  29. }))(SiteSelector);