index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Select } from "antd";
  2. import { connect } from "dva/index";
  3. import { Component } from "react";
  4. import { businessStateEnum } from "@/utils/utils";
  5. import styles from "./index.less";
  6. @connect(({ store }) => ({
  7. store,
  8. }))
  9. export default class BusinessStateSelector extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. stateList: Object.keys(businessStateEnum).map((key) => ({
  14. name: businessStateEnum[key],
  15. value: key,
  16. })),
  17. currentBusinessState: "",
  18. };
  19. }
  20. handleChange = (value) => {
  21. this.setState({ currentBusinessState: value });
  22. };
  23. componentDidMount() {
  24. // dispatch({
  25. // type: "store/get_business_state",
  26. // callback: (res) => {},
  27. // });
  28. }
  29. render() {
  30. const { stateList, currentBusinessState } = this.state;
  31. return stateList.length ? (
  32. <div className={`${styles.state_warp}`}>
  33. <span className={`${styles.label}`}>经营状态</span>
  34. <Select
  35. value={currentBusinessState}
  36. style={{ width: 150 }}
  37. onChange={this.handleChange}
  38. >
  39. {stateList.map((state) => (
  40. <Select.Option key={state.name} value={state.value}>
  41. {state.name}
  42. </Select.Option>
  43. ))}
  44. </Select>
  45. </div>
  46. ) : null;
  47. }
  48. }