2024-08-08 11:08:55 +08:00
|
|
|
<template>
|
|
|
|
<u-sticky bgColor="#ffffff">
|
2024-08-28 18:12:34 +08:00
|
|
|
<view class="card top-flex-box">
|
|
|
|
<u--text v-if="isHasFilter" suffixIcon="arrow-down" text="筛选" @click="selfHandleShowPicker" style="flex: 0.2" />
|
|
|
|
<u-search v-model="localInputSearchValue" :showAction="true" actionText="搜索" :animation="false"
|
|
|
|
@search="selfHandlerSearch" @custom="selfHandlerSearch" @clear="selfHandlerClear" />
|
2024-08-08 11:08:55 +08:00
|
|
|
</view>
|
|
|
|
<app-line />
|
|
|
|
</u-sticky>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
inputSearchValue: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2024-08-28 18:12:34 +08:00
|
|
|
/** 是否需要启用前置筛选能力 */
|
|
|
|
isHasFilter: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
}
|
2024-08-08 11:08:55 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// 使用本地变量存储父组件传递的值
|
|
|
|
localInputSearchValue: this.inputSearchValue,
|
|
|
|
};
|
|
|
|
},
|
2024-08-28 18:12:34 +08:00
|
|
|
watch: {
|
|
|
|
// 监听父组件传递的 prop 变化
|
|
|
|
inputSearchValue(newVal) {
|
|
|
|
this.localInputSearchValue = newVal;
|
|
|
|
},
|
|
|
|
},
|
2024-08-08 11:08:55 +08:00
|
|
|
methods: {
|
|
|
|
selfHandlerSearch() {
|
|
|
|
this.$emit("search", this.localInputSearchValue);
|
|
|
|
},
|
2024-08-28 18:12:34 +08:00
|
|
|
selfHandlerClear() {
|
|
|
|
this.localInputSearchValue = "";
|
|
|
|
},
|
|
|
|
/** 组件自身的筛选器处理事件 */
|
|
|
|
selfHandleShowPicker() {
|
|
|
|
if (!this.isHasFilter) {
|
|
|
|
console.log("%c%s", "background: orange; color: black", "请添加 is-has-filter 属性使其生效")
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$emit("showPicker");
|
|
|
|
}
|
2024-08-08 11:08:55 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.key-word-search-input-box {
|
|
|
|
margin: 20rpx;
|
|
|
|
}
|
2024-08-28 18:12:34 +08:00
|
|
|
|
|
|
|
.top-flex-box {
|
|
|
|
display: flex;
|
|
|
|
}
|
2024-08-08 11:08:55 +08:00
|
|
|
</style>
|