Inventoryentrydetails.vue 8.2 KB

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