selectWarehouse.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="warp">
  3. <view class="content1">
  4. <u-search placeholder="输入仓库名称" :show-action="false" v-model="inputKeyword"></u-search>
  5. </view>
  6. <view class="content2" v-if="!inputKeyword&&newSelectList.length!=0">
  7. <view class="title" v-if="">最新选择</view>
  8. <view class="item-contnet">
  9. <view class="item-list" v-for="(item,index) in newSelectList" :key="index" @click="confirm(item)">
  10. {{item.warehouseName}}
  11. </view>
  12. </view>
  13. </view>
  14. <view class="content2" v-if="!inputKeyword&&moreList.length!=0 ">
  15. <view class="title" v-if="">更多仓库</view>
  16. <view class="item-contnet">
  17. <view class="item-list" v-for="(item,index) in moreList" :key="index" @click="confirm(item)">
  18. {{item.warehouseName}}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="content3" v-if="inputKeyword">
  23. <view class="search-item-list" v-for="(item,index) in filterNewList" :key="index" @click="confirm(item)">
  24. {{item.warehouseName}}
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import helper from '@/common/helper.js';
  31. export default {
  32. data() {
  33. return {
  34. inputKeyword: '',
  35. newList: [],
  36. newSelectList:[],
  37. filterNewList: [],
  38. moreList:[],
  39. compId: '',
  40. warehouseType:"",
  41. }
  42. },
  43. onShow() {
  44. this.newSelectList = uni.getStorageSync('theWarehouseList');
  45. },
  46. onLoad(options) {
  47. this.warehouseType = options.warehouseType
  48. // this.compId = helper.theWarehouse.compId
  49. this.getWarehouse()
  50. },
  51. watch: {
  52. inputKeyword(val) {
  53. this.filterNewList = this.newList.filter(function(item) {
  54. if (item.warehouseName.indexOf(val) > -1) {
  55. return item
  56. }
  57. })
  58. }
  59. },
  60. methods: {
  61. confirm(item){
  62. let _list = uni.getStorageSync('theWarehouseList');
  63. if(_list==''){
  64. _list=[]
  65. }
  66. if(_list.length<=20){
  67. _list = _list.filter(function(val) {
  68. if (val.warehouseName!=item.warehouseName) {
  69. return val
  70. }
  71. })
  72. _list.unshift(item)
  73. }else{
  74. _list.unshift(item).pop(item)
  75. }
  76. uni.setStorageSync('theWarehouseList', _list);
  77. uni.setStorageSync('theWarehouse', item);
  78. uni.navigateBack({
  79. delta: 1
  80. })
  81. },
  82. getWarehouse() {
  83. var that = this
  84. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
  85. compId: uni.getStorageSync("pcUserInfo").compId,
  86. warehouseType: '1'
  87. }).then(res => {
  88. if (res.data.data.length != 0) {
  89. that.newList = res.data.data
  90. that.moreList = res.data.data
  91. }
  92. })
  93. },
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. .content1 {
  99. background: white;
  100. padding: 20rpx;
  101. border-radius: 0 0 20rpx 20rpx;
  102. }
  103. .content2 {
  104. background: white;
  105. margin-top: 20rpx;
  106. padding: 20rpx;
  107. border-radius: 20rpx 20rpx 0 0;
  108. .title {
  109. font-size: 28rpx;
  110. font-weight: 400;
  111. color: #AFB3BF;
  112. }
  113. .item-contnet {
  114. display: flex;
  115. flex-wrap: wrap;
  116. justify-content: space-between;
  117. }
  118. .item-list {
  119. width: 45%;
  120. background: #F5F6F9;
  121. margin: 20rpx 0;
  122. padding: 10rpx 15rpx;
  123. border-radius: 30rpx;
  124. text-align: center;
  125. }
  126. }
  127. .content3 {
  128. height: calc(100vh - 192rpx);
  129. background: white;
  130. padding: 20rpx;
  131. box-sizing: border-box;
  132. }
  133. .search-item-list {
  134. margin: 20rpx;
  135. border-bottom: 1px solid #EEEEEE;
  136. padding-bottom: 20rpx;
  137. }
  138. </style>