search.vue 1.63 KB
<template>
  <div class="resIssue_search_container">
    <NafmHeader title="注册发行" navClass="nafmii-head-bg3">
      <template #bottom>
        <SearchInput class="common_search" v-model="keyword" placeholder="请输入企业名称/注册报告名称/主承销商" @search="jumpSearchResult" />
      </template>
    </NafmHeader>
    <div class="resIssue_search_content">
      <SearchHistory :list="list" @jumpPage="jumpSearchResult" @clear="handleClear" />
    </div>
  </div>
</template>
<script>
import SearchInput from '@/components/SearchInput.vue'
import SearchHistory from '@/components/SearchHistory'
import { setLocalStorage, getLocalStorage, removeLocalStorage } from '@/utils/LocalStorage'
export default {
  name: 'ResIssueSearch',
  components: {
    SearchInput,
    SearchHistory
  },
  data() {
    return {
      keyword: '',
      list: []
    }
  },
  mounted() {
    this.list = getLocalStorage('resIssucessData') || []
  },
  methods: {
    handleSearch(val) {
      if (this.list.indexOf(val) === -1) {
        this.list.unshift(val)
        if (this.list.length > 10) {
          this.list.pop()
        }
        setLocalStorage('resIssucessData', this.list)
      }
    },
    jumpSearchResult(val) {
      this.handleSearch(val)
      this.$router.push({
        name: 'RegIssueSearchResult',
        query: {
          keyword: val
        }
      })
    },
    handleClear() {
      this.list = []
      removeLocalStorage('resIssucessData')
    }
  }
}
</script>
<style lang="less" scoped>
.resIssue_search_container{
  display: flex;
  flex-direction: column;
  height: 100%;
}
.resIssue_search_content{
  flex: 1;
}
</style>