Inventoryentrydetails.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. // if (this.statusFlag == 3) {
  104. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  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.warehouseList=[]
  133. this.currentPage=1
  134. this.warehouse = this.warehouseList1[e[0]].warehouseName
  135. this.baseId = this.warehouseList1[e[0]].id
  136. this.getList()
  137. },
  138. calendarchange(e) {
  139. this.startDate = e.startDate
  140. this.endDate = e.endDate
  141. this.getList()
  142. console.log(e)
  143. },
  144. getList() {
  145. uni.showLoading({
  146. title: "正在加载"
  147. })
  148. // warehouseBaseInfo/selectWarehouseSelf
  149. this.$api.doRequest('get', '/warehousingOrder/selectInfo', {
  150. currentPage: this.currentPage,
  151. pageSize: this.pageSize,
  152. searchKeyWord: this.searchKeyWord,
  153. compId: uni.getStorageSync('pcUserInfo').compId,
  154. baseId: this.baseId,
  155. startDate: this.startDate,
  156. endDate: this.endDate
  157. }).then(res => {
  158. if (res.data.code == 200) {
  159. if (res.data.data.records.length > 0) {
  160. this.show2 = false
  161. for (var i = 0; i < res.data.data.records.length; i++) {
  162. var arr = []
  163. if (res.data.data.records[i].warehousingOrderList) {
  164. var data = res.data.data.records[i].warehousingOrderList
  165. for (let q = 0; q < data.length; q++) {
  166. if (arr.every((item) => {
  167. return item.goodsName != data[q].goodsName
  168. })) {
  169. var list = []
  170. list.push(data[q])
  171. arr.push({
  172. goodsName: data[q].goodsName,
  173. list: list
  174. })
  175. } else {
  176. for (var t = 0; t < arr.length; t++) {
  177. if (arr[t].goodsName = data[q].goodsName) {
  178. arr[t].list.push(data[q])
  179. }
  180. }
  181. }
  182. }
  183. }
  184. for (var q = 0; q < arr.length; q++) {
  185. var weight = 0
  186. var weightedMoisture = 0
  187. var avgCost = 0
  188. for (var t = 0; t < arr[q].list.length; t++) {
  189. weight += arr[q].list[t].inWarehouseWeight
  190. weightedMoisture += (arr[q].list[t].weightedMoisture * arr[q].list[t]
  191. .inWarehouseWeight)
  192. avgCost += (arr[q].list[t].avgCost * arr[q].list[t].inWarehouseWeight)
  193. }
  194. arr[q].weight = weight
  195. arr[q].weightedMoisture = (weightedMoisture / weight).toFixed(2)
  196. arr[q].avgCost = (avgCost / weight).toFixed(2)
  197. }
  198. console.log(arr)
  199. res.data.data.records[i].goodsNameList = arr
  200. }
  201. console.log(res.data.data.records)
  202. if (this.currentPage == 1) {
  203. this.warehouseList = res.data.data.records
  204. } else {
  205. this.warehouseList = this.warehouseList.concat(res.data.data.records)
  206. }
  207. } else {
  208. this.show2 = true
  209. if (this.currentPage == 1) {
  210. this.warehouseList = []
  211. }
  212. }
  213. uni.hideLoading()
  214. } else {
  215. uni.hideLoading()
  216. uni.showToast({
  217. title: "系统异常,请联系管理员",
  218. icon: 'none',
  219. duration: 2000
  220. })
  221. }
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang='scss' scoped>
  228. .contractwrap {
  229. background: #fff;
  230. margin: 20rpx;
  231. padding: 20rpx 20rpx 40rpx 20rpx;
  232. border-radius: 20rpx;
  233. .contractwrap-title {
  234. font-size: 28rpx;
  235. padding: 20rpx;
  236. justify-content: space-between;
  237. align-items: center;
  238. }
  239. .contractwrap-item {
  240. display: flex;
  241. justify-content: space-between;
  242. padding: 10rpx 20rpx;
  243. font-size: 28rpx;
  244. .title {
  245. font-size: 24rpx;
  246. color: #8F8F8F;
  247. }
  248. }
  249. }
  250. .search {
  251. width: 100vw;
  252. background: #fff;
  253. }
  254. .u-search {
  255. width: 94%;
  256. margin: 0 auto !important;
  257. }
  258. </style>