|
@@ -0,0 +1,87 @@
|
|
|
+<template>
|
|
|
+ <view class="labelColor itemBox">
|
|
|
+ <view class="item" v-for="item in filterList" :key="item[props.idValue]" @click="handleClick(item)">
|
|
|
+ <view class="">{{ item[labelValue] }}</view>
|
|
|
+ <!-- <icon type="success" size="14"/> -->
|
|
|
+ <view class="iconBox"><uni-icons type="bottom" color="#999" size="18"/></view>
|
|
|
+ </view>
|
|
|
+ <uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0">
|
|
|
+ <view class="popup">
|
|
|
+ <view v-for="val in itemObj?.selectOptions" :key="val[props.selectIdValue]">{{ val[selectLabelValue] }}</view>
|
|
|
+ </view>
|
|
|
+ </uni-popup>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref, watch } from 'vue'
|
|
|
+const props = defineProps({
|
|
|
+ list: { type: Array, default: () => [] },
|
|
|
+ idValue: { type: String, default: 'id' },
|
|
|
+ labelValue: { type: String, default: 'label' },
|
|
|
+ selectIdValue: { type: String, default: 'id' },
|
|
|
+ selectLabelValue: { type: String, default: 'label' },
|
|
|
+ useApiData: { type: Boolean, default: true },
|
|
|
+ lazy: { type: Boolean, default: false },
|
|
|
+})
|
|
|
+
|
|
|
+const popupRef = ref()
|
|
|
+let itemObj = {}
|
|
|
+const handleClick = (item) => {
|
|
|
+ itemObj = item
|
|
|
+ popupRef.value.open('bottom')
|
|
|
+}
|
|
|
+
|
|
|
+const selectData = {
|
|
|
+ 行业: [{ label: '行业' }],
|
|
|
+ 城市: [{ label: '城市' }],
|
|
|
+ 工作性质: [{ label: '工作性质' }],
|
|
|
+ 月薪范围: [{ label: '月薪范围' }],
|
|
|
+ 工作经验: [{ label: '工作经验' }],
|
|
|
+}
|
|
|
+
|
|
|
+const getData = (e) => {
|
|
|
+ // api
|
|
|
+ e.selectOptions = selectData[e[props.idValue]] || []
|
|
|
+}
|
|
|
+
|
|
|
+const setItemSelectData = () => {
|
|
|
+ filterList.value.forEach(e => {
|
|
|
+ getData(e)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const filterList = ref([])
|
|
|
+watch(() => props.list,
|
|
|
+ (newVal) => {
|
|
|
+ filterList.value = newVal ? [...newVal] : []
|
|
|
+ if (filterList.value.length && !props.lazy) setItemSelectData()
|
|
|
+ },
|
|
|
+ { immediate: true },
|
|
|
+ // { deep: true }
|
|
|
+)
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+.labelColor { color: #5c5c5c; }
|
|
|
+.marginR5 { margin-right: 5px; }
|
|
|
+.itemBox {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ .item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 14px;
|
|
|
+ margin: 5px 0;
|
|
|
+ .iconBox {
|
|
|
+ margin: 2px 13px 0 4px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.popup {
|
|
|
+ height: 50vh;
|
|
|
+ background-color: #fff;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+</style>
|