初始化仓库

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,283 @@
<template>
<view>
<uni-collapse style="width: 100%;">
<uni-forms ref="form" :modelValue="getCode" class="form">
<uni-easyinput type="text" prefixIcon="scan"
class="Number"
placeholder="请扫描销售工业条码!"
placeholderStyle="color:black"
v-model="getCode.Industry"
@iconClick="iconClick('industry')"
@confirm="getIndustry"
:focus="focusFoIndustry"
clearable
/>
<uni-collapse-item :disabled="open" :open="!open" class="uniCollapse">
<form class="form" >
<uni-table border stripe emptyText="暂无更多数据" >
<!-- 表格数据行 -->
<uni-tr>
<uni-td align="center" width="30">物料编码</uni-td>
<uni-td align="center" width="70">{{form.materialCode}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center" width="30">工业条码</uni-td>
<uni-td align="center" width="70">{{form.Industry}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center" width="30">物料名称</uni-td>
<uni-td align="center" width="70">{{form.materialName}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center" width="30">规格</uni-td>
<uni-td align="center" width="70">{{form.specification1}}</uni-td>
</uni-tr>
</uni-table>
<br />
<uni-easyinput type="text" prefixIcon="scan"
class="Number"
placeholder="请扫描组件二维码!"
placeholderStyle="color:black"
v-model="getCode.computed"
@iconClick="iconClick('subassembly')"
@confirm="getSubassembly"
:focus="focusComputed"
clearable
/>
<uni-table border stripe emptyText="暂无更多数据" >
<!-- 表头行 -->
<uni-tr>
<uni-th align="center" width="70">编码</uni-th>
<uni-th align="center" width="30">操作</uni-th>
</uni-tr>
<!-- 表格数据行 -->
<uni-tr v-for="(item,index) in form.list" :key="index">
<uni-td align="center">{{item.componentCode}}</uni-td>
<uni-td align="center">
<u-button @click="deleteList(item)">删除</u-button>
</uni-td>
</uni-tr>
</uni-table>
</form>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog cancelText="关闭" confirmText="同意" title="通知" :content="'是否删除编码为'+item.componentCode+'的单子'" @confirm="dialogConfirm"
@close="dialogClose"></uni-popup-dialog>
</uni-popup>
<!-- 提示信息弹窗 -->
<uni-popup ref="message" type="message">
<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
</uni-popup>
</view>
</template>
<script>
import {
getMaterial,
} from "@/api/mes/material.js";
import {
getSubassembly,
insertSubassembly,
deletSubassembly
} from "@/api/mes/wmsPieceOutRecord.js"
export default {
data() {
return {
//工业条码自动聚焦
focusFoIndustry:true,
focusComputed:false,
//解析的码数据
getCode:{
//工业条码
Industry:null,
//组件
computed:null,
},
//控制明细区是否展开
open:true,
//获取到的数据
form:{
list:[{
name:1,
id:3
},{
name:2,
id:4
}]
},
//要删除的信息
item:{},
//提示信息
messageText:null,
msgType:'info'
}
},
methods: {
/**
* 扫码方法
* @param {Object} value {industry || number }
*/
iconClick(value){
const _this = this;
uni.scanCode({
// 是否只能从相机扫码,不允许从相册选择图片
onlyFromCamera:true,
// 扫码类型
scanType: ['barCode', 'qrCode'],
success: function(res) {
value === 'industry' ? _this.getIndustry(res.result) : value;
value === 'subassembly' ? _this.getSubassembly(res.result) : value;
}
})
},
/**
* 扫描工业条码
* @param {Object} pieceBarcode 解析到的条码数据
*/
async getIndustry(pieceBarcode){
const _self = this;
//判断工业条码里面是否有,号,逗号后面是九位数
_self.focusComputed = false;
if(pieceBarcode ==undefined || pieceBarcode == null|| pieceBarcode.length < 11) return
if(pieceBarcode.indexOf(',') === -1 ||pieceBarcode.split(',').length !=2 ||pieceBarcode.split(',')[1].length != 9){
this.updateMessage('error','该工业条码不符合规范')
return
}
try{
//获取物料信息
const {materialCode,materialName,specification1} = await fnGetMaterial(pieceBarcode);
//获取组件信息
const list = await this.getSubassemblyList(pieceBarcode)
//把所有信息存入form中
_self.form = Object.assign({},{materialCode,materialName,specification1,list,Industry:pieceBarcode})
_self.open = false
_self.focusComputed = true;
}catch(e){
//TODO handle the exception
_self.updateMessage('error','未查到相关数据')
_self.form = Object.assign({})
}
/**
* 通过id获取物料信息
* @param {Object} pieceBarcode 扫描的工业条码
*/
async function fnGetMaterial(pieceBarcode){
//从pieceBarcode截取逗号前面的数据用作id
const id = parseInt(pieceBarcode.split(',')[0]);
let data = [];
await getMaterial(id).then(function(res){
data = res.data
})
return data;
}
},
/**
* 扫描组件条码
* @param {Object} code
*/
async getSubassembly(componentCode){
const _self = this;
// _self.focusComputed = false;
//判断条码是否符合规范
if(componentCode === null || componentCode ==='' ||componentCode === undefined) return _self.focusComputed = true
//查询组件表是否有这个组件,没有则添加,有则结束
if(!await fnInsertSubassembly(this.form.Industry,componentCode)) {
_self.focusComputed = true
return _self.updateMessage('warn','该组件已被扫描')
}
//重新查询数据
const list = await _self.getSubassemblyList(_self.form.Industry)
//把所有信息存入form中
_self.form = Object.assign({},_self.form,{list});
_self.getCode.computed = null;
_self.focusComputed = true
/**
* 查询组件表是否有这个组件,没有则添加
* @param {Object} Industry
* @param {Object} componentCode
*/
async function fnInsertSubassembly(Industry,componentCode){
let data = false;
await insertSubassembly(Industry,componentCode).then(res=>{
data = true
})
return data
}
},
/**
* 通过工业条码查询组件信息
* @param {Object} pieceBarcode
*/
async getSubassemblyList(pieceBarcode){
let data = [];
await getSubassembly(pieceBarcode).then(res => {
data = res.data
})
return data
},
/**
* 删除明细
* @param {Object} 要删除明细的数据
*/
deleteList(item){
this.item = item
this.$refs.alertDialog.open()
},
/**
* 弹出框确认按钮
*/
async dialogConfirm(){
const _self = this;
await deletSubassembly(this.item.id).then(async res => {
this.$refs.alertDialog.close()
this.updateMessage('success','删除成功')
//重新查询数据
const list = await this.getSubassemblyList(_self.form.Industry)
//把所有信息存入form中
_self.form = Object.assign({},_self.form,{list})
})
},
/**
* 弹出框取消按钮
*/
dialogClose(){
this.updateMessage('info','取消删除')
},
/**控制提示框的类型和文字
* @param {Object} type {'info':消息,'success''成功‘,'error':'失败','warn':'警告'}
* @param {Object} text
*/
updateMessage(type,text){
this.messageText = text
this.msgType = type
this.$refs.message.open()
}
}
}
</script>
<style>
page{
padding-top: 10px;
background-color: #ffffff ;
}
</style>
<style scoped lang="scss">
.form {
width: 90%;
margin: 0 auto;
color: black;
font-size:40rpx;
}
.form text {
margin-left: 20%;
}
</style>

View File

@@ -0,0 +1,565 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules" label-align="right">
<uni-collapse-item title="直接入库单" :open="true">
<uni-forms-item label="工单" :labelWidth='80' name="workOrderCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanWorkOrderCode" @change="handleChangeWorkOrderCode"
v-model="workOrderCode" type="text" />
</uni-forms-item>
<uni-forms-item label="产品入库任务单" :labelWidth='80' name="productInTaskCode">
<uni-combox :candidates="productInTaskCodeList" emptyTips="无" @input="fetchTaskInfo"
v-model="formData.productInTaskCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="上架员" :labelWidth='80' name="shelfPutBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanPutBy" v-model="formData.shelfPutBy" type="text" />
<uni-data-picker popup-title="选择上架员" :localdata="dataTree" v-model="pickerData" @change="onchange"
@nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed" placeholder="选择上架员"
class="putByPicker" :preload="true">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="入库方式" :labelWidth='80'>
<uni-data-checkbox v-model="value" :localdata="pdcInTypeOptions" class="pdcInType" />
</uni-forms-item>
<span v-if="value=='扫物料标签' && formData.wmsProductInDetailList.length == 0" class="scanMatLabel">
<button size="mini" type="primary" class="scanMatLabelBtn" @click="show=!show">
添加物料标签
</button>
</span>
<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.wmsProductInDetailList" @click="(data) => clickDetail(index,data)"
@change="swipChange">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :labelWidth='90' :name="'wmsProductInDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90' :name="'wmsProductInDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90' name="'wmsProductInDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" :labelWidth='90' name="'wmsProductInDetailList.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="text" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="类型" :labelWidth='90' name="'wmsProductInDetailList.'+ 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-forms-item>
<uni-forms-item label="推荐库位" :label-width="90" ref="myInput">
<uni-easyinput type="text" class="uni-mt-5" v-model="item.recommendLocation" disabled>
<template #right>
<uni-icons custom-prefix="iconfont" type="icon-fuzhi" size="40"
@click="clickCopy(index)"></uni-icons>
</template>
</uni-easyinput>
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
name="'wmsProductInDetailList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item>
<uni-forms-item label="上架数量" :labelWidth='90' name="'wmsProductInDetailList.'+ index +'number'">
<uni-easyinput disabled type="text" v-model="item.number" v-if="value == '扫物料标签'" />
<u-number-box inputWidth="120" button-size="36" v-model="item.number" :min="0" :max="item.notInNumber" v-else></u-number-box>
</uni-forms-item>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<view class="opt">
<button @click="clickCopy">一键复制</button>
<button type="primary" @click="submit">提交</button>
</view>
</view>
</template>
<script>
import {
addIn,
listTask,
getTask,
getReveive,
getDetails,
listReceiveDetail,
getDetail,
directProductInByTaskDetail,
getConnectLoc
} from "@/api/wms/pdcIn.js";
import { listDepartment } from "@/api/basic/department";
import { listEmployee } from "@/api/mes/jobIn.js";
import { listWarehouse } from "@/api/wms/warehouse";
import { listStock } from "@/api/wms/stock.js";
import { getConfigKey } from "@/api/system/config.js"
import { getMaterial_code } from "@/api/wms/purchase.js";
import { listLocation } from '@/api/basic/location';
export default {
mounted() {
// 获取任务单编码列表
listTask({
pageNum: 1,
pageSize: 25
}).then(res => {
this.productInTaskCodeList = res.rows.map(item => item.productInTaskCode);
});
// 获取部门列表
listDepartment().then((res) => {
this.dptList = res.rows
})
// 获取员工列表
listEmployee().then((res) => {
this.empList = res.rows
})
// 获取参数: 库位显示级数
getConfigKey('wms.location.size').then(res => {
this.locationSize = res.msg
})
},
data() {
return {
locationSize: null,
value: '正常',
show: false,
materialLabel: null,
workOrderCode: '',
productInTaskCodeList: [],
legalLocation: true,
dptList: [],
empList: [],
item: '',
dataTree: [],
pickerData: '',
formData: {
billType: '2',
status: '3',
productInTaskCode: '',
shelfPutBy: null,
wmsProductInDetailList: [],
},
//类型
pdcInTypeOptions: [
{ text: '正常', value: '正常' },
{ text: '扫物料标签', value: '扫物料标签' },
],
typeOptions: [{
value: 1,
label: "合格",
},
{
value: 2,
label: "不良",
},
{
value: 3,
label: "报废",
},
],
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
productInTaskCode: {
rules: [{
required: true,
errorMessage: '请输入产品入库任务单!'
}]
},
shelfPutBy: {
rules: [{
required: false,
errorMessage: '请输入上架员编码!'
}]
}
}
}
},
methods: {
// 工单改变
handleChangeWorkOrderCode() {
// 重置任务单列表
this.productInTaskCodeList = [];
// 重置任务单编码
this.formData.productInTaskCode = '';
// 重置明细
this.formData.wmsProductInDetailList = [];
// 获取任务单列表
this.fetchTaskList();
},
// 获取任务单列表
fetchTaskList() {
if (!this.workOrderCode) return;
listTask({
workOrderCode: this.workOrderCode
}).then(async res => {
this.productInTaskCodeList = res.rows.map(item => item.productInTaskCode);
}).catch(err => {
console.error(`获取工单号为${this.workOrderCode}的产品入库任务单列表失败,详情:${err}`);
});
},
// 扫描工单号
scanWorkOrderCode() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.workOrderCode = res.result;
_this.handleChangeWorkOrderCode();
}
});
},
onnodeclick(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);
}
})
},
onchange(e) {
this.formData.shelfPutBy = null
this.$set(this.formData, 'shelfPutBy', e.value.split('/')[0])
},
cancelMaterialLabel() {
this.materialLabel = null;
this.show = false;
},
confirmMaterialLabel(data) {
data = JSON.parse(data)
if (data) {
this.id = data.id
getDetail(data.id).then(res => {
if (res.data) {
this.formData.productInTaskCode = res.data.productInTaskCode;
let obj = {
materialCode: res.data.materialCode,
materialName: res.data.materialName,
materialBatchNo: res.data.materialBatchNo,
materialLotNo: res.data.materialLotNo,
type: res.data.type,
storageLocationBarcode: res.data.storageLocationBarcode,
number: res.data.number
}
this.formData.wmsProductInDetailList.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 validateLocation(item) {
const code = item.storageLocationBarcode
if (!code) return false
if (['2', '4'].includes(this.locationSize)) return true
let fullLocation = null
if (this.locationSize == '0') {
fullLocation = code
} else if (this.locationSize == '5') {
// 用两级库位查完整库位
const res = await listLocation({
storageShelvesCode: code.split('-')[0],
storageLocationCode: code.split('-').slice(1).join('-')
})
fullLocation = res.rows[0]?.storageLocationBarcode || null
}
const data = await getConnectLoc({ connectLoc: fullLocation })
if (data.data) {
item.whCode = fullLocation.split('-')[0] || null
item.areaCode = fullLocation.split('-')[1] || null
item.shelvesCode = fullLocation.split('-')[2] || null
item.storageLocationCode = fullLocation.split('-').slice(3).join('-') || null
} else {
this.$modal.msg("库位条码校验错误,请重新输入!")
}
return data.data
},
// 扫描库位编码
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.formData.wmsProductInDetailList[i], "storageLocationBarcode", res.result);
}
});
},
selectTypeList() {
listTask({
pageNum: 1,
pageSize: 25
}).then(async res => {
for (var i in res.rows) {
this.productInTaskCodeList.push(res.rows[i].productInTaskCode);
}
});
},
// 依次获取推荐库位
async fetchLocation(taskDetail) {
const promises = taskDetail.map(async (item) => {
if (!item.materialCode) {
return {
...item,
recommend: null,
recommendLocation: null
}
}
const res = await getMaterial_code(item.materialCode);
// 提供默认值以防 res 为 null 或 undefined
const { data } = res || {};
const recommend = data || null;
const recommendLocation = data ? this.getRecommend(data) : null;
return { ...item, recommend, recommendLocation };
});
// 等待所有异步操作完成
const updatedList = await Promise.all(promises);
return updatedList;
},
async fetchTaskInfo() {
// 清空明细单列表
this.formData.wmsProductInDetailList = [];
if (!this.formData.productInTaskCode) return;
let taskId = null;
let taskDetail = [];
// 获取任务单 id
await listTask({
productInTaskCode: this.formData.productInTaskCode
}).then(res => {
taskId = res.rows[0].id
}).catch(err => {
console.error(`获取入库任务单号为${this.formData.productInTaskCode}的任务单 id 失败,详情:${err}`);
})
// 根据任务单 id 获取任务单明细
await getTask(taskId).then(res => {
taskDetail = res.data.wmsProductInTaskDetailList
}).catch(err => {
console.error(`获取入库任务单 id 为${taskId}的任务单明细失败,详情:${err}`);
})
if (taskDetail.length === 0) return
// 获取推荐库位
this.formData.wmsProductInDetailList = await this.fetchLocation(taskDetail)
console.log("明细单列表: ", this.formData.wmsProductInDetailList)
},
// 上架员
scanPutBy() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.shelfPutBy = res.result;
}
});
},
// 拆解推荐库位
getRecommend(recommend) {
const { whCode, areaCode, shelvesCode, storageLocationCode } = recommend
if (!(whCode || areaCode || shelvesCode || storageLocationCode)) return null
switch (this.locationSize) {
case '0':
return [whCode, areaCode, shelvesCode, storageLocationCode].join('-')
case '2':
return areaCode
case '4':
return storageLocationCode
case '5':
return [shelvesCode, storageLocationCode].join('-')
}
},
// 校验明细单各项库位是否为空
checkLocation() {
this.formData.wmsProductInDetailList.forEach(item => {
if (!item.storageLocationBarcode) {
this.$modal.msg("库位条码不允许为空")
return false
}
})
return true
},
// 提交
async submit() {
const _this = this;
if (!this.checkLocation()) return
_this.$modal.loading('校验库位中')
await _this.formData.wmsProductInDetailList.forEach(async item => {
// 避免明细传递失败,删除明细 id
delete item.id;
if (!item.storageLocationBarcode) {
this.$modal.msg("库位条码不允许为空");
return;
}
const res = await _this.validateLocation(item)
if (!res) {
item.storageLocationBarcode = null
this.$modal.msg("库位条码校验错误,请重新输入!")
return
}
})
_this.$modal.closeLoading()
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成直接入库吗?',
success: function(res) {
if (res.confirm) {
if (_this.value == '扫物料标签') {
let obj = {
id: _this.id,
whCode: _this.formData.wmsProductInDetailList[0].whCode,
areaCode: _this.formData.wmsProductInDetailList[0]
.areaCode,
shelvesCode: _this.formData.wmsProductInDetailList[0]
.shelvesCode,
storageLocationCode: _this.formData.wmsProductInDetailList[
0].storageLocationCode
}
_this.$modal.loading('提交中')
directProductInByTaskDetail(obj).then(async res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("入库成功!");
_this.$tab.switchTab('/pages/work/index');
});
} else {
if (_this.formData.productInTaskCode) {
_this.$modal.loading('提交中')
addIn(_this.formData).then(async res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("入库成功!");
_this.$tab.switchTab('/pages/work/index');
});
}
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
// 复制库位
clickCopy(index) {
// 创建新数组避免引用问题
const newList = this.formData.wmsProductInDetailList.map(item => ({ ...item }));
if (typeof index === 'number') {
// 复制单个项
newList[index] = {
...newList[index],
storageLocationBarcode: newList[index].recommendLocation,
whCode: newList[index].recommend.whCode,
areaCode: newList[index].recommend.areaCode,
shelvesCode: newList[index].recommend.shelvesCode,
storageLocationCode: newList[index].recommend.storageLocationCode
};
} else {
// 复制所有项
newList.forEach(item => {
item.storageLocationBarcode = item.recommendLocation;
item.whCode = item.recommend.whCode;
item.areaCode = item.recommend.areaCode;
item.shelvesCode = item.recommend.shelvesCode;
item.storageLocationCode = item.recommend.storageLocationCode;
});
}
// 创建新对象确保响应式更新
this.formData = {
...this.formData,
wmsProductInDetailList: newList
};
}
}
}
</script>
<style lang="scss" scoped>
.putByPicker {
margin-top: 5px;
}
.pdcInType {
margin-top: 6px;
}
.scanMatLabel {
display: flex;
}
.scanMatLabel .scanMatLabelBtn {
justify-content: center;
font-size: 1.1rem;
}
.opt {
// position: fixed;
// bottom: 0;
width: 100%;
padding: 2vw 0;
display: flex;
justify-content: space-evenly;
}
.opt button {
flex: 1;
margin: 0 5px;
}
</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-caidanlan-shengchan-shengchanruku" 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/pdcIn/pdcSh');
} else if (e.detail.index == 2) {
this.$tab.navigateTo('/pages/wms/pdcIn/pdcInQualityT');
} else if (e.detail.index == 3) {
this.$tab.navigateTo('/pages/wms/pdcIn/pdcRk');
}
}
}
}
</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,239 @@
<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="productReveiveCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode"
v-model="formData.productReveiveCode" type="text" />
</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>
</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.pdcInQualityDetailList"
@click="(data) => clickDetail(index,data)" @change="swipChange">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :name="'pdcInQualityDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :name="'pdcInQualityDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'
name="'pdcInQualityDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="实收数量" :labelWidth='90'
name="'pdcInQualityDetailList.'+ index +'.actualNumber'">
<uni-easyinput disabled type="number" v-model="item.actualNumber" />
</uni-forms-item>
<uni-forms-item label="质检数量" :labelWidth='90'
name="'pdcInQualityDetailList.'+ index +'number'">
<uni-easyinput disabled type="number" v-model="item.number" />
</uni-forms-item>
<uni-forms-item label="合格数量" :labelWidth='90'
name="'pdcInQualityDetailList.'+ index +'.passNumber'">
<u-number-box inputWidth="120" button-size="36" v-model="item.passNumber"
min="0"></u-number-box>
</uni-forms-item>
<!-- <uni-forms-item label="不良数量" :labelWidth='90' name="'pdcInQualityDetailList.'+ index +'.blNum'">
<uni-easyinput type="number" v-model="item.blNum"/>
</uni-forms-item> -->
<uni-forms-item label="不良原因" :labelWidth='90'
name="'pdcInQualityDetailList.'+ 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 {
addReveive,
listReceive,
getReceive,
listTask,
getTask,
listQuality,
getQuality,
addQuality
} from "@/api/wms/pdcIn.js";
import {
listMaterial
} from "@/api/wms/request.js";
export default {
mounted() {
this.test();
},
data() {
return {
formData: {
pdcInQualityDetailList: [],
},
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
productReveiveCode: {
rules: [{
required: true,
errorMessage: '请输入产品收货单!'
}]
},
materialCode: {
rules: [{
required: true,
errorMessage: '请输入物料编码!'
}]
},
}
}
},
methods: {
clickDetail(itemIndex, {
position,
index
}) {
// if (index == 0){
// this.deleteDetail(itemIndex);
// }
},
reset(code) {
this.formData = {
productReveiveCode: code,
pdcInQualityDetailList: [],
};
},
test() {
listQuality().then(async res => {
console.log(res);
});
// getQuality('284').then(async res => {
// console.log(res);
// });
},
scanBarCode(code) {
if (code) {
this.reset(code);
}
if (this.formData.productReveiveCode) {
let q = {
productReveiveCode: this.formData.productReveiveCode
}
listReceive(q).then(async res => {
console.log(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.wmsProductReceiveDetailList) {
let obj = {};
obj.materialBatchNo = res.data.wmsProductReceiveDetailList[i]
.materialBatchNo;
obj.materialCode = res.data.wmsProductReceiveDetailList[i]
.materialCode;
obj.materialName = res.data.wmsProductReceiveDetailList[i]
.materialName;
obj.actualNumber = res.data.wmsProductReceiveDetailList[i]
.actualNumber;
obj.number = res.data.wmsProductReceiveDetailList[i]
.actualNumber
obj.unitId = res.data.wmsProductReceiveDetailList[i]
.unitId
this.formData.pdcInQualityDetailList.push(obj);
}
});
}
});
}
},
//采购任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.productReveiveCode = res.result;
_this.scanBarCode(_this.formData.productReveiveCode);
}
});
},
submit() {
const _this = this;
// this.$refs["jobInForm"].validate().then(valid => {
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成该质检吗?',
success: function(res) {
if (res.confirm) {
// let psNum = Number()
let wmsProductQualityDetailList = [];
for (let i in _this.formData.pdcInQualityDetailList) {
let obj = {};
obj.materialCode = _this.formData.pdcInQualityDetailList[i]
.materialCode;
obj.materialName = _this.formData.pdcInQualityDetailList[i]
.materialName;
obj.materialBatchNo = _this.formData.pdcInQualityDetailList[i]
.materialBatchNo;
obj.number = _this.formData.pdcInQualityDetailList[i].number;
obj.unitId = Number(_this.formData.pdcInQualityDetailList[i]
.unitId);
obj.secondNumber = _this.formData.pdcInQualityDetailList[i].number;
obj.passNumber = Number(_this.formData.pdcInQualityDetailList[i]
.passNumber);
obj.secondPassNumber = Number(_this.formData
.pdcInQualityDetailList[i]
.secondPassNumber);
obj.secondUnitId = Number(_this.formData.pdcInQualityDetailList[i]
.unitId);
obj.failReason = _this.formData.pdcInQualityDetailList[i]
.failReason;
wmsProductQualityDetailList.push(obj);
}
console.log(wmsProductQualityDetailList);
let data = {
productReceiveCode: _this.formData.productReveiveCode,
status: '1',
wmsProductQualityDetailList: wmsProductQualityDetailList
}
console.log(data);
_this.$modal.loading('提交中')
addQuality(data).then(response => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("质检成功!");
_this.$tab.switchTab('/pages/work/index');
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
}
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,373 @@
<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,
isSubmitted: false,
// 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 = [];
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;
let materialCode = this.singleInfo.materialCode;
let batchNo = this.singleInfo.materialBatchNo;
let unit = this.singleInfo.unit;
let productInCode = this.singleInfo.productInCode;
let unitId = this.singleInfo.unitId;
let secondUnitId = this.singleInfo.secondUnitId;
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.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.unit = unit;
obj.storageInBillCode = productInCode;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
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;
let materialCode = this.singleInfo.materialCode;
let batchNo = this.singleInfo.materialBatchNo;
let unit = this.singleInfo.unit;
let productInCode = this.singleInfo.productInCode;
let unitId = this.singleInfo.unitId;
let secondUnitId = this.singleInfo.secondUnitId;
for (let i = 0; i < this.splitNumber; i++) {
let obj = {};
obj.materialCode = materialCode;
obj.batchNo = batchNo;
obj.number = k;
obj.secondNumber = k;
obj.unit = unit;
obj.unitId = unitId;
obj.secondUnitId = secondUnitId;
obj.storageInBillCode = productInCode;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.storageInTime = this.rkTime;
// obj.lotNo = i + 1;
if (i == this.splitNumber - 1) {
obj.number = 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.secondNumber = this.singleInfo.secondNumber;
obj.secondUnit = this.singleInfo.secondUnit;
obj.secondUnitId = this.singleInfo.secondUnitId;
obj.storageInBillCode = this.singleInfo.productInCode;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.number = this.singleInfo.number;
obj.unit = this.singleInfo.unit;
obj.storageInTime = this.rkTime;
// obj.lotNo = 1;
this.wmsLotNoList.push(obj);
},
async splitStlBarcode(i, event) {
console.log(this.wmsLotNoList[i]);
const _this = this;
const detail = _this.wmsLotNoList[i];
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;
console.log(this.wmsLotNoList[i]);
},
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.wmsLotNoList[i].storageLocationBarcode = res.result;
_this.splitStlBarcode(i);
}
});
},
//提交分批入库详情
async submit() {
//数量防错
let allNum = 0;
for (var i in this.wmsLotNoList) {
allNum += this.wmsLotNoList[i].number;
}
console.log(allNum)
if (allNum == this.singleInfo.number) {
let obj = {};
obj = this.singleInfo;
obj.batchNo = this.singleInfo.materialBatchNo;
obj.lotNo = this.singleInfo.materialLotNo;
obj.eachNumber = this.eachNumber;
obj.storageInBillDetailCode = this.singleInfo.storageInBillDetailCode;
obj.storageInBillCode = this.singleInfo.storageInBillCode;
obj.type = this.singleInfo.type;
// obj.eachSecondNumber = this.eachSecondNumber;
obj.splitNumber = this.splitNumber;
if (!this.checkStorageLocationBarcode) {
this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
// 拼接仓库
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 => {
console.log(this.wmsLotNoList)
addInDetail(this.wmsLotNoList, 1).then(res => {
console.log(res)
if (this.wmsLotNoList && this.wmsLotNoList.length > 0) {
this.selectedRow.status = "1";
} else {
this.selectedRow.status = "0";
}
this.$modal.closeLoading();
this.$modal.msgSuccess("编辑成功!");
uni.$emit('backWithParam', {
status: this.selectedRow.status,
index: this.index
});
this.$tab.navigateBack();
});
});
} 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>

718
pages/wms/pdcIn/pdcRk.vue Normal file
View File

@@ -0,0 +1,718 @@
<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="productReceiveCode">
<uni-combox :candidates="productReceiveCodeList" emptyTips="无" @input="scanBarReceiveCode"
v-model="formData.productReceiveCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="产品入库质检单" :labelWidth='90' name="productQualityCode">
<uni-combox :candidates="productQualityCodeList" emptyTips="无" @input="scanBarQualityCode"
v-model="formData.productQualityCode" />
</uni-forms-item>
<uni-forms-item label="产品入库单" :labelWidth='90' name="productInCode">
<uni-combox-re labelKey="productInCode" valueKey="productInCode" :candidates="productInCodeList"
emptyTips="无" @input="scanBarProductInCode"
v-model="formData.productInCode"></uni-combox-re>
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBarwarehouseCode"
v-model="formData.warehouseCode" />
<uni-data-select style="margin-top: 5px;" v-model="formData.warehouseCode"
:localdata="wcList"></uni-data-select>
</uni-forms-item>
<uni-forms-item label="上架员" :labelWidth='90' name="shelfPutBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.shelfPutBy"
type="text" />
<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>
<!-- <uni-forms-item :labelWidth='90' > -->
<button size="mini" v-if="value=='扫物料标签' && formData.wmsProductInDetailList.length == 0"
type="primary" style="text-align: center;margin-left: 30%;font-size: 18px;"
@click="show=!show">添加物料标签</button>
<!-- </uni-forms-item> -->
<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"
@click="(data) => clickDetail(index,data)"
v-for="(item, index) in formData.wmsProductInDetailList">
<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-badge :text="index+1" type="primary"></uni-badge> -->
<uni-forms-item label="物料编码" :name="'wmsProductInDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :name="'wmsProductInDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" name="'wmsProductInDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" name="'wmsProductInDetailList.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="text" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="类型" name="'wmsProductInDetailList.'+ 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-forms-item>
<!-- <uni-forms-item label="库位条码" :labelWidth='90'
name="'wmsProductInDetailList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)"
@confirm="splitStlBarcode(index)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item> -->
<uni-forms-item label="上架数量" :labelWidth='90'
name="'wmsProductInDetailList.'+ index +'number'">
<u-number-box inputWidth="120" button-size="36" v-model="item.number"
min="0"></u-number-box>
</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>
<!-- <u-modal :show="show" :title="title" content='是否进行批号分包入库'></u-modal> -->
</view>
</template>
<script>
import {
listQuality,
addIn,
listTask,
getTask,
getReceive,
getDetails,
listReceive,
updateIn,
listIn,
getIn,
listReceiveDetail,
updateProductIndetail
} from "@/api/wms/pdcIn.js";
import {
getListDetailByBL
} from "@/api/wms/purchase.js"
import uniComboxRe from "../../../uni_modules/uni-combox/components/uni-combox/uni-combox-re.vue"
import {
listDepartment
} from "@/api/basic/department";
import {
listEmployee
} from "@/api/mes/jobIn.js";
import {
listWarehouse
} from "@/api/wms/warehouse";
import _ from 'lodash';
export default {
created() {
//监听编辑批号分批后的状态
uni.$on('backWithParam', (param) => {
console.log(param);
if (param.status && param.index) {
this.formData.wmsProductInDetailList[Number(param.index)].status = param.status
}
this.checkIsListed();
});
},
mounted() {
listDepartment().then((res) => {
this.dptList = res.rows
})
listEmployee().then((res) => {
this.empList = res.rows
})
listWarehouse().then((res) => {
this.wcList = res.rows.map(item => {
let obj = {
text: item.warehouseName,
value: item.warehouseCode
}
return obj
})
})
},
components: {
uniComboxRe
},
data() {
return {
buttonDisabled: false,
dptList: [],
empList: [],
wcList: [],
item: '',
dataTree: [],
pickerData: '',
value: '正常',
show: false,
materialLabel: null,
range: [],
isRk: false,
//是否打开编辑按钮
isSplit: true,
workOrderCode: '',
productReceiveCodeList: [],
productQualityCodeList: [],
productInCodeList: [],
formData: {
workOrderCode: '',
productReceiveCode: '',
productQualityCode: '',
shelfPutBy: null,
wmsProductInDetailList: [],
billType: "1",
status: "1",
id: null,
productInCode: ''
},
//是否都入库
isAllListed: false,
// storageLocationBarcode:null,
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
shelfPutBy: {
rules: [{
required: true,
errorMessage: '请输入上架员编码!'
}]
},
// workOrderCode: {
// rules: [{
// required: true,
// errorMessage: '请输入工单!'
// }]
// }
},
wmsLotNoList: []
}
},
methods: {
deleteDetail(index) {
this.formData.wmsProductInDetailList.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({
productInTaskDetailId: data.id
}).then(res => {
console.log(res)
//若已有收货单
if (res.data.length > 0) {
this.formData.productReceiveCode = res.data[0].productReceiveCode;
// this.formData.workOrderCode = data.pwoCode;
this.formData.productQualityCode = '';
this.formData.productInCode = '';
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) {
console.log(row)
// 禁用按钮
this.buttonDisabled = true;
//拆分下的列表
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.unitId = row.unitId;
singleInfo.secondNumber = row.number;
singleInfo.secondUnitId = row.unitId;
singleInfo.productInCode = row.productInCode;
singleInfo.materialName = row.materialName;
singleInfo.type = row.type;
singleInfo.storageInBillDetailCode = row.productInDetailCode;
this.formData.productInCode = row.productInCode;
await getListDetailByBL({
materialCode: row.materialCode,
storageInBillDetailCode: row.productInDetailCode,
batchNo: row.materialBatchNo,
lotNo: row.materialLotNo,
}).then((response) => {
console.log(response)
if (
response.materialDetailList &&
response.materialStockList
) {
/** 导入拆分信息 */
if (response.materialDetailList.length > 0) {
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.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;
}
} else {
if (singleInfo.materialLotNo) {
console.log(singleInfo)
splitNumber = 1;
singleInfo.storageInBillCode = singleInfo.productInCode;
this.wmsLotNoList.push(singleInfo);
console.log(this.wmsLotNoList)
isSecondOpen = true;
}
}
});
console.log(6)
console.log(this.wmsLotNoList);
uni.navigateTo({
url: '/pages/wms/pdcIn/pdcListing?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.wmsProductInDetailList[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.storageAreaCode == 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.productReceiveCodeList = [];
this.productQualityCodeList = [];
this.productInCodeList = [];
if (this.formData.workOrderCode) {
listReceive({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
for (var i = 0; i < response.rows.length; i++) {
this.productReceiveCodeList.push(response
.rows[i].productReceiveCode);
}
});
listQuality({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
for (var i = 0; i < response.rows.length; i++) {
this.productQualityCodeList.push(response.rows[i].productQualityCode);
}
});
listIn({
workOrderCode: this.formData.workOrderCode
}).then(async response => {
this.productInCodeList = response.rows
// for (var i = 0; i < response.rows.length; i++) {
// this.productInCodeList.push(response.rows[i].productInCode);
// }
});
}
},
change(e) {
console.log(e);
},
// selectTypeList() {
// this.productReceiveCodeList = [];
// this.productQualityCodeList = [];
// this.productInCodeList = [];
// listReceive().then(async response => {
// for (var i = 0; i < response.rows.length; i++) {
// this.productReceiveCodeList.push(response.rows[i].productReceiveCode);
// }
// });
// listQuality().then(response => {
// for (var i = 0; i < response.rows.length; i++) {
// this.productQualityCodeList.push(response.rows[i].productQualityCode);
// }
// });
// listIn().then(response => {
// for (var i = 0; i < response.rows.length; i++) {
// this.productInCodeList.push(response.rows[i].productInCode);
// }
// });
// },
scanBarReceiveCode() {
if (this.formData.productReceiveCode) {
this.formData.productQualityCode = '';
this.formData.productInCode = '';
this.selectTask();
} else {
this.$modal.msg("产品入库收货单!");
}
},
scanBarQualityCode() {
if (this.formData.productQualityCode) {
this.formData.productReceiveCode = '';
this.formData.productInCode = '';
this.selectTask();
} else {
this.$modal.msg("产品入库质检单!");
}
},
selectTask() {
getDetails(this.formData).then(res => {
this.formData.wmsProductInDetailList = res.details;
this.formData.warehouseCode = res.inBill.warehouseCode;
})
},
scanBarProductInCode(i) {
this.formData.productReceiveCode = '';
this.formData.productQualityCode = '';
getIn(this.productInCodeList.find(item => item.productInCode == i).id).then((response) => {
this.formData = response.data;
this.checkIsListed();
});
},
//上架员
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.shelfPutBy = 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.productReceiveCode || _this.formData
.productQualityCode) {
// _this.formData.wmsProductInDetailList.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;
console.log(_this.formData);
_this.checkIsListed();
_this.$modal.msgSuccess("修改成功!");
});
} else {
_this.$modal.loading('提交中')
addIn(_this.formData).then((response) => {
_this.$modal.closeLoading();
_this.formData = response.data;
console.log(_this.formData);
_this.checkIsListed();
_this.$modal.msgSuccess("保存成功!");
});
}
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
/** 提交按钮 */
submit() {
const _this = this;
_this.formData.status = 2;
//判断明细是否都入库
if (
_this.formData.wmsProductInDetailList.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.formData.wmsProductInDetailList.map(item => {
// item.secondNumber = item.number;
// item.secondUnitId = item.unitId;
// return item
// })
_this.$modal.loading('提交中')
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.wmsProductInDetailList.forEach((item) => {
if (item.status == 0 || item.status == null) flag = false;
});
this.isAllListed = flag;
},
}
}
</script>
<style>
</style>

450
pages/wms/pdcIn/pdcSh.vue Normal file
View File

@@ -0,0 +1,450 @@
<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="productInTaskCode">
<uni-combox :candidates="productInTaskCodeList" emptyTips="无" @input="scanBarCode"
v-model="formData.productInTaskCode"></uni-combox>
</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 v-model="formData.warehouseCode" type="text" />
</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.wmsProductReceiveDetailList.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 :key="index"
v-for="(item, index) in formData.wmsProductReceiveDetailList"
@click="(data) => clickDetail(index,data)" :right-options="rightOptions">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="number" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="类型" :labelWidth='90'
name="'wmsProductReceiveDetailList.'+ 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-forms-item>
<uni-forms-item label="应收数量" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.theoryNumber'">
<uni-easyinput disabled type="number" v-model="item.theoryNumber" />
</uni-forms-item>
<uni-forms-item label="已收数量" :labelWidth='90' v-if="item.receivedNumber"
:name="'wmsProductReceiveDetailList.'+ index +'.receivedNumber'">
<uni-easyinput disabled type="number" v-model="item.receivedNumber" />
</uni-forms-item>
<uni-forms-item label="到货数量" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.arriveNumber'">
<u-number-box inputWidth="120" button-size="36" v-model="item.arriveNumber"
min="0"></u-number-box>
</uni-forms-item>
<uni-forms-item label="实收数量" :labelWidth='90'
:name="'wmsProductReceiveDetailList.'+ index +'.actualNumber'">
<u-number-box inputWidth="120" button-size="36" v-model="item.actualNumber"
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 {
addReceive,
listReceive,
getReceive,
listTask,
getTask,
getReceiveDetails,
listReceiveDetail,
updateReceiveDetail,
} from "@/api/wms/pdcIn.js";
import {
listMaterial
} from "@/api/wms/request.js";
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() {
//判断是否已收货
listReceiveDetail({
productInTaskDetailId: 846
}).then(res => {
console.log(res)
})
},
data() {
return {
isReceive: false,
value: '正常',
show: false,
materialLabel: null,
workOrderCode: null,
productInTaskCodeList: [],
formData: {
productInTaskCode: '',
drawBy: null,
warehouseCode: null,
wmsProductReceiveDetailList: [],
arriveTime: null,
},
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
productInTaskCode: {
rules: [{
required: true,
errorMessage: '请输入产品任务单!'
}]
},
actualNumber: {
rules: [{
required: true,
errorMessage: '请输入实收数量!'
}]
},
}
}
},
computed: {
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
methods: {
deleteDetail(index) {
this.formData.wmsProductReceiveDetailList.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) {
//判断是否已收货
listReceiveDetail({
productInTaskDetailId: data.id
}).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.productInTaskCode = data.productInTaskCode
// 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,
receivedNumber: num,
productInTaskDetailId: data.id,
type: res.data[0].type,
id: res.data[0].id
}
this.formData.wmsProductReceiveDetailList.push(obj);
this.isReceive = true;
this.materialLabel = null;
this.show = false;
}
} else {
// this.workOrderCode = data.pwoCode
getReceiveDetails({
productInTaskCode: data.productInTaskCode
}).then((res) => {
if (res.details.length > 0) {
this.formData = res.rcv;
this.formData.productInTaskCode = data.productInTaskCode
this.formData.wmsProductReceiveDetailList = []
this.formData.wmsProductReceiveDetailList.push(res.details
.find(item =>
item.productInTaskDetailId == data.id));
this.isReceive = false;
this.materialLabel = null;
this.show = false;
} else {
this.$modal.msg("任务单里未查到该条明细!")
}
});
// let obj = {
// materialCode: data.materialCode,
// materialName: data.materialName,
// materialBatchNo: data.materialBatchNo,
// theoryNumber: data.number,
// productInTaskDetailId: data.id,
// type: data.type
// }
// this.formData.wmsProductReceiveDetailList.push(obj);
}
})
}
},
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.productInTaskCodeList = [];
if (this.workOrderCode) {
listTask({
workOrderCode: this.workOrderCode
}).then(async response => {
for (var i = 0; i < response.rows.length; i++) {
this.productInTaskCodeList.push(response.rows[i].productInTaskCode);
}
});
}
},
selectTypeList() {
listTask().then(async res => {
// console.log(res);
for (var i in res.rows) {
this.productInTaskCodeList.push(res.rows[i].productInTaskCode);
}
// console.log(this.drawTaskCodeList)
});
},
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}`;
},
scanBarCode() {
if (this.formData.productInTaskCode) {
let data = {
productInTaskCode: this.formData.productInTaskCode
}
getReceiveDetails(this.formData).then(res => {
this.formData.wmsProductReceiveDetailList = res.details;
})
} else {
this.$modal.msg("请输入产品任务单!")
}
},
//产品任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.productInTaskCode = res.result;
_this.scanBarCode();
}
});
},
//签收员编码
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) {
_this.formData.wmsProductReceiveDetailList.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.wmsProductReceiveDetailList) {
if (_this.formData.wmsProductReceiveDetailList[i]
.actualNumber > _this.formData.wmsProductReceiveDetailList[
i].theoryNumber) {
_this.$modal.msg("实收数量超出应收数量,请检查!");
isNumOver = true;
}
}
if (isNumOver == false) {
_this.$modal.loading('提交中')
addReceive(_this.formData).then(async res => {
_this.$modal.msgSuccess("收货成功!");
_this.$modal.closeLoading();
setTimeout(() => {
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
}
} else {
let isNumOver = false;
for (var i in _this.formData.wmsProductReceiveDetailList) {
if (_this.formData.wmsProductReceiveDetailList[i]
.actualNumber > (_this.formData
.wmsProductReceiveDetailList[i].theoryNumber - _this
.formData.wmsProductReceiveDetailList[i].receivedNumber
)) {
_this.$modal.msg("实收数量超出应收数量,请检查!");
isNumOver = true;
}
}
if (isNumOver == false) {
console.log(_this.formData.wmsProductReceiveDetailList)
_this.formData.wmsProductReceiveDetailList[0].actualNumber +=
_this.formData.wmsProductReceiveDetailList[0]
.receivedNumber;
_this.formData.wmsProductReceiveDetailList[0].arriveNumber +=
_this.formData.wmsProductReceiveDetailList[0]
.receivedNumber;
_this.$modal.loading('提交中')
updateReceiveDetail(_this.formData.wmsProductReceiveDetailList[
0])
.then(async res => {
_this.$modal.msgSuccess("收货成功!");
_this.$modal.closeLoading();
setTimeout(() => {
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
}
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
}
}
</script>
<style>
</style>