index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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="onClickItem" styleType="text"
  26. activeColor="#409eff"></uni-segmented-control>
  27. </view>
  28. <view class="process_list">
  29. <process-list :processes="processes"></process-list>
  30. </view>
  31. <view class="popup_container">
  32. <uni-popup ref="searchItemPopup" type="bottom">
  33. <uni-list>
  34. <uni-list-item @click="clickSearchItem(item)" v-for="(item, index) in candidates" :key="index" clickable
  35. :title="item">
  36. </uni-list-item>
  37. </uni-list>
  38. </uni-popup>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import processList from '@/components/ygoa/processList.vue'
  44. import { onMounted, reactive, ref } from 'vue';
  45. // 分段器选项
  46. const items = reactive(['我的', '待办', '在办', '办结'])
  47. // 待办列表
  48. let processes = reactive([])
  49. // 分段器选项
  50. const current = ref(-1)
  51. // 搜索项
  52. const candidates = ref(['全局', '请假日期', '天数'])
  53. // 搜索栏选中项
  54. const searchItem = ref('全局')
  55. onMounted(() => {
  56. onClickItem({ currentIndex: 0 })
  57. })
  58. // 搜索项弹出层
  59. const searchItemPopup = ref(null)
  60. function openPopup() { // 打开搜索项弹出层
  61. searchItemPopup.value.open()
  62. }
  63. function closePopup() { // 关闭搜索项弹出层
  64. searchItemPopup.value.close()
  65. }
  66. function clickSearchItem(item) { // 选中搜索项
  67. searchItem.value = item
  68. closePopup()
  69. }
  70. function search(e) { // 搜索
  71. console.log('search', e)
  72. }
  73. function searchCancel() { // 取消搜索
  74. return
  75. }
  76. function searchOnBlur(e) { // 搜索栏失去焦点
  77. console.log('searchOnBlur', e);
  78. }
  79. function onClickItem({ currentIndex }) { // 点击分段器选项
  80. current.value = currentIndex
  81. switch (currentIndex) {
  82. case 0: // 我的
  83. case 1: // 待办
  84. case 2: // 在办
  85. processes = [
  86. {
  87. id: 1,
  88. title: '账户1 的请假申请',
  89. user: '账户1',
  90. createTime: '2024/10/10',
  91. startTime: '2024/10/10',
  92. endTime: '2024/10/12',
  93. totalTime: '2',
  94. description: '请假说明请假说明请假说明请假说明请假说明',
  95. type: 'icon-apply-leave',
  96. step: 0
  97. },
  98. {
  99. id: 1,
  100. title: '账户2 的请假申请',
  101. user: '账户2',
  102. createTime: '2024/10/10',
  103. startTime: '2024/10/10',
  104. endTime: '2024/10/12',
  105. totalTime: '2',
  106. description: '请假说明请假说明',
  107. type: 'icon-apply-leave',
  108. step: 0
  109. },
  110. {
  111. id: 2,
  112. title: '账户2 的加班申请',
  113. user: '账户2',
  114. createTime: '2024/10/10',
  115. startTime: '2024/10/10 17/30/00',
  116. endTime: '2024/10/10 18/30/00',
  117. totalTime: '1',
  118. description: '加班说明加班说明',
  119. type: 'icon-apply-overtime',
  120. step: 0
  121. }
  122. ]
  123. break;
  124. // case 1:
  125. // processes = []
  126. // break;
  127. // case 2:
  128. // processes = []
  129. // break;
  130. case 3: // 办结
  131. processes = []
  132. break;
  133. }
  134. }
  135. </script>
  136. <style lang="scss">
  137. @import url("@/static/font/ygoa/iconfont.css");
  138. .ygoa-icon {
  139. font-size: 3rem;
  140. }
  141. .search_container {
  142. .popup_button_container {
  143. width: 100%;
  144. padding-top: 10px;
  145. .button {
  146. font-size: 14px;
  147. font-weight: bold;
  148. color: #ffffff;
  149. background-color: #1aad19;
  150. height: 36px;
  151. width: 100%;
  152. }
  153. }
  154. .search_bar {
  155. ::v-deep .uni-searchbar {
  156. padding-left: 0;
  157. }
  158. }
  159. }
  160. .segmented_control_container {}
  161. </style>