import React, { Component } from "react";
import { Select, } from "antd";

/**
 * 驳回位置选择
 */

class SelectReject extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selValue: 0,
      opList: [],
      // 0 退单退款
      theArr0: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 3, lable: "技术员", },
        { value: 4, lable: "技术经理", },
        { value: 5, lable: "技术总监", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁", },
        { value: 9, lable: "董事长", },
      ],
      // 1 项目&金额
      theArr1: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 3, lable: "技术员", },
        { value: 4, lable: "技术经理", },
        { value: 5, lable: "技术总监", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁审核", },
      ],
      // 2 仅项目
      theArr2: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 3, lable: "技术员", },
        { value: 4, lable: "技术经理", },
        { value: 5, lable: "技术总监", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁", },
      ],
      // 3 仅金额
      theArr3: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 5, lable: "技术总监", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁", },
      ],
      // 4 重报
      theArr4: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 3, lable: "技术员", },
        { value: 4, lable: "技术经理", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁", },
      ],
      // 5 赠送
      theArr5: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 6, lable: "财务专员", },
        { value: 8, lable: "总裁", },
      ],
      // 6 退单不退款
      theArr6: [
        { value: 0, lable: "营销员", },
        { value: 1, lable: "营销经理", },
        { value: 2, lable: "营销管理员", },
        { value: 3, lable: "技术员", },
        { value: 4, lable: "技术经理", },
        { value: 5, lable: "技术总监", },
        { value: 6, lable: "财务专员", },
        { value: 7, lable: "财务总监", },
        { value: 8, lable: "总裁", },
      ],
      // 7 仅变更合同
      theArr7: [
        { value: 0, lable: "营销员发起", },
        { value: 2, lable: "营销管理员审核", },
      ],
    };
    this.onChange = this.onChange.bind(this);
  }


  componentDidMount() {

  }

  componentWillUnmount() {

  }

  componentWillReceiveProps(nextProps) {
    const { theArr0, theArr1, theArr2, theArr3, theArr4, theArr5, theArr6, theArr7 } = this.state
    const { type } = this.props
    this.setState({
      opList: type == 0
        ? theArr0 : type == 1
          ? theArr1 : type == 2
            ? theArr2 : type == 3
              ? theArr3 : type == 4
                ? theArr4 : type == 5
                  ? theArr5 : type == 6
                    ? theArr6 : type == 7 && theArr7
    })
  }


  onChange(e) {
    const { onSelect } = this.props
    this.setState({
      selValue: e
    })
    onSelect(e)
  }

  render() {
    const { selValue, opList } = this.state
    const { processState } = this.props
    return (
      opList.length > 0 &&
      <Select
        value={selValue}
        style={{ width: 120 }}
        onChange={this.onChange}
      >
        {
          opList.map(item =>
            <Option
              value={item.value}
              key={item.value}
              style={{ display: processState > item.value ? "block" : "none", }}
            >{item.lable}</Option>
          )
        }
      </Select>
    );
  }
}

export default SelectReject;