141 lines
3.2 KiB
Vue
141 lines
3.2 KiB
Vue
<template>
|
|
<view class="select-container">
|
|
<!-- 搜索框 -->
|
|
<view class="search-bar">
|
|
<input type="text" placeholder="请输入关键字搜索" v-model="searchKey" />
|
|
<uni-icons type="search" size="18"></uni-icons>
|
|
</view>
|
|
|
|
<!-- 分类选择 -->
|
|
<view class="category-wrap">
|
|
<!-- 左侧分类 -->
|
|
<scroll-view scroll-y class="category-left">
|
|
<view
|
|
class="category-item"
|
|
:class="{ active: activeCategory === item.id }"
|
|
@click="selectCategory(item)"
|
|
v-for="item in categoryList"
|
|
:key="item.id"
|
|
>
|
|
{{ item.name }}
|
|
</view>
|
|
</scroll-view>
|
|
|
|
<!-- 右侧项目 -->
|
|
<scroll-view scroll-y class="category-right">
|
|
<view
|
|
class="project-item"
|
|
@click="selectProject(item)"
|
|
v-for="item in currentProjectList"
|
|
:key="item.id"
|
|
>
|
|
{{ item.name }}
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, computed } from 'vue'
|
|
// import { uniNavigateTo } from '@dcloudio/uni-app'
|
|
|
|
// 分类列表
|
|
const categoryList = ref([
|
|
{ id: 1, name: '基础设施' },
|
|
{ id: 2, name: '电子设施' }
|
|
])
|
|
|
|
// 所有项目数据
|
|
const projectList = ref([
|
|
{ id: 101, categoryId: 1, name: '路灯' },
|
|
{ id: 102, categoryId: 1, name: '楼层指示灯' },
|
|
{ id: 103, categoryId: 2, name: '应急出口灯' },
|
|
{ id: 104, categoryId: 1, name: '草坪灯' }
|
|
])
|
|
|
|
// 选中的分类
|
|
const activeCategory = ref(1)
|
|
// 搜索关键词
|
|
const searchKey = ref('')
|
|
|
|
// 筛选当前分类的项目(含搜索)
|
|
const currentProjectList = computed(() => {
|
|
let list = projectList.value.filter(item => item.categoryId === activeCategory.value)
|
|
if (searchKey.value) {
|
|
list = list.filter(item => item.name.includes(searchKey.value))
|
|
}
|
|
return list
|
|
})
|
|
|
|
// 选择分类
|
|
const selectCategory = (item) => {
|
|
activeCategory.value = item.id
|
|
}
|
|
|
|
// 选择项目并跳转到维修项目填写页
|
|
const selectProject = (item) => {
|
|
// 获取分类名称
|
|
const categoryName = categoryList.value.find(c => c.id === item.categoryId)?.name
|
|
// 跳转并传参
|
|
uni.navigateTo({
|
|
url: `/pageSubPack/online-repair/publicRepair?category=${categoryName}&project=${item.name}`
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.select-container {
|
|
padding: 10px;
|
|
height: 100vh;
|
|
box-sizing: border-box;
|
|
}
|
|
.search-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 8px 10px;
|
|
background: #f5f5f5;
|
|
border-radius: 6px;
|
|
margin-bottom: 10px;
|
|
}
|
|
.search-bar input {
|
|
flex: 1;
|
|
font-size: 14px;
|
|
}
|
|
.category-wrap {
|
|
display: flex;
|
|
height: calc(100% - 50px);
|
|
}
|
|
.category-left {
|
|
width: 120px;
|
|
height: 100%;
|
|
background: #f8f8f8;
|
|
border-radius: 6px 0 0 6px;
|
|
}
|
|
.category-item {
|
|
padding: 15px 10px;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
.category-item.active {
|
|
background: #fff;
|
|
color: #007aff;
|
|
font-weight: bold;
|
|
}
|
|
.category-right {
|
|
flex: 1;
|
|
height: 100%;
|
|
background: #fff;
|
|
border-radius: 0 6px 6px 0;
|
|
padding: 10px;
|
|
}
|
|
.project-item {
|
|
padding: 12px 10px;
|
|
font-size: 14px;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
.project-item:active {
|
|
background: #f5f5f5;
|
|
}
|
|
</style> |