初始化仓库

This commit is contained in:
tao
2025-12-18 14:11:48 +08:00
parent e96f277a68
commit 54ec472bd4
1107 changed files with 158756 additions and 0 deletions

View File

@@ -0,0 +1,350 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData">
<!-- <uni-collapse-item title="明细标签入库" :open="true"> -->
<uni-forms-item label="扫描标签" :labelWidth='90' name="purchaseLabelCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @blur="getlabelCode" placeholder='请扫描标签'
v-model="purchaseLabelCode" type="text" :focus='true'/>
</uni-forms-item>
<!-- 标签明细 -->
<uni-collapse-item :open="true">
<uni-card :is-shadow="false" is-full v-for="(item,index) in formData.wmsCommonInDetailLabelList"
:key="index" v-if="total>0">
<div><strong>标签码</strong>:{{item.labelCode}}</div>
<div><strong>供应商</strong>:{{item.supplierName}}</div>
<div><strong>物料编码</strong>:{{item.materialCode}}</div>
<div><strong>物料名称</strong>:{{item.materialName}}</div>
<div><strong>规格</strong>:{{item.specification}}</div>
<div><strong>批号</strong>:{{item.materialBatchNo}}</div>
<div><strong>数量</strong>:{{item.number}}</div>
<!-- <div><strong>状态</strong>:{{returnStatus(item.status)}}</div> -->
<div><strong>状态</strong>:{{dtlStatusFormat(item.status)}}</div>
</uni-card>
</uni-collapse-item>
<uni-forms-item label="上架扫码" :labelWidth='90' name="location" style="margin-top:10px">
<uni-easyinput suffixIcon="scan" @iconClick="scanLocation" @blur="getWarehouse"
placeholder='请扫描库位标签' v-model="locationCode" type="text" />
</uni-forms-item>
<uni-collapse-item :open="true">
<uni-card :is-shadow="false" is-full v-if='warehouseName'>
<div><strong>仓库</strong>:{{warehouseName}}</div>
<div><strong>库位</strong>:{{showLocationCode}}</div>
</uni-card>
</uni-collapse-item>
<u-button type="primary" @click="submitIn">确认入库</u-button>
</uni-forms>
</uni-collapse>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="确认是否入库" @confirm="dialogConfirm">
<div>
<div><strong>物料编码</strong>:{{alert.materialCode}}</div>
<div><strong>数量</strong>:{{alert.number}}</div>
<div><strong>库位</strong>:{{alert.showLocationCode}}</div>
</div>
</uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {
listQuality,
getQuality,
addIn,
listReceive,
getReceive,
getListDetail,
updateIn,
listIn,
getIn,
getQualityDetail,
getReceiveDetail,
getDetailListsBySRM,
getListDetailByBL,
listSupplier,
listPurchaseInDetailLabel,
listWarehouse,
labelInStock,
} from "@/api/wms/purchase.js";
import {
getConfigKey,
} from "@/api/wms/materRequisitiontask";
export default {
onLoad: function() {},
created() {
//获取当前客户
getConfigKey('wms.warehouse.mode').then(res =>{
this.getConfigKey.setkey(res.msg)
})
},
mounted() {
},
data() {
return {
// 遮罩层
loading: true,
// 总条数
total: 0,
//标识码
purchaseLabelCode: null,
//库位码
locationCode: null,
//仓库码
showLocationCode: null,
//仓库名
warehouseName: null,
formData: {
areaCode: null,
shelvesCode: null,
storageLocationCode: null,
whCode: null,
// 采购入库明细标签表格数据
wmsCommonInDetailLabelList: [],
},
//标签码查询参数
queryParams: {
pageNum: 1,
pageSize: 50,
labelCode: null,
},
//仓库查询参数
queryParamsCK: {
pageNum: 1,
pageSize: 50,
orderByColumn: "id",
isAsc: "desc",
warehouseCode: null,
},
getConfigKey:new classLocationCode(),
alert:{
materialCode :null,
number : null,
showLocationCode: null
}
}
},
methods: {
//明细状态
dtlStatusFormat(status) {
if (status == 1) {
return "入库完成";
} else if (status == 0) {
return "等待入库";
} else if (status == 2) {
return "入库中";
} else {
return "等待入库";
}
},
//扫描标签码
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.purchaseLabelCode = res.result;
_this.getlabelCode();
}
});
},
getlabelCode() {
this.queryParams.labelCode = this.purchaseLabelCode;
this.getList()
},
//查询标签列表
getList() {
this.loading = true;
//解析扫的条码信息,以,为间隔转换成数组,并取第二个数据为真实需要的信息
this.purchaseLabelCode = this.queryParams.labelCode = this.queryParams.labelCode.split(',')[1]
listPurchaseInDetailLabel(this.queryParams).then(res => {
this.formData.wmsCommonInDetailLabelList = [res.rows[0]];
this.total = res.total;
this.loading = false;
if (this.total == 0) {
// console.log("二维码有错");
this.$modal.msgError("标签二维码错误");
this.purchaseLabelCode = null
}
});
},
//扫描库位码
scanLocation() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.locationCode = res.result;
_this.getWarehouse();
}
});
},
//仓库码
async getWarehouse() {
if (this.locationCode == null || this.locationCode == '') {
this.$modal.msgError("库位码为空");
} else {
this.showLocationCode = this.locationCode
let parts = this.locationCode.split('-');
if (parts.length <1 || parts.length > 4) {
this.$modal.msgError("库位码格式有误");
this.locationCode = null
return
}
parts = this.getConfigKey.getValue(this.locationCode).split('-');
// this.formData.whCode = parts[0] || null;
this.formData.whCode = await getParts(parts) || null;
this.formData.areaCode = parts[1] || null;
this.formData.shelvesCode = parts[2] || null;
this.formData.storageLocationCode = parts.slice(3).join('-') || null;
this.queryParamsCK.warehouseCode = parts[0]
this.getlistWarehouse()
}
/**
* 根据扫的二维码的长度判断其第一位应该是什么值
* @name PZQ
* @param {Object} parts 二维码转换的数组
*/
function getParts(parts){
if(parts.length == 4 ){
return parts[0] || null;
}else {
return '0' + parts[0].charAt(0) || null;
}
}
},
//查仓库名
getlistWarehouse() {
// this.formData.location
this.loading = true;
listWarehouse(this.queryParamsCK).then(res => {
this.warehouseName = res.rows[0].warehouseName
this.loading = false;
});
},
//重置
reset() {
// 总条数
this.total = 0,
//标识码
this.purchaseLabelCode = null,
//库位码
this.locationCode = null,
//仓库码
this.showLocationCode = null,
//仓库名
this.warehouseName = null,
this.formData = {
areaCode: null,
shelvesCode: null,
storageLocationCode: null,
whCode: null,
// 采购入库明细标签表格数据
wmsCommonInDetailLabelList: [],
}
//标签码查询参数
this.queryParams = {
pageNum: 1,
pageSize: 50,
labelCode: null,
}
//仓库查询参数
this.queryParamsCK = {
pageNum: 1,
pageSize: 50,
orderByColumn: "id",
isAsc: "desc",
warehouseCode: null,
}
},
//确认入库
submitIn() {
if(this.formData.wmsCommonInDetailLabelList == null || this.formData.whCode == []){
this.$modal.msgError("请扫描标识码");
return;
}
if(this.formData.whCode == null || this.formData.whCode == ''){
this.$modal.msgError("请扫描库位码");
return;
}
console.log(this.formData)
const {wmsCommonInDetailLabelList} = this.formData
const {materialCode,number } = wmsCommonInDetailLabelList[0]
// showLocationCode
// else
//弹框二次确认
this.alert = {
materialCode,
number,
showLocationCode:this.showLocationCode
}
this.$refs.alertDialog.open()
return
// uni.showModal({
// title: '提示',
// content: `确定要入库数量为${number}物料编码为${materialCode}到${this.showLocationCode}吗?`,
// success: res => {
// if (res.confirm) {
// labelInStock(this.formData).then(response => {
// this.$modal.msgSuccess("入库成功");
// this.reset()
// });
// } else if (res.cancel) {
// // console.log('用户点击取消');
// uni.showToast({
// title: '取消入库',
// icon: 'none', //如果要纯文本不要icon将值设为'none'
// duration: 2000 //持续时间为 2秒
// })
// }
// }
// });
},
dialogConfirm(){
labelInStock(this.formData).then(response => {
this.$modal.msgSuccess("入库成功");
this.reset()
});
this.$refs.alertDialog.close()
}
}
}
class classLocationCode{
#key = null
setkey(key){
this.key = key
}
/**
* 给外部调用的方法
* @param {Object} value
*/
getValue(value){
const obj = {
"1":this.#getLocationCode,
}
if(this.key in obj){
return obj[this.key](value)
}
return value
}
/**
* 判断上架扫码是否拼接
* @param {Object} value
*/
#getLocationCode(value){
const number = value[0]
return '0' + number + '-' + value
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,78 @@
<template>
<view class="uni-padding-wrap uni-common-mt" >
<view class="grid-body">
<uni-grid :column="3" :showBorder="false" @change="changeGrid1">
<uni-grid-item :index="1" style="line-height: 100px;margin-top:100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-caigoushouhuodan" size="30"></uni-icons>
<text class="text">采购收货单</text>
</view>
</uni-grid-item>
<uni-grid-item :index="2" style="line-height: 100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-zhijian" size="30"></uni-icons>
<text class="text">采购质检</text>
</view>
</uni-grid-item>
<uni-grid-item :index="3" style="line-height: 100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-navicon-cgrkd" size="30"></uni-icons>
<text class="text">采购入库单</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
</view>
</template>
<script>
export default {
onLoad: function() {
},
methods: {
changeGrid1(e) {
console.log(e.detail.index);
if (e.detail.index == 1) {
this.$tab.navigateTo('/pages/wms/purchase/purchaseSh');
} else if (e.detail.index == 2) {
this.$tab.navigateTo('/pages/wms/purchase/purchaseQualityT');
} else if (e.detail.index == 3) {
this.$tab.navigateTo('/pages/wms/purchase/purchaseRk');
}
}
}
}
</script>
<style>
uni-grid-item {
line-height: 100px;
margin: auto;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

View File

@@ -0,0 +1,673 @@
<template>
<view>
<uni-collapse>
<view class="cu-card article ">
<view class="cu-item shadow borderBottom">
<view class="content">
<view class="desc">
<view class="text-content" style="font-size: 15px;">
<view><strong>物料编码</strong> : {{singleInfo.materialCode}}</view>
<view><strong>物料名称</strong> : {{singleInfo.materialName}}</view>
<view><strong>物料批号</strong> : {{singleInfo.materialBatchNo}}</view>
<view><strong>上架数量</strong> : {{singleInfo.secondNumber}}</view>
</view>
</view>
</view>
</view>
</view>
<uni-row>
<uni-col :span="12">
<span style="display: block;text-align: center;">每份数量<view style="margin-left: 15%;"><u-number-box
v-model="eachNumber" integer min="0" @change="eachNumberClear" /></view></span>
</uni-col>
<uni-col :span="12">
<span style="display: block;text-align: center;">拆分数量<view style="margin-left: 15%;"><u-number-box
v-model="splitNumber" integer min="0" @change="splitNumberClear" /></view></span>
</uni-col>
</uni-row>
<uni-row style="margin-top: 5px;" :gutter="10">
<uni-col :span="12">
<u-button type="primary" icon="cut" :disabled="isSecondOpen" @click="multiSplit" :plain="true"
text="拆分"></u-button>
</uni-col>
<uni-col :span="12">
<u-button type="success" icon="close-circle" @click="singleSplit" :disabled="isSecondOpen"
:plain="true" text="不拆分"></u-button>
</uni-col>
</uni-row>
<uni-collapse-item :open="true">
<uni-forms ref="form" :modelValue="formData">
<view :key="index" v-for="(item, index) in wmsLotNoList">
<view>
<uni-badge :text="index+1" class="uni-badge-left-margin" type="primary"></uni-badge>
</view>
<uni-forms-item label="物料箱号" :labelWidth='90' :name="item.lotNo">
<uni-easyinput type="text" v-model="item.lotNo" />
</uni-forms-item>
<uni-forms-item label="推荐库位" :label-width="90" ref="myInput">
<uni-easyinput disabled type="text" v-model="item.recommend"
style="width: 70%;float: left;" />
<u-button
style="background-color: beige;width: 30%;float: left;font-size: 100%;height: 100%;"
@click="clickCopy(index)">复制库位</u-button>
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
:name="'wmsLotNoList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)"
@change="splitStlBarcode(index,$event)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item>
<uni-forms-item label="上架数量" :labelWidth='90'>
<second-number-change-to-convert :materialCode="item.materialCode"
:secondNumber.sync="item.secondNumber" :secondUnitId="item.secondUnitId"
:number.sync="item.number" :unitId="item.unitId"></second-number-change-to-convert>
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.secondNumber"
min="0"></u-number-box> -->
</uni-forms-item>
<uni-forms-item label="入库时间" :labelWidth='90' :name="item.storageInTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="item.storageInTime" />
</view>
</uni-forms-item>
</view>
</uni-forms>
</uni-collapse-item>
</uni-collapse>
<u-button type="warning" @click="clickCopy">一键复制</u-button>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
addInDetail,
addLotInfo,
uploadU9
} from "@/api/wms/purchase.js";
import SecondNumberChangeToConvert from "@/components/SecondNumberChangeToConvert/index.vue";
import {
updateInDetail,
getConnectLoc
} from "@/api/wms/pdcIn.js";
import {
listStock
} from "@/api/wms/stock.js"
// import { set } from "lodash";
export default {
onLoad: async function(option) {
console.log(option);
console.log(option.selectedRow);
console.log(option.singleInfo);
console.log(option.wmsLotNoList);
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.rkTime = formattedDate;
this.isSecondOpen = option.isSecondOpen == 'false' ? false : true;
this.selectedRow = JSON.parse(decodeURIComponent(option.selectedRow));
this.singleInfo = JSON.parse(decodeURIComponent(option.singleInfo));
this.wmsLotNoList = JSON.parse(decodeURIComponent(option.wmsLotNoList));
this.wmsLotNoList.map(item => {
item.storageInTime = formattedDate;
item.storageLocationBarcode = item.whCode ? (item.areaCode ? (
item.shelvesCode ? (item.storageLocationCode ? (item
.whCode + '-' + item.areaCode + '-' + item
.shelvesCode +
'-' + item.storageLocationCode) : (item.whCode +
'-' + item.areaCode + '-' + item
.shelvesCode
)) : (item.whCode + '-' + item.areaCode)) : item
.whCode) : ''
return item
})
console.log(this.wmsLotNoList);
this.recommend = await fnListStock(this.singleInfo)
this.eachNumber = option.eachNumber;
this.splitNumber = option.splitNumber;
this.index = option.index
/**
* 通过明细编码去获取库位
* @param {Object} list 明细信息
*/
async function fnListStock(list) {
const set = new Set()
await listStock({
materialCode: list.materialCode
}).then(res => {
const rows = res.rows;
for (let i in rows) {
if (rows[i].whCode != null && rows[i].areaCode != null && rows[i]
.storageLocationCode && rows[i].shelvesCode) {
set.add(rows[i].whCode + '-' + rows[i].areaCode + '-' + rows[i].shelvesCode +
'-' + rows[i].storageLocationCode)
}
}
})
return [...set].toString()
}
},
data() {
return {
recommend: null,
number: 1111,
//入库时间
rkTime: null,
//是否已分批
isSecondOpen: false,
selectedRow: {},
singleInfo: {},
wmsLotNoList: [],
eachNumber: null,
splitNumber: null,
index: null,
checkStorageLocationBarcode: true,
// storageLocationBarcode: ''
formData: {},
isSubmitted: false,
rules: {
// storageLocationBarcode: {
// rules: [{
// required: true,
// errorMessage: '请输入库位条码!'
// }]
// }
storageLocationBarcode: [{
required: true,
errorMessage: '请输入库位条码!'
}]
},
}
},
components: {
SecondNumberChangeToConvert
},
methods: {
eachNumberClear() {
this.eachSecondNumber = null;
this.splitNumber = null;
},
eachSecondNumberClear() {
this.eachNumber = null;
this.splitNumber = null;
},
splitNumberClear() {
this.eachNumber = null;
this.eachSecondNumber = null;
},
//选择条件拆分批次
multiSplit() {
this.wmsLotNoList = [];
let materialCode = this.singleInfo.materialCode;
let batchNo = this.singleInfo.materialBatchNo;
let unit = this.singleInfo.unit;
let unitId = this.singleInfo.unitId;
let secondUnitId = this.singleInfo.secondUnitId;
let purchaseInCode = this.singleInfo.purchaseInCode;
let materialName = this.singleInfo.materialName;
let specification = this.singleInfo.specification;
let unitName = this.singleInfo.unitName;
let u9StorageCode = this.singleInfo.u9StorageCode;
let storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
let u9LineId = this.singleInfo.u9LineId;
let connectedLocation = "";
let storageInTime = this.rkTime;
if (this.singleInfo.whCode != null) {
connectedLocation = this.singleInfo.whCode;
if (this.singleInfo.areaCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.areaCode;
if (this.singleInfo.shelvesCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.shelvesCode;
if (this.singleInfo.storageLocationCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.storageLocationCode;
}
}
}
}
let locCascade = [
this.singleInfo.whCode,
this.singleInfo.areaCode,
this.singleInfo.shelvesCode,
this.singleInfo.storageLocationCode,
];
if (this.eachNumber != null) {
let t;
let k;
t = parseInt(this.singleInfo.number / this.eachNumber);
k = this.singleInfo.number % this.eachNumber;
let rate;
let secondK;
let secondT;
rate = this.singleInfo.number / this.singleInfo.secondNumber;
secondT = parseInt(this.singleInfo.secondNumber / this.eachNumber);
secondK = this.singleInfo.secondNumber % this.eachNumber;
// if (k != 0) { t++; }
if (secondK != 0) {
secondT++;
}
for (let i = 0; i < secondT; i++) {
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = this.eachNumber * rate;
obj.secondNumber = this.eachNumber;
obj.unit = unit;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.specification = specification;
obj.unitName = unitName;
obj.locCascade = locCascade;
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// this.selectLoc(locCascade, obj);
if (i == secondT - 1) {
if (secondK != 0) {
obj.number = secondK * rate;
obj.secondNumber = secondK;
}
}
// obj.lotNo = i + 1;
this.wmsLotNoList.push(obj);
}
} else if (this.splitNumber != null) {
let k;
let j;
const data = this.singleInfo[0] === undefined ? this.singleInfo : this.singleInfo[0]
k = parseInt(data.number / this.splitNumber);
j = data.number - (this.splitNumber - 1) * k;
let secondK;
let secondJ;
secondK = parseInt(data.secondNumber / this.splitNumber);
secondJ = data.secondNumber - (this.splitNumber - 1) * secondK;
for (let i = 0; i < this.splitNumber; i++) {
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = k;
obj.unit = unit;
obj.secondNumber = secondK;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.unitName = unitName;
obj.specification = specification;
obj.locCascade = locCascade;
// this.selectLoc(locCascade, obj);
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// obj.lotNo = i + 1;
if (i == this.splitNumber - 1) {
obj.number = j;
obj.secondNumber = secondJ;
}
this.wmsLotNoList.push(obj);
}
} else if (this.eachSecondNumber != 0) {
let t;
let k;
t = parseInt(this.singleInfo.secondNumber / this.eachSecondNumber);
k = this.singleInfo.secondNumber % this.eachSecondNumber;
if (k != 0) {
t++;
}
for (let i = 0; i < t; i++) {
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.secondNumber = this.eachSecondNumber;
obj.secondUnit = secondUnit;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.unitName = unitName;
obj.secondNumber = this.eachSecondNumber;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.specification = specification;
obj.locCascade = locCascade;
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// this.selectLoc(locCascade, obj);
if (i == t - 1) {
if (k != 0) {
obj.secondNumber = k;
}
}
// obj.lotNo = i + 1;
this.wmsLotNoList.push(obj);
}
}
},
/**
* 复制
*/
clickCopy(index) {
const data = this.wmsLotNoList
if (index != undefined) {
data[index].storageLocationBarcode = data[index].recommend
} else {
for (let i in data) {
data[i].storageLocationBarcode = data[i].recommend
}
}
this.wmsLotNoList = Object.assign({});
this.wmsLotNoList = data
},
//不拆分批次
async singleSplit() {
const set = new Set()
await listStock({
materialCode: this.singleInfo.materialCode
}).then(res => {
const rows = res.rows;
for (let i in rows) {
if (rows[i].whCode != null && rows[i].areaCode != null && rows[i]
.storageLocationCode && rows[i].shelvesCode) {
set.add(rows[i].whCode + '-' + rows[i].areaCode + '-' + rows[i]
.storageLocationCode + '-' + rows[i].shelvesCode)
}
}
})
const array = [...set].toString()
this.wmsLotNoList = [];
this.splitNumber = 1;
let obj = {};
obj.areaCode = array;
obj.recommend = this.recommend;
obj.materialCode = this.singleInfo.materialCode;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.secondNumber = this.singleInfo.secondNumber;
obj.secondUnit = this.singleInfo.secondUnit;
obj.storageInBillCode = this.singleInfo.purchaseInCode;
obj.number = this.singleInfo.number;
obj.unitId = this.singleInfo.unitId;
obj.secondUnitId = this.singleInfo.secondUnitId;
obj.unit = this.singleInfo.unit;
obj.unitName = this.singleInfo.unitName;
obj.materialName = this.singleInfo.materialName;
obj.specification = this.singleInfo.specification;
obj.u9StorageCode = this.singleInfo.u9StorageCode;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.u9LineId = this.singleInfo.u9LineId;
obj.storageInTime = this.rkTime;
if (this.singleInfo.whCode != null) {
obj.connectedLocation = this.singleInfo.whCode;
if (this.singleInfo.areaCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo.areaCode;
if (this.singleInfo.shelvesCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo.shelvesCode;
if (this.singleInfo.storageLocationCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo
.storageLocationCode;
}
}
}
}
obj.locCascade = [
this.singleInfo.whCode,
this.singleInfo.areaCode,
this.singleInfo.shelvesCode,
this.singleInfo.storageLocationCode,
];
// this.selectLoc(obj.locCascade, obj);
// obj.lotNo = 1;
this.wmsLotNoList.push(obj);
},
async splitStlBarcode(i, event) {
console.log(i)
const _this = this;
const detail = _this.wmsLotNoList[i];
console.log(detail.whCode)
detail.whCode = _this.singleInfo.whCode
detail.areaCode = null;
detail.shelvesCode = null;
detail.storageLocationCode = null;
let barcode = detail.storageLocationBarcode;
if (!barcode) {
return; // 如果没有条码,不做任何处理
}
// 分割为三部分:库区、货架、库位(库位可能含'-'
const parts = barcode.split('-');
if (parts.length < 3) {
_this.$modal.msg("库位条码格式错误,应为:库区-货架-库位");
return;
}
// 解析三部分
const areaCode = parts[0];
const shelvesCode = parts[1];
const storageLocationCode = parts.slice(2).join('-'); // 合并剩余部分为库位
const data = await getConnectLoc({
connectLoc: event
})
if (!data.data) return this.$modal.msg("库位条码校验错误,请重新输入!")
_this.checkStorageLocationBarcode = true;
detail.areaCode = areaCode || null;
detail.shelvesCode = shelvesCode || null;
detail.storageLocationCode = storageLocationCode || null;
},
scanBarstorageLocationBarcode(i) {
const _this = this;
_this.isSubmitted = false
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.wmsLotNoList[i], "storageLocationBarcode", res
.result);
_this.splitStlBarcode(i);
}
});
},
//提交分批入库详情
async submit() {
// const valid = await this.$refs.form.validate();
// if (valid) {
// this.$refs.form.validate().then(res => {
let isStorageLocationBarcode = true;
for (var i in this.wmsLotNoList) {
if (this.wmsLotNoList[i].storageLocationBarcode == null || this.wmsLotNoList[i]
.storageLocationBarcode == '') isStorageLocationBarcode = false
}
if (isStorageLocationBarcode) {
//数量防错
let allNum = 0;
for (var i in this.wmsLotNoList) {
allNum += this.wmsLotNoList[i].number;
}
if (this.wmsLotNoList.length > 0) {
if (this.wmsLotNoList[0].id != null) {
for (let i = 0; i < this.wmsLotNoList.length; i++) {
// if (this.wmsu9whMode == "true") {
// console.log(this.wmsu9whMode);
// updateU9Stock(this.wmsLotNoList[i]);
// } else {
// updateStock(this.wmsLotNoList[i]);
// }
if (this.wmsLotNoList && this.wmsLotNoList.length >
0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
}
this.$modal.msgSuccess("编辑成功!");
setTimeout(() => {
uni.$emit('backWithParam', {
status: this.selectedRow.status,
index: this.index
});
this.$tab.navigateBack();
}, 500);
} else {
let obj = {};
obj = this.singleInfo;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.eachNumber = this.eachNumber;
obj.splitNumber = this.splitNumber;
if (this.wmsLotNoList && this.wmsLotNoList.length >
0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
if (!this.checkStorageLocationBarcode) {
this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
console.log(this.wmsLotNoList)
// 拼接仓库
if (!this.isSubmitted) {
this.isSubmitted = true
for (let i in this.wmsLotNoList) {
this.wmsLotNoList[i].storageLocationBarcode =
`${this.wmsLotNoList[i].whCode}-${this.wmsLotNoList[i].storageLocationBarcode}`
}
}
console.log(this.wmsLotNoList)
this.$modal.loading('提交中')
addLotInfo(obj).then(res => {
addInDetail(this.wmsLotNoList, 1).then(res => {
uploadU9(this.wmsLotNoList)
this.$modal.closeLoading();
this.$modal.msgSuccess("编辑成功!");
// setTimeout(() => {
uni.$emit(
'backWithParam', {
status: this
.selectedRow
.status,
index: this
.index
});
this.$tab.navigateBack();
// }, 500);
})
});
}
}
// if (allNum == this.singleInfo.number) {
// if (this.wmsLotNoList.length > 0) {
// if (this.wmsLotNoList[0].id != null) {
// console.log(this.wmsLotNoList[0].id);
// for (let i = 0; i < this.wmsLotNoList.length; i++) {
// // if (this.wmsu9whMode == "true") {
// // console.log(this.wmsu9whMode);
// // updateU9Stock(this.wmsLotNoList[i]);
// // } else {
// // updateStock(this.wmsLotNoList[i]);
// // }
// if (this.wmsLotNoList && this.wmsLotNoList.length >
// 0) {
// this.selectedRow.status = "1";
// } else {
// this.selectedRow.status = "0";
// }
// }
// this.$modal.msgSuccess("编辑成功!");
// setTimeout(() => {
// uni.$emit('backWithParam', {
// status: this.selectedRow.status,
// index: this.index
// });
// this.$tab.navigateBack();
// }, 500);
// } else {
// let obj = {};
// obj = this.singleInfo;
// obj.batchNo = this.singleInfo.materialBatchNo;
// obj.eachNumber = this.eachNumber;
// obj.splitNumber = this.splitNumber;
// if (this.wmsLotNoList && this.wmsLotNoList.length >
// 0) {
// this.selectedRow.status = "1";
// } else {
// this.selectedRow.status = "0";
// }
// if (!this.checkStorageLocationBarcode) {
// this.$modal.msg("库位条码校验错误,请重新输入!")
// return;
// }
// this.$modal.loading('提交中')
// addLotInfo(obj).then(res => {
// addInDetail(this.wmsLotNoList, 1).then(res => {
// uploadU9(this.wmsLotNoList)
// this.$modal.closeLoading();
// this.$modal.msgSuccess("编辑成功!");
// // setTimeout(() => {
// uni.$emit(
// 'backWithParam', {
// status: this
// .selectedRow
// .status,
// index: this
// .index
// });
// this.$tab.navigateBack();
// // }, 500);
// })
// });
// }
// }
// } else {
// this.$modal.msg("批号分批入库明细数量不符合!");
// }
} else {
this.$modal.msg("库位条码必填!");
}
// })
}
},
}
</script>
<style>
.cu-card.article>.cu-item .content .text-content {
height: 100% !important;
}
.cu-card.article>.cu-item {
padding-bottom: 0;
}
.cu-card>.cu-item {
margin: 0;
}
.uni-swipe {
overflow: inherit;
}
</style>

View File

@@ -0,0 +1,655 @@
<template>
<view>
<uni-collapse>
<view class="cu-card article ">
<view class="cu-item shadow borderBottom">
<view class="content">
<view class="desc">
<view class="text-content" style="font-size: 15px;">
<view><strong>物料编码</strong> : {{singleInfo.materialCode}}</view>
<view><strong>物料名称</strong> : {{singleInfo.materialName}}</view>
<view><strong>物料批号</strong> : {{singleInfo.materialBatchNo}}</view>
<view><strong>上架数量</strong> : {{singleInfo.secondNumber}}</view>
</view>
</view>
</view>
</view>
</view>
<uni-row>
<uni-col :span="12">
<span style="display: block;text-align: center;">每份数量<view style="margin-left: 15%;"><u-number-box
v-model="eachNumber" integer min="0" @change="eachNumberClear" /></view></span>
</uni-col>
<uni-col :span="12">
<span style="display: block;text-align: center;">拆分数量<view style="margin-left: 15%;"><u-number-box
v-model="splitNumber" integer min="0" @change="splitNumberClear" /></view></span>
</uni-col>
</uni-row>
<uni-row style="margin-top: 5px;" :gutter="10">
<uni-col :span="12">
<u-button type="primary" icon="cut" :disabled="isSecondOpen" @click="multiSplit" :plain="true"
text="拆分"></u-button>
</uni-col>
<uni-col :span="12">
<u-button type="success" icon="close-circle" @click="singleSplit" :disabled="isSecondOpen"
:plain="true" text="不拆分"></u-button>
</uni-col>
</uni-row>
<uni-collapse-item :open="true">
<uni-forms ref="form" :modelValue="formData">
<view :key="index" v-for="(item, index) in wmsLotNoList">
<view>
<uni-badge :text="index+1" class="uni-badge-left-margin" type="primary"></uni-badge>
</view>
<uni-forms-item label="物料箱号" :labelWidth='90' :name="item.lotNo">
<uni-easyinput type="text" v-model="item.lotNo" />
</uni-forms-item>
<uni-forms-item label="推荐库位" :label-width="90" ref="myInput">
<uni-easyinput disabled type="text" v-model="item.recommend"
style="width: 70%;float: left;" />
<u-button
style="background-color: beige;width: 30%;float: left;font-size: 100%;height: 100%;"
@click="clickCopy(index)">复制库位</u-button>
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
:name="'wmsLotNoList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)"
@change="splitStlBarcode(index,$event)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item>
<uni-forms-item label="上架数量" :labelWidth='90'>
<second-number-change-to-convert :materialCode="item.materialCode"
:secondNumber.sync="item.secondNumber" :secondUnitId="item.secondUnitId"
:number.sync="item.number" :unitId="item.unitId"></second-number-change-to-convert>
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.secondNumber"
min="0"></u-number-box> -->
</uni-forms-item>
<uni-forms-item label="入库时间" :labelWidth='90' :name="item.storageInTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="item.storageInTime" />
</view>
</uni-forms-item>
</view>
</uni-forms>
</uni-collapse-item>
</uni-collapse>
<u-button type="warning" @click="clickCopy">一键复制</u-button>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
addInDetail,
addLotInfo,
uploadU9
} from "@/api/wms/purchase.js";
import SecondNumberChangeToConvert from "@/components/SecondNumberChangeToConvert/index.vue";
import {
updateInDetail,
getConnectLoc
} from "@/api/wms/pdcIn.js";
import {
listStock
} from "@/api/wms/stock.js"
// import { set } from "lodash";
export default {
onLoad: async function(option) {
console.log(option);
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.rkTime = formattedDate;
this.isSecondOpen = option.isSecondOpen == 'false' ? false : true;
this.selectedRow = JSON.parse(decodeURIComponent(option.selectedRow));
this.singleInfo = JSON.parse(decodeURIComponent(option.singleInfo));
this.wmsLotNoList = JSON.parse(decodeURIComponent(option.wmsLotNoList));
this.wmsLotNoList.map(item => {
item.storageInTime = formattedDate;
item.storageLocationBarcode = item.whCode ? (item.areaCode ? (
item.shelvesCode ? (item.storageLocationCode ? (item
.whCode + '-' + item.areaCode + '-' + item
.shelvesCode +
'-' + item.storageLocationCode) : (item.whCode +
'-' + item.areaCode + '-' + item
.shelvesCode
)) : (item.whCode + '-' + item.areaCode)) : item
.whCode) : ''
return item
})
console.log(this.wmsLotNoList);
this.recommend = await fnListStock(this.singleInfo)
this.eachNumber = option.eachNumber;
this.splitNumber = option.splitNumber;
this.index = option.index
/**
* 通过明细编码去获取库位
* @param {Object} list 明细信息
*/
async function fnListStock(list) {
const set = new Set()
await listStock({
materialCode: list.materialCode
}).then(res => {
const rows = res.rows;
for (let i in rows) {
if (rows[i].whCode != null && rows[i].areaCode != null && rows[i]
.storageLocationCode && rows[i].shelvesCode) {
set.add(rows[i].whCode + '-' + rows[i].areaCode + '-' + rows[i].shelvesCode +
'-' + rows[i].storageLocationCode)
}
}
})
return [...set].toString()
}
},
data() {
return {
recommend: null,
number: 1111,
//入库时间
rkTime: null,
//是否已分批
isSecondOpen: false,
selectedRow: {},
singleInfo: {},
wmsLotNoList: [],
eachNumber: null,
splitNumber: null,
index: null,
checkStorageLocationBarcode: true,
// storageLocationBarcode: ''
formData: {},
rules: {
// storageLocationBarcode: {
// rules: [{
// required: true,
// errorMessage: '请输入库位条码!'
// }]
// }
storageLocationBarcode: [{
required: true,
errorMessage: '请输入库位条码!'
}]
},
}
},
components: {
SecondNumberChangeToConvert
},
methods: {
eachNumberClear() {
this.eachSecondNumber = null;
this.splitNumber = null;
},
eachSecondNumberClear() {
this.eachNumber = null;
this.splitNumber = null;
},
splitNumberClear() {
this.eachNumber = null;
this.eachSecondNumber = null;
},
//选择条件拆分批次
multiSplit() {
this.wmsLotNoList = [];
let materialCode = this.singleInfo.materialCode;
let batchNo = this.singleInfo.materialBatchNo;
let unit = this.singleInfo.unit;
let unitId = this.singleInfo.unitId;
let secondUnitId = this.singleInfo.secondUnitId;
let purchaseInCode = this.singleInfo.purchaseInCode;
let materialName = this.singleInfo.materialName;
let specification = this.singleInfo.specification;
let unitName = this.singleInfo.unitName;
let u9StorageCode = this.singleInfo.u9StorageCode;
let storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
let u9LineId = this.singleInfo.u9LineId;
let connectedLocation = "";
let storageInTime = this.rkTime;
if (this.singleInfo.whCode != null) {
connectedLocation = this.singleInfo.whCode;
if (this.singleInfo.areaCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.areaCode;
if (this.singleInfo.shelvesCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.shelvesCode;
if (this.singleInfo.storageLocationCode != null) {
connectedLocation = connectedLocation + '-' + this.singleInfo.storageLocationCode;
}
}
}
}
let locCascade = [
this.singleInfo.whCode,
this.singleInfo.areaCode,
this.singleInfo.shelvesCode,
this.singleInfo.storageLocationCode,
];
if (this.eachNumber != null) {
let t;
let k;
t = parseInt(this.singleInfo.number / this.eachNumber);
k = this.singleInfo.number % this.eachNumber;
let rate;
let secondK;
let secondT;
rate = this.singleInfo.number / this.singleInfo.secondNumber;
secondT = parseInt(this.singleInfo.secondNumber / this.eachNumber);
secondK = this.singleInfo.secondNumber % this.eachNumber;
// if (k != 0) { t++; }
if (secondK != 0) {
secondT++;
}
for (let i = 0; i < secondT; i++) {
console.log(i)
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = this.eachNumber * rate;
obj.secondNumber = this.eachNumber;
obj.unit = unit;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.specification = specification;
obj.unitName = unitName;
obj.locCascade = locCascade;
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// this.selectLoc(locCascade, obj);
if (i == secondT - 1) {
if (secondK != 0) {
obj.number = secondK * rate;
obj.secondNumber = secondK;
}
}
// obj.lotNo = i + 1;
console.log(obj);
this.wmsLotNoList.push(obj);
}
} else if (this.splitNumber != null) {
let k;
let j;
const data = this.singleInfo[0] === undefined ? this.singleInfo : this.singleInfo[0]
k = parseInt(data.number / this.splitNumber);
j = data.number - (this.splitNumber - 1) * k;
let secondK;
let secondJ;
secondK = parseInt(data.secondNumber / this.splitNumber);
secondJ = data.secondNumber - (this.splitNumber - 1) * secondK;
for (let i = 0; i < this.splitNumber; i++) {
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = k;
obj.unit = unit;
obj.secondNumber = secondK;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.unitName = unitName;
obj.specification = specification;
obj.locCascade = locCascade;
// this.selectLoc(locCascade, obj);
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// obj.lotNo = i + 1;
if (i == this.splitNumber - 1) {
obj.number = j;
obj.secondNumber = secondJ;
}
this.wmsLotNoList.push(obj);
}
} else if (this.eachSecondNumber != 0) {
let t;
let k;
t = parseInt(this.singleInfo.secondNumber / this.eachSecondNumber);
k = this.singleInfo.secondNumber % this.eachSecondNumber;
if (k != 0) {
t++;
}
for (let i = 0; i < t; i++) {
let obj = {};
obj.recommend = this.recommend;
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.secondNumber = this.eachSecondNumber;
obj.secondUnit = secondUnit;
obj.storageInBillCode = purchaseInCode;
obj.materialName = materialName;
obj.unitName = unitName;
obj.secondNumber = this.eachSecondNumber;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.specification = specification;
obj.locCascade = locCascade;
obj.connectedLocation = connectedLocation;
obj.u9StorageCode = u9StorageCode;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.u9LineId = u9LineId;
obj.storageInTime = storageInTime;
// this.selectLoc(locCascade, obj);
if (i == t - 1) {
if (k != 0) {
obj.secondNumber = k;
}
}
// obj.lotNo = i + 1;
console.log(obj);
this.wmsLotNoList.push(obj);
}
}
},
/**
* 复制
*/
clickCopy(index) {
const data = this.wmsLotNoList
if (index != undefined) {
data[index].storageLocationBarcode = data[index].recommend
} else {
for (let i in data) {
data[i].storageLocationBarcode = data[i].recommend
}
}
this.wmsLotNoList = Object.assign({});
this.wmsLotNoList = data
},
//不拆分批次
async singleSplit() {
const set = new Set()
await listStock({
materialCode: this.singleInfo.materialCode
}).then(res => {
const rows = res.rows;
for (let i in rows) {
if (rows[i].whCode != null && rows[i].areaCode != null && rows[i]
.storageLocationCode && rows[i].shelvesCode) {
set.add(rows[i].whCode + '-' + rows[i].areaCode + '-' + rows[i]
.storageLocationCode + '-' + rows[i].shelvesCode)
}
}
})
const array = [...set].toString()
this.wmsLotNoList = [];
this.splitNumber = 1;
let obj = {};
obj.areaCode = array;
obj.recommend = this.recommend;
obj.materialCode = this.singleInfo.materialCode;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.secondNumber = this.singleInfo.secondNumber;
obj.secondUnit = this.singleInfo.secondUnit;
obj.storageInBillCode = this.singleInfo.purchaseInCode;
obj.number = this.singleInfo.number;
obj.unitId = this.singleInfo.unitId;
obj.secondUnitId = this.singleInfo.secondUnitId;
obj.unit = this.singleInfo.unit;
obj.unitName = this.singleInfo.unitName;
obj.materialName = this.singleInfo.materialName;
obj.specification = this.singleInfo.specification;
obj.u9StorageCode = this.singleInfo.u9StorageCode;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.u9LineId = this.singleInfo.u9LineId;
obj.storageInTime = this.rkTime;
if (this.singleInfo.whCode != null) {
obj.connectedLocation = this.singleInfo.whCode;
if (this.singleInfo.areaCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo.areaCode;
if (this.singleInfo.shelvesCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo.shelvesCode;
if (this.singleInfo.storageLocationCode != null) {
obj.connectedLocation = obj.connectedLocation + '-' + this.singleInfo
.storageLocationCode;
}
}
}
}
obj.locCascade = [
this.singleInfo.whCode,
this.singleInfo.areaCode,
this.singleInfo.shelvesCode,
this.singleInfo.storageLocationCode,
];
// this.selectLoc(obj.locCascade, obj);
// obj.lotNo = 1;
this.wmsLotNoList.push(obj);
console.log(this.wmsLotNoList);
},
async splitStlBarcode(i, event) {
const _this = this;
const detail = _this.wmsLotNoList[i];
detail.whCode = null;
detail.areaCode = null;
detail.shelvesCode = null;
detail.storageLocationCode = null;
let barcode = detail.storageLocationBarcode;
if (!barcode) {
return; // 如果没有条码,不做任何处理
}
let [whCode, areaCode, shelvesCode, storageLocationCode, extra] = barcode.split('-');
const data = await getConnectLoc({
connectLoc: event
})
if (!data.data) return this.$modal.msg("库位条码校验错误,请重新输入!")
_this.checkStorageLocationBarcode = true;
detail.whCode = whCode || null;
detail.areaCode = areaCode || null;
detail.shelvesCode = shelvesCode || null;
detail.storageLocationCode = extra ? `${storageLocationCode}-${extra}` : storageLocationCode || null;
console.log(this.wmsLotNoList[i]);
},
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.wmsLotNoList[i], "storageLocationBarcode", res
.result);
_this.splitStlBarcode(i);
}
});
},
//提交分批入库详情
async submit() {
// const valid = await this.$refs.form.validate();
// if (valid) {
// this.$refs.form.validate().then(res => {
let isStorageLocationBarcode = true;
for (var i in this.wmsLotNoList) {
if (this.wmsLotNoList[i].storageLocationBarcode == null || this.wmsLotNoList[i]
.storageLocationBarcode == '') isStorageLocationBarcode = false
}
if (isStorageLocationBarcode) {
//数量防错
let allNum = 0;
for (var i in this.wmsLotNoList) {
allNum += this.wmsLotNoList[i].number;
}
console.log(allNum, this.singleInfo.number)
if (this.wmsLotNoList.length > 0) {
if (this.wmsLotNoList[0].id != null) {
console.log(this.wmsLotNoList[0].id);
for (let i = 0; i < this.wmsLotNoList.length; i++) {
// if (this.wmsu9whMode == "true") {
// console.log(this.wmsu9whMode);
// updateU9Stock(this.wmsLotNoList[i]);
// } else {
// updateStock(this.wmsLotNoList[i]);
// }
if (this.wmsLotNoList && this.wmsLotNoList.length >
0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
}
this.$modal.msgSuccess("编辑成功!");
setTimeout(() => {
uni.$emit('backWithParam', {
status: this.selectedRow.status,
index: this.index
});
this.$tab.navigateBack();
}, 500);
} else {
let obj = {};
obj = this.singleInfo;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.eachNumber = this.eachNumber;
obj.splitNumber = this.splitNumber;
if (this.wmsLotNoList && this.wmsLotNoList.length >
0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
if (!this.checkStorageLocationBarcode) {
this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
this.$modal.loading('提交中')
addLotInfo(obj).then(res => {
addInDetail(this.wmsLotNoList, 1).then(res => {
uploadU9(this.wmsLotNoList)
this.$modal.closeLoading();
this.$modal.msgSuccess("编辑成功!");
// setTimeout(() => {
uni.$emit(
'backWithParam', {
status: this
.selectedRow
.status,
index: this
.index
});
this.$tab.navigateBack();
// }, 500);
})
});
}
}
// if (allNum == this.singleInfo.number) {
// if (this.wmsLotNoList.length > 0) {
// if (this.wmsLotNoList[0].id != null) {
// console.log(this.wmsLotNoList[0].id);
// for (let i = 0; i < this.wmsLotNoList.length; i++) {
// // if (this.wmsu9whMode == "true") {
// // console.log(this.wmsu9whMode);
// // updateU9Stock(this.wmsLotNoList[i]);
// // } else {
// // updateStock(this.wmsLotNoList[i]);
// // }
// if (this.wmsLotNoList && this.wmsLotNoList.length >
// 0) {
// this.selectedRow.status = "1";
// } else {
// this.selectedRow.status = "0";
// }
// }
// this.$modal.msgSuccess("编辑成功!");
// setTimeout(() => {
// uni.$emit('backWithParam', {
// status: this.selectedRow.status,
// index: this.index
// });
// this.$tab.navigateBack();
// }, 500);
// } else {
// let obj = {};
// obj = this.singleInfo;
// obj.batchNo = this.singleInfo.materialBatchNo;
// obj.eachNumber = this.eachNumber;
// obj.splitNumber = this.splitNumber;
// if (this.wmsLotNoList && this.wmsLotNoList.length >
// 0) {
// this.selectedRow.status = "1";
// } else {
// this.selectedRow.status = "0";
// }
// if (!this.checkStorageLocationBarcode) {
// this.$modal.msg("库位条码校验错误,请重新输入!")
// return;
// }
// this.$modal.loading('提交中')
// addLotInfo(obj).then(res => {
// addInDetail(this.wmsLotNoList, 1).then(res => {
// uploadU9(this.wmsLotNoList)
// this.$modal.closeLoading();
// this.$modal.msgSuccess("编辑成功!");
// // setTimeout(() => {
// uni.$emit(
// 'backWithParam', {
// status: this
// .selectedRow
// .status,
// index: this
// .index
// });
// this.$tab.navigateBack();
// // }, 500);
// })
// });
// }
// }
// } else {
// this.$modal.msg("批号分批入库明细数量不符合!");
// }
} else {
this.$modal.msg("库位条码必填!");
}
// })
}
},
}
</script>
<style>
.cu-card.article>.cu-item .content .text-content {
height: 100% !important;
}
.cu-card.article>.cu-item {
padding-bottom: 0;
}
.cu-card>.cu-item {
margin: 0;
}
.uni-swipe {
overflow: inherit;
}
</style>

View File

@@ -0,0 +1,625 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<!-- <uni-collapse-item title="采购质检单" :open="true"> -->
<uni-forms-item label="收货单" :labelWidth='90' name="purchaseReceiveCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode"
v-model="formData.purchaseReceiveCode" type="text" />
</uni-forms-item>
<uni-forms-item label="质检单" :labelWidth='90' name="purchaseQualityCode"
v-show="formData.purchaseQualityCode">
<uni-easyinput v-model="formData.purchaseQualityCode" type="text" disabled />
</uni-forms-item>
<uni-forms-item label="附件" :labelWidth='90' name="enclosure">
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
:maxCount="10" :previewFullImage="true"></u-upload>
</uni-forms-item>
<uni-forms-item label="质检方式" :labelWidth='90'>
<u-radio-group v-model="value" iconPlacement="left">
<u-radio label="正常" name="正常"></u-radio>
<u-radio label="扫物料标签" name="扫物料标签" style="margin-left: 10px;"></u-radio>
</u-radio-group>
</uni-forms-item>
<button size="mini" v-if="value=='扫物料标签' &&formData.wmsPurchaseQualityDetailList.length == 0"
type="primary" style="text-align: center;margin-left: 30%;font-size: 18px;"
@click="show=!show">添加物料标签</button>
<u-modal :show="show" title="扫描物料标签编码" showCancelButton closeOnClickOverlay
@cancel="cancelMaterialLabel" @close="cancelMaterialLabel" :showConfirmButton="false">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarMaterialLabel" v-model="materialLabel"
type="text" @confirm="confirmMaterialLabel" maxlength="-1" :focus="true" />
</u-modal>
<!-- </uni-collapse-item> -->
<uni-collapse-item title="采购质检单明细" :open="true">
<uni-swipe-action>
<uni-swipe-action-item :rightOptions="rightOptions" :key="index"
v-for="(item, index) in formData.wmsPurchaseQualityDetailList"
@click="(data) => clickDetail(index,data)">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :labelWidth='90'
:name="'wmsPurchaseQualityDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'
:name="'wmsPurchaseQualityDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="实收数量" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'.secondActualNumber'">
<uni-easyinput disabled type="number" v-model="item.secondActualNumber" />
</uni-forms-item>
<uni-forms-item label="质检数量" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'secondNumber'">
<second-number-change-to-convert :materialCode="item.materialCode"
:secondNumber.sync="item.secondNumber" :secondUnitId="item.secondUnitId"
:number.sync="item.number" :unitId="item.unitId"
@input="(data) => inputNUmber(index,data)"
></second-number-change-to-convert>
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.number" min="0"
@change="getBackNumber(index)"></u-number-box> -->
<!-- <uni-easyinput type="number" v-model="item.number"
@change="(data) => getBackNumber(index,data)" /> -->
</uni-forms-item>
<uni-forms-item label="合格数量" :labelWidth='90'
name="'wmsPurchaseQualityDetailList'+ index +'.secondPassNumber'">
<second-number-change-to-convert-new :materialCode="item.materialCode"
:key="item.passNumber"
:secondNumber.sync="item.secondPassNumber" :secondUnitId="item.secondUnitId"
:number.sync="item.passNumber"
:unitId="item.unitId"
@change="(data) => getCompare(item,data)"></second-number-change-to-convert-new>
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.passNumber" min="0"
@change="getBackNumber(index)"></u-number-box> -->
</uni-forms-item>
<uni-forms-item label="应入数量" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'.secondInNumber'">
<!-- 之前代码 -->
<!-- <second-number-change-to-convert :materialCode="item.materialCode"
:secondNumber.sync="item.secondInNumber" :secondUnitId="item.secondUnitId"
:number.sync="item.inNumber" :unitId="item.unitId"
@change="(data) => getBackNumber('secondInNumber',item,data)"></second-number-change-to-convert> -->
<uni-easyinput type="number" v-model="item.secondInNumber" @input="(data) => getBackNumber('secondInNumber',item,data)"/>
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.secondInNumber" min="0"
@change="(data) => getBackNumber(index,data)"
:max="item.actualNumber"></u-number-box> -->
<!-- <uni-row style="margin-top: 10px;">
<uni-col :span="12">
<button size="mini" type="primary" style="font-size: 16px;"
@click="item.inNumber = item.actualNumber">全部入库</button>
</uni-col>
<uni-col :span="12">
<button size="mini" type="primary" style="font-size: 16px;"
@click="item.inNumber = 0">全部退回</button>
</uni-col>
</uni-row> -->
</uni-forms-item>
<uni-forms-item label="退回数量" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'.backNumber'">
<uni-easyinput type="number" v-model="item.backNumber" @input="(data) => getBackNumber('backNumber',item,data)"/>
</uni-forms-item>
<uni-forms-item label="不良原因" :labelWidth='90'
name="'wmsPurchaseQualityDetailList.'+ index +'.failReason'">
<uni-easyinput type="textarea" v-model="item.failReason" />
</uni-forms-item>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
uploadImage,
getStandardList,
addQualityHistoryList,
listQualityHistory,
updateQualityHistory
} from "@/api/qc/qc.js";
import {
addReceive,
listReceive,
listQuality,
getReceive,
addQuality,
updateQuality,
getReceiveDetail,
getQualityDetail,
getQualityReceiveDetail,
getDetailListsBySRM
} from "@/api/wms/purchase.js";
import {
listMaterial
} from "@/api/wms/request.js";
import {
getConfigKey,
} from "@/api/wms/materRequisitiontask";
import SecondNumberChangeToConvert from "@/components/SecondNumberChangeToConvert/index.vue";
import SecondNumberChangeToConvertNew from "@/components/SecondNumberChangeToConvert/index-.vue";
import {
toast,
} from '@/utils/common'
export default {
mounted() {
getConfigKey('wms.app').then(res => {
if(getKey('purchaseQualityT',res.msg) === 'Y'){
this.value='扫物料标签'
}
/**
* 获取wms.app的值
* @param {Object} name 要获取的字段
* @param {Object} json 要转换的数据默认res.msg
*/
function getKey(name,json){
return JSON.parse(json)[name]
}
});
},
data() {
return {
isSupplierCode: false,
isQualited: false,
value: '正常',
show: false,
materialLabel: null,
fileList1: [],
formData: {
purchaseReceiveCode: null,
purchaseQualityCode: null,
enclosure: null,
wmsPurchaseQualityDetailList: []
},
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
passNumber: {
rules: [{
required: true,
errorMessage: '请输入质检数量!'
}]
},
purchaseReceiveCode: {
rules: [{
required: true,
errorMessage: '请输入采购收货单!'
}]
},
},
listStyles: {
// 是否显示边框
border: true,
// 是否显示分隔线
dividline: true,
// 线条样式
borderStyle: {
width: 1,
color: 'blue',
style: 'dashed',
radius: 2
}
},
}
},
components: {
SecondNumberChangeToConvert,
SecondNumberChangeToConvertNew,
},
methods: {
// getCompare1(e){
// console.log('质检数量改变');
// // console.log('111');
// },
getCompare(item,data){
if(data>item.secondNumber){
uni.showToast({
title: '合格数量不能大于质检数量',
icon: 'none',
duration: 2000
})
// this.$set(item, "secondPassNumber", item.secondNumber)
// this.$forceUpdate()
item.secondPassNumber=item.secondNumber
// console.log("1414",item.secondPassNumber);
}
},
//获取退回数量
getBackNumber(name,item,e) {
//输入的应收数量
if(name === 'secondInNumber'){
if (e > item.secondActualNumber) {
toast("应入数量不能大于实收数量");
return false
}
item.backNumber = item.secondActualNumber - e
}
if(name === 'backNumber'){
if (e > item.secondActualNumber) {
toast("退回数量不能大于实收数量");
return false
}
item.secondInNumber = item.secondActualNumber - e
}
this.formData = Object.assign({},this.formData)
},
// getBackNumber(index, data) {
// if (data) {
// this.formData.wmsPurchaseQualityDetailList[index].backNumber = this.formData
// .wmsPurchaseQualityDetailList[
// index]
// .actualNumber - data.value
// } else {
// this.formData.wmsPurchaseQualityDetailList[index].backNumber = this.formData
// .wmsPurchaseQualityDetailList[
// index]
// .actualNumber - this.formData
// .wmsPurchaseQualityDetailList[
// index]
// .inNumber
// }
// },
deleteDetail(index) {
this.formData.wmsPurchaseQualityDetailList.splice(index, 1);
},
clickDetail(itemIndex, {
position,
index
}) {
if (index == 0) {
this.deleteDetail(itemIndex);
}
},
addMaterialLabel() {
this.show = true;
},
cancelMaterialLabel() {
this.materialLabel = null;
this.show = false;
},
confirmMaterialLabel(data) {
//判断是否供应商扫码
if (data.includes('@')) {
this.isSupplierCode = true;
let array = data.split('@');
let new_supplierCode = array[0];
let new_u9SourceBillCode = array[3].split('|')[0];
let new_erpDocCode1 = array[4].split('|')[0];
let new_erpDocLineKey1 = array[4].split('|')[1];
getDetailListsBySRM({
u9SourceBillCode: new_u9SourceBillCode,
erpDocCode1: new_erpDocCode1,
erpDocLineKey1: new_erpDocLineKey1
}).then(res => {
//判断有没有质检(先查质检-再查收货)
if (res.qualityList.length == 0) {
//没有质检
//判断有没有收货
// if (res.receiveDetailList.length == 0) {
// this.$modal.msg("该条物料还未收货!")
// } else {
// //判断有没有完成收货
// if (res.receiveDetailList[0].theoryNumber == res.receiveDetailList[0]
// .actualNumber) {
// getQualityReceiveDetail({
// purchaseReceiveCode: res.receiveDetailList[0].purchaseReceiveCode,
// status: '1'
// }).then((res) => {
// console.log(res);
// this.formData = res.qualityBill;
// this.formData.purchaseQualityDetailList = res.qualityBill
// .wmsPurchaseQualityDetailList;
// });
// } else {
this.$modal.msg("该条物料还未完成收货!")
// }
// }
} else {
this.isQualited = true;
//判断检验有无完成
if (res.qualityList[0].status == 3) {
this.$modal.msg("该条物料已完成检验!")
} else {
this.formData = res.qualityList[0];
this.formData.wmsPurchaseQualityDetailList = res.qualityList[0]
.purchaseQualityDetailList
}
}
})
this.materialLabel = null;
this.show = false;
} else {
data = JSON.parse(data)
if (data) {
getQualityDetail({
purchaseReceiveDetailId: data.id
}).then(res => {
//判断有没有质检
if (res.data.length > 0) {
this.formData.purchaseReceiveCode = res.data[0].purchaseReceiveCode;
this.formData.purchaseQualityCode = res.data[0].purchaseQualityCode;
this.formData.supplierCode = res.data[0].supplierCode;
this.formData.supplierName = res.data[0].supplierName;
//代入主表id
this.formData.id = res.data[0].purchaseQualityId;
const data = res.data[0];
data.inNumber = data.secondInNumber;
data.backNumber = 0
this.formData.wmsPurchaseQualityDetailList.push(data);
this.materialLabel = null;
this.show = false;
// this.$modal.msg("该条物料已质检!");
} else {
getReceiveDetail(data.id).then(res => {
//判断有没有收货
if (res.data.actualNumber != null) {
let obj = {
materialCode: res.data.materialCode,
materialName: res.data.materialName,
materialBatchNo: res.data.materialBatchNo,
actualNumber: res.data.actualNumber,
number: res.data.number,
purchaseReceiveDetailId: data.id,
passNumber: 0,
unitId: res.data.unitId,
inNumber: res.data.secondInNumber,
secondNumber: res.data.secondActualNumber,
secondUnitId: res.data.secondActualUnitId,
secondInNumber: res.data.secondInNumber,
}
this.formData.supplierCode = res.data.supplierCode;
this.formData.supplierName = res.data.supplierName;
this.formData.purchaseReceiveCode = res.data.purchaseReceiveCode;
this.formData.wmsPurchaseQualityDetailList.push(obj);
this.materialLabel = null;
this.show = false;
} else {
this.$modal.msg("该条物料还没有收货,无法质检!");
}
})
}
})
};
}
},
scanBarMaterialLabel() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.materialLabel = res.result;
// console.log(materialLabel)
_this.confirmMaterialLabel(_this.materialLabel);
}
});
},
// 删除图片
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
// 新增图片
async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
// console.log(item)
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
let a = uploadImage({
filePath: url
}).then(response => {
uni.showToast({
title: "上传成功",
icon: 'success'
});
this.formData.enclosure = response.fileName
resolve(response.url)
});
})
},
reset(code) {
this.formData = {
purchaseReceiveCode: code,
wmsPurchaseQualityDetailList: [],
};
},
scanBarCode(code) {
// if (code){
// this.reset(code);
// }
if (code) {
let q = {
purchaseReceiveCode: code
}
listReceive(q).then(async res => {
if (res.rows != null && res.rows.length > 0) {
let did = res.rows[0].id
getReceive(did).then(async res => {
for (let i in res.data
.wmsPurchaseReceiveDetailList) {
let obj = {};
obj.materialBatchNo = res.data
.wmsPurchaseReceiveDetailList[i]
.materialBatchNo;
obj.materialCode = res.data
.wmsPurchaseReceiveDetailList[i]
.materialCode;
obj.materialName = res.data
.wmsPurchaseReceiveDetailList[i]
.materialName;
obj.actualNumber = res.data
.wmsPurchaseReceiveDetailList[i]
.actualNumber;
obj.number = res.data
.wmsPurchaseReceiveDetailList[i]
.actualNumber;
obj.secondActualNumber = res.data
.wmsPurchaseReceiveDetailList[i]
.secondActualNumber;
this.formData.wmsPurchaseQualityDetailList.push(
obj);
}
});
} else {
this.$modal.msg("未检索到收货明细!");
}
});
}
},
//采购任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.purchaseReceiveCode = res.result;
_this.scanBarCode(_this.formData.purchaseReceiveCode);
}
});
},
submit() {
const _this = this;
if(!getNumber(_this.formData.wmsPurchaseQualityDetailList,'secondActualNumber','secondInNumber','backNumber','materialCode')) return
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成该质检吗?',
success: function(res) {
if (res.confirm) {
if (_this.formData.id != null) {
_this.$modal.loading('提交中')
for(let i in _this.formData.wmsPurchaseQualityDetailList){
_this.formData.wmsPurchaseQualityDetailList[i].inNumber = _this.formData.wmsPurchaseQualityDetailList[i].secondInNumber
}
updateQuality(_this.formData).then(res => {
_this.$modal.msgSuccess("质检成功!");
setTimeout(() => {
_this.$modal.closeLoading();
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
})
} else {
let wmsPurchaseQualityDetailList = [];
for (let i in _this.formData
.wmsPurchaseQualityDetailList) {
let obj = {};
obj.materialCode = _this.formData
.wmsPurchaseQualityDetailList[i]
.materialCode;
obj.materialName = _this.formData
.wmsPurchaseQualityDetailList[i]
.materialName;
obj.materialBatchNo = _this.formData
.wmsPurchaseQualityDetailList[i]
.materialBatchNo;
obj.number = _this.formData
.wmsPurchaseQualityDetailList[i].number;
obj.passNumber = Number(_this.formData
.wmsPurchaseQualityDetailList[i]
.passNumber);
obj.failReason = _this.formData
.wmsPurchaseQualityDetailList[i]
.failReason;
wmsPurchaseQualityDetailList.push(obj);
}
let enclosure = null;
if (_this.fileList1.length > 0) {
enclosure = _this.fileList1.map(obj => obj.url)
.join(', ');
}
for(let i in _this.formData.wmsPurchaseQualityDetailList){
_this.formData.wmsPurchaseQualityDetailList[i].inNumber = _this.formData.wmsPurchaseQualityDetailList[i].secondInNumber
}
let data = {
purchaseReceiveCode: _this.formData
.purchaseReceiveCode,
status: '1',
wmsPurchaseQualityDetailList: _this.formData
.wmsPurchaseQualityDetailList,
enclosure: enclosure
}
_this.$modal.loading('提交中')
addQuality(data).then(response => {
_this.$modal.msgSuccess("质检成功!");
setTimeout(() => {
_this.$modal.closeLoading();
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
}
} else if (res.cancel) {
}
}
});
});
/**
* 判断应入和退回和是否等于实收
* @param {Object} list 要比较的数据
* @param {Object} key1 secondActualNumber
* @param {Object} key2 secondInNumber
* @param {Object} key3 backNumber
* @param {Object} key4 materialCode
*/
function getNumber(list,key1,key2,key3,key4){
for(let i in list){
if(list[i][key1] != parseInt(list[i][key2]) +parseInt(list[i][key3])){
_this.$modal.msg("物料编码为 " + list[i][key4] + "的单子应入和退回不等于实收");
return false
}
}
return true
}
},
/**
* 修改质检数量,合格数量跟随改变
* @param {Object} index 当前修改数据的下标
* @param {Object} data 当前修改的数据
*/
inputNUmber(index,data){
const arr = this.formData.wmsPurchaseQualityDetailList
arr[index].passNumber =arr[index].secondPassNumber = parseInt(data)
}
}
}
</script>
<style>
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,546 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<!-- <uni-collapse-item title="采购收货单" :open="true"> -->
<uni-forms-item v-if="value=='正常' && !formData.u9SourceBillCode" label="采购任务单" :labelWidth='90'
name="purchaseTaskCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarTaskCode"
v-model="formData.purchaseTaskCode" type="text" />
</uni-forms-item>
<uni-forms-item v-if="value=='扫物料标签'" label="采购收货单" :labelWidth='90' name="purchaseReceiveCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarTaskCode"
v-model="formData.purchaseReceiveCode" type="text" />
</uni-forms-item>
<uni-forms-item v-if="!formData.u9SourceBillCode" label="采购订单号" :labelWidth='90' name="purchaseCode">
<uni-combox :candidates="purchaseCodeList" emptyTips="无" @input="scanBarPurchaseCode"
v-model="formData.purchaseCode"></uni-combox>
</uni-forms-item>
<uni-forms-item v-if="formData.supplierCode" label="供应商代码" :labelWidth='90' name="supplierCode">
<uni-easyinput v-model="formData.supplierCode" type="text" disabled />
</uni-forms-item>
<uni-forms-item v-if="formData.u9SourceBillCode" label="采购订单号" :labelWidth='90' name="u9SourceBillCode">
<uni-easyinput v-model="formData.u9SourceBillCode" type="text" disabled />
</uni-forms-item>
<uni-forms-item v-if="formData.remark" label="备注" :labelWidth='90' name="remark">
<uni-easyinput v-model="formData.remark" type="text" disabled />
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarscanBarwarehouseCode"
v-model="formData.warehouseCode" />
<uni-data-select v-model="formData.warehouseCode" :localdata="wcList"
style="margin-top: 10px;"></uni-data-select>
</uni-forms-item>
<!-- <uni-forms-item label="收货方式" :labelWidth='90' name="receiveWay"> -->
<u-radio-group v-model="value" iconPlacement="left" style="font-size: 14px;margin-bottom: 20px;">收货方式
<u-radio label="正常" name="正常" style="margin-left: 40px;"></u-radio>
<u-radio label="扫物料标签" name="扫物料标签" style="margin-left: 10px;"></u-radio>
</u-radio-group>
<!-- </uni-forms-item> -->
<button size="mini" v-if="value=='扫物料标签'" type="primary"
style="text-align: center;margin-left: 30%;font-size: 18px;margin-top: 15px;"
@click="show=!show">添加物料标签</button>
<u-modal :show="show" title="扫描物料标签编码" showCancelButton closeOnClickOverlay
@cancel="cancelMaterialLabel" @close="cancelMaterialLabel" :showConfirmButton="false">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarMaterialLabel" v-model="materialLabel"
type="text" @confirm="confirmMaterialLabel" maxlength="-1" :focus="true" />
</u-modal>
<!-- </uni-collapse-item> -->
<!-- <uni-collapse-item title="采购收货单单明细" :open="true"> -->
<!-- <uni-swipe-action> -->
<view v-for="(item, index) in formData.wmsPurchaseReceiveDetailList" :key="index"
@click="(data) => clickDetail(index,data)" :right-options="rightOptions">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'>
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="箱号" :labelWidth='90' v-if="item.remark">
<uni-easyinput disabled type="text" v-model="item.remark" />
</uni-forms-item>
<uni-forms-item label="应收数量" :labelWidth='90'>
<uni-easyinput disabled type="number" v-model="item.theoryNumber" />
</uni-forms-item>
<uni-forms-item label="已收数量" :labelWidth='90'>
<uni-easyinput disabled type="number" v-model="item.rcvNum" />
</uni-forms-item>
<uni-forms-item label="入库数量" :labelWidth='90'>
<uni-easyinput disabled type="number" v-model="item.quaInNum" />
</uni-forms-item>
<uni-forms-item label="退回数量" :labelWidth='90'>
<uni-easyinput disabled type="number" v-model="item.backNum" />
</uni-forms-item>
<uni-forms-item label="到货数量" :labelWidth='90'>
<uni-easyinput type="number" v-model="item.arriveNumber" />
<!-- <u-number-box inputWidth="120" button-size="36" v-model="item.arriveNumber"
:max="item.theoryNumber" min="0"></u-number-box> -->
</uni-forms-item>
<uni-forms-item label="实收数量" :labelWidth='90'>
<uni-row>
<uni-col :span="12">
<second-number-change-to-convert :materialCode="item.materialCode"
:secondNumber.sync="item.secondActualNumber" :secondUnitId="item.secondActualUnitId"
:number.sync="item.actualNumber"
:unitId="item.unitId"></second-number-change-to-convert>
</uni-col>
<uni-col :span="12">
<select-unit-convertible v-model="item.secondActualUnitId"
:materialCode="item.materialCode" :secondNumber.sync="item.secondActualNumber"
:number="item.actualNumber" :unitId="item.unitId"></select-unit-convertible>
</uni-col>
</uni-row>
</uni-forms-item>
</view>
<!-- </uni-swipe-action-item> -->
<!-- </uni-swipe-action> -->
<!-- </uni-collapse-item> -->
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
</uni-collapse>
</view>
</template>
<script>
import {
addReceive,
getTask,
listTask,
getDetail,
updateReceive,
updateReceiveDetail,
getDetailByPoCode,
getReceiveDetailJoin,
getDetailListsBySRM,
listSupplier
} from "@/api/wms/purchase.js";
import {
getConfigKey,
} from "@/api/wms/materRequisitiontask";
import {
values
} from "lodash";
import {
listWarehouse
} from "@/api/wms/warehouse";
import selectUnitConvertible from "@/components/selectUnitConvertible/index.vue";
import SecondNumberChangeToConvert from "@/components/SecondNumberChangeToConvert/index.vue";
export default {
mounted() {
getConfigKey('wms.app').then(res => {
if(getKey('purchaseSh',res.msg) === 'Y'){
this.value='扫物料标签'
}
/**
* 获取wms.app的值
* @param {Object} name 要获取的字段
* @param {Object} json 要转换的数据默认res.msg
*/
function getKey(name,json){
return JSON.parse(json)[name]
}
});
listTask().then((response) => {
for (var i = 0; i < response.rows.length; i++) {
this.purchaseCodeList.push(response.rows[i].purchaseCode);
}
});
listWarehouse().then((res) => {
this.wcList = res.rows.map(item => {
let obj = {
text: item.warehouseName,
value: item.warehouseCode
}
return obj
})
})
},
components: {
selectUnitConvertible,
SecondNumberChangeToConvert
},
data() {
return {
wcList: [],
isSupplierCode: false,
isReceived: false,
purchaseCodeList: [],
value: '正常',
show: false,
materialLabel: null,
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
formData: {
purchaseTaskCode: null,
purchaseReceiveCode: null,
wmsPurchaseReceiveDetailList: [],
warehouseCode: null,
//任务单状态=1=‘新建’
status: '1'
},
rules: {
// purchaseTaskCode: {
// rules: [{
// required: true,
// errorMessage: '请输入采购任务单!'
// }]
// },
warehouseCode: {
rules: [{
required: false,
errorMessage: '请输入仓库编码!'
}]
},
}
}
},
methods: {
scanBarPurchaseCode() {
if (this.formData.purchaseCode) {
getDetailByPoCode(this.formData.purchaseCode).then(res => {
console.log(res)
let purchaseCode = this.formData.purchaseCode
this.formData = res.receiveBill
this.formData.purchaseCode = purchaseCode
})
} else {
this.$modal.msg("请输入采购订单号!");
}
},
deleteDetail(index) {
this.formData.wmsPurchaseReceiveDetailList.splice(index, 1);
},
clickDetail(itemIndex, {
position,
index
}) {
if (index == 0) {
this.deleteDetail(itemIndex);
}
},
addMaterialLabel() {
this.show = true;
},
cancelMaterialLabel() {
this.materialLabel = null;
this.show = false;
},
confirmMaterialLabel(data) {
//判断是否供应商扫码
if (data.includes('@')) {
this.isSupplierCode = true;
let array = data.split('@');
let new_supplierCode = array[0];
let new_u9SourceBillCode = array[3].split('|')[0];
let new_erpDocCode1 = array[4].split('|')[0];
let new_erpDocLineKey1 = array[4].split('|')[1];
let lotNo = array[4].split('|')[2];
let supplierCode = null;
console.log(new_erpDocLineKey1, lotNo);
getDetailListsBySRM({
u9SourceBillCode: new_u9SourceBillCode,
erpDocCode1: new_erpDocCode1,
erpDocLineKey1: new_erpDocLineKey1
}).then(res => {
console.log(res)
//查供应商编码
listSupplier({
remark: new_supplierCode
}).then(res => {
if (res.rows.length > 0) {
supplierCode = res.rows[0].supplierCode
}
})
//判断有没有进行收货
//未收货
if (res.receiveDetailList.length == 0) {
//判断是总码还是外箱,外箱码是多加一个箱数量
if (array.length < 7) {
//总码
let obj = {
materialCode: array[1],
materialBatchNo: array[2],
theoryNumber: Number(array[5]),
arriveNumber: Number(array[5]),
actualNumber: Number(array[5]),
//ASN行号
erpDocLineKey1: new_erpDocLineKey1,
}
//供应商代码
this.formData.supplierCode = supplierCode;
//采购订单号
this.formData.u9SourceBillCode = new_u9SourceBillCode;
//ASN单号
this.formData.erpDocCode1 = new_erpDocCode1;
this.formData.wmsPurchaseReceiveDetailList.push(obj);
} else {
//外箱,会出现多次扫码的情况
//判断当前单据下是否已扫描添加过明细
if (this.formData.wmsPurchaseReceiveDetailList.length > 0) {
//有明细
//判断是否为同一个主表下的同一物料
if (this.formData.u9SourceBillCode == new_u9SourceBillCode && this.formData
.erpDocCode1 == new_erpDocCode1 && this.formData
.wmsPurchaseReceiveDetailList[0].erpDocLineKey1 == new_erpDocLineKey1) {
//判断箱号有无重复
if (this.formData.wmsPurchaseReceiveDetailList.find(item => item.remark
.includes(lotNo))) {
this.$modal.msg("该条物料已添加!")
} else {
this.formData.wmsPurchaseReceiveDetailList[0].remark = this.formData
.wmsPurchaseReceiveDetailList[0].remark + ',' + lotNo
this.formData.wmsPurchaseReceiveDetailList[0].arriveNumber += Number(
array[
5]);
this.formData.wmsPurchaseReceiveDetailList[0].actualNumber += Number(
array[
5]);
}
} else {
this.$modal.msg("该条物料与现有明细不在同一ASN行号下")
}
} else {
//没明细
let obj = {
materialCode: array[1],
materialBatchNo: array[2],
theoryNumber: Number(array[6]),
arriveNumber: Number(array[5]),
actualNumber: Number(array[5]),
//ASN行号
erpDocLineKey1: array[4].split('|')[1],
remark: lotNo
}
//供应商代码
this.formData.supplierCode = supplierCode;
//采购订单号
this.formData.u9SourceBillCode = new_u9SourceBillCode;
//ASN单号
this.formData.erpDocCode1 = new_erpDocCode1;
this.formData.wmsPurchaseReceiveDetailList.push(obj);
}
}
} else {
//已收货存在收货明细
this.isReceived = true;
//判断收货有无完成
if (res.receiveDetailList[0].actualNumber == res.receiveDetailList[0]
.theoryNumber) {
this.$modal.msg("该条物料已完成收货!")
} else {
//判断当前表单是否已有明细
if (this.formData.wmsPurchaseReceiveDetailList.length > 0) {
//判断是否为同一个主表下的同一物料
if (this.formData.u9SourceBillCode == new_u9SourceBillCode && this.formData
.erpDocCode1 == new_erpDocCode1 && this.formData
.wmsPurchaseReceiveDetailList[0].erpDocLineKey1 == new_erpDocLineKey1) {
//判断箱号有无重复
if (this.formData.wmsPurchaseReceiveDetailList.find(item => item.remark
.includes(lotNo))) {
this.$modal.msg("该条物料已添加!")
} else {
this.formData.wmsPurchaseReceiveDetailList[0].remark = this.formData
.wmsPurchaseReceiveDetailList[0].remark + ',' + lotNo
this.formData.wmsPurchaseReceiveDetailList[0].arriveNumber += Number(
array[
5]);
this.formData.wmsPurchaseReceiveDetailList[0].actualNumber += Number(
array[
5]);
}
} else {
this.$modal.msg("该条物料与现有明细不在同一ASN单号下")
}
} else {
//判断箱号有无重复
if (res.receiveDetailList.find(item => item.remark
.includes(lotNo))) {
this.$modal.msg("该条物料已添加!")
} else {
//供应商代码
this.formData.supplierCode = supplierCode;
//采购订单号
this.formData.u9SourceBillCode = new_u9SourceBillCode;
//ASN单号
this.formData.erpDocCode1 = new_erpDocCode1;
res.receiveDetailList[0].remark = res.receiveDetailList[0].remark + ',' +
lotNo
res.receiveDetailList[0].arriveNumber += Number(array[5]);
res.receiveDetailList[0].actualNumber += Number(array[5]);
this.formData.wmsPurchaseReceiveDetailList = res.receiveDetailList;
}
}
}
}
})
this.materialLabel = null;
this.show = false;
} else {
data = JSON.parse(data)
if (data) {
//判断后续输入的物料明细是否与第一条绑定的收货单一致
if (this.formData.purchaseReceiveCode) {
//添加过物料标签,加入判断
getReceiveDetailJoin(data.id).then(res => {
if (res.data) {
if (res.data.purchaseReceiveCode !== this.formData
.purchaseReceiveCode) {
this.$modal.msg("与上一条输入的物料标签编码的收货单不一致!")
} else {
//若与上一条输入的物料标签编码的收货单一致则进行物料id判断
let a = this.formData.wmsPurchaseReceiveDetailList.find(item => item.id ==
data
.id)
//id添加过
if (typeof(this.formData.wmsPurchaseReceiveDetailList.find(item => item
.id ==
data
.id)) ===
'object') {
this.$modal.msg("该条物料标签已添加!")
} else {
this.formData.wmsPurchaseReceiveDetailList.push(res.data);
this.materialLabel = null;
this.show = false;
}
}
} else {
this.$modal.msg("未查询到该明细!")
}
})
} else {
//没有添加过物料标签,则跳过判断直接添加
getReceiveDetailJoin(data.id).then(res => {
if (res.data) {
this.formData.purchaseReceiveCode = res.data.purchaseReceiveCode
this.formData.wmsPurchaseReceiveDetailList.push(res.data);
this.materialLabel = null;
this.show = false;
} else {
this.$modal.msg("未查询到该明细!")
}
})
}
}
}
},
scanBarMaterialLabel() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.materialLabel = res.result;
// console.log(materialLabel)
_this.confirmMaterialLabel(_this.materialLabel);
}
});
},
//采购任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.purchaseTaskCode = res.result;
_this.scanBarTaskCode(res.result);
}
});
},
scanBarTaskCode(code) {
// let obj = {
// purchaseTaskCode: this.formData.purchaseTaskCode,
// };
// listReceive(obj).then((response) => {
// this.taskReceiveList = response.rows;
// });
getDetail(this.formData).then((res) => {
// console.log(res);
this.formData = res.receiveBill;
// this.formData.wmsPurchaseReceiveDetailList = res.receiveBill.wmsPurchaseReceiveDetailList;
});
// getDetail(this.formData).then((res) => {
// this.formData.wmsPurchaseReceiveDetailList = res.details;
// });
},
//仓库编码
scanBarscanBarwarehouseCode() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
submit() {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定收取该物料吗?',
success: function(res) {
if (res.confirm) {
if (_this.value == '正常' || _this.value == '扫物料标签' && _this
.isSupplierCode && !_this.isReceived) {
console.log(_this.formData)
_this.$modal.loading('提交中')
addReceive(_this.formData).then(async res => {
_this.$modal.msgSuccess("收货成功!");
setTimeout(() => {
_this.$modal.closeLoading();
_this.$tab.switchTab(
"/pages/work/index"
);
}, 500);
});
} else if (_this.value == '扫物料标签' || _this.value ==
'扫物料标签' &&
_this
.isSupplierCode && _this.isReceived) {
console.log(2)
_this.$modal.loading('提交中')
updateReceiveDetail(_this.formData
.wmsPurchaseReceiveDetailList)
.then(async res => {
_this.$modal.msgSuccess("收货成功!");
setTimeout(() => {
_this.$modal.msgSuccess("收货成功!");
_this.$tab.switchTab(
"/pages/work/index"
);
}, 500);
});
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
},
watch:{
value(newVal){
if(newVal === '扫物料标签'){
this.rules.warehouseCode.rules[0].required =false
}else{
this.rules.warehouseCode.rules[0].required =true
}
}
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,397 @@
<template>
<view id="view">
<div class="header">
<table>
<tr>
<td>物料代码:</td>
<td>
<uni-easyinput placeholder="请输入内容" :focus="PTfocus" v-model="PTCode" primaryColor="red" @confirm="getCode"
prefixIcon="scan" @iconClick="scanClick('primary')" />
</td>
</tr>
</table>
</div>
<div class="body">
<table>
<tr>
<td>收货单号:</td>
<td>{{form.purchaseReceiveCode}}</td>
</tr>
<tr>
<td>&numsp;&numsp;:</td>
<td>{{form.supplierCode}}{{form.supplierName}}</td>
</tr>
<tr>
<td>物料编码:</td>
<td>{{form.materialCode}}</td>
</tr>
<tr>
<td>物料名称:</td>
<td>{{form.materialName}}</td>
</tr>
<tr>
<td>规格型号:</td>
<td>{{form.specification}}</td>
</tr>
<tr>
<td>推荐库位:</td>
<td>
<uni-easyinput :key="keyBol" class="uni-mt-5" v-model="form.recommend" disabled>
<template #right>
<uni-icons custom-prefix="iconfont" type="icon-fuzhi" size="40" @click="iconClick"></uni-icons>
</template>
</uni-easyinput>
</td>
</tr>
<tr>
<td>上架数量:</td>
<td>
<u-number-box inputWidth="120" button-size="36" v-model="form.number" min="0"
:max="form.secondInNumber"></u-number-box>
</td>
</tr>
<tr>
<td>&emsp;&emsp;:</td>
<td>
<uni-easyinput :key="keyBol" type="text" prefixIcon="scan" placeholder="扫描"
v-model="form.storageLocationBarcode" @iconClick="scanClick('storageLocationBarcode')" />
</td>
</tr>
</table>
</div>
<div class="footer">
<button type="primary" @click="submit">
<span>提交</span>
</button>
</div>
<uni-popup ref="message" type="message">
<uni-popup-message :type="message.msgType" :message="message.messageText" :duration="2000"></uni-popup-message>
</uni-popup>
<uni-popup ref="popup" type="center" background-color="#fff" :is-mask-click="false">
<!-- 加载动画 -->
<loding-vue />
</uni-popup>
</view>
</template>
<script>
import {
getReceiveDetailJoin,
addPurchase,
getMaterial_code
} from "@/api/wms/purchase.js";
import {
getConfigKey,
getUser
} from "@/api/system/config.js"
import lodingVue from "@/utils/loding/loding.vue";
export default {
components: {
lodingVue
},
data() {
return {
form: {},
message: {
msgType: 'warn',
messageText: '请先查询设备信息'
},
locationSize: 0,
map: null,
PTfocus: true, //物料编码输入框的是否焦点标记
PTCode: null, //物料编码框的已输入内容
keyBol: true,
user: {},
}
},
async mounted() {
const _this = this;
_this.locationSize = await _this.fnApi('getConfigKey', 'wms.location.size', 'msg')
_this.user = (await _this.fnApi('getUser', { pageNum: 1, pageSize: 1, userName: _this.$store.state.user.name },
'rows'))[0]
},
methods: {
/**
* 所有扫描点击事件
* @param {Object} key
*/
scanClick(key) {
const _this = this;
const obj = {
primary: 'getCode',
storageLocationBarcode: 'iconClick'
}
uni.scanCode({
// 是否只能从相机扫码,不允许从相册选择图片
onlyFromCamera: true,
// 扫码类型
scanType: ['barCode', 'qrCode'],
success: function(res) {
const value = res.result
_this[obj[key]](value)
}
})
},
/**
* 图标点击事件
*/
iconClick(value) {
const _self = this;
// const arr =
_self.form = Object.assign({}, _self.form, {
storageLocationBarcode: value || _self.form.recommend
})
},
/**
* 扫描收货单明细标签
* @param {Object} value id
*/
async getCode(value) {
const _self = this;
_self.PTfocus = false;
const obj = JSON.parse(value);
try {
const data = (await _self.fnApi('getReceiveDetailJoin', obj.id || value))
const res = await _self.fnApi('getMaterial_code', data.materialCode, 'data')
let code = null;
if (res && res.whCode) {
code = getCode(_self.locationSize, res).value
}
data.number = data.allowedNumber || data.number
data.recommend = code
_self.form = data
} catch (e) {
//TODO handle the exception
_self.messageType({
msgType: 'error',
messageText: '未查到信息'
})
}
/**
* 根据参数显示库位格式
* @param {Object} num
* @param {Object} i
*/
function getCode(num, i) {
const code = i.whCode + '-' + i.areaCode + '-' + i.shelvesCode + '-' + i.storageLocationCode;
let value = null;
switch (num) {
case '0':
value = code
break;
case '2':
value = i.areaCode
break;
case '4':
value = i.storageLocationCode
break;
case '5':
value = i.shelvesCode + '-' + i.storageLocationCode
break;
}
return { value }
}
},
/**
* 提交事件
*/
async submit() {
const _self = this
const form = Object.assign({}, _self.form);
if (!form.number) {
_self.messageType({
msgType: 'warn',
messageText: '上架数量不能为0'
})
return
}
if (!this.isEmpty(form.storageLocationBarcode)) {
_self.messageType({
msgType: 'warn',
messageText: '库位未填写'
})
return
}
form.purchaseReceiveDetailId = form.id
form.id = null
form.secondNumber = form.number;
const { purchaseReceiveCode, supplierCode } = _self.form
const obj = {
purchaseReceiveCode,
supplierCode,
userId: _self.user.userId,
wmsPurchaseInDetailList: [form]
}
const data = await _self.fnApi('addPurchase', obj, 'code')
if (data === 200) {
_self.messageType({
msgType: 'success',
messageText: '操作成功'
})
/* Begins 20250503-0001
新增:“提交成功”后输入焦点自动回到顶部输入框,并清空物料输入框、推荐库位、库位内容
修改关闭提交后2秒延时退出页面功能。
For Customer:浙江日井泵业股份有限公司
*/
_self.PTfocus = true
_self.PTCode = null
_self.form = {}
_self.keyBol = !_self.keyBol;
/* Ends 20250503-0001
setTimeout(()=>{
uni.switchTab({
url:'/pages/work/index'
})
},2000)
*/
} else {
/*
TODO: If Error happens, Should notify the user what happened and how to deal with it.
*/
_self.messageType({
msgType: 'error',
messageText: '操作失败'
})
}
},
/**
* 接口访问方法
* @param {String} api 接口名称
* @param {Object} value 带入参数
* @param {String} accept 接受的数据有些的data有些的data看具体数据 默认data
*/
async fnApi(api, value, accept = 'data') {
const _self = this;
const objApi = {
getReceiveDetailJoin,
addPurchase,
getConfigKey,
getMaterial_code,
getUser
}
try {
//打开蒙层
_self.$refs.popup.open()
//查询接口
const data = (await objApi[api](value))[accept]
return data
} catch (e) {
_self.messageType({
msgType: 'error',
messageText: '接口请求出错'
})
} finally {
//关闭蒙层
_self.$refs.popup.close()
}
},
/**
* 提示信息
* @param {Object|undefined} value
* {msgType,messageText} 参数里面需要包含这两个键
*/
messageType(obj) {
const _self = this;
let message = {}
if (obj === undefined) {
message = {
msgType: 'error',
messageText: '请填写设备代码'
}
} else {
message = {
msgType: obj.msgType,
messageText: obj.messageText
}
}
_self.message = Object.assign({}, message)
return _self.$refs.message.open()
},
isEmpty(value) {
if (value === undefined || value === null || value === '') return false
return true
}
}
}
</script>
<style>
page {
background-color: #ffffff;
display: flex;
justify-content: center;
font-size: 5vw;
color: #484744;
}
</style>
<style lang="scss" scoped>
#view {
width: 97vw;
height: calc(100vh - 44px);
display: flex;
justify-content: center;
flex-wrap: wrap;
&>* {
width: 100%;
background-color: #ffffff;
}
.header,
.footer {
height: 8%;
}
.footer {
margin-top: auto;
&>* {
margin-top: 3%;
}
.icon-saomiao {
margin-right: 2%;
}
}
.body {
height: calc(100% - 2 * 8% - 4%);
table>tr {
border-bottom: 1px dashed #969696;
height: 15vw;
&>td:last-child {
display: flex;
justify-content: flex-end
}
}
}
table {
width: 100%;
tr {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
td {
display: flex;
align-items: center;
justify-content: center;
text-overflow: ellipsis;
}
&>td:first-child {
width: 30%;
}
&>td:last-child {
width: 70%;
}
}
}
}
</style>