优化
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<view v-if="user" class="page-shell palletization-page">
|
||||
<PortalHeader title="合托作业" :user="user" :fallback-url="'/pages/dropship-tasks/dropship-tasks'" />
|
||||
<PortalHeader title="一件代发入库" :user="user" :fallback-url="'/pages/dropship-tasks/dropship-tasks'" />
|
||||
<view class="content">
|
||||
<view v-if="error" class="message error" role="alert">{{ error }}</view>
|
||||
<view v-if="notice" class="message success" role="status">{{ notice }}</view>
|
||||
<view v-if="loading && !task" class="state">正在加载合托任务…</view>
|
||||
<view v-if="loading && !task" class="state">正在加载入库任务…</view>
|
||||
<template v-if="task">
|
||||
<view class="summary-card">
|
||||
<view class="task-summary-card">
|
||||
<view class="summary-head"><view><text class="eyebrow">入仓码</text><text class="inbound-code">{{ task.inboundCode || '—' }}</text></view><text class="status">{{ statusLabel }}</text></view>
|
||||
<text class="customer">{{ task.customerName || '客户未关联' }} · {{ task.warehouseName || '仓库未关联' }}</text>
|
||||
<view class="metrics">
|
||||
@@ -15,7 +15,7 @@
|
||||
<view><strong>{{ task.boundCartons || 0 }}</strong><text>已归托</text></view>
|
||||
<view><strong>{{ task.unboundCartons || 0 }}</strong><text>待归托</text></view>
|
||||
</view>
|
||||
<button v-if="task.taskStatus === 'PENDING'" class="primary-button" :disabled="submitting" @tap="claimTask">领取并开始合托</button>
|
||||
<button v-if="task.taskStatus === 'PENDING'" class="primary-button" :disabled="submitting" @tap="claimTask">领取并开始入库</button>
|
||||
</view>
|
||||
|
||||
<view v-if="task.taskStatus === 'CLAIMED'" class="section-card">
|
||||
@@ -33,20 +33,18 @@
|
||||
</view>
|
||||
|
||||
<view v-if="task.taskStatus === 'CLAIMED'" class="section-card">
|
||||
<text class="section-title">2. 归托</text>
|
||||
<text class="section-desc">把已清点待归托箱绑定到现有 DP 托盘,或由系统生成新托盘。</text>
|
||||
<ScanTargetInput v-model="palletNo" name="palletNo" label="托盘码" placeholder="扫描 DP-YYMMDD-NNNN" :active="activeScan === 'palletNo'" @activate="activeScan = 'palletNo'" @submit="bindPending" />
|
||||
<button class="secondary-button" :disabled="!validPalletNo || !task.unboundCartons || submitting" @tap="bindPending">绑定到扫描托盘</button>
|
||||
<button class="primary-button" :disabled="!task.unboundCartons || submitting" @tap="createAndBind">生成 DP 托盘并绑定</button>
|
||||
<text class="section-title">2. 完成入库</text>
|
||||
<text class="section-desc">全部箱码清点完成后,系统一次性完成归托、封托并生成正式 DP 托盘码。</text>
|
||||
<button class="primary-button" :disabled="!allCartonsCounted || !task.unboundCartons || submitting" @tap="completeInbound">完成入库并生成托盘码</button>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<view class="section-heading"><view><text class="section-title">3. 托盘与封托</text><text class="section-desc">所有箱清点并归托后,逐托确认封托。</text></view><button class="text-button" :disabled="loading" @tap="loadTask">刷新</button></view>
|
||||
<view class="section-heading"><view><text class="section-title">3. 托盘码与打印</text><text class="section-desc">完成入库后显示最终托盘码,可立即打印并粘贴。</text></view><button class="text-button" :disabled="loading" @tap="loadTask">刷新</button></view>
|
||||
<view v-if="!task.pallets || !task.pallets.length" class="empty">暂无托盘</view>
|
||||
<view v-for="pallet in task.pallets" :key="pallet.palletId" class="pallet-card">
|
||||
<view class="pallet-head"><text class="pallet-code">{{ pallet.palletNo }}</text><text class="pallet-status" :class="pallet.status === 'SEALED' ? 'sealed' : ''">{{ pallet.status === 'SEALED' ? '已封托' : '待封托' }}</text></view>
|
||||
<text class="pallet-meta">{{ pallet.cartonCount || 0 }} 箱 · {{ pallet.skuCount || 0 }} SKU · {{ pallet.weightKg || 0 }} kg · {{ pallet.volumeCbm || 0 }} m³</text>
|
||||
<button v-if="pallet.status === 'OPEN'" class="primary-button" :disabled="submitting || !canSeal" @tap="sealPallet(pallet)">确认封托</button>
|
||||
<button v-if="pallet.status === 'SEALED'" class="primary-button" :disabled="printing" @tap="printPallet(pallet)">{{ printing ? '正在生成打印文件…' : '打印托盘码' }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -57,20 +55,19 @@
|
||||
<script>
|
||||
import PortalHeader from '@/components/PortalHeader.vue'
|
||||
import ScanTargetInput from '@/components/ScanTargetInput.vue'
|
||||
import { bindDropshipPendingCartons, claimDropshipPalletizationTask, countDropshipCarton, createAndBindDropshipPallet, getDropshipPalletizationTask, resolveDropshipCarton, sealDropshipPallet } from '@/api/pda-dropship.js'
|
||||
import { claimDropshipPalletizationTask, countDropshipCarton, createAndBindDropshipPallet, downloadDropshipPalletLabel, getDropshipPalletizationTask, resolveDropshipCarton } from '@/api/pda-dropship.js'
|
||||
import { session, requireSession } from '@/stores/session.js'
|
||||
import { formatApiError } from '@/utils/user-facing.js'
|
||||
import { startScanBroadcast } from '@/utils/scan-broadcast.js'
|
||||
|
||||
export default {
|
||||
components: { PortalHeader, ScanTargetInput },
|
||||
data() { return { user: session.currentUser, taskId: '', warehouseId: '', task: null, boxCode: '', palletNo: '', carton: null, actualQuantity: '', discrepancyRemark: '', activeScan: 'boxCode', loading: false, submitting: false, error: '', notice: '' } },
|
||||
data() { return { user: session.currentUser, taskId: '', warehouseId: '', task: null, boxCode: '', carton: null, actualQuantity: '', discrepancyRemark: '', activeScan: 'boxCode', loading: false, submitting: false, printing: false, error: '', notice: '' } },
|
||||
computed: {
|
||||
statusLabel() { return this.task?.taskStatus === 'COMPLETED' ? '已完成' : (this.task?.taskStatus === 'CLAIMED' ? '作业中' : '待领取') },
|
||||
quantityDiffers() { return this.carton && Number(this.actualQuantity) !== Number(this.carton.expectedSkuQuantity) },
|
||||
canCount() { return Boolean(this.carton?.canCount && Number(this.actualQuantity) > 0 && (!this.quantityDiffers || this.discrepancyRemark.trim())) },
|
||||
validPalletNo() { return /^DP-\d{6}-\d{4}$/.test(this.palletNo.trim().toUpperCase()) },
|
||||
canSeal() { return Number(this.task?.countedCartons || 0) === Number(this.task?.totalCartons || 0) && Number(this.task?.unboundCartons || 0) === 0 }
|
||||
allCartonsCounted() { return Number(this.task?.totalCartons || 0) > 0 && Number(this.task?.countedCartons || 0) === Number(this.task?.totalCartons || 0) }
|
||||
},
|
||||
onLoad(options) { this.taskId = String(options.taskId || ''); this.warehouseId = String(options.warehouseId || '') },
|
||||
onShow() { if (!requireSession()) return; this.user = session.currentUser; this.startScanner(); this.loadTask() },
|
||||
@@ -78,16 +75,16 @@
|
||||
methods: {
|
||||
startScanner() { this.stopScanner(); this._stopScanner = startScanBroadcast({ onScan: (value) => this.handleScan(value), onError: () => { this.error = '扫码头连接失败,可使用输入框继续作业' } }) },
|
||||
stopScanner() { if (this._stopScanner) this._stopScanner(); this._stopScanner = null },
|
||||
handleScan(value) { if (this.activeScan === 'palletNo') { this.palletNo = String(value).trim().toUpperCase(); this.bindPending() } else { this.boxCode = String(value).trim().toUpperCase(); this.resolveCarton() } },
|
||||
handleScan(value) { this.boxCode = String(value).trim().toUpperCase(); this.resolveCarton() },
|
||||
resetMessages() { this.error = ''; this.notice = '' },
|
||||
async loadTask() {
|
||||
if (!this.taskId || !this.warehouseId) { this.error = '缺少合托任务或仓库信息,请返回任务列表'; return }
|
||||
this.loading = true; this.resetMessages()
|
||||
try { this.task = await getDropshipPalletizationTask(this.taskId, this.warehouseId) }
|
||||
catch (error) { this.error = formatApiError(error, '合托任务加载失败') }
|
||||
catch (error) { this.error = formatApiError(error, '一件代发入库任务加载失败') }
|
||||
finally { this.loading = false }
|
||||
},
|
||||
async claimTask() { await this.runMutation(() => claimDropshipPalletizationTask(this.taskId, Number(this.warehouseId)), '任务领取成功') },
|
||||
async claimTask() { await this.runMutation(() => claimDropshipPalletizationTask(this.taskId, this.warehouseId), '任务领取成功') },
|
||||
async resolveCarton(value) {
|
||||
const code = String(value || this.boxCode || '').trim().toUpperCase(); if (!code || this.loading) return
|
||||
this.boxCode = code; this.loading = true; this.resetMessages(); this.carton = null
|
||||
@@ -96,12 +93,25 @@
|
||||
finally { this.loading = false }
|
||||
},
|
||||
async countCarton() {
|
||||
const result = await this.runMutation(() => countDropshipCarton(this.taskId, { warehouseId: Number(this.warehouseId), boxCode: this.carton.boxCode, actualSkuQuantity: Number(this.actualQuantity), discrepancyAction: this.quantityDiffers ? 'ACCEPT_VARIANCE' : 'MATCH', discrepancyRemark: this.quantityDiffers ? this.discrepancyRemark.trim() : null, palletNo: null }), '本箱已清点,等待归托')
|
||||
const result = await this.runMutation(() => countDropshipCarton(this.taskId, { warehouseId: this.warehouseId, boxCode: this.carton.boxCode, actualSkuQuantity: Number(this.actualQuantity), discrepancyAction: this.quantityDiffers ? 'ACCEPT_VARIANCE' : 'MATCH', discrepancyRemark: this.quantityDiffers ? this.discrepancyRemark.trim() : null }), '本箱已完成入库清点')
|
||||
if (result) { this.boxCode = ''; this.carton = null; this.actualQuantity = ''; this.discrepancyRemark = '' }
|
||||
},
|
||||
async bindPending(value) { const code = String(value || this.palletNo || '').trim().toUpperCase(); if (!/^DP-\d{6}-\d{4}$/.test(code)) { this.error = '请输入正确的 DP 托盘码'; return }; this.palletNo = code; await this.runMutation(() => bindDropshipPendingCartons(this.taskId, Number(this.warehouseId), code), '待归托箱已绑定') },
|
||||
async createAndBind() { await this.runMutation(() => createAndBindDropshipPallet(this.taskId, Number(this.warehouseId)), '已生成 DP 托盘并绑定') },
|
||||
async sealPallet(pallet) { await this.runMutation(() => sealDropshipPallet(this.taskId, Number(this.warehouseId), pallet), `${pallet.palletNo} 已封托`) },
|
||||
async completeInbound() { await this.runMutation(() => createAndBindDropshipPallet(this.taskId, this.warehouseId), '入库已完成,正式托盘码已生成') },
|
||||
async printPallet(pallet) {
|
||||
if (this.printing || pallet.status !== 'SEALED') return
|
||||
this.printing = true; this.resetMessages()
|
||||
try {
|
||||
const filePath = await downloadDropshipPalletLabel(this.taskId, this.warehouseId, pallet.palletId)
|
||||
// #ifdef H5
|
||||
const link = document.createElement('a'); link.href = filePath; link.download = `${pallet.palletNo}-托盘码.pdf`; link.click()
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
await new Promise((resolve, reject) => uni.openDocument({ filePath, fileType: 'pdf', showMenu: true, success: resolve, fail: reject }))
|
||||
// #endif
|
||||
this.notice = `${pallet.palletNo} 打印文件已打开`
|
||||
} catch (error) { this.error = formatApiError(error, '托盘码打印失败') }
|
||||
finally { this.printing = false }
|
||||
},
|
||||
async runMutation(action, message) {
|
||||
if (this.submitting) return null
|
||||
this.submitting = true; this.resetMessages()
|
||||
@@ -124,7 +134,8 @@
|
||||
.content { padding: 12px 12px 42px; }
|
||||
.state, .message { margin-bottom: 10px; padding: 12px; border-radius: 9px; color: #667085; font-size: 12px; line-height: 18px; text-align: center; background: #fff; }
|
||||
.message.error { color: #b42318; background: #fff1f0; }.message.success { color: #067647; background: #ecfdf3; }
|
||||
.summary-card, .section-card { margin-bottom: 12px; padding: 13px; border: 1px solid #dce6f1; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(23,55,93,.05); }
|
||||
.task-summary-card, .section-card { margin-bottom: 12px; padding: 13px; border: 1px solid #dce6f1; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(23,55,93,.05); }
|
||||
.task-summary-card { display: block; }
|
||||
.summary-head, .section-heading, .pallet-head, .carton-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
|
||||
.summary-head > view { display: flex; min-width: 0; flex-direction: column; }.eyebrow { color: #667085; font-size: 10px; }.inbound-code { margin-top: 2px; color: #12233f; font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
|
||||
.status, .pallet-status { flex-shrink: 0; padding: 4px 8px; border-radius: 99px; color: #155eef; font-size: 10px; background: #eff4ff; }.pallet-status.sealed { color: #067647; background: #ecfdf3; }
|
||||
|
||||
Reference in New Issue
Block a user