<template>
|
<view class="wrap">
|
<view class="list" :border="false">
|
<view class="content" style="background: #fff;">
|
<view class="row-list">
|
<view style="font-size: 28rpx;color: #909399;margin-right: 10rpx;">
|
工作站:
|
</view>
|
<view class="_content" style="text-align: left;">
|
{{ tailHandle.workstationName }}
|
</view>
|
<view style="margin-right: 30rpx;">
|
<u-icon name="scan" class="scan" @click="goScan"></u-icon>
|
</view>
|
<view >
|
<u-button type="primary" style="width:150rpx;" @click="toWorkstation">选择</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="title">
|
<view>
|
<u-icon class="grid-icon" name="column-line" :size="40" :style="{ color: '#0081ff' }"></u-icon>
|
</view>
|
<view class="text-black text-bold basis-xl">机台物料</view>
|
</view>
|
<scroll-view class="scroll-list mid" scroll-y="true">
|
<div class="tip" v-if="list.length==0">-暂无物料-</div>
|
<view :class="['content',item.isSelected?'select-class':'']" v-for="(item, index) in list" :key="item.id" :index="index" @click="selectRow(item)">
|
<view class="row-list" style="padding-top: 8px;">
|
<view class="_label">
|
零件号:
|
</view>
|
<view class="_content">
|
{{ item.partNo }}
|
</view>
|
</view>
|
<view class="row-list">
|
<view class="_label">
|
零件名称:
|
</view>
|
<view class="_content">
|
{{ item.partName }}
|
</view>
|
</view>
|
<view class="row-list">
|
<view class="_label">
|
SN号:
|
</view>
|
<view class="_content">
|
{{ item.partBatchNo }}
|
</view>
|
</view>
|
<view class="row-list">
|
<view class="_label">
|
ifs批次号:
|
</view>
|
<view class="_content">
|
{{ item.ifsBatchNo }}
|
</view>
|
</view>
|
<view class="row-list">
|
<view class="_label">
|
可用数量:
|
</view>
|
<view class="_content">
|
{{ item.availableStockQuantity+'('+item.unit+')' }}
|
</view>
|
</view>
|
</view>
|
</scroll-view>
|
|
<view class="view-fixed-two bottom">
|
<u-button class="r" size="medium" type="primary" @click="goSubmit">尾料发放</u-button>
|
</view>
|
<scan></scan>
|
<u-modal v-model="showConfirm" content="是否确认将尾料扣除,此操作不可逆!" @confirm="confirm" :show-cancel-button="true"/>
|
</view>
|
</template>
|
<script>
|
import scan from "@/components/scan/scan.vue";
|
export default {
|
components: {
|
scan
|
},
|
data() {
|
return {
|
tailHandle:{
|
workstationId: null,
|
workstationNo: null,
|
workstationName: null
|
},
|
list:[],
|
showConfirm:false
|
};
|
},
|
onLoad() {
|
|
},
|
onShow() {
|
let that = this
|
uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
|
uni.$on('scan', function(data) {
|
//扫码成功后的回调,你可以写自己的逻辑代码在这里
|
console.log('扫码结果:', data.code);
|
// console.log(data.code.replace(/\n/g,'').replace(/\s*/g,''))
|
// console.log('扫码结果1:', JSON.parse(data.code.replace(/\n/g,"").replace(/\s*/g,'')));
|
|
that.loadList(data.code);
|
that.$forceUpdate();
|
})
|
},
|
onNavigationBarButtonTap(e) {
|
this.goScan()
|
},
|
methods: {
|
goScan(){
|
//let scanresult={"part_no":"88.118.1/A0044193","package_code":"TP092022101200001","unit_meas":"跦","wdr":"*","lot_batch_no":"*","qty_arrived":12}
|
//this.scanHandle(JSON.stringify(scanresult))
|
|
uni.scanCode({
|
scanType: ['qrCode'],
|
success: res => {
|
try {
|
console.log('扫码结果:', res);
|
this.scanHandle(res.result)
|
} catch (e) {}
|
}
|
});
|
},
|
//根据机台号,查询机台信息,再查询物料信息
|
scanHandle(workstationNo){
|
if(workstationNo!=''){
|
this.$u.api.pigxFeed.fetchWorkstationList({workstationNo:workstationNo}).then(resp => {
|
|
if (!resp.data.records || resp.data.records.length == 0) {
|
this.$u.toast('【'+workstationNo+'】,未查询到机台信息')
|
}else{
|
let workstationList=resp.data.records
|
let scanWorkstationInfo=workstationList[0]
|
this.tailHandle.workstationId = scanWorkstationInfo.id
|
this.tailHandle.workstationNo = scanWorkstationInfo.workstationNo
|
this.tailHandle.workstationName = scanWorkstationInfo.name
|
this.list=[]
|
this.$u.api.pigxTailHandle.getFeedingStock({workstationId:scanWorkstationInfo.id}).then(res => {
|
let reList = []
|
reList = res.data;
|
if(reList.length!=0)
|
{
|
// 按可用数量排个序
|
reList.sort(this.compare('availableStockQuantity'))
|
reList.forEach((item)=>{
|
this.list.push({
|
locationId:item.locationId,
|
locNo:item.locNo,
|
partBatchNo:item.partBatchNo,
|
partId:item.partId,
|
partNo:item.partNo,
|
partName:item.partName,
|
availableStockQuantity:item.availableStockQuantity,
|
unit:item.unit,
|
ifsBatchNo:item.ifsBatchNo,
|
id:item.id,
|
isSelected:false
|
})
|
})
|
}
|
})
|
}
|
})
|
}else{
|
this.$u.toast('未扫描到机台号')
|
}
|
},
|
selectRow(stock){
|
stock.isSelected=!stock.isSelected
|
/*this.list.forEach((item,index)=>{
|
if(item.id ==stock.id){
|
this.list.splice(index,1)
|
return;
|
}
|
})*/
|
//if(stock.isSelected){
|
//展示在列表最上方
|
// this.list.unshift(stock)
|
//}else{
|
//展示在列表最下方
|
// this.list.push(stock)
|
//}
|
|
},
|
setWorkstation(workstation) {
|
this.list=[]
|
this.tailHandle.workstationId = workstation.id
|
this.tailHandle.workstationNo = workstation.workstationNo
|
this.tailHandle.workstationName = workstation.name
|
this.$u.api.pigxTailHandle.getFeedingStock({workstationId:workstation.id}).then(res => {
|
let reList = []
|
reList = res.data;
|
if(reList.length!=0)
|
{
|
// 按可用数量排个序
|
reList.sort(this.compare('availableStockQuantity'))
|
reList.forEach((item)=>{
|
this.list.push({
|
locationId:item.locationId,
|
locNo:item.locNo,
|
partBatchNo:item.partBatchNo,
|
partId:item.partId,
|
partNo:item.partNo,
|
partName:item.partName,
|
availableStockQuantity:item.availableStockQuantity,
|
unit:item.unit,
|
ifsBatchNo:item.ifsBatchNo,
|
id:item.id,
|
isSelected:false
|
})
|
})
|
}
|
});
|
},
|
toWorkstation() {
|
uni.navigateTo({
|
url: '/pages/product/tailHandle/workstationList'
|
})
|
},
|
loadList(sanCode) {
|
let that = this
|
if(sanCode!="")
|
{
|
//根据扫入的字符串信息,判断扫的是条形码,还是二维码
|
let snNo
|
if (sanCode.indexOf('sn_no') != -1) {
|
// 二维码
|
const scanContentJson = JSON.parse(
|
sanCode.replace(/\n/g, '').replace(/\s*/g, '')
|
)
|
snNo=scanContentJson.sn_no
|
|
} else {
|
// 条形码
|
snNo = sanCode
|
}
|
//根据sn号选中物料
|
let exsitMaterial=this.list.find((item)=>{
|
return item.partBatchNo==snNo
|
})
|
if(exsitMaterial){
|
exsitMaterial.isSelected=true
|
/*this.list.forEach((item,index)=>{
|
if(item.id ==exsitMaterial.id){
|
this.list.splice(index,1)
|
return;
|
}
|
})*/
|
//展示在列表最上方
|
//this.list.unshift(exsitMaterial)
|
|
}
|
}
|
},
|
goSubmit(){
|
this.showConfirm=true
|
},
|
confirm(){
|
let stockIds = []
|
this.list.forEach((item) => {
|
if(item.isSelected){
|
stockIds.push(item.id)
|
}
|
})
|
if(stockIds.length>0){
|
this.$u.api.pigxTailHandle.tailStockIssue(stockIds).then(res => {
|
let reData = res.data;
|
this.$u.toast('尾料发放成功!')
|
this.getWorkstationMaterial(this.tailHandle.workstationId)
|
})
|
}else{
|
this.$u.toast('请选择需发放的物料!')
|
}
|
},
|
getWorkstationMaterial(workstationId){
|
this.list=[]
|
this.$u.api.pigxTailHandle.getFeedingStock({workstationId:workstationId}).then(res => {
|
let reList = []
|
reList = res.data;
|
if(reList.length!=0)
|
{
|
// 按可用数量排个序
|
reList.sort(this.compare('availableStockQuantity'))
|
reList.forEach((item)=>{
|
this.list.push({
|
locationId:item.locationId,
|
locNo:item.locNo,
|
partBatchNo:item.partBatchNo,
|
partId:item.partId,
|
partNo:item.partNo,
|
partName:item.partName,
|
availableStockQuantity:item.availableStockQuantity,
|
unit:item.unit,
|
ifsBatchNo:item.ifsBatchNo,
|
id:item.id,
|
isSelected:false
|
})
|
})
|
}
|
});
|
},
|
compare(pro){
|
return function(obj1, obj2) {
|
const val1 = obj1[pro]
|
const val2 = obj2[pro]
|
if (val2 < val1) {
|
// 正序
|
return 1
|
} else if (val2 > val1) {
|
return -1
|
} else {
|
return 0
|
}
|
}
|
}
|
}
|
};
|
</script>
|
<style lang="scss" scoped>
|
.mid {
|
height: calc(100vh - var(--window-top) - var(--window-bottom) - 286rpx);
|
padding: 30rpx 30rpx 0;
|
box-sizing: border-box;
|
.tip{
|
text-align: center;
|
padding-top: 50rpx;
|
font-size: 30rpx;
|
}
|
.u-card{
|
margin: 0 0 30rpx!important;
|
position: relative;
|
box-shadow: 0px 3px 6px 1px rgba(127, 127, 127, 0.2)!important;
|
&+.u-card{
|
// margin-top: 30rpx!important;
|
}
|
.u-form-item{
|
padding: 2px 0;
|
}
|
}
|
.index{
|
text-align: center;
|
padding-top: 20rpx;
|
}
|
}
|
|
|
.content {
|
font-size: 12px;
|
background-color: #efefef;
|
box-sizing: border-box;
|
border-radius: 14rpx;
|
margin: 8px;
|
padding: 5px 10px;
|
box-shadow: none;
|
position: relative;
|
}
|
|
.title {
|
display: flex;
|
flex-direction: row;
|
}
|
|
.row-list {
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
}
|
|
.row-list ._label {
|
flex: 0.8;
|
color: #909399;
|
}
|
|
.row-list ._content {
|
flex: 1.5;
|
text-align: right;
|
}
|
.bottom {
|
width: 750rpx;
|
height: 90rpx;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
margin-bottom:5rpx ;
|
.u-btn{
|
margin: initial;
|
height: 100%;
|
border-radius: 14rpx;
|
width: 90%;
|
background:#3281FF;
|
}
|
.l{
|
|
}
|
}
|
.scan{
|
width: 60rpx;
|
height: 60rpx;
|
font-size: 60rpx;
|
color: #3281ff;
|
}
|
.select-class{
|
background-color: #9FFF5F;
|
}
|
</style>
|