feat(毛坯入库): 新增毛坯入库功能及相关组件
实现毛坯入库功能,包括: 1. 新增毛坯入库页面及路由配置 2. 添加毛坯相关API接口 3. 实现入库通用工具方法 4. 扩展PDA扫码组件支持毛坯扫码 5. 新增毛坯入库主页面及交互逻辑 6. 实现数量修改弹窗功能
This commit is contained in:
614
pages/blank/blankWarehousing/blankWarehousing.vue
Normal file
614
pages/blank/blankWarehousing/blankWarehousing.vue
Normal file
@@ -0,0 +1,614 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="title-box">
|
||||
<!-- <span class="title-text">毛坯入库(无箱,只填数量)</span> -->
|
||||
<view class="warehoseInfo-box">
|
||||
<!-- <view>
|
||||
仓库编号:{{ warehouseInfo.warehouse + ' ' + warehouseInfo.location }}
|
||||
<span></span>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="col">层号:{{ warehouseInfo.layer }}</view>
|
||||
<view class="col">货架:{{ warehouseInfo.shelf }}</view>
|
||||
</view> -->
|
||||
<view class="row">
|
||||
<span class="col">已扫货物数:{{ quantityTotal }}</span>
|
||||
<span class="col">已扫箱数:{{ newMaterialList.length }}</span>
|
||||
</view>
|
||||
<view>
|
||||
<!-- <view v-if="searchType === 1" class="color1 aciton-box">请扫仓库码</view> -->
|
||||
<view v-if="searchType === 5" class="color2 aciton-box">请扫箱码</view>
|
||||
<!-- <view v-if="searchType === 0" class="color2 aciton-box">请扫毛坯标签</view> -->
|
||||
<!-- 扫描操作 -->
|
||||
<view class="pda-search-box">
|
||||
<PdaScanInput @getInfo="handleGetInfo" :type="searchType" :warehouseInfo="warehouseInfo" :hasFocus="scanHasFocus"></PdaScanInput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上次批次号 -->
|
||||
<view class="last-batch-info">
|
||||
<view class="scroll-view-last" v-if="newMaterialList.length > 1">上次批次号:{{ newMaterialList[newMaterialList.length - 2].patchCode }}</view>
|
||||
<view class="scroll-view-last" v-if="newMaterialList.length <= 1">上次批次号:</view>
|
||||
</view>
|
||||
<!-- 货物列表 -->
|
||||
<view class="scroll-view-box">
|
||||
<view class="scroll-view-title">毛坯入库清单</view>
|
||||
<view class="scroll-view-content">
|
||||
<!-- 内联packageCard组件 -->
|
||||
<view v-for="(item, index) in newMaterialList" :key="index">
|
||||
<view class="package-card-box">
|
||||
<view class="package-card-header">
|
||||
<view class="package-card-title">毛坯号:{{ item.blankNumber }}</view>
|
||||
<view class="delete-btn" @click="handleDeleteItem(item)">×</view>
|
||||
</view>
|
||||
<view class="package-card-body">
|
||||
<view class="package-card-describe">
|
||||
<view>批次号:{{ item.patchCode }}</view>
|
||||
<view>总成号:{{ item.partNumner }}</view>
|
||||
<view>描述:{{ item.productionDescribe }}</view>
|
||||
</view>
|
||||
<view class="package-card-time">
|
||||
<view class="quantity-edit-container">
|
||||
<text class="package-card-quantity-label">数量:{{ item.quantity }}</text>
|
||||
</view>
|
||||
<view class="package-card-patch">生产批次</view>
|
||||
<view class="package-card-patch">{{ item.productionTime }}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="package-card-foot">
|
||||
<view class="edit-quantity-btn" @click="openQuantityModal(index)">修改数量</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部按钮 -->
|
||||
<view class="button-box">
|
||||
<u-button style="width: 40%" type="error" @click="clear" :disabled="loading" :loading="loading">全部重置</u-button>
|
||||
<u-button style="width: 40%" type="success" @click="handlerSubmit" :disabled="loading" :loading="loading">毛坯入库</u-button>
|
||||
</view>
|
||||
|
||||
<!-- 数量修改弹窗 -->
|
||||
<uni-popup ref="quantityModalRef" type="center">
|
||||
<view class="modal-content">
|
||||
<view class="modal-title">修改数量</view>
|
||||
<view class="modal-body">
|
||||
<text>当前数量:{{ currentItemIndex !== -1 ? newMaterialList[currentItemIndex].quantity : 0 }}</text>
|
||||
<input type="number" class="modal-input" v-model="newQuantity" placeholder="请输入新数量">
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<u-button type="default" @click="closeQuantityModal">取消</u-button>
|
||||
<u-button type="primary" @click="confirmUpdateQuantity">确认</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import materialItem from '@/components/material-item/material-item.vue';
|
||||
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
|
||||
import * as BlankApi from '@/api/blank/blank.js';
|
||||
import { showOperationConfirm, isRepeatPackage, isChangeBatch, clearRepeatPackages, debounce } from './utils.js';
|
||||
// 入库
|
||||
export default {
|
||||
components: {
|
||||
materialItem,
|
||||
uniPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 默认扫码模式
|
||||
defaultSearchType: 5,
|
||||
// 扫描框是否获取焦点
|
||||
scanHasFocus: true,
|
||||
// 入库模式(true严格追溯 false不严格不追溯)
|
||||
isStrict: false,
|
||||
loading: false,
|
||||
clearData: {},
|
||||
// 仓库信息
|
||||
warehouseInfo: {
|
||||
id: '',
|
||||
warehouse: '',
|
||||
warehouse_num: '',
|
||||
location: '',
|
||||
shelf: '',
|
||||
layer: '',
|
||||
number: 0
|
||||
},
|
||||
// 货物信息
|
||||
lastPackageInfo: {
|
||||
// 工单号
|
||||
workoderID: '',
|
||||
// 批次号(工单号+箱号+班组)
|
||||
patchCode: '',
|
||||
// 零件号
|
||||
partNumner: '',
|
||||
// 描述
|
||||
productionDescribe: '',
|
||||
// 出厂日期/生产日期
|
||||
productionTime: '',
|
||||
// 此箱数量
|
||||
quantity: 0
|
||||
},
|
||||
// 库位历史信息
|
||||
oldMaterialList: [],
|
||||
// 库位新录入货物信息
|
||||
newMaterialList: [],
|
||||
// 1-仓库扫码 2-货物扫码 0-直接扫码
|
||||
searchType: this.defaultSearchType,
|
||||
// 数量修改弹窗相关
|
||||
showQuantityModal: false,
|
||||
quantityModalRef:false,
|
||||
currentItemIndex: -1,
|
||||
newQuantity: 1
|
||||
};
|
||||
},
|
||||
watch: {},
|
||||
onLoad(e) {
|
||||
if (e.isStrict === 'true') {
|
||||
this.isStrict = true;
|
||||
} else {
|
||||
this.isStrict = false;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init();
|
||||
},
|
||||
computed: {
|
||||
quantityTotal() {
|
||||
let num = 0;
|
||||
for (let index = 0; index < this.newMaterialList.length; index++) {
|
||||
num += this.newMaterialList[index].quantity * 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
// 需要展示的参数:【零件号[物料号](35233201041) 描述(鲨鱼鳍) 箱号+班组(BNW240312023_18B1) 数量 时间 】
|
||||
// 初始化,并且清空数据
|
||||
this.clearData.warehouseInfo = JSON.parse(JSON.stringify(this.warehouseInfo));
|
||||
this.clearData.oldMaterialList = JSON.parse(JSON.stringify(this.oldMaterialList));
|
||||
this.clearData.newMaterialList = JSON.parse(JSON.stringify(this.newMaterialList));
|
||||
this.searchType = this.defaultSearchType;
|
||||
},
|
||||
clear() {
|
||||
uni.showModal({
|
||||
title: '确认重置',
|
||||
content: '确定要重置所有数据吗?',
|
||||
showCancel: true,
|
||||
cancelText: '取消',
|
||||
confirmText: '确认',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.warehouseInfo = JSON.parse(JSON.stringify(this.clearData.warehouseInfo));
|
||||
this.oldMaterialList = JSON.parse(JSON.stringify(this.clearData.oldMaterialList));
|
||||
this.newMaterialList = JSON.parse(JSON.stringify(this.clearData.newMaterialList));
|
||||
this.searchType = this.defaultSearchType;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
handleGetInfo(data, type) {
|
||||
if (type === 1) {
|
||||
// 预留扫仓库
|
||||
this.searchType = 2;
|
||||
this.warehouseInfo = data?.warehoseInfo;
|
||||
this.newMaterialList = [];
|
||||
this.loading = false;
|
||||
} else if (type === 5) {
|
||||
if (this.loading) {
|
||||
showOperationConfirm('提示', '请等待加载完成!', false);
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.newMaterialList.push(data);
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 删除货物项
|
||||
handleDeleteItem(item) {
|
||||
showOperationConfirm('删除提示', '是否从列表中删除此货物?', true).then((res) => {
|
||||
if (res.confirm) {
|
||||
const index = this.newMaterialList.findIndex((i) => i.originalCode === item.originalCode);
|
||||
if (index > -1) {
|
||||
this.newMaterialList.splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 打开数量修改弹窗
|
||||
openQuantityModal(index) {
|
||||
this.currentItemIndex = index;
|
||||
this.newQuantity = this.newMaterialList[index].quantity;
|
||||
this.$refs.quantityModalRef.open()
|
||||
this.scanHasFocus = false;
|
||||
},
|
||||
|
||||
// 关闭数量修改弹窗
|
||||
closeQuantityModal() {
|
||||
this.$refs.quantityModalRef.close()
|
||||
this.currentItemIndex = -1;
|
||||
this.scanHasFocus = true;
|
||||
},
|
||||
|
||||
// 确认修改数量
|
||||
confirmUpdateQuantity() {
|
||||
// 确保数量为正整数
|
||||
let value = parseInt(this.newQuantity);
|
||||
if (isNaN(value) || value < 1) {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
// 使用Vue的set方法确保响应式更新
|
||||
this.$set(this.newMaterialList, this.currentItemIndex, {
|
||||
...this.newMaterialList[this.currentItemIndex],
|
||||
quantity: value
|
||||
});
|
||||
|
||||
this.closeQuantityModal();
|
||||
},
|
||||
// 入库提交
|
||||
handlerSubmit() {
|
||||
if (this.newMaterialList.length === 0) {
|
||||
showOperationConfirm('提示', '无入库货物!', false);
|
||||
return;
|
||||
}
|
||||
// 箱重复提醒 this.isPackageRepeat()
|
||||
if (this.isPackageRepeat()) {
|
||||
showOperationConfirm('重复箱校验', '检测到存在重复箱,是否自动清除?', true).then((res) => {
|
||||
if (res.confirm) {
|
||||
this.clearRepeatPackage();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
showOperationConfirm('入库操作', '是否确认入库?', true).then((res) => {
|
||||
if (res.confirm) {
|
||||
this.loading = true;
|
||||
let _list = JSON.parse(JSON.stringify(this.newMaterialList));
|
||||
//入库参数
|
||||
const warehousingData = {
|
||||
isBack: 0,
|
||||
packageList: _list
|
||||
};
|
||||
// 优化防抖处理机制,使用更可靠的防抖函数
|
||||
const debouncedSubmit = (() => {
|
||||
let timeoutId;
|
||||
return () => {
|
||||
// 清除之前的定时器
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
// 设置新的定时器执行入库操作
|
||||
timeoutId = setTimeout(() => {
|
||||
BlankApi.PDABlankWarehousing(warehousingData)
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
if (res.data === 0 || !res.data) {
|
||||
showOperationConfirm('提示', '入库失败:' + res.msg, false);
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '入库成功!' + res.msg
|
||||
});
|
||||
this.loading = false;
|
||||
this.oldMaterialList = JSON.parse(JSON.stringify(this.clearData.oldMaterialList));
|
||||
this.newMaterialList = JSON.parse(JSON.stringify(this.clearData.newMaterialList));
|
||||
} else {
|
||||
showOperationConfirm('提示', '入库失败!', false);
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// 处理请求失败的情况,确保loading状态被重置
|
||||
//console.error('入库请求失败:', error);
|
||||
//showOperationConfirm('提示', '请求失败,请重试!', false);
|
||||
this.loading = false;
|
||||
});
|
||||
}, 1000); // 1秒防抖延迟
|
||||
};
|
||||
})();
|
||||
|
||||
// 调用防抖函数
|
||||
debouncedSubmit();
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
// 入库箱去重校验,数据是否有重复
|
||||
// 统一重复检查逻辑,使用Map提高查找效率
|
||||
isPackageRepeat() {
|
||||
let oldList = this.newMaterialList;
|
||||
let seen = new Map();
|
||||
for (let item of oldList) {
|
||||
if (seen.has(item.originalCode)) {
|
||||
return true;
|
||||
}
|
||||
seen.set(item.originalCode, true);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// 自动清除重复箱
|
||||
clearRepeatPackage() {
|
||||
let oldArray = this.newMaterialList;
|
||||
let newArray = [];
|
||||
let seen = new Map();
|
||||
let repeatPackage = [];
|
||||
oldArray.forEach((item) => {
|
||||
// 统一重复检查逻辑,使用originalCode作为唯一标识
|
||||
if (!seen.has(item.originalCode)) {
|
||||
seen.set(item.originalCode, true);
|
||||
newArray.push(item);
|
||||
} else {
|
||||
repeatPackage.push(item.patchCode);
|
||||
}
|
||||
});
|
||||
this.newMaterialList = newArray;
|
||||
// 增强用户交互提示信息
|
||||
showOperationConfirm(
|
||||
'重复箱清除',
|
||||
`检测到${repeatPackage.length}个重复箱,已自动清除。原箱数:${oldArray.length} 现箱数:${newArray.length} 重复箱:${repeatPackage.join(', ')}`,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
padding: 10px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title-box {
|
||||
font-size: 26px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.warehoseInfo-box {
|
||||
font-size: 20px;
|
||||
width: 94%;
|
||||
margin: 5px auto;
|
||||
padding: 5px;
|
||||
background-color: aliceblue;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.warehoseInfo-box .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.warehoseInfo-box .row .col {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.aciton-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.color1 {
|
||||
color: brown;
|
||||
}
|
||||
|
||||
.color2 {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.pda-search-box {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.list-box {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.scroll-view-title {
|
||||
font-size: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #151515;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.scroll-view-box {
|
||||
width: 94%;
|
||||
margin: 20px auto;
|
||||
padding: 10px;
|
||||
background-color: rgba(179, 179, 179, 0.7);
|
||||
border-radius: 5px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.scroll-view-content {
|
||||
/* 确保内容高度超过容器时可以滚动 */
|
||||
}
|
||||
|
||||
.last-batch-info {
|
||||
width: 94%;
|
||||
margin: 10px auto;
|
||||
padding: 5px;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.scroll-view-last {
|
||||
width: 100%;
|
||||
font-size: 18px;
|
||||
color: rgba(0, 9, 0, 0.7);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 8px;
|
||||
border-radius: 5px;
|
||||
background-color: white;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.button-box {
|
||||
width: 90%;
|
||||
margin: 20px auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
/* 内联packageCard样式 */
|
||||
.package-card-box {
|
||||
position: relative;
|
||||
padding: 10rpx;
|
||||
margin: 5rpx;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 10rpx;
|
||||
box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.package-card-header {
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.package-card-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #ff4d4f;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.package-card-body {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.package-card-foot{
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.package-card-describe {
|
||||
flex: 1.5;
|
||||
}
|
||||
|
||||
.package-card-describe view {
|
||||
margin-bottom: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.package-card-time {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.quantity-edit-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.package-card-quantity-label {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
.edit-quantity-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
background-color: #1989fa;
|
||||
color: white;
|
||||
border-radius: 5rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
|
||||
/* 弹窗样式 */
|
||||
.modal-content {
|
||||
/* width: 100%;
|
||||
max-width: 600rpx; */
|
||||
background-color: white;
|
||||
border-radius: 10rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.modal-input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
font-size: 32rpx;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5rpx;
|
||||
padding: 0 15rpx;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.modal-footer u-button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.package-card-patch {
|
||||
font-size: 38rpx;
|
||||
color: #333333;
|
||||
}
|
||||
</style>
|
||||
118
pages/blank/blankWarehousing/utils.js
Normal file
118
pages/blank/blankWarehousing/utils.js
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* 入库通用工具方法
|
||||
*/
|
||||
|
||||
/**
|
||||
* 显示操作确认模态框
|
||||
* @param {string} title - 标题
|
||||
* @param {string} content - 内容
|
||||
* @param {boolean} showCancel - 是否显示取消按钮
|
||||
* @returns {Promise} Promise对象
|
||||
*/
|
||||
export function showOperationConfirm(title, content, showCancel = true) {
|
||||
return new Promise((resolve) => {
|
||||
uni.showModal({
|
||||
title: title || '提示',
|
||||
content: content || '',
|
||||
showCancel: showCancel,
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: function(res) {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为重复箱
|
||||
* @param {Array} list - 箱子列表
|
||||
* @param {string} patchCode - 批次号
|
||||
* @returns {boolean} 是否重复
|
||||
*/
|
||||
export function isRepeatPackage(list, patchCode) {
|
||||
if (!list || list.length === 0) return false;
|
||||
|
||||
for (let item of list) {
|
||||
if (item.patchCode === patchCode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否更换了批次
|
||||
* @param {Array} list - 箱子列表
|
||||
* @param {string} productionTime - 批次时间
|
||||
* @returns {boolean} 是否更换批次
|
||||
*/
|
||||
export function isChangeBatch(list, productionTime) {
|
||||
if (!list || list.length === 0) return false;
|
||||
|
||||
const lastItem = list[list.length - 1];
|
||||
return lastItem.productionTime !== productionTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为重复箱(基于originalCode)
|
||||
* @param {Array} list - 箱子列表
|
||||
* @param {string} originalCode - 原始编码
|
||||
* @returns {boolean} 是否重复
|
||||
*/
|
||||
export function isRepeatPackageByCode(list, originalCode) {
|
||||
if (!list || list.length === 0) return false;
|
||||
|
||||
for (let item of list) {
|
||||
if (item.originalCode === originalCode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除重复箱
|
||||
* @param {Array} list - 箱子列表
|
||||
* @returns {Array} 清除重复后的列表和重复箱信息
|
||||
*/
|
||||
export function clearRepeatPackages(list) {
|
||||
let newArray = [];
|
||||
let seen = new Map();
|
||||
let repeatPackage = [];
|
||||
|
||||
list.forEach((item) => {
|
||||
if (!seen.has(item.originalCode)) {
|
||||
seen.set(item.originalCode, true);
|
||||
newArray.push(item);
|
||||
} else {
|
||||
repeatPackage.push(item.patchCode);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
clearedList: newArray,
|
||||
repeatPackages: repeatPackage
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 防抖函数
|
||||
* @param {Function} func - 要防抖的函数
|
||||
* @param {number} delay - 延迟时间(ms)
|
||||
* @returns {Function} 防抖后的函数
|
||||
*/
|
||||
export function debounce(func, delay) {
|
||||
let timeoutId;
|
||||
return function (...args) {
|
||||
// 清除之前的定时器
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
// 设置新的定时器
|
||||
timeoutId = setTimeout(() => {
|
||||
func.apply(this, args);
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
@@ -45,7 +45,7 @@ export default {
|
||||
{
|
||||
name: '毛坯入库',
|
||||
icon: 'inbound/rough-casting-inbound',
|
||||
url: '',
|
||||
url: '/pages/blank/blankWarehousing/blankWarehousing?isStrict=false',
|
||||
type: 1,
|
||||
index: 3
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user