categoryOne.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="categoryOne">
  3. <view class="head">
  4. 请选择故障类型
  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="toCategoryTwo(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. })
  39. // 跳转二级故障现象列表
  40. function toCategoryTwo(data){
  41. uni.navigateTo({
  42. url: `/pages/categoryTwo/categoryTwo?incidentId=${dataInfo.incidentId}&parentId=${data.id}&parentName=${data.category}`
  43. })
  44. }
  45. // 获取列表信息
  46. function getList(idx){
  47. uni.showLoading({
  48. title: "加载中",
  49. mask: true,
  50. });
  51. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  52. if(dataInfo.idx === 0){
  53. dataInfo.list = [];
  54. }
  55. let postData = {
  56. idx: dataInfo.idx,
  57. sum: 20,
  58. incidentcategory: {
  59. selectType: 'one',
  60. }
  61. }
  62. // 当前所属院区或责任科室
  63. if(loginUserStore.loginUser.user.duty){
  64. postData.incidentcategory.duty = loginUserStore.loginUser.user.duty.id;
  65. }else if(loginUserStore.loginUser.user.branch){
  66. postData.incidentcategory.branch = loginUserStore.loginUser.user.branch.id;
  67. }
  68. api_incidentcategory(postData).then(res => {
  69. uni.hideLoading();
  70. uni.stopPullDownRefresh();
  71. if(res.status == 200){
  72. let list = res.list || [];
  73. if(list.length){
  74. dataInfo.hasMore = true;
  75. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  76. }else{
  77. dataInfo.hasMore = false;
  78. }
  79. }else{
  80. uni.showToast({
  81. icon: 'none',
  82. title: res.msg || '请求数据失败!'
  83. });
  84. }
  85. })
  86. }
  87. onLoad((option) => {
  88. dataInfo.incidentId = option.incidentId;
  89. getList(0);
  90. })
  91. onPullDownRefresh(() => {
  92. getList(0)
  93. })
  94. onReachBottom(() => {
  95. dataInfo.idx += 1;
  96. if (dataInfo.hasMore) {
  97. getList(); // 当触底时加载更多数据
  98. }
  99. })
  100. </script>
  101. <style lang="scss" scoped>
  102. .categoryOne{
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: space-between;
  106. .head{
  107. height: 88rpx;
  108. display: flex;
  109. align-items: center;
  110. padding: 0 24rpx;
  111. position: fixed;
  112. z-index: 99;
  113. width: 100%;
  114. box-sizing: border-box;
  115. background: #fff;
  116. font-size: 26rpx;
  117. color: $uni-primary;
  118. }
  119. .body{
  120. border-top: 1rpx solid #DEDEDE;
  121. margin-bottom: 140rpx;
  122. margin-top: 88rpx;
  123. font-size: 26rpx;
  124. .body_item{
  125. border-bottom: 1rpx solid #DEDEDE;
  126. padding: 24rpx;
  127. }
  128. }
  129. .zanwu{
  130. margin-bottom: 140rpx;
  131. margin-top: 88rpx;
  132. display: flex;
  133. justify-content: center;
  134. .newicon-zanwu{
  135. font-size: 256rpx;
  136. color: #D6D6D6;
  137. margin-top: 140rpx;
  138. }
  139. }
  140. .foot_common_btns{
  141. position: fixed;
  142. left: 0;
  143. bottom: 0;
  144. background-color: #fff;
  145. }
  146. }
  147. </style>