Commit 7e43253e by chenwq

feat(teamList): 新增团队列表按督导姓名搜索功能

新建通用搜索栏组件searchBar,支持v-model绑定与搜索、清空、取消事件。在团队列表页接入该组件,将搜索关键词传入接口请求参数实现列表数据过滤。
1 parent 535470d2
<template>
<div class="search-bar-wrapper">
<van-search
v-model="keyword"
:placeholder="placeholder"
shape="round"
background="transparent"
@search="onSearch"
@clear="onClear"
@cancel="onCancel"
/>
</div>
</template>
<script>
export default {
name: 'SearchBar',
props: {
placeholder: {
type: String,
default: '搜索督导姓名'
},
value: {
type: String,
default: ''
}
},
data() {
return {
keyword: this.value
}
},
watch: {
value(newVal) {
this.keyword = newVal
},
keyword(newVal) {
this.$emit('input', newVal)
}
},
methods: {
onSearch(val) {
this.$emit('search', val)
},
onClear() {
this.$emit('clear')
this.$emit('search', '')
},
onCancel() {
this.$emit('cancel')
this.$emit('search', '')
}
}
}
</script>
<style lang="scss" scoped>
.search-bar-wrapper {
padding: 0 4px;
/* 深度覆盖 Vant 样式以匹配设计稿 */
:deep(.van-search) {
padding: 10px 12px;
}
:deep(.van-search__content) {
background-color: #FFFFFF;
border: 1px solid #E5E5E5;
}
}
</style>
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
</div> </div>
</van-sticky> </van-sticky>
<!-- 新增搜索组件 -->
<search-bar v-model="searchKeyword" @search="onKeywordSearch"></search-bar>
<div class="content-box"> <div class="content-box">
<van-pull-refresh v-model="refreshing" @refresh="onRefresh"> <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list <van-list
...@@ -144,13 +147,15 @@ ...@@ -144,13 +147,15 @@
import api from '@/api/teamWork' import api from '@/api/teamWork'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import dateSearch from '@/components/dateSearch/dateSearch.vue' import dateSearch from '@/components/dateSearch/dateSearch.vue'
import SearchBar from '@/components/searchBar/index.vue'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/' const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
export default { export default {
name: 'TeamList', name: 'TeamList',
components: { components: {
dateSearch dateSearch,
SearchBar
}, },
data() { data() {
return { return {
...@@ -204,6 +209,7 @@ export default { ...@@ -204,6 +209,7 @@ export default {
finished: false, finished: false,
startStr: '', startStr: '',
endStr: '', endStr: '',
searchKeyword: ''
} }
}, },
created() { created() {
...@@ -278,6 +284,10 @@ export default { ...@@ -278,6 +284,10 @@ export default {
this.endStr = detail.endDay?.replace(/\//g, '-') this.endStr = detail.endDay?.replace(/\//g, '-')
this.onRefresh() this.onRefresh()
}, },
onKeywordSearch(val) {
this.searchKeyword = val
this.onRefresh()
},
onRefresh() { onRefresh() {
this.finished = false this.finished = false
this.loading = true this.loading = true
...@@ -301,7 +311,8 @@ export default { ...@@ -301,7 +311,8 @@ export default {
startDate: this.startStr, startDate: this.startStr,
endDate: this.endStr, endDate: this.endStr,
pageNum: this.pageNum, pageNum: this.pageNum,
pageSize: 10 pageSize: 10,
keyword: this.searchKeyword
} }
api.getMissionList(params).then(res => { api.getMissionList(params).then(res => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!