Inventoryentrydetails.vue 8.0 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.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. isLoadMore: false
  55. }
  56. },
  57. onLoad() {
  58. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelfApp', {
  59. compId: uni.getStorageSync('pcUserInfo').compId,
  60. }).then(res => {
  61. if (res.data.code == 200) {
  62. // uni.hideLoading()
  63. this.warehouseList = res.data.data
  64. } else {
  65. // uni.hideLoading()
  66. uni.showToast({
  67. title: "系统异常,请联系管理员",
  68. icon: 'none',
  69. duration: 2000
  70. })
  71. }
  72. })
  73. },
  74. onShow() {
  75. Date.prototype.format = function(format) {
  76. var o = {
  77. "M+": this.getMonth() + 1, //month
  78. "d+": this.getDate(), //day
  79. "h+": this.getHours(), //hour
  80. "m+": this.getMinutes(), //minute
  81. "s+": this.getSeconds(), //second
  82. "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
  83. "S": this.getMilliseconds() //millisecond
  84. }
  85. if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
  86. (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  87. for (var k in o)
  88. if (new RegExp("(" + k + ")").test(format))
  89. format = format.replace(RegExp.$1,
  90. RegExp.$1.length == 1 ? o[k] :
  91. ("00" + o[k]).substr(("" + o[k]).length));
  92. return format;
  93. }
  94. var day = new Date();
  95. this.endDate = day.format('yyyy-MM-dd'); //今天
  96. this.startDate = new Date(new Date().setDate(new Date().getDate() - 1)).format('yyyy-MM-dd'); //昨天
  97. // this.startDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+(date.getDate()-1)
  98. // this.endDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+date.getDate()
  99. this.getList()
  100. },
  101. onReachBottom() { //上拉触底函数
  102. // if (this.statusFlag == 3) {
  103. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  104. this.pageSize += 1
  105. this.currentPage += 1
  106. this.getList()
  107. }
  108. // }
  109. },
  110. methods: {
  111. format(format) {
  112. var o = {
  113. "M+": this.getMonth() + 1, //month
  114. "d+": this.getDate(), //day
  115. "h+": this.getHours(), //hour
  116. "m+": this.getMinutes(), //minute
  117. "s+": this.getSeconds(), //second
  118. "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
  119. "S": this.getMilliseconds() //millisecond
  120. }
  121. if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
  122. (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  123. for (var k in o)
  124. if (new RegExp("(" + k + ")").test(format))
  125. format = format.replace(RegExp.$1,
  126. RegExp.$1.length == 1 ? o[k] :
  127. ("00" + o[k]).substr(("" + o[k]).length));
  128. return format;
  129. },
  130. confirm(e) {
  131. console.log(e)
  132. this.warehouse = this.warehouseList[e[0]].warehouseName
  133. this.baseId = this.warehouseList[e[0]].id
  134. this.getList()
  135. },
  136. calendarchange(e) {
  137. this.startDate = e.startDate
  138. this.endDate = e.endDate
  139. this.getList()
  140. console.log(e)
  141. },
  142. getList() {
  143. uni.showLoading({
  144. title: "正在加载"
  145. })
  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. uni.hideLoading()
  212. } else {
  213. uni.hideLoading()
  214. uni.showToast({
  215. title: "系统异常,请联系管理员",
  216. icon: 'none',
  217. duration: 2000
  218. })
  219. }
  220. })
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang='scss' scoped>
  226. .contractwrap {
  227. background: #fff;
  228. margin: 20rpx;
  229. padding: 20rpx 20rpx 40rpx 20rpx;
  230. border-radius: 20rpx;
  231. .contractwrap-title {
  232. font-size: 28rpx;
  233. padding: 20rpx;
  234. justify-content: space-between;
  235. align-items: center;
  236. }
  237. .contractwrap-item {
  238. display: flex;
  239. justify-content: space-between;
  240. padding: 10rpx 20rpx;
  241. font-size: 28rpx;
  242. .title {
  243. font-size: 24rpx;
  244. color: #8F8F8F;
  245. }
  246. }
  247. }
  248. .search {
  249. width: 100vw;
  250. background: #fff;
  251. }
  252. .u-search {
  253. width: 94%;
  254. margin: 0 auto !important;
  255. }
  256. </style>