selectContract.vue 3.1 KB

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