初始化仓库

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,514 @@
<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="workOrderCode" v-if="value !== '扫物料标签'">
<uni-easyinput clearable suffixIcon="scan" @iconClick="scanBarPwo"
v-model="formData.workOrderCode" @confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
<uni-forms-item label="生产退料任务单" :labelWidth='90' name="backTaskCode">
<uni-easyinput v-model="formData.backTaskCode" disabled />
</uni-forms-item>
<uni-forms-item label="生产退料收货单" :labelWidth='90' name="backReceiveCode" v-if="value !== '扫物料标签'">
<uni-combox :candidates="backReceiveCodeList" emptyTips="无" @input="scanBarReceiveCode"
v-model="formData.backReceiveCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="生产退料入库单" :labelWidth='90' name="backInCode" v-if="value !== '扫物料标签'">
<uni-combox :candidates="backInCodeList" emptyTips="无" @input="scanBarBackInCode"
v-model="formData.backInCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode" v-if="value !== '扫物料标签'">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarwarehouseCode"
v-model="formData.warehouseCode" />
</uni-forms-item>
<uni-forms-item label="上架员" :labelWidth='90' name="shelfPutBy" v-if="value !== '扫物料标签'">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarshelfPutBy"
v-model="formData.shelfPutBy" @confirm="isEmp" />
<uni-data-picker popup-title="请选择上架员" :localdata="dataTree" v-model="pickerData"
@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</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.wmsBackInDetailList.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 v-for="(item, index) in formData.wmsBackInDetailList" :key="index">
<view>
<uni-badge :text="index+1" class="uni-badge-left-margin" type="primary"></uni-badge>
</view>
<uni-forms-item label="物料编码" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialCode" />
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialName" />
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'>
<uni-easyinput type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="箱号" v-if="item.materialLotNo" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="类型" :labelWidth='90' name="'wmsBackInDetailList.'+ index +'.type'">
<uni-tag v-if="item.type == 1" text="合格" type="success"></uni-tag>
<uni-tag v-else-if="item.type == 2" text="不良" type="warning"></uni-tag>
<uni-tag v-else-if="item.type == 3" text="报废" type="error"></uni-tag>
<uni-tag v-else-if="item.type == null" text="无" type="primary"></uni-tag>
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
name="'wmsBackInDetailList.'+ 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'>
<uni-easyinput disabled type="text" v-model="item.number" v-if="value == '扫物料标签'" />
<u-number-box inputWidth="120" button-size="36" v-model="item.number" v-else
min="0"></u-number-box>
</uni-forms-item>
<!-- <uni-forms-item label="备注" :labelWidth='90' name="remark">
<uni-easyinput autoHeight type="textarea" v-model="item.remark"></uni-easyinput>
</uni-forms-item> -->
<!-- <uni-forms-item label="单位" :labelWidth='90' :disabled="true">
<uni-easyinput type="text" disabled v-model="item.unitText" />
</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 {
listIn,
getIn,
delIn,
addIn,
updateIn,
exportIn,
getListDetail,
updateStock,
getInBySrc,
getInByCode,
getTaskDetailByDetailCode,
directBackInByTaskDetail
} from "@/api/wms/pdcBack/in";
import {
listReceive,
getReceive,
delReceive,
addReceive,
updateReceive,
exportReceive,
getRcvByTask,
listReceiveDetail,
updateReceiveDetail,
listDetail
} from "@/api/wms/pdcBack/receive";
import {
listMaterial
} from "@/api/wms/request.js";
import {
getListDetailByBL,
} from "@/api/wms/purchase.js";
import {
listEmployee
} from "@/api/mes/jobIn.js";
import {
listDepartment
} from "@/api/basic/department";
import {
listUnit
} from "@/api/basic/unit";
import {
getConnectLoc
} from "@/api/wms/pdcIn.js";
import _ from 'lodash';
export default {
created() {
this.selectTypeList()
},
mounted() {
listDepartment().then((res) => {
this.dptList = res.rows
})
listEmployee().then((res) => {
this.empList = res.rows
})
listUnit().then((res) => {
this.unitList = res.rows.map(item => {
let obj = {
text: item.unitCode + ":" + item.unitName,
value: item.id
}
return obj
})
})
console.log(this.$store)
},
data() {
return {
buttonDisabled: false,
wmsLotNoList: [],
dptList: [],
empList: [],
unitList: [],
item: '',
dataTree: [],
pickerData: '',
value: '正常',
show: false,
materialLabel: null,
//是否都入库
isAllListed: false,
isRk: false,
//是否打开编辑按钮
isSplit: true,
backReceiveCodeList: [],
// backQualityCodeList: [],
checkStorageLocationBarcode: true,
backInCodeList: [],
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
formData: {
workOrderCode: '',
backReceiveCode: '',
// backQualityCode: null,
wmsBackInDetailList: [],
billType: "1",
status: "1",
id: null,
backInCode: '',
shelfPutBy: null,
backTaskCode: ''
},
backTaskDetailCode: '',
rules: {
}
}
},
methods: {
deleteDetail(index) {
this.formData.wmsBackInDetailList.splice(index, 1);
},
clickDetail(itemIndex, {
position,
index
}) {
if (index == 0) {
this.deleteDetail(itemIndex);
}
},
onnodeclick(e) {
console.log(e)
this.item = e
this.onchange(this.item)
},
onpopupopened(e) {
this.dataTree = []
this.empList.filter(item => item.deptId).forEach(item => {
item.departmentTitle = this.dptList.find(item2 => item2.id == item.deptId).departmentTitle
// 检查dataTree中是否已存在相同部门
let existingDept = this.dataTree.find(dept => dept.value === item.deptId);
if (existingDept) {
// 如果已存在相同部门则将员工信息push进该部门的children数组
existingDept.children.push({
text: item.name,
value: item.empCode
});
} else {
// 如果不存在相同部门则创建一个新部门对象包括children数组并将员工信息push进去
let newDept = {
text: item.departmentTitle,
value: item.deptId,
children: [{
text: item.name,
value: item.empCode
}]
};
this.dataTree.push(newDept);
}
})
console.log(this.dataTree)
},
onpopupclosed() {
//处理不同步
// this.$nextTick(() => {
// this.pickerData = this.item.value;
// this.formData.pickerData = this.item.value;
// if (!this.item) return
// this.onchange(this.item)
// });
},
onchange(e) {
console.log(e)
this.formData.shelfPutBy = null
this.$set(this.formData, 'shelfPutBy', e.value.split('/')[0])
},
addMaterialLabel() {
this.show = true;
},
cancelMaterialLabel() {
this.materialLabel = null;
this.show = false;
},
confirmMaterialLabel(data) {
data = JSON.parse(data)
if (data) {
// this.id = data.id
getTaskDetailByDetailCode(data.backTaskDetailCode).then(res => {
console.log(res)
if (res.backTaskDetail) {
this.formData.backTaskCode = res.backTaskDetail.backTaskCode;
let obj = {
materialCode: res.backTaskDetail.materialCode,
materialName: res.backTaskDetail.materialName,
materialBatchNo: res.backTaskDetail.materialBatchNo,
materialLotNo: res.backTaskDetail.materialLotNo,
type: res.backTaskDetail.type,
storageLocationBarcode: res.backTaskDetail.storageLocationBarcode,
number: res.backTaskDetail.number
}
this.backTaskDetailCode = res.backTaskDetail.backTaskDetailCode
this.formData.wmsBackInDetailList.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);
}
});
},
async splitStlBarcode(i,event) {
const _this = this;
const detail = _this.formData.wmsBackInDetailList[i];
detail.whCode = null;
detail.areaCode = null;
detail.shelvesCode = null;
detail.storageLocationCode = null;
console.log(_this.$store)
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;
},
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.formData.wmsBackInDetailList[i], "storageLocationBarcode", res
.result);
_this.splitStlBarcode(i);
}
});
},
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
this.backReceiveCodeList = [];
// this.productQualityCodeList = [];
this.backInCodeList = [];
if (this.formData.workOrderCode) {
listReceive({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
this.backReceiveCodeList = response.rows.map(item => {
return item.backReceiveCode
})
});
listIn({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
this.backInCodeList = response.rows.map(item => {
return item.backInCode
})
});
}
},
selectTypeList() {
listReceive().then(async response => {
this.backReceiveCodeList = response.rows.map(item => {
return item.backReceiveCode
})
});
listIn().then(async response => {
this.backInCodeList = response.rows.map(item => {
return item.backInCode
})
});
},
change(e) {
console.log(e);
},
scanBarReceiveCode() {
if (this.formData.backReceiveCode) {
// this.formData.productQualityCode = '';
this.formData.backInCode = '';
console.log(this.formData, "this.formData");
this.selectTask();
} else {
this.$modal.msg("生产退料收货单!");
}
},
selectTask() {
getInBySrc(this.formData).then((res) => {
console.log(this.formData, "this.formData");
// this.form = res.wmsBackIn;
this.formData.wmsBackInDetailList = res.wmsBackIn.wmsBackInDetailList;
});
// getDetails(this.formData).then(res => {
// this.formData.wmsBackInDetailList = res.details;
// })
},
scanBarBackInCode(i) {
console.log(i)
this.formData.backReceiveCode = '';
getInByCode({
backInCode: i
}).then((response) => {
this.formData = response.wmsBackIn;
this.checkIsListed();
});
},
//上架员
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.shelfPutBy = res.result;
}
});
},
scanBarwarehouseCode() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
/** 提交按钮 */
submit() {
const _this = this;
_this.formData.status = 2;
//判断明细是否都入库
if (
_this.formData.wmsBackInDetailList.filter((obj) => obj.status != 1).length == 0
) {
_this.formData.status = 3;
}
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成入库吗?',
success: function(res) {
_this.$modal.loading('提交中')
console.log(_this, " _this");
// _this.formData.wmsBackInDetailList.map(item => {
// item.secondNumber = item.number;
// item.secondUnitId = item.unitId;
// return item
// })
let obj = {
backTaskDetailCode: _this.backTaskDetailCode,
whCode: _this.formData.wmsBackInDetailList[0].whCode,
areaCode: _this.formData.wmsBackInDetailList[0]
.areaCode,
shelvesCode: _this.formData.wmsBackInDetailList[0]
.shelvesCode,
storageLocationCode: _this.formData.wmsBackInDetailList[
0].storageLocationCode,
backTaskDetailCode:_this.formData .wmsBackInDetailList[0].backTaskDetailCode
}
if (!_this.checkStorageLocationBarcode) {
_this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
directBackInByTaskDetail(obj).then(response => {
_this.$modal.msgSuccess("入库成功!");
_this.$modal.closeLoading();
setTimeout(() => {
_this.$tab.switchTab("/pages/work/index");
}, 500);
})
// }
}
});
});
},
//检查是否都入库
checkIsListed() {
let flag = true;
this.formData.wmsBackInDetailList.forEach((item) => {
if (item.status == 0 || item.status == null) flag = false;
});
this.isAllListed = flag;
},
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,422 @@
<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.materialLotNo}}</view>
<view><strong>上架数量</strong> : {{singleInfo.number}}</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-swipe-action> -->
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<view :key="index" v-for="(item, index) in wmsLotNoList">
<!-- <uni-swipe-action-item :key="index" v-for="(item, index) in wmsLotNoList"
@click="(data) => clickDetail(index,data)" @change="swipChange"> -->
<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="库位条码" :labelWidth='90' name="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'>
<u-number-box inputWidth="120" button-size="36" v-model="item.number"
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-swipe-action-item> -->
</uni-forms>
<!-- </uni-swipe-action> -->
</uni-collapse-item>
</uni-collapse>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
addInDetail,
addLotInfo,
} from "@/api/wms/purchase.js";
import {
updateInDetail,
getConnectLoc
} from "@/api/wms/pdcIn.js";
export default {
onLoad: function(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;
console.log(option);
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.eachNumber = option.eachNumber;
this.splitNumber = option.splitNumber;
this.index = option.index
},
data() {
return {
//入库时间
rkTime: null,
//是否已分批
isSecondOpen: false,
selectedRow: {},
singleInfo: {},
wmsLotNoList: [],
eachNumber: null,
splitNumber: null,
index: null,
checkStorageLocationBarcode: true,
// storageLocationBarcode: ''
formData: {},
rules: {
storageLocationBarcode: {
rules: [{
required: true,
errorMessage: '请输入库位条码!'
}]
}
},
}
},
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 = [];
console.log(this.singleInfo)
let materialCode = this.singleInfo.materialCode;
let batchNo = this.singleInfo.materialBatchNo;
let unit = this.singleInfo.unit;
let purchaseInCode = this.singleInfo.purchaseInCode;
let type = this.singleInfo.type;
let unitId = this.singleInfo.unitId;
let secondNumber = this.singleInfo.secondNumber;
let secondUnitId = this.singleInfo.secondUnitId;
let productionVersion = this.singleInfo.productionVersion;
let materialName = this.singleInfo.materialName;
let specification = this.singleInfo.specification;
let unitName = this.singleInfo.unit;
let storageInBillCode = this.singleInfo.storageInBillCode;
let storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
let erpDocLineKey1 = this.singleInfo.erpDocLineKey1;
if (this.eachNumber != 0 && this.eachNumber != null) {
console.log(this.eachNumber)
this.splitNumber = 0;
let t;
let k;
t = parseInt(this.singleInfo.number / this.eachNumber);
k = this.singleInfo.number % this.eachNumber;
if (k != 0) {
t++;
}
for (let i = 0; i < t; i++) {
let obj = {};
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = this.eachNumber;
obj.secondNumber = this.eachNumber;
obj.unit = unit;
obj.secondUnitId = secondUnitId;
obj.type = type;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.storageInBillCode = storageInBillCode;
obj.materialName = materialName;
obj.specification = specification;
obj.productionVersion = productionVersion;
obj.storageInTime = this.rkTime;
if (i == t - 1) {
if (k != 0) {
obj.number = k;
}
}
// obj.lotNo = i + 1;
this.wmsLotNoList.push(obj);
}
}
if (this.splitNumber != 0 && this.splitNumber != null) {
console.log(2)
this.eachNumber = 0;
let k;
let j;
k = parseInt(this.singleInfo.number / this.splitNumber);
j = this.singleInfo.number - (this.splitNumber - 1) * k;
for (let i = 0; i < this.splitNumber; i++) {
let obj = {};
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = k;
obj.secondNumber = k;
obj.secondUnitId = secondUnitId;
obj.unit = unit;
obj.type = type;
obj.storageInBillDetailCode = storageInBillDetailCode;
obj.storageInBillCode = storageInBillCode;
obj.materialName = materialName;
obj.specification = specification;
obj.productionVersion = productionVersion;
obj.storageInTime = this.rkTime;
// obj.lotNo = i + 1;
if (i == this.splitNumber - 1) {
obj.number = j;
obj.secondNumber = j;
}
this.wmsLotNoList.push(obj);
}
}
},
//不拆分批次
singleSplit() {
this.wmsLotNoList = [];
this.splitNumber = 1;
this.eachNumber = 0;
let obj = {};
obj.materialCode = this.singleInfo.materialCode;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.number = this.singleInfo.number;
obj.unit = this.singleInfo.unit;
obj.secondNumber = this.singleInfo.secondNumber;
obj.secondUnitId = this.singleInfo.secondUnitId;
obj.type = this.singleInfo.type;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.storageInBillCode = this.singleInfo.storageInBillCode;
obj.materialName = this.singleInfo.materialName;
obj.specification = this.singleInfo.specification;
obj.productionVersion = this.singleInfo.productionVersion;
obj.storageInTime = this.rkTime;
// obj.lotNo = 1;
this.wmsLotNoList.push(obj);
},
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.wmsLotNoList[i].storageLocationBarcode = res.result;
_this.splitStlBarcode(i);
}
});
},
//提交分批入库详情
submit() {
//数量防错
let allNum = 0;
for (var i in this.wmsLotNoList) {
allNum += this.wmsLotNoList[i].number;
}
console.log(allNum)
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.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 {
console.log(this.wmsLotNoList);
var flag =
this.wmsLotNoList.filter((obj) => obj.whCode == null).length == 0 ?
1 :
0;
console.log(flag);
if (flag == 0) {
console.log("入库库位必填!", flag);
this.$modal.msgError("入库库位必填!");
} else {
let obj = {};
obj = this.singleInfo;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.eachNumber = this.eachNumber;
// obj.eachSecondNumber = this.eachSecondNumber;
obj.splitNumber = this.splitNumber;
if (this.wmsLotNoList && this.wmsLotNoList.length > 0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
console.log(obj, this.wmsLotNoList);
if (!this.checkStorageLocationBarcode) {
this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
this.$modal.loading('提交中')
addLotInfo(obj).then(res => {
console.log(this.wmsLotNoList)
addInDetail(this.wmsLotNoList, 1).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("上架成功!");
uni.$emit('backWithParam', {
status: this.selectedRow.status,
index: this.index
});
this.$tab.navigateBack();
});
});
}
}
}
// let obj = {};
// obj = this.singleInfo;
// obj.batchNo = this.singleInfo.materialBatchNo;
// obj.lotNo = this.singleInfo.materialLotNo;
// obj.eachNumber = this.eachNumber;
// // obj.eachSecondNumber = this.eachSecondNumber;
// obj.splitNumber = this.splitNumber;
// addLotInfo(obj); //拆箱详情
// addInDetail(this.wmsLotNoList, 1) //对库存操作
// 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 {
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,695 @@
<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="workOrderCode">
<uni-easyinput clearable suffixIcon="scan" @iconClick="scanBarPwo"
v-model="formData.workOrderCode" @confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
<uni-forms-item label="生产退料收货单" :labelWidth='90' name="backReceiveCode">
<uni-combox :candidates="backReceiveCodeList" emptyTips="无" @input="scanBarReceiveCode"
v-model="formData.backReceiveCode"></uni-combox>
</uni-forms-item>
<!-- <uni-forms-item label="生产退料入库质检单" :labelWidth='90' name="backQualityCode">
<uni-combox :candidates="backQualityCodeList" emptyTips="无" @input="scanBarQualityCode"
v-model="formData.backQualityCode" />
</uni-forms-item> -->
<!-- <uni-forms-item label="生产退料收货单" :labelWidth='90' name="backReceiveCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarReceiveCode"
v-model="formData.backReceiveCode" type="text" />
</uni-forms-item> -->
<uni-forms-item label="生产退料入库单" :labelWidth='90' name="backInCode">
<uni-combox :candidates="backInCodeList" emptyTips="无" @input="scanBarBackInCode"
v-model="formData.backInCode"></uni-combox>
<!-- <uni-easyinput suffixIcon="scan" @iconClick="scanBarPInCode" @confirm="scanBarbackInCodeCode"
v-model="formData.backInCode" type="text" /> -->
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarwarehouseCode"
v-model="formData.warehouseCode" />
</uni-forms-item>
<uni-forms-item label="上架员" :labelWidth='90' name="shelfPutBy">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarshelfPutBy"
v-model="formData.shelfPutBy" @confirm="isEmp" />
<uni-data-picker popup-title="请选择上架员" :localdata="dataTree" v-model="pickerData"
@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</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.wmsBackInDetailList.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 v-for="(item, index) in formData.wmsBackInDetailList" :key="index">
<view>
<uni-badge :text="index+1" class="uni-badge-left-margin" type="primary"></uni-badge>
<button @click="open(index,item)" size="mini"
:disabled="buttonDisabled || !formData.id || !item.materialBatchNo"
type="primary">编辑</button>
</view>
<uni-forms-item label="物料编码" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialCode" />
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialName" />
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'>
<uni-easyinput type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="箱号" v-if="item.materialLotNo" :labelWidth='90'>
<uni-easyinput type="text" disabled v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="类型" :labelWidth='90' name="'wmsBackInDetailList.'+ index +'.type'">
<uni-tag v-if="item.type == 1" text="合格" type="success"></uni-tag>
<uni-tag v-else-if="item.type == 2" text="不良" type="warning"></uni-tag>
<uni-tag v-else-if="item.type == 3" text="报废" type="error"></uni-tag>
<uni-tag v-else-if="item.type == null" text="无" type="primary"></uni-tag>
</uni-forms-item>
<uni-forms-item label="上架数量" :labelWidth='90'>
<u-number-box inputWidth="120" button-size="36" v-model="item.number"
min="0"></u-number-box>
</uni-forms-item>
<uni-forms-item label="备注" :labelWidth='90' name="remark">
<uni-easyinput autoHeight type="textarea" v-model="item.remark"></uni-easyinput>
</uni-forms-item>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<uni-row :gutter="10">
<uni-col :span="12">
<u-button type="success" @click="savesubmit">保存</u-button>
</uni-col>
<uni-col :span="12">
<u-button type="primary" :disabled="!isAllListed" @click="submit">提交</u-button>
</uni-col>
</uni-row>
</view>
</template>
<script>
import {
listIn,
getIn,
delIn,
addIn,
updateIn,
exportIn,
getListDetail,
updateStock,
getInBySrc,
getInByCode
} from "@/api/wms/pdcBack/in";
import {
listReceive,
getReceive,
delReceive,
addReceive,
updateReceive,
exportReceive,
getRcvByTask,
listReceiveDetail,
updateReceiveDetail,
listDetail
} from "@/api/wms/pdcBack/receive";
import {
listMaterial
} from "@/api/wms/request.js";
import {
getListDetailByBL,
} from "@/api/wms/purchase.js";
import {
listEmployee
} from "@/api/mes/jobIn.js";
import {
listDepartment
} from "@/api/basic/department";
import _ from 'lodash';
export default {
created() {
this.selectTypeList()
//监听编辑批号分批后的状态
uni.$on('backWithParam', (param) => {
if (param.status && param.index) {
this.formData.wmsBackInDetailList[Number(param.index)].status = param.status
}
this.checkIsListed();
});
},
mounted() {
listDepartment().then((res) => {
this.dptList = res.rows
})
listEmployee().then((res) => {
this.empList = res.rows
})
},
data() {
return {
buttonDisabled: false,
wmsLotNoList: [],
dptList: [],
empList: [],
item: '',
dataTree: [],
pickerData: '',
value: '正常',
show: false,
materialLabel: null,
//是否都入库
isAllListed: false,
isRk: false,
//是否打开编辑按钮
isSplit: true,
backReceiveCodeList: [],
// backQualityCodeList: [],
backInCodeList: [],
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
formData: {
workOrderCode: '',
backReceiveCode: '',
// backQualityCode: null,
wmsBackInDetailList: [],
billType: "1",
status: "1",
id: null,
backInCode: '',
shelfPutBy: null
},
rules: {
}
}
},
methods: {
deleteDetail(index) {
this.formData.wmsBackInDetailList.splice(index, 1);
},
clickDetail(itemIndex, {
position,
index
}) {
if (index == 0) {
this.deleteDetail(itemIndex);
}
},
onnodeclick(e) {
console.log(e)
this.item = e
this.onchange(this.item)
},
onpopupopened(e) {
this.dataTree = []
this.empList.filter(item => item.deptId).forEach(item => {
item.departmentTitle = this.dptList.find(item2 => item2.id == item.deptId).departmentTitle
// 检查dataTree中是否已存在相同部门
let existingDept = this.dataTree.find(dept => dept.value === item.deptId);
if (existingDept) {
// 如果已存在相同部门则将员工信息push进该部门的children数组
existingDept.children.push({
text: item.name,
value: item.empCode
});
} else {
// 如果不存在相同部门则创建一个新部门对象包括children数组并将员工信息push进去
let newDept = {
text: item.departmentTitle,
value: item.deptId,
children: [{
text: item.name,
value: item.empCode
}]
};
this.dataTree.push(newDept);
}
})
console.log(this.dataTree)
},
onpopupclosed() {
//处理不同步
// this.$nextTick(() => {
// this.pickerData = this.item.value;
// this.formData.pickerData = this.item.value;
// if (!this.item) return
// this.onchange(this.item)
// });
},
onchange(e) {
console.log(e)
this.formData.shelfPutBy = null
this.$set(this.formData, 'shelfPutBy', e.value.split('/')[0])
},
addMaterialLabel() {
this.show = true;
},
cancelMaterialLabel() {
this.materialLabel = null;
this.show = false;
},
confirmMaterialLabel(data) {
data = JSON.parse(data)
if (data) {
//判断是否已收货
listReceiveDetail({
backTaskDetailCode: data.backTaskDetailCode
}).then(res => {
console.log(res)
//若已有收货单
if (res.data.length > 0) {
this.formData.backReceiveCode = res.data[0].backReceiveCode;
this.formData.deptCode = res.data[0].deptCode
this.formData.warehouseCode = res.data[0].warehouseCode
// this.formData.workOrderCode = data.pwoCode;
this.formData.backQualityCode = '';
this.formData.backInCode = '';
this.selectTask();
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);
}
});
},
//进入编辑页
open: _.debounce(async function(index, row) {
// 禁用按钮
this.buttonDisabled = true;
console.log(row)
//拆分下的列表
this.wmsLotNoList = [];
//选中的物料明细项
let selectedRow = row;
//是否分批
let isSecondOpen = false;
//每份数量
let eachNumber = null;
//拆分数量
let splitNumber = null;
//头部信息
let singleInfo = {};
singleInfo.materialCode = row.materialCode;
singleInfo.materialBatchNo = row.materialBatchNo;
// singleInfo.materialLotNo = row.materialLotNo;
singleInfo.number = row.number;
singleInfo.unit = row.unit;
singleInfo.secondNumber = row.number;
singleInfo.secondUnitId = row.unitId;
singleInfo.backInCode = row.backInCode;
singleInfo.materialName = row.materialName;
singleInfo.type = row.type;
singleInfo.unitName = row.unit;
singleInfo.specification = row.specification;
singleInfo.whCode = row.whCode;
singleInfo.areaCode = row.areaCode;
singleInfo.shelvesCode = row.shelvesCode;
singleInfo.storageLocationCode = row.storageLocationCode;
singleInfo.storageInBillCode = row.backInCode;
singleInfo.storageInBillDetailCode = row.backInDetailCode;
singleInfo.erpDocLineKey1 = row.erpDocLineKey1;
singleInfo.unitId = row.unitId;
this.formData.productInCode = row.productInCode;
await getListDetailByBL(singleInfo).then((response) => {
if (
response.materialDetailList &&
response.materialDetailList.length > 0
) {
console.log(1)
/** 导入拆分信息 */
if (response.materialDetailList[0].splitNumber != null) {
splitNumber = response.materialDetailList[0].splitNumber;
} else if (response.materialDetailList[0].eachNumber != null) {
eachNumber = response.materialDetailList[0].eachNumber;
} else if (response.materialDetailList[0].eachSecondNumber != null) {
eachSecondNumber =
response.materialDetailList[0].eachSecondNumber;
}
if (
response.materialStockList &&
response.materialStockList.length > 0
) {
/** 导入拆分详情 */
this.wmsLotNoList = response.materialStockList.map((item) => {
item.batchNo = item.materialBatchNo;
item.locCascade = [
item.whCode,
item.areaCode,
item.shelvesCode,
item.storageLocationCode,
];
if (item.whCode != null) {
item.connectedLocation = item.whCode;
if (item.areaCode != null) {
item.connectedLocation = item.connectedLocation + '-' +
item
.areaCode;
if (item.shelvesCode != null) {
item.connectedLocation = item.connectedLocation +
'-' +
item
.shelvesCode;
if (item.storageLocationCode != null) {
item.connectedLocation = item
.connectedLocation +
'-' +
item.storageLocationCode;
}
}
}
}
return item;
});
if (response.materialStockList.length != 0) {
isSecondOpen = true;
}
}
}
});
console.log(this.wmsLotNoList);
uni.navigateTo({
url: '/pages/wms/pdcBack/pdcBackListing?singleInfo=' + encodeURIComponent(JSON
.stringify(
singleInfo)) +
'&wmsLotNoList=' + encodeURIComponent(JSON.stringify(
this.wmsLotNoList)) +
'&selectedRow=' + encodeURIComponent(JSON.stringify(
selectedRow)) +
'&eachNumber=' + eachNumber +
'&splitNumber=' + splitNumber +
'&isSecondOpen=' + isSecondOpen +
'&index=' + index
});
// 在页面跳转后恢复按钮状态
setTimeout(() => {
this.buttonDisabled = false;
}, 500); // 延时,确保跳转完成后再启用按钮
}, 1000, {
leading: true,
trailing: false
}),
splitStlBarcode(i) {
this.formData.wmsProductInDetailList[i].whCode = null;
this.formData.wmsProductInDetailList[i].areaCode = null;
this.formData.wmsProductInDetailList[i].shelvesCode = null;
this.formData.wmsProductInDetailList[i].storageLocationCode = null;
let array = this.formData.wmsProductInDetailList[i].storageLocationBarcode.split('-');
let [whCode, areaCode, shelvesCode, storageLocationCode, extra] = array;
this.formData.wmsProductInDetailList[i].whCode = whCode || null;
this.formData.wmsProductInDetailList[i].areaCode = areaCode || null;
this.formData.wmsProductInDetailList[i].shelvesCode = shelvesCode || null;
this.formData.wmsProductInDetailList[i].storageLocationCode = extra ? `${storageLocationCode}-${extra}` :
storageLocationCode || null;
// const _this = this;
// const detail = _this.formData.wmsBackInDetailList[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 checkAndSetField = (obj, field, value, msg) => {
// if (!value) {
// _this.$modal.msg(msg);
// _this.$set(obj, field, null);
// _this.$nextTick(() => {
// _this.$set(obj, "storageLocationBarcode", null);
// });
// return false;
// }
// return true;
// };
// let warehouseObj = _this.$store.getters.warehouseOptions.find(item => item.warehouseCode == whCode);
// if (!checkAndSetField(detail, 'whCode', warehouseObj, "仓库不存在!")) return;
// let areaObj = _this.$store.getters.areaOptions.find(item => item.areaCode == areaCode);
// if (!checkAndSetField(detail, 'areaCode', areaObj, "库区不存在!")) return;
// let shelvesObj = _this.$store.getters.shelvesOptions.find(item => item.storageShelvesCode == shelvesCode);
// if (!checkAndSetField(detail, 'shelvesCode', shelvesObj, "货架不存在!")) return;
// let locationObj = _this.$store.getters.locationOptions.find(item => item.storageLocationCode ==
// `${storageLocationCode}-${extra}`);
// if (!checkAndSetField(detail, 'storageLocationCode', locationObj, "库位不存在!")) return;
// // 更新formData中的对应字段
// detail.whCode = whCode || null;
// detail.areaCode = areaCode || null;
// detail.shelvesCode = shelvesCode || null;
// detail.storageLocationCode = extra ? `${storageLocationCode}-${extra}` : storageLocationCode || null;
},
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.formData.wmsProductInDetailList[i], "storageLocationBarcode", res
.result);
_this.splitStlBarcode(i);
}
});
},
// clearPwo() {
// if (this.formData.workOrderCode == '' || !this.formData.workOrderCode) {
// this.selectTypeList();
// }
// },
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
this.backReceiveCodeList = [];
// this.productQualityCodeList = [];
this.backInCodeList = [];
if (this.formData.workOrderCode) {
listReceive({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
this.backReceiveCodeList = response.rows.map(item => {
return item.backReceiveCode
})
});
listIn({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
this.backInCodeList = response.rows.map(item => {
return item.backInCode
})
});
}
},
selectTypeList() {
listReceive().then(async response => {
this.backReceiveCodeList = response.rows.map(item => {
return item.backReceiveCode
})
});
listIn().then(async response => {
this.backInCodeList = response.rows.map(item => {
return item.backInCode
})
});
},
change(e) {
console.log(e);
},
scanBarReceiveCode() {
if (this.formData.backReceiveCode) {
// this.formData.productQualityCode = '';
this.formData.backInCode = '';
this.selectTask();
} else {
this.$modal.msg("生产退料收货单!");
}
},
// scanBarQualityCode() {
// if (this.formData.productQualityCode) {
// this.formData.productReceiveCode = '';
// this.formData.productInCode = '';
// this.selectTask();
// } else {
// this.$modal.msg("产品入库质检单!");
// }
// },
selectTask() {
getInBySrc(this.formData).then((res) => {
console.log(res);
// this.form = res.wmsBackIn;
this.formData.wmsBackInDetailList = res.wmsBackIn.wmsBackInDetailList;
});
// getDetails(this.formData).then(res => {
// this.formData.wmsBackInDetailList = res.details;
// })
},
scanBarBackInCode(i) {
console.log(i)
this.formData.backReceiveCode = '';
getInByCode({
backInCode: i
}).then((response) => {
this.formData = response.wmsBackIn;
this.checkIsListed();
});
},
//上架员
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.shelfPutBy = res.result;
}
});
},
scanBarwarehouseCode() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
savesubmit() {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定保存吗?',
success: function(res) {
if (res.confirm) {
if (_this.formData.backReceiveCode) {
_this.formData.wmsBackInDetailList.map(item => {
item.secondNumber = item.number;
item.secondUnitId = item.unitId;
return item
})
if (_this.formData.id != null) {
_this.$modal.loading('提交中')
updateIn(_this.formData).then((response) => {
_this.$modal.closeLoading();
_this.formData = response.data;
_this.checkIsListed();
_this.$modal.msgSuccess("修改成功!");
});
} else {
_this.$modal.loading('提交中')
addIn(_this.formData).then((response) => {
_this.$modal.closeLoading();
_this.formData = response.data;
_this.checkIsListed();
_this.$modal.msgSuccess("保存成功!");
});
}
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
/** 提交按钮 */
submit() {
const _this = this;
_this.formData.status = 2;
//判断明细是否都入库
if (
_this.formData.wmsBackInDetailList.filter((obj) => obj.status != 1).length == 0
) {
_this.formData.status = 3;
}
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成入库吗?',
success: function(res) {
_this.$modal.loading('提交中')
_this.formData.wmsBackInDetailList.map(item => {
item.secondNumber = item.number;
item.secondUnitId = item.unitId;
return item
})
updateIn(_this.formData).then(response => {
_this.$modal.msgSuccess("入库成功!");
_this.$modal.closeLoading();
setTimeout(() => {
_this.$tab.switchTab("/pages/work/index");
}, 500);
});
// }
}
});
});
},
//检查是否都入库
checkIsListed() {
let flag = true;
this.formData.wmsBackInDetailList.forEach((item) => {
if (item.status == 0 || item.status == null) flag = false;
});
this.isAllListed = flag;
},
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,439 @@
<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="workOrderCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPwo" @change="clearPwo"
v-model="workOrderCode" @confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
<uni-forms-item label="生产退料任务单" :labelWidth='90' name="backTaskCode">
<uni-combox :candidates="backTaskCodeList" emptyTips="无" @input="scanBarCode"
v-model="formData.backTaskCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="生产退料任务明细单" :labelWidth='90' name="backTaskDetailCode">
<uni-easyinput v-model="formData.backTaskDetailCode" type="text" />
</uni-forms-item>
<uni-forms-item label="生产退料收货单" :labelWidth='90' name="backReceiveCode">
<uni-easyinput v-model="formData.backReceiveCode" type="text" />
</uni-forms-item>
<uni-forms-item label="签收员" :labelWidth='90' name="drawBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.drawBy" type="text" />
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarwarehouseCode"
v-model="formData.warehouseCode" />
</uni-forms-item>
<uni-forms-item label="到货时间" :labelWidth='90' name="arriveTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.arriveTime" />
</view>
</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.wmsBackReceiveDetailList.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 v-for="(item, index) in formData.wmsBackReceiveDetailList" :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'>
<uni-easyinput disabled type="text" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="退料原因" :labelWidth='90'>
<uni-easyinput disabled type="text" v-model="item.reason" />
</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' v-if="item.receivedNumber"
:name="'wmsBackReceiveDetailList.'+ index +'.receivedNumber'">
<uni-easyinput disabled type="number" v-model="item.receivedNumber" />
</uni-forms-item>
<uni-forms-item label="到货数量" :labelWidth='90'>
<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'>
<u-number-box inputWidth="120" button-size="36" v-model="item.actualNumber"
:max="item.theoryNumber" min="0"></u-number-box>
</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 {
listReceive,
getReceive,
delReceive,
addReceive,
updateReceive,
exportReceive,
getRcvByTask,
listReceiveDetail,
updateReceiveDetail,
listDetail
} from "@/api/wms/pdcBack/receive";
import {
listTask,
getTask,
delTask,
addTask,
updateTask,
exportTask,
mergePrintDetailPdfs,
} from "@/api/wms/pdcBack/task";
export default {
onLoad: function() {
// 获取当前时间
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.formData.arriveTime = formattedDate;
},
mounted() {},
data() {
return {
isSupplierCode: false,
isReceive: false,
backTaskCodeList: [],
value: '正常',
show: false,
materialLabel: null,
workOrderCode: null,
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
formData: {
backTaskCode: '',
backReceiveCode: null,
backTaskDetailCode: null,
wmsBackReceiveDetailList: [],
arriveTime: null,
warehouseCode: null,
//任务单状态=1=‘新建’
status: '1'
},
rules: {
// backTaskCode: {
// rules: [{
// required: true,
// errorMessage: '请输入生产退料任务单!'
// }]
// },
}
}
},
methods: {
deleteDetail(index) {
this.formData.wmsBackReceiveDetailList.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) {
data = JSON.parse(data)
if (data) {
//判断是否已收货
console.log(data)
listReceiveDetail({
backTaskDetailCode: data.backTaskDetailCode
}).then(res => {
console.log(res)
//若已有收货单
if (res.data.length > 0) {
let num = 0;
//统计所有实收数量
for (var i in res.data) {
num += res.data[i].actualNumber
}
//若所有收货单的实际收货数量与应收数量一致
if (num == res.data[0].theoryNumber) {
this.$modal.msg("该条物料明细已完成收货!")
} else {
// this.workOrderCode = data.pwoCode
this.formData.backTaskCode = res.data[0].backTaskCode
this.formData.backTaskDetailCode = data.backTaskDetailCode
this.formData.backReceiveCode = res.data[0].backReceiveCode
this.formData.deptCode = res.data[0].deptCode
this.formData.warehouseCode = res.data[0].warehouseCode
// this.formData.id
let obj = {
materialCode: res.data[0].materialCode,
materialName: res.data[0].materialName,
materialBatchNo: res.data[0].materialBatchNo,
theoryNumber: res.data[0].theoryNumber,
unitId: res.data[0].unitId,
receivedNumber: num,
backTaskDetailCode: data.backTaskDetailCode,
type: res.data[0].type,
id: res.data[0].id
}
this.formData.wmsBackReceiveDetailList.push(obj);
this.isReceive = true;
this.materialLabel = null;
this.show = false;
}
} else {
// this.workOrderCode = data.pwoCode
listDetail({
backTaskDetailCode: data.backTaskDetailCode
}).then((res) => {
console.log(res)
if (res.rows.length > 0) {
this.formData.backTaskDetailCode = data.backTaskDetailCode
this.formData.wmsBackReceiveDetailList = []
let obj = res.rows[0]
obj.theoryNumber = obj.number;
obj.unitId = obj.unitId;
obj.id = null
this.formData.backTaskCode = obj.backTaskCode
this.formData.deptCode = obj.deptCode
this.formData.warehouseCode = obj.warehouseCode
this.formData.wmsBackReceiveDetailList.push(obj);
this.isReceive = false;
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);
}
});
},
clearPwo() {
if (this.workOrderCode == '' || !this.workOrderCode) {
this.selectTypeList();
}
},
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
this.backTaskCodeList = [];
if (this.workOrderCode) {
listTask({
workOrderCode: this.workOrderCode
}).then(async response => {
this.backTaskCodeList = response.rows.map(item => {
return item.backTaskCode
});
});
}
},
selectTypeList() {
listTask().then(async res => {
this.backTaskCodeList = res.rows.map(item => {
return item.backTaskCode
});
})
},
scanBarCode() {
if (this.formData.backTaskCode) {
// let data = {
// backTaskDetailCode: this.formData.backTaskDetailCode
// }
getRcvByTask(this.formData).then(res => {
this.formData.wmsBackReceiveDetailList = res.wmsBackReceive.wmsBackReceiveDetailList;
})
} else {
this.$modal.msg("请输入生产退料任务单!")
}
},
bindDateChange(e) {
this.formData.arriveTime = e.detail.value
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
//仓库编码
scanBarwarehouseCode() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
//签收员编码
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.drawBy = res.result;
// _this.scanBarCode();
}
});
},
submit() {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定收取该物料吗?',
success: function(res) {
if (res.confirm) {
console.log(_this.formData)
_this.formData.wmsBackReceiveDetailList.map(item => {
item.secondTheoryNumber = item.number;
item.secondUnitId = item.unitId;
item.secondArriveNumber = item.arriveNumber;
item.secondActualNumber = item.actualNumber;
item.secondActualUnitId = item.unitId;
return item
})
if (_this.isReceive == false) {
//判断实收数量是否超出应收数量
let isNumOver = false;
for (var i in _this.formData.wmsBackReceiveDetailList) {
if (_this.formData.wmsBackReceiveDetailList[i]
.actualNumber > _this.formData.wmsBackReceiveDetailList[
i].theoryNumber) {
_this.$modal.msg("实收数量超出应收数量,请检查!");
isNumOver = true;
}
}
if (isNumOver == false) {
_this.$modal.loading('提交中')
addReceive(_this.formData).then(async res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("收货成功!");
setTimeout(() => {
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
}
} else {
console.log(1)
let isNumOver = false;
for (var i in _this.formData.wmsBackReceiveDetailList) {
if (_this.formData.wmsBackReceiveDetailList[i]
.actualNumber > (_this.formData
.wmsBackReceiveDetailList[i].theoryNumber - _this
.formData.wmsBackReceiveDetailList[i].receivedNumber
)) {
_this.$modal.msg("实收数量超出应收数量,请检查!");
isNumOver = true;
}
}
if (isNumOver == false) {
console.log(_this.formData.wmsBackReceiveDetailList)
_this.formData.wmsBackReceiveDetailList[0].actualNumber +=
_this.formData.wmsBackReceiveDetailList[0]
.receivedNumber;
_this.formData.wmsBackReceiveDetailList[0].arriveNumber +=
_this.formData.wmsBackReceiveDetailList[0]
.receivedNumber;
_this.$modal.loading('提交中')
updateReceiveDetail(_this.formData.wmsBackReceiveDetailList[
0])
.then(async res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("收货成功!");
setTimeout(() => {
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
}
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
}
}
</script>
<style>
</style>