index.vue 5.3 KB

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