<template>
  <div>
    <el-button type="primary" size="mini" @click="handleQuery">查询</el-button>
    <el-input v-show="showSearch" v-model="queryParams.voucherGroupName" placeholder="输入抽样模板编码或名称" clearable size="small" @keyup.native.enter="handleQuery" class="search-input" style="width: 200px; margin-right: 10px"></el-input>
  </div>
</template>
<script>
export default {
  data() {
    return {
      showSearch: true,
      queryParams: {
        voucherGroupName: '',
        // other query parameters
      },
      voucherGroupList: [],
      loading: false
    };
  },
  methods: {
    handleQuery() {
      console.log(this.queryParams.voucherGroupName, 'item');
      if (this.queryParams.voucherGroupName) {
        this.voucherGroupList = this.voucherGroupList.filter((item) => {
          // 根据抽样模板编码或名称进行过滤
          return (
            item.voucherGroupId.includes(this.queryParams.voucherGroupName) ||
            item.parentId.includes(this.queryParams.voucherGroupName)
          );
        });
      } else {
        this.getList();
      }
    },
    getList() {
      this.loading = true;
      this.queryParams.accountsId = this.accountsId;
      listVoucherGroup(this.queryParams).then((response) => {
        console.log(response, 'response');
        this.voucherGroupList = this.handleTree(
          response.data,
          'voucherGroupId',
          'parentId'
        );
        this.loading = false;
      });
    },
    handleTree(data, idKey, parentIdKey) {
      // handle tree data
    }
  },
  mounted() {
    this.getList();
  }
};
</script>
Vue 实现搜索功能:根据抽样模板编码或名称过滤列表