index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="index_container">
  3. <view class="search_container">
  4. <uni-row>
  5. <uni-col :xs="6" :sm="4">
  6. <view @click="openPopup" class="popup_button_container">
  7. <text class="ygoa-icon icon-filter"></text>
  8. <text class="button_text">{{ searchItem }}</text>
  9. </view>
  10. </uni-col>
  11. <uni-col :xs="18" :sm="20">
  12. <view class="search_bar">
  13. <uni-search-bar placeholder="搜索栏" @confirm="search" @cancel="searchCancel" @blur="searchOnBlur">
  14. <template v-slot:searchIcon>
  15. <uni-icons type="search" size="30"></uni-icons>
  16. </template>
  17. <template v-slot:clearIcon>
  18. <uni-icons type="clear" size="30"></uni-icons>
  19. </template>
  20. </uni-search-bar>
  21. </view>
  22. </uni-col>
  23. </uni-row>
  24. </view>
  25. <view class="segmented_control_container">
  26. <uni-segmented-control :current="current" :values="items" @clickItem="clickSegmentItem" styleType="text"
  27. activeColor="#409eff"></uni-segmented-control>
  28. </view>
  29. <view class="process_list">
  30. <process-list ref="processListRef" :list="processes" @clickSegment="getProcessData"
  31. @clickItem="handleToProcessDetail" @scrollToBottom="getProcessPage" :current="current" :pSize="5"
  32. :pageNo="1"></process-list>
  33. </view>
  34. <view class="popup_container">
  35. <uni-popup ref="searchItemPopup" type="bottom">
  36. <uni-list>
  37. <uni-list-item @click="clickSearchItem(item)" v-for="(item, index) in candidates" :key="index"
  38. clickable :title="item">
  39. </uni-list-item>
  40. </uni-list>
  41. </uni-popup>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup lang="ts">
  46. import processList from '@/components/ygoa/processList.vue'
  47. import { reactive, ref } from 'vue';
  48. import $tab from '@/plugins/tab.js'
  49. import { getUserProcess, getUserProcessed, getUserProcessing, getUserAllProcess } from '@/api/process';
  50. import { useUserStore } from '@/store/user';
  51. const userStore = useUserStore();
  52. // 分段器选项
  53. const items = reactive(['我的', '待办', '在办', '办结'])
  54. // 分段器选项
  55. const current = ref(0)
  56. // 子组件
  57. const processListRef = ref(null)
  58. // 待办列表
  59. const processes = ref([])
  60. // 分段器点击事件 调用子组件刷新数据
  61. function clickSegmentItem({ currentIndex }) {
  62. processes.value = [] // 清空列表数据
  63. current.value = currentIndex // 更新分段器状态
  64. processListRef.value.onClickItem() // 调用子组件刷新数据
  65. }
  66. // 搜索项
  67. const candidates = ref(['全局', '类型', '创建时间'])
  68. // 搜索栏选中项
  69. const searchItem = ref('全局')
  70. // 搜索项弹出层
  71. const searchItemPopup = ref(null)
  72. // 打开搜索项弹出层
  73. function openPopup() {
  74. searchItemPopup.value.open()
  75. }
  76. // 关闭搜索项弹出层
  77. function closePopup() {
  78. searchItemPopup.value.close()
  79. }
  80. // 选中搜索项
  81. function clickSearchItem(item) {
  82. searchItem.value = item
  83. closePopup()
  84. }
  85. // 搜索
  86. function search(e) {
  87. // console.log('search', e)
  88. }
  89. // 取消搜索
  90. function searchCancel() {
  91. return
  92. }
  93. // 搜索栏失去焦点
  94. function searchOnBlur(e) {
  95. // console.log('searchOnBlur', e);
  96. }
  97. // 获取待办列表数据
  98. function getProcessData({ pageNo, pSize }, callback) {
  99. const params = {
  100. staffId: userStore.user.useId,
  101. page: pageNo,
  102. pageNum: pSize,
  103. modelId: "",
  104. control: 1
  105. }
  106. const requestMap = [
  107. getUserAllProcess, // 我的
  108. getUserProcess, // 待办
  109. getUserProcessing, // 在办
  110. getUserProcessed // 办结
  111. ]
  112. requestMap[current.value](params).then(({ returnParams }) => {
  113. processes.value = returnParams.list
  114. callback(returnParams.list, returnParams.total, pageNo)
  115. })
  116. }
  117. // 分页获取待办列表数据
  118. function getProcessPage({ pageNo, pSize }, callback) {
  119. const params = {
  120. staffId: userStore.user.useId,
  121. page: pageNo,
  122. pageNum: pSize,
  123. modelId: "",
  124. control: 1
  125. }
  126. const requestMap = [
  127. getUserAllProcess, // 我的
  128. getUserProcess, // 待办
  129. getUserProcessing, // 在办
  130. getUserProcessed // 办结
  131. ]
  132. requestMap[current.value](params).then(({ returnParams }) => {
  133. processes.value.push(...returnParams.list)
  134. callback(returnParams.list, returnParams.total, pageNo)
  135. })
  136. }
  137. // 跳转到流程详情页
  138. function handleToProcessDetail({ insId, insName }) {
  139. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&insName=' + insName)
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. @import url("@/static/font/ygoa/iconfont.css");
  144. .search_container {
  145. .popup_button_container {
  146. display: flex;
  147. justify-content: center;
  148. margin-left: 5px;
  149. height: 36px;
  150. line-height: 36px;
  151. width: 100%;
  152. padding-top: 10px;
  153. background-color: #f5f5f5;
  154. text-align: center;
  155. font-size: 16px;
  156. color: #333;
  157. .button_text {
  158. width: 64px;
  159. margin-left: 4px;
  160. }
  161. }
  162. .search_bar {
  163. ::v-deep .uni-searchbar {
  164. padding-left: 0;
  165. }
  166. }
  167. }
  168. .segmented_control_container {}
  169. </style>