selectContractNo.vue 3.7 KB

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