Ver Fonte

新增搜索筛选

htc há 5 dias atrás
pai
commit
9d9eb92017
1 ficheiros alterados com 9 adições e 3 exclusões
  1. 9 3
      pages/role.vue

+ 9 - 3
pages/role.vue

@@ -4,7 +4,7 @@
 			<div class="query adfacjb">
 				<div class="ql adfac">
 					<image src="http://106.54.209.120:8188/static/query_mini.png"></image>
-					<input type="text" placeholder="搜索" placeholder-class="ph">
+					<input type="text" v-model="keyword" placeholder="搜索" placeholder-class="ph" @confirm="queryRole">
 				</div>
 				<div class="qr" @tap="addRole"> + 新增角色</div>
 			</div>
@@ -59,6 +59,7 @@
 		data(){
 			return {
 				list:[],
+				originList:[],
 				deviceList:[],
 				show:false,
 				options: [{
@@ -67,8 +68,9 @@
 						backgroundColor: '#f56c6c'
 					}
 				}],
-				agentId: "",
-				deviceId: ""
+				keyword:'',
+				agentId: '',
+				deviceId: ''
 			}
 		},
 		onShow() {
@@ -76,6 +78,9 @@
 			this.getDeviceList();
 		},
 		methods:{
+			queryRole(){
+				this.list = this.originList.filter(l=>l.agentName.indexOf(this.keyword)>-1);
+			},
 			getAgentList(){
 				this.$api.get('/agent/list').then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg)
@@ -83,6 +88,7 @@
 					this.list.forEach((l,i)=>{
 						l.img = `http://106.54.209.120:8188/static/role_avatar${i%3}.png`;
 					})
+					this.originList = JSON.parse(JSON.stringify(this.list));
 				})
 			},
 			getDeviceList(){