index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="project-container">
  3. <!-- 顶部固定搜索区域 -->
  4. <view class="search-header">
  5. <!-- 搜索输入框 -->
  6. <view class="search-row">
  7. <uv-input placeholder="请输入项目名称" v-model="queryParams.projectName" prefixIcon="search"
  8. prefixIconStyle="color: #999; font-size: 32rpx;" clearable shape="circle"
  9. customStyle="background-color: #f5f7fa; border: none;"></uv-input>
  10. </view>
  11. <!-- 状态与角色过滤 -->
  12. <view class="filter-row">
  13. <!-- 状态选择 Picker 触发器 -->
  14. <view class="status-picker-wrap" @click="openPicker">
  15. <text class="status-text">{{ currentStatusLabel }}</text>
  16. <uv-icon name="arrow-down-fill" size="10" color="#666" customStyle="margin-left: 8rpx"></uv-icon>
  17. </view>
  18. <!-- 我负责/我参与 切换 -->
  19. <view class="role-tabs">
  20. <view class="role-tab" :class="{ active: queryParams.operatorType === '10' }"
  21. @click="queryParams.operatorType = '10'">我负责的</view>
  22. <view class="role-tab" :class="{ active: queryParams.operatorType === '20' }"
  23. @click="queryParams.operatorType = '20'">我参与的</view>
  24. <view class="role-tab" :class="{ active: queryParams.operatorType === '30' }"
  25. @click="queryParams.operatorType = '30'">全部</view>
  26. </view>
  27. </view>
  28. <!-- 项目类型切换 -->
  29. <view class="type-tabs">
  30. <uv-tabs :list="tabList" :current="currentTab" @change="onTabChange"
  31. :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold', transform: 'scale(1.05)' }"
  32. :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd" lineWidth="40"
  33. :itemStyle="{ height: '88rpx', flex: 1 }" :scrollable="false"></uv-tabs>
  34. </view>
  35. </view>
  36. <!-- 列表区域 -->
  37. <view class="list-container">
  38. <VerticalProject v-if="currentTab === 0" :queryParams="queryParams" @goDetail="goDetail"></VerticalProject>
  39. <HorizontalProject v-if="currentTab === 1" :queryParams="queryParams" @goDetail="goDetail"></HorizontalProject>
  40. <SpontaneityProject v-if="currentTab === 2" :queryParams="queryParams" @goDetail="goDetail"></SpontaneityProject>
  41. <SafetyProject v-if="currentTab === 3" :queryParams="queryParams" @goDetail="goDetail"></SafetyProject>
  42. </view>
  43. <!-- 状态拾取器 -->
  44. <uv-picker ref="statusPicker" :columns="statusColumns" keyName="dictLabel" @confirm="onStatusConfirm"></uv-picker>
  45. </view>
  46. </template>
  47. <script setup lang="ts">
  48. import { ref, computed } from 'vue';
  49. import { onLoad } from '@dcloudio/uni-app';
  50. import VerticalProject from './components/VerticalProject.vue';
  51. import HorizontalProject from './components/HorizontalProject.vue';
  52. import SpontaneityProject from './components/SpontaneityProject.vue';
  53. import SafetyProject from './components/SafetyProject.vue';
  54. import {
  55. verticalProjectStatusOptions,
  56. horizontalProjectStatusOptions,
  57. spontaneityProjectStatusOptions,
  58. safetyProjectStatusOptions
  59. } from '@/constants/index';
  60. // 查询条件
  61. const queryParams = ref({
  62. projectName: '',
  63. projectStatus: '',
  64. operatorType: '10'
  65. });
  66. const currentTab = ref(0);
  67. const tabList = ref([{ name: '纵向项目' }, { name: '横向项目' }, { name: '校内项目' }, { name: '安评项目' }]);
  68. const currentStatusOptions = computed(() => {
  69. if (currentTab.value === 0) return verticalProjectStatusOptions;
  70. if (currentTab.value === 1) return horizontalProjectStatusOptions;
  71. if (currentTab.value === 2) return spontaneityProjectStatusOptions;
  72. if (currentTab.value === 3) return safetyProjectStatusOptions;
  73. return [];
  74. });
  75. const currentStatusLabel = computed(() => {
  76. const item = currentStatusOptions.value.find(s => s.dictValue === queryParams.value.projectStatus);
  77. return item && item.dictValue !== '' ? item.dictLabel : '项目状态';
  78. });
  79. const statusColumns = computed(() => [currentStatusOptions.value]);
  80. const statusPicker = ref<any>(null);
  81. const openPicker = () => {
  82. const idx = currentStatusOptions.value.findIndex(s => s.dictValue === queryParams.value.projectStatus);
  83. if (idx !== -1 && statusPicker.value?.setIndexs) {
  84. statusPicker.value.setIndexs([idx]);
  85. }
  86. statusPicker.value?.open();
  87. };
  88. const onStatusConfirm = (e: any) => {
  89. queryParams.value.projectStatus = e.value[0].dictValue;
  90. };
  91. const onTabChange = (e: any) => {
  92. currentTab.value = e.index;
  93. queryParams.value.projectStatus = ''; // 切换 Tab 时重置状态筛选
  94. };
  95. const goDetail = (item: any) => {
  96. // 跳转到统一或者独立的详情页(这里使用了带参数的统一详情页)
  97. uni.navigateTo({
  98. url: `/pages/project/detail?type=${item._type}&id=${item.id}`
  99. });
  100. };
  101. onLoad((options: any) => {
  102. if (options.tabIndex) {
  103. currentTab.value = Number(options.tabIndex);
  104. }
  105. });
  106. </script>
  107. <style lang="scss" scoped>
  108. .project-container {
  109. height: calc(100vh - var(--window-top));
  110. display: flex;
  111. flex-direction: column;
  112. background-color: #f5f7fa;
  113. box-sizing: border-box;
  114. }
  115. .search-header {
  116. background-color: #fff;
  117. padding: 20rpx 30rpx 0;
  118. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  119. position: sticky;
  120. top: 0;
  121. z-index: 99;
  122. .search-row {
  123. margin-bottom: 24rpx;
  124. }
  125. .filter-row {
  126. display: flex;
  127. justify-content: space-between;
  128. align-items: center;
  129. margin-bottom: 10rpx;
  130. height: 70rpx;
  131. .status-picker-wrap {
  132. display: flex;
  133. align-items: center;
  134. background-color: #f5f7fa;
  135. height: 60rpx;
  136. padding: 0 16rpx 0 20rpx;
  137. border-radius: 30rpx;
  138. flex-shrink: 0;
  139. .status-text {
  140. font-size: 26rpx;
  141. color: #666;
  142. max-width: 140rpx;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. white-space: nowrap;
  146. }
  147. }
  148. .role-tabs {
  149. display: flex;
  150. background-color: #f5f7fa;
  151. border-radius: 40rpx;
  152. padding: 6rpx;
  153. .role-tab {
  154. font-size: 24rpx;
  155. color: #666;
  156. padding: 10rpx 28rpx;
  157. border-radius: 34rpx;
  158. transition: all 0.3s;
  159. &.active {
  160. background-color: #1c9bfd;
  161. color: #fff;
  162. font-weight: 500;
  163. box-shadow: 0 4rpx 8rpx rgba(28, 155, 253, 0.3);
  164. }
  165. }
  166. }
  167. }
  168. .type-tabs {
  169. margin-top: 10rpx;
  170. }
  171. }
  172. .list-container {
  173. padding: 30rpx;
  174. flex: 1;
  175. overflow: hidden;
  176. box-sizing: border-box;
  177. }
  178. </style>