categoryTwo.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="categoryTwo">
  3. <view class="head">
  4. {{dataInfo.parentName}}
  5. </view>
  6. <view class="body" v-if="dataInfo.list.length">
  7. <view class="body_item ellipsis" v-for="data in dataInfo.list" :key="data.id" @click="toCategoryThree(data)">
  8. {{data.category}}
  9. </view>
  10. </view>
  11. <view class="zanwu" v-else>
  12. <text class="newicon newicon-zanwu"></text>
  13. </view>
  14. <view class="foot_common_btns">
  15. <button @click="goBack" type="default" class="primaryButton btn">上一级</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref, reactive} from 'vue'
  21. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  22. import { api_incidentcategory } from "@/http/api.js"
  23. import { defaultColor } from '@/static/js/theme.js'
  24. import { useSetTitle } from '@/share/useSetTitle.js'
  25. import { useLoginUserStore } from '@/stores/loginUser'
  26. import { useGoBack } from '@/share/useGoBack.js'
  27. useSetTitle();
  28. const loginUserStore = useLoginUserStore();
  29. const { goBack } = useGoBack();
  30. // 主题颜色
  31. const primaryColor = ref(defaultColor)
  32. // 数据
  33. const dataInfo = reactive({
  34. list: [],//工单列表
  35. idx: 0,//页码
  36. hasMore: true,//是否有更多数据
  37. incidentId: undefined,//事件ID
  38. parentId: undefined,//父级故障现象ID
  39. parentName: undefined,//父级故障现象名称
  40. })
  41. // 跳转三级故障现象列表
  42. function toCategoryThree(data){
  43. uni.navigateTo({
  44. url: `/pages/categoryThree/categoryThree?incidentId=${dataInfo.incidentId}&grandParentName=${dataInfo.parentName}&parentId=${data.id}&parentName=${data.category}`
  45. })
  46. }
  47. // 获取列表信息
  48. function getList(idx){
  49. uni.showLoading({
  50. title: "加载中",
  51. mask: true,
  52. });
  53. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  54. if(dataInfo.idx === 0){
  55. dataInfo.list = [];
  56. }
  57. let postData = {
  58. idx: dataInfo.idx,
  59. sum: 20,
  60. incidentcategory: {
  61. parent: {
  62. id: dataInfo.parentId,
  63. },
  64. }
  65. }
  66. // 当前所属院区或责任科室
  67. if(loginUserStore.loginUser.user.duty){
  68. postData.incidentcategory.duty = loginUserStore.loginUser.user.duty.id;
  69. }else if(loginUserStore.loginUser.user.branch){
  70. postData.incidentcategory.branch = loginUserStore.loginUser.user.branch.id;
  71. }
  72. api_incidentcategory(postData).then(res => {
  73. uni.hideLoading();
  74. uni.stopPullDownRefresh();
  75. if(res.status == 200){
  76. let list = res.list || [];
  77. if(list.length){
  78. dataInfo.hasMore = true;
  79. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  80. }else{
  81. dataInfo.hasMore = false;
  82. }
  83. }else{
  84. uni.showToast({
  85. icon: 'none',
  86. title: res.msg || '请求数据失败!'
  87. });
  88. }
  89. })
  90. }
  91. onLoad((option) => {
  92. dataInfo.incidentId = option.incidentId;
  93. dataInfo.parentId = option.parentId;
  94. dataInfo.parentName = option.parentName;
  95. getList(0);
  96. })
  97. onPullDownRefresh(() => {
  98. getList(0)
  99. })
  100. onReachBottom(() => {
  101. dataInfo.idx += 1;
  102. if (dataInfo.hasMore) {
  103. getList(); // 当触底时加载更多数据
  104. }
  105. })
  106. </script>
  107. <style lang="scss" scoped>
  108. .categoryTwo{
  109. display: flex;
  110. flex-direction: column;
  111. justify-content: space-between;
  112. .head{
  113. height: 88rpx;
  114. display: flex;
  115. align-items: center;
  116. padding: 0 24rpx;
  117. position: fixed;
  118. z-index: 99;
  119. width: 100%;
  120. box-sizing: border-box;
  121. background: #fff;
  122. font-size: 26rpx;
  123. color: $uni-primary;
  124. }
  125. .body{
  126. border-top: 1rpx solid #DEDEDE;
  127. margin-bottom: 140rpx;
  128. margin-top: 88rpx;
  129. font-size: 26rpx;
  130. .body_item{
  131. border-bottom: 1rpx solid #DEDEDE;
  132. padding: 24rpx;
  133. }
  134. }
  135. .zanwu{
  136. margin-bottom: 140rpx;
  137. margin-top: 88rpx;
  138. display: flex;
  139. justify-content: center;
  140. .newicon-zanwu{
  141. font-size: 256rpx;
  142. color: #D6D6D6;
  143. margin-top: 140rpx;
  144. }
  145. }
  146. .foot_common_btns{
  147. position: fixed;
  148. left: 0;
  149. bottom: 0;
  150. background-color: #fff;
  151. }
  152. }
  153. </style>