Inventoryentrydetails.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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="warehouseList"></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.contractNo}}</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. isLoadMore: false
  55. }
  56. },
  57. onLoad() {
  58. uni.showLoading({
  59. title: "正在加载"
  60. })
  61. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelf', {
  62. compId: uni.getStorageSync('pcUserInfo').compId,
  63. }).then(res => {
  64. if (res.data.code == 200) {
  65. uni.hideLoading()
  66. this.warehouseList = res.data.data
  67. } else {
  68. uni.hideLoading()
  69. uni.showToast({
  70. title: "系统异常,请联系管理员",
  71. icon: 'none',
  72. duration: 2000
  73. })
  74. }
  75. })
  76. },
  77. onShow() {
  78. Date.prototype.format = function(format) {
  79. var o = {
  80. "M+": this.getMonth() + 1, //month
  81. "d+": this.getDate(), //day
  82. "h+": this.getHours(), //hour
  83. "m+": this.getMinutes(), //minute
  84. "s+": this.getSeconds(), //second
  85. "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
  86. "S": this.getMilliseconds() //millisecond
  87. }
  88. if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
  89. (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  90. for (var k in o)
  91. if (new RegExp("(" + k + ")").test(format))
  92. format = format.replace(RegExp.$1,
  93. RegExp.$1.length == 1 ? o[k] :
  94. ("00" + o[k]).substr(("" + o[k]).length));
  95. return format;
  96. }
  97. var day = new Date();
  98. this.endDate = day.format('yyyy-MM-dd'); //今天
  99. this.startDate = new Date(new Date().setDate(new Date().getDate() - 1)).format('yyyy-MM-dd'); //昨天
  100. // this.startDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+(date.getDate()-1)
  101. // this.endDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+date.getDate()
  102. this.getList()
  103. },
  104. onReachBottom() { //上拉触底函数
  105. // if (this.statusFlag == 3) {
  106. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  107. this.pageSize += 1
  108. this.currentPage += 1
  109. this.getList()
  110. }
  111. // }
  112. },
  113. methods: {
  114. format(format) {
  115. var o = {
  116. "M+": this.getMonth() + 1, //month
  117. "d+": this.getDate(), //day
  118. "h+": this.getHours(), //hour
  119. "m+": this.getMinutes(), //minute
  120. "s+": this.getSeconds(), //second
  121. "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
  122. "S": this.getMilliseconds() //millisecond
  123. }
  124. if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
  125. (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  126. for (var k in o)
  127. if (new RegExp("(" + k + ")").test(format))
  128. format = format.replace(RegExp.$1,
  129. RegExp.$1.length == 1 ? o[k] :
  130. ("00" + o[k]).substr(("" + o[k]).length));
  131. return format;
  132. },
  133. confirm(e) {
  134. console.log(e)
  135. this.warehouse = this.warehouseList[e[0]].warehouseName
  136. this.baseId = this.warehouseList[e[0]].id
  137. this.getList()
  138. },
  139. calendarchange(e) {
  140. this.startDate = e.startDate
  141. this.endDate = e.endDate
  142. this.getList()
  143. console.log(e)
  144. },
  145. getList() {
  146. // warehouseBaseInfo/selectWarehouseSelf
  147. this.$api.doRequest('get', '/warehousingOrder/selectInfo', {
  148. currentPage: this.currentPage,
  149. pageSize: this.pageSize,
  150. searchKeyWord: this.searchKeyWord,
  151. compId: uni.getStorageSync('pcUserInfo').compId,
  152. baseId: this.baseId,
  153. startDate: this.startDate,
  154. endDate: this.endDate
  155. }).then(res => {
  156. if (res.data.code == 200) {
  157. if (res.data.data.records.length > 0) {
  158. this.show2 = false
  159. for (var i = 0; i < res.data.data.records.length; i++) {
  160. var arr = []
  161. if (res.data.data.records[i].warehousingOrderList) {
  162. var data = res.data.data.records[i].warehousingOrderList
  163. for (let q = 0; q < data.length; q++) {
  164. if (arr.every((item) => {
  165. return item.goodsName != data[q].goodsName
  166. })) {
  167. var list = []
  168. list.push(data[q])
  169. arr.push({
  170. goodsName: data[q].goodsName,
  171. list: list
  172. })
  173. } else {
  174. for (var t = 0; t < arr.length; t++) {
  175. if (arr[t].goodsName = data[q].goodsName) {
  176. arr[t].list.push(data[q])
  177. }
  178. }
  179. }
  180. }
  181. }
  182. for (var q = 0; q < arr.length; q++) {
  183. var weight = 0
  184. var weightedMoisture = 0
  185. var avgCost = 0
  186. for (var t = 0; t < arr[q].list.length; t++) {
  187. weight += arr[q].list[t].inWarehouseWeight
  188. weightedMoisture += (arr[q].list[t].weightedMoisture * arr[q].list[t]
  189. .inWarehouseWeight)
  190. avgCost += (arr[q].list[t].avgCost * arr[q].list[t].inWarehouseWeight)
  191. }
  192. arr[q].weight = weight
  193. arr[q].weightedMoisture = (weightedMoisture / weight).toFixed(2)
  194. arr[q].avgCost = (avgCost / weight).toFixed(2)
  195. }
  196. console.log(arr)
  197. res.data.data.records[i].goodsNameList = arr
  198. }
  199. console.log(res.data.data.records)
  200. if (this.currentPage == 1) {
  201. this.warehouseList = res.data.data.records
  202. } else {
  203. this.warehouseList = this.warehouseList.concat(res.data.data.records)
  204. }
  205. } else {
  206. this.show2 = true
  207. if (this.currentPage == 1) {
  208. this.warehouseList = []
  209. }
  210. }
  211. } else {
  212. uni.hideLoading()
  213. uni.showToast({
  214. title: "系统异常,请联系管理员",
  215. icon: 'none',
  216. duration: 2000
  217. })
  218. }
  219. })
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang='scss' scoped>
  225. .contractwrap {
  226. background: #fff;
  227. margin: 20rpx;
  228. padding: 20rpx 20rpx 40rpx 20rpx;
  229. border-radius: 20rpx;
  230. .contractwrap-title {
  231. font-size: 28rpx;
  232. padding: 20rpx;
  233. justify-content: space-between;
  234. align-items: center;
  235. }
  236. .contractwrap-item {
  237. display: flex;
  238. justify-content: space-between;
  239. padding: 10rpx 20rpx;
  240. font-size: 28rpx;
  241. .title {
  242. font-size: 24rpx;
  243. color: #8F8F8F;
  244. }
  245. }
  246. }
  247. .search {
  248. width: 100vw;
  249. background: #fff;
  250. }
  251. .u-search {
  252. width: 94%;
  253. margin: 0 auto !important;
  254. }
  255. </style>