index.vue 4.3 KB

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