Blame view

components/qj-fuzzy-search/index2.vue 1.97 KB
8c5ff8ba   “wangming”   updatemap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  <template>
  	<cover-view class="index">
  		<cover-view class="search" v-if="show">
  			<cover-view v-for="item in list" :key="item[valueName]" class="item" :style="[setItemStyle]"
  				hover-class="item-hover" hover-start-time="0" hover-stay-time="100" @click="click(item)">
  				<cover-view class="item" style="padding-left: 10rpx;"
  					@click="click(item)">{{ item[labelName] }}</cover-view>
  			</cover-view>
  			<!-- <cover-view class="empty" v-else>{{ noData }}</cover-view> -->
  		</cover-view>
  	</cover-view>
  </template>
  
  <script>
  	export default {
  		props: {
  			/** 展示整体组件 */
  			show: {
  				type: Boolean,
  				default: false
  			},
  			/** 需要展示的列表 */
  			list: {
  				type: Array,
  				default: () => []
  			},
  			/** 自定义label */
  			labelName: {
  				type: String,
  				default: 'label'
  			},
  			/** 自定义value */
  			valueName: {
  				type: String,
  				default: 'value'
  			},
  			/** 无内容时显示的内容  */
  			noData: {
  				type: String,
  				default: '暂无匹配企业...'
  			},
  			/** item的对齐样式 */
  			align: {
  				type: String,
  				default: 'left',
  				validator: value => {
  					return ['left', 'center', 'right'].includes(value);
  				}
  			},
  			/** 自定义item展示样式 */
  			customStyle: {
  				type: Object,
  				default: () => ({})
  			}
  		},
  		computed: {
  			/** 设置item的样式 */
  			setItemStyle() {
  				const {
  					align,
  					customStyle
  				} = this;
  				return {
  					textAlign: align,
  					...customStyle
  				};
  			}
  		},
  		methods: {
  			/** item点击事件 */
  			click(item) {
  				this.$emit('select', {
  					...item
  				});
  			},
  			/** 触底加载下一页 */
  			scrolltolower() {
  				this.$emit('scrolltolower');
  			}
  		}
  	};
  </script>
  
  <style lang="scss" scoped>
  	.index {
  		width: 99%;
  		position: absolute;
  		z-index: 9;
  
  
  	}
  
  	.search {
  		height: 500rpx;
  
  		overflow-x: hidden;
  
  		.item {
  			font-size: 26rpx;
  			height: 60rpx;
  			line-height: 60rpx;
  			background-color: #fff;
  
  			&-hover {
  				background-color: #f5f5f5;
  			}
  		}
  	}
  </style>