search.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view class="home">
  3. <view class="search-area" style="padding:20rpx 0;background-color: #f5f6fa;">
  4. <u-search
  5. placeholder="搜索设备"
  6. v-model="keyword"
  7. shape="square"
  8. :clearabled="true"
  9. :show-action="true"
  10. action-text="搜索"
  11. :animation="true"
  12. search-icon-color="#000"
  13. color="#000"
  14. bgColor="#fff"
  15. height="40"
  16. placeholder-color="#5c5b5b"
  17. @search="search(1,keyword)"
  18. @custom="search(1,keyword)"></u-search>
  19. </view>
  20. <u-empty
  21. :show="emptyShow"
  22. mode="search"
  23. :icon="require('@/static/images/search.png')"
  24. >
  25. </u-empty>
  26. <view v-show="!emptyShow" style="height: 100%;">
  27. <u-list @scrolltolower="scrolltolower" height="100%">
  28. <u-list-item
  29. v-for="(item, index) in dataList"
  30. :key="index"
  31. >
  32. <view class="data-box" @click="toBorrow(item.barCode)">
  33. <view style="display: flex;justify-content: space-between;margin-bottom: 10rpx;">
  34. <view class="data-header">
  35. <image style="width: 40rpx;height: 40rpx;margin-right: 10rpx;"
  36. :src="require('@/static/images/shebeiname1.png')"
  37. mode="aspectFit"></image>
  38. <text>{{item.name}}</text>
  39. </view>
  40. <text :style="{color:`${item.borrowStatus==='可借出'?'#19be6b':item.borrowStatus==='已借出'?'#fa3534':'#ff9900'}`}">{{item.borrowStatus}}</text>
  41. </view>
  42. <view class="data-content">
  43. <text>设备编码:{{item.number}}</text><br/>
  44. <text>设备条形码:{{item.barCode}}</text>
  45. </view>
  46. </view>
  47. </u-list-item>
  48. </u-list>
  49. </view>
  50. <!-- <view v-show="!emptyShow">
  51. <u-cell-group :border="true">
  52. <u-cell
  53. title="设备"
  54. value="状态"
  55. :title-style="{'color': '#000'}"
  56. :value-style="{'color': '#5c5b5b'}"
  57. ></u-cell>
  58. <u-cell
  59. v-for="item in dataList"
  60. :key="item.barCode"
  61. :title="item.name"
  62. :label="item.barCode"
  63. @click="toBorrow(item.barCode)"
  64. >
  65. <view slot="value" class="u-slot-value">
  66. <i class="iconfont icon-yuandian" :style="{color:`${item.borrowStatus==='可借出'?'#19be6b':item.borrowStatus==='已借出'?'#fa3534':'#ff9900'}`}"></i>
  67. <text class="list-name" :style="{color:`${item.borrowStatus==='可借出'?'#19be6b':item.borrowStatus==='已借出'?'#fa3534':'#ff9900'}`}">{{item.borrowStatus}}</text>
  68. </view>
  69. </u-cell>
  70. </u-cell-group>
  71. </view> -->
  72. </view>
  73. </template>
  74. <script>
  75. import { keywordSearch } from "@/api/asset.js"
  76. // searchAsset,
  77. export default {
  78. data() {
  79. return {
  80. keyword:"",
  81. checked:false,
  82. emptyShow:false,
  83. dataList:[],
  84. pageNum:1,
  85. pageSize:5,
  86. total:0
  87. };
  88. },
  89. onLoad:function(option){
  90. this.keyword = option.keyword
  91. },
  92. onShow(){
  93. this.pageNum = 1
  94. this.search(this.pageNum,this.keyword)
  95. },
  96. methods:{
  97. scrolltolower(){
  98. console.log(222222333)
  99. if(Math.ceil(this.total/this.pageSize)<this.pageNum){
  100. return;
  101. }else if(Math.ceil(this.total/this.pageSize)>=this.pageNum){
  102. this.search(this.pageNum,this.keyword)
  103. }
  104. },
  105. search(page,val){
  106. uni.showLoading({
  107. title: "正在加载中",
  108. mask: true
  109. })
  110. try{
  111. if(page===1){
  112. this.dataList=[]
  113. }
  114. keywordSearch(page,this.pageSize,{numberOrName: val}).then(res=>{
  115. uni.hideLoading()
  116. console.log(res.records,111)
  117. if(res.records){
  118. if(res.records.length===0&&page==1){
  119. this.emptyShow = true
  120. }else{
  121. this.emptyShow = false
  122. this.dataList = [...this.dataList,...res.records]
  123. this.pageNum = page + 1
  124. this.total = res.total
  125. }
  126. }
  127. })
  128. // searchAsset({numberOrName: val}).then(res=>{
  129. // if(res.length===0){
  130. // this.emptyShow = true
  131. // }else{
  132. // this.emptyShow = false
  133. // this.dataList = res
  134. // }
  135. // uni.hideLoading()
  136. // })
  137. }catch(err){
  138. uni.hideLoading()
  139. }
  140. },
  141. toBorrow(val){
  142. uni.navigateTo({
  143. url:'/pages/borrow/borrow?number='+val,
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" >
  150. page{
  151. background-color: #f5f6fa;
  152. }
  153. .home{
  154. padding: 0 24rpx 30rpx;
  155. // display: flex;
  156. // flex-direction: column;
  157. height: 100vh;
  158. // box-sizing: border-box;
  159. }
  160. .u-slot-value {
  161. display: flex;
  162. justify-content: center;
  163. align-items: center;
  164. i {
  165. flex: 1
  166. }
  167. text {
  168. flex: 4
  169. }
  170. }
  171. /deep/ .u-cell-group__wrapper{
  172. border-left: 1rpx solid #d6d7d9;
  173. border-right: 1rpx solid #d6d7d9;
  174. }
  175. .data-box{
  176. // border: 1px solid black;
  177. margin: 14rpx 0;
  178. padding: 30rpx;
  179. background-color: #fff;
  180. border-radius: 18rpx;
  181. color: #252525;
  182. .data-header{
  183. display: flex;
  184. align-items: center;
  185. font-size: 36rpx;
  186. letter-spacing: 4rpx;
  187. }
  188. .data-content{
  189. line-height: 160%;
  190. font-size: 30rpx;
  191. }
  192. }
  193. </style>