<template>
|
<view class="overflow" style="padding-bottom:20rpx">
|
<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 margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="10">
|
<u-form-item label="库位编号:" prop="locationCode" required
|
style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
|
<input v-model="warehouse.locationCode" placeholder="请录入或扫码" @focus="warehouse.locationCode = ''"
|
@blur="getLocationDetails" style="font-weight: bolder;margin-left: 15rpx;"
|
class="width padding_left30rpx">
|
</input>
|
</u-form-item>
|
</u-col>
|
<u-col span="2">
|
<u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
|
</u-col>
|
</u-row>
|
<u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="10">
|
<u-form-item label="物料编号:" style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;;">
|
<input v-model="warehouse.materialCode" placeholder="请录入或扫码" @focus="warehouse.materialCode = ''"
|
@blur="getMaterialDetails" style="font-weight: bolder;margin-left: 15rpx;"
|
class="width padding_left30rpx">
|
</input>
|
</u-form-item>
|
</u-col>
|
<u-col span="2">
|
<u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
|
</u-col>
|
</u-row>
|
</u-form>
|
<modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
|
<view style="margin-bottom: 200rpx;">
|
<view v-for="(item, eindex) in singlist" :key="item.code" 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="Number(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.wareMaterialCode}}
|
</text>
|
</u-col>
|
</u-row>
|
<u-row style="margin-top: 20rpx;">
|
<u-col span="6">
|
<text class="el_batchNo">
|
批次:{{item.barNo}}
|
</text>
|
</u-col>
|
<u-col span="6">
|
<input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx" v-model="item.quantity"
|
type="number" @blur="changeNum(item)" :min="1" placeholder="请输入入库数量" />
|
</u-col>
|
</u-row>
|
</view>
|
</u-swipe-action>
|
</view>
|
</view>
|
<button-modal :subShow="true" garmenTitle="确认入库" :disabled="singlist.length == 0" @submit="submit" />
|
|
</view>
|
</template>
|
|
<script>
|
import ButtonModal from '../../../components/buttonModal.vue'
|
import ModalCode from '../../../components/ModalCode.vue'
|
import {addEnterWare} from '../../../api/putIn/material.js'
|
import {getLocationDetail,entryConfirm} from '../../../api/putIn/plane.js'
|
import {getOrderNo} from '../../../api/putIn/artificial.js'
|
import {getDate} from '../../../utils/dateTime.js'
|
import {getAttrValue} from '../../../utils/tool.js'
|
export default {
|
data() {
|
return {
|
rescode: 0,
|
resmessage: "",
|
detailshow: false,
|
operator: '',
|
singlist: [], //物料详情
|
orderNo: '', //入库单号
|
options: [
|
{
|
text: '删除',
|
style: {
|
backgroundColor: '#fc4b4b'
|
}
|
}
|
],
|
materlist: [],
|
warehouse: {
|
locationCode: '',
|
materialCode: ''
|
},
|
warehouseRules: {
|
locationCode: [{required: true,message: '库位编号不能为空',trigger: 'blur'}]
|
},
|
barNo: '', //当前扫描的物料标签获取到的批次
|
};
|
},
|
components: {
|
ButtonModal,
|
ModalCode
|
},
|
onLoad(options) {
|
this.type = options.type
|
},
|
onReady(){
|
this.$refs.warehouseRef.setRules(this.warehouseRules)
|
},
|
mounted() {
|
// this.WarehousChangePort()
|
this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
|
this.getOrderNo()
|
},
|
methods: {
|
//获取入库单号
|
getOrderNo() {
|
getOrderNo().then((res) => {
|
if (res.code == 200) {
|
this.orderNo = res.data
|
} else {
|
this.rescode = 400
|
this.resmessage = `${res.code}:${res.message}`
|
this.$refs.resmodal.show = true
|
}
|
})
|
},
|
//验证库位,判断库位信息是否存在
|
getLocationDetails() {
|
this.$refs.warehouseRef.validate(valid => {
|
if (valid) {
|
getLocationDetail(this.warehouse.locationCode).then((res) => {
|
if (res.data.rows.length == 0) {
|
this.rescode = 400
|
this.resmessage = '此库位不存在'
|
this.$refs.resmodal.show = true
|
}else if(res.data.rows.length > 1){
|
this.rescode = 400
|
this.resmessage = '查询出多个库位,请录入完整库位编号'
|
this.$refs.resmodal.show = true
|
}
|
})
|
}
|
})
|
},
|
//物料编号验证
|
getMaterialDetails() {
|
if(this.warehouse.materialCode == "") {
|
this.rescode = 400
|
this.resmessage = '物料编号不能为空'
|
this.$refs.resmodal.show = true
|
return
|
}
|
|
if(this.warehouse.materialCode.length > 50) {
|
this.rescode = 400
|
this.resmessage = '扫描的物料标签不正确'
|
this.$refs.resmodal.show = true
|
return
|
}
|
|
|
//批次
|
this.barNo = getAttrValue(this.warehouse.materialCode,'LOTNO');
|
//数量
|
var quantity = getAttrValue(this.warehouse.materialCode,'QUANTITY');
|
if(!quantity) {
|
// this.rescode = 400
|
// this.resmessage = '物料标签中没有数量信息'
|
// this.$refs.resmodal.show = true
|
// return
|
}
|
//物料编号
|
this.warehouse.materialCode = getAttrValue(this.warehouse.materialCode,'PARTSNUMBER');
|
//判断当前物料 + 批次是否存在
|
const count = this.singlist.findIndex(item =>item.wareMaterialCode == this.warehouse.materialCode);
|
if(count > -1) {
|
this.singlist.unshift(...this.singlist.splice(count,1))
|
return;
|
}
|
|
//添加数据
|
this.singlist.unshift({
|
wareLocationCode: this.warehouse.locationCode,
|
wareMaterialCode: this.warehouse.materialCode,
|
barNo: this.barNo,
|
quantity: quantity,
|
show: false
|
})
|
|
},
|
//删除详情
|
longpress(index, eindex) {
|
this.singlist.splice(index, 1)
|
},
|
// 如果打开一个的时候,不需要关闭其他,则无需实现本方法
|
open(index) {
|
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
|
// 原本为'false',再次设置为'false'会无效
|
this.singlist[index].show = true;
|
this.singlist.map((val, idx) => {
|
if (index != idx) this.singlist[idx].show = false;
|
})
|
},
|
//改变入库数量
|
changeNum(val) {
|
if(val.quantity <= 0 || val.quantity == '')
|
{
|
this.rescode = 400
|
this.resmessage = '入库数量不能为空或者小于等于0'
|
this.$refs.resmodal.show = true
|
}
|
|
},
|
//关闭时
|
close(index) {
|
this.singlist[index].show = false;
|
},
|
rest() {
|
this.warehouse.materialCode = ''
|
this.warehouse.locationCode = ''
|
this.barNo = "";
|
this.singlist = []
|
},
|
//确认
|
submit() {
|
if(this.orderNo == '') {
|
this.rescode = 400
|
this.resmessage = '生成入库单号失败'
|
this.$refs.resmodal.show = true
|
return;
|
}
|
//判断材料列表中是否存在入库数量不符合要求的
|
const index = this.singlist.findIndex(item =>item.quantity <= 0 || item.quantity == "");
|
if(index >= 0) {
|
this.rescode = 400
|
this.resmessage = '材料列表中存在入库数量为空或者小于等于0'
|
this.$refs.resmodal.show = true
|
return;
|
}
|
//材料列表
|
//alert(this.singlist.length);
|
// let materialList = 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.wareMaterialCode,
|
// batchNo:item.barNo,
|
// completeQuantity: item.quantity,
|
// quantity: item.quantity
|
// })
|
// },[])
|
let materialList = []
|
this.singlist.forEach(item => {
|
materialList.push({
|
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.wareMaterialCode,
|
batchNo: item.barNo,
|
purchaseNo: item.purchaseNo,
|
collectNo: item.collectNo,
|
deliveryNo: item.deliveryNo,
|
completeQuantity: item.quantity,
|
quantity: item.quantity
|
})
|
})
|
//alert(this.materialList.length);
|
//alert(materialList);
|
////debugger
|
let params = {
|
createdTime: getDate(),
|
updatedTime: this.Datetime,
|
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.orderNo,
|
wareLocationCode: this.warehouse.locationCode,
|
warehousOrderDetails: materialList
|
}
|
if(this.warehouse.locationCode != ""){
|
entryConfirm(params).then((res) => {
|
this.orderNo = '';
|
this.$refs.resmodal.show = true
|
this.resmessage = "入库成功"
|
this.rescode = 200
|
this.rest();
|
})
|
}
|
}
|
},
|
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.el_batchNo {
|
padding: 10rpx 0 10rpx 45rpx;
|
color: #808080;
|
}
|
.bg_item {
|
background: #FFEBCD !important;
|
}
|
</style>
|