123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <template>
- <view>
- <view class='search'>
- <u-search v-model='searchKeyWord' placeholder='可按货源查找' search-icon-color='#AFB3BF' bg-color='#F5F6F9' :shape='"round"' :clearabled="true" :show-action='false'></u-search>
- </view>
-
- <view style='justify-content: space-between;background:#fff;padding:20rpx;' class='flex'>
- <view @click='show=true'>{{startDate}}~{{endDate}}></view>
- <view @click='show1=true'>{{warehouse?warehouse:'全部仓库'}}></view>
- </view>
- <u-picker mode="selector" @confirm='confirm' v-model="show1" range-key='warehouseName' :default-selector="[0]" :range="warehouseList"></u-picker>
- <u-calendar @change='calendarchange' v-model="show" :mode="mode"></u-calendar>
- <view>
- <view class='contractwrap' v-for='(item,index) in warehouseList'>
- <view class='flex contractwrap-title'>
- <view class='contractNo'>{{item.contractNo}}</view>
- <view class='contractNo'>{{item.issuingTime}}</view>
- </view>
- <view v-for='(item1,index1) in item.goodsNameList ' style='background:#EFFAF4;border-radius:10rpx;'>
- <view style='color:#22C572;padding:20rpx;border-bottom:1rpx solid #D8E8E0;justify-content: space-between;' class='flex'>
- <view style='width:33.3333%;text-align:left;'>{{item1.goodsName}}</view>
- <view style='width:33.3333%;'>均水{{item1.weightedMoisture}}</view>
- <view style='width:33.3333%;text-align:right;'>均价{{item1.avgCost}}</view>
- </view>
- <view v-for='(item2,index2) in item1.list' class='flex contractwrap-item'>
- <view class="title">{{item2.goodsSource}}</view>
- <view>{{item2.inWarehouseWeight}}吨</view>
- </view>
- </view>
-
- </view>
- </view>
- <view v-if='show2' style='text-align:center;background:#F2F6FA;margin-top:20rpx;'>暂无更多数据</view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- startDate:'',
- endDate:'',
- mode:'range',
- show:false,
- show1:false,
- show2:false,
- currentPage:1,
- pageSize:10,
- baseId:'',
- warehouse:'',
- searchKeyWord:'',
- warehouseList:[],
- isLoadMore:false
- }
- },
- onLoad() {
- uni.showLoading({
- title: "正在加载"
- })
- this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelf', {
- compId:uni.getStorageSync('pcUserInfo').compId,
- }).then(res => {
- if(res.data.code==200){
- uni.hideLoading()
- this.warehouseList=res.data.data
- }else{
- uni.hideLoading()
- uni.showToast({
- title: "系统异常,请联系管理员",
- icon: 'none',
- duration: 2000
- })
- }
- })
- },
- onShow() {
- var date=new Date()
- this.startDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+(date.getDate()-1)
- this.endDate=date.getFullYear()+'-'+((date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1))+'-'+date.getDate()
- this.getList()
- },
- onReachBottom() { //上拉触底函数
- // if (this.statusFlag == 3) {
- if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
- this.pageSize += 1
- this.currentPage += 1
- this.getList()
- }
- // }
- },
- methods: {
- confirm(e){
- console.log(e)
- this.warehouse=this.warehouseList[e[0]].warehouseName
- this.baseId=this.warehouseList[e[0]].id
- this.getList()
- },
- calendarchange(e){
- this.startDate=e.startDate
- this.endDate=e.endDate
- this.getList()
- console.log(e)
- },
- getList(){
-
- // warehouseBaseInfo/selectWarehouseSelf
-
- this.$api.doRequest('get', '/warehousingOrder/selectInfo', {
- currentPage: this.currentPage,
- pageSize: this.pageSize,
- searchKeyWord:this.searchKeyWord,
- compId:uni.getStorageSync('pcUserInfo').compId,
- baseId:this.baseId,
- startDate:this.startDate,
- endDate:this.endDate
- }).then(res => {
- if(res.data.code==200){
-
- if(res.data.data.records.length>0){
- this.show2=false
- for (var i = 0; i < res.data.data.records.length; i++) {
- var arr=[]
- if(res.data.data.records[i].warehousingOrderList){
- var data=res.data.data.records[i].warehousingOrderList
- for (let q = 0; q < data.length; q++) {
- if(arr.every((item)=>{return item.goodsName!=data[q].goodsName})){
- var list=[]
- list.push(data[q])
- arr.push({goodsName:data[q].goodsName,list:list})
- }else{
- for (var t = 0; t < arr.length; t++) {
- if(arr[t].goodsName=data[q].goodsName){
- arr[t].list.push(data[q])
- }
- }
- }
- }
- }
- for (var q = 0; q < arr.length; q++) {
- var weight=0
- var weightedMoisture=0
- var avgCost=0
- for (var t = 0; t < arr[q].list.length; t++) {
- weight+=arr[q].list[t].inWarehouseWeight
- weightedMoisture+=(arr[q].list[t].weightedMoisture*arr[q].list[t].inWarehouseWeight)
- avgCost+=(arr[q].list[t].avgCost*arr[q].list[t].inWarehouseWeight)
- }
- arr[q].weight=weight
- arr[q].weightedMoisture=(weightedMoisture/weight).toFixed(2)
- arr[q].avgCost=(avgCost/weight).toFixed(2)
-
- }
- console.log(arr)
- res.data.data.records[i].goodsNameList=arr
- }
- console.log(res.data.data.records)
- if(this.currentPage==1){
- this.warehouseList=res.data.data.records
- }else{
- this.warehouseList=this.warehouseList.concat(res.data.data.records)
- }
- }else{
- this.show2=true
- if(this.currentPage==1){
- this.warehouseList=[]
- }
- }
- }else{
- uni.hideLoading()
- uni.showToast({
- title: "系统异常,请联系管理员",
- icon: 'none',
- duration: 2000
- })
- }
-
- })
- }
- }
- }
- </script>
- <style lang='scss' scoped>
- .contractwrap{
- background:#fff;
- margin:20rpx;
- padding:20rpx 20rpx 40rpx 20rpx;
- border-radius:20rpx;
- .contractwrap-title{
- font-size:28rpx;
- padding:20rpx;
- justify-content: space-between;
- align-items: center;
-
- }
- .contractwrap-item{
- display:flex;
- justify-content: space-between;
- padding:10rpx 20rpx;
- font-size:28rpx;
- .title{
- font-size:24rpx;
- color:#8F8F8F;
- }
- }
- }
- .search{
- width:100vw;
- background:#fff;
- }
- .u-search{
- width:94%;
- margin:0 auto !important;
- }
- </style>
|