import React, {Component} from 'react';
import {Select} from 'antd';
import {observer} from 'mobx-react';
import { sites } from '../../libs/ht';

class SiteSelect extends Component {
    constructor(props) {
        super(props);
    }


    render() {
      const { store, mode, value, onChange, show_all, ...extProps } = this.props;
        return (
            <div>
                <Select
                    mode={mode || store?.site_select_mode || null}
                    style={{width: '100%'}}
                    placeholder="选择来源"
                    defaultValue={value || store?.webcode || 'ALL'}
                    onChange={(value) => {
                      if (typeof onChange === 'function') {
                        onChange(value);
                      }
                      store?.handleChange_webcode(value);
                    }}
                    {...extProps}
                >
                    {show_all===true ? <Select.Option key="1" value="ALL">所有来源</Select.Option> : ''}
                    {sites.map(ele => <Select.Option key={ele.key} value={ele.code}>{ele.label}</Select.Option>)}
                </Select>
            </div>
        );
    }
}

export default observer(SiteSelect);

