12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import React,{Component} from "react";
- import {message, Select, Spin} from "antd";
- import $ from "jquery/src/ajax";
- class DepartmentList extends Component{
- constructor(props) {
- super(props);
- this.state={
- departmentArr:[],
- }
- }
- componentDidMount() {
- this.departmentList();
- }
- departmentList() {
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/organization/selectSuperId",
- data: {},
- success: function (data) {
- let thedata = data.data;
- let theArr = [];
- if (!thedata) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- }
- } else {
- thedata.map(function (item, index) {
- theArr.push({
- key: index,
- name: item.name,
- id: item.id
- });
- });
- }
- this.setState({
- departmentArr: theArr
- });
- }.bind(this)
- }).always(
- function () {
- }.bind(this)
- );
- }
- render() {
- return(
- <Select
- placeholder="订单部门"
- style={{ width: 200, marginRight: 10 }}
- value={this.props.value}
- onChange={e => {
- this.props.onChange(e);
- }}
- >
- {this.state.departmentArr.map(function (item) {
- return <Select.Option key={item.id}>{item.name}</Select.Option>;
- })}
- </Select>
- )
- }
- }
- export default DepartmentList;
|