selectPolling.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="consumableList">
  3. <view class="head">
  4. <uni-search-bar v-model="dataInfo.keyWord" :placeholder="placeHolder" bgColor="#F8F8F8" @input="search" cancelButton="none" focus :radius="18" />
  5. </view>
  6. <view class="body" v-if="dataInfo.list.length">
  7. <view class="body_item ellipsis" :class="dataInfo.index == index ? 'activeClass' :''" v-for="(data, index) in dataInfo.list" :key="data.id" @click="clickItem(data,index)">
  8. {{data.name}}
  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="goBackPage" type="default" class="primaryButton btn">确定</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { debounce } from 'lodash-es'
  21. import { ref, reactive} from 'vue'
  22. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  23. import { api_inspectionNode } from "@/http/api.js"
  24. import { defaultColor } from '@/static/js/theme.js'
  25. import { useSetTitle } from '@/share/useSetTitle.js'
  26. import { useLoginUserStore } from '@/stores/loginUser'
  27. import { useIncidentBuildStore } from '@/stores/incidentBuild'
  28. import { useGoBack } from '@/share/useGoBack.js'
  29. useSetTitle();
  30. const loginUserStore = useLoginUserStore();
  31. const incidentBuildStore = useIncidentBuildStore();
  32. const { goBack } = useGoBack();
  33. // 主题颜色
  34. const primaryColor = ref(defaultColor)
  35. const placeHolder = ref('请搜索巡检点');
  36. const entranceType = ref(null);
  37. // 院区id
  38. const branchId = ref(null);
  39. // 数据
  40. const dataInfo = reactive({
  41. list: [],//工单列表
  42. idx: 0,//页码
  43. hasMore: true,//是否有更多数据
  44. incidentData: {},//事件对象
  45. keyWord: '',//搜索的关键词
  46. item:null,
  47. index:null
  48. })
  49. // 搜索
  50. const search = debounce(getList.bind(null, 0), 500);
  51. // 获取列表信息
  52. function getList(idx){
  53. if(dataInfo.keyWord.trim() === ''){
  54. dataInfo.list = [];
  55. return;
  56. }
  57. uni.showLoading({
  58. title: "加载中",
  59. mask: true,
  60. });
  61. let postData = {
  62. idx: dataInfo.idx,
  63. sum: 9999,
  64. inspectionNode: {
  65. hosId: loginUserStore.loginUser.user.currentHospital.id,
  66. name: dataInfo.keyWord
  67. }
  68. }
  69. api_inspectionNode(postData).then(res => {
  70. uni.hideLoading();
  71. if(res.status == 200){
  72. let list = res.list || [];
  73. if(list.length){
  74. dataInfo.hasMore = true;
  75. dataInfo.list = 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. function goBackPage(){
  88. if(!dataInfo.item){
  89. uni.showToast({
  90. icon: 'none',
  91. title: '请选择巡检点!'
  92. });
  93. return
  94. }
  95. let data = JSON.stringify(dataInfo.item)
  96. uni.navigateTo({
  97. url: '/pages/setPolling/setPolling?data=' + data
  98. })
  99. }
  100. // 点击
  101. function clickItem(data,index){
  102. dataInfo.index = index
  103. dataInfo.item = data;
  104. console.log(444,dataInfo.item)
  105. }
  106. onLoad((option) => {
  107. getList(0);
  108. })
  109. onPullDownRefresh(() => {
  110. })
  111. onReachBottom(() => {
  112. })
  113. </script>
  114. <style lang="scss" scoped>
  115. .consumableList{
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: space-between;
  119. .head{
  120. height: 88rpx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. padding: 0 24rpx;
  125. position: fixed;
  126. z-index: 99;
  127. width: 100%;
  128. box-sizing: border-box;
  129. background: linear-gradient( 90deg, #58CF66 0%, #DDE9FC 100%);
  130. }
  131. .body{
  132. margin-bottom: 140rpx;
  133. margin-top: 88rpx;
  134. font-size: 26rpx;
  135. .body_item{
  136. border-bottom: 1rpx solid #DEDEDE;
  137. padding: 24rpx;
  138. }
  139. .activeClass{
  140. color: #49b856;
  141. }
  142. }
  143. .zanwu{
  144. margin-bottom: 140rpx;
  145. margin-top: 88rpx;
  146. display: flex;
  147. justify-content: center;
  148. .newicon-zanwu{
  149. font-size: 256rpx;
  150. color: #D6D6D6;
  151. margin-top: 140rpx;
  152. }
  153. }
  154. .foot_common_btns{
  155. position: fixed;
  156. left: 0;
  157. bottom: 0;
  158. background-color: #fff;
  159. }
  160. }
  161. </style>