search.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. :label="item.barCode"
  37. @click="toBorrow(item.barCode)"
  38. >
  39. <!-- :value="item.borrowStatus" :style="{color:`${item.isreturn==='0'?'#439dea':'#000000'}`}"-->
  40. <view slot="value" class="u-slot-value">
  41. <i class="iconfont icon-yuandian" :style="{color:`${item.borrowStatus==='可借出'?'#19be6b':item.borrowStatus==='已借出'?'#fa3534':'#ff9900'}`}"></i>
  42. <text class="list-name" :style="{color:`${item.borrowStatus==='可借出'?'#19be6b':item.borrowStatus==='已借出'?'#fa3534':'#ff9900'}`}">{{item.borrowStatus}}</text>
  43. </view>
  44. </u-cell>
  45. </u-cell-group>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { searchAsset } from "@/api/asset.js"
  51. export default {
  52. data() {
  53. return {
  54. keyword:"",
  55. checked:false,
  56. emptyShow:false,
  57. dataList:[]
  58. };
  59. },
  60. onLoad:function(option){
  61. this.keyword = option.keyword
  62. },
  63. onShow(){
  64. this.search(this.keyword)
  65. },
  66. methods:{
  67. search(val){
  68. uni.showLoading({
  69. title: "正在加载中",
  70. mask: true
  71. })
  72. try{
  73. searchAsset({numberOrName: val}).then(res=>{
  74. if(res.length===0){
  75. this.emptyShow = true
  76. }else{
  77. this.emptyShow = false
  78. this.dataList = res
  79. }
  80. uni.hideLoading()
  81. })
  82. }catch(err){
  83. uni.hideLoading()
  84. }
  85. },
  86. toBorrow(val){
  87. uni.navigateTo({
  88. url:'/pages/borrow/borrow?number='+val,
  89. })
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .home{
  96. padding: 20rpx 20rpx 30rpx;
  97. display: flex;
  98. flex-direction: column;
  99. box-sizing: border-box;
  100. }
  101. .u-slot-value {
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. i {
  106. flex: 1
  107. }
  108. text {
  109. flex: 4
  110. }
  111. }
  112. /deep/ .u-cell-group__wrapper{
  113. border-left: 1rpx solid #d6d7d9;
  114. border-right: 1rpx solid #d6d7d9;
  115. }
  116. </style>