<template>
|
<view>
|
<!-- 搜索框 -->
|
<view class="search-bar">
|
<uni-search-bar v-model="condition" placeholder=" 输入批次/编码/单号" bgColor="#EEEEEE" @confirm="search()"/>
|
</view>
|
|
|
<view>
|
<view class="padding-lr margin-top-sm" style="padding-bottom: 120upx;">
|
<block v-for="(item, index) in matList" :key="index">
|
<view class="cu-list det menu sm-border margin-bottom-sm " :class="[item.selected === true &&'act']" @click="selectedItem(index)">
|
<view class="cu-bar bg-white solid-bottom " >
|
<view class="action">
|
<view class="index">
|
{{index+1}}
|
</view>
|
<view class="text-blue">
|
物料编码:
|
{{`${item.matnrCode}`}}
|
</view>
|
</view>
|
<view class="action">
|
<text v-if="item.selected" class="cuIcon-check text-green" style="font-size: 24px;"></text>
|
<text v-else class="cuIcon-close text-red" style="font-size: 24px;"></text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">物料名称:</text>
|
<text class="text-grey">{{ item.maktx }}</text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">单据编号:</text>
|
</view>
|
<view class="action">
|
<text class="text-grey ">{{item.asnCode}}</text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">计划跟踪号:</text>
|
</view>
|
<view class="action">
|
<text class="text-grey ">{{item.platWorkCode}}</text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">批次:</text>
|
</view>
|
<view class="action">
|
<text class="text-grey ">{{item.splrBatch}}</text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">单位: <text class="text-grey ">{{item.stockUnit}}</text></text>
|
</view>
|
<view class="content">
|
<text class="text-black">收货数量: <text class="text-grey ">{{item.anfme}}</text></text>
|
</view>
|
</view>
|
<view class="cu-item">
|
<view class="content">
|
<text class="text-black">可组盘数量: <text
|
class="text-grey ">{{item.ableQty}}</text></text>
|
</view>
|
</view>
|
|
</view>
|
</block>
|
|
<!-- 空状态 -->
|
<view class="empty-state" v-if="matList.length === 0 && !loading">
|
<uni-icons type="search" size="60" color="#CCCCCC"></uni-icons>
|
<text class="empty-text">暂无数据</text>
|
<text class="empty-hint">下拉刷新试试</text>
|
</view>
|
|
<!-- 加载更多 -->
|
<uni-load-more v-show="matList.length !== 0" :status="status" :icon-size="16" :content-text="contentText" />
|
</view>
|
</view>
|
<view class="cu-bar btn-group foot">
|
<button class="cu-btn bg-blue shadow-blur" :disabled="repeatClick" @click="back">确定</button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
request
|
} from '../../common/request.js'
|
export default {
|
data() {
|
return {
|
matList: [],
|
condition:'',
|
baseUrl: '',
|
token: '',
|
itemStyle: {
|
border: "1px solid #e54d42",
|
},
|
selectedList:[],
|
repeatClick: false,
|
matnrCode:'',
|
asnCode:'',
|
// 分页相关
|
curr: 1,
|
pageSize: 5,
|
loading: false,
|
status: 'more',
|
contentText: {
|
contentdown: '上拉加载更多',
|
contentrefresh: '加载中',
|
contentnomore: '没有更多'
|
},
|
// 保存查询参数
|
lastReq: null
|
}
|
},
|
// 下拉刷新
|
onPullDownRefresh() {
|
this.refreshData();
|
},
|
// 上拉加载更多
|
onReachBottom() {
|
if (this.status !== 'noMore' && !this.loading) {
|
this.status = 'loading';
|
this.loadMoreData();
|
}
|
},
|
onLoad() {
|
// 没啥用了
|
let that = this
|
// const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
|
const eventChannel = this.getOpenerEventChannel();
|
|
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
|
eventChannel.on('data', function(data) {
|
that.getDet(data)
|
})
|
},
|
onShow() {
|
this.baseUrl = uni.getStorageSync('baseUrl');
|
this.token = uni.getStorageSync('token');
|
|
},
|
methods: {
|
// 刷新数据
|
refreshData() {
|
this.curr = 1;
|
this.matList = [];
|
this.status = 'more';
|
if (this.lastReq) {
|
this.getDet(this.lastReq, true);
|
}
|
uni.stopPullDownRefresh();
|
},
|
// 加载更多数据
|
loadMoreData() {
|
if (this.lastReq) {
|
this.getDet(this.lastReq, false);
|
}
|
},
|
search(){
|
let req = {
|
matnrCode: this.condition,
|
asnCode: this.condition,
|
code: this.condition,
|
batch: this.condition
|
}
|
// 搜索时重置分页
|
this.curr = 1;
|
this.matList = [];
|
this.status = 'more';
|
this.getDet(req, true);
|
},
|
back() {
|
for (var i = 0; i < this.matList.length; i++) {
|
if(this.matList[i].selected === true){
|
this.selectedList.push(this.matList[i])
|
}
|
}
|
this.getOpenerEventChannel().emit('backData', {data: this.selectedList});
|
uni.navigateBack({
|
|
})
|
},
|
selectedItem(index){
|
|
if(this.matList[index].selected === '' || this.matList[index].selected === null || this.matList[index].selected === undefined){
|
this.matList[index].selected = true
|
}else{
|
this.matList[index].selected = !this.matList[index].selected
|
}
|
},
|
async getDet(req, isRefresh = true) {
|
let that = this;
|
// 保存查询参数供刷新和加载更多使用
|
this.lastReq = req;
|
this.loading = true;
|
|
if (isRefresh) {
|
uni.showLoading({
|
title:'加载中...'
|
})
|
}
|
|
try {
|
const {
|
code,
|
data,
|
msg
|
} = await request('/asnOrderItem/trackCode', {
|
matnrCode: req.matnrCode,
|
asnCode: req.asnCode,
|
code: req.code,
|
batch: req.batch,
|
curr: this.curr,
|
pageSize: this.pageSize
|
}, "post")
|
|
if (code === 200) {
|
let records = data.records || [];
|
let currentPage = data.current || 1;
|
let totalPages = data.pages || 1;
|
|
// 处理数据
|
for (var i = 0; i < records.length; i++) {
|
records[i].receiptQty = 0;
|
records[i].selected = false;
|
}
|
|
if (records.length > 0) {
|
if (isRefresh) {
|
this.matList = records;
|
} else {
|
this.matList = this.matList.concat(records);
|
}
|
this.curr = this.curr + 1;
|
// 判断是否还有更多数据
|
if (this.curr > totalPages) {
|
this.status = 'noMore';
|
} else {
|
this.status = 'more';
|
}
|
} else {
|
if (isRefresh) {
|
this.matList = [];
|
}
|
this.status = 'noMore';
|
}
|
} else {
|
uni.showToast({
|
title: msg,
|
icon: "none",
|
position: 'top'
|
})
|
}
|
} catch (err) {
|
uni.showToast({
|
title: '网络请求失败',
|
icon: "none",
|
position: 'top'
|
})
|
} finally {
|
this.loading = false;
|
uni.hideLoading();
|
uni.stopPullDownRefresh();
|
}
|
},
|
|
}
|
}
|
</script>
|
|
<style>
|
@import url('../../static/css/wms.css/wms.css');
|
.index {
|
border: 1px solid #e54d42;
|
color: #e54d42;
|
border-radius: 50%;
|
display: block;
|
width: 50rpx;
|
height: 50rpx;
|
line-height: 48rpx;
|
text-align: center;
|
margin-right: 20rpx;
|
font-size: 30rpx;
|
}
|
|
.text-blue {
|
color: #0081ff !important;
|
|
}
|
|
.act {
|
border: 1px solid #e54d42;
|
}
|
|
.item {
|
position: relative;
|
display: flex;
|
min-height: 80upx;
|
align-items: center;
|
}
|
|
/* 空状态 */
|
.empty-state {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
padding: 120rpx 0;
|
}
|
|
.empty-text {
|
font-size: 30rpx;
|
color: #909399;
|
margin-top: 30rpx;
|
}
|
|
.empty-hint {
|
font-size: 24rpx;
|
color: #c0c4cc;
|
margin-top: 12rpx;
|
}
|
</style>
|