uniapp实现快捷模糊查询

uniapp实现快捷模糊查询,根据输入员工姓名进行模糊查询


前言

快捷模糊查询,根据输入员工姓名进行模糊查询
利用了uni组件完成
实现要求
在这里插入图片描述


提示:以下是本篇文章正文内容,下面案例可供参考

一、思路?

思路:filterList() {
var arr = [] //定义一个空数组
this.zhiweilist.forEach((item) => arr.push(item)) //在zhiweilist查找数据放入空数组
if (this.filterText) { //如果有这个数据
arr = this.zhiweilist.filter(item => item.name.includes(this.filterText))
//则在zhiweilist里过滤掉filterText
}
return arr

二、使用步骤

1.引入库

代码如下(示例):

<template>
	<view class="pages">


		<!-- 代码 start -->



		<view class="emg-1">
			<uni-search-bar v-model="filterText" placeholder="请输入员工姓名" bgColor="#EEEEEE" confirm-type="search"
				@confirm="searchMe" />

		</view>
		<view class="emg-2" @click="goAddemployee" data-tralerId="tralerList.id">+添加员工</view>
		<view class="emg-3" v-for="(xxzx,index) in xxzx" :key="index">
			<uni-list-item title="待审核员工" link @tap="gonoshenhe">
				<template v-slot:footer>
					<uni-badge class="uni-badge-left-margin" :text="xxzx.number" />
				</template>
			</uni-list-item>
		</view>

		<view class="invitation-zhiwei-ul" v-for="(item,index) in filterList" :key="index" @click="goModifyyg()">
			<uni-list-item :thumb="item.tx" thumb-size="base">
				<template v-slot:body>
					<view class="slot-box">
						<text class="slot-text">
							{{item.name}}

						</text>
						<uni-tag :inverted="true" :text="item.gly" class="emg-5" />
					</view>
				</template>
			</uni-list-item>

		</view>

		<!-- 代码  end -->

	</view>
</template>





<script>
	import {

		zhiweilist,
		xxzx
	}
	from '@/src/Employeegl.js';
	export default {
		data() {
			return {

				zhiweilist,
				xxzx,
				filterText: '',

			}
		},
		onLoad() {},
		computed: {
			filterList() {
				var arr = [] //定义一个空数组
				this.zhiweilist.forEach((item) => arr.push(item)) //在zhiweilist查找数据放入空数组
				if (this.filterText) { //如果有这个数据
					arr = this.zhiweilist.filter(item => item.name.includes(this.filterText))
					//则在zhiweilist里过滤掉filterText
				}
				return arr
			}
		},
		methods: {
			goModifyyg() {
				// console.log('kcodeList--->', this.kcodeList)
				uni.navigateTo({
					url: '/pages/Index/Employeegl/Modifyyg/Modifyyg'
				});
			},
			goAddemployee() {
				// console.log('kcodeList--->', this.kcodeList)
				uni.navigateTo({
					url: '/pages/Index/Employeegl/noshenhe/Addemployee/Addemployee'

				});
			},
			gonoshenhe() {
				// console.log('kcodeList--->', this.kcodeList)
				uni.navigateTo({
					url: '/pages/Index/Employeegl/noshenhe/noshenhe'
				});
			},

		}
	}
</script>




<style>
	.emg-2 {
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 30upx;
		color: #52baff;
	}

	.emg-3 {
		margin-top: 50upx;
	}

	.emg-5 {
		margin-left: 40upx;
	}

	.slot-text {
		display: inline-block;
	}
</style>

2.mock数据

代码如下(示例):

export const zhiweilist = [
	
	{
			id: 0,name: '刘*元',
			tx:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
			gly:'超级管理员'
		},
		{
			id: 1,name: '刘*元',
			tx:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
			gly:'超级管理员'
		},
		{
			id: 2,name: '张三',
			tx:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
			gly:'超级管理员'
		},
		{
			id: 3,name: '李四',
			tx:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
			gly:'超级管理员'
		},
		{
			id: 4,name: '王五',
			tx:'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
			gly:'超级管理员'
		}
	
	
]

export const xxzx = [
	
	{
	number:'20'
		},
	
	
]

总结

  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值