index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 { onShow } from '@dcloudio/uni-app'
  48. import { reactive, ref, onMounted, onUpdated } from 'vue';
  49. import $tab from '@/plugins/tab.js'
  50. import { getUserProcess, getUserProcessed, getUserProcessing, getUserAllProcess } from '@/api/process';
  51. import { useUserStore } from '@/store/user';
  52. onMounted(() => {
  53. uni.$on('ReloadProcessData', (res) => {
  54. processListRef.value.onClickItem()
  55. })
  56. })
  57. onShow(() => {
  58. uni.$emit('showTabBarBadge')
  59. })
  60. const userStore = useUserStore();
  61. // 分段器选项
  62. const items = reactive(['我的', '待办', '在办', '办结'])
  63. // 分段器选项
  64. const current = ref(0)
  65. // 子组件
  66. const processListRef = ref(null)
  67. // 待办列表
  68. const processes = ref([])
  69. // 分段器点击事件 调用子组件刷新数据
  70. function clickSegmentItem({ currentIndex }) {
  71. processes.value = [] // 清空列表数据
  72. current.value = currentIndex // 更新分段器状态
  73. processListRef.value.onClickItem() // 调用子组件刷新数据
  74. }
  75. // 搜索项
  76. const candidates = ref(['全局', '类型', '创建时间'])
  77. // 搜索栏选中项
  78. const searchItem = ref('全局')
  79. // 搜索项弹出层
  80. const searchItemPopup = ref(null)
  81. // 打开搜索项弹出层
  82. function openPopup() {
  83. searchItemPopup.value.open()
  84. }
  85. // 关闭搜索项弹出层
  86. function closePopup() {
  87. searchItemPopup.value.close()
  88. }
  89. // 选中搜索项
  90. function clickSearchItem(item) {
  91. searchItem.value = item
  92. closePopup()
  93. }
  94. // 搜索
  95. function search(e) {
  96. // console.log('search', e)
  97. }
  98. // 取消搜索
  99. function searchCancel() {
  100. return
  101. }
  102. // 搜索栏失去焦点
  103. function searchOnBlur(e) {
  104. // console.log('searchOnBlur', e);
  105. }
  106. // 获取待办列表数据
  107. function getProcessData({ pageNo, pSize }, callback) {
  108. const params = {
  109. staffId: userStore.user.useId,
  110. page: pageNo,
  111. pageNum: pSize,
  112. modelId: "",
  113. control: 1
  114. }
  115. const requestMap = [
  116. getUserAllProcess, // 我的
  117. getUserProcess, // 待办
  118. getUserProcessing, // 在办
  119. getUserProcessed // 办结
  120. ]
  121. requestMap[current.value](params).then(({ returnParams }) => {
  122. processes.value = returnParams.list
  123. callback(returnParams.list, returnParams.total, pageNo)
  124. })
  125. }
  126. // 分页获取待办列表数据
  127. function getProcessPage({ pageNo, pSize }, callback) {
  128. const params = {
  129. staffId: userStore.user.useId,
  130. page: pageNo,
  131. pageNum: pSize,
  132. modelId: "",
  133. control: 1
  134. }
  135. const requestMap = [
  136. getUserAllProcess, // 我的
  137. getUserProcess, // 待办
  138. getUserProcessing, // 在办
  139. getUserProcessed // 办结
  140. ]
  141. requestMap[current.value](params).then(({ returnParams }) => {
  142. processes.value.push(...returnParams.list)
  143. callback(returnParams.list, returnParams.total, pageNo)
  144. })
  145. }
  146. // 跳转到流程详情页
  147. function handleToProcessDetail({ username, insId, tinsId, insName, control }) {
  148. let url = '/pages/process/detail/index?insId=' + insId + '&insName=' + insName + '&control=' + control
  149. if (tinsId) {
  150. url = url + '&tinsId=' + tinsId
  151. }
  152. $tab.navigateTo(url)
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. @import url("@/static/font/ygoa/iconfont.css");
  157. .search_container {
  158. .popup_button_container {
  159. display: flex;
  160. justify-content: center;
  161. margin-left: 5px;
  162. height: 36px;
  163. line-height: 36px;
  164. width: 100%;
  165. padding-top: 10px;
  166. background-color: #f5f5f5;
  167. text-align: center;
  168. font-size: 16px;
  169. color: #333;
  170. .button_text {
  171. width: 64px;
  172. margin-left: 4px;
  173. }
  174. }
  175. .search_bar {
  176. ::v-deep .uni-searchbar {
  177. padding-left: 0;
  178. }
  179. }
  180. }
  181. .segmented_control_container {}
  182. </style>