123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <template>
- <view>
- <view class='search'>
- <u-search @custom='search' v-model='searchKeyWord' placeholder='可按货源查找' search-icon-color='#AFB3BF' bg-color='#F5F6F9'
- :shape='"round"' :clearabled="true" ></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="warehouseList1"></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.warehouseName}}</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: [],
- warehouseList1:[],
- searchKeyWord:'',
- isLoadMore: false
- }
- },
- onLoad() {
- this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelfApp', {
- compId: uni.getStorageSync('pcUserInfo').compId,
- }).then(res => {
- if (res.data.code == 200) {
- // uni.hideLoading()
- this.warehouseList1 = res.data.data
- } else {
- // uni.hideLoading()
- uni.showToast({
- title: "系统异常,请联系管理员",
- icon: 'none',
- duration: 2000
- })
- }
- })
- },
- onShow() {
- Date.prototype.format = function(format) {
- var o = {
- "M+": this.getMonth() + 1, //month
- "d+": this.getDate(), //day
- "h+": this.getHours(), //hour
- "m+": this.getMinutes(), //minute
- "s+": this.getSeconds(), //second
- "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
- "S": this.getMilliseconds() //millisecond
- }
- if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
- (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(format))
- format = format.replace(RegExp.$1,
- RegExp.$1.length == 1 ? o[k] :
- ("00" + o[k]).substr(("" + o[k]).length));
- return format;
- }
- var day = new Date();
- this.endDate = day.format('yyyy-MM-dd'); //今天
- this.startDate = new Date(new Date().setDate(new Date().getDate() - 1)).format('yyyy-MM-dd'); //昨天
- // 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.show2) { //此处判断,上锁,防止重复请求
- this.currentPage += 1
- this.getList()
- }
- // }
- },
- methods: {
- search(e){
- this.searchKeyWord=e
- this.show2=false
- this.warehouseList=[]
- this.currentPage=1
- this.getList()
- },
- format(format) {
- var o = {
- "M+": this.getMonth() + 1, //month
- "d+": this.getDate(), //day
- "h+": this.getHours(), //hour
- "m+": this.getMinutes(), //minute
- "s+": this.getSeconds(), //second
- "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
- "S": this.getMilliseconds() //millisecond
- }
- if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
- (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(format))
- format = format.replace(RegExp.$1,
- RegExp.$1.length == 1 ? o[k] :
- ("00" + o[k]).substr(("" + o[k]).length));
- return format;
- },
- confirm(e) {
- this.show2=false
- console.log(e)
- this.warehouseList=[]
- this.currentPage=1
- this.warehouse = this.warehouseList1[e[0]].warehouseName
- this.baseId = this.warehouseList1[e[0]].id
- this.getList()
- },
- calendarchange(e) {
- this.startDate = e.startDate
- this.endDate = e.endDate
- this.getList()
- console.log(e)
- },
- getList() {
- uni.showLoading({
- title: "正在加载"
- })
- // 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,
- searchKeyWord:this.searchKeyWord
- }).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 = []
- }
- }
- uni.hideLoading()
- } 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>
|