Inventoryentrydetails.vue 8.0 KB

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