categoryOne.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: 9999,
  58. category: {hierarchy: 1}
  59. // incidentcategory: {
  60. // selectType: 'one',
  61. // }
  62. }
  63. // 当前所属院区或责任科室
  64. // if(loginUserStore.loginUser.user.duty){
  65. // postData.incidentcategory.duty = loginUserStore.loginUser.user.duty.id;
  66. // }else if(loginUserStore.loginUser.user.branch){
  67. // postData.incidentcategory.branch = loginUserStore.loginUser.user.branch.id;
  68. // }
  69. api_incidentcategory(postData).then(res => {
  70. uni.hideLoading();
  71. uni.stopPullDownRefresh();
  72. if(res.status == 200){
  73. dataInfo.list = res.data || [];
  74. // if(list.length){
  75. // dataInfo.hasMore = true;
  76. // dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  77. // }else{
  78. // dataInfo.hasMore = false;
  79. // }
  80. }else{
  81. uni.showToast({
  82. icon: 'none',
  83. title: res.msg || '请求数据失败!'
  84. });
  85. }
  86. })
  87. }
  88. onLoad((option) => {
  89. dataInfo.incidentId = option.incidentId;
  90. getList(0);
  91. })
  92. onPullDownRefresh(() => {
  93. // getList(0)
  94. })
  95. onReachBottom(() => {
  96. // dataInfo.idx += 1;
  97. // if (dataInfo.hasMore) {
  98. // getList(); // 当触底时加载更多数据
  99. // }
  100. })
  101. </script>
  102. <style lang="scss" scoped>
  103. .categoryOne{
  104. display: flex;
  105. flex-direction: column;
  106. justify-content: space-between;
  107. .head{
  108. height: 88rpx;
  109. display: flex;
  110. align-items: center;
  111. padding: 0 24rpx;
  112. position: fixed;
  113. z-index: 99;
  114. width: 100%;
  115. box-sizing: border-box;
  116. background: #fff;
  117. font-size: 26rpx;
  118. color: $uni-primary;
  119. }
  120. .body{
  121. border-top: 1rpx solid #DEDEDE;
  122. margin-bottom: 140rpx;
  123. margin-top: 88rpx;
  124. font-size: 26rpx;
  125. .body_item{
  126. border-bottom: 1rpx solid #DEDEDE;
  127. padding: 24rpx;
  128. }
  129. }
  130. .zanwu{
  131. margin-bottom: 140rpx;
  132. margin-top: 88rpx;
  133. display: flex;
  134. justify-content: center;
  135. .newicon-zanwu{
  136. font-size: 256rpx;
  137. color: #D6D6D6;
  138. margin-top: 140rpx;
  139. }
  140. }
  141. .foot_common_btns{
  142. position: fixed;
  143. left: 0;
  144. bottom: 0;
  145. background-color: #fff;
  146. }
  147. }
  148. </style>