- 盘点列表从详情页返回时自动刷新,保证状态与详情操作一致 - 默认列表仅展示 approved/checking/completed/cancelled 四种状态,过滤 created/submitted/rejected - 详情页移除提交审核入口(删除按钮、canSubmit 计算属性及 handleSubmitAudit 方法) - 盘点数量字段兼容 checked_quantity,回退 check_quantity(涉及列表行解析与回填两处)
1037 lines
28 KiB
Vue
1037 lines
28 KiB
Vue
<template>
|
||
<view class="inventory-count-detail-page">
|
||
<view class="normar_container">
|
||
<page-nav title="盘点操作"></page-nav>
|
||
|
||
<!-- 任务摘要 -->
|
||
<view class="summary-panel">
|
||
<view class="summary-panel__row">
|
||
<text class="summary-panel__label">盘点单号</text>
|
||
<text class="summary-panel__value summary-panel__value--strong">{{ taskInfo.checkNo || '--' }}</text>
|
||
</view>
|
||
<view v-if="taskInfo.title" class="summary-panel__row">
|
||
<text class="summary-panel__label">标题</text>
|
||
<text class="summary-panel__value">{{ taskInfo.title }}</text>
|
||
</view>
|
||
<view class="summary-panel__row">
|
||
<text class="summary-panel__label">盘点类型</text>
|
||
<text class="summary-panel__value">{{ taskInfo.typeText || '--' }}</text>
|
||
</view>
|
||
<view class="summary-panel__row">
|
||
<text class="summary-panel__label">状态</text>
|
||
<text class="summary-panel__value" :class="taskInfo.statusClass">{{ taskInfo.statusText || '--' }}</text>
|
||
</view>
|
||
<view class="summary-panel__row summary-panel__row--last">
|
||
<text class="summary-panel__label">进度</text>
|
||
<view class="summary-panel__value summary-panel__progress">
|
||
<text>{{ taskInfo.checkedItems || 0 }}/{{ taskInfo.totalItems || 0 }}</text>
|
||
<text v-if="taskInfo.detailStatusText" class="summary-panel__diff">· {{ taskInfo.detailStatusText }}</text>
|
||
<text v-if="taskInfo.diffItems" class="summary-panel__diff summary-panel__diff--warn">差异 {{ taskInfo.diffItems }} 条</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 扫码定位 -->
|
||
<view class="search-panel">
|
||
<view class="search-input-wrap">
|
||
<u-search
|
||
v-model="scanKeyword"
|
||
placeholder="扫码/输入商品条码快速定位"
|
||
:bg-color="'#f5f5f5'"
|
||
shape="round"
|
||
:show-action="false"
|
||
@search="handleLocateSearch"
|
||
@clear="handleLocateClear"
|
||
></u-search>
|
||
<view class="search-actions">
|
||
<view class="scan-btn" @click="handleCameraScan">
|
||
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
||
</view>
|
||
<view class="search-divider"></view>
|
||
<view class="search-btn" @click="handleLocateSearch">
|
||
<text class="search-btn__text">定位</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 商品列表 -->
|
||
<scroll-view class="detail-scroll" scroll-y :scroll-into-view="scrollIntoViewId" scroll-with-animation>
|
||
<view v-if="itemList.length === 0" class="empty-state">
|
||
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
|
||
<text class="empty-text">{{ loading ? '加载中...' : '暂无待盘商品' }}</text>
|
||
</view>
|
||
<view v-else class="item-list">
|
||
<view
|
||
v-for="(item, index) in itemList"
|
||
:key="item.key"
|
||
:id="`count-item-${item.key}`"
|
||
class="count-card"
|
||
:class="{ 'count-card--highlight': focusKey === item.key }"
|
||
>
|
||
<view class="count-card__head">
|
||
<view class="count-card__name-wrap">
|
||
<text class="count-card__name">{{ item.name || '--' }}</text>
|
||
<text class="count-card__barcode">{{ item.barcode || '--' }}</text>
|
||
<text v-if="item.spec" class="count-card__spec">规格:{{ item.spec }}</text>
|
||
<text v-if="item.batchNo" class="count-card__batch">批次:{{ item.batchNo }}</text>
|
||
</view>
|
||
<view class="count-card__space" v-if="item.locationCode">
|
||
<text class="count-card__space-text">{{ item.locationCode }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="count-card__body">
|
||
<view class="count-card__metric">
|
||
<text class="count-card__label">账面数量</text>
|
||
<text class="count-card__value">{{ item.systemQuantityText }}</text>
|
||
</view>
|
||
<view class="count-card__metric count-card__metric--input">
|
||
<text class="count-card__label">实盘数量</text>
|
||
<view class="count-card__input-wrap" :class="{ 'count-card__input-wrap--reported': item.reported }">
|
||
<input
|
||
class="count-card__input"
|
||
type="number"
|
||
:disabled="!canEdit"
|
||
:focus="focusKey === item.key"
|
||
v-model="item.inputValue"
|
||
placeholder="请输入"
|
||
placeholder-style="color: #c0c4cc; font-size: 34rpx;"
|
||
@focus="handleItemFocus(item)"
|
||
@blur="handleItemBlur(item)"
|
||
@confirm="handleItemBlur(item)"
|
||
/>
|
||
<text v-if="item.reported" class="count-card__checked-icon">
|
||
<u-icon name="checkmark-circle-fill" size="34rpx" color="#18a058"></u-icon>
|
||
</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view v-if="item.diffText" class="count-card__diff" :class="item.diffClass">
|
||
<text class="count-card__diff-text">{{ item.diffText }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="safe-area-bottom"></view>
|
||
</scroll-view>
|
||
|
||
<!-- 底部操作 -->
|
||
<view class="footer-bar">
|
||
<view v-if="canCancel" class="footer-bar__btn footer-bar__btn--secondary" @click="handleCancel">
|
||
<text class="footer-bar__btn-text">取消任务</text>
|
||
</view>
|
||
<view v-if="canFinish" class="footer-bar__btn" @click="handleFinish">
|
||
<text class="footer-bar__btn-text">{{ submitting ? '提交中...' : '完成盘点' }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
taskId: '',
|
||
taskInfo: {},
|
||
scanKeyword: '',
|
||
itemList: [],
|
||
focusKey: '',
|
||
scrollIntoViewId: '',
|
||
loading: false,
|
||
submitting: false
|
||
}
|
||
},
|
||
computed: {
|
||
status() {
|
||
return String(this.taskInfo.status || '').trim().toLowerCase();
|
||
},
|
||
canEdit() {
|
||
return this.status === 'approved' || this.status === 'checking';
|
||
},
|
||
canFinish() {
|
||
return this.status === 'approved' || this.status === 'checking';
|
||
},
|
||
canCancel() {
|
||
return this.status === 'created' || this.status === 'submitted' || this.status === 'rejected';
|
||
}
|
||
},
|
||
onLoad(options = {}) {
|
||
this.taskId = String(options.id || options.taskId || '').trim();
|
||
if (this.taskId) {
|
||
this.loadTaskDetail();
|
||
}
|
||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||
this.safeDispatchBroadcast('start');
|
||
},
|
||
onShow() {
|
||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||
this.safeDispatchBroadcast('resume');
|
||
this.scheduleBroadcastSelfHeal();
|
||
},
|
||
onHide() {
|
||
this.safeDispatchBroadcast('pause');
|
||
},
|
||
onUnload() {
|
||
if (this._broadcastHealTimer) {
|
||
clearTimeout(this._broadcastHealTimer);
|
||
this._broadcastHealTimer = null;
|
||
}
|
||
this.safeDispatchBroadcast('stop');
|
||
},
|
||
methods: {
|
||
// ===== 广播/扫码基础设施 =====
|
||
safeDispatchBroadcast(action, payload) {
|
||
try {
|
||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||
if (task && typeof task.catch === 'function') {
|
||
task.catch(error => console.warn(`[inventoryCountDetail] broadcast/${action} 调用失败:`, error));
|
||
}
|
||
} catch (error) {
|
||
console.warn(`[inventoryCountDetail] broadcast/${action} 调用异常:`, error);
|
||
}
|
||
},
|
||
scheduleBroadcastSelfHeal() {
|
||
if (this._broadcastHealTimer) {
|
||
clearTimeout(this._broadcastHealTimer);
|
||
}
|
||
this._broadcastHealTimer = setTimeout(() => {
|
||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||
this.safeDispatchBroadcast('start');
|
||
}, 1200);
|
||
},
|
||
normalizeScanResult(scanResult) {
|
||
if (!scanResult) return '';
|
||
if (typeof scanResult === 'string') return scanResult.trim();
|
||
if (typeof scanResult.result === 'string') return scanResult.result.trim();
|
||
if (Array.isArray(scanResult.result)) {
|
||
const first = scanResult.result.find(item => item);
|
||
if (typeof first === 'string') return first.trim();
|
||
if (first && typeof first.data === 'string') return first.data.trim();
|
||
}
|
||
if (typeof scanResult.data === 'string') return scanResult.data.trim();
|
||
return '';
|
||
},
|
||
handleBroadcastResult(result) {
|
||
const code = this.normalizeScanResult(result);
|
||
if (!code) return;
|
||
this.scanKeyword = code;
|
||
this.locateItem(code);
|
||
},
|
||
handleCameraScan() {
|
||
uni.scanCode({
|
||
onlyFromCamera: true,
|
||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||
success: (res) => {
|
||
const code = this.normalizeScanResult(res);
|
||
if (!code) return;
|
||
this.scanKeyword = code;
|
||
this.locateItem(code);
|
||
},
|
||
fail: () => {}
|
||
});
|
||
},
|
||
// ===== 扫码定位 =====
|
||
handleLocateSearch() {
|
||
this.locateItem(this.scanKeyword);
|
||
},
|
||
handleLocateClear() {
|
||
this.scanKeyword = '';
|
||
this.focusKey = '';
|
||
},
|
||
locateItem(code) {
|
||
const keyword = String(code || '').trim();
|
||
if (!keyword) return;
|
||
const target = this.itemList.find(item => {
|
||
return [item.barcode, item.name].some(field => field && String(field).trim() === keyword);
|
||
});
|
||
if (!target) {
|
||
uni.showToast({ title: '未找到匹配商品', icon: 'none' });
|
||
return;
|
||
}
|
||
this.focusKey = target.key;
|
||
this.scrollIntoViewId = `count-item-${target.key}`;
|
||
this.$nextTick(() => {
|
||
setTimeout(() => {
|
||
this.scrollIntoViewId = '';
|
||
}, 800);
|
||
});
|
||
},
|
||
handleItemFocus(item) {
|
||
this.focusKey = item.key;
|
||
},
|
||
// ===== 字段归一化 =====
|
||
firstValue(source, keys) {
|
||
for (let i = 0; i < keys.length; i += 1) {
|
||
const value = source[keys[i]];
|
||
if (value !== null && value !== undefined && String(value).trim() !== '') {
|
||
return String(value).trim();
|
||
}
|
||
}
|
||
return '';
|
||
},
|
||
statusText(status) {
|
||
const map = {
|
||
created: '待提交',
|
||
submitted: '待审核',
|
||
rejected: '已驳回',
|
||
approved: '待盘点',
|
||
checking: '盘点中',
|
||
completed: '已完成',
|
||
cancelled: '已取消'
|
||
};
|
||
const key = String(status || '').trim().toLowerCase();
|
||
return map[key] || (status ? String(status) : '--');
|
||
},
|
||
statusClass(status) {
|
||
const key = String(status || '').trim().toLowerCase();
|
||
if (key === 'completed') return 'summary-panel__value--success';
|
||
if (key === 'checking') return 'summary-panel__value--warning';
|
||
if (key === 'rejected') return 'summary-panel__value--danger';
|
||
if (key === 'cancelled') return 'summary-panel__value--muted';
|
||
if (key === 'approved') return 'summary-panel__value--strong';
|
||
return '';
|
||
},
|
||
detailStatusText(status) {
|
||
const map = {
|
||
none_checked: '未盘',
|
||
partial_checked: '部分已盘',
|
||
all_checked: '全部已盘'
|
||
};
|
||
const key = String(status || '').trim().toLowerCase();
|
||
return map[key] || '';
|
||
},
|
||
typeText(type) {
|
||
const map = {
|
||
all: '全盘',
|
||
full: '全盘',
|
||
open: '明盘',
|
||
store: '按货主',
|
||
part: '抽盘',
|
||
partial: '抽盘',
|
||
dynamic: '动销盘',
|
||
cycle: '循环盘'
|
||
};
|
||
const key = String(type || '').trim().toLowerCase();
|
||
return map[key] || (type ? String(type) : '--');
|
||
},
|
||
modeText(mode) {
|
||
const map = {
|
||
all: '全盘',
|
||
full: '全盘',
|
||
open: '明盘',
|
||
store: '按货主',
|
||
by_store: '按货主',
|
||
owner: '按货主',
|
||
by_owner: '按货主',
|
||
space: '按库位',
|
||
by_space: '按库位',
|
||
location: '按库位',
|
||
item: '按商品',
|
||
by_item: '按商品',
|
||
product: '按商品'
|
||
};
|
||
const key = String(mode || '').trim().toLowerCase();
|
||
return map[key] || (mode ? String(mode) : '');
|
||
},
|
||
composeType(type, mode) {
|
||
const t = this.typeText(type);
|
||
const m = this.modeText(mode);
|
||
if (t === '--') return m || '--';
|
||
return m ? `${t},${m}` : t;
|
||
},
|
||
extractDetailPayload(response) {
|
||
const candidates = [
|
||
response?.data?.data,
|
||
response?.data,
|
||
response?.result,
|
||
response
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
const current = candidates[i];
|
||
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
||
return current;
|
||
}
|
||
}
|
||
return {};
|
||
},
|
||
extractItemList(payload, response) {
|
||
const candidates = [
|
||
payload?.items,
|
||
payload?.list,
|
||
payload?.rows,
|
||
payload?.records,
|
||
payload?.details,
|
||
payload?.data?.list,
|
||
payload?.data?.items,
|
||
response?.data?.list,
|
||
response?.data?.data?.list,
|
||
response?.list
|
||
];
|
||
for (let i = 0; i < candidates.length; i += 1) {
|
||
if (Array.isArray(candidates[i])) return candidates[i];
|
||
}
|
||
return [];
|
||
},
|
||
normalizeTaskInfo(check) {
|
||
const source = check && typeof check === 'object' ? check : {};
|
||
const checkNo = this.firstValue(source, ['check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no']);
|
||
const title = this.firstValue(source, ['title', 'name']);
|
||
const typeValue = this.firstValue(source, ['check_type', 'checkType', 'type']);
|
||
const modeValue = this.firstValue(source, ['mode', 'check_mode', 'checkMode']);
|
||
const status = this.firstValue(source, ['status', 'check_status', 'checkStatus', 'state']);
|
||
const totalItems = Number(this.firstValue(source, ['total_items', 'totalItems'])) || 0;
|
||
const checkedItems = Number(this.firstValue(source, ['checked_items', 'checkedItems'])) || 0;
|
||
const diffItems = Number(this.firstValue(source, ['diff_items', 'diffItems'])) || 0;
|
||
const detailStatus = this.firstValue(source, ['detail_status', 'detailStatus']);
|
||
return {
|
||
checkNo,
|
||
title,
|
||
typeText: this.composeType(typeValue, modeValue),
|
||
status,
|
||
statusText: this.statusText(status),
|
||
statusClass: this.statusClass(status),
|
||
totalItems,
|
||
checkedItems,
|
||
diffItems,
|
||
detailStatus,
|
||
detailStatusText: this.detailStatusText(detailStatus)
|
||
};
|
||
},
|
||
normalizeItemList(list) {
|
||
if (!Array.isArray(list)) return [];
|
||
return list.map((item, index) => {
|
||
const source = item && typeof item === 'object' ? item : {};
|
||
const barcode = this.firstValue(source, ['item_code', 'itemCode', 'barcode', 'bar_code']);
|
||
const name = this.firstValue(source, ['item_name', 'itemName', 'product_name', 'name', 'stock_name']);
|
||
const spec = this.firstValue(source, ['spec', 'specification', 'sku_property']);
|
||
const batchNo = this.firstValue(source, ['batch_no', 'batchNo', 'batch_number']);
|
||
const locationCode = this.firstValue(source, ['location_code', 'locationCode', 'space_code', 'spaceCode']);
|
||
const systemRaw = this.firstValue(source, ['system_quantity', 'systemQuantity', 'book_quantity', 'stock_quantity', 'quantity']);
|
||
const checkRaw = this.firstValue(source, ['checked_quantity', 'checkedQuantity', 'check_quantity', 'checkQuantity']);
|
||
const diffRaw = this.firstValue(source, ['diff_quantity', 'diffQuantity']);
|
||
const detailId = this.firstValue(source, ['id', 'detail_id', 'detailId']) || `${index + 1}`;
|
||
const systemNumber = systemRaw === '' ? null : Number(systemRaw);
|
||
const checkNumber = checkRaw === '' ? null : Number(checkRaw);
|
||
const diffNumber = diffRaw === '' ? null : Number(diffRaw);
|
||
const reported = checkRaw !== '';
|
||
const normalized = {
|
||
key: `${index + 1}`,
|
||
detailId,
|
||
barcode,
|
||
name,
|
||
spec,
|
||
batchNo,
|
||
locationCode,
|
||
systemQuantity: Number.isFinite(systemNumber) ? systemNumber : null,
|
||
systemQuantityText: systemRaw === '' ? '--' : (Number.isFinite(systemNumber) ? String(systemNumber) : systemRaw),
|
||
checkQuantity: Number.isFinite(checkNumber) ? checkNumber : null,
|
||
diffQuantity: Number.isFinite(diffNumber) ? diffNumber : null,
|
||
reported,
|
||
inputValue: reported ? String(checkNumber) : '',
|
||
diffText: '',
|
||
diffClass: '',
|
||
reporting: false
|
||
};
|
||
this.applyDiffText(normalized);
|
||
return normalized;
|
||
});
|
||
},
|
||
// ===== 差异计算与逐条上报 =====
|
||
applyDiffText(item) {
|
||
if (!item.reported) {
|
||
item.diffText = '';
|
||
item.diffClass = '';
|
||
return;
|
||
}
|
||
const diff = item.diffQuantity;
|
||
if (!Number.isFinite(diff)) {
|
||
item.diffText = '';
|
||
item.diffClass = '';
|
||
return;
|
||
}
|
||
if (diff > 0) {
|
||
item.diffText = `盘盈 +${diff}`;
|
||
item.diffClass = 'count-card__diff--gain';
|
||
} else if (diff < 0) {
|
||
item.diffText = `盘亏 ${diff}`;
|
||
item.diffClass = 'count-card__diff--loss';
|
||
} else {
|
||
item.diffText = '账实相符';
|
||
item.diffClass = 'count-card__diff--match';
|
||
}
|
||
},
|
||
handleItemBlur(item) {
|
||
if (!this.canEdit) return;
|
||
const raw = String(item.inputValue || '').trim();
|
||
if (raw === '') return;
|
||
if (item.checkQuantity !== null && Number(raw) === item.checkQuantity) return;
|
||
this.reportItem(item);
|
||
},
|
||
updateProgress(response) {
|
||
if (!response || typeof response !== 'object') return;
|
||
if (response.total_items !== undefined && response.total_items !== null) {
|
||
this.taskInfo.totalItems = Number(response.total_items) || 0;
|
||
}
|
||
if (response.checked_items !== undefined && response.checked_items !== null) {
|
||
this.taskInfo.checkedItems = Number(response.checked_items) || 0;
|
||
}
|
||
if (response.diff_items !== undefined && response.diff_items !== null) {
|
||
this.taskInfo.diffItems = Number(response.diff_items) || 0;
|
||
}
|
||
if (response.detail_status) {
|
||
this.taskInfo.detailStatus = response.detail_status;
|
||
this.taskInfo.detailStatusText = this.detailStatusText(response.detail_status);
|
||
}
|
||
},
|
||
async reportItem(item) {
|
||
if (!this.canEdit || item.reporting) return;
|
||
const raw = String(item.inputValue || '').trim();
|
||
if (raw === '') return;
|
||
const quantity = Number(raw);
|
||
if (!Number.isInteger(quantity) || quantity < 0) {
|
||
uni.showToast({ title: '实盘数量须为不小于0的整数', icon: 'none' });
|
||
return;
|
||
}
|
||
item.reporting = true;
|
||
try {
|
||
const response = await this.$http('check.report', {
|
||
id: Number(this.taskId),
|
||
detail_id: Number(item.detailId),
|
||
location: item.locationCode || '',
|
||
quantity
|
||
});
|
||
if (response?.flag === 'failure') {
|
||
uni.showToast({ title: response.message || '上报失败', icon: 'none' });
|
||
return;
|
||
}
|
||
const detail = (response && typeof response === 'object') ? (response.detail || {}) : {};
|
||
const checkQtyRaw = detail.checked_quantity !== undefined && detail.checked_quantity !== null
|
||
? detail.checked_quantity : detail.check_quantity;
|
||
const checkQty = checkQtyRaw !== undefined && checkQtyRaw !== null
|
||
? Number(checkQtyRaw) : quantity;
|
||
item.checkQuantity = checkQty;
|
||
item.inputValue = String(checkQty);
|
||
item.diffQuantity = detail.diff_quantity !== undefined && detail.diff_quantity !== null
|
||
? Number(detail.diff_quantity)
|
||
: (item.systemQuantity === null ? 0 : checkQty - item.systemQuantity);
|
||
item.isDiff = detail.is_diff !== undefined && detail.is_diff !== null
|
||
? !!detail.is_diff : (item.diffQuantity !== 0);
|
||
item.reported = true;
|
||
this.applyDiffText(item);
|
||
this.updateProgress(response);
|
||
uni.showToast({ title: '已记录', icon: 'success', duration: 600 });
|
||
} catch (error) {
|
||
console.error('[inventoryCountDetail] 盘点上报失败:', error);
|
||
uni.showToast({ title: '盘点上报失败', icon: 'none' });
|
||
} finally {
|
||
item.reporting = false;
|
||
}
|
||
},
|
||
// ===== 加载与提交 =====
|
||
async loadTaskDetail() {
|
||
this.loading = true;
|
||
try {
|
||
const response = await this.$http('check.detail', { id: Number(this.taskId) });
|
||
const payload = this.extractDetailPayload(response);
|
||
this.taskInfo = this.normalizeTaskInfo(payload.check);
|
||
this.itemList = this.normalizeItemList(this.extractItemList(payload, response));
|
||
} catch (error) {
|
||
console.error('[inventoryCountDetail] 盘点明细加载失败:', error);
|
||
this.itemList = [];
|
||
uni.showToast({ title: '盘点明细加载失败', icon: 'none' });
|
||
} finally {
|
||
this.loading = false;
|
||
}
|
||
},
|
||
async handleFinish() {
|
||
if (this.submitting || !this.taskId) return;
|
||
uni.showModal({
|
||
title: '完成盘点',
|
||
content: '确认全部明细已盘点并完成该盘点任务?',
|
||
confirmText: '完成',
|
||
cancelText: '再想想',
|
||
success: async (res) => {
|
||
if (!res.confirm) return;
|
||
this.submitting = true;
|
||
try {
|
||
const response = await this.$http('check.finish', { id: Number(this.taskId) });
|
||
if (response?.flag === 'failure') {
|
||
uni.showToast({ title: response.message || '完成失败', icon: 'none' });
|
||
return;
|
||
}
|
||
const profit = Number(response?.profit_total) || 0;
|
||
const loss = Number(response?.loss_total) || 0;
|
||
let title = '盘点完成';
|
||
if (profit || loss) {
|
||
title = `盘点完成 盘盈${profit} 盘亏${loss}`;
|
||
}
|
||
uni.showModal({
|
||
title,
|
||
content: '该盘点任务已完成。',
|
||
showCancel: false,
|
||
confirmText: '返回列表',
|
||
success: () => {
|
||
setTimeout(() => uni.navigateBack({ delta: 1, fail: () => {} }), 200);
|
||
}
|
||
});
|
||
} catch (error) {
|
||
console.error('[inventoryCountDetail] 完成盘点失败:', error);
|
||
uni.showToast({ title: '完成盘点失败', icon: 'none' });
|
||
} finally {
|
||
this.submitting = false;
|
||
}
|
||
}
|
||
});
|
||
},
|
||
handleCancel() {
|
||
if (this.submitting || !this.taskId) return;
|
||
uni.showModal({
|
||
title: '取消盘点任务',
|
||
content: '确定取消该盘点任务?取消后不可恢复。',
|
||
confirmText: '确定取消',
|
||
cancelText: '再想想',
|
||
success: async (res) => {
|
||
if (!res.confirm) return;
|
||
await this.doStatusAction('check.cancel', '已取消');
|
||
}
|
||
});
|
||
},
|
||
async doStatusAction(api, successText) {
|
||
this.submitting = true;
|
||
try {
|
||
const response = await this.$http(api, { id: Number(this.taskId) });
|
||
if (response?.flag === 'failure') {
|
||
uni.showToast({ title: response.message || '操作失败', icon: 'none' });
|
||
return;
|
||
}
|
||
uni.showToast({ title: successText, icon: 'success' });
|
||
setTimeout(() => uni.navigateBack({ delta: 1, fail: () => {} }), 600);
|
||
} catch (error) {
|
||
console.error(`[inventoryCountDetail] ${api} 失败:`, error);
|
||
uni.showToast({ title: '操作失败', icon: 'none' });
|
||
} finally {
|
||
this.submitting = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.inventory-count-detail-page {
|
||
height: 100vh;
|
||
background: #f8f9fa;
|
||
}
|
||
|
||
.normar_container {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
|
||
/* 任务摘要 */
|
||
.summary-panel {
|
||
background: #ffffff;
|
||
border-bottom: 1rpx solid #f2f2f2;
|
||
padding: 20rpx 28rpx;
|
||
box-sizing: border-box;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.summary-panel__row {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
padding: 10rpx 0;
|
||
}
|
||
|
||
.summary-panel__row--last {
|
||
padding-bottom: 0;
|
||
}
|
||
|
||
.summary-panel__label {
|
||
flex-shrink: 0;
|
||
width: 160rpx;
|
||
font-size: 32rpx;
|
||
color: #8a9099;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.summary-panel__value {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: 34rpx;
|
||
color: #303133;
|
||
line-height: 1.5;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.summary-panel__value--strong {
|
||
font-weight: 600;
|
||
color: #2979ff;
|
||
}
|
||
|
||
.summary-panel__value--success {
|
||
font-weight: 600;
|
||
color: #18a058;
|
||
}
|
||
|
||
.summary-panel__value--warning {
|
||
font-weight: 600;
|
||
color: #ff9800;
|
||
}
|
||
|
||
/* 扫码定位 */
|
||
.search-panel {
|
||
background: #ffffff;
|
||
border-bottom: 1rpx solid #f2f2f2;
|
||
padding: 16rpx;
|
||
box-sizing: border-box;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.search-input-wrap {
|
||
position: relative;
|
||
|
||
::v-deep .u-search {
|
||
width: 100%;
|
||
}
|
||
|
||
::v-deep .u-search__content {
|
||
padding-right: 200rpx;
|
||
}
|
||
}
|
||
|
||
.search-actions {
|
||
position: absolute;
|
||
right: 24rpx;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
height: 68rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.scan-btn {
|
||
height: 68rpx;
|
||
padding: 0 8rpx 0 4rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
&:active {
|
||
opacity: 0.88;
|
||
}
|
||
}
|
||
|
||
.search-divider {
|
||
width: 1rpx;
|
||
height: 28rpx;
|
||
background: #dcdfe6;
|
||
margin: 0 16rpx 0 10rpx;
|
||
}
|
||
|
||
.search-btn {
|
||
height: 68rpx;
|
||
padding: 0 8rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
|
||
&__text {
|
||
font-size: 34rpx;
|
||
font-weight: 500;
|
||
color: #2979ff;
|
||
line-height: 1;
|
||
}
|
||
|
||
&:active {
|
||
opacity: 0.88;
|
||
}
|
||
}
|
||
|
||
/* 商品列表 */
|
||
.detail-scroll {
|
||
flex: 1;
|
||
min-height: 0;
|
||
height: auto;
|
||
padding: 20rpx 0 0;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.empty-state {
|
||
padding: 160rpx 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.empty-text {
|
||
margin-top: 24rpx;
|
||
font-size: 36rpx;
|
||
color: #909399;
|
||
}
|
||
|
||
.item-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
padding: 0 12rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.count-card {
|
||
background: #ffffff;
|
||
border: 2rpx solid #ebedf2;
|
||
border-radius: 20rpx;
|
||
padding: 20rpx 28rpx;
|
||
margin-bottom: 20rpx;
|
||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||
transition: border-color 0.3s ease, background-color 0.3s ease;
|
||
}
|
||
|
||
.count-card--highlight {
|
||
border-color: #2979ff;
|
||
background: #eef4ff;
|
||
box-shadow: 0 6rpx 20rpx rgba(41, 121, 255, 0.22);
|
||
}
|
||
|
||
.count-card__head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.count-card__name-wrap {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.count-card__name {
|
||
font-size: 38rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
line-height: 1.4;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.count-card__barcode {
|
||
margin-top: 6rpx;
|
||
font-size: 30rpx;
|
||
color: #8a9099;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.count-card__space {
|
||
flex-shrink: 0;
|
||
max-width: 40%;
|
||
margin-left: 16rpx;
|
||
background: #f5f7fa;
|
||
border-radius: 10rpx;
|
||
padding: 6rpx 14rpx;
|
||
}
|
||
|
||
.count-card__space-text {
|
||
font-size: 28rpx;
|
||
color: #606266;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.count-card__body {
|
||
margin-top: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.count-card__metric {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.count-card__metric--input {
|
||
margin-left: 20rpx;
|
||
}
|
||
|
||
.count-card__label {
|
||
font-size: 28rpx;
|
||
color: #8a9099;
|
||
}
|
||
|
||
.count-card__value {
|
||
margin-top: 8rpx;
|
||
font-size: 40rpx;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.count-card__input-wrap {
|
||
margin-top: 8rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
height: 68rpx;
|
||
background: #f5f7fa;
|
||
border: 1rpx solid #ebeef5;
|
||
border-radius: 12rpx;
|
||
padding: 0 16rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.count-card__input {
|
||
flex: 1;
|
||
min-width: 0;
|
||
height: 100%;
|
||
font-size: 36rpx;
|
||
color: #303133;
|
||
}
|
||
|
||
.count-card__unit {
|
||
flex-shrink: 0;
|
||
margin-left: 10rpx;
|
||
font-size: 28rpx;
|
||
color: #8a9099;
|
||
}
|
||
|
||
.count-card__diff {
|
||
margin-top: 16rpx;
|
||
padding: 10rpx 16rpx;
|
||
border-radius: 10rpx;
|
||
display: inline-flex;
|
||
}
|
||
|
||
.count-card__diff--gain {
|
||
background: #e8f7ee;
|
||
}
|
||
|
||
.count-card__diff--gain .count-card__diff-text {
|
||
color: #18a058;
|
||
}
|
||
|
||
.count-card__diff--loss {
|
||
background: #fdecec;
|
||
}
|
||
|
||
.count-card__diff--loss .count-card__diff-text {
|
||
color: #e64340;
|
||
}
|
||
|
||
.count-card__diff--match {
|
||
background: #f5f7fa;
|
||
}
|
||
|
||
.count-card__diff--match .count-card__diff-text {
|
||
color: #606266;
|
||
}
|
||
|
||
.count-card__diff-text {
|
||
font-size: 28rpx;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.safe-area-bottom {
|
||
height: calc(20rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
/* 底部提交栏(多按钮) */
|
||
.footer-bar {
|
||
flex-shrink: 0;
|
||
padding: 16rpx 24rpx;
|
||
padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
|
||
background: #ffffff;
|
||
border-top: 1rpx solid #f2f2f2;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.footer-bar__btn {
|
||
flex: 1;
|
||
height: 88rpx;
|
||
background: #2979ff;
|
||
border-radius: 44rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 8rpx 20rpx rgba(41, 121, 255, 0.32);
|
||
|
||
&:active {
|
||
opacity: 0.9;
|
||
}
|
||
}
|
||
|
||
.footer-bar__btn + .footer-bar__btn {
|
||
margin-left: 20rpx;
|
||
}
|
||
|
||
.footer-bar__btn--secondary {
|
||
background: #f5f7fa;
|
||
border: 1rpx solid #dcdfe6;
|
||
box-shadow: none;
|
||
|
||
.footer-bar__btn-text {
|
||
color: #606266;
|
||
}
|
||
}
|
||
|
||
.footer-bar__btn--disabled {
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.footer-bar__btn-text {
|
||
font-size: 36rpx;
|
||
font-weight: 600;
|
||
color: #ffffff;
|
||
}
|
||
|
||
/* 状态/进度补充 */
|
||
.summary-panel__value--danger {
|
||
font-weight: 600;
|
||
color: #e64340;
|
||
}
|
||
|
||
.summary-panel__value--muted {
|
||
color: #c0c4cc;
|
||
}
|
||
|
||
.summary-panel__progress {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.summary-panel__diff {
|
||
margin-left: 16rpx;
|
||
font-size: 30rpx;
|
||
color: #8a9099;
|
||
}
|
||
|
||
.summary-panel__diff--warn {
|
||
color: #ff9800;
|
||
}
|
||
|
||
/* 商品卡片补充字段 */
|
||
.count-card__spec,
|
||
.count-card__batch {
|
||
margin-top: 6rpx;
|
||
font-size: 28rpx;
|
||
color: #909399;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.count-card__checked-icon {
|
||
flex-shrink: 0;
|
||
margin-left: 10rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.count-card__input-wrap--reported {
|
||
background: #e8f7ee;
|
||
border-color: #b7e4c7;
|
||
}
|
||
</style>
|