|
@@ -1,18 +1,26 @@
|
|
|
<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>
|
|
|
- <view class="iconBox"><uni-icons type="icon-arrow-sortdown-smal" custom-prefix="iconfont" color="#999"/></view>
|
|
|
+ <view class="item" v-for="item in filterList" :key="item[props.idValue]">
|
|
|
+ <picker @change="e => handleClick(e, item)" :value="item.selected" :range="item.array">
|
|
|
+ <view>
|
|
|
+ {{ item[labelValue] }}
|
|
|
+ <uni-icons type="icon-arrow-sortdown-smal" custom-prefix="iconfont" color="#999"/>
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ <!-- <uni-data-picker :localdata="item.array" :popup-title="'请选择' + item[labelValue]" :map="{ text: 'name', value: 'id' }">
|
|
|
+ <view>
|
|
|
+ {{ item[labelValue] }}
|
|
|
+ <uni-icons type="icon-arrow-sortdown-smal" custom-prefix="iconfont" color="#999"/>
|
|
|
+ </view>
|
|
|
+ </uni-data-picker> -->
|
|
|
</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'
|
|
|
+import { getDict } from '@/utils/useDictionaries'
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
list: { type: Array, default: () => [] },
|
|
|
idValue: { type: String, default: 'id' },
|
|
@@ -23,28 +31,52 @@ const props = defineProps({
|
|
|
lazy: { type: Boolean, default: false },
|
|
|
})
|
|
|
|
|
|
-const popupRef = ref()
|
|
|
-let itemObj = {}
|
|
|
-const handleClick = (item) => {
|
|
|
- itemObj = item
|
|
|
- popupRef.value.open('bottom')
|
|
|
+const handleClick = (e, item) => {
|
|
|
+ item.selected = e.detail.value
|
|
|
}
|
|
|
|
|
|
-const selectData = {
|
|
|
- 行业: [{ label: '行业' }],
|
|
|
- 城市: [{ label: '城市' }],
|
|
|
- 工作性质: [{ label: '工作性质' }],
|
|
|
- 月薪范围: [{ label: '月薪范围' }],
|
|
|
- 工作经验: [{ label: '工作经验' }],
|
|
|
-}
|
|
|
+// const selectData = {
|
|
|
+// 城市: [{ label: '城市' }],
|
|
|
+// 行业: [{ label: '行业' }],
|
|
|
+// 求职类型: [{ label: '求职类型' }],
|
|
|
+// 薪资待遇: [{ label: '薪资待遇' }],
|
|
|
+// 工作经验: [{ label: '工作经验' }],
|
|
|
+// }
|
|
|
|
|
|
+// 获取字典数据
|
|
|
const getData = (e) => {
|
|
|
- // api
|
|
|
- e.selectOptions = selectData[e[props.idValue]] || []
|
|
|
+ getDict(e.dictType).then(({ data }) => {
|
|
|
+ e.source = data.data
|
|
|
+ e.array = data.data.map(e => e.label)
|
|
|
+ })
|
|
|
+ // e.array = [
|
|
|
+ // {
|
|
|
+ // id: '110101',
|
|
|
+ // name: '北京',
|
|
|
+ // children: [
|
|
|
+ // { id: '110101', name: '东城区' },
|
|
|
+ // { id: '110102', name: '西城区' },
|
|
|
+ // { id: '110105', name: '朝阳区' },
|
|
|
+ // { id: '110106', name: '丰台区' },
|
|
|
+ // { id: '110107', name: '石景山区' }
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '120000',
|
|
|
+ // name: '天津',
|
|
|
+ // children: [
|
|
|
+ // { id: '120101', name: '和平区' },
|
|
|
+ // { id: '120102', name: '河东区' },
|
|
|
+ // { id: '120103', name: '河西区' },
|
|
|
+ // { id: '120104', name: '南开区' },
|
|
|
+ // ]
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
}
|
|
|
|
|
|
const setItemSelectData = () => {
|
|
|
filterList.value.forEach(e => {
|
|
|
+ e.selected = 0
|
|
|
getData(e)
|
|
|
})
|
|
|
}
|
|
@@ -55,8 +87,7 @@ watch(() => props.list,
|
|
|
filterList.value = newVal ? [...newVal] : []
|
|
|
if (filterList.value.length && !props.lazy) setItemSelectData()
|
|
|
},
|
|
|
- { immediate: true },
|
|
|
- // { deep: true }
|
|
|
+ { immediate: true }
|
|
|
)
|
|
|
|
|
|
</script>
|
|
@@ -72,10 +103,7 @@ watch(() => props.list,
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
font-size: 14px;
|
|
|
- margin: 5px 0;
|
|
|
- .iconBox {
|
|
|
- margin: 2px 13px 0 4px;
|
|
|
- }
|
|
|
+ margin: 0 5px;
|
|
|
}
|
|
|
}
|
|
|
.popup {
|