WMS_PDA/pages/work/storage/receiving/receivingDetail.vue

1165 lines
32 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view class="normar_container">
<page-nav :title="`收货任务详情`" :showBack="true">
<template #right>
<view class="nav-right">
<u-icon name="more-dot-fill" size="22" @click="showActionSheet = true"></u-icon>
</view>
</template>
</page-nav>
<view class="tabs-container">
<u-tabs :list="tabs" :current="currentTab" @change="handleTabChange" lineWidth="30"
lineHeight="4"></u-tabs>
</view>
<view class="container">
<!-- 收货单信息 -->
<view v-if="currentTab === 0" class="info-container">
<info-container :receivingInfo="receivingInfo" @change="initData" @print="handlePrint"/>
</view>
<!-- 收货中状态显示收货明细,其他状态显示收货清单 -->
<view v-else-if="currentTab === 1" class="content-container">
<detail-container v-if="isReceivingStatus" :selectedDetail="selectedDetail" :details="details"
@select="handleSelectDetail" @add="handleAddDetail" @delete="handleDeleteDetail"
@preview="handlePreviewImage" ref="detailContainerRef" @change="initData"
@tryGetStock="tryGetStock" @selectDetailChange="handleSelectDetailChange" @searchSpace="searchSpace" @print="handlePrint"/>
<receivingList v-else :receiving-data="receivingInfo" :detail-list="details"
:fixed-header="true" :fixed-top="receivingListHeaderTop"
:fixed-mask-height="receivingListHeaderGap"></receivingList>
</view>
</view>
</view>
<stockList :stock-list="stockList" :show="showStockList" @select="selectStock" @close="showStockList=false" @tryGetStock="tryGetStock"></stockList>
<space-list :space-list="spaceList" :show="showSpaceList" @select="selectSpace" @close="showSpaceList=false" @searchSpace="searchSpace"></space-list>
<!-- 操作菜单 -->
<u-action-sheet :actions="actionList" :show="showActionSheet" @select="handleAction"
@close="showActionSheet = false">
</u-action-sheet>
<u-popup :show="showComplete" mode="bottom" :closeable="true" border-radius="20" @close="showComplete = false">
<view class="filter-popup">
<view class="popup-header">
<text class="popup-title">收货明细</text>
</view>
<view class="popup-content">
<receivingList :receiving-data="receivingInfo" :detail-list="details">
<template #bottom>
<u-button @click="completeReceiving">确认收货</u-button>
</template>
</receivingList>
</view>
</view>
</u-popup>
<PrintPanel :show="showPrint" :printData="printData" @close="showPrint=false"></PrintPanel>
</view>
</template>
<script>
import infoContainer from './components/info-container.vue'
import detailContainer from './components/detail-container.vue'
import stockList from './components/stockList.vue'
import spaceList from '@/components/space-list/space-list.vue'
import receivingList from './receivingList.vue'
export default {
components: {
infoContainer,
detailContainer,
stockList,
spaceList,
receivingList
},
data() {
return {
receivingId: null,
currentTab: 0,
hasInitializedDefaultTab: false,
receivingListHeaderTop: 0,
receivingListHeaderGap: 0,
qrcodeUrl: null,
showStockList: false,
showSpaceList:false,
showComplete:false,
showPrint:false,
stockList: [],
spaceList: [],
printData:{},
// 收货单信息
receivingInfo: {},
tmp_storeName: "",
// 收货明细
details: [],
selectedDetail: null,
// 对话框控制
showActionSheet: false,
// 下拉菜单
actionList: [{
name: '刷新数据',
color: '#2979ff',
action:"initData"
},
{
name: '完成收货',
color: '#9a3130',
action:"completeReceiving"
},
{
name: '打印收货单',
color: '#9a3130',
action:"comfir"
},
{
name: '整单作废',
color: '#FF0000',
action:"cancel"
}
],
};
},
computed: {
// 判断是否为收货中状态
isReceivingStatus() {
return this.receivingInfo.status === 'receiving';
},
// 动态Tab列表
tabs() {
// 基础Tab:收货单信息
const baseTabs = [{
name: '收货单信息'
}];
// 根据状态添加第二个Tab
if (this.isReceivingStatus) {
baseTabs.push({
name: '收货'
});
} else {
baseTabs.push({
name: '收货清单'
});
}
return baseTabs;
}
},
methods: {
normalizeSpeechText(message) {
const rawText = String(message || '').trim();
if (!rawText) {
return '';
}
const digitMap = {
'0': '零',
'1': '一',
'2': '二',
'3': '三',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九'
};
const normalizeCodeSegment = (segment) => {
return segment
.split('-')
.map(part => String(part || '')
.split('')
.map(char => (digitMap[char] || char))
.join(''))
.join('的');
};
return rawText.replace(/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)+)/g, normalizeCodeSegment);
},
speakMessage(message, options = {}) {
const text = this.normalizeSpeechText(message);
if (!text) {
return;
}
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') {
return;
}
try {
const task = tools.speakText(text, options);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn('[ReceivingDetail] 语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail] 语音播报异常:', error);
}
},
stopSpeak() {
const tools = this.$tools;
if (!tools || typeof tools.stopSpeak !== 'function') {
return;
}
try {
tools.stopSpeak();
} catch (error) {
console.warn('[ReceivingDetail] 停止语音播报异常:', error);
}
},
showToastMessage(title, icon = 'none', options = {}) {
const message = String(title || '').trim();
if (!message) {
return;
}
uni.showToast({
title: message,
icon,
duration: options.duration || 1500
});
if (options.speak !== false) {
this.speakMessage(options.speakText || message, options.voiceOptions || {});
}
},
getTodayStartTimestamp() {
const today = new Date();
today.setHours(0, 0, 0, 0);
return today.getTime();
},
parseDateToTimestamp(dateValue) {
const text = String(dateValue || '').trim();
if (!text) {
return NaN;
}
const normalizedText = text.replace(/-/g, '/');
const date = new Date(normalizedText);
if (Number.isNaN(date.getTime())) {
return NaN;
}
date.setHours(0, 0, 0, 0);
return date.getTime();
},
isShelfLifeMgmtDetail(detail) {
if (!detail || typeof detail !== 'object') {
return false;
}
const flag = detail.is_shelf_life_mgmt
?? detail.product_snapshot?.is_shelf_life_mgmt;
return flag === true || flag === 1 || flag === '1' || flag === 'true';
},
validateShelfLifeRequiredFields() {
const invalidDetail = (this.details || []).find(detail => {
if (!this.isShelfLifeMgmtDetail(detail)) {
return false;
}
const productionDate = String(detail.production_date || '').trim();
const expiryDate = String(detail.expiry_date || '').trim();
return !productionDate || !expiryDate;
});
if (!invalidDetail) {
return null;
}
const missingFields = [];
if (!String(invalidDetail.production_date || '').trim()) {
missingFields.push('生产日期');
}
if (!String(invalidDetail.expiry_date || '').trim()) {
missingFields.push('到期日期');
}
return {
detail: invalidDetail,
missingFields
};
},
validateExpiryDateNotPast() {
const todayStart = this.getTodayStartTimestamp();
const invalidDetail = (this.details || []).find(detail => {
const expiryDate = String(detail?.expiry_date || '').trim();
if (!expiryDate) {
return false;
}
const expiryTimestamp = this.parseDateToTimestamp(expiryDate);
return Number.isFinite(expiryTimestamp) && expiryTimestamp < todayStart;
});
return invalidDetail || null;
},
validateReceivingBaseFields() {
const detailList = this.details || [];
// 1) 先校验商品名称
const invalidNameDetail = detailList.find(detail => !String(detail?.product_name || '').trim());
if (invalidNameDetail) {
return {
detail: invalidNameDetail,
message: `${invalidNameDetail.product_name || '当前商品'}缺少商品名称`
};
}
// 2) 再校验实际数量是否为空
const invalidEmptyQtyDetail = detailList.find(detail => !String(detail?.actual_quantity ?? '').trim());
if (invalidEmptyQtyDetail) {
return {
detail: invalidEmptyQtyDetail,
message: `${invalidEmptyQtyDetail.product_name || '当前商品'}缺少实际数量`
};
}
// 3) 最后校验实际数量是否大于0
const invalidQtyValueDetail = detailList.find(detail => {
const quantityValue = Number(String(detail?.actual_quantity ?? '').trim());
return !Number.isFinite(quantityValue) || quantityValue <= 0;
});
if (invalidQtyValueDetail) {
return {
detail: invalidQtyValueDetail,
message: `${invalidQtyValueDetail.product_name || '当前商品'}实际数量需大于0`
};
}
return null;
},
// 初始化数据
async initData() {
await this.loadReceivingInfo();
},
// 加载收货单信息
async loadReceivingInfo() {
try {
const res = await this.$http('storage.receiving.get', {
id: this.receivingId
});
if (res.code === 200) {
this.receivingInfo = {
...res.data,
creator_name: res.data.creator_snapshot ?
JSON.parse(res.data.creator_snapshot).name : ''
};
if (!this.hasInitializedDefaultTab) {
this.currentTab = this.receivingInfo.status === 'receiving' ? 1 : 0;
this.hasInitializedDefaultTab = true;
}
this.details = res.data.details || [];
// 默认选中第一个明细
if (this.details.length > 0 && !this.selectedDetail) {
this.selectedDetail = this.details[0];
}
// 如果已有选中,更新对应的明细数据
if (this.selectedDetail && this.selectedDetail.id) {
// 找到当前选中明细在数组中的位置
const index = this.details.findIndex(item => item.id === this.selectedDetail.id);
if (index !== -1) {
// 如果需要,重新设置选中的对象(保持响应性)
this.selectedDetail = this.details[index];
} else {
this.selectedDetail = this.details[0];
}
}
}
} catch (error) {
console.error('加载收货单信息失败:', error);
uni.showToast({
title: '加载失败',
icon: 'error'
});
}
},
async handleSelectDetailChange(data) {
console.log('更新数据:', data);
try {
// 货主确认逻辑
if (this.receivingInfo.store_id == null && data.system_product_id) {
this.speakMessage('请确认货主');
const confirm = await this.confirmStoreOwner();
if (!confirm) {
this.showToastMessage('已取消', 'none', {
speak: false
});
return;
}
this.speakMessage('已确认');
}
// 调用API更新
uni.showLoading({
title: '更新中...'
});
const res = await this.$http("storage.receiving.detailChange", data);
uni.hideLoading();
if (res.code == 200) {
await this.initData(); // 刷新数据
} else {
uni.showToast({
title: res.message || '更新失败',
icon: 'error'
});
}
} catch (error) {
console.error('更新失败:', error);
uni.showToast({
title: '网络错误',
icon: 'error'
});
}
},
/**
* 确认货主弹窗
*/
confirmStoreOwner() {
return new Promise((resolve) => {
uni.showModal({
title: '货主确认',
content: `是否确定当前收货单为货主【${this.tmp_storeName}】的?确定后不可更改。`,
success: (res) => {
resolve(res.confirm);
}
});
});
},
// Tab切换
handleTabChange(tab) {
this.currentTab = tab.index;
this.$nextTick(() => {
this.updateReceivingListHeaderTop();
});
},
updateReceivingListHeaderTop() {
const query = uni.createSelectorQuery().in(this);
query.select('.content-container').boundingClientRect();
query.exec(res => {
const contentRect = res && res[0];
if (!contentRect) {
return;
}
const headerGap = this.receivingListHeaderGap || uni.upx2px(20);
this.receivingListHeaderTop = contentRect.top + headerGap;
});
},
// DetailContainer事件处理
handleSelectDetail(detail) {
this.selectedDetail = detail;
},
async handleDeleteDetail(id) {
// 先查找要删除的明细信息,用于提示
const detailToDelete = this.details.find(item => item.id === id);
const deletedIndex = this.details.findIndex(item => item.id === id);
const selectedIdBeforeDelete = this.selectedDetail && this.selectedDetail.id;
if (!detailToDelete) {
uni.showToast({
title: '要删除的明细不存在',
icon: 'none'
});
return;
}
this.speakMessage('请确认删除');
uni.showModal({
title: '确认删除',
content: `确定要删除商品"${detailToDelete.product_name}"吗?`,
success: async (res) => {
if (res.confirm) {
try {
const result = await this.$http('storage.receiving.deleteDetail', {
receiving_id: this.receivingId,
detail_id: id
});
if (result.code === 200) {
this.showToastMessage('删除成功', 'success', {
speakText: '删除成功'
});
// 删除后统一以服务端最新数据重建列表与选中态,避免残留旧引用
await this.loadReceivingInfo();
if (!Array.isArray(this.details) || this.details.length === 0) {
this.selectedDetail = null;
return;
}
if (selectedIdBeforeDelete && selectedIdBeforeDelete !== id) {
const reboundDetail = this.details.find(item => item.id === selectedIdBeforeDelete);
this.selectedDetail = reboundDetail || this.details[0];
return;
}
const nextIndex = Math.min(
Math.max(deletedIndex, 0),
this.details.length - 1
);
this.selectedDetail = this.details[nextIndex] || this.details[0];
} else {
uni.showToast({
title: result.message || '删除失败',
icon: 'none'
});
}
} catch (error) {
console.error('删除明细失败:', error);
uni.showToast({
title: `删除失败: ${error.message}`,
icon: 'error'
});
}
} else {
this.showToastMessage('已取消', 'none', {
speak: false
});
}
}
});
},
// 处理添加明细事件 - 从detail-container组件接收
async handleAddDetail() {
try {
const result = await this.$http('storage.receiving.addDetail', {
receiving_id: this.receivingId
});
if (result.code === 200) {
this.speakMessage('添加成功');
this.showToastMessage('添加成功', 'success', {
speak: false
});
const selectId = result.data && result.data.selectId;
await this.loadReceivingInfo();
if (selectId) {
const newDetail = this.details.find(item => item.id === selectId);
if (newDetail) {
this.selectedDetail = newDetail;
}
}
}
} catch (error) {
console.error('添加明细失败:', error);
uni.showToast({
title: `添加失败: ${error.message}`,
icon: 'error'
});
}
},
// 处理删除明细事件
async deleteDetail(id) {
uni.showModal({
title: '确认删除',
content: '确定要删除这个商品明细吗?',
async success(res) {
if (res.confirm) {
try {
const result = await this.$http('storage.receiving.detailDelete', {
id: id
});
if (result.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
// 重新加载收货单信息(包含明细)
await this.loadReceivingInfo();
// 如果删除的是当前选中的,清空选中
if (this.selectedDetail && this.selectedDetail.id === id) {
this.selectedDetail = null;
}
}
} catch (error) {
uni.showToast({
title: `删除失败: ${error.message}`,
icon: 'error'
});
}
}
}
});
},
// 处理图片预览事件
handlePreviewImage({
images,
index
}) {
this.previewImage(images, index);
},
// 图片预览方法
previewImage(images, index) {
if (!images || images.length === 0) return;
uni.previewImage({
current: index,
urls: images
});
},
// 操作菜单处理
handleAction(index) {
console.log("菜单点击",index);
switch (index.action) {
case "initData":
this.initData();
break;
case "completeReceiving":
this.showComplete = true;
break;
case "cancel":
this.cancel();
}
},
async completeReceiving() {
this.showComplete = false;
const baseValidation = this.validateReceivingBaseFields();
if (baseValidation) {
this.currentTab = 1;
this.selectedDetail = baseValidation.detail;
const message = baseValidation.message || '商品信息不完整';
this.speakMessage(message);
uni.showModal({
title: '商品信息不完整',
content: message,
showCancel: false
});
return;
}
const shelfLifeValidation = this.validateShelfLifeRequiredFields();
if (shelfLifeValidation) {
this.currentTab = 1;
this.selectedDetail = shelfLifeValidation.detail;
uni.showModal({
title: '商品信息不完整',
content: `${shelfLifeValidation.detail.product_name || '当前商品'}缺少${shelfLifeValidation.missingFields.join('、')}`,
showCancel: false
});
return;
}
const expiredDetail = this.validateExpiryDateNotPast();
if (expiredDetail) {
this.currentTab = 1;
this.selectedDetail = expiredDetail;
uni.showModal({
title: '禁止收货',
content: `商品名称:${expiredDetail.product_name || '当前商品'}已过期,请移除拒绝收货`,
showCancel: false
});
return;
}
try {
const tools = this.$tools;
if (tools && typeof tools.speakText === 'function') {
try {
const speakTask = tools.speakText('请确认完成收货', {
force: true,
minInterval: 0
});
if (speakTask && typeof speakTask.catch === 'function') {
speakTask.catch(error => {
console.warn('[ReceivingDetail] 完成收货前语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail] 完成收货前语音播报失败:', error);
}
} else {
this.speakMessage('请确认完成收货', {
force: true,
minInterval: 0
});
}
uni.showToast({
title: '请确认完成收货',
icon: 'none',
duration: 800
});
await new Promise(resolve => setTimeout(resolve, 900));
// 1. 显示确认弹窗
const confirmResult = await uni.showModal({
title: '完成收货',
content: '确定要完成当前收货单吗?完成后将无法修改。',
confirmText: '确定完成',
confirmColor: '#2979ff',
cancelText: '再想想',
cancelColor: '#999'
});
console.log('确认结果:', confirmResult);
// 修正:直接使用confirmResult.confirm
if (!confirmResult[1].confirm) {
this.showToastMessage('已取消', 'none', {
speak: false
});
return;
}
// 2. 显示加载状态
uni.showLoading({
title: '正在完成收货...',
mask: true
});
// 3. 调用完成收货接口
const res = await this.$http('storage.receiving.completeReceiving', {
id: this.receivingId
});
console.log('请求返回:', res);
// 4. 隐藏加载状态
uni.hideLoading();
// 5. 检查响应结果
// 根据你的后端响应结构调整
if (res.code === 200 || res.success) {
// 成功提示
this.showToastMessage('收货完成成功', 'success');
// 延迟跳转
setTimeout(() => {
uni.redirectTo({
url: './receiving',
animationType: 'slide-in-left'
});
}, 1500);
} else {
// 处理业务错误
let errorMsg = res.message || '操作失败';
// 如果有详细的错误信息
if (res.data && res.data.invalid_details) {
const firstError = res.data.invalid_details[0];
// 弹出详细错误提示
uni.showModal({
title: '商品信息不完整',
content: errorMsg,
confirmText: '去补全',
success: (modalRes) => {
if (modalRes.confirm) {
this.currentTab = 1;
const index = this.details.findIndex(item => item.id === firstError.detail_id);
if (index !== -1) {
this.selectedDetail = this.details[index];
} else {
//数据不一致,设置选中id,更新数据
this.selectedDetail.id = firstError.detail_id;
this.initData();
}
}
}
});
return;
}
throw new Error(errorMsg);
}
} catch (error) {
// 错误处理
uni.hideLoading();
console.error('完成收货失败:', error);
this.currentTab = 1;
this.showToastMessage(error.message || '操作失败,请稍后重试', 'none', {
duration: 3000
});
}
},
async cancel() {
try {
this.speakMessage('请确认作废');
// 1. 显示确认弹窗
const confirmResult = await uni.showModal({
title: '整单作废',
content: '确定要作废当前收货单吗?此操作不可撤销。',
confirmText: '确定作废',
confirmColor: '#e64340',
cancelText: '再想想',
cancelColor: '#999'
});
console.log(confirmResult);
if (!confirmResult[1].confirm) {
this.showToastMessage('已取消', 'none', {
speak: false
});
return;
}
// 2. 显示加载状态
uni.showLoading({
title: '正在作废...',
mask: true
});
console.log("作废");
// 3. 调用取消接口
const res = await this.$http('storage.receiving.cancel', {
id: this.receivingId
});
console.log("请求返回",res);
const {data} = res;
// 4. 隐藏加载状态
uni.hideLoading();
if(res.code!==200){
throw new Error("取消失败"+res.message)
}
// 5. 显示成功提示
this.showToastMessage('取消成功', 'success', {
speakText: '取消成功'
});
// 6. 延迟跳转,让用户看到成功提示
setTimeout(() => {
uni.redirectTo({
url: './receiving',
animationType: 'slide-in-left'
});
}, 1500);
} catch (error) {
// 7. 错误处理
uni.hideLoading();
console.log(error);
uni.showToast({
title: error.message,
icon: 'none',
duration: 3000
});
}
},
getStockName(stock) {
if (!stock || typeof stock !== 'object') {
return '新商品';
}
return stock.item_name || stock.product_name || stock.name || stock.goods_name || '新商品';
},
getStockBarcode(stock, fallbackBarcode = '') {
if (fallbackBarcode) {
return fallbackBarcode;
}
if (Array.isArray(stock?.barcodes) && stock.barcodes.length) {
return stock.barcodes.filter(Boolean).join(';');
}
return stock?.barcode || stock?.goods_code || stock?.item_code || '';
},
normalizeWeightValue(value) {
if (value === undefined || value === null) {
return '';
}
const text = String(value).trim();
if (!text) {
return '';
}
const numericValue = Number(text);
return Number.isFinite(numericValue) ? String(numericValue) : text;
},
getStockWeight(stock) {
if (!stock || typeof stock !== 'object') {
return '';
}
const candidates = [
stock.gross_weight,
stock.product && stock.product.gross_weight,
stock.product_snapshot && stock.product_snapshot.gross_weight,
stock.store_stock && stock.store_stock.gross_weight,
];
for (const item of candidates) {
const normalized = this.normalizeWeightValue(item);
if (normalized !== '') {
return normalized;
}
}
return '';
},
buildStockUpdateData(stock, scannedBarcode = '') {
const updateData = {
...this.selectedDetail,
system_product_id: stock.id,
product_name: this.getStockName(stock),
barcode: this.getStockBarcode(stock, scannedBarcode)
};
const weight = this.getStockWeight(stock);
updateData.weight = weight;
return updateData;
},
async selectStock(stock) {
const updateData = this.buildStockUpdateData(stock);
this.tmp_storeName = stock.store_stock.store_remask;
await this.handleSelectDetailChange(updateData);
},
async selectSpace(space){
const updateData = {
...this.selectedDetail, // 保留原有的所有属性
space_id: space.id,
};
await this.handleSelectDetailChange(updateData);
},
async ensureSelectedDetailForScan() {
if (this.selectedDetail && this.selectedDetail.id) {
return true;
}
try {
const addResult = await this.$http('storage.receiving.addDetail', {
receiving_id: this.receivingId
});
if (addResult.code !== 200) {
uni.showToast({
title: addResult.message || '新增商品明细失败',
icon: 'none'
});
return false;
}
const selectId = addResult.data && addResult.data.selectId;
await this.loadReceivingInfo();
if (selectId) {
const detail = this.details.find(item => item.id === selectId);
if (detail) {
this.selectedDetail = detail;
}
}
if (!this.selectedDetail && this.details.length > 0) {
this.selectedDetail = this.details[this.details.length - 1];
}
return !!(this.selectedDetail && this.selectedDetail.id);
} catch (error) {
console.error('扫码自动新增明细失败:', error);
uni.showToast({
title: '新增商品明细失败',
icon: 'none'
});
return false;
}
},
async tryGetStock(data) {
const keyword = String(data || '').trim();
if (!keyword) {
return false;
}
if (!this.selectedDetail) {
const ready = await this.ensureSelectedDetailForScan();
if (!ready) {
return false;
}
}
const stocks = await this.$http("stock.warehouse.search", {
keyword,
store_id: this.receivingInfo.store_id
});
if (stocks.code == 200) {
if (stocks.total == 1) {
const updateData = this.buildStockUpdateData(stocks.data[0], keyword);
this.tmp_storeName = stocks.data[0].store_stock.store_remask;
await this.handleSelectDetailChange(updateData);
} else if (stocks.total > 1) {
this.showStockList = true;
this.stockList = stocks.data;
//显示列表
} else {
const updateData = {
...this.selectedDetail, // 保留原有的所有属性
barcode: keyword,
system_product_id:null,
product_name:"新商品",
// 确保barcode被正确设置
};
this.tmp_storeName = null;
await this.handleSelectDetailChange(updateData);
}
} else {
console.log("搜索出错");
}
},
async searchSpace(data){
console.log("searchSpace",data);
const spaceInfo = await this.$http("common.searchSpace",{keyword:data});
if(spaceInfo.code==200){
if (spaceInfo.total == 1 && this.selectedDetail.space_id!=spaceInfo.data[0].id) {
const matchedSpace = spaceInfo.data[0] || {};
const spaceLabel = matchedSpace.custom_name || matchedSpace.name || matchedSpace.space_name || matchedSpace.space_code || matchedSpace.custom_barcode || String(data || '').trim();
const updateData = {
...this.selectedDetail, // 保留原有的所有属性
space_id: spaceInfo.data[0].id
};
console.log("更新仓位",updateData);
await this.handleSelectDetailChange(updateData);
this.speakMessage(`扫描成功,库位:${spaceLabel}`);
} else if (spaceInfo.total > 1) {
console.log("多个仓位",spaceInfo.data);
this.showSpaceList = true;
this.spaceList = spaceInfo.data;
}
}
},
async handlePrint(data){
console.log(data);
this.printData = data;
this.showPrint = true;
},
},
onLoad(options) {
if (options.id) {
this.receivingId = parseInt(options.id);
if (options.tab === 'content') {
this.currentTab = 1;
this.hasInitializedDefaultTab = true;
}
this.initData();
}
},
onReady() {
this.receivingListHeaderGap = uni.upx2px(20);
this.$nextTick(() => {
this.updateReceivingListHeaderTop();
});
},
onHide() {
this.stopSpeak();
},
onUnload() {
this.stopSpeak();
}
};
</script>
<style lang="scss" scoped>
.container {
padding: 20rpx;
flex: 1;
overflow: hidden;
}
.tabs-container {
background: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
}
.nav-right {
padding-right: 20rpx;
}
.info-container {
height: 100%;
}
.content-container {
height: 100%;
display: flex;
flex-direction: column;
}
.receipt-content {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
background: #fff;
border-radius: 16rpx;
}
.filter-popup {
height: 750rpx;
display: flex;
flex-direction: column;
padding-bottom: env(safe-area-inset-bottom);
.popup-header {
padding: 40rpx 30rpx 20rpx;
border-bottom: 1rpx solid #f0f0f0;
.popup-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
}
.popup-content {
padding: 30rpx;
height: 100rpx;
flex:1;
.date-range {
font-size: 28rpx;
color: #333;
padding: 10rpx 0;
}
.quick-date-buttons {
display: flex;
gap: 20rpx;
::v-deep .u-btn {
flex: 1;
}
}
}
.popup-actions {
padding: 30rpx;
border-top: 1rpx solid #f0f0f0;
display: flex;
gap: 20rpx;
::v-deep .u-btn {
flex: 1;
height: 90rpx;
font-size: 32rpx;
}
}
}
</style>