|
|
@ -19,6 +19,7 @@ export default {
|
|
|
|
...inputProps,
|
|
|
|
...inputProps,
|
|
|
|
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
|
|
|
|
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
|
|
|
|
enterButton: PropTypes.any,
|
|
|
|
enterButton: PropTypes.any,
|
|
|
|
|
|
|
|
onSearch: PropTypes.func,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setup() {
|
|
|
|
setup() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -29,13 +30,14 @@ export default {
|
|
|
|
saveInput(node) {
|
|
|
|
saveInput(node) {
|
|
|
|
this.input = node;
|
|
|
|
this.input = node;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onChange(e) {
|
|
|
|
handleChange(e) {
|
|
|
|
if (e && e.target && e.type === 'click') {
|
|
|
|
if (e && e.target && e.type === 'click') {
|
|
|
|
this.$emit('search', e.target.value, e);
|
|
|
|
this.$emit('search', e.target.value, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('update:value', e.target.value);
|
|
|
|
this.$emit('change', e);
|
|
|
|
this.$emit('change', e);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onSearch(e) {
|
|
|
|
handleSearch(e) {
|
|
|
|
if (this.loading || this.disabled) {
|
|
|
|
if (this.loading || this.disabled) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -78,7 +80,7 @@ export default {
|
|
|
|
if (enterButton) return suffix;
|
|
|
|
if (enterButton) return suffix;
|
|
|
|
|
|
|
|
|
|
|
|
const icon = (
|
|
|
|
const icon = (
|
|
|
|
<SearchOutlined class={`${prefixCls}-icon`} key="searchIcon" onClick={this.onSearch} />
|
|
|
|
<SearchOutlined class={`${prefixCls}-icon`} key="searchIcon" onClick={this.handleSearch} />
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (suffix) {
|
|
|
|
if (suffix) {
|
|
|
@ -114,7 +116,7 @@ export default {
|
|
|
|
key: 'enterButton',
|
|
|
|
key: 'enterButton',
|
|
|
|
class: isAntdButton ? btnClassName : '',
|
|
|
|
class: isAntdButton ? btnClassName : '',
|
|
|
|
...(isAntdButton ? { size } : {}),
|
|
|
|
...(isAntdButton ? { size } : {}),
|
|
|
|
onClick: this.onSearch,
|
|
|
|
onClick: this.handleSearch,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
button = (
|
|
|
|
button = (
|
|
|
@ -124,7 +126,7 @@ export default {
|
|
|
|
size={size}
|
|
|
|
size={size}
|
|
|
|
disabled={disabled}
|
|
|
|
disabled={disabled}
|
|
|
|
key="enterButton"
|
|
|
|
key="enterButton"
|
|
|
|
onClick={this.onSearch}
|
|
|
|
onClick={this.handleSearch}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{enterButton === true || enterButton === '' ? <SearchOutlined /> : enterButton}
|
|
|
|
{enterButton === true || enterButton === '' ? <SearchOutlined /> : enterButton}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
@ -149,6 +151,7 @@ export default {
|
|
|
|
delete restProps.loading;
|
|
|
|
delete restProps.loading;
|
|
|
|
delete restProps.enterButton;
|
|
|
|
delete restProps.enterButton;
|
|
|
|
delete restProps.addonBefore;
|
|
|
|
delete restProps.addonBefore;
|
|
|
|
|
|
|
|
delete restProps['onUpdate:value'];
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const prefixCls = getPrefixCls('input-search', customizePrefixCls);
|
|
|
|
const prefixCls = getPrefixCls('input-search', customizePrefixCls);
|
|
|
|
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
|
|
|
|
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
|
|
|
@ -175,8 +178,8 @@ export default {
|
|
|
|
addonAfter: this.renderAddonAfter(prefixCls),
|
|
|
|
addonAfter: this.renderAddonAfter(prefixCls),
|
|
|
|
addonBefore,
|
|
|
|
addonBefore,
|
|
|
|
class: inputClassName,
|
|
|
|
class: inputClassName,
|
|
|
|
onPressEnter: this.onSearch,
|
|
|
|
onPressEnter: this.handleSearch,
|
|
|
|
onChange: this.onChange,
|
|
|
|
onChange: this.handleChange,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return <Input {...inputProps} ref={this.saveInput} />;
|
|
|
|
return <Input {...inputProps} ref={this.saveInput} />;
|
|
|
|
},
|
|
|
|
},
|
|
|
|