新增称重页面

This commit is contained in:
zm2000 2026-07-08 17:58:35 +08:00
parent e7086daddc
commit 28b16a6cd5
2 changed files with 373 additions and 0 deletions

View File

@ -216,6 +216,13 @@
"titleNView": false
}
},
{
"path" : "pages/work/order/weighing",
"style" :
{
"titleNView": false
}
},
{
"path" : "pages/packing/labelReprint",
"style" :

View File

@ -0,0 +1,366 @@
<template>
<view class="weighing-page">
<view class="normar_container">
<page-nav title="称重">
<template #left>
<view
class="nav-manual-input"
:class="{ 'nav-manual-input--inactive': !showScanInput }"
@click="toggleScanInput"
>
<text class="nav-manual-input-text">{{ showScanInput ? '关闭手动输入' : '手动输入' }}</text>
</view>
</template>
<template #right>
<view class="nav-reset" @click="handleReset">
<text class="nav-reset-text">重置</text>
</view>
</template>
</page-nav>
<!-- 扫码输入区 -->
<view class="scan-section" v-show="showScanInput">
<view class="scan-input-wrap">
<u-input
v-model="scanInput"
placeholder="扫描/输入快递单号"
border="surround"
:customStyle="{ flex: 1 }"
:focus="scanFocused"
@confirm="handleScanConfirm"
></u-input>
<view class="scan-camera-btn" @click="handleCameraScan">
<u-icon name="camera" size="22" color="#2979ff"></u-icon>
</view>
</view>
</view>
<!-- 信息展示 -->
<view class="info-list" :class="{ 'info-list--no-scan': !showScanInput }" v-show="showOrderInfo">
<view class="info-row">
<text class="info-label">快递号</text>
<text class="info-value">{{ orderInfo.waybill_code || '--' }}</text>
</view>
<view class="info-row">
<text class="info-label">商品净重</text>
<text class="info-value info-value--highlight">{{ netWeight !== '' ? netWeight : '--' }}</text>
</view>
<view class="info-row">
<text class="info-label">称重重量</text>
<view class="info-value-input">
<u-input
v-model="manualWeight"
type="digit"
placeholder="请输入重量"
border="surround"
:customStyle="{ flex: 1 }"
></u-input>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="submit-section" v-show="showOrderInfo">
<u-button
type="primary"
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', width: '100%' }"
:disabled="!manualWeight"
:loading="submitting"
@click="handleSubmitWeight"
>设置重量</u-button>
</view>
</view>
</view>
</template>
<script>
import voice from '@/core/utils/voice';
export default {
data() {
return {
scanInput: '',
scanFocused: true,
showScanInput: false,
orderInfo: {
order_id: 0,
waybill_code: ''
},
netWeight: '',
manualWeight: '',
submitting: false,
showOrderInfo: false
};
},
onLoad() {
this.startScan();
},
onUnload() {
this.stopScan();
},
methods: {
startScan() {
uni.$on('onScanData', this.onScanData);
},
stopScan() {
uni.$off('onScanData', this.onScanData);
},
onScanData(data) {
if (data) {
this.scanInput = data;
this.handleScanConfirm(data);
}
},
toggleScanInput() {
this.showScanInput = !this.showScanInput;
},
handleScanConfirm(value) {
const code = value || this.scanInput;
if (!code) return;
this.fetchOrderInfo(code);
},
handleCameraScan() {
// 调用相机扫码
uni.scanCode({
success: (res) => {
this.scanInput = res.result;
this.handleScanConfirm(res.result);
}
});
},
speakVoice(text) {
voice.speak(text, { minInterval: 800 });
},
async fetchOrderInfo(code) {
uni.showLoading({ title: '查询中...' });
try {
const res = await this.$http('order.recheckOrder.scanOrder', { waybill_code: code }, '', false);
if (res && res.flag !== 'failure') {
const data = res.data || {};
if (data.list_type === 'single') {
// 散单模式
const orderItem = (data.list || []).find(
item => item.waybill_no === code
);
if (!orderItem) {
uni.showToast({ title: '未找到匹配订单', icon: 'none' });
return;
}
if (!orderItem.is_reviewed) {
uni.showToast({ title: '订单未复核', icon: 'none' });
this.speakVoice('订单未复核');
this.showOrderInfo = false;
this.orderInfo = { order_id: 0, waybill_code: '' };
this.netWeight = '';
this.manualWeight = '';
return;
}
this.orderInfo = {
order_id: orderItem.order_id || 0,
waybill_code: orderItem.waybill_no || code
};
this.netWeight = orderItem.items_weight ?? '';
this.manualWeight = orderItem.items_weight ? String(orderItem.items_weight) : '';
} else {
// 团购模式 — 由后端按运单号处理
const waveItem = (data.list || [])[0];
const hasUnreviewed = waveItem && waveItem.unreviewed_count > 0;
if (hasUnreviewed) {
uni.showToast({ title: '订单未复核', icon: 'none' });
this.speakVoice('订单未复核');
this.showOrderInfo = false;
this.orderInfo = { order_id: 0, waybill_code: '' };
this.netWeight = '';
this.manualWeight = '';
return;
}
this.orderInfo = {
order_id: 0,
waybill_code: code
};
this.netWeight = waveItem?.items_weight ?? '';
this.manualWeight = waveItem?.items_weight ? String(waveItem.items_weight) : '';
}
this.showOrderInfo = true;
} else {
uni.showToast({ title: res.msg || '查询失败', icon: 'none' });
}
} catch (e) {
uni.showToast({ title: '网络异常', icon: 'none' });
} finally {
uni.hideLoading();
}
},
handleSubmitWeight() {
if (!this.manualWeight) {
uni.showToast({ title: '请输入称重重量', icon: 'none' });
return;
}
this.submitting = true;
const payload = {
order_id: this.orderInfo.order_id,
waybill_code: this.orderInfo.waybill_code,
weighing_weight: Number((Number(this.manualWeight) / 1000).toFixed(3))
};
this.$http('order.recheckOrder.updateExpressWeighingWeight', payload, '', false)
.then(res => {
if (res && res.flag !== 'failure') {
uni.showToast({ title: '设置成功', icon: 'success' });
this.resetForm();
} else {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
}
})
.catch(() => {
uni.showToast({ title: '网络异常', icon: 'none' });
})
.finally(() => {
this.submitting = false;
});
},
handleBack() {
uni.navigateBack();
},
handleReset() {
this.resetForm();
},
resetForm() {
this.scanInput = '';
this.orderInfo = { order_id: 0, waybill_code: '' };
this.netWeight = '';
this.manualWeight = '';
this.showOrderInfo = false;
this.scanFocused = true;
}
}
};
</script>
<style lang="scss" scoped>
.weighing-page {
.normar_container {
min-height: 100vh;
background-color: #f5f5f5;
}
/* ===== 左侧手动输入按钮 ===== */
::v-deep .nav-title .left {
min-width: auto;
gap: 0;
}
::v-deep .nav-title .right {
width: auto;
min-width: 80rpx;
}
.nav-manual-input {
display: flex;
align-items: center;
justify-content: center;
width: 210rpx;
height: 52rpx;
background: #fa8c16;
border-radius: 8rpx;
&--inactive {
background: #2979ff;
}
.nav-manual-input-text {
font-size: 32rpx;
color: #ffffff;
white-space: nowrap;
}
}
/* ===== 重置按钮 ===== */
.nav-reset {
padding: 8rpx 0;
.nav-reset-text {
font-size: 32rpx;
color: #fff;
background-color: #2979ff;
padding: 8rpx 24rpx;
border-radius: 8rpx;
white-space: nowrap;
}
}
/* ===== 扫码输入区 ===== */
.scan-section {
padding: 20rpx 24rpx;
background: #fff;
margin-bottom: 16rpx;
.scan-input-wrap {
display: flex;
align-items: center;
gap: 16rpx;
.scan-camera-btn {
width: 72rpx;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f0f7ff;
border-radius: 8rpx;
flex-shrink: 0;
}
}
}
/* ===== 信息展示列表 ===== */
.info-list {
background: #fff;
margin: 0 24rpx 16rpx;
&--no-scan {
margin-top: 20rpx;
}
border-radius: 12rpx;
overflow: hidden;
.info-row {
display: flex;
align-items: center;
padding: 24rpx 24rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.info-label {
font-size: 32rpx;
color: #000;
width: 160rpx;
flex-shrink: 0;
}
.info-value {
font-size: 32rpx;
color: #000;
flex: 1;
&--highlight {
color: #000;
}
}
.info-value-input {
flex: 1;
}
}
}
/* ===== 提交按钮 ===== */
.submit-section {
padding: 40rpx 24rpx;
}
}
</style>