优化
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<view class="label-confirmation">
|
||||
<text v-if="confirmed">标签已扫码确认,可按该包裹/箱号出库</text>
|
||||
<template v-else>
|
||||
<ScanTargetInput v-model="code" label="确认已贴标签" placeholder="贴好后扫描此包裹/箱标签" @submit="confirm" />
|
||||
<button class="secondary" :disabled="busy || !code.trim()" @tap="confirm(code)">确认贴标</button>
|
||||
<text v-if="error">{{ error }}</text>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import ScanTargetInput from '@/components/ScanTargetInput.vue'
|
||||
import { confirmReturnLabel } from '@/api/return-packing.js'
|
||||
export default {
|
||||
components: { ScanTargetInput },
|
||||
props: { cartonMark: { type: String, required: true } },
|
||||
data() { return { code: '', confirmed: false, busy: false, error: '' } },
|
||||
methods: {
|
||||
acceptScan(value) { if (String(value).trim() === this.cartonMark) return this.confirm(value) },
|
||||
async confirm(raw) {
|
||||
if (this.busy || this.confirmed) return
|
||||
const mark = String(raw?.detail?.value ?? raw ?? this.code).trim()
|
||||
if (mark !== this.cartonMark) { this.error = '请扫描当前包裹/箱的标签'; return }
|
||||
this.busy = true; this.error = ''
|
||||
try { await confirmReturnLabel(mark); this.confirmed = true }
|
||||
catch (error) { this.error = error?.message || '贴标确认失败,请重试' }
|
||||
finally { this.busy = false }
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user