You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dashboard/src/components/search/SiteSelect.jsx

45 lines
1.5 KiB
React

3 years ago
import React, {Component} from 'react';
import {Select} from 'antd';
import {observer} from 'mobx-react';
import { sites } from '../../libs/ht';
3 years ago
class SiteSelect extends Component {
constructor(props) {
super(props);
}
render() {
const { store, mode, value, onChange, show_all, ...extProps } = this.props;
const _mode = mode || store?.group_select_mode || null;
const _show_all = ['tags', 'multiple'].includes(_mode) ? false : show_all;
return (
3 years ago
<div>
<Select
mode={_mode}
style={{width: '100%'}}
placeholder="选择来源"
defaultValue={value || store?.webcode || undefined }
onChange={(value) => {
if (typeof onChange === 'function') {
onChange(value);
}
store?.handleChange_webcode(value);
}}
2 years ago
labelInValue={false}
maxTagCount={1}
maxTagPlaceholder={(omittedValues) => ` + ${omittedValues.length} 更多...`}
allowClear={_mode != null}
{...extProps}
3 years ago
>
{_show_all===true ? <Select.Option key="ALL" value="ALL">所有来源</Select.Option> : ''}
{sites.map(ele => <Select.Option key={ele.key} value={ele.code}>{ele.label}</Select.Option>)}
3 years ago
</Select>
</div>
);
}
}
3 years ago
export default observer(SiteSelect);