searchSub.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view id="searchSub">
  3. <view class="top-max-big-box">
  4. <view class="search-box">
  5. <img class="img-view" :src="imagesUrl('commonality/icon_aqjc_ss.png')">
  6. <input type="text" v-model="searchValue" placeholder="实验室名称" maxlength="20">
  7. <view class="button-view" @click="searchButton()">搜索</view>
  8. </view>
  9. </view>
  10. <scroll-view scroll-y @scrolltolower="scrollGet" class="list">
  11. <view class="for-sub-box" v-for="(item,index) in dataList" :key="index">
  12. <view class="for-text-box">{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</view>
  13. <view class="for-right-button" @click="checkSub(item)">
  14. <view></view>
  15. <view>选择</view>
  16. <view></view>
  17. </view>
  18. </view>
  19. <view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
  20. <view class="get-data-null-p" v-else="getDataType">- 滑动加载更多 -</view>
  21. </scroll-view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. systemSubjectGetAppSubjectByLogin
  27. } from '@/pages_manage/api/index.js'
  28. export default {
  29. data() {
  30. return {
  31. searchValue:'',
  32. getDataType: false,
  33. getData: {
  34. page: 1,
  35. pageSize: 20,
  36. },
  37. dataList: [],
  38. total: 0,
  39. }
  40. },
  41. onLoad(option) {
  42. // if(option.subName){
  43. // //有查询过
  44. // this.$set(this,'data1',option.subName);
  45. // this.scrollGet();
  46. // }else{
  47. // //无查询过
  48. // this.scrollGet();
  49. // }
  50. },
  51. onShow() {
  52. },
  53. mounted() {
  54. this.getList();
  55. },
  56. methods: {
  57. //选择实验室
  58. checkSub(item){
  59. uni.setStorageSync('searchSubData', JSON.stringify(item));
  60. uni.navigateBack();
  61. },
  62. //滚动加载事件
  63. scrollGet() {
  64. let self = this;
  65. if (self.total / self.getData.pageSize <= self.getData.page) {
  66. this.$set(this, 'getDataType', true);
  67. } else {
  68. this.getData.page += 1;
  69. this.$nextTick(() => {
  70. this.getList();
  71. })
  72. }
  73. },
  74. //获取实验室
  75. async getList() {
  76. let self = this;
  77. let obj = JSON.parse(JSON.stringify(this.getData))
  78. obj.searchValue = this.searchValue
  79. const {
  80. data
  81. } = await systemSubjectGetAppSubjectByLogin(obj);
  82. if (data.code == 200) {
  83. if (self.getData.page == 1) {
  84. this.dataList = data.data.records;
  85. this.total = data.data.total;
  86. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  87. this.$set(this, 'getDataType', true);
  88. }
  89. } else {
  90. this.dataList = [...this.dataList, ...data.data.records]
  91. this.total = data.data.total;
  92. if (data.data.total / self.getData.pageSize <= self.getData.page) {
  93. this.$set(this, 'getDataType', true);
  94. }
  95. }
  96. }
  97. },
  98. // 搜索按钮
  99. searchButton() {
  100. this.$set(this.getData,'page',1);
  101. this.getList();
  102. },
  103. },
  104. }
  105. </script>
  106. <style lang="stylus" scoped>
  107. #searchSub {
  108. height: 100%;
  109. display flex;
  110. flex-direction column;
  111. .top-max-big-box {
  112. width: 750rpx;
  113. height: 120rpx;
  114. background: #FFFFFF;
  115. padding: 20rpx 30rpx;
  116. box-sizing: border-box;
  117. .search-box {
  118. width: 690rpx;
  119. height: 78rpx;
  120. border: 1rpx solid #E0E0E0;
  121. border-radius: 50rpx;
  122. display: flex;
  123. .img-view {
  124. display: inline-block;
  125. margin: 27rpx 17rpx 0 37rpx;
  126. width: 26rpx;
  127. height: 26rpx;
  128. }
  129. input {
  130. height: 78rpx;
  131. line-height: 78rpx;
  132. flex: 1;
  133. font-size: 24rpx;
  134. }
  135. .button-view {
  136. width: 100rpx;
  137. line-height: 78rpx;
  138. text-align: center;
  139. font-size: 24rpx;
  140. color: #0183FA;
  141. }
  142. }
  143. }
  144. .list {
  145. flex: 1;
  146. overflow-y scroll;
  147. padding: 0 30rpx;
  148. box-sizing: border-box;
  149. padding-bottom: 160rpx;
  150. margin-top:20rpx;
  151. background-color: #fff;
  152. .for-sub-box{
  153. display: flex;
  154. border-bottom: 1rpx dashed #E0E0E0;
  155. .for-text-box{
  156. flex:1;
  157. line-height:42rpx;
  158. padding:40rpx 0 40rpx 0;
  159. }
  160. .for-right-button{
  161. width:100rpx;
  162. display: flex;
  163. flex-direction: column;
  164. view:nth-child(1){
  165. flex:1;
  166. }
  167. view:nth-child(2){
  168. line-height:42rpx;
  169. text-align: right;
  170. color:#0183FA;
  171. font-size:28rpx;
  172. }
  173. view:nth-child(3){
  174. flex:1;
  175. }
  176. }
  177. }
  178. .get-data-null-p {
  179. text-align: center;
  180. line-height: 100rpx;
  181. padding-bottom: 80px;
  182. color: #999;
  183. }
  184. }
  185. }
  186. </style>