<template>
|
<view>
|
<cu-custom bgColor="bg-white" :isBack="true">
|
<block slot="backText">
|
</block>
|
<block slot="content">人工组盘</block>
|
</cu-custom>
|
<view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
|
<text class="fontSize12rpx"> 操作人:{{operator}} </text>
|
</view>
|
<u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
|
<u-row class="border_bottom padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="容器编号:" prop="containerCode" required style="font-size: 16px;font-weight: bold;padding: 0;">
|
<u-input v-model.trim="warehouse.containerCode" @focus="warehouse.containerCode = ''" @blur="containerBlur" placeholder="请扫码录入" style="font-weight: bolder;margin-left: 15rpx;" class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
</u-row>
|
<u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="物料编号:" style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
|
<u-input v-model="warehouse.materialCode" ref="materialRef" placeholder="请扫码录入" @focus="warehouse.materialCode = ''" @blur="getMaterialDetails" style="font-weight: bolder;margin-left: 15rpx;"
|
class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
</u-row>
|
</u-form>
|
<modal-code :rescode='rescode' :resmessage='resmessage' ref="resmodal" />
|
<view style="margin-bottom: 200rpx;" v-show="singlist.length > 0">
|
<view v-for="(item, eindex) in singlist" :key="eindex" style="width: 100vw;display: flex;">
|
<u-swipe-action :show="item.show" :index="eindex" @click="longpress"
|
@open="open" @close='close' :options="options" style="margin-bottom: 10rpx;width: 100vw;">
|
<view class="title-wrap fontSize32rpx background_fff" :class="parseInt(item.quantity) > 0 ? 'bg_item' : '' " style="width: 100vw;">
|
<u-row>
|
<u-col span="1">
|
<text class="flex justify-center align-center" style="background-color: #f18202;color: #fff;border-radius: 50vh;width: 20px;height: 20px;">
|
{{eindex+1}}
|
</text>
|
</u-col>
|
<u-col span="10">
|
<text class="color_f18202">
|
物料编号:{{item.code}}
|
</text>
|
</u-col>
|
</u-row>
|
<u-row style="margin-top: 20rpx;">
|
<u-col span="8">
|
<text class="el_batchNo">
|
批次:{{item.batchNo}}
|
</text>
|
</u-col>
|
<u-col span="4">
|
<input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx" v-model="item.quantity"
|
type="number" @blur="changeNum(item)" :min="1" placeholder="请输入组盘数量" />
|
<!-- <text class="el_batchNo">
|
组盘数量:{{item.quantity}}
|
</text> -->
|
</u-col>
|
</u-row>
|
</view>
|
</u-swipe-action>
|
</view>
|
</view>
|
<u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom">
|
<view class="pop ">
|
<h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料编号</text>
|
<text>{{materlist.code}}</text>
|
</view>
|
|
<view class="line flex justify-between">
|
<text class="text-gray">物料名称</text>
|
<text>{{materlist.name}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料类型</text>
|
<text>{{materlist.wareMaterialTypeName}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料规格</text>
|
<text>{{materlist.specificationModel}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">长(mm)</text>
|
<text>{{materlist.long}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">宽(mm)</text>
|
<text>{{materlist.width}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">高(mm)</text>
|
<text>{{materlist.high}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">重量(kg)</text>
|
<text>{{materlist.weight}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">单位</text>
|
<text>{{materlist.unit}}</text>
|
</view>
|
</view>
|
</u-popup>
|
<button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='确认组盘' @allsubmit="reset" @submit='submit'/>
|
</view>
|
</template>
|
<script>
|
import ButtonModal from '../../components/buttonModal.vue'
|
import ModalCode from '../../components/ModalCode.vue'
|
import {getOrderNo,addGroupDisk,getMaterialList, getContainDetail, getContainerRecord} from '../../api/putIn/artificial.js'
|
import {getDate} from '../../utils/dateTime.js'
|
import {getAttrValue} from '../../utils/tool.js'
|
export default {
|
data() {
|
return {
|
rescode: 0,
|
resmessage: "",
|
putCode: '', //容器二维码
|
detailshow: false,
|
operator: '',
|
focu: false, //清空按钮隐显
|
focuM: false, //物料隐显按钮
|
Datetime: getDate(),
|
singlist: [], //物料详情
|
options: [{
|
text: '详情',
|
style: {
|
backgroundColor: '#fc9f35'
|
}
|
},
|
{
|
text: '删除',
|
style: {
|
backgroundColor: '#fc4b4b'
|
}
|
}
|
],
|
materlist: {},
|
warehouse: {
|
containerCode: '',
|
materialCode: '',
|
},
|
batchNo: '', //扫码到的当前物料的批次
|
warehouseRules: {
|
containerCode: [{
|
required: true,
|
message: '容器编号不能为空',
|
trigger: 'blur'
|
}],
|
// gridNumber: [{required: true,message: '栅格总数不能为空',trigger: 'blur'}],
|
// exitNumber:[{required: true,message: '本次占用数量不能为空',trigger: 'blur'}],
|
materialCode: [{
|
required: true,
|
message: '物料编号不能为空',
|
trigger: 'blur'
|
}]
|
}
|
|
};
|
},
|
components: {
|
ButtonModal,
|
ModalCode
|
},
|
onReady() {
|
this.$refs.warehouseRef.setRules(this.warehouseRules)
|
},
|
mounted() {
|
this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
|
this.getOrderNo()
|
},
|
computed: {
|
containerCode(){
|
return this.warehouse.containerCode
|
}
|
},
|
methods: {
|
//容器失焦事件
|
containerBlur(){
|
Promise.all([this.getContainerRecord(), this.getContainerData()])
|
},
|
//获取当前容器下组盘记录
|
getContainerRecord(){
|
if(this.warehouse.containerCode.length < 5) {
|
return
|
}
|
getContainerRecord({ContainerCode: this.warehouse.containerCode}).then(res => {
|
if(Array.isArray(res.data) && res.data.length > 0) {
|
this.putCode = res.data[0].orderNo;
|
const recordArr = res.data.reduce((curr,item)=>{
|
curr.push({
|
code: item.wareMaterialCode,
|
batchNo:item.batchNo,
|
quantity:item.quantity,
|
show: false
|
})
|
return curr
|
},[])
|
this.singlist.push(...recordArr)
|
}
|
})
|
|
},
|
//获取容器的信息
|
getContainerData() {
|
if(this.warehouse.containerCode.length < 5) {
|
return
|
}
|
getContainDetail(this.warehouse.containerCode).then(res => {
|
const result = res.data.rows;
|
if(!Array.isArray(result) || result.length !== 1) {
|
this.rescode = 400
|
this.resmessage = '容器信息查询失败'
|
this.$refs.resmodal.show = true
|
}
|
|
})
|
},
|
//入库单号
|
getOrderNo() {
|
getOrderNo().then((res) => {
|
if (res.code == 200) {
|
this.putCode = res.data
|
} else {
|
this.$refs.resmodal.show = true
|
}
|
})
|
},
|
//物料查询
|
getMaterialDetails() {
|
if(!this.warehouse.materialCode) {
|
uni.showModal({
|
title: '提示',
|
content: '物料编号不能为空',
|
showCancel: false
|
})
|
return
|
}
|
if(this.warehouse.materialCode.length > 50) {
|
this.batchNo = getAttrValue(this.warehouse.materialCode,'LOTNO')
|
//扫描的物料是否有批次
|
if(!this.batchNo) {
|
this.rescode = 400
|
this.resmessage = '无批次'
|
this.$refs.resmodal.show = true
|
return
|
}
|
this.warehouse.materialCode = getAttrValue(this.warehouse.materialCode,'PARTSNUMBER')
|
if(this.singlist.length > 0) {
|
//判断当次扫描的物料是否已存在同批次
|
let index = this.singlist.findIndex(item => item.code == this.warehouse.materialCode && item.batchNo == this.batchNo)
|
//置顶
|
if(index > -1) {
|
this.singlist.unshift(...this.singlist.splice(index,1))
|
return
|
}
|
}
|
|
if(this.warehouse.materialCode.length > 3) {
|
getMaterialList(this.warehouse.materialCode).then((res) => {
|
if (res.code == 200) {
|
if (res.data.rows.length == 0) {
|
this.rescode = 400
|
this.resmessage = '无此物料'
|
this.$refs.resmodal.show = true
|
return
|
}else {
|
res.data.rows.map(item => {
|
item.batchNo = this.batchNo
|
item.quantity = ''
|
item.show = false
|
return item;
|
})
|
this.singlist.unshift(...res.data.rows)
|
}
|
} else {
|
this.resmessage = res.message
|
this.rescode = res.code
|
this.$refs.resmodal.show = true
|
}
|
})
|
}
|
}
|
},
|
//删除详情
|
longpress(index, eindex) {
|
this.singlist[index].cardNum = true
|
if (eindex == 1) {
|
this.singlist.splice(index, 1)
|
} else {
|
this.materlist = this.singlist[index]
|
this.detailshow = true
|
}
|
|
},
|
// 如果打开一个的时候,不需要关闭其他,则无需实现本方法
|
open(index) {
|
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
|
// 原本为'false',再次设置为'false'会无效
|
this.singlist[index].show = true;
|
this.singlist.map((val, idx) => {
|
if (index != idx) this.singlist[idx].show = false;
|
})
|
},
|
close(index) {
|
this.singlist[index].show = false;
|
this.singlist[index].cardNum = false;
|
this.$forceUpdate()
|
},
|
//改变组盘数量
|
changeNum(val) {
|
val.cardNum = false
|
if(!val.quantity) {
|
uni.showModal({
|
title: '提示',
|
content: '组盘数量不能为空',
|
showCancel: false
|
})
|
}
|
if(val.quantity <0) {
|
uni.showModal({
|
title: '提示',
|
content: '组盘数量必须大于0',
|
showCancel: false
|
})
|
}
|
|
},
|
//全部取消
|
reset() {
|
this.singlist = [];
|
this.$refs.warehouseRef.resetFields();
|
this.$forceUpdate()
|
},
|
//重置页面信息
|
rest() {
|
this.warehouse.containerCode = ''
|
this.warehouse.materialCode = ''
|
this.singlist.forEach(item => {
|
item.quantity = ''
|
})
|
this.singlist = []
|
this.getOrderNo()
|
},
|
//确认
|
submit() {
|
this.$refs.warehouseRef.validate(valid => {
|
if (valid) {
|
//物料详情
|
let matatilDetails = this.singlist.reduce((curr,item) => {
|
curr.push({
|
createdTime: getDate(),
|
updatedTime: getDate(),
|
createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
wareMaterialCode: item.code,
|
batchNo:item.batchNo,
|
price:item.price,
|
completeQuantity: item.quantity,
|
quantity: item.quantity
|
})
|
return curr;
|
},[])
|
|
//请求参数
|
let params = {
|
createdTime: getDate(),
|
updatedTime: getDate(),
|
createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
orderNo: this.putCode,
|
orderType: 1,
|
wareContainerCode: this.warehouse.containerCode,
|
gridNumber: 1,
|
useNumber: 0,
|
warehousOrderDetails: matatilDetails
|
}
|
|
addGroupDisk(params).then(res => {
|
this.rescode = res.code
|
this.resmessage = res.message
|
this.$refs.resmodal.show = true
|
this.rest()
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style lang="scss" scoped>
|
.el_batchNo {
|
padding: 10rpx 0 10rpx 45rpx;
|
color: #808080;
|
}
|
.bg_item {
|
background: #FFEBCD !important;
|
}
|
</style>
|