<template>
|
<default-header-page-layout ref="page" title="拣货">
|
<view class="page-frame with-action-user-row" :style="{height:pageBodyHeight+'px'}" v-if="pageBodyHeight">
|
<action-user-row />
|
<view class="with-action-user-row-page-content">
|
<!-- step 1 start -->
|
<scan-input-form-item class="forma-item" label="托盘编码" v-model="form.containterNo"
|
:msg="msg.containterNo" :msg-type="msgType.containterNo" @search="onSearchContainter"
|
@clear="onClearContainter" />
|
|
<scan-input-form-item class="forma-item" label="物料二维码" v-model="form.materialId"
|
:msg="msg.materialId" :msg-type="msgType.materialId" @search="selectMaterial(form.materialId)" />
|
|
<uni-view class="p-form-label">拣货明细</uni-view>
|
<sortInfo :sortInfo="this.sortInfo" />
|
<contentCard :materialData="materialData" @handleItemClick="handleItemClick" />
|
</view>
|
</view>
|
|
</view>
|
<template v-slot:footer>
|
<view class="bottom-btns-row">
|
<template>
|
<div class="btn-frame"><u-button type="primary" text="确 定" @click="submint"
|
></u-button></div>
|
<!-- <div class="btn-frame"><u-button type="primary" text=""
|
></u-button></div> -->
|
</template>
|
</view>
|
</template>
|
</default-header-page-layout>
|
</template>
|
|
<script>
|
import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
|
import ActionUserRow from '@/components/ActionUserRow.vue'
|
import ScanInputFormItem from '@/components/ScanInputFormItem.vue'
|
import EasySelectFormItem from '@/components/EasySelectFormItem.vue'
|
import EasyPicker from '@/components/EasyPicker.vue'
|
import contentCard from './modules/contentCard.vue'
|
import sortInfo from './modules/sortingInfo.vue'
|
import {
|
SortInfo,addSortDetail
|
} from '@/api/sorting.js'
|
import { $alert, $successInfo, regexValidate } from '@/static/js/utils/index.js'
|
let initInterVal = null;
|
|
export default {
|
name: 'emptyInPage',
|
components: {
|
DefaultHeaderPageLayout,
|
ActionUserRow,
|
ScanInputFormItem,
|
EasySelectFormItem,
|
EasyPicker,
|
contentCard,
|
sortInfo
|
},
|
data() {
|
return {
|
pageBodyHeight: 0,
|
form: {
|
no: '',
|
},
|
containterNo: null,
|
noData:[],
|
count: 0,
|
sortInfo: {},
|
materialData: [],
|
actionStyle: {
|
backgroundColor: '#F18202',
|
color:'#fff',
|
width: 120 + 'rpx',
|
height: 58 + 'rpx',
|
lineHeight: 58 + 'rpx',
|
borderRadius: 10 + 'rpx',
|
},
|
msg: {
|
containterNo: '',
|
material: '',
|
site: '',
|
},
|
msgType: {
|
containterNo: 'info',
|
material: 'error',
|
site: 'error'
|
},
|
}
|
},
|
computed: {
|
disabled() {
|
return this.noData.filter(item => item.checked).length < 1
|
},
|
},
|
methods: {
|
onClearContainter(){
|
this.sortInfo={}
|
this.materialData=[]
|
},
|
// 获取单据信息
|
async onSearchContainter() {
|
if (!this.form.containterNo) {
|
this.msgType.containterNo = 'error'
|
this.msg.containterNo = '请输入托盘编号!';
|
return false;
|
}
|
// 获取代码
|
try{
|
let {result}=await SortInfo({containerNo:this.form.containterNo})
|
|
this.materialData = result.materialInfos
|
result.selectQuantity = 0;
|
|
this.sortInfo = result
|
this.count = 0
|
|
}catch(e){
|
//TODO handle the exception
|
console.log(e);
|
}
|
},
|
handleItemClick(materialId) {
|
console.log(materialId)
|
this.materialData.forEach((item, i) => {
|
if (item.materialId === materialId && item.checked) {
|
item.checked = false;
|
// this.count =this.count -1 <0 ? 0 : this.count -1;
|
this.sortInfo.selectQuantity = this.sortInfo.selectQuantity -1 < 0 ? 0 : this.sortInfo.selectQuantity -1;
|
}
|
this.materialData = [...this.materialData];
|
});
|
},
|
selectMaterial(data) {
|
if (Array.isArray(this.materialData)) {
|
console.log(this.sortInfo.selectQuantity)
|
if (this.sortInfo.sortQuantity <= this.sortInfo.selectQuantity + this.sortInfo.actualQuantity) {
|
$alert("已达到分拣到数量,分拣已完成");
|
return;
|
}
|
|
let materialNo;
|
if (data.includes("^")) {
|
materialNo = this.QRCodeAnalysis(data);
|
} else {
|
materialNo = data;
|
}
|
|
var flag=this.materialData.some(item=>item.materialId==materialNo);
|
if(!flag) {
|
$alert(`物料${materialNo}不在当前托盘中!`);
|
}
|
|
this.materialData.forEach((item, index) => {
|
if (item.materialId === materialNo && !item.checked) {
|
// this.count +=1;
|
this.sortInfo.selectQuantity += 1;
|
item.checked = true;
|
}
|
});
|
|
// this.sortInfo.actualQuantity += 1;
|
|
this.$nextTick(() => {
|
|
})
|
|
this.materialData.sort((a, b) => {
|
if (a.checked && !b.checked) {
|
return -1;
|
}
|
if (!a.checked && b.checked) {
|
return 1;
|
}
|
return 0;
|
});
|
this.materialData = [...this.materialData];
|
// if (count > this.sortInfo.sortQuantity) {
|
// this.sortInfo.actualQuantity = this.sortInfo.sortQuantity;
|
// } else {
|
// this.sortInfo.actualQuantity = count;
|
// }
|
}
|
},
|
|
|
QRCodeAnalysis(code){
|
if (!code || code.length < 10 || !code.includes("^")) {
|
throw new Error(`传入二维码【${code || ""}】异常,请确认!`);
|
}
|
|
const entity = {};
|
const parts = code.trim().split("^");
|
|
if (parts.length !== 2 || parts[1].length < 10) {
|
throw new Error(`传入二维码【${code || ""}】格式异常,请确认!`);
|
}
|
|
entity.MaterialNo = parts[0];
|
entity.MaterialId = parts[1].substring(4);
|
|
const reg = /[A-Z]$/;
|
if (reg.test(parts[1])) {
|
entity.MaterialBatch = parts[1].substring(4, parts[1].length - 5);
|
} else {
|
entity.MaterialBatch = parts[1].substring(4, parts[1].length - 4);
|
}
|
|
entity.Line = parts[1].substring(0, 4);
|
|
return entity.MaterialId;
|
},
|
|
submint() {
|
const checkMaterials = this.materialData.filter(obj => obj.checked === true);
|
if(checkMaterials==undefined || checkMaterials.length ==0){
|
$alert("请扫描物料码")
|
return;
|
}
|
|
const data = {
|
orderNo: this.sortInfo.orderNo,
|
taskNo: "111",
|
orderDetailId: this.sortInfo.orderDetailId,
|
containerNo: this.sortInfo.containerNo,
|
sourceContainerNo: this.sortInfo.containerNo,
|
sortOrderNo: this.sortInfo.sortOrderNo,
|
addSortDetails: checkMaterials
|
}
|
addSortDetail(data).then(res=>{
|
if(res.code == 200){
|
$successInfo("分拣完成")
|
this.materialData = []
|
this.sortInfo = {},
|
this.form.containterNo = ''
|
this.form.materialId = ''
|
return;
|
} else {
|
$alert("res.message")
|
return;
|
}
|
})
|
},
|
|
clear(){
|
this.form.materialNo=''
|
},
|
/* 页面初始化获取页面body高度的定时器 */
|
startInitInterval(callback) {
|
initInterVal = setInterval(() => {
|
if (this.pageBodyHeight) {
|
this.clearInitInterval()
|
callback && callback()
|
} else {
|
this.pageBodyHeight = this.$refs.page.getBodyHeight()
|
}
|
}, 200)
|
},
|
/* 清除定时器 */
|
clearInitInterval() {
|
try {
|
clearInterval(initInterVal)
|
initInterVal = null
|
} catch (e) {
|
//TODO handle the exception
|
}
|
}
|
},
|
onReady() {
|
this.startInitInterval(() => {
|
/* 页面初始化后需要执行的代码在这边调用 */
|
// this.getData()
|
// this.getLinesOptions()
|
// this.selectOptions.models = getDicList(this.$store,'assemble_taskmodel')
|
})
|
},
|
onUnload() {
|
this.clearInitInterval()
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.p-form-label{
|
font-size: 32px;
|
color: #909193;
|
padding-bottom: 12px;
|
padding-left: 20px;
|
}
|
.bottom-btns-row {
|
display: flex;
|
justify-content: center;
|
padding: 10rpx 10rpx;
|
background-color: #fff;
|
|
.btn-frame {
|
flex:1;
|
box-sizing: border-box;
|
}
|
|
.btn-frame:nth-child(1){
|
margin-right: 10rpx;
|
}
|
|
.left-btn-frame {
|
padding-left: 20rpx;
|
padding-right: 8rpx;
|
}
|
|
.right-btn-frame {
|
padding-right: 20rpx;
|
padding-left: 8rpx;
|
}
|
}
|
|
.forma-item {
|
margin-bottom: 24rpx;
|
}
|
|
.material-item-group {
|
background-color: $uni-bg-color;
|
padding-top: 10rpx;
|
|
.material-list-item {
|
border-bottom: 2rpx solid $uni-border-color;
|
padding-bottom: 10rpx;
|
padding-left: 60rpx;
|
margin-bottom: 10rpx;
|
position: relative;
|
|
&:last-child {
|
border-bottom: 0;
|
}
|
|
.item-row {
|
display: flex;
|
|
&>.label {
|
flex-shrink: 0;
|
color: $u-tips-color;
|
width: 144rpx;
|
}
|
|
&>.content {
|
flex-grow: 1;
|
color: $u-content-color;
|
|
uni-input {
|
font: inherit;
|
color: $u-primary;
|
text-decoration: underline;
|
}
|
}
|
}
|
|
.badge-box {
|
position: absolute;
|
top: 8rpx;
|
left: 8rpx;
|
z-index: 1;
|
}
|
|
.close-btn {
|
$closeBtnSize: 70rpx;
|
width: $closeBtnSize;
|
height: $closeBtnSize;
|
z-index: 1;
|
position: absolute;
|
top: 0rpx;
|
right: 8rpx;
|
background-color: $u-error;
|
opacity: 0.6;
|
border-radius: 25rpx;
|
|
.icon-layer {
|
position: absolute;
|
width: 100%;
|
height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
z-index: 2;
|
}
|
}
|
}
|
}
|
</style>
|