index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="switchRecord-container">
  3. <!--顶部导航栏-->
  4. <scroll-view class="scroll-view" scroll-x="true" @scroll="scroll">
  5. <view class="scroll-view-item" v-for="(tab,index) in tabBars" :key="tab.id" :id="tab.id" :class="navIndex==index ? 'activite' : ''" @tap="checkIndex(index)">
  6. {{tab.name}}
  7. </view>
  8. </scroll-view>
  9. <!-- 内容 -->
  10. <swiper :current="navIndex" @change="tabChange" class="swiper_content">
  11. <swiper-item class="swiper_item">
  12. <FeedbackList :status="status" :listArray="listArray" @click="onClick" @nextPage="onNextPage" />
  13. </swiper-item>
  14. <swiper-item class="swiper_item">
  15. <FeedbackList :listArray="listArray" @click="onClick" @nextPage="onNextPage" />
  16. </swiper-item>
  17. <swiper-item class="swiper_item">
  18. <FeedbackList :listArray="listArray" @click="onClick" @nextPage="onNextPage" />
  19. </swiper-item>
  20. <swiper-item class="swiper_item">
  21. <FeedbackList :listArray="listArray" @click="onClick" @nextPage="onNextPage" />
  22. </swiper-item>
  23. </swiper>
  24. <!-- 新增 -->
  25. <view class="feedback-add-icon" @click="onClickAdd">
  26. <image class="add-icon" src="/static/image/add-icon.svg" mode="aspectFit"></image>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup lang="ts">
  31. import { ref,onMounted } from "vue"
  32. import * as link from '@/lib/link'
  33. import rest from '@/stores/rest'
  34. import { formatDate } from '@/lib/util'
  35. import FeedbackList from './FeedbackList.vue'
  36. const queryParams = ref({
  37. pageNo: 1,
  38. pageSize: 10,
  39. fkzt: '',
  40. })
  41. const scrollTop = ref(0)
  42. const navIndex = ref(0)
  43. const tabBars = ref([
  44. {
  45. name:'全部',
  46. id: 0
  47. },
  48. {
  49. name:'待受理',
  50. id: 1
  51. },
  52. {
  53. name:'受理中 ',
  54. id: 2
  55. },
  56. {
  57. name:'已办结 ',
  58. id: 3
  59. }
  60. ])
  61. const scroll = (e: any) => {
  62. console.log("scroll",e);
  63. scrollTop.value = e.detail.scrollTop;
  64. };
  65. const checkIndex = (idx:number) => {
  66. if (navIndex.value !== idx){
  67. navIndex.value = idx;
  68. switch (idx) {
  69. case 0:
  70. queryParams.value.fkzt = ''
  71. break;
  72. case 1:
  73. queryParams.value.fkzt = '1'
  74. break;
  75. case 2:
  76. queryParams.value.fkzt = '2'
  77. break;
  78. case 3:
  79. queryParams.value.fkzt = '3'
  80. break;
  81. }
  82. queryParams.value.pageNo = 1
  83. list.value = []
  84. console.log("内容")
  85. getList()
  86. }
  87. }
  88. const tabChange = async(e:any) => {
  89. let _idx = e.detail.current
  90. checkIndex(_idx)
  91. }
  92. const listArray = ref([])
  93. const list = ref() //处方列表
  94. const total = ref(0)
  95. const status = ref('loading')
  96. const getList = async () => {
  97. try {
  98. console.log("此时的",queryParams.value)
  99. // loaded.value = true;
  100. let res = await rest.get('/admin-api/zyyp/feedback/page', queryParams.value)
  101. let _list = res.list
  102. if (queryParams.value.pageNo === 1) {
  103. list.value = _list;
  104. } else {
  105. list.value = list.value.concat(_list);
  106. }
  107. getFormattedData(list.value)
  108. total.value = res.total
  109. if (res.total && queryParams.value.pageNo >= total.value / queryParams.value.pageSize) {
  110. status.value = "noMore"
  111. }
  112. } catch (e) {
  113. } finally {
  114. }
  115. }
  116. const titleArray = [
  117. { title: '办件编号', key: 'id' },
  118. { title: '登记时间', key: 'createTime' },
  119. ];
  120. const getFormattedData = (listData) => {
  121. const formattedData = listData.map(item => {
  122. const formattedItem = titleArray.map(titleItem => {
  123. let value = item[titleItem.key];
  124. if (titleItem.key === 'createTime') {
  125. value = formatDate(item[titleItem.key], '{y}-{m}-{d} {h}:{i}:{s}');
  126. }
  127. return {
  128. title: titleItem.title,
  129. value: value
  130. };
  131. });
  132. return {
  133. ...item,
  134. title: '中医用药一件事反馈登记',
  135. formattedData: formattedItem ,
  136. };
  137. });
  138. listArray.value = formattedData;
  139. };
  140. const onNextPage = ()=> {
  141. if (!list.value || queryParams.value.pageNo > (total.value / queryParams.value.pageSize)) {
  142. return false;
  143. }
  144. if (queryParams.value.pageNo < total.value / queryParams.value.pageSize) {
  145. status.value = "loading";
  146. } else {
  147. status.value = "noMore"
  148. return;
  149. }
  150. queryParams.value.pageNo++;
  151. getList();
  152. }
  153. const onClick = (e)=> {
  154. link.goBJDetails(e.id)
  155. }
  156. const onClickAdd = ()=> {
  157. link.goBJDetails()
  158. }
  159. // 页面每次加载
  160. onMounted(() => {
  161. getList()
  162. })
  163. </script>
  164. <style lang="scss">
  165. .switchRecord-container {
  166. display: flex;
  167. background-color: #f2f2f2;
  168. flex-direction: column;
  169. height: calc(100vh - 120rpx);
  170. position: relative;
  171. .scroll-view {
  172. background-color: #fff;
  173. color: #3D3D3D;
  174. display: flex;
  175. overflow-x: auto;
  176. white-space: nowrap;
  177. box-sizing: border-box;
  178. }
  179. .scroll-view-item {
  180. display: inline-block;
  181. width: calc(100% / 4);
  182. height: 88rpx;
  183. line-height: 88rpx;
  184. text-align: center;
  185. font-size: 24rpx;
  186. font-weight: 350;
  187. position: relative; /* 添加相对定位 */
  188. box-sizing: border-box; /* 确保边框在总宽度内计算 */
  189. &::after {
  190. content: '';
  191. display: inline-block;
  192. width: 50%; /* 默认宽度为50% */
  193. margin: 0 auto;
  194. position: absolute;
  195. bottom: 0;
  196. left: 25%; /* 使其居中 */
  197. height: 2rpx; /* 默认未选中的高度 */
  198. background: #fff; /* 默认未选中的颜色 */
  199. z-index: 1;
  200. }
  201. &.activite {
  202. color: #1E92F0;
  203. &::after {
  204. background: #1E92F0;
  205. height: 4rpx;
  206. width: 50%;
  207. }
  208. }
  209. }
  210. .swiper_content {
  211. background-color: #f2f2f2;
  212. flex: 1;
  213. }
  214. .feedback-add-icon {
  215. position: absolute;
  216. bottom: 300rpx;
  217. right: 32rpx;
  218. width: 120rpx;
  219. height: 120rpx;
  220. @include flex-center;
  221. border-radius: 50%;
  222. background-color: #fff;
  223. box-shadow: 0px 4px 10px 0px rgba(216, 216, 216, 0.8),inset 0px 4px 10px 0px rgba(216, 216, 216, 0.3);
  224. .add-icon {
  225. width: 60rpx;
  226. height: 60rpx;
  227. }
  228. }
  229. }
  230. </style>