index.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React,{Component} from "react";
  2. import {message, Select, Spin} from "antd";
  3. import $ from "jquery/src/ajax";
  4. class DepartmentList extends Component{
  5. constructor(props) {
  6. super(props);
  7. this.state={
  8. departmentArr:[],
  9. }
  10. }
  11. componentDidMount() {
  12. this.departmentList();
  13. }
  14. departmentList() {
  15. $.ajax({
  16. method: "get",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  20. data: {},
  21. success: function (data) {
  22. let thedata = data.data;
  23. let theArr = [];
  24. if (!thedata) {
  25. if (data.error && data.error.length) {
  26. message.warning(data.error[0].message);
  27. }
  28. } else {
  29. thedata.map(function (item, index) {
  30. theArr.push({
  31. key: index,
  32. name: item.name,
  33. id: item.id
  34. });
  35. });
  36. }
  37. this.setState({
  38. departmentArr: theArr
  39. });
  40. }.bind(this)
  41. }).always(
  42. function () {
  43. }.bind(this)
  44. );
  45. }
  46. render() {
  47. return(
  48. <Select
  49. placeholder="订单部门"
  50. style={{ width: 200, marginRight: 10 }}
  51. value={this.props.value}
  52. onChange={e => {
  53. this.props.onChange(e);
  54. }}
  55. >
  56. {this.state.departmentArr.map(function (item) {
  57. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  58. })}
  59. </Select>
  60. )
  61. }
  62. }
  63. export default DepartmentList;