Inventoryentrydetails.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view>
  3. <view class='search'>
  4. <u-search v-model='searchKeyWord' placeholder='可按货源查找' search-icon-color='#AFB3BF' bg-color='#F5F6F9' :shape='"round"' :clearabled="true" :show-action='false'></u-search>
  5. </view>
  6. <view style='justify-content: space-between;background:#fff;padding:20rpx;' class='flex'>
  7. <view @click='show=true'>{{startDate}}~{{endDate}}></view>
  8. <view @click='show1=true'>{{warehouse?warehouse:'全部仓库'}}></view>
  9. </view>
  10. <u-picker mode="selector" @confirm='confirm' v-model="show1" range-key='warehouseName' :default-selector="[0]" :range="warehouseList"></u-picker>
  11. <u-calendar @change='calendarchange' v-model="show" :mode="mode"></u-calendar>
  12. <view>
  13. <view class='contractwrap' v-for='(item,index) in warehouseList'>
  14. <view class='flex contractwrap-title'>
  15. <view class='contractNo'>{{item.contractNo}}</view>
  16. <view class='contractNo'>{{item.issuingTime}}</view>
  17. </view>
  18. <view v-for='(item1,index1) in item.goodsNameList ' style='background:#EFFAF4;border-radius:10rpx;'>
  19. <view style='color:#22C572;padding:20rpx;border-bottom:1rpx solid #D8E8E0;justify-content: space-between;' class='flex'>
  20. <view style='width:33.3333%;text-align:left;'>{{item1.goodsName}}</view>
  21. <view style='width:33.3333%;'>均水{{item1.weightedMoisture}}</view>
  22. <view style='width:33.3333%;text-align:right;'>均价{{item1.avgCost}}</view>
  23. </view>
  24. <view v-for='(item2,index2) in item1.list' class='flex contractwrap-item'>
  25. <view class="title">{{item2.goodsSource}}</view>
  26. <view>{{item2.inWarehouseWeight}}吨</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view v-if='show2' style='text-align:center;background:#F2F6FA;margin-top:20rpx;'>暂无更多数据</view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. startDate:'',
  39. endDate:'',
  40. mode:'range',
  41. show:false,
  42. show1:false,
  43. show2:false,
  44. currentPage:1,
  45. pageSize:10,
  46. baseId:'',
  47. warehouse:'',
  48. searchKeyWord:'',
  49. warehouseList:[],
  50. isLoadMore:false
  51. }
  52. },
  53. onLoad() {
  54. uni.showLoading({
  55. title: "正在加载"
  56. })
  57. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelf', {
  58. compId:uni.getStorageSync('pcUserInfo').compId,
  59. }).then(res => {
  60. if(res.data.code==200){
  61. uni.hideLoading()
  62. this.warehouseList=res.data.data
  63. }else{
  64. uni.hideLoading()
  65. uni.showToast({
  66. title: "系统异常,请联系管理员",
  67. icon: 'none',
  68. duration: 2000
  69. })
  70. }
  71. })
  72. },
  73. onShow() {
  74. var date=new Date()
  75. this.startDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+(date.getDate()-1)
  76. this.endDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+date.getDate()
  77. this.getList()
  78. },
  79. onReachBottom() { //上拉触底函数
  80. // if (this.statusFlag == 3) {
  81. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  82. this.pageSize += 1
  83. this.currentPage += 1
  84. this.getList()
  85. }
  86. // }
  87. },
  88. methods: {
  89. confirm(e){
  90. console.log(e)
  91. this.warehouse=this.warehouseList[e[0]].warehouseName
  92. this.baseId=this.warehouseList[e[0]].id
  93. this.getList()
  94. },
  95. calendarchange(e){
  96. this.startDate=e.startDate
  97. this.endDate=e.endDate
  98. this.getList()
  99. console.log(e)
  100. },
  101. getList(){
  102. // warehouseBaseInfo/selectWarehouseSelf
  103. this.$api.doRequest('get', '/warehousingOrder/selectInfo', {
  104. currentPage: this.currentPage,
  105. pageSize: this.pageSize,
  106. searchKeyWord:this.searchKeyWord,
  107. compId:uni.getStorageSync('pcUserInfo').compId,
  108. baseId:this.baseId,
  109. startDate:this.startDate,
  110. endDate:this.endDate
  111. }).then(res => {
  112. if(res.data.code==200){
  113. if(res.data.data.records.length>0){
  114. this.show2=false
  115. for (var i = 0; i < res.data.data.records.length; i++) {
  116. var arr=[]
  117. if(res.data.data.records[i].warehousingOrderList){
  118. var data=res.data.data.records[i].warehousingOrderList
  119. for (let q = 0; q < data.length; q++) {
  120. if(arr.every((item)=>{return item.goodsName!=data[q].goodsName})){
  121. var list=[]
  122. list.push(data[q])
  123. arr.push({goodsName:data[q].goodsName,list:list})
  124. }else{
  125. for (var t = 0; t < arr.length; t++) {
  126. if(arr[t].goodsName=data[q].goodsName){
  127. arr[t].list.push(data[q])
  128. }
  129. }
  130. }
  131. }
  132. }
  133. for (var q = 0; q < arr.length; q++) {
  134. var weight=0
  135. var weightedMoisture=0
  136. var avgCost=0
  137. for (var t = 0; t < arr[q].list.length; t++) {
  138. weight+=arr[q].list[t].inWarehouseWeight
  139. weightedMoisture+=(arr[q].list[t].weightedMoisture*arr[q].list[t].inWarehouseWeight)
  140. avgCost+=(arr[q].list[t].avgCost*arr[q].list[t].inWarehouseWeight)
  141. }
  142. arr[q].weight=weight
  143. arr[q].weightedMoisture=(weightedMoisture/weight).toFixed(2)
  144. arr[q].avgCost=(avgCost/weight).toFixed(2)
  145. }
  146. console.log(arr)
  147. res.data.data.records[i].goodsNameList=arr
  148. }
  149. console.log(res.data.data.records)
  150. if(this.currentPage==1){
  151. this.warehouseList=res.data.data.records
  152. }else{
  153. this.warehouseList=this.warehouseList.concat(res.data.data.records)
  154. }
  155. }else{
  156. this.show2=true
  157. if(this.currentPage==1){
  158. this.warehouseList=[]
  159. }
  160. }
  161. }else{
  162. uni.hideLoading()
  163. uni.showToast({
  164. title: "系统异常,请联系管理员",
  165. icon: 'none',
  166. duration: 2000
  167. })
  168. }
  169. })
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang='scss' scoped>
  175. .contractwrap{
  176. background:#fff;
  177. margin:20rpx;
  178. padding:20rpx 20rpx 40rpx 20rpx;
  179. border-radius:20rpx;
  180. .contractwrap-title{
  181. font-size:28rpx;
  182. padding:20rpx;
  183. justify-content: space-between;
  184. align-items: center;
  185. }
  186. .contractwrap-item{
  187. display:flex;
  188. justify-content: space-between;
  189. padding:10rpx 20rpx;
  190. font-size:28rpx;
  191. .title{
  192. font-size:24rpx;
  193. color:#8F8F8F;
  194. }
  195. }
  196. }
  197. .search{
  198. width:100vw;
  199. background:#fff;
  200. }
  201. .u-search{
  202. width:94%;
  203. margin:0 auto !important;
  204. }
  205. </style>