You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2007 lines
51 KiB

<template>
<div class="pda-container">
<!-- 头部栏 -->
<div class="header-bar">
<div class="header-left" @click="$router.back()">
<i class="el-icon-arrow-left"></i>
<span>入库上架</span>
</div>
<div class="header-right" @click="$router.push({ path: '/' })">
首页
</div>
</div>
<!-- 入库单信息卡片 -->
<div class="material-info-card" v-if="inboundInfo.inboundNo">
<!-- 第一行入库单号 -->
<div class="card-row-first">
<div class="title-item">
<span class="title-label">入库单号</span>
<span class="title-value">{{ inboundInfo.inboundNo }}</span>
</div>
</div>
<!-- 第二行关联单号行号+ 标签张数物料总数右靠 -->
<div class="card-row-second">
<div class="card-row-left">
<div class="title-item">
<span class="title-label">关联单号</span>
<span class="title-value title-value-sm">{{ inboundInfo.relatedOrderNo || '-' }}</span>
</div>
<div class="title-item">
<span class="title-label">行号</span>
<span class="title-value title-value-sm">{{ inboundInfo.relatedOrderLineNo || '-' }}</span>
</div>
</div>
<div class="card-row-right">
<div class="detail-item">
<div class="detail-label">标签张数</div>
<div class="detail-value">
<span class="qualified">{{ inboundInfo.totalLabels || 0 }}</span>
</div>
</div>
<div class="detail-item">
<div class="detail-label">物料总数</div>
<div class="detail-value">
<span class="qualified">{{ inboundInfo.totalQty || 0 }}</span>
</div>
</div>
</div>
</div>
</div>
<!-- 物料输入区域 -->
<div class="input-section">
<!-- 物料信息输入区域 -->
<div class="material-input-grid">
<!-- 第一行物料编码需求数量入库数量批次号 -->
<div class="input-row-top">
<!-- 物料编码 -->
<div class="input-item material-code-item">
<span class="input-label">物料编码</span>
<el-select
v-model="materialCode"
placeholder="请选择物料"
filterable
@change="handleMaterialSelect"
ref="materialSelect"
class="input-field"
>
<el-option
v-for="item in materialOptions"
:key="item.materialCode"
:label="item.materialCode"
:value="item.materialCode"
>
<span style="float: left">{{ item.materialCode }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.materialName }}</span>
</el-option>
</el-select>
</div>
<!-- 需求数量 -->
<div class="input-item required-qty-item">
<span class="input-label">需求数量</span>
<el-input
v-model="currentMaterial.requiredQty"
disabled
class="input-field"
/>
</div>
<!-- 入库数量 -->
<div class="input-item quantity-item">
<span class="input-label">入库数量</span>
<el-input class="inlineNumber numInput" v-model="actualQty" placeholder="入库数量" type="number" @keyup.enter.native="handleAddMaterial" clearable/>
</div>
<!-- 批次号 -->
<div class="input-item batch-item">
<span class="input-label">批次号</span>
<el-input class="inlineNumber numInput" v-model="batchNo" placeholder="*" @keyup.enter.native="handleAddMaterial" ref="batchInput" clearable/>
</div>
</div>
<!-- 第二行:单位(左)+ 物料名称 -->
<div class="input-row-bottom">
<div class="input-item unit-item-bottom">
<span class="input-label">单位</span>
<el-input
v-model="currentMaterial.unit"
disabled
class="input-field"
/>
</div>
<div class="field-area material-name-area">
<div class="field-title">物料名称</div>
<div class="info-box">{{ currentMaterial.materialName }}</div>
</div>
</div>
</div>
<!-- 添加物料按钮 -->
<div class="add-material-section">
<button class="add-material-btn" @click="handleAddMaterial">
<i class="el-icon-plus"></i>
<span>添加物料</span>
</button>
</div>
</div>
<!-- 入库信息确认标题 -->
<div class="section-title">
<div class="title-left">
<i class="el-icon-circle-check"></i>
<span>入库信息确认</span>
</div>
<div class="title-right">
<span class="material-list-link" @click="showMaterialListDialog">物料清单</span>
</div>
</div>
<!-- 物料列表 -->
<div class="label-list">
<div class="list-header">
<div class="col-no">NO.</div>
<div class="col-label">标签条码</div>
<div class="col-part">物料编码</div>
<div class="col-batch">批次号</div>
<div class="col-qty">标签数量</div>
</div>
<div class="list-body">
<!-- 左滑删除容器 -->
<div
v-for="(item, index) in materialList"
:key="item.id"
class="swipe-item-wrapper"
>
<!-- 可滑动的内容区域 -->
<div
class="swipe-content"
:style="{
transform: item.swipeOffset ? `translateX(${item.swipeOffset}px)` : 'translateX(0)',
transition: item.isAnimating ? 'transform 0.3s ease' : 'none'
}"
@touchstart="handleTouchStart($event, item, index)"
@touchmove="handleTouchMove($event, item)"
@touchend="handleTouchEnd($event, item)"
>
<div class="list-item">
<div class="col-no">{{ materialList.length - index }}</div>
<div class="col-label">{{ item.labelCode }}</div>
<div class="col-part">{{ item.materialCode }}</div>
<div class="col-batch">{{ item.batchNo || '-' }}</div>
<div class="col-qty">{{ item.actualQty }}</div>
</div>
</div>
<!-- 删除按钮(隐藏在右侧) -->
<div class="delete-action" @click="handleDeleteItem(item, index)">
<i class="el-icon-delete"></i>
</div>
</div>
<!-- 空状态 -->
<div v-if="materialList.length === 0" class="empty-labels">
<p>暂无入库物料</p>
</div>
</div>
</div>
<!-- 底部操作按钮 -->
<div class="bottom-actions">
<button class="action-btn secondary" @click="confirmInbound">
确定
</button>
<button class="action-btn secondary" @click="cancelInbound">
取消
</button>
</div>
<!-- 库位号输入覆盖层 -->
<div v-if="showLocationDialog" class="location-overlay">
<div class="location-modal">
<div class="modal-header">
<span class="modal-title">扫描库位号</span>
</div>
<div class="modal-body">
<div class="location-input-section">
<div class="input-wrapper">
<i class="el-icon-location-outline input-icon"></i>
<input
v-model="locationCode"
placeholder="请扫描库位号"
ref="locationInput"
class="location-input"
/>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn-cancel" @click="cancelLocationInput">取消</button>
<button class="btn-confirm" @click="submitInbound" :disabled="!locationCode.trim()">
确认上架
</button>
</div>
</div>
</div>
<!-- 物料清单弹窗 -->
<div v-if="showMaterialDialog" class="material-overlay">
<div class="material-modal">
<div class="modal-header">
<span class="modal-title">物料清单</span>
<i class="el-icon-close close-btn" @click="closeMaterialDialog"></i>
</div>
<div class="modal-body">
<!-- 加载状态 -->
<div v-if="materialListLoading" class="loading-container">
<i class="el-icon-loading"></i>
<span>加载中...</span>
</div>
<!-- 物料表格 -->
<div v-else-if="originalMaterialList.length > 0" class="material-table">
<div class="table-header">
<div class="col-no">NO.</div>
<div class="col-material-code">物料编码</div>
<div class="col-part-name">物料名称</div>
<div class="col-required-qty">需求数量</div>
<div class="col-available-qty">可用数量</div>
<div class="col-scans-qty">扫描数量</div>
</div>
<div class="table-body">
<div
v-for="(item, index) in originalMaterialList"
:key="index"
class="table-row"
>
<div class="col-no">{{ index + 1 }}</div>
<div class="col-material-code clickable-part" @click="showStockDialogFn(item)">{{ item.materialCode || item.partNo }}</div>
<div class="col-part-name">
<span class="part-name-text" @click.stop="showPartNameTip(item.materialName, $event)">{{ item.materialName || '-' }}</span>
</div>
<div class="col-required-qty">{{ item.requiredQty || 0 }}</div>
<div class="col-available-qty">{{ item.pickedQty || 0 }}</div>
<div class="col-scans-qty">{{ item.scansQty || 0 }}</div>
</div>
</div>
</div>
<!-- 空数据状态 -->
<div v-else class="empty-material">
<i class="el-icon-document"></i>
<p>暂无物料数据</p>
</div>
</div>
<div class="modal-footer">
<button class="btn-close" @click="closeMaterialDialog">关闭</button>
</div>
</div>
<!-- 物料名称提示框 -->
<div v-if="showPartNameTooltip" class="part-name-tooltip" :style="tooltipStyle" @click.stop>
<div class="tooltip-content">{{ currentPartName }}</div>
</div>
</div>
<!-- 可用库存弹窗 -->
<div v-if="showStockDialog" class="stock-overlay">
<div class="stock-modal">
<div class="modal-header">
<span class="modal-title">可用库存 - {{ currentPartNo }}</span>
<i class="el-icon-close close-btn" @click="closeStockDialog"></i>
</div>
<div class="modal-body">
<div v-if="stockLoading" class="loading-container"><i class="el-icon-loading"></i><span>加载中...</span></div>
<div v-else-if="stockList.length > 0" class="stock-table">
<div class="table-header">
<div class="col-roll-no">标签条码</div>
<div class="col-qty">数量</div>
<div class="col-location">库位</div>
<div class="col-batch">合约号码</div>
<div class="col-date">入库天数</div>
</div>
<div class="table-body">
<div v-for="(item, index) in stockList" :key="index" class="table-row">
<div class="col-roll-no">{{ item.rollNo }}</div>
<div class="col-qty">{{ item.rollQty }} <span class="unit-text">{{ item.um }}</span></div>
<div class="col-location">{{ item.location }}</div>
<div class="col-batch">{{ item.batchNo }}</div>
<div class="col-date">{{ item.daysInStock }}</div>
</div>
</div>
</div>
<div v-else class="empty-stock"><i class="el-icon-box"></i><p>暂无可用库存</p></div>
</div>
<div class="modal-footer"><button class="btn-close" @click="closeStockDialog">关闭</button></div>
</div>
</div>
</div>
</template>
<script>
import { getOtherInboundDetails, getMaterialList, validateLabelWithOtherInbound, confirmOtherInbound, getScannedLabelList, getUserDefaultPrinter } from "@/api/other-inbound/other-inbound.js";
import { getInventoryStock } from "@/api/inbound.js";
import { getCurrentWarehouse } from '@/utils'
import moment from 'moment';
import getLodop from '@/utils/LodopFuncs.js';
import labelPrintTemplates from '@/mixins/labelPrintTemplates.js';
export default {
mixins: [labelPrintTemplates],
data() {
return {
materialCode: '',
actualQty: '',
batchNo: '*',
inboundInfo: {},
materialList: [],
originalMaterialList: [],
materialOptions: [], // 物料下拉选项
currentMaterial: {},
inboundNo: '',
buNo: '',
showMaterialDialog: false,
materialListLoading: false,
showStockDialog: false,
stockList: [],
stockLoading: false,
currentPartNo: '',
showLocationDialog: false,
locationCode: '',
// 左滑删除相关
touchStartX: 0,
touchStartY: 0,
deleteButtonWidth: 80, // 删除按钮宽度
// 物料名称提示框相关
showPartNameTooltip: false,
currentPartName: '',
tooltipStyle: { top: '0px', left: '0px' },
relatedOrderNo: ''
};
},
methods: {
formatDate(date) {
return date ? moment(date).format('YYYY-MM-DD') : '';
},
// ==================== 左滑删除功能 ====================
// 触摸开始
handleTouchStart(event, item, index) {
this.touchStartX = event.touches[0].clientX;
this.touchStartY = event.touches[0].clientY;
// 关闭其他已打开的项
this.materialList.forEach((material, idx) => {
if (idx !== index && material.swipeOffset) {
this.$set(material, 'isAnimating', true);
this.$set(material, 'swipeOffset', 0);
}
});
this.$set(item, 'isAnimating', false);
},
// 触摸移动
handleTouchMove(event, item) {
const touchCurrentX = event.touches[0].clientX;
const touchCurrentY = event.touches[0].clientY;
const deltaX = touchCurrentX - this.touchStartX;
const deltaY = touchCurrentY - this.touchStartY;
// 如果垂直滑动距离大于水平滑动,则认为是滚动操作,不处理左滑
if (Math.abs(deltaY) > Math.abs(deltaX)) {
return;
}
// 阻止默认的滚动行为
if (Math.abs(deltaX) > 10) {
event.preventDefault();
}
// 只允许向左滑动
if (deltaX < 0) {
const offset = Math.max(deltaX, -this.deleteButtonWidth);
this.$set(item, 'swipeOffset', offset);
} else if (item.swipeOffset) {
// 如果已经打开,允许向右滑动关闭
const offset = Math.min(deltaX + (item.swipeOffset || 0), 0);
this.$set(item, 'swipeOffset', offset);
}
},
// 触摸结束
handleTouchEnd(event, item) {
const currentOffset = item.swipeOffset || 0;
this.$set(item, 'isAnimating', true);
// 如果滑动距离超过删除按钮宽度的一半,则完全展开,否则收回
if (currentOffset < -this.deleteButtonWidth / 2) {
this.$set(item, 'swipeOffset', -this.deleteButtonWidth);
} else {
this.$set(item, 'swipeOffset', 0);
}
},
// 删除物料项
handleDeleteItem(item, index) {
this.$confirm('确定要删除该物料吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 调用存储过程删除(operationType: 'D')
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
materialCode: item.materialCode,
labelCode: item.labelCode,
actualQty: item.actualQty,
batchNo: item.batchNo,
warehouseId: getCurrentWarehouse(),
operationType: 'D', // D表示删除
documentType: '其他入库'
};
validateLabelWithOtherInbound(params).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('删除成功');
// 重新加载已扫描标签列表
this.loadScannedLabelList();
} else {
this.$message.error(data.msg || '删除失败');
}
}).catch(error => {
console.error('删除物料失败:', error);
this.$message.error('删除失败');
});
}).catch(() => {
// 用户取消删除,收回滑动
this.$set(item, 'isAnimating', true);
this.$set(item, 'swipeOffset', 0);
});
},
// ==================== 原有功能 ====================
// 处理物料选择
handleMaterialSelect() {
if (!this.materialCode) {
this.currentMaterial = {};
return;
}
// 从选项中找到对应的物料信息
const material = this.materialOptions.find(m => m.materialCode === this.materialCode);
if (material) {
this.currentMaterial = {
materialCode: material.materialCode,
materialName: material.materialName,
unit: material.unit,
requiredQty: material.requiredQty
};
}
},
// 加载物料选项(从入库明细获取)
loadMaterialOptions() {
if (!this.inboundInfo.site || !this.inboundInfo.buNo || !this.inboundNo) {
return;
}
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
documentType: '其他入库', // 单据类型
warehouseId: getCurrentWarehouse(), // 当前仓库
relatedOrderNo: this.relatedOrderNo
}
getMaterialList(params).then(({ data }) => {
if (data && data.code === 0) {
this.materialOptions = (data.data || []).map(item => ({
materialCode: item.materialCode,
materialName: item.materialName,
unit: item.unit,
requiredQty: item.requiredQty
}));
} else {
console.error('获取物料选项失败:', data.msg);
this.materialOptions = [];
}
}).catch(error => {
console.error('获取物料选项失败:', error);
this.materialOptions = [];
});
},
// 添加物料到列表(通过存储过程GetScanLabelVerification)
handleAddMaterial() {
if (!this.materialCode.trim()) {
this.$message.warning('请选择物料编码');
return;
}
if (!this.actualQty || this.actualQty <= 0) {
this.$message.warning('请输入有效的入库数量');
return;
}
if (!this.batchNo.trim()) {
this.$message.warning('请输入批次号');
this.$refs.batchInput.focus();
return;
}
// 调用存储过程GetScanLabelVerification
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
materialCode: this.materialCode.trim(),
actualQty: parseFloat(this.actualQty),
batchNo: this.batchNo.trim(),
warehouseId: getCurrentWarehouse(),
operationType: 'I', // I表示添加
documentType: '其他入库', // 单据类型
relatedOrderNo: this.inboundInfo.relatedOrderNo,
relatedOrderLineNo: this.inboundInfo.relatedOrderLineNo
};
validateLabelWithOtherInbound(params).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('操作成功');
// 重新加载已扫描标签列表
this.loadScannedLabelList();
// 清空输入
this.materialCode = '';
this.actualQty = '';
this.batchNo = '*';
this.currentMaterial = {};
} else {
this.$message.error(data.msg || '操作失败');
}
}).catch(error => {
console.error('添加物料失败:', error);
this.$message.error('操作失败');
});
},
// 确认入库
confirmInbound() {
if (this.materialList.length === 0) {
this.$message.warning('请先添加入库物料');
return;
}
// 显示库位号输入对话框
this.showLocationDialog = true;
this.locationCode = '';
// 聚焦到库位号输入框
this.$nextTick(() => {
if (this.$refs.locationInput) {
this.$refs.locationInput.focus();
}
});
},
// 取消库位号输入
cancelLocationInput() {
this.showLocationDialog = false;
this.locationCode = '';
},
// 提交入库(通过存储过程GetSaveLabelVerification)
async submitInbound() {
if (!this.locationCode.trim()) {
this.$message.warning('请输入库位号');
return;
}
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
locationCode: this.locationCode.trim(),
documentType: '其他入库', // 单据类型
relatedOrderNo: this.inboundInfo.relatedOrderNo,
relatedOrderLineNo: this.inboundInfo.relatedOrderLineNo
}
try {
const { data } = await confirmOtherInbound(params);
if (data && data.code === 0) {
this.$message.success('入库成功');
this.showLocationDialog = false;
// 自动打印标签
const printList = data.printList || [];
if (printList.length > 0) {
await this.printLabelsWithTemplate(printList);
}
this.$router.back();
} else {
this.$message.error(data.msg || '入库失败');
}
} catch (error) {
console.error('入库失败:', error);
this.$message.error('入库失败');
}
},
/**
* 获取当前用户配置的默认打印机
* @param {String} labelNo - 标签模板编号(A001/A002/A003)
* @returns {Object} 打印机配置 {printerName, printerIp}
*/
async fetchUserDefaultPrinter(labelNo) {
try {
const params = {
userName: localStorage.getItem('userName'),
labelNo: labelNo || ''
};
const { data } = await getUserDefaultPrinter(params);
if (data && data.code === 0 && data.printerName) {
return {
printerName: data.printerName,
printerIp: data.printerIp,
labelNo: data.labelNo
};
}
return null;
} catch (error) {
console.error('获取用户打印机配置失败:', error);
return null;
}
},
/**
* 使用模板打印标签
* @param {Array} printList - 打印数据列表(存储过程UspPartLabelTemplate返回)
*/
async printLabelsWithTemplate(printList) {
try {
// 1. 获取 LODOP 打印控件
const LODOP = getLodop();
if (!LODOP) {
console.warn('无法连接到打印控件,跳过打印');
this.$message.warning('无法连接到打印控件,请确保已安装并启动打印服务');
return;
}
// 2. 检测打印机数量
const printerCount = LODOP.GET_PRINTER_COUNT();
if (printerCount === 0) {
console.warn('未检测到打印机,跳过打印');
this.$message.warning('未检测到打印机,请检查打印机连接');
return;
}
// 3. 获取用户配置的默认打印机
// 使用第一个标签的 labelNo 来查询打印机配置
const firstLabelNo = printList.length > 0 ? printList[0].labelNo : '';
const printerConfig = await this.fetchUserDefaultPrinter(firstLabelNo);
let printerName = null;
if (printerConfig && printerConfig.printerName) {
printerName = printerConfig.printerName;
console.log('使用用户配置的打印机:', printerName);
} else {
console.warn('未找到用户打印机配置,跳过打印');
this.$message.warning('未配置用户打印机,请在系统中配置默认打印机后再打印');
return;
}
// 4. 执行打印
await this.executePrintWithTemplate(LODOP, printList, printerName);
this.$message.success('标签打印任务已发送!');
} catch (error) {
console.error('模板打印失败:', error);
this.$message.warning('标签打印失败,请手动打印');
}
},
/**
* 执行模板打印
* @param {Object} LODOP - 打印控件对象
* @param {Array} printDataList - 打印数据列表
* @param {String} printerName - 用户配置的打印机名称(可选)
*/
async executePrintWithTemplate(LODOP, printDataList, printerName) {
console.log('开始打印,标签数量:', printDataList.length, '打印机:', printerName || '默认', '标签数据:', printDataList);
// 循环打印每个标签(每个标签单独打印一次)
for (let i = 0; i < printDataList.length; i++) {
const printData = printDataList[i];
// 获取标签模板编号(存储过程返回)
const labelNo = printData.labelNo;
// 每个标签单独初始化一个打印任务
LODOP.PRINT_INIT('其他入库标签打印_' + (i + 1));
// 设置用户配置的打印机(如果有)
if (printerName) {
LODOP.SET_PRINTER_INDEX(printerName);
}
// 设置打印模式
LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE", true);
// 根据 labelNo 调用不同的打印方法(来自 labelPrintTemplates mixin)
// 注意:不需要 NEWPAGE,因为每个标签是独立的打印任务
if (labelNo === 'A001') {
await this.printLabelA001(LODOP, printData, false);
} else if (labelNo === 'A002') {
this.printLabelA002(LODOP, printData, false);
} else if (labelNo === 'A003') {
this.printLabelA003(LODOP, printData, false);
} else if (labelNo === 'A004') {
this.printLabelA004(LODOP, printData, false);
}
// 执行打印
//LODOP.PREVIEW();
LODOP.PRINT();
console.log(`${i + 1}张标签已发送打印, 打印机: ${printerName || '默认'}, 标签条码: ${printData.rollNo}`);
}
},
// 取消入库
cancelInbound() {
if (this.materialList.length > 0) {
this.$confirm('取消后将清空已添加的物料,确定取消吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '继续操作',
type: 'warning'
}).then(() => {
this.$router.back();
}).catch(() => {
// 用户选择继续操作
});
} else {
this.$router.back();
}
},
// 显示物料清单弹窗
showMaterialListDialog() {
this.showMaterialDialog = true;
this.loadOriginalMaterialList();
},
// 加载原始物料清单
loadOriginalMaterialList() {
if (!this.inboundInfo.site || !this.inboundInfo.buNo || !this.inboundNo) {
this.$message.error('缺少必要参数,无法获取物料清单');
return;
}
this.materialListLoading = true;
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
warehouseId: getCurrentWarehouse() // 当前仓库
};
getMaterialList(params).then(({ data }) => {
this.materialListLoading = false;
if (data && data.code === 0) {
this.originalMaterialList = data.data || [];
} else {
this.$message.error(data.msg || '获取物料清单失败');
this.originalMaterialList = [];
}
}).catch(error => {
this.materialListLoading = false;
console.error('获取物料清单失败:', error);
this.$message.error('获取物料清单失败');
this.originalMaterialList = [];
});
},
// 关闭物料清单弹窗
closeMaterialDialog() {
this.showMaterialDialog = false;
this.hidePartNameTip();
},
// 显示物料名称提示框
showPartNameTip(partName, event) {
if (!partName || partName === '-') return;
const rect = event.target.getBoundingClientRect();
this.tooltipStyle = { top: (rect.top - 5) + 'px', left: rect.left + 'px' };
this.currentPartName = partName;
this.showPartNameTooltip = true;
setTimeout(() => { document.addEventListener('click', this.hidePartNameTip); }, 0);
},
// 隐藏物料名称提示框
hidePartNameTip() {
this.showPartNameTooltip = false;
this.currentPartName = '';
document.removeEventListener('click', this.hidePartNameTip);
},
showStockDialogFn(item) {
this.currentPartNo = item.materialCode || item.partNo;
this.showStockDialog = true;
this.loadInventoryStock(this.currentPartNo);
},
loadInventoryStock(partNo) {
this.stockLoading = true;
const params = {
site: this.inboundInfo.site,
notifyNo: this.inboundNo,
notifyType: '其他入库',
orderNo: '',
orderLineNo: '',
partNo: partNo,
warehouseId: localStorage.getItem('warehouseId') || ''
};
getInventoryStock(params).then(({ data }) => {
this.stockLoading = false;
if (data && data.code === 0) { this.stockList = data.data || []; }
else { this.$message.error(data.msg || '获取可用库存失败'); this.stockList = []; }
}).catch(error => { this.stockLoading = false; this.$message.error('获取可用库存失败'); this.stockList = []; });
},
closeStockDialog() {
this.showStockDialog = false;
this.stockList = [];
this.currentPartNo = '';
},
// 加载入库单详情
loadInboundDetails() {
const params = {
inboundNo: this.inboundNo,
buNo: this.buNo,
warehouseId: getCurrentWarehouse(),
site: localStorage.getItem('site'),
relatedOrderNo: this.relatedOrderNo
};
getOtherInboundDetails(params).then(({ data }) => {
if (data && data.code === 0) {
this.inboundInfo = data.data;
// 加载入库单详情成功后,加载物料选项和已扫描标签列表
this.loadMaterialOptions();
this.loadScannedLabelList();
} else {
this.$message.error(data.msg || '获取入库单详情失败');
}
}).catch(error => {
console.error('获取入库单详情失败:', error);
this.$message.error('获取入库单详情失败');
});
},
// 加载已扫描标签列表(从ScannedRollTempTable缓存表)
loadScannedLabelList() {
if (!this.inboundInfo.site || !this.inboundInfo.buNo || !this.inboundNo) {
return;
}
const params = {
site: this.inboundInfo.site,
buNo: this.inboundInfo.buNo,
inboundNo: this.inboundNo,
documentType: '其他入库' // 单据类型
};
getScannedLabelList(params).then(({ data }) => {
if (data && data.code === 0) {
// 将查询结果转换为materialList格式
this.materialList = (data.data || []).map((item, index) => ({
id: Date.now() + index,
labelCode: item.labelCode,
materialCode: item.materialCode,
actualQty: item.actualQty,
batchNo: item.batchNo,
swipeOffset: 0, // 左滑偏移量
isAnimating: false // 是否正在动画
}));
// 更新入库信息卡片的统计数据
this.inboundInfo.totalLabels = this.materialList.length;
this.inboundInfo.totalQty = this.materialList.reduce((sum, item) => sum + parseFloat(item.actualQty || 0), 0);
} else {
console.error('获取已扫描标签列表失败:', data.msg);
}
}).catch(error => {
console.error('获取已扫描标签列表失败:', error);
});
}
},
mounted() {
// 获取路由参数
this.inboundNo = this.$route.params.inboundNo;
this.buNo = this.$route.params.buNo;
this.relatedOrderNo = this.$route.params.relatedOrderNo;
if (!this.inboundNo || !this.buNo) {
this.$message.error('参数错误');
this.$router.back();
return;
}
// 初始化字段
this.materialCode = '';
this.actualQty = '';
this.batchNo = '*';
// 加载入库单详情
this.loadInboundDetails();
}
};
</script>
<style scoped>
/* 复用其他出库的样式,保持一致性 */
.pda-container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
background: #f5f5f5;
overflow-y: auto;
}
/* 头部栏 */
.header-bar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 16px;
background: #17B3A3;
color: white;
height: 40px;
min-height: 40px;
}
.header-left {
display: flex;
align-items: center;
cursor: pointer;
font-size: 16px;
font-weight: 500;
}
.header-left i {
margin-right: 8px;
font-size: 18px;
}
.header-right {
cursor: pointer;
font-size: 16px;
font-weight: 500;
}
/* 物料信息卡片 */
.material-info-card {
background: white;
margin: 4px 16px;
padding: 6px 20px;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #f0f0f0;
}
/* 卡片第一行:入库单号 */
.card-row-first {
margin-bottom: 8px;
}
/* 卡片第二行:关联单号+行号(左) + 标签张数+物料总数(右) */
.card-row-second {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 8px;
}
.card-row-left {
display: flex;
gap: 12px;
align-items: flex-end;
flex: 1;
min-width: 0;
}
.card-row-left .title-item {
flex: 1;
}
.card-row-right {
display: flex;
gap: 10px;
align-items: flex-end;
flex-shrink: 0;
}
.title-item {
display: flex;
flex-direction: column;
min-width: 0;
}
.title-label {
font-size: 11px;
color: #999;
margin-bottom: 4px;
white-space: nowrap;
}
.title-value {
font-size: 15px;
font-weight: bold;
color: #333;
word-break: break-all;
}
.title-value-sm {
font-size: 13px;
font-weight: 600;
}
.detail-item {
text-align: center;
}
.detail-label {
font-size: 11px;
color: #999;
margin-bottom: 4px;
font-weight: normal;
line-height: 1.2;
white-space: nowrap;
}
.detail-value {
font-size: 13px;
color: #333;
font-weight: 500;
line-height: 1.2;
}
.detail-value .qualified {
color: #17B3A3;
font-weight: 500;
}
.detail-value .total {
color: #333;
font-weight: 500;
}
.detail-value .total::before {
content: '/';
color: #333;
}
/* 物料输入区域 */
.input-section {
background: white;
margin: 8px 16px;
padding: 12px 16px 16px;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
border: 1px solid #f0f0f0;
}
/* 物料信息网格布局 */
.material-input-grid {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 12px;
}
/* 第一行:物料编码、需求数量、入库数量、批次号 */
.input-row-top {
display: flex;
align-items: flex-end;
gap: 10px;
}
/* 第二行:单位(左)+ 物料名称 */
.input-row-bottom {
display: flex;
align-items: flex-end;
gap: 10px;
width: 100%;
margin-top: 2px;
}
.input-item {
display: flex;
flex-direction: column;
flex: 1;
}
.material-code-item {
flex: 1.6;
}
.required-qty-item {
flex: 1;
min-width: 60px;
}
.quantity-item {
flex: 1;
}
.batch-item {
flex: 1;
}
/* 第二行单位:固定小宽度,居左 */
.unit-item-bottom {
display: flex;
flex-direction: column;
flex: 0 0 64px;
width: 64px;
}
.material-name-area {
flex: 1;
min-width: 0;
}
.input-label {
font-size: 13px;
color: #666;
margin-bottom: 6px;
text-align: left;
font-weight: 500;
line-height: 1.2;
}
.input-field {
width: 100%;
}
.input-field ::v-deep .el-input__inner {
font-size: 13px;
padding: 0 10px;
border: 1px solid #17B3A3;
border-radius: 6px;
height: 44px;
text-align: center;
font-weight: 500;
}
/* disabled状态的输入框样式 */
.input-field ::v-deep .el-input__inner[disabled] {
background-color: #f5f7fa;
border-color: #d0d4d9;
color: #333;
cursor: not-allowed;
}
/* 添加物料按钮区域 */
.add-material-section {
display: flex;
justify-content: center;
padding-top: 4px;
}
.add-material-btn {
background: linear-gradient(135deg, #17B3A3 0%, #0d8f7f 100%);
color: white;
border: none;
border-radius: 5px;
padding: 6px 14px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 5px;
font-size: 13px;
font-weight: 600;
transition: all 0.3s ease;
min-width: 90px;
box-shadow: 0 2px 6px rgba(23, 179, 163, 0.2);
letter-spacing: 0.2px;
}
.add-material-btn:hover {
background: linear-gradient(135deg, #0d8f7f 0%, #17B3A3 100%);
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(23, 179, 163, 0.35);
}
.add-material-btn:active {
transform: translateY(0);
box-shadow: 0 3px 8px rgba(23, 179, 163, 0.3);
}
.add-material-btn i {
font-size: 14px;
font-weight: bold;
}
.field-area {
margin-bottom: 0;
}
.field-title {
font-size: 13px;
color: #666;
margin-bottom: 6px;
font-weight: 500;
text-align: left;
line-height: 1.2;
}
.field-input {
width: 100%;
}
.field-input ::v-deep .el-input__inner {
font-size: 13px;
padding: 0 10px;
border: 1px solid #dcdfe6;
border-radius: 6px;
height: 44px;
}
.info-box {
background: #f5f7fa;
padding: 0 10px;
border-radius: 6px;
font-size: 13px;
color: #333;
height: 44px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #d0d4d9;
font-weight: 500;
line-height: 1.2;
text-align: center;
}
/* 物料名称信息框 - 与其他输入框等高 */
.material-name-area .info-box {
height: 44px;
padding: 0 12px;
justify-content: flex-start;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.numInput ::v-deep .el-input__inner {
font-size: 13px;
padding: 0 10px;
border: 1px solid #17B3A3;
border-radius: 6px;
height: 44px;
text-align: center;
font-weight: 500;
}
/* 区域标题 */
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
background: white;
margin: 0 16px;
margin-top: 4px;
border-radius: 8px 8px 0 0;
border-bottom: 2px solid #17B3A3;
}
.title-left {
display: flex;
align-items: center;
}
.title-left i {
color: #17B3A3;
font-size: 16px;
margin-right: 8px;
}
.title-left span {
color: #17B3A3;
font-size: 14px;
font-weight: 500;
}
/* 物料列表 */
.label-list {
background: white;
margin: 0 16px 12px;
border-radius: 0 0 8px 8px;
overflow: hidden;
flex: 1;
display: flex;
flex-direction: column;
max-height: 300px;
}
.label-list .list-body {
flex: 1;
overflow-y: auto;
max-height: 250px;
}
.label-list .list-body::-webkit-scrollbar {
width: 4px;
}
.label-list .list-body::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 2px;
}
.label-list .list-body::-webkit-scrollbar-thumb {
background: #17B3A3;
border-radius: 2px;
}
.label-list .list-body::-webkit-scrollbar-thumb:hover {
background: #0d8f7f;
}
/* 左滑删除容器 */
.swipe-item-wrapper {
position: relative;
overflow: hidden;
background: white;
}
/* 可滑动的内容区域 */
.swipe-content {
position: relative;
z-index: 2;
background: white;
touch-action: pan-y; /* 允许垂直滚动 */
}
/* 删除按钮(隐藏在右侧) */
.delete-action {
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: 80px;
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: white;
cursor: pointer;
z-index: 1;
transition: background 0.2s ease;
}
.delete-action:active {
background: linear-gradient(135deg, #ee5a52 0%, #ff6b6b 100%);
}
.delete-action i {
font-size: 20px;
margin-bottom: 4px;
}
.delete-action span {
font-size: 12px;
font-weight: 500;
}
.list-header {
display: flex;
background: #f8f9fa;
padding: 12px 8px;
border-bottom: 1px solid #e0e0e0;
font-size: 12px;
color: #666;
font-weight: 500;
}
.list-item {
display: flex;
padding: 12px 8px;
border-bottom: 1px solid #f0f0f0;
font-size: 12px;
color: #333;
}
.list-item:last-child {
border-bottom: none;
}
.col-no {
width: 20px;
text-align: center;
}
.col-label {
flex: 2;
text-align: center;
}
.col-part {
flex: 2;
text-align: center;
}
.col-batch {
flex: 1.5;
text-align: center;
}
.col-qty {
width: 60px;
text-align: center;
}
.empty-labels {
padding: 40px 20px;
text-align: center;
color: #999;
}
.empty-labels p {
margin: 0;
font-size: 14px;
}
/* 底部操作按钮 */
.bottom-actions {
display: flex;
padding: 16px;
gap: 20px;
background: white;
margin-top: auto;
}
.action-btn {
flex: 1;
padding: 12px;
border: 1px solid #17B3A3;
background: white;
color: #17B3A3;
border-radius: 20px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s ease;
}
.action-btn:hover {
background: #17B3A3;
color: white;
}
.action-btn:active {
transform: scale(0.98);
}
/* 物料清单弹窗样式 */
.material-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.material-modal {
background: white;
border-radius: 12px;
width: 100%;
max-width: 800px;
max-height: 80vh;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
overflow: hidden;
display: flex;
flex-direction: column;
}
.material-modal .modal-header {
background: #17B3A3;
color: white;
padding: 5px 16px;
display: flex;
justify-content: space-between;
align-items: center;
min-height: 28px;
}
.close-btn {
font-size: 16px;
cursor: pointer;
color: white;
transition: color 0.2s ease;
padding: 4px;
display: flex;
align-items: center;
justify-content: center;
}
.close-btn:hover {
color: #e0e0e0;
}
.material-modal .modal-title {
font-size: 16px;
font-weight: 500;
margin: 0;
line-height: 1.2;
}
.material-modal .modal-body {
flex: 1;
overflow: auto;
padding: 0;
}
.material-table {
min-width: 500px;
width: max-content;
}
.table-header {
display: flex;
background: #f8f9fa;
padding: 10px 6px;
border-bottom: 2px solid #17B3A3;
font-size: 12px;
color: #333;
font-weight: 600;
position: sticky;
top: 0;
z-index: 1;
}
.table-body {
/* 垂直滚动由modal-body处理 */
}
.table-row {
display: flex;
padding: 10px 6px;
border-bottom: 1px solid #f0f0f0;
font-size: 12px;
color: #333;
transition: background-color 0.2s ease;
}
.table-row:hover {
background-color: #f8f9fa;
}
.table-row:last-child {
border-bottom: none;
}
.material-table .col-no {
width: 25px;
text-align: center;
flex-shrink: 0;
font-size: 12px;
}
.material-table .col-material-code {
flex: 1.8;
text-align: center;
min-width: 100px;
font-size: 12px;
word-break: break-all;
}
.clickable-part { color: #17B3A3; font-weight: 500; cursor: pointer; text-decoration: underline; }
.clickable-part:hover { color: #0d8f7f; }
.stock-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.stock-modal { background: white; border-radius: 12px; width: 100%; max-width: 800px; max-height: 80vh; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); overflow: hidden; display: flex; flex-direction: column; }
.stock-modal .modal-header { background: #17B3A3; color: white; padding: 5px 16px; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.stock-modal .modal-body { flex: 1; overflow: auto; padding: 0; }
.stock-table { min-width: 500px; width: max-content; }
.stock-table .table-header { display: flex; background: #f8f9fa; padding: 10px 6px; border-bottom: 2px solid #17B3A3; font-size: 12px; color: #333; font-weight: 600; position: sticky; top: 0; }
.stock-table .table-body { /* 垂直滚动由modal-body处理 */ }
.stock-table .table-row { display: flex; padding: 10px 6px; border-bottom: 1px solid #f0f0f0; font-size: 12px; color: #333; }
.stock-table .table-row:hover { background-color: #f8f9fa; }
.stock-table .col-roll-no { flex: 1.5; text-align: center; min-width: 100px; }
.stock-table .col-qty { flex: 0.8; text-align: center; min-width: 60px; }
.unit-text { color: #999; font-size: 11px; margin-left: 2px; }
.stock-table .col-location { flex: 0.8; text-align: center; min-width: 60px; }
.stock-table .col-batch { flex: 1; text-align: center; min-width: 80px; }
.stock-table .col-date { flex: 1; text-align: center; min-width: 80px; }
.stock-modal .modal-footer { padding: 15px 20px; display: flex; justify-content: center; border-top: 1px solid #f0f0f0; }
.empty-stock { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: #999; }
.empty-stock i { font-size: 48px; margin-bottom: 16px; color: #ddd; }
.empty-stock p { margin: 0; font-size: 14px; }
.material-table .col-required-qty {
flex: 0.8;
text-align: center;
min-width: 65px;
font-size: 12px;
}
.material-table .col-available-qty {
flex: 0.8;
text-align: center;
min-width: 65px;
font-size: 12px;
}
.material-table .col-scans-qty {
flex: 0.8;
text-align: center;
min-width: 65px;
font-size: 12px;
}
/* 物料名称列样式 */
.material-table .col-part-name {
flex: 1.2;
text-align: left;
min-width: 80px;
font-size: 12px;
overflow: hidden;
}
.material-table .col-part-name .part-name-text {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
color: #17B3A3;
cursor: pointer;
}
.material-table .col-part-name .part-name-text:active {
color: #0d8f7f;
}
/* 物料名称提示框样式 */
.part-name-tooltip {
position: fixed;
z-index: 10001;
transform: translateY(-100%);
max-width: 200px;
animation: tooltipFadeIn 0.2s ease;
}
@keyframes tooltipFadeIn {
from { opacity: 0; transform: translateY(-100%) translateY(5px); }
to { opacity: 1; transform: translateY(-100%) translateY(0); }
}
.part-name-tooltip .tooltip-content {
background: #303133;
color: #fff;
padding: 8px 12px;
border-radius: 4px;
font-size: 12px;
line-height: 1.4;
word-break: break-all;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.part-name-tooltip::after {
content: '';
position: absolute;
bottom: -6px;
left: 15px;
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: #303133 transparent transparent transparent;
}
.material-modal .modal-footer {
padding: 15px 20px;
display: flex;
justify-content: center;
border-top: 1px solid #f0f0f0;
}
.btn-close {
padding: 10px 20px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #17B3A3;
background: white;
color: #17B3A3;
}
.btn-close:hover {
background: #17B3A3;
color: white;
}
/* 加载状态样式 */
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
color: #666;
}
.loading-container i {
font-size: 24px;
margin-bottom: 12px;
color: #17B3A3;
}
.loading-container span {
font-size: 14px;
}
/* 空数据状态样式 */
.empty-material {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 20px;
color: #999;
}
.empty-material i {
font-size: 48px;
margin-bottom: 16px;
color: #ddd;
}
.empty-material p {
margin: 0;
font-size: 14px;
}
/* 库位号覆盖层样式 */
.location-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.location-modal {
background: white;
border-radius: 12px;
width: 100%;
max-width: 400px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.location-modal .modal-header {
background: #17B3A3;
color: white;
padding: 12px 20px;
text-align: center;
}
.location-modal .modal-title {
font-size: 16px;
font-weight: 500;
}
.location-modal .modal-body {
padding: 20px;
}
.location-input-section {
margin-bottom: 20px;
}
.input-wrapper {
position: relative;
display: flex;
align-items: center;
}
.input-icon {
position: absolute;
left: 12px;
font-size: 18px;
color: #17B3A3;
z-index: 1;
}
.location-input {
width: 100%;
height: 48px;
padding: 0 16px 0 40px;
border: 1px solid #dcdfe6;
border-radius: 8px;
font-size: 16px;
outline: none;
transition: border-color 0.2s;
}
.location-input:focus {
border-color: #17B3A3;
}
.location-input::placeholder {
color: #c0c4cc;
}
.location-modal .modal-footer {
padding: 16px 20px;
display: flex;
justify-content: center;
gap: 12px;
border-top: 1px solid #f0f0f0;
}
.btn-cancel,
.btn-confirm {
padding: 10px 20px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: none;
outline: none;
}
.btn-cancel {
background: #f5f5f5;
color: #666;
}
.btn-cancel:hover {
background: #e6e6e6;
}
.btn-confirm {
background: #17B3A3;
color: white;
}
.btn-confirm:hover:not(:disabled) {
background: #0d8f7f;
}
.btn-confirm:disabled {
background: #c0c4cc;
cursor: not-allowed;
}
/* 响应式设计 */
@media (max-width: 360px) {
.header-bar {
padding: 8px 12px;
}
.material-info-card {
margin: 4px 12px;
padding: 8px 16px;
}
.input-section {
margin: 6px 12px;
padding: 8px 12px;
}
.material-input-grid {
gap: 10px;
}
.input-row-top {
gap: 6px;
}
.input-row-bottom {
margin-top: 4px;
}
.add-material-btn {
padding: 8px 16px;
font-size: 13px;
min-width: 90px;
}
.section-title {
margin: 0 12px;
margin-top: 4px;
}
.label-list {
margin: 0 12px 8px;
}
.card-row-second {
flex-wrap: wrap;
gap: 6px;
}
.card-row-left {
flex: 1 1 100%;
}
.card-row-right {
justify-content: flex-end;
}
.list-header, .list-item {
font-size: 11px;
}
.col-label, .col-part {
flex: 1.5;
}
.col-batch {
flex: 1;
}
}
.material-list-link {
color: #17B3A3;
font-size: 14px;
font-weight: 500;
cursor: pointer;
text-decoration: underline;
transition: color 0.2s ease;
}
.material-list-link:hover {
color: #0d8f7f;
}
/deep/ .inlineNumber input::-webkit-outer-spin-button,
/deep/ .inlineNumber input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
/deep/ .inlineNumber input[type="number"]{
-moz-appearance: textfield;
padding-right: 5px !important;
}
</style>