search.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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="http://cdn.uviewui.com/uview/empty/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. :title-style="{'color': '#000'}"
  39. :value-style="{'color': '#5c5b5b'}"
  40. @click="toBorrow(item.barCode)"
  41. ></u-cell>
  42. </u-cell-group>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { searchAsset } from "@/api/asset.js"
  48. export default {
  49. data() {
  50. return {
  51. keyword:"",
  52. checked:false,
  53. emptyShow:false,
  54. dataList:[]
  55. };
  56. },
  57. onLoad:function(option){
  58. this.keyword = option.keyword
  59. this.search(this.keyword)
  60. },
  61. onShow(){
  62. this.search(this.keyword)
  63. },
  64. methods:{
  65. search(val){
  66. searchAsset({numberOrName: val}).then(res=>{
  67. if(res.length===0){
  68. this.emptyShow = true
  69. }else{
  70. this.emptyShow = false
  71. this.dataList = res
  72. }
  73. })
  74. },
  75. toBorrow(val){
  76. uni.navigateTo({
  77. url:'/pages/borrow/borrow?number='+val,
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .home{
  85. padding: 20rpx 20rpx 30rpx;
  86. display: flex;
  87. flex-direction: column;
  88. box-sizing: border-box;
  89. }
  90. /deep/ .u-cell-group__wrapper{
  91. border-left: 1rpx solid #d6d7d9;
  92. border-right: 1rpx solid #d6d7d9;
  93. }
  94. </style>