index.vue 5.6 KB

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