import React from 'react';
import router from 'umi/router';
import { Form, Select, Button } from 'antd';

const { Option } = Select;

function TypeSelect(props) {
  const { type, processId, projectId, name } = props;

  const onChangeType = value => {
    switch (value) {
      case 1:
        router.replace(
          `/unity/energy-consumption/detail/${projectId}/${processId}?showType=1&name=${name}`
        );
        break;
      case 2:
        router.replace(`/unity/Chem-cost-mng/${projectId}?processId=${processId}&name=${name}`);
        break;
      case 3:
        router.replace(`/unity/water-amt-manage/${projectId}?processId=${processId}&name=${name}`);
        break;
    }
  };

  return (
    <Form layout="inline" style={{ margin: '20px 0' }}>
      <Form.Item label="成本类型">
        <Select style={{ width: 200 }} value={type} onChange={onChangeType}>
          <Option value={1}>能耗</Option>
          <Option value={2}>药耗</Option>
          <Option value={3}>水量</Option>
        </Select>
      </Form.Item>
      {/* <Button type="primary" style={{ float: 'right' }} onClick={() => router.goBack()}>
        返回
      </Button> */}
    </Form>
  );
}

export default TypeSelect;
