提交 dd985252 编写于 作者: zhujiamin's avatar zhujiamin

点击搜索记录tag触发搜索

上级 623b7585
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
.hisText{ .hisText{
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-size: 14px; font-size: 15px;
color: #777777; color: #777777;
margin:2px 15px; margin:2px 15px;
ion-icon{ .van-icon{
padding-top: 3px; margin-top: 2px;
} }
} }
.hisItems{ .hisItems{
......
<template> <template>
<div class="app-seach-history"> <div class="app-seach-history">
<ion-toolbar> <ion-toolbar>
<ion-searchbar style="height: 36px; padding-bottom: 0px;" :placeholder="$t('app.fastsearch')" debounce="500" @ionChange="quickValueChange($event)" show-cancel-button="focus" :cancel-button-text="$t('app.button.cancel')" @ionFocus="showHistory" @ionBlur="hideHistory" @search="searchVal"></ion-searchbar> <ion-searchbar style="height: 36px; padding-bottom: 0px;" :placeholder="$t('app.fastsearch')" debounce="500" @ionChange="quickValueChange($event)" show-cancel-button="focus" :cancel-button-text="$t('app.button.cancel')" @ionFocus="showHistory" @ionBlur="hideHistory" @search="searchVal" ref="searchbar"></ion-searchbar>
<ion-button v-if="showfilter" class="filter-btn" size="small" slot="end" @click="openSearchform"><ion-icon slot="end" name="filter-outline"></ion-icon>过滤</ion-button> <ion-button v-if="showfilter" class="filter-btn" size="small" slot="end" @click="openSearchform"><ion-icon slot="end" name="filter-outline"></ion-icon>过滤</ion-button>
</ion-toolbar> </ion-toolbar>
<div class="history" v-if="hasHistory"> <div class="history" v-if="hasHistory">
<div class="hisText"><div>最近搜索</div> <ion-icon name="trash-bin-outline" @click="clearHistory"></ion-icon></div> <div class="hisText"><div>最近搜索</div> <van-icon name="delete" @click="clearHistory"/></div>
<div class="hisItems"> <div class="hisItems">
<van-tag type="primary" v-for="item in historyList" :key="item.index" round size="medium" color="#ededed" text-color="#333" >{{item}}</van-tag> <van-tag type="primary" v-for="item in historyList" :key="item.index" round size="medium" color="#ededed" text-color="#333" @click="clickTag">{{item}}</van-tag>
</div> </div>
</div> </div>
</div> </div>
...@@ -41,7 +41,7 @@ export default class AppRoundList extends Vue{ ...@@ -41,7 +41,7 @@ export default class AppRoundList extends Vue{
* @type {boolean} * @type {boolean}
* @memberof AppSearchHistory * @memberof AppSearchHistory
*/ */
@Prop() public showfilter:boolean = false; @Prop() public showfilter!:boolean;
/** /**
* 快速搜索值变化 * 快速搜索值变化
...@@ -52,6 +52,7 @@ export default class AppRoundList extends Vue{ ...@@ -52,6 +52,7 @@ export default class AppRoundList extends Vue{
*/ */
public quickValueChange($event:any){ public quickValueChange($event:any){
this.$emit('quickValueChange',$event); this.$emit('quickValueChange',$event);
this.searchVal($event);
} }
/** /**
...@@ -153,7 +154,6 @@ export default class AppRoundList extends Vue{ ...@@ -153,7 +154,6 @@ export default class AppRoundList extends Vue{
if ( (Array.isArray(this.historyLists.historyList)) && (this.historyLists.historyList.length <= 0) ) { if ( (Array.isArray(this.historyLists.historyList)) && (this.historyLists.historyList.length <= 0) ) {
this.hasHistory = false; this.hasHistory = false;
} else { } else {
console.log('333');
this.hasHistory = true; this.hasHistory = true;
} }
} }
...@@ -176,6 +176,9 @@ export default class AppRoundList extends Vue{ ...@@ -176,6 +176,9 @@ export default class AppRoundList extends Vue{
public searchVal($event:any){ public searchVal($event:any){
let val:any = $event.target.value; let val:any = $event.target.value;
val = val.trim(); val = val.trim();
if (val === "") {
return;
}
if (this.historyList.length > 0) { if (this.historyList.length > 0) {
if (this.historyList.indexOf(val) !== -1) { if (this.historyList.indexOf(val) !== -1) {
this.historyList.splice(this.historyList.indexOf(val), 1); this.historyList.splice(this.historyList.indexOf(val), 1);
...@@ -212,6 +215,18 @@ export default class AppRoundList extends Vue{ ...@@ -212,6 +215,18 @@ export default class AppRoundList extends Vue{
return false; return false;
} }
} }
/**
* 点击tag
*
* @memberof AppSearchHistory
*/
public async clickTag($event:any){
let content:any = $event.target.textContent
let searchbar:any = this.$refs.searchbar;
searchbar.value = content;
this.quickValueChange({detail:{value:content}});
}
}; };
</script> </script>
<style lang = "less"> <style lang = "less">
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册