index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 === '30' }"
  21. @click="queryParams.operatorType = '30'">全部</view>
  22. <view class="role-tab" :class="{ active: queryParams.operatorType === '10' }"
  23. @click="queryParams.operatorType = '10'">我负责的</view>
  24. <view class="role-tab" :class="{ active: queryParams.operatorType === '20' }"
  25. @click="queryParams.operatorType = '20'">我参与的</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. </view>
  42. <!-- 状态拾取器 -->
  43. <uv-picker
  44. ref="statusPicker"
  45. :columns="statusColumns"
  46. keyName="dictLabel"
  47. @confirm="onStatusConfirm"
  48. ></uv-picker>
  49. </view>
  50. </template>
  51. <script setup lang="ts">
  52. import { ref, computed } from 'vue';
  53. import { onLoad } from '@dcloudio/uni-app';
  54. import VerticalProject from './components/VerticalProject.vue';
  55. import HorizontalProject from './components/HorizontalProject.vue';
  56. import SpontaneityProject from './components/SpontaneityProject.vue';
  57. import { projectStatusOptions } from '@/constants/index';
  58. // 查询条件
  59. const queryParams = ref({
  60. projectName: '',
  61. projectStatus: '', // 空表示全部
  62. operatorType: '30' // 30表示全部
  63. });
  64. const currentTab = ref(0);
  65. const tabList = ref([{ name: '纵向项目' }, { name: '横向项目' }, { name: '校内项目' }]);
  66. const currentStatusLabel = computed(() => {
  67. const item = projectStatusOptions.find(s => s.dictValue === queryParams.value.projectStatus);
  68. return item && item.dictValue !== '' ? item.dictLabel : '项目状态';
  69. });
  70. const statusColumns = computed(() => [projectStatusOptions]);
  71. const statusPicker = ref<any>(null);
  72. const openPicker = () => {
  73. const idx = projectStatusOptions.findIndex(s => s.dictValue === queryParams.value.projectStatus);
  74. if (idx !== -1 && statusPicker.value?.setIndexs) {
  75. statusPicker.value.setIndexs([idx]);
  76. }
  77. statusPicker.value?.open();
  78. };
  79. const onStatusConfirm = (e: any) => {
  80. queryParams.value.projectStatus = e.value[0].dictValue;
  81. };
  82. const onTabChange = (e: any) => {
  83. currentTab.value = e.index;
  84. };
  85. const goDetail = (item: any) => {
  86. // 跳转到统一或者独立的详情页(这里使用了带参数的统一详情页)
  87. uni.navigateTo({
  88. url: `/pages/project/detail?type=${item._type}&id=${item.id}`
  89. });
  90. };
  91. onLoad((options: any) => {
  92. if (options.tabIndex) {
  93. currentTab.value = Number(options.tabIndex);
  94. }
  95. });
  96. </script>
  97. <style lang="scss" scoped>
  98. .project-container {
  99. height: calc(100vh - var(--window-top));
  100. display: flex;
  101. flex-direction: column;
  102. background-color: #f5f7fa;
  103. box-sizing: border-box;
  104. }
  105. .search-header {
  106. background-color: #fff;
  107. padding: 20rpx 30rpx 0;
  108. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  109. position: sticky;
  110. top: 0;
  111. z-index: 99;
  112. .search-row {
  113. margin-bottom: 24rpx;
  114. }
  115. .filter-row {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. margin-bottom: 10rpx;
  120. height: 70rpx;
  121. .status-picker-wrap {
  122. display: flex;
  123. align-items: center;
  124. background-color: #f5f7fa;
  125. height: 60rpx;
  126. padding: 0 16rpx 0 20rpx;
  127. border-radius: 30rpx;
  128. flex-shrink: 0;
  129. .status-text {
  130. font-size: 26rpx;
  131. color: #666;
  132. max-width: 140rpx;
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. white-space: nowrap;
  136. }
  137. }
  138. .role-tabs {
  139. display: flex;
  140. background-color: #f5f7fa;
  141. border-radius: 40rpx;
  142. padding: 6rpx;
  143. .role-tab {
  144. font-size: 24rpx;
  145. color: #666;
  146. padding: 10rpx 28rpx;
  147. border-radius: 34rpx;
  148. transition: all 0.3s;
  149. &.active {
  150. background-color: #1c9bfd;
  151. color: #fff;
  152. font-weight: 500;
  153. box-shadow: 0 4rpx 8rpx rgba(28, 155, 253, 0.3);
  154. }
  155. }
  156. }
  157. }
  158. .type-tabs {
  159. margin-top: 10rpx;
  160. }
  161. }
  162. .list-container {
  163. padding: 30rpx;
  164. flex: 1;
  165. overflow: hidden;
  166. box-sizing: border-box;
  167. }
  168. </style>