袁伟杰:V2.0.003 采购入库扫码

This commit is contained in:
yuan
2026-05-14 16:48:09 +08:00
parent 7f84bbca79
commit 7859af83b2
24 changed files with 3479 additions and 62 deletions

View File

@@ -0,0 +1,85 @@
<template>
<view class="order-context-bar">
<view class="order-context-bar__main">
<view class="order-context-bar__order">
<text class="order-context-bar__label">单号</text>
<text class="order-context-bar__value">{{ orderNo || '-' }}</text>
</view>
<view class="order-context-bar__progress">
已扫 {{ scannedCount }} / {{ targetCount }}
</view>
</view>
<view class="order-context-bar__meta">
<text>供应商{{ supplierName || '-' }}</text>
<text>仓库{{ warehouseName || '-' }}</text>
<text class="order-context-bar__exception">异常{{ exceptionCount }}</text>
</view>
</view>
</template>
<script setup lang="ts">
defineProps<{
orderNo: string
supplierName?: string
warehouseName?: string
scannedCount: number
targetCount: number
exceptionCount: number
}>()
</script>
<style lang="scss" scoped>
.order-context-bar {
padding: 20rpx 24rpx;
border-bottom: 2rpx solid #e5e6eb;
background: rgba(255, 255, 255, 0.96);
&__main,
&__meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__order {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
&__label {
flex-shrink: 0;
color: #86909c;
font-size: 24rpx;
}
&__value {
min-width: 0;
color: #1f2329;
font-size: 30rpx;
font-weight: 600;
}
&__progress {
flex-shrink: 0;
color: #1677ff;
font-size: 24rpx;
font-weight: 600;
}
&__meta {
margin-top: 12rpx;
color: #4e5969;
font-size: 22rpx;
flex-wrap: wrap;
}
&__exception {
color: #d4380d;
}
}
</style>

View File

@@ -0,0 +1,187 @@
<template>
<view class="recent-scan-list">
<view v-if="items.length === 0" class="recent-scan-list__empty">
暂无最近扫码记录
</view>
<view
v-for="(item, index) in items"
:key="buildItemKey(item)"
class="scan-card"
:class="{ 'scan-card--latest': latestIndex === index }"
>
<view class="scan-card__header">
<text class="scan-card__name">{{ item.productName || '-' }}</text>
<text class="scan-card__undo" @tap="emit('undo', index, item)">撤销</text>
</view>
<view class="scan-card__meta">
<text>条码{{ item.productBarCode || '-' }}</text>
<view class="scan-card__quantity">
<text class="scan-card__step" @tap="emit('decrease', index, item)">-</text>
<input
class="scan-card__count-input"
type="number"
:value="formatCount(item.count)"
@blur="handleCountBlur($event, index, item)"
@confirm="handleCountBlur($event, index, item)"
>
<text class="scan-card__step" @tap="emit('increase', index, item)">+</text>
</view>
</view>
<view class="scan-card__meta">
<text>批次{{ item.batchNo || '-' }}</text>
<text>剩余{{ formatCount(item.remainCount) }}</text>
</view>
<view class="scan-card__meta">
<text>库位{{ item.locationCode || '-' }}</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import type { PurchaseScanItem } from '@/utils/purchase-scan'
defineProps<{
items: PurchaseScanItem[]
latestIndex?: number
}>()
const emit = defineEmits<{
(event: 'undo', index: number, item: PurchaseScanItem): void
(event: 'increase', index: number, item: PurchaseScanItem): void
(event: 'decrease', index: number, item: PurchaseScanItem): void
(event: 'change-count', index: number, nextCount: number, item: PurchaseScanItem): void
}>()
/**
* 功能说明:生成最近扫码卡片的稳定 key复用采购扫码的聚合维度。
* 适用场景:最近扫码列表渲染时为每条记录提供唯一标识。
* @param item 当前扫码记录
* @return 组合后的字符串 key
* 注意事项:采购扫码项已按订单行、批次和库位聚合,这里直接使用相同维度生成稳定 key避免列表重排时节点误复用。
*/
function buildItemKey(item: PurchaseScanItem) {
return [
item.orderItemId || item.productId || 'unknown',
item.batchNo || 'no-batch',
item.locationCode || 'no-location',
].join('-')
}
/**
* 功能说明:格式化数量展示,避免空值直接透出到工作台。
* 适用场景:最近扫码卡片展示扫码数量和剩余数量。
* @param value 原始数量
* @return 格式化后的数量文案
* 注意事项:采购扫码数量可能来自接口或本地累加,这里统一转数值后再按整数/小数展示。
*/
function formatCount(value?: number) {
if (value === undefined || value === null) {
return '-'
}
const normalizedValue = Number(value)
return normalizedValue.toFixed(Number.isInteger(normalizedValue) ? 0 : 4)
}
/**
* 功能说明:处理扫码卡片中的手动数量录入。
* 适用场景:操作员直接输入目标数量后离焦或回车确认。
* @param event 输入框事件
* @param index 当前记录索引
* @param item 当前扫码记录
* @return 无
* 注意事项:这里只负责把输入值抛给页面层,实际数量校验与上限判断统一由页面业务逻辑处理。
*/
function handleCountBlur(event: Record<string, any>, index: number, item: PurchaseScanItem) {
const rawValue = event?.detail?.value
emit('change-count', index, Number(rawValue), item)
}
</script>
<style lang="scss" scoped>
.recent-scan-list {
&__empty {
padding: 28rpx;
border-radius: 16rpx;
background: #fff;
color: #86909c;
text-align: center;
}
}
.scan-card {
margin-bottom: 16rpx;
padding: 24rpx;
border: 2rpx solid transparent;
border-radius: 16rpx;
background: #fff;
&--latest {
border-color: #1677ff;
box-shadow: 0 8rpx 20rpx rgba(22, 119, 255, 0.12);
}
&__header,
&__meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
&__header {
margin-bottom: 12rpx;
}
&__name {
color: #1f2329;
font-size: 28rpx;
font-weight: 600;
}
&__undo {
flex-shrink: 0;
color: #f53f3f;
font-size: 24rpx;
}
&__meta {
margin-top: 8rpx;
color: #4e5969;
font-size: 24rpx;
flex-wrap: wrap;
}
&__quantity {
display: flex;
align-items: center;
gap: 12rpx;
}
&__step {
width: 44rpx;
height: 44rpx;
line-height: 44rpx;
border-radius: 8rpx;
background: #f2f3f5;
color: #1f2329;
text-align: center;
font-size: 30rpx;
}
&__count-input {
width: 104rpx;
height: 44rpx;
line-height: 44rpx;
border: 2rpx solid #d9dce3;
border-radius: 8rpx;
background: #fff;
color: #1f2329;
text-align: center;
box-sizing: border-box;
}
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<view v-if="message" class="feedback-bar" :class="`feedback-bar--${tone}`">
{{ message }}
</view>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
tone?: 'success' | 'error' | 'idle'
message?: string
}>(),
{
tone: 'idle',
message: '',
},
)
</script>
<style lang="scss" scoped>
.feedback-bar {
min-height: 76rpx;
padding: 18rpx 24rpx;
border-radius: 14rpx;
font-size: 24rpx;
line-height: 40rpx;
&--idle {
background: #f2f3f5;
color: #4e5969;
}
&--success {
background: #f6ffed;
color: #389e0d;
}
&--error {
background: #fff2f0;
color: #cf1322;
}
}
</style>