selectContractNo.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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.contractNo}}
  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.contractNo}}
  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.contractNo}}
  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. }
  41. },
  42. // onShow() {},
  43. // onLoad(options) {
  44. onShow() {
  45. this.newSelectList = uni.getStorageSync('erpContractNoList');
  46. },
  47. onLoad(options) {
  48. this.compId = helper.erpWarehouse.compId
  49. console.log(helper.selectContractNo);
  50. this.getContractNoList()
  51. },
  52. watch: {
  53. inputKeyword(val) {
  54. console.log(this.newList)
  55. this.filterNewList = this.newList.filter(function(item) {
  56. if (item.contractNo.indexOf(val) > -1) {
  57. return item
  58. }
  59. })
  60. }
  61. },
  62. methods: {
  63. confirm(item){
  64. let _list = uni.getStorageSync('erpContractNoList');
  65. if(_list==''){
  66. _list=[]
  67. }
  68. if(_list.length<=20){
  69. _list = _list.filter(function(val) {
  70. if (val.contractNo.indexOf(item) > -1) {
  71. return val
  72. }
  73. })
  74. _list.unshift(item)
  75. }else{
  76. _list.unshift(item).pop(item)
  77. }
  78. uni.setStorageSync('erpContractNoList', _list);
  79. uni.setStorageSync('erpContractNo', item);
  80. console.log(item)
  81. uni.navigateBack({})
  82. },
  83. getContractNoList() {
  84. this.$api.doRequest('get', '/warehouseBaseInfo/selectContractNoList', {
  85. compId: this.compId,
  86. flag: 7,
  87. }).then(res => {
  88. if (res.data.code == 200) {
  89. console.log(res)
  90. this.newList = res.data.data
  91. // this.makeMoreList()
  92. }
  93. })
  94. this.$api.doRequest('get', '/warehouseBaseInfo/selectContractNoList', {
  95. compId: this.compId,
  96. flag: 6,
  97. }).then(res => {
  98. if (res.data.code == 200) {
  99. console.log(res)
  100. this.moreList = res.data.data
  101. // this.makeMoreList()
  102. }
  103. })
  104. },
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .content1 {
  110. background: white;
  111. padding: 20rpx;
  112. border-radius: 0 0 20rpx 20rpx;
  113. }
  114. .content2 {
  115. background: white;
  116. margin-top: 20rpx;
  117. padding: 20rpx;
  118. border-radius: 20rpx 20rpx 0 0;
  119. .title {
  120. font-size: 28rpx;
  121. font-weight: 400;
  122. color: #AFB3BF;
  123. }
  124. .item-contnet {
  125. display: flex;
  126. flex-wrap: wrap;
  127. justify-content: space-between;
  128. }
  129. .item-list {
  130. width: 45%;
  131. background: #F5F6F9;
  132. margin: 20rpx 0;
  133. padding: 10rpx 15rpx;
  134. border-radius: 30rpx;
  135. text-align: center;
  136. }
  137. }
  138. .content3 {
  139. height: calc(100vh - 192rpx);
  140. background: white;
  141. padding: 20rpx;
  142. box-sizing: border-box;
  143. }
  144. .search-item-list {
  145. margin: 20rpx;
  146. border-bottom: 1px solid #EEEEEE;
  147. padding-bottom: 20rpx;
  148. }
  149. </style>