search.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="home">
  3. <view class="search-area" style="margin-bottom: 20rpx;">
  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. placeholder-color="#5c5b5b"
  15. @search="search(keyword)"
  16. @custom="search(keyword)"></u-search>
  17. </view>
  18. <u-empty
  19. :show="emptyShow"
  20. mode="search"
  21. :icon="require('@/static/images/search.png')"
  22. >
  23. </u-empty>
  24. <view v-show="!emptyShow">
  25. <u-cell-group :border="true">
  26. <u-cell
  27. title="设备"
  28. value="状态"
  29. :title-style="{'color': '#000'}"
  30. :value-style="{'color': '#5c5b5b'}"
  31. ></u-cell>
  32. <u-cell
  33. v-for="item in dataList"
  34. :key="item.barCode"
  35. :title="item.name"
  36. :value="item.borrowStatus"
  37. :label="item.barCode"
  38. @click="toBorrow(item.barCode)"
  39. ></u-cell>
  40. </u-cell-group>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { searchAsset } from "@/api/asset.js"
  46. export default {
  47. data() {
  48. return {
  49. keyword:"",
  50. checked:false,
  51. emptyShow:false,
  52. dataList:[]
  53. };
  54. },
  55. onLoad:function(option){
  56. this.keyword = option.keyword
  57. },
  58. onShow(){
  59. this.search(this.keyword)
  60. },
  61. methods:{
  62. search(val){
  63. uni.showLoading({
  64. title: "正在加载中",
  65. mask: true
  66. })
  67. try{
  68. searchAsset({numberOrName: val}).then(res=>{
  69. if(res.length===0){
  70. this.emptyShow = true
  71. }else{
  72. this.emptyShow = false
  73. this.dataList = res
  74. }
  75. uni.hideLoading()
  76. })
  77. }catch(err){
  78. uni.hideLoading()
  79. }
  80. },
  81. toBorrow(val){
  82. uni.navigateTo({
  83. url:'/pages/borrow/borrow?number='+val,
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .home{
  91. padding: 20rpx 20rpx 30rpx;
  92. display: flex;
  93. flex-direction: column;
  94. box-sizing: border-box;
  95. }
  96. /deep/ .u-cell-group__wrapper{
  97. border-left: 1rpx solid #d6d7d9;
  98. border-right: 1rpx solid #d6d7d9;
  99. }
  100. </style>