search.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. @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. searchAsset({numberOrName: val}).then(res=>{
  68. if(res.length===0){
  69. this.emptyShow = true
  70. }else{
  71. this.emptyShow = false
  72. this.dataList = res
  73. }
  74. })
  75. },
  76. toBorrow(val){
  77. uni.navigateTo({
  78. url:'/pages/borrow/borrow?number='+val,
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .home{
  86. padding: 20rpx 20rpx 30rpx;
  87. display: flex;
  88. flex-direction: column;
  89. box-sizing: border-box;
  90. }
  91. /deep/ .u-cell-group__wrapper{
  92. border-left: 1rpx solid #d6d7d9;
  93. border-right: 1rpx solid #d6d7d9;
  94. }
  95. </style>