refactor(warehouse): 盘点列表/详情拆分复用组件并新增库位明细子页
- 抽出 inventoryCount-comps/:countModel 纯函数 + 记录卡片/工具栏/汇总面板/搜索面板/明细面板/宫格/添加商品弹窗等 - 新增 pages/warehouse/inventoryCountLocation 库位明细子页(workDataDetail + 扫码预填添加商品 + 左滑删除记录) - apis.js 补 result / workData / workDataDetail / recordDelete / addDetail / addLocationDetail 别名 - pages.json 注册新页面
This commit is contained in:
parent
c924b5c0fb
commit
fd3228eac3
@ -443,6 +443,34 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点明细结果(按范围行聚合作业记录):返回 { check, rows, total },
|
||||
// rows 含已盘/差异聚合 + 作业记录/库位/未知商品;无状态限制(已完成任务也能拉)
|
||||
result: {
|
||||
path: "stock.check.result",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点作业数据:入参 id + is_goods + keyword + pagination;视图由任务范围与 is_goods 驱动
|
||||
// (库位任务一律 location 视图;商品任务默认 space 聚合库位视图,is_goods=true 为 goods 商品视图)
|
||||
// keyword 仅 location 视图生效(按 location_code/location_name 模糊匹配后分页)
|
||||
// 仅任务状态 approved/checking 可拉取,其他状态返回 400
|
||||
workData: {
|
||||
path: "stock.check.workData",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 单条盘点明细的作业数据(workData 单行版,仅库位任务明细):
|
||||
// 入参仅 detail_id(兼容 detailId),warehouse_id 由服务端注入;
|
||||
// 返回 data 为单行 location 结构(detail_id/location_id/location_code/location_name/
|
||||
// status/has_unknown/is_empty/checked_at/checkers/goods),仅 approved/checking 可拉取
|
||||
workDataDetail: {
|
||||
path: "stock.check.workDataDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点作业上报:单条明细实盘数量(quantity>=0 整数)
|
||||
report: {
|
||||
path: "stock.check.report",
|
||||
@ -450,6 +478,14 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 删除盘点作业记录(批量:record_ids 数组,单次≤200,兼容单值 recordId/record_id)
|
||||
// 仅 approved/checking 允许;查不到的 ID 计入 skipped_ids 不报错;删除后重算进度、主表状态不回退
|
||||
recordDelete: {
|
||||
path: "stock.check.recordDelete",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 完成盘点作业:主表置 completed
|
||||
finish: {
|
||||
path: "stock.check.finish",
|
||||
@ -470,6 +506,22 @@ export default {
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 添加盘点明细(按任务盘点类型决定维度):商品任务传 stock_ids;
|
||||
// 库位任务传 locations/location_ids(location_ids 优先),type=all 两者都不传则自动拉全仓启用库位
|
||||
// 仅 created/rejected 允许;已存在的盘点项自动跳过(幂等);完成后重算主表 total_items
|
||||
addDetail: {
|
||||
path: "stock.check.addDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 批量添加库位明细(兼容入口,转调 addDetail 的库位ID直查路径)
|
||||
addLocationDetail: {
|
||||
path: "stock.check.addLocationDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
},
|
||||
pick: {
|
||||
|
||||
@ -138,6 +138,13 @@
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/warehouse/inventoryCountLocation",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/403",
|
||||
"style" :
|
||||
|
||||
163
src/pages/warehouse/inventoryCount-comps/CountActionsPopup.vue
Normal file
163
src/pages/warehouse/inventoryCount-comps/CountActionsPopup.vue
Normal file
@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<u-popup :show="show" mode="bottom" :closeable="true" border-radius="20" @close="$emit('close')">
|
||||
<view class="actions-popup">
|
||||
<view class="actions-popup-title">{{ title }}</view>
|
||||
<view class="actions-popup-body">
|
||||
<view
|
||||
v-if="canMarkEmpty"
|
||||
class="actions-popup-btn actions-popup-btn--cancel"
|
||||
@click="$emit('mark-empty')"
|
||||
>
|
||||
<text class="actions-popup-btn__text actions-popup-btn__text--cancel">{{ submitting ? '处理中...' : '标记空库位' }}</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="canCancel"
|
||||
class="actions-popup-btn actions-popup-btn--cancel"
|
||||
@click="$emit('cancel')"
|
||||
>
|
||||
<text class="actions-popup-btn__text actions-popup-btn__text--cancel">取消任务</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="canSubmit"
|
||||
class="actions-popup-btn actions-popup-btn--submit"
|
||||
@click="$emit('submit')"
|
||||
>
|
||||
<text class="actions-popup-btn__text actions-popup-btn__text--submit">{{ submitting ? '提交中...' : '提交审核' }}</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="canFinish"
|
||||
class="actions-popup-btn actions-popup-btn--complete"
|
||||
@click="$emit('finish')"
|
||||
>
|
||||
<text class="actions-popup-btn__text actions-popup-btn__text--complete">{{ submitting ? '提交中...' : '完成盘点' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="actions-popup-footer">
|
||||
<view class="actions-popup-close-btn" @click="$emit('close')">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** 盘点右上角「...」操作菜单(写法参考 pages/work/order/picking.vue) */
|
||||
export default {
|
||||
name: 'CountActionsPopup',
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '盘点操作'
|
||||
},
|
||||
canFinish: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
canCancel: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
canSubmit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 库位明细页:菜单内「标记空库位」
|
||||
canMarkEmpty: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
submitting: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.actions-popup {
|
||||
padding: 48rpx 32rpx calc(40rpx + env(safe-area-inset-bottom));
|
||||
background: #ffffff;
|
||||
border-top-left-radius: 20rpx;
|
||||
border-top-right-radius: 20rpx;
|
||||
}
|
||||
|
||||
.actions-popup-title {
|
||||
font-size: 38rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
margin-bottom: 36rpx;
|
||||
}
|
||||
|
||||
.actions-popup-body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.actions-popup-btn {
|
||||
flex: 1 1 200rpx;
|
||||
height: 100rpx;
|
||||
margin: 0 10rpx 20rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.actions-popup-btn--cancel {
|
||||
background: #fff1f0;
|
||||
border: 2rpx solid #ffccc7;
|
||||
}
|
||||
|
||||
.actions-popup-btn--submit {
|
||||
background: #eef4ff;
|
||||
border: 2rpx solid #cfe1ff;
|
||||
}
|
||||
|
||||
.actions-popup-btn--complete {
|
||||
background: #2979ff;
|
||||
border: 2rpx solid #2979ff;
|
||||
}
|
||||
|
||||
.actions-popup-btn__text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.actions-popup-btn__text--cancel {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.actions-popup-btn__text--submit {
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.actions-popup-btn__text--complete {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.actions-popup-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.actions-popup-close-btn {
|
||||
padding: 16rpx 48rpx;
|
||||
font-size: 34rpx;
|
||||
color: #909399;
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 10rpx;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
</style>
|
||||
309
src/pages/warehouse/inventoryCount-comps/CountDetailPicker.vue
Normal file
309
src/pages/warehouse/inventoryCount-comps/CountDetailPicker.vue
Normal file
@ -0,0 +1,309 @@
|
||||
<template>
|
||||
<u-popup :show="show" mode="bottom" round="20" :closeable="true" :safeAreaInsetBottom="true" @close="handleClose">
|
||||
<view class="picker">
|
||||
<view class="picker__header">
|
||||
<text class="picker__title">{{ title }}</text>
|
||||
<text class="picker__subtitle">{{ subtitle }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 搜索/扫码 -->
|
||||
<view class="picker__search">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
:placeholder="placeholder"
|
||||
bg-color="#f5f5f5"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleSearch"
|
||||
@clear="handleSearch"
|
||||
></u-search>
|
||||
</view>
|
||||
|
||||
<!-- type=all 库位任务:一键全仓 -->
|
||||
<view v-if="allowAllLocations" class="picker__all" @click="handleAllLocations">
|
||||
<text class="picker__all-text">全部库位(自动拉取全仓库启用库位)</text>
|
||||
</view>
|
||||
|
||||
<scroll-view class="picker__scroll" scroll-y>
|
||||
<view v-if="loading" class="picker__empty">加载中...</view>
|
||||
<view v-else-if="!list.length" class="picker__empty">
|
||||
{{ searched ? '未找到匹配结果' : '请输入关键字或扫码查询' }}
|
||||
</view>
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.key"
|
||||
class="picker-item"
|
||||
:class="{ 'picker-item--selected': isSelected(item) }"
|
||||
@click="toggle(item)"
|
||||
>
|
||||
<view class="picker-item__main">
|
||||
<text class="picker-item__title">{{ item.title }}</text>
|
||||
<text v-if="item.subtitle" class="picker-item__subtitle">{{ item.subtitle }}</text>
|
||||
</view>
|
||||
<u-icon
|
||||
:name="isSelected(item) ? 'checkmark-circle-fill' : 'circle'"
|
||||
:color="isSelected(item) ? '#2979ff' : '#c0c4cc'"
|
||||
size="40rpx"
|
||||
></u-icon>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="picker__footer">
|
||||
<view class="picker__footer-btn" :class="{ 'picker__footer-btn--disabled': !selected.length }" @click="handleConfirm">
|
||||
<text class="picker__footer-btn-text">确认添加{{ selected.length ? `(${selected.length})` : '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { normalizeStockSearchRows, normalizeSpaceSearchRows } from './countModel.js';
|
||||
|
||||
/**
|
||||
* 盘点明细添加选择器(stock.check.addDetail 用)
|
||||
* mode='goods' 商品任务 → 搜 stock.warehouse.search,选 stock_id,提交 stock_ids
|
||||
* mode='location' 库位任务 → 搜 common.searchSpace,选库位 id,提交 location_ids
|
||||
* allowAllLocations=true 时提供「全部库位」(不传 locations/location_ids,后端自动拉全仓启用库位)
|
||||
*/
|
||||
export default {
|
||||
name: 'CountDetailPicker',
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'location'
|
||||
},
|
||||
// 商品任务的任务货主(传给 stock.warehouse.search)
|
||||
storeId: {
|
||||
type: [Number, String],
|
||||
default: null
|
||||
},
|
||||
allowAllLocations: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
list: [],
|
||||
selected: [],
|
||||
loading: false,
|
||||
searched: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.mode === 'goods' ? '添加商品明细' : '添加库位明细';
|
||||
},
|
||||
subtitle() {
|
||||
return this.mode === 'goods' ? '仅支持已存在的商品(按商品盘点)' : '可扫码或搜索库位,勾选后批量添加';
|
||||
},
|
||||
placeholder() {
|
||||
return this.mode === 'goods' ? '扫描/输入商品条码或名称' : '扫描/输入库位编码、自定义名称';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(value) {
|
||||
if (value) {
|
||||
this.keyword = '';
|
||||
this.list = [];
|
||||
this.selected = [];
|
||||
this.searched = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClose() {
|
||||
this.$emit('close');
|
||||
},
|
||||
isSelected(item) {
|
||||
return this.selected.some(one => one.key === item.key);
|
||||
},
|
||||
toggle(item) {
|
||||
const index = this.selected.findIndex(one => one.key === item.key);
|
||||
if (index === -1) {
|
||||
this.selected.push(item);
|
||||
} else {
|
||||
this.selected.splice(index, 1);
|
||||
}
|
||||
},
|
||||
async handleSearch() {
|
||||
const keyword = String(this.keyword || '').trim();
|
||||
if (!keyword) {
|
||||
this.list = [];
|
||||
this.searched = false;
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
try {
|
||||
if (this.mode === 'goods') {
|
||||
const params = { keyword };
|
||||
if (this.storeId !== null && this.storeId !== undefined && this.storeId !== '') {
|
||||
params.store_id = this.storeId;
|
||||
}
|
||||
const response = await this.$http('stock.warehouse.search', params);
|
||||
this.list = normalizeStockSearchRows(response);
|
||||
} else {
|
||||
const response = await this.$http('common.searchSpace', { keyword });
|
||||
this.list = normalizeSpaceSearchRows(response);
|
||||
}
|
||||
this.searched = true;
|
||||
} catch (error) {
|
||||
console.error('[CountDetailPicker] 查询失败:', error);
|
||||
this.list = [];
|
||||
uni.showToast({ title: '查询失败', icon: 'none' });
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
handleAllLocations() {
|
||||
this.$emit('confirm', { mode: 'location', all: true, ids: [], codes: [] });
|
||||
},
|
||||
handleConfirm() {
|
||||
if (!this.selected.length) return;
|
||||
this.$emit('confirm', {
|
||||
mode: this.mode,
|
||||
all: false,
|
||||
ids: this.selected.map(item => item.id),
|
||||
codes: this.selected.map(item => item.code).filter(Boolean)
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 80vh;
|
||||
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.picker__header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.picker__title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.picker__subtitle {
|
||||
margin-top: 8rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.picker__search {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.picker__all {
|
||||
margin-top: 16rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #eef4ff;
|
||||
border: 1rpx solid #cfe1ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
}
|
||||
|
||||
.picker__all-text {
|
||||
font-size: 30rpx;
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.picker__scroll {
|
||||
flex: 1;
|
||||
min-height: 320rpx;
|
||||
max-height: 50vh;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.picker__empty {
|
||||
padding: 80rpx 0;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.picker-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 8rpx;
|
||||
border-bottom: 1rpx solid #f2f4f7;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-item--selected {
|
||||
background: #f5f9ff;
|
||||
}
|
||||
|
||||
.picker-item__main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.picker-item__title {
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.picker-item__subtitle {
|
||||
margin-top: 6rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.picker__footer {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.picker__footer-btn {
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
background: #2979ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.picker__footer-btn--disabled {
|
||||
background: #c8d6f0;
|
||||
}
|
||||
|
||||
.picker__footer-btn-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
259
src/pages/warehouse/inventoryCount-comps/CountItemCard.vue
Normal file
259
src/pages/warehouse/inventoryCount-comps/CountItemCard.vue
Normal file
@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<view class="count-card" :class="{ 'count-card--highlight': focused }">
|
||||
<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, 'count-card__input-wrap--readonly': !editable }"
|
||||
>
|
||||
<input
|
||||
v-if="editable"
|
||||
class="count-card__input"
|
||||
type="number"
|
||||
:focus="focused"
|
||||
v-model="item.inputValue"
|
||||
placeholder="请输入"
|
||||
placeholder-style="color: #c0c4cc; font-size: 34rpx;"
|
||||
@focus="$emit('focus', item)"
|
||||
@blur="$emit('blur', item)"
|
||||
@confirm="$emit('blur', item)"
|
||||
/>
|
||||
<text
|
||||
v-else
|
||||
class="count-card__readonly"
|
||||
:class="{ 'count-card__readonly--empty': !item.reported }"
|
||||
>{{ item.reported ? item.inputValue : '--' }}</text>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 盘点明细卡片
|
||||
* editable=false 时实盘数量以纯文本展示(只读);item.inputValue 由父级明细对象双向承载
|
||||
*/
|
||||
export default {
|
||||
name: 'CountItemCard',
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
editable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.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__spec,
|
||||
.count-card__batch {
|
||||
margin-top: 6rpx;
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
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-wrap--reported {
|
||||
background: #e8f7ee;
|
||||
border-color: #b7e4c7;
|
||||
}
|
||||
|
||||
.count-card__input-wrap--readonly {
|
||||
background: #fafbfc;
|
||||
}
|
||||
|
||||
.count-card__readonly {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.count-card__readonly--empty {
|
||||
color: #c0c4cc;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.count-card__input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
font-size: 36rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.count-card__checked-icon {
|
||||
flex-shrink: 0;
|
||||
margin-left: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
187
src/pages/warehouse/inventoryCount-comps/CountListToolbar.vue
Normal file
187
src/pages/warehouse/inventoryCount-comps/CountListToolbar.vue
Normal file
@ -0,0 +1,187 @@
|
||||
<template>
|
||||
<view class="search-panel">
|
||||
<view class="search-input-wrap">
|
||||
<u-search
|
||||
:value="keyword"
|
||||
:placeholder="placeholder"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@input="$emit('input', $event)"
|
||||
@search="$emit('search')"
|
||||
@clear="$emit('clear')"
|
||||
></u-search>
|
||||
<view class="search-actions">
|
||||
<view class="scan-btn" @click="$emit('scan')">
|
||||
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
<view class="search-divider"></view>
|
||||
<view class="search-btn" @click="$emit('search')">
|
||||
<text class="search-btn__text">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="filter-scroll" scroll-x :show-scrollbar="false">
|
||||
<view class="filter-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="filter-group__item"
|
||||
:class="{ 'filter-group__item--active': statusFilter === opt.value }"
|
||||
@click="$emit('status-change', opt.value)"
|
||||
>
|
||||
<text class="filter-group__item-text">{{ opt.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** 盘点列表顶部工具栏:关键字搜索/扫码 + 状态筛选(支持 v-model 绑定关键字) */
|
||||
export default {
|
||||
name: 'CountListToolbar',
|
||||
// 让父级 v-model 绑定到 keyword(默认会绑定 value)
|
||||
model: {
|
||||
prop: 'keyword',
|
||||
event: 'input'
|
||||
},
|
||||
props: {
|
||||
keyword: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请输入/扫描盘点单号或标题'
|
||||
},
|
||||
statusOptions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
statusFilter: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-panel {
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
padding: 16rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.search-input-wrap {
|
||||
position: relative;
|
||||
|
||||
::v-deep .u-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content {
|
||||
padding-right: 200rpx;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content__close {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 状态筛选行(横向滚动) */
|
||||
.filter-scroll {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-group__item {
|
||||
flex: none;
|
||||
height: 56rpx;
|
||||
padding: 0 24rpx;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.filter-group__item + .filter-group__item {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.filter-group__item--active {
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.28);
|
||||
}
|
||||
|
||||
.filter-group__item-text {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group__item--active .filter-group__item-text {
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
275
src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue
Normal file
275
src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue
Normal file
@ -0,0 +1,275 @@
|
||||
<template>
|
||||
<view v-if="row" class="loc-detail">
|
||||
<view class="loc-detail__head">
|
||||
<view class="loc-detail__title-wrap">
|
||||
<text class="loc-detail__title">{{ row.title || '--' }}</text>
|
||||
<text v-if="row.subtitle" class="loc-detail__subtitle">{{ row.subtitle }}</text>
|
||||
</view>
|
||||
<view class="loc-detail__tags">
|
||||
<text v-if="row.empty" class="loc-detail__tag loc-detail__tag--empty">空库位</text>
|
||||
<text v-if="row.statusText" class="loc-detail__tag" :class="row.statusClass">{{ row.statusText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="row.meta && row.meta.length" class="loc-detail__meta">
|
||||
<text v-for="item in row.meta" :key="item.label" class="loc-detail__meta-item">{{ item.label }}:{{ item.value }}</text>
|
||||
</view>
|
||||
|
||||
<view class="loc-detail__section">
|
||||
<view class="loc-detail__section-head">
|
||||
<text class="loc-detail__section-title">商品记录</text>
|
||||
<text class="loc-detail__section-count">共 {{ (row.goodsCount || 0) + (row.unknownCount || 0) }} 条</text>
|
||||
<text v-if="row.unknownCount" class="loc-detail__section-unknown">未知 {{ row.unknownCount }}</text>
|
||||
</view>
|
||||
|
||||
<view v-if="!row.children || !row.children.length" class="loc-detail__empty">
|
||||
<text class="loc-detail__empty-text">该库位暂无商品记录</text>
|
||||
</view>
|
||||
<view v-else class="loc-detail__list">
|
||||
<u-swipe-action :key="listKey">
|
||||
<u-swipe-action-item
|
||||
v-for="child in row.children"
|
||||
:key="child.key"
|
||||
:name="child.key"
|
||||
:options="swipeOptions"
|
||||
:disabled="!canDelete(child)"
|
||||
@click="handleSwipeClick(child)"
|
||||
>
|
||||
<view class="loc-detail__row">
|
||||
<view class="loc-detail__row-main">
|
||||
<text class="loc-detail__row-title">{{ child.title }}</text>
|
||||
<text v-if="child.subtitle" class="loc-detail__row-sub">{{ child.subtitle }}</text>
|
||||
</view>
|
||||
<view class="loc-detail__row-side">
|
||||
<text v-if="child.statusText" class="loc-detail__row-tag" :class="child.statusClass">{{ child.statusText }}</text>
|
||||
<text v-if="child.quantityText !== ''" class="loc-detail__row-qty">实盘 {{ child.quantityText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</u-swipe-action-item>
|
||||
</u-swipe-action>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 库位盘点明细面板
|
||||
* 展示当前库位状态、盘点人与商品作业记录(商品记录可左滑删除);
|
||||
* 「添加商品」不放按钮:统一由页面顶部输入框/扫码打开添加弹窗
|
||||
*/
|
||||
export default {
|
||||
name: 'CountLocationDetail',
|
||||
props: {
|
||||
row: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
editable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 可删除时左滑出「删除」(需 taskId + record_id,由父级实际调用 recordDelete)
|
||||
swipeOptions() {
|
||||
return this.editable ? [{ text: '删除', style: { backgroundColor: '#f56c6c' } }] : [];
|
||||
},
|
||||
// 记录集合变化时重建列表:uview 的左滑打开状态存在 DOM 节点上,重建可清掉残留的展开态
|
||||
listKey() {
|
||||
const children = (this.row && this.row.children) || [];
|
||||
const detailId = (this.row && this.row.detailId) || '';
|
||||
return `${detailId}#${children.map(child => child.key).join('|')}`;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
canDelete(child) {
|
||||
return this.editable && !!(child && child.recordId);
|
||||
},
|
||||
handleSwipeClick(child) {
|
||||
if (!this.canDelete(child)) return;
|
||||
this.$emit('delete', child);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.loc-detail {
|
||||
margin: 0 12rpx 12rpx;
|
||||
padding: 20rpx 28rpx;
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.loc-detail__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.loc-detail__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.loc-detail__title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.3;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.loc-detail__subtitle {
|
||||
margin-top: 6rpx;
|
||||
font-size: 28rpx;
|
||||
color: #8a9099;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.loc-detail__tags {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.loc-detail__tag {
|
||||
margin-bottom: 8rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1;
|
||||
color: #909399;
|
||||
background: #f5f7fa;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.loc-detail__tag--empty {
|
||||
color: #606266;
|
||||
background: #eef0f3;
|
||||
}
|
||||
|
||||
.loc-detail__meta {
|
||||
margin-top: 10rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.loc-detail__meta-item {
|
||||
margin-right: 24rpx;
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.loc-detail__section {
|
||||
margin-top: 16rpx;
|
||||
border-top: 1rpx solid #f0f2f5;
|
||||
}
|
||||
|
||||
.loc-detail__section-head {
|
||||
padding-top: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.loc-detail__section-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.loc-detail__section-count {
|
||||
margin-left: 12rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.loc-detail__section-unknown {
|
||||
margin-left: 12rpx;
|
||||
padding: 4rpx 10rpx;
|
||||
border-radius: 6rpx;
|
||||
font-size: 22rpx;
|
||||
color: #e64340;
|
||||
background: #fdecec;
|
||||
}
|
||||
|
||||
.loc-detail__empty {
|
||||
padding: 40rpx 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.loc-detail__empty-text {
|
||||
font-size: 30rpx;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.loc-detail__list {
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
.loc-detail__row {
|
||||
padding: 16rpx 0;
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f5f6f8;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.loc-detail__row-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.loc-detail__row-title {
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.loc-detail__row-sub {
|
||||
margin-top: 4rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.loc-detail__row-side {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.loc-detail__row-tag {
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1;
|
||||
color: #909399;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.loc-detail__row-qty {
|
||||
margin-top: 6rpx;
|
||||
font-size: 28rpx;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
174
src/pages/warehouse/inventoryCount-comps/CountLocationGrid.vue
Normal file
174
src/pages/warehouse/inventoryCount-comps/CountLocationGrid.vue
Normal file
@ -0,0 +1,174 @@
|
||||
<template>
|
||||
<view class="loc-grid">
|
||||
<view class="loc-grid__head">
|
||||
<text class="loc-grid__head-title">库位列表</text>
|
||||
<text class="loc-grid__head-hint">点击库位查看明细</text>
|
||||
</view>
|
||||
<view class="loc-grid__body">
|
||||
<view
|
||||
v-for="row in rows"
|
||||
:key="row.key"
|
||||
class="loc-grid__cell"
|
||||
@click="$emit('select', row.key)"
|
||||
>
|
||||
<view class="loc-grid__inner" :class="cellClass(row)">
|
||||
<text class="loc-grid__code">{{ row.gridText || row.title || '--' }}</text>
|
||||
<view class="loc-grid__side">
|
||||
<text class="loc-grid__flag" :class="flagClass(row)">{{ row.checked ? '已盘' : '未盘' }}</text>
|
||||
<text class="loc-grid__count">{{ countText(row) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 库位盘点宫格列表(2 列,每页 20 个 → 2 列 10 行,随页面滚动)
|
||||
* 行数据来自 countModel.normalizeWorkRows(rows, 'location', mode)
|
||||
* 格子显示完整 location_name(缺失时回退 location_code)+ 已盘/未盘标记
|
||||
* 点击格子只派发 select,由父级跳转到库位明细页
|
||||
*/
|
||||
export default {
|
||||
name: 'CountLocationGrid',
|
||||
props: {
|
||||
rows: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
selectedKey: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cellClass(row) {
|
||||
const classes = [];
|
||||
if (row.checked) classes.push('loc-grid__inner--done');
|
||||
if (row.empty) classes.push('loc-grid__inner--empty');
|
||||
if (row.hasUnknown) classes.push('loc-grid__inner--unknown');
|
||||
if (row.key === this.selectedKey) classes.push('loc-grid__inner--active');
|
||||
return classes;
|
||||
},
|
||||
flagClass(row) {
|
||||
return row.checked ? 'loc-grid__flag--done' : 'loc-grid__flag--todo';
|
||||
},
|
||||
/** 商品记录数(已盘才有记录,未盘显示 --) */
|
||||
countText(row) {
|
||||
if (!row.checked) return '--';
|
||||
const total = (Number(row.goodsCount) || 0) + (Number(row.unknownCount) || 0);
|
||||
return `${total} 项`;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 2 列宫格(每页 20 个 → 2 列 10 行,随 scroll-view 滚动) */
|
||||
.loc-grid {
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #f2f2f2;
|
||||
}
|
||||
|
||||
.loc-grid__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12rpx 24rpx 0;
|
||||
}
|
||||
|
||||
.loc-grid__head-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.loc-grid__head-hint {
|
||||
font-size: 24rpx;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.loc-grid__body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 8rpx 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.loc-grid__cell {
|
||||
width: 50%;
|
||||
padding: 6rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.loc-grid__inner {
|
||||
height: 76rpx;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 12rpx;
|
||||
background: #f5f7fa;
|
||||
border: 2rpx solid #e6e8eb;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.loc-grid__inner--done {
|
||||
background: #e8f7ee;
|
||||
border-color: #b7e4c7;
|
||||
}
|
||||
|
||||
.loc-grid__inner--empty {
|
||||
border-style: dashed;
|
||||
}
|
||||
|
||||
.loc-grid__inner--unknown {
|
||||
border-color: #f0b7b5;
|
||||
}
|
||||
|
||||
.loc-grid__inner--active {
|
||||
background: #eef4ff;
|
||||
border-color: #2979ff;
|
||||
box-shadow: 0 0 0 2rpx rgba(41, 121, 255, 0.18);
|
||||
}
|
||||
|
||||
.loc-grid__code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.2;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.loc-grid__flag {
|
||||
font-size: 26rpx;
|
||||
line-height: 1;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.loc-grid__side {
|
||||
flex-shrink: 0;
|
||||
margin-left: 12rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.loc-grid__count {
|
||||
margin-top: 4rpx;
|
||||
font-size: 20rpx;
|
||||
line-height: 1;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.loc-grid__flag--done {
|
||||
color: #18a058;
|
||||
}
|
||||
|
||||
.loc-grid__flag--todo {
|
||||
color: #ff9800;
|
||||
}
|
||||
</style>
|
||||
510
src/pages/warehouse/inventoryCount-comps/CountRecordAddPopup.vue
Normal file
510
src/pages/warehouse/inventoryCount-comps/CountRecordAddPopup.vue
Normal file
@ -0,0 +1,510 @@
|
||||
<template>
|
||||
<u-popup :show="show" mode="bottom" round="20" :closeable="true" :safeAreaInsetBottom="true" @close="handleClose">
|
||||
<view class="record-add">
|
||||
<view class="record-add__header">
|
||||
<text class="record-add__title">添加商品</text>
|
||||
<text class="record-add__subtitle">{{ subtitle }}</text>
|
||||
</view>
|
||||
|
||||
<view class="record-add__search">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="扫描/输入商品条码或名称"
|
||||
bg-color="#f5f5f5"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleSearch"
|
||||
@clear="handleClear"
|
||||
></u-search>
|
||||
</view>
|
||||
|
||||
<scroll-view class="record-add__scroll" scroll-y>
|
||||
<view v-if="loading" class="record-add__empty">查询中...</view>
|
||||
<view v-else-if="list.length" class="record-add__list">
|
||||
<view
|
||||
v-for="item in list"
|
||||
:key="item.key"
|
||||
class="record-add__item"
|
||||
:class="{ 'record-add__item--selected': selectedKey === item.key }"
|
||||
@click="selectItem(item)"
|
||||
> <!-- 商品首图 + 图片数量角标(点图只看图,不选中) -->
|
||||
<view class="record-add__thumb" @click.stop="previewImages(item)">
|
||||
<u-image
|
||||
v-if="item.images && item.images.length"
|
||||
:src="item.images[0]"
|
||||
mode="aspectFill"
|
||||
width="120rpx"
|
||||
height="120rpx"
|
||||
radius="10rpx"
|
||||
>
|
||||
<template #error>
|
||||
<view class="record-add__thumb-empty">
|
||||
<text class="record-add__thumb-empty-text">无图片</text>
|
||||
</view>
|
||||
</template>
|
||||
</u-image>
|
||||
<view v-else class="record-add__thumb-empty">
|
||||
<text class="record-add__thumb-empty-text">无图片</text>
|
||||
</view>
|
||||
<view v-if="item.images && item.images.length > 1" class="record-add__thumb-badge">
|
||||
<text class="record-add__thumb-badge-text">{{ item.images.length }}</text>
|
||||
</view>
|
||||
</view> <view class="record-add__item-main">
|
||||
<text class="record-add__item-title">{{ item.title }}</text>
|
||||
<text v-if="item.subtitle" class="record-add__item-subtitle">{{ item.subtitle }}</text>
|
||||
</view>
|
||||
<view class="record-add__radio" :class="{ 'record-add__radio--checked': selectedKey === item.key }">
|
||||
<u-icon v-if="selectedKey === item.key" name="checkmark" size="24rpx" color="#ffffff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 未匹配到系统商品:按未知商品记录 -->
|
||||
<view v-else-if="useUnknown" class="record-add__unknown">
|
||||
<text class="record-add__unknown-tip">未匹配到系统商品,将按「未知商品」记录</text>
|
||||
<view class="record-add__unknown-row">
|
||||
<text class="record-add__label">条码</text>
|
||||
<text class="record-add__unknown-code">{{ keyword }}</text>
|
||||
</view>
|
||||
<view class="record-add__unknown-row">
|
||||
<text class="record-add__label">商品名称</text>
|
||||
<input
|
||||
class="record-add__unknown-input"
|
||||
v-model="unknownName"
|
||||
placeholder="可不填,默认用条码"
|
||||
placeholder-style="color: #c0c4cc;"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="record-add__empty">请输入条码或名称查询商品</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="record-add__qty">
|
||||
<text class="record-add__label">实盘数量</text>
|
||||
<input
|
||||
class="record-add__qty-input"
|
||||
type="number"
|
||||
v-model="quantity"
|
||||
placeholder="请输入数量"
|
||||
placeholder-style="color: #c0c4cc;"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="record-add__footer">
|
||||
<view class="record-add__btn" :class="{ 'record-add__btn--disabled': !canConfirm }" @click="handleConfirm">
|
||||
<text class="record-add__btn-text">确认添加</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { normalizeStockSearchRows } from './countModel.js';
|
||||
|
||||
/**
|
||||
* 在库位明细行下添加一条商品作业记录(stock.check.report)
|
||||
* - 命中系统商品:带 stock_id(report 会校验商品属于本仓库)
|
||||
* - 未命中:只带 barcode(item_name 可选)→ 由后端记为未知商品(stock_id=NULL)
|
||||
*/
|
||||
export default {
|
||||
name: 'CountRecordAddPopup',
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
detailId: {
|
||||
type: [Number, String],
|
||||
default: ''
|
||||
},
|
||||
location: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
storeId: {
|
||||
type: [Number, String],
|
||||
default: null
|
||||
},
|
||||
// 预填关键字(扫码得到条码后直接带进弹窗并自动查询)
|
||||
prefillKeyword: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
list: [],
|
||||
selectedKey: '',
|
||||
unknownName: '',
|
||||
quantity: '',
|
||||
loading: false,
|
||||
searched: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
subtitle() {
|
||||
const parts = [];
|
||||
if (this.location) parts.push(`库位 ${this.location}`);
|
||||
if (this.detailId) parts.push(`明细 #${this.detailId}`);
|
||||
return parts.join(' · ') || '按库位盘点录入商品';
|
||||
},
|
||||
selected() {
|
||||
return this.list.find(item => item.key === this.selectedKey) || null;
|
||||
},
|
||||
// 无系统商品匹配时,允许按未知商品记录(必须有条码)
|
||||
useUnknown() {
|
||||
return this.searched && !this.list.length && !!String(this.keyword || '').trim();
|
||||
},
|
||||
canConfirm() {
|
||||
const raw = String(this.quantity || '').trim();
|
||||
if (raw === '') return false;
|
||||
const value = Number(raw);
|
||||
if (!Number.isInteger(value) || value < 0) return false;
|
||||
return !!(this.selected || this.useUnknown);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(value) {
|
||||
if (value) {
|
||||
// 每次打开先重置,再套用预填条码
|
||||
this.resetForm();
|
||||
this.applyPrefill();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 清空搜索词/选中项/名称/数量(提交成功后由父级调用,便于连续录入) */
|
||||
resetForm() {
|
||||
this.keyword = '';
|
||||
this.list = [];
|
||||
this.selectedKey = '';
|
||||
this.unknownName = '';
|
||||
this.quantity = '';
|
||||
this.loading = false;
|
||||
this.searched = false;
|
||||
},
|
||||
/** 外部(扫码)直接带关键字查询;弹窗已打开时同样生效 */
|
||||
applyKeyword(keyword) {
|
||||
const code = String(keyword || '').trim();
|
||||
if (!code) return;
|
||||
this.resetForm();
|
||||
this.keyword = code;
|
||||
this.handleSearch();
|
||||
},
|
||||
// 扫码/外部传入的条码:直接带入并自动查询
|
||||
applyPrefill() {
|
||||
const code = String(this.prefillKeyword || '').trim();
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.handleSearch();
|
||||
},
|
||||
handleClose() {
|
||||
this.$emit('close');
|
||||
},
|
||||
handleClear() {
|
||||
this.keyword = '';
|
||||
this.list = [];
|
||||
this.selectedKey = '';
|
||||
this.searched = false;
|
||||
},
|
||||
selectItem(item) {
|
||||
this.selectedKey = item.key;
|
||||
if (!String(this.keyword || '').trim()) {
|
||||
this.keyword = item.code || item.title || '';
|
||||
}
|
||||
},
|
||||
/** 预览商品图片组(无图片不响应,也不触发选中) */
|
||||
previewImages(item) {
|
||||
const urls = (item && Array.isArray(item.images) ? item.images : []).filter(Boolean);
|
||||
if (!urls.length) return;
|
||||
uni.previewImage({ current: urls[0], urls });
|
||||
},
|
||||
async handleSearch() {
|
||||
const keyword = String(this.keyword || '').trim();
|
||||
if (!keyword) {
|
||||
this.handleClear();
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.selectedKey = '';
|
||||
try {
|
||||
const params = { keyword };
|
||||
if (this.storeId !== null && this.storeId !== undefined && this.storeId !== '') {
|
||||
params.store_id = this.storeId;
|
||||
}
|
||||
const response = await this.$http('stock.warehouse.search', params);
|
||||
this.list = normalizeStockSearchRows(response);
|
||||
// 扫码命中唯一商品时直接选中
|
||||
if (this.list.length === 1) {
|
||||
this.selectItem(this.list[0]);
|
||||
}
|
||||
this.searched = true;
|
||||
} catch (error) {
|
||||
console.error('[CountRecordAddPopup] 查询商品失败:', error);
|
||||
this.list = [];
|
||||
this.searched = true;
|
||||
uni.showToast({ title: '查询商品失败', icon: 'none' });
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
handleConfirm() {
|
||||
if (!this.canConfirm) return;
|
||||
const payload = {
|
||||
detailId: this.detailId,
|
||||
location: this.location,
|
||||
stockId: '',
|
||||
barcode: '',
|
||||
itemName: '',
|
||||
quantity: Number(this.quantity)
|
||||
};
|
||||
if (this.selected) {
|
||||
payload.stockId = this.selected.id;
|
||||
payload.barcode = this.selected.code || '';
|
||||
} else {
|
||||
payload.barcode = String(this.keyword || '').trim();
|
||||
payload.itemName = String(this.unknownName || '').trim() || payload.barcode;
|
||||
}
|
||||
this.$emit('confirm', payload);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.record-add {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 80vh;
|
||||
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.record-add__header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-add__title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.record-add__subtitle {
|
||||
margin-top: 8rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.record-add__search {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.record-add__scroll {
|
||||
flex: 1;
|
||||
min-height: 240rpx;
|
||||
max-height: 42vh;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.record-add__empty {
|
||||
padding: 70rpx 0;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.record-add__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 8rpx;
|
||||
border-bottom: 1rpx solid #f2f4f7;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.record-add__item--selected {
|
||||
background: #f5f9ff;
|
||||
}
|
||||
|
||||
.record-add__item-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-right: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 商品首图 + 图片数量角标 */
|
||||
.record-add__thumb {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.record-add__thumb-empty {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 10rpx;
|
||||
background: #f5f7fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.record-add__thumb-empty-text {
|
||||
font-size: 22rpx;
|
||||
line-height: 1.2;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.record-add__thumb-badge {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
min-width: 32rpx;
|
||||
height: 32rpx;
|
||||
padding: 0 6rpx;
|
||||
box-sizing: border-box;
|
||||
border-top-left-radius: 10rpx;
|
||||
border-bottom-right-radius: 10rpx;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.record-add__thumb-badge-text {
|
||||
font-size: 20rpx;
|
||||
line-height: 1;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.record-add__item-title {
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.record-add__item-subtitle {
|
||||
margin-top: 6rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 选择指示:CSS 圆点(uview 图标字体没有 uicon-circle,用图标会渲染成文字) */
|
||||
.record-add__radio {
|
||||
flex-shrink: 0;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 50%;
|
||||
border: 2rpx solid #c0c4cc;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.record-add__radio--checked {
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
}
|
||||
|
||||
.record-add__unknown {
|
||||
padding: 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #fff8e6;
|
||||
border: 1rpx solid #ffe0a3;
|
||||
}
|
||||
|
||||
.record-add__unknown-tip {
|
||||
font-size: 28rpx;
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.record-add__unknown-row {
|
||||
margin-top: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-add__unknown-code {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.record-add__unknown-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 64rpx;
|
||||
padding: 0 16rpx;
|
||||
background: #ffffff;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 10rpx;
|
||||
font-size: 30rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.record-add__label {
|
||||
flex-shrink: 0;
|
||||
width: 160rpx;
|
||||
font-size: 30rpx;
|
||||
color: #8a9099;
|
||||
}
|
||||
|
||||
.record-add__qty {
|
||||
margin-top: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-add__qty-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 72rpx;
|
||||
padding: 0 16rpx;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 10rpx;
|
||||
font-size: 34rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.record-add__footer {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.record-add__btn {
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
background: #2979ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.record-add__btn--disabled {
|
||||
background: #c8d6f0;
|
||||
}
|
||||
|
||||
.record-add__btn-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
199
src/pages/warehouse/inventoryCount-comps/CountRecordCard.vue
Normal file
199
src/pages/warehouse/inventoryCount-comps/CountRecordCard.vue
Normal file
@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<view
|
||||
class="record-card"
|
||||
:class="{ 'record-card--stripe': stripe }"
|
||||
@click="$emit('click', item)"
|
||||
>
|
||||
<!-- 第一行:标题 -->
|
||||
<view class="record-card__title-row">
|
||||
<text class="record-card__title">{{ item.title || '--' }}</text>
|
||||
</view>
|
||||
<!-- 第二行:单号 + 盘点类型 -->
|
||||
<view class="record-card__no-row">
|
||||
<text class="record-card__no">{{ item.checkNo || '--' }}</text>
|
||||
<text
|
||||
v-if="item.typeLabel && item.typeLabel !== '--'"
|
||||
class="record-card__type"
|
||||
:class="item.typeClass"
|
||||
>{{ item.typeLabel }}</text>
|
||||
</view>
|
||||
<!-- 第三行:左(创建人 / 创建时间)· 右(进度 / 状态) -->
|
||||
<view class="record-card__body">
|
||||
<view class="record-card__info">
|
||||
<text class="record-card__info-line">
|
||||
<text class="record-card__info-label">创建人:</text>{{ item.operator || '--' }}
|
||||
</text>
|
||||
<text class="record-card__info-line record-card__info-line--time">{{ item.timeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="record-card__stat">
|
||||
<text v-if="item.progressText" class="record-card__progress">{{ item.progressText }}</text>
|
||||
<text class="record-card__status" :class="item.statusClass">{{ item.statusText || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** 盘点任务列表卡片(标题 / 单号+类型 / 创建人·时间 + 进度·状态) */
|
||||
export default {
|
||||
name: 'CountRecordCard',
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
stripe: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.record-card {
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
padding: 24rpx 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.record-card--stripe {
|
||||
background: #dde9fb;
|
||||
border-color: #dfe7f5;
|
||||
}
|
||||
|
||||
/* 第一行:标题 */
|
||||
.record-card__title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-card__title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
/* 原 38rpx 的 80%,缩小后仍能装下更多字数 */
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.4;
|
||||
/* 超长直接省略号 */
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 第二行:单号 + 盘点类型 */
|
||||
.record-card__no-row {
|
||||
margin-top: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.record-card__no {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 30rpx;
|
||||
color: #8a9099;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.5rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.record-card__type {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1;
|
||||
color: #2979ff;
|
||||
background: #eef4ff;
|
||||
}
|
||||
|
||||
.record-card__type--goods {
|
||||
color: #2979ff;
|
||||
background: #eef4ff;
|
||||
}
|
||||
|
||||
.record-card__type--location {
|
||||
color: #18a058;
|
||||
background: #e8f7ee;
|
||||
}
|
||||
|
||||
/* 第三行:左右结构 */
|
||||
.record-card__body {
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1rpx solid #f0f2f5;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.record-card__info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.record-card__info-line {
|
||||
font-size: 32rpx;
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.record-card__info-line--time {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.record-card__info-label {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.record-card__stat {
|
||||
flex-shrink: 0;
|
||||
margin-left: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.record-card__progress {
|
||||
font-size: 32rpx;
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.record-card__status {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #2979ff;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.record-card__status--strong {
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.record-card__status--success {
|
||||
color: #18a058;
|
||||
}
|
||||
|
||||
.record-card__status--warning {
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.record-card__status--danger {
|
||||
color: #e64340;
|
||||
}
|
||||
|
||||
.record-card__status--muted {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
</style>
|
||||
116
src/pages/warehouse/inventoryCount-comps/CountSearchPanel.vue
Normal file
116
src/pages/warehouse/inventoryCount-comps/CountSearchPanel.vue
Normal file
@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<view class="search-panel">
|
||||
<view class="search-input-wrap">
|
||||
<u-search
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@input="$emit('input', $event)"
|
||||
@search="$emit('search')"
|
||||
@clear="$emit('clear')"
|
||||
></u-search>
|
||||
<view class="search-actions">
|
||||
<view class="scan-btn" @click="$emit('scan')">
|
||||
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
<view class="search-divider"></view>
|
||||
<view class="search-btn" @click="$emit('search')">
|
||||
<text class="search-btn__text">{{ actionText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** 盘点扫码/输入定位条(支持 v-model) */
|
||||
export default {
|
||||
name: 'CountSearchPanel',
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '扫码/输入商品条码快速定位'
|
||||
},
|
||||
actionText: {
|
||||
type: String,
|
||||
default: '定位'
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-panel {
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
padding: 16rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
190
src/pages/warehouse/inventoryCount-comps/CountSummaryPanel.vue
Normal file
190
src/pages/warehouse/inventoryCount-comps/CountSummaryPanel.vue
Normal file
@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="summary-panel">
|
||||
<!-- 基本信息 -->
|
||||
<view class="summary-panel__group">基本信息</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">盘点单号</text>
|
||||
<text class="summary-panel__value summary-panel__value--strong">{{ info.checkNo || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">标题</text>
|
||||
<text class="summary-panel__value">{{ info.title || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">盘点类型</text>
|
||||
<text class="summary-panel__value">{{ info.typeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">盘点方式</text>
|
||||
<text class="summary-panel__value">{{ info.modeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">状态</text>
|
||||
<text class="summary-panel__value" :class="info.statusClass">{{ info.statusText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">货主</text>
|
||||
<text class="summary-panel__value">{{ storeText }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">创建人</text>
|
||||
<text class="summary-panel__value">{{ info.creatorName || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 明细统计 -->
|
||||
<view class="summary-panel__group">明细统计</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">明细进度</text>
|
||||
<text class="summary-panel__value">{{ info.detailStatusText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">明细总数</text>
|
||||
<text class="summary-panel__value">{{ info.totalItems }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">已盘明细</text>
|
||||
<text class="summary-panel__value">{{ info.checkedItems }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">差异明细</text>
|
||||
<text class="summary-panel__value" :class="{ 'summary-panel__value--warning': info.diffItems > 0 }">{{ info.diffItems }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 时间信息 -->
|
||||
<view class="summary-panel__group">时间信息</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">盘点开始</text>
|
||||
<text class="summary-panel__value">{{ info.startTimeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">盘点结束</text>
|
||||
<text class="summary-panel__value">{{ info.endTimeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">创建时间</text>
|
||||
<text class="summary-panel__value">{{ info.createTimeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="summary-panel__row">
|
||||
<text class="summary-panel__label">更新时间</text>
|
||||
<text class="summary-panel__value">{{ info.updateTimeText || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 备注(有值才显示) -->
|
||||
<template v-if="info.remark">
|
||||
<view class="summary-panel__group">备注</view>
|
||||
<view class="summary-panel__row summary-panel__row--last">
|
||||
<text class="summary-panel__value">{{ info.remark }}</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/** 盘点单头摘要(单号/标题/类型/状态/进度) */
|
||||
export default {
|
||||
name: 'CountSummaryPanel',
|
||||
props: {
|
||||
info: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 货主:优先名称,无名称时退回 ID
|
||||
storeText() {
|
||||
if (this.info.storeName) return this.info.storeName;
|
||||
if (this.info.storeId !== null && this.info.storeId !== undefined && this.info.storeId !== '') {
|
||||
return `ID ${this.info.storeId}`;
|
||||
}
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.summary-panel {
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
padding: 20rpx 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary-panel__group {
|
||||
margin: 24rpx 0 6rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: #2979ff;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 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;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
414
src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue
Normal file
414
src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue
Normal file
@ -0,0 +1,414 @@
|
||||
<template>
|
||||
<view class="work-card" :class="{ 'work-card--highlight': focused }">
|
||||
<view class="work-card__head">
|
||||
<view class="work-card__title-wrap">
|
||||
<text class="work-card__title">{{ row.title || '--' }}</text>
|
||||
<text v-if="row.subtitle" class="work-card__subtitle">{{ row.subtitle }}</text>
|
||||
</view>
|
||||
<text v-if="row.statusText" class="work-card__tag" :class="row.statusClass">{{ row.statusText }}</text>
|
||||
</view>
|
||||
|
||||
<view v-if="row.meta && row.meta.length" class="work-card__meta">
|
||||
<text v-for="item in row.meta" :key="item.label" class="work-card__meta-item">{{ item.label }}:{{ item.value }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 行级数量(明盘) -->
|
||||
<view v-if="row.amount" class="work-card__amount">
|
||||
<view class="work-card__metric">
|
||||
<text class="work-card__label">账面数量</text>
|
||||
<text class="work-card__value">{{ row.amount.systemText }}</text>
|
||||
</view>
|
||||
<view class="work-card__metric">
|
||||
<text class="work-card__label">已盘数量</text>
|
||||
<text class="work-card__value">{{ row.amount.checkedText }}</text>
|
||||
</view>
|
||||
<text v-if="row.amount.diffText" class="work-card__diff" :class="row.amount.diffClass">{{ row.amount.diffText }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 行级录入(库位任务的库位行 / 商品任务的商品行) -->
|
||||
<view v-if="row.unit" class="work-card__input-row">
|
||||
<text class="work-card__label">实盘数量</text>
|
||||
<view class="work-input" :class="{ 'work-input--reported': row.unit.reported }">
|
||||
<input
|
||||
v-if="editable"
|
||||
class="work-input__field"
|
||||
type="number"
|
||||
v-model="row.unit.inputValue"
|
||||
placeholder="请输入"
|
||||
placeholder-style="color: #c0c4cc;"
|
||||
@blur="$emit('report', row.unit)"
|
||||
@confirm="$emit('report', row.unit)"
|
||||
/>
|
||||
<text
|
||||
v-else
|
||||
class="work-input__readonly"
|
||||
:class="{ 'work-input__readonly--empty': !row.unit.inputValue }"
|
||||
>{{ row.unit.inputValue || '--' }}</text>
|
||||
<text v-if="row.unit.reported" class="work-card__checked">
|
||||
<u-icon name="checkmark-circle-fill" size="32rpx" color="#18a058"></u-icon>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 子项:space=该库位下的商品;goods=该商品的各库位记录;location=该库位的作业记录 -->
|
||||
<view v-if="row.children && row.children.length" class="work-card__children">
|
||||
<view v-for="child in row.children" :key="child.key" class="work-child">
|
||||
<view class="work-child__main">
|
||||
<text class="work-child__title">{{ child.title }}</text>
|
||||
<text v-if="child.subtitle" class="work-child__subtitle">{{ child.subtitle }}</text>
|
||||
</view>
|
||||
<view class="work-child__side">
|
||||
<text v-if="child.statusText" class="work-card__tag" :class="child.statusClass">{{ child.statusText }}</text>
|
||||
<text v-if="child.amount" class="work-child__amount">
|
||||
账面 {{ child.amount.systemText }} · 已盘 {{ child.amount.checkedText }}
|
||||
</text>
|
||||
<text v-else-if="child.quantityText !== ''" class="work-child__amount">实盘 {{ child.quantityText }}</text>
|
||||
</view>
|
||||
<view v-if="child.unit" class="work-child__input">
|
||||
<view class="work-input" :class="{ 'work-input--reported': child.unit.reported }">
|
||||
<input
|
||||
v-if="editable"
|
||||
class="work-input__field"
|
||||
type="number"
|
||||
v-model="child.unit.inputValue"
|
||||
placeholder="请输入"
|
||||
placeholder-style="color: #c0c4cc;"
|
||||
@blur="$emit('report', child.unit)"
|
||||
@confirm="$emit('report', child.unit)"
|
||||
/>
|
||||
<text
|
||||
v-else
|
||||
class="work-input__readonly"
|
||||
:class="{ 'work-input__readonly--empty': !child.unit.inputValue }"
|
||||
>{{ child.unit.inputValue || '--' }}</text>
|
||||
<text v-if="child.unit.reported" class="work-card__checked">
|
||||
<u-icon name="checkmark-circle-fill" size="32rpx" color="#18a058"></u-icon>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 行级动作(库位视图:添加商品 / 标记空库位) -->
|
||||
<view v-if="editable && row.actions && row.actions.length" class="work-card__actions">
|
||||
<view
|
||||
v-for="action in row.actions"
|
||||
:key="action.key"
|
||||
class="work-card__action"
|
||||
:class="{ 'work-card__action--danger': action.key === 'mark-empty' }"
|
||||
@click="$emit('action', { row, key: action.key })"
|
||||
>
|
||||
<text class="work-card__action-text">{{ action.text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 盘点作业行卡片(stock.check.workData)
|
||||
* view = space → 行=库位,children=该库位下的任务商品(子项可录入)
|
||||
* view = goods → 行=商品,children=各库位作业记录(行级可录入)
|
||||
* view = location → 行=任务库位,children=已知/未知商品作业记录(行级可录入)
|
||||
* 录入单元上报由父级处理:@report 回传 unit(detailId/location/inputValue)
|
||||
*/
|
||||
export default {
|
||||
name: 'CountWorkCard',
|
||||
props: {
|
||||
row: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
editable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.work-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;
|
||||
}
|
||||
|
||||
.work-card--highlight {
|
||||
border-color: #2979ff;
|
||||
background: #eef4ff;
|
||||
box-shadow: 0 6rpx 20rpx rgba(41, 121, 255, 0.22);
|
||||
}
|
||||
|
||||
.work-card__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.work-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.work-card__title {
|
||||
font-size: 38rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.work-card__subtitle {
|
||||
margin-top: 6rpx;
|
||||
font-size: 30rpx;
|
||||
color: #8a9099;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.work-card__tag {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1;
|
||||
color: #909399;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.work-card__tag--done {
|
||||
color: #18a058;
|
||||
background: #e8f7ee;
|
||||
}
|
||||
|
||||
.work-card__tag--todo {
|
||||
color: #ff9800;
|
||||
background: #fff5e6;
|
||||
}
|
||||
|
||||
.work-card__tag--unknown {
|
||||
color: #e64340;
|
||||
background: #fdecec;
|
||||
}
|
||||
|
||||
.work-card__meta {
|
||||
margin-top: 10rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.work-card__meta-item {
|
||||
margin-right: 24rpx;
|
||||
font-size: 28rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.work-card__amount {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.work-card__metric {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.work-card__label {
|
||||
font-size: 28rpx;
|
||||
color: #8a9099;
|
||||
}
|
||||
|
||||
.work-card__value {
|
||||
margin-top: 8rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.work-card__diff {
|
||||
margin-left: 16rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.work-card__diff--gain {
|
||||
color: #18a058;
|
||||
background: #e8f7ee;
|
||||
}
|
||||
|
||||
.work-card__diff--loss {
|
||||
color: #e64340;
|
||||
background: #fdecec;
|
||||
}
|
||||
|
||||
.work-card__diff--match {
|
||||
color: #606266;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.work-card__input-row {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.work-card__input-row .work-card__label {
|
||||
flex-shrink: 0;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.work-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 68rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.work-input--reported {
|
||||
background: #e8f7ee;
|
||||
border-color: #b7e4c7;
|
||||
}
|
||||
|
||||
.work-input__field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
font-size: 36rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.work-input__readonly {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.work-input__readonly--empty {
|
||||
color: #c0c4cc;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.work-card__checked {
|
||||
flex-shrink: 0;
|
||||
margin-left: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.work-card__children {
|
||||
margin-top: 16rpx;
|
||||
border-top: 1rpx solid #f0f2f5;
|
||||
}
|
||||
|
||||
.work-child {
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx solid #f5f6f8;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.work-child__main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.work-child__title {
|
||||
font-size: 32rpx;
|
||||
color: #303133;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.work-child__subtitle {
|
||||
margin-top: 4rpx;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.work-child__side {
|
||||
margin-top: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.work-child__amount {
|
||||
margin-left: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.work-child__side .work-card__amount {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.work-child__input {
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.work-card__actions {
|
||||
margin-top: 16rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.work-card__action {
|
||||
flex: 1 1 200rpx;
|
||||
height: 72rpx;
|
||||
margin: 8rpx 10rpx 0 0;
|
||||
border-radius: 12rpx;
|
||||
background: #eef4ff;
|
||||
border: 1rpx solid #cfe1ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
}
|
||||
|
||||
.work-card__action--danger {
|
||||
background: #fff1f0;
|
||||
border-color: #ffccc7;
|
||||
}
|
||||
|
||||
.work-card__action--danger .work-card__action-text {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.work-card__action-text {
|
||||
font-size: 28rpx;
|
||||
color: #2979ff;
|
||||
}
|
||||
</style>
|
||||
848
src/pages/warehouse/inventoryCount-comps/countModel.js
Normal file
848
src/pages/warehouse/inventoryCount-comps/countModel.js
Normal file
@ -0,0 +1,848 @@
|
||||
/**
|
||||
* 库存盘点共享逻辑(纯函数 / 无副作用)
|
||||
* 供 pages/warehouse/inventoryCount.vue 与 inventoryCountDetail.vue 共用,
|
||||
* 避免两个页面各维护一份字段映射与响应解析。
|
||||
*/
|
||||
|
||||
// ===== 取值 / 文案 / 格式化 =====
|
||||
|
||||
/** 取第一个非空字段值 */
|
||||
export function firstValue(source, keys) {
|
||||
const target = source && typeof source === 'object' ? source : {};
|
||||
for (let i = 0; i < keys.length; i += 1) {
|
||||
const value = target[keys[i]];
|
||||
if (value !== null && value !== undefined && String(value).trim() !== '') {
|
||||
return String(value).trim();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 状态文案 */
|
||||
export function statusText(status) {
|
||||
const map = {
|
||||
created: '待提交',
|
||||
submitted: '待审核',
|
||||
rejected: '已驳回',
|
||||
approved: '待盘点',
|
||||
checking: '盘点中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
};
|
||||
const key = String(status || '').trim().toLowerCase();
|
||||
return map[key] || (status ? String(status) : '--');
|
||||
}
|
||||
|
||||
/** 状态色调:success/warning/danger/muted/strong(各页面自行拼类名) */
|
||||
export function statusTone(status) {
|
||||
const key = String(status || '').trim().toLowerCase();
|
||||
if (key === 'completed') return 'success';
|
||||
if (key === 'checking') return 'warning';
|
||||
if (key === 'rejected') return 'danger';
|
||||
if (key === 'cancelled') return 'muted';
|
||||
if (key === 'approved') return 'strong';
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 明细盘点进度文案 */
|
||||
export function detailStatusText(status) {
|
||||
const map = {
|
||||
none_checked: '未盘',
|
||||
partial_checked: '部分已盘',
|
||||
all_checked: '全部已盘'
|
||||
};
|
||||
const key = String(status || '').trim().toLowerCase();
|
||||
return map[key] || '';
|
||||
}
|
||||
|
||||
/** 盘点类型文案:goods=商品盘点 / location=库位盘点 */
|
||||
export function typeText(type) {
|
||||
const map = {
|
||||
goods: '商品盘点',
|
||||
location: '库位盘点'
|
||||
};
|
||||
const key = String(type || '').trim().toLowerCase();
|
||||
return map[key] || (type ? String(type) : '--');
|
||||
}
|
||||
|
||||
/** 盘点类型色调:goods/location */
|
||||
export function typeTone(type) {
|
||||
const key = String(type || '').trim().toLowerCase();
|
||||
if (key === 'goods') return 'goods';
|
||||
if (key === 'location') return 'location';
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 盘点方式文案 */
|
||||
export function modeText(mode) {
|
||||
const map = {
|
||||
all: '全盘',
|
||||
full: '全盘',
|
||||
open: '明盘',
|
||||
blind: '盲盘',
|
||||
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) : '');
|
||||
}
|
||||
|
||||
/** 类型 + 方式 */
|
||||
export function composeType(type, mode) {
|
||||
const t = typeText(type);
|
||||
const m = modeText(mode);
|
||||
if (t === '--') return m || '--';
|
||||
return m ? `${t},${m}` : t;
|
||||
}
|
||||
|
||||
/** 时间格式化(yyyy-MM-dd HH:mm:ss) */
|
||||
export function formatDateTime(value) {
|
||||
if (value === null || value === undefined || value === '') return '';
|
||||
const date = new Date(String(value).trim());
|
||||
if (Number.isNaN(date.getTime())) return String(value).trim();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hour = String(date.getHours()).padStart(2, '0');
|
||||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||||
const second = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
|
||||
/** 扫码结果归一化:兼容字符串 / {result:[]} / {data} 等多种回调结构 */
|
||||
export function 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 '';
|
||||
}
|
||||
|
||||
// ===== 响应体解析 =====
|
||||
|
||||
/** 取响应里的第一个普通对象(各接口包裹层级不一) */
|
||||
export function extractObjectPayload(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 {};
|
||||
}
|
||||
|
||||
/** 取响应里的第一个数组(rows/list/items/records/details 等) */
|
||||
export function extractListPayload(payload, response) {
|
||||
const candidates = [
|
||||
payload?.rows,
|
||||
payload?.list,
|
||||
payload?.items,
|
||||
payload?.records,
|
||||
payload?.details,
|
||||
payload?.data?.rows,
|
||||
payload?.data?.list,
|
||||
payload?.data?.items,
|
||||
response?.data?.rows,
|
||||
response?.data?.list,
|
||||
response?.data?.data?.rows,
|
||||
response?.data?.data?.list,
|
||||
response?.rows,
|
||||
response?.list
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
if (Array.isArray(candidates[i])) return candidates[i];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/** 解析分页总数 */
|
||||
export function resolveListTotal(payload, response, list) {
|
||||
const pagination = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
|
||||
const candidates = [
|
||||
pagination?.total,
|
||||
pagination?.count,
|
||||
payload?.pagination?.total,
|
||||
payload?.total,
|
||||
payload?.count,
|
||||
payload?.totalCount,
|
||||
response?.data?.pagination?.total,
|
||||
response?.data?.total,
|
||||
response?.total,
|
||||
Array.isArray(list) ? list.length : 0
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
const value = Number(candidates[i]);
|
||||
if (Number.isFinite(value) && value >= 0) return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ===== 列表页:请求参数与记录归一化 =====
|
||||
|
||||
/**
|
||||
* 列表状态筛选项
|
||||
* 只展示正式作业与结果:待盘点 / 盘点中 / 已完成;
|
||||
* created(已创建未审核)、submitted(待审核)、rejected(已驳回)、cancelled(已取消)均不在 PDA 列表中拉取
|
||||
*/
|
||||
export const RECORD_STATUS_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待盘点', value: 'approved' },
|
||||
{ label: '盘点中', value: 'checking' },
|
||||
{ label: '已完成', value: 'completed' }
|
||||
];
|
||||
|
||||
/** 列表拉取的状态范围(不含 created / submitted / rejected / cancelled) */
|
||||
const RECORD_VISIBLE_STATUS = ['approved', 'checking', 'completed'];
|
||||
|
||||
/** 构造列表查询参数 */
|
||||
export function buildCheckListParams({ page = 1, pageSize = 20, keyword = '', statusFilter = '' } = {}) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
const size = Math.max(1, Number(pageSize || 20));
|
||||
const params = {
|
||||
pagination: {
|
||||
page: targetPage,
|
||||
pageSize: size
|
||||
}
|
||||
};
|
||||
const where = {};
|
||||
const kw = String(keyword || '').trim();
|
||||
if (kw) {
|
||||
where.keyword = kw;
|
||||
}
|
||||
if (statusFilter) {
|
||||
where.status = statusFilter;
|
||||
} else {
|
||||
where.status = RECORD_VISIBLE_STATUS.slice();
|
||||
}
|
||||
if (Object.keys(where).length) {
|
||||
params.where = where;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/** 列表记录归一化(卡片展示字段) */
|
||||
export function normalizeCheckRecords(list, fallbackPage = 1) {
|
||||
if (!Array.isArray(list)) return [];
|
||||
return list
|
||||
.map((item, index) => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const checkNo = firstValue(source, ['check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no']);
|
||||
const title = firstValue(source, ['title', 'name']);
|
||||
const typeValue = firstValue(source, ['check_type', 'checkType', 'type']);
|
||||
const modeValue = firstValue(source, ['mode', 'check_mode', 'checkMode']);
|
||||
const operator = firstValue(source, [
|
||||
'creator_name', 'creatorName', 'operator_name', 'operatorName',
|
||||
'create_user', 'createUser', 'creator', 'created_by', 'createdBy'
|
||||
]);
|
||||
const timeValue = firstValue(source, ['created_at', 'createdAt', 'create_time', 'createTime']);
|
||||
const status = firstValue(source, ['status', 'check_status', 'checkStatus', 'state']);
|
||||
const totalItems = firstValue(source, ['total_items', 'totalItems']);
|
||||
const checkedItems = firstValue(source, ['checked_items', 'checkedItems']);
|
||||
let progressText = '';
|
||||
if (totalItems !== '') {
|
||||
progressText = checkedItems !== '' ? `${checkedItems}/${totalItems}` : `0/${totalItems}`;
|
||||
}
|
||||
const id = firstValue(source, ['id', 'check_id', 'checkId', 'task_id', 'taskId'])
|
||||
|| `${fallbackPage}-${index + 1}`;
|
||||
const tone = statusTone(status);
|
||||
return {
|
||||
id,
|
||||
checkNo,
|
||||
title,
|
||||
type: typeValue,
|
||||
typeText: composeType(typeValue, modeValue),
|
||||
typeLabel: typeText(typeValue),
|
||||
typeClass: typeTone(typeValue) ? `record-card__type--${typeTone(typeValue)}` : '',
|
||||
operator,
|
||||
progressText,
|
||||
status,
|
||||
statusText: statusText(status),
|
||||
statusClass: tone ? `record-card__status--${tone}` : '',
|
||||
timeText: formatDateTime(timeValue)
|
||||
};
|
||||
})
|
||||
.filter(item => !!(item.checkNo || item.title || item.operator));
|
||||
}
|
||||
|
||||
// ===== 详情页:单头与明细归一化 =====
|
||||
|
||||
/** 单头信息归一化(check.detail / check.workData / check.result 的 check 同口径,覆盖全部字段) */
|
||||
export function normalizeCheckTaskInfo(check) {
|
||||
const source = check && typeof check === 'object' ? check : {};
|
||||
const id = firstValue(source, ['id']);
|
||||
const checkNo = firstValue(source, ['check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no']);
|
||||
const title = firstValue(source, ['title', 'name']);
|
||||
const typeValue = firstValue(source, ['check_type', 'checkType', 'type']);
|
||||
const modeValue = firstValue(source, ['mode', 'check_mode', 'checkMode']);
|
||||
const status = firstValue(source, ['status', 'check_status', 'checkStatus', 'state']);
|
||||
const totalItems = Number(firstValue(source, ['total_items', 'totalItems'])) || 0;
|
||||
const checkedItems = Number(firstValue(source, ['checked_items', 'checkedItems'])) || 0;
|
||||
const diffItems = Number(firstValue(source, ['diff_items', 'diffItems'])) || 0;
|
||||
const detailStatus = firstValue(source, ['detail_status', 'detailStatus']);
|
||||
const storeIdRaw = firstValue(source, ['store_id', 'storeId']);
|
||||
const storeName = firstValue(source, ['store_name', 'storeName']);
|
||||
const creatorId = firstValue(source, ['creator_id', 'creatorId']);
|
||||
const creatorName = firstValue(source, ['creator_name', 'creatorName', 'creator']);
|
||||
const remark = firstValue(source, ['remark']);
|
||||
const tone = statusTone(status);
|
||||
return {
|
||||
id,
|
||||
checkNo,
|
||||
title,
|
||||
// 盘点类型(商品盘点/库位盘点)与盘点方式(明盘/盲盘)分开展示
|
||||
type: typeValue,
|
||||
typeText: typeText(typeValue),
|
||||
mode: modeValue,
|
||||
modeText: modeText(modeValue),
|
||||
storeId: storeIdRaw === '' ? null : storeIdRaw,
|
||||
storeName,
|
||||
status,
|
||||
statusText: statusText(status),
|
||||
statusClass: tone ? `summary-panel__value--${tone}` : '',
|
||||
detailStatus,
|
||||
detailStatusText: detailStatusText(detailStatus),
|
||||
totalItems,
|
||||
checkedItems,
|
||||
diffItems,
|
||||
creatorId,
|
||||
creatorName,
|
||||
remark,
|
||||
startTimeText: formatDateTime(firstValue(source, ['start_time', 'startTime'])),
|
||||
endTimeText: formatDateTime(firstValue(source, ['end_time', 'endTime'])),
|
||||
createTimeText: formatDateTime(firstValue(source, ['created_at', 'createdAt', 'create_time', 'createTime'])),
|
||||
updateTimeText: formatDateTime(firstValue(source, ['updated_at', 'updatedAt', 'update_time', 'updateTime']))
|
||||
};
|
||||
}
|
||||
|
||||
/** 依据已盘/差异数量刷新差异文案与样式类 */
|
||||
export function applyItemDiffText(item) {
|
||||
if (!item || !item.reported) {
|
||||
if (item) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
/** 明细归一化(商品/库位、账面/实盘/差异) */
|
||||
export function normalizeCheckItemList(list) {
|
||||
if (!Array.isArray(list)) return [];
|
||||
return list.map((item, index) => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const barcode = firstValue(source, ['item_code', 'itemCode', 'barcode', 'bar_code']);
|
||||
const name = firstValue(source, ['item_name', 'itemName', 'product_name', 'name', 'stock_name']);
|
||||
const spec = firstValue(source, ['spec', 'specification', 'sku_property']);
|
||||
const batchNo = firstValue(source, ['batch_no', 'batchNo', 'batch_number']);
|
||||
const locationCode = firstValue(source, ['location_code', 'locationCode', 'space_code', 'spaceCode']);
|
||||
const systemRaw = firstValue(source, ['system_quantity', 'systemQuantity', 'book_quantity', 'stock_quantity', 'quantity']);
|
||||
const checkRaw = firstValue(source, ['checked_quantity', 'checkedQuantity', 'check_quantity', 'checkQuantity']);
|
||||
const diffRaw = firstValue(source, ['diff_quantity', 'diffQuantity']);
|
||||
const detailId = 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
|
||||
};
|
||||
applyItemDiffText(normalized);
|
||||
return normalized;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 盘点明细结果行归一化(stock.check.result,供明细 tab 只读展示)
|
||||
* 商品行:挂 stock 商品快照 + checked_quantity/diff_quantity/is_diff/status
|
||||
* 库位行:以 location_code 为主标识,含 is_empty/行级 checked_quantity
|
||||
*/
|
||||
export function normalizeCheckResultRows(rows) {
|
||||
if (!Array.isArray(rows)) return [];
|
||||
return rows.map((row, index) => {
|
||||
const source = row && typeof row === 'object' ? row : {};
|
||||
const stock = source.stock && typeof source.stock === 'object' ? source.stock : {};
|
||||
const scopeType = firstValue(source, ['scope_type', 'scopeType']).toLowerCase();
|
||||
const isGoods = scopeType !== 'location';
|
||||
const locationCode = firstValue(source, ['location_code', 'locationCode']);
|
||||
const itemCode = firstValue(source, ['item_code', 'itemCode'])
|
||||
|| firstValue(stock, ['item_code', 'itemCode', 'barcode', 'bar_code']);
|
||||
const itemName = firstValue(source, ['item_name', 'itemName'])
|
||||
|| firstValue(stock, ['item_name', 'itemName', 'product_name', 'name']);
|
||||
const spec = firstValue(source, ['spec']) || firstValue(stock, ['spec', 'specification']);
|
||||
const batchNo = firstValue(source, ['batch_no', 'batchNo']);
|
||||
const detailId = firstValue(source, ['id', 'detail_id', 'detailId']) || `${index + 1}`;
|
||||
const systemRaw = source.system_quantity !== undefined && source.system_quantity !== null
|
||||
? source.system_quantity : source.systemQuantity;
|
||||
const checkedRaw = source.checked_quantity !== undefined && source.checked_quantity !== null
|
||||
? source.checked_quantity : source.checkedQuantity;
|
||||
const diffRaw = source.diff_quantity !== undefined && source.diff_quantity !== null
|
||||
? source.diff_quantity : source.diffQuantity;
|
||||
const status = firstValue(source, ['status']).toLowerCase();
|
||||
const isEmpty = source.is_empty === 1 || source.is_empty === true;
|
||||
const systemNumber = toNumberOrNull(systemRaw);
|
||||
const checkedNumber = toNumberOrNull(checkedRaw);
|
||||
const reported = isEmpty || status === 'checked' || checkedNumber !== null;
|
||||
const normalized = {
|
||||
key: `${detailId}`,
|
||||
detailId,
|
||||
scopeType: isGoods ? 'goods' : 'location',
|
||||
name: isGoods ? (itemName || itemCode || '--') : (locationCode || `明细 #${detailId}`),
|
||||
barcode: itemCode,
|
||||
spec,
|
||||
batchNo,
|
||||
locationCode: isGoods ? locationCode : '',
|
||||
isEmpty,
|
||||
systemQuantity: systemNumber,
|
||||
systemQuantityText: systemNumber === null ? '--' : String(systemNumber),
|
||||
checkQuantity: checkedNumber,
|
||||
diffQuantity: toNumberOrNull(diffRaw),
|
||||
reported,
|
||||
inputValue: reported && checkedNumber !== null ? String(checkedNumber) : (isEmpty ? '0' : ''),
|
||||
diffText: '',
|
||||
diffClass: '',
|
||||
reporting: false
|
||||
};
|
||||
applyItemDiffText(normalized);
|
||||
return normalized;
|
||||
});
|
||||
}
|
||||
|
||||
// ===== 作业列表(stock.check.workData)=====
|
||||
|
||||
/** 商品类任务:type=goods/store(库位类任务 type=location/all) */
|
||||
export function isGoodsTask(type) {
|
||||
const key = String(type || '').trim().toLowerCase();
|
||||
return key === 'goods' || key === 'store';
|
||||
}
|
||||
|
||||
/** 任务是否明盘(open);盲盘(blind)接口不返回任何数量字段 */
|
||||
export function isOpenCheckMode(mode) {
|
||||
return String(mode || '').trim().toLowerCase() === 'open';
|
||||
}
|
||||
|
||||
/**
|
||||
* 作业解析视图:
|
||||
* 库位任务(location/all)一律 location;商品任务(goods/store)默认 space,isGoods=true 时为 goods
|
||||
*/
|
||||
export function resolveWorkView(type, isGoods) {
|
||||
if (!isGoodsTask(type)) return 'location';
|
||||
return isGoods ? 'goods' : 'space';
|
||||
}
|
||||
|
||||
function toNumberOrNull(value) {
|
||||
if (value === null || value === undefined || value === '') return null;
|
||||
const num = Number(value);
|
||||
return Number.isFinite(num) ? num : null;
|
||||
}
|
||||
|
||||
/** 布尔字段归一化(兼容 true/1/'1'/'true') */
|
||||
function toBool(value) {
|
||||
if (value === true || value === 1) return true;
|
||||
const key = String(value === null || value === undefined ? '' : value).trim().toLowerCase();
|
||||
return key === '1' || key === 'true';
|
||||
}
|
||||
|
||||
/** 宫格格子里显示的短库位号(取末两段,如 E07-01-02-01 → 02-01) */
|
||||
export function shortLocationLabel(code) {
|
||||
const text = String(code || '').trim();
|
||||
if (!text) return '';
|
||||
const parts = text.split('-').filter(part => part !== '');
|
||||
if (parts.length <= 2) return text;
|
||||
return parts.slice(-2).join('-');
|
||||
}
|
||||
|
||||
function toNumberString(value) {
|
||||
const num = toNumberOrNull(value);
|
||||
return num === null ? '' : String(num);
|
||||
}
|
||||
|
||||
/** 明盘数量块(盲盘返回 null,不展示任何数量) */
|
||||
function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open) {
|
||||
if (!open) return null;
|
||||
const sys = toNumberOrNull(systemQuantity);
|
||||
const chk = toNumberOrNull(checkedQuantity);
|
||||
let diff = toNumberOrNull(diffQuantity);
|
||||
if (diff === null && sys !== null && chk !== null) diff = chk - sys;
|
||||
return {
|
||||
systemText: sys === null ? '--' : String(sys),
|
||||
checkedText: chk === null ? '--' : String(chk),
|
||||
diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${diff}` : '账实相符')),
|
||||
diffClass: diff === null ? '' : (diff > 0 ? 'work-card__diff--gain' : (diff < 0 ? 'work-card__diff--loss' : 'work-card__diff--match'))
|
||||
};
|
||||
}
|
||||
|
||||
/** 录入单元:detailId + location + 输入值(original 用于判断是否已修改) */
|
||||
function buildWorkUnit(detailId, location, currentQuantity, reported, stockId) {
|
||||
const value = toNumberString(currentQuantity);
|
||||
const done = !!reported;
|
||||
return {
|
||||
detailId: detailId ? String(detailId) : '',
|
||||
location: location ? String(location) : '',
|
||||
stockId: stockId === undefined || stockId === null ? '' : String(stockId),
|
||||
inputValue: done ? value : '',
|
||||
original: done ? value : '',
|
||||
reported: done,
|
||||
reporting: false
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 check.report 入参(按 https 文档口径)
|
||||
* - 商品明细行:stock_id 固定为明细商品;location 可选(未传归入无库位分组)
|
||||
* - 库位明细行:必须带商品(stock_id 或 barcode 至少一项),location 以明细库位为准
|
||||
* - 未知商品:只传 barcode(item_name 可选,缺省为条码)
|
||||
* - 空库位标记:is_empty=true(仅库位明细行,quantity 恒为 0)
|
||||
*/
|
||||
export function buildReportParams(taskId, payload = {}) {
|
||||
const isEmpty = !!payload.isEmpty;
|
||||
const params = {
|
||||
id: Number(taskId),
|
||||
detail_id: Number(payload.detailId),
|
||||
quantity: isEmpty ? 0 : Number(payload.quantity)
|
||||
};
|
||||
if (isEmpty) {
|
||||
params.is_empty = true;
|
||||
return params;
|
||||
}
|
||||
const location = String(payload.location || '').trim();
|
||||
if (location) params.location = location;
|
||||
const stockId = payload.stockId;
|
||||
if (stockId !== undefined && stockId !== null && String(stockId).trim() !== '') {
|
||||
params.stock_id = Number(stockId);
|
||||
}
|
||||
const barcode = String(payload.barcode || '').trim();
|
||||
if (barcode) params.barcode = barcode;
|
||||
const itemName = String(payload.itemName || '').trim();
|
||||
if (itemName) params.item_name = itemName;
|
||||
return params;
|
||||
}
|
||||
|
||||
function joinText(parts, sep = ' · ') {
|
||||
return parts.filter(part => part !== null && part !== undefined && String(part).trim() !== '').map(part => String(part).trim()).join(sep);
|
||||
}
|
||||
|
||||
/** space 视图:行=库位,goods 为该库位下的任务商品(商品任务默认视图) */
|
||||
function normalizeSpaceWorkRow(item, index, open) {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const spaceCode = firstValue(source, ['space_code', 'spaceCode']) || `#${index + 1}`;
|
||||
const rawGoods = Array.isArray(source.goods) ? source.goods : [];
|
||||
const children = rawGoods.map((row, goodIndex) => {
|
||||
const good = row && typeof row === 'object' ? row : {};
|
||||
const detailId = firstValue(good, ['detail_id', 'detailId']);
|
||||
const checkedRaw = good.checked_quantity !== undefined ? good.checked_quantity : good.checkedQuantity;
|
||||
const done = String(good.status || '').trim().toLowerCase() === 'checked';
|
||||
return {
|
||||
key: `${spaceCode}-${detailId || goodIndex + 1}`,
|
||||
title: firstValue(good, ['item_name', 'itemName']) || '--',
|
||||
subtitle: joinText([firstValue(good, ['barcode']), firstValue(good, ['spec']), firstValue(good, ['store_name', 'storeName'])]),
|
||||
statusText: done ? '已盘' : '未盘',
|
||||
statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
|
||||
amount: buildWorkAmount(good.system_quantity !== undefined ? good.system_quantity : good.systemQuantity, checkedRaw, null, open),
|
||||
quantityText: '',
|
||||
unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId']))
|
||||
};
|
||||
});
|
||||
return {
|
||||
key: `space-${firstValue(source, ['id']) || spaceCode}`,
|
||||
view: 'space',
|
||||
title: spaceCode,
|
||||
subtitle: joinText([firstValue(source, ['custom_name', 'customName']), firstValue(source, ['custom_barcode', 'customBarcode'])]),
|
||||
statusText: '',
|
||||
statusClass: '',
|
||||
meta: children.length ? [] : [{ label: '商品', value: '该库位暂无任务商品' }],
|
||||
amount: null,
|
||||
quantityText: '',
|
||||
children,
|
||||
unit: null
|
||||
};
|
||||
}
|
||||
|
||||
/** goods 视图:行=商品,locations 为按库位聚合的作业记录(商品任务的 is_goods=true) */
|
||||
function normalizeGoodsWorkRow(item, index, open) {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const detailId = firstValue(source, ['detail_id', 'detailId']);
|
||||
const checkedRaw = source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity;
|
||||
const rawLocations = Array.isArray(source.locations) ? source.locations : [];
|
||||
const children = rawLocations.map((row, locIndex) => {
|
||||
const loc = row && typeof row === 'object' ? row : {};
|
||||
const code = firstValue(loc, ['location_code', 'locationCode']);
|
||||
const time = firstValue(loc, ['checked_at', 'checkedAt']);
|
||||
return {
|
||||
key: `${detailId || index + 1}-loc-${locIndex + 1}`,
|
||||
title: code || '未指定库位',
|
||||
subtitle: joinText([firstValue(loc, ['checker_name', 'checkerName']), time ? formatDateTime(time) : '']),
|
||||
statusText: '',
|
||||
statusClass: '',
|
||||
amount: null,
|
||||
quantityText: open && loc.quantity !== undefined && loc.quantity !== null ? String(loc.quantity) : '',
|
||||
unit: null
|
||||
};
|
||||
});
|
||||
const reported = checkedRaw !== undefined && checkedRaw !== null && checkedRaw !== '';
|
||||
return {
|
||||
key: `goods-${detailId || index + 1}`,
|
||||
view: 'goods',
|
||||
title: firstValue(source, ['item_name', 'itemName']) || '--',
|
||||
subtitle: joinText([firstValue(source, ['spec']), firstValue(source, ['barcode']), firstValue(source, ['store_name', 'storeName'])]),
|
||||
statusText: '',
|
||||
statusClass: '',
|
||||
meta: children.length ? [] : [{ label: '库位', value: '暂无作业记录' }],
|
||||
amount: buildWorkAmount(source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity, checkedRaw, source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity, open),
|
||||
quantityText: '',
|
||||
children,
|
||||
unit: buildWorkUnit(detailId, '', checkedRaw, reported, firstValue(source, ['stock_id', 'stockId']))
|
||||
};
|
||||
}
|
||||
|
||||
/** location 视图:行=任务库位,goods 为该库位的作业记录(未知商品也在 goods 内,stock_id=null) */
|
||||
function normalizeLocationWorkRow(item, index, open) {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const locationCode = firstValue(source, ['location_code', 'locationCode']) || `#${index + 1}`;
|
||||
const detailId = firstValue(source, ['detail_id', 'detailId']);
|
||||
const status = String(source.status || '').trim().toLowerCase();
|
||||
const done = status === 'checked';
|
||||
const rawGoods = Array.isArray(source.goods) ? source.goods : [];
|
||||
const children = [];
|
||||
rawGoods.forEach((row, goodIndex) => {
|
||||
const good = row && typeof row === 'object' ? row : {};
|
||||
const qty = toNumberOrNull(good.quantity);
|
||||
// 未知商品:stock_id 为空(后端已不再返回独立 unknown 子列表)
|
||||
const stockIdRaw = good.stock_id !== undefined && good.stock_id !== null ? good.stock_id : good.stockId;
|
||||
const unknown = stockIdRaw === undefined || stockIdRaw === null || String(stockIdRaw).trim() === '';
|
||||
const itemCode = firstValue(good, ['item_code', 'itemCode', 'barcode']);
|
||||
const checkerName = firstValue(good, ['checker_name', 'checkerName']);
|
||||
// 用 record_id 做稳定 key:删记录后剩下的项不会因下标位移而复用旧的左滑节点
|
||||
const recordId = firstValue(good, ['record_id', 'recordId']);
|
||||
children.push({
|
||||
key: `${locationCode}-${unknown ? 'u' : 'g'}-${recordId || goodIndex + 1}`,
|
||||
recordId,
|
||||
stockId: unknown ? '' : String(stockIdRaw),
|
||||
title: firstValue(good, ['item_name', 'itemName']) || itemCode || (unknown ? '未知商品' : '--'),
|
||||
subtitle: joinText([
|
||||
itemCode,
|
||||
unknown ? '未知商品' : firstValue(good, ['store_name', 'storeName']),
|
||||
checkerName ? `盘点人 ${checkerName}` : ''
|
||||
]),
|
||||
statusText: unknown ? '未知' : '',
|
||||
statusClass: unknown ? 'work-card__tag--unknown' : '',
|
||||
amount: null,
|
||||
quantityText: qty === null ? '' : String(qty),
|
||||
images: Array.isArray(good.images) ? good.images : [],
|
||||
unknown,
|
||||
unit: null
|
||||
});
|
||||
});
|
||||
const unknownCount = children.filter(child => child.unknown).length;
|
||||
const goodsCount = children.length - unknownCount;
|
||||
const checkersRaw = source.checkers;
|
||||
const checkers = Array.isArray(checkersRaw) ? checkersRaw.filter(Boolean).join('、') : '';
|
||||
const checkedAt = firstValue(source, ['checked_at', 'checkedAt']);
|
||||
const checkedAtText = checkedAt ? formatDateTime(checkedAt) : '';
|
||||
const locationName = firstValue(source, ['location_name', 'locationName']);
|
||||
const isEmpty = toBool(source.is_empty);
|
||||
const hasUnknown = toBool(source.has_unknown);
|
||||
const meta = [];
|
||||
if (checkers) meta.push({ label: '盘点人', value: checkers });
|
||||
if (checkedAtText) meta.push({ label: '最近上报', value: checkedAtText });
|
||||
if (hasUnknown) meta.push({ label: '提示', value: '含未知商品' });
|
||||
return {
|
||||
key: `location-${detailId || locationCode}`,
|
||||
view: 'location',
|
||||
detailId: detailId ? String(detailId) : '',
|
||||
location: locationCode,
|
||||
title: locationCode,
|
||||
subtitle: locationName && locationName !== locationCode ? locationName : '',
|
||||
// 原始 location_name(跳转库位明细页时携带)
|
||||
locationName: locationName || locationCode,
|
||||
statusText: done ? '已盘' : '未盘',
|
||||
statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
|
||||
// 宫格 / 明细面板展示字段
|
||||
empty: isEmpty,
|
||||
checked: done,
|
||||
hasUnknown,
|
||||
checkersText: checkers,
|
||||
checkedAtText,
|
||||
goodsCount,
|
||||
unknownCount,
|
||||
// 宫格主文本:优先完整 location_name,缺失时回退 location_code
|
||||
gridText: locationName || locationCode,
|
||||
gridLabel: shortLocationLabel(locationCode),
|
||||
meta,
|
||||
amount: null,
|
||||
quantityText: '',
|
||||
children,
|
||||
// 库位明细行不直接录入数量:在库位下逐条添加商品记录,或标记空库位
|
||||
unit: null,
|
||||
actions: [
|
||||
{ key: 'add-goods', text: '添加商品' },
|
||||
{ key: 'mark-empty', text: '标记空库位' }
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
/** 作业数据行归一化(view: space / goods / location) */
|
||||
export function normalizeWorkRows(rows, view, mode) {
|
||||
if (!Array.isArray(rows)) return [];
|
||||
const open = isOpenCheckMode(mode);
|
||||
return rows.map((item, index) => {
|
||||
if (view === 'goods') return normalizeGoodsWorkRow(item, index, open);
|
||||
if (view === 'location') return normalizeLocationWorkRow(item, index, open);
|
||||
return normalizeSpaceWorkRow(item, index, open);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条盘点明细作业数据归一化(stock.check.workDataDetail)
|
||||
* 返回结构与 workData location 视图单行一致;payload 为空时返回 null。
|
||||
*/
|
||||
export function normalizeLocationWorkDetail(payload, mode) {
|
||||
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return null;
|
||||
if (!Object.keys(payload).length) return null;
|
||||
return normalizeLocationWorkRow(payload, 0, isOpenCheckMode(mode));
|
||||
}
|
||||
|
||||
/** 作业行内可录入单元(行级 + 子项级) */
|
||||
export function collectWorkUnits(row) {
|
||||
if (!row) return [];
|
||||
const units = [];
|
||||
if (row.unit) units.push(row.unit);
|
||||
if (Array.isArray(row.children)) {
|
||||
row.children.forEach(child => {
|
||||
if (child && child.unit) units.push(child.unit);
|
||||
});
|
||||
}
|
||||
return units;
|
||||
}
|
||||
|
||||
/** 作业行内可用于扫码定位的文本(主标题/副标题 + 子项标题/副标题) */
|
||||
export function collectWorkSearchTexts(row) {
|
||||
if (!row) return [];
|
||||
const texts = [row.title, row.subtitle];
|
||||
if (Array.isArray(row.children)) {
|
||||
row.children.forEach(child => {
|
||||
if (!child) return;
|
||||
texts.push(child.title, child.subtitle);
|
||||
});
|
||||
}
|
||||
return texts.filter(text => text !== null && text !== undefined && String(text).trim() !== '');
|
||||
}
|
||||
|
||||
// ===== 选择器共用的查询结果归一化(stock.warehouse.search / common.searchSpace)=====
|
||||
|
||||
/** 从各接口包裹层级里取数组 */
|
||||
export function pickResponseRows(response) {
|
||||
const candidates = [
|
||||
response?.data,
|
||||
response?.rows,
|
||||
response?.list,
|
||||
response?.data?.rows,
|
||||
response?.data?.list
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
if (Array.isArray(candidates[i])) return candidates[i];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/** 商品图片归一化成 URL 数组(兼容字符串 / {url|path|image_url|fileUrl|successUrl} / {file:{file_url}}) */
|
||||
export function normalizeImageUrls(list) {
|
||||
if (!Array.isArray(list)) return [];
|
||||
return list
|
||||
.map(image => {
|
||||
if (!image) return '';
|
||||
if (typeof image === 'string') return image.trim();
|
||||
if (typeof image !== 'object') return '';
|
||||
const file = image.file && typeof image.file === 'object' ? image.file : {};
|
||||
return String(
|
||||
image.url || image.path || image.image_url || image.fileUrl || image.successUrl
|
||||
|| file.file_url || file.url || file.path || ''
|
||||
).trim();
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/** 商品搜索结果归一化:id=wms_stock_warehouse.id(即 report/addDetail 的 stock_id) */
|
||||
export function normalizeStockSearchRows(response) {
|
||||
return pickResponseRows(response).map((row, index) => {
|
||||
const source = row && typeof row === 'object' ? row : {};
|
||||
const name = source.item_name || source.product_name || source.name || source.goods_name || '未命名商品';
|
||||
const barcodeList = Array.isArray(source.barcodes) ? source.barcodes.filter(Boolean) : [];
|
||||
const barcode = source.barcode || source.goods_code || source.item_code || barcodeList.join(';');
|
||||
const storeStock = source.store_stock || {};
|
||||
const storeName = storeStock.store_remask || storeStock.store_name || source.store_name || '';
|
||||
const spec = source.spec || source.specification || '';
|
||||
return {
|
||||
key: `goods-${source.id || index}`,
|
||||
id: source.id === undefined || source.id === null ? '' : source.id,
|
||||
code: barcode,
|
||||
title: name,
|
||||
subtitle: [barcode, spec, storeName].filter(Boolean).join(' · '),
|
||||
images: normalizeImageUrls(source.images)
|
||||
};
|
||||
}).filter(item => item.id !== '');
|
||||
}
|
||||
|
||||
/** 库位搜索结果归一化 */
|
||||
export function normalizeSpaceSearchRows(response) {
|
||||
return pickResponseRows(response).map((row, index) => {
|
||||
const source = row && typeof row === 'object' ? row : {};
|
||||
const code = source.space_code || source.spaceCode || '';
|
||||
return {
|
||||
key: `space-${source.id || code || index}`,
|
||||
id: source.id === undefined || source.id === null ? '' : source.id,
|
||||
code,
|
||||
title: code || `库位 #${index + 1}`,
|
||||
subtitle: [source.custom_name, source.custom_barcode ? `条码:${source.custom_barcode}` : ''].filter(Boolean).join(' · ')
|
||||
};
|
||||
}).filter(item => item.id !== '');
|
||||
}
|
||||
@ -3,87 +3,40 @@
|
||||
<view class="normar_container">
|
||||
<page-nav title="库存盘点"></page-nav>
|
||||
|
||||
<!-- 搜索区 -->
|
||||
<view class="search-panel">
|
||||
<view class="search-input-wrap">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="请输入/扫描盘点单号或标题"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleSearch"
|
||||
@clear="handleClear"
|
||||
></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="handleSearch">
|
||||
<text class="search-btn__text">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="filter-scroll" scroll-x :show-scrollbar="false">
|
||||
<view class="filter-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="filter-group__item"
|
||||
:class="{ 'filter-group__item--active': statusFilter === opt.value }"
|
||||
@click="handleStatusChange(opt.value)"
|
||||
>
|
||||
<text class="filter-group__item-text">{{ opt.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 搜索区 + 状态筛选 -->
|
||||
<count-list-toolbar
|
||||
v-model="keyword"
|
||||
:status-options="statusOptions"
|
||||
:status-filter="statusFilter"
|
||||
@search="handleSearch"
|
||||
@clear="handleClear"
|
||||
@scan="handleCameraScan"
|
||||
@status-change="handleStatusChange"
|
||||
/>
|
||||
|
||||
<!-- 列表区 -->
|
||||
<scroll-view class="detail-scroll" scroll-y>
|
||||
<!-- 列表区(支持下拉刷新) -->
|
||||
<scroll-view
|
||||
class="detail-scroll"
|
||||
scroll-y
|
||||
refresher-enabled
|
||||
:refresher-triggered="refreshing"
|
||||
refresher-background="#f8f9fa"
|
||||
@refresherrefresh="handleRefresh"
|
||||
@refresherrestore="handleRefresherRestore"
|
||||
>
|
||||
<view v-if="recordList.length === 0" class="empty-state">
|
||||
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
|
||||
<text class="empty-text">{{ loading ? '加载中...' : '暂无盘点任务' }}</text>
|
||||
<text class="empty-hint">{{ keyword ? '请检查关键字后重试' : '请在上方输入关键字查询' }}</text>
|
||||
</view>
|
||||
<view v-else class="record-list">
|
||||
<view
|
||||
<count-record-card
|
||||
v-for="(item, index) in recordList"
|
||||
:key="item.id || index"
|
||||
class="record-card"
|
||||
:class="{ 'record-card--stripe': index % 2 === 1 }"
|
||||
:item="item"
|
||||
:stripe="index % 2 === 1"
|
||||
@click="handleRecordClick(item)"
|
||||
>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">盘点单号</text>
|
||||
<text class="record-card__value record-card__value--strong">{{ item.checkNo || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="item.title" class="record-card__row">
|
||||
<text class="record-card__label">标题</text>
|
||||
<text class="record-card__value">{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">盘点类型</text>
|
||||
<text class="record-card__value">{{ item.typeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">状态</text>
|
||||
<text class="record-card__value" :class="item.statusClass">{{ item.statusText || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="item.progressText" class="record-card__row">
|
||||
<text class="record-card__label">进度</text>
|
||||
<text class="record-card__value">{{ item.progressText }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">创建人</text>
|
||||
<text class="record-card__value">{{ item.operator || '--' }}</text>
|
||||
</view>
|
||||
<view class="record-card__row record-card__row--last">
|
||||
<text class="record-card__label">创建时间</text>
|
||||
<text class="record-card__value">{{ item.timeText || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
/>
|
||||
</view>
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
@ -108,23 +61,34 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CountListToolbar from './inventoryCount-comps/CountListToolbar.vue';
|
||||
import CountRecordCard from './inventoryCount-comps/CountRecordCard.vue';
|
||||
import {
|
||||
normalizeScanResult,
|
||||
extractObjectPayload,
|
||||
extractListPayload,
|
||||
resolveListTotal,
|
||||
buildCheckListParams,
|
||||
normalizeCheckRecords,
|
||||
RECORD_STATUS_OPTIONS
|
||||
} from './inventoryCount-comps/countModel.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CountListToolbar,
|
||||
CountRecordCard
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
statusFilter: '',
|
||||
statusOptions: [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待盘点', value: 'approved' },
|
||||
{ label: '盘点中', value: 'checking' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '已取消', value: 'cancelled' }
|
||||
],
|
||||
statusOptions: RECORD_STATUS_OPTIONS.slice(),
|
||||
pageSize: 20,
|
||||
currentPage: 1,
|
||||
paginationTotal: 0,
|
||||
recordList: [],
|
||||
loading: false,
|
||||
refreshing: false,
|
||||
_listLoaded: false
|
||||
}
|
||||
},
|
||||
@ -182,20 +146,8 @@ export default {
|
||||
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);
|
||||
const code = normalizeScanResult(result);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.loadRecordList(1);
|
||||
@ -205,7 +157,7 @@ export default {
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = this.normalizeScanResult(res);
|
||||
const code = normalizeScanResult(res);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.loadRecordList(1);
|
||||
@ -213,6 +165,22 @@ export default {
|
||||
fail: () => {}
|
||||
});
|
||||
},
|
||||
// ===== 下拉刷新(scroll-view refresher)=====
|
||||
async handleRefresh() {
|
||||
// 防重入:同一手势可能被重复触发
|
||||
if (this.refreshing) return;
|
||||
this.refreshing = true;
|
||||
try {
|
||||
// 保持当前关键字/状态筛选,回到第一页重拉
|
||||
await this.loadRecordList(1);
|
||||
} finally {
|
||||
this.refreshing = false;
|
||||
uni.stopPullDownRefresh();
|
||||
}
|
||||
},
|
||||
handleRefresherRestore() {
|
||||
this.refreshing = false;
|
||||
},
|
||||
// ===== 查询 =====
|
||||
handleSearch() {
|
||||
this.loadRecordList(1);
|
||||
@ -238,225 +206,21 @@ export default {
|
||||
if (!item || !item.id) return;
|
||||
this.$tools.routerTo(`/pages/warehouse/inventoryCountDetail?id=${encodeURIComponent(item.id)}`);
|
||||
},
|
||||
buildRecordParams(page = this.currentPage) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
const pageSize = Math.max(1, Number(this.pageSize || 20));
|
||||
const params = {
|
||||
pagination: {
|
||||
page: targetPage,
|
||||
pageSize
|
||||
}
|
||||
};
|
||||
const where = {};
|
||||
const keyword = String(this.keyword || '').trim();
|
||||
if (keyword) {
|
||||
where.keyword = keyword;
|
||||
}
|
||||
if (this.statusFilter) {
|
||||
where.status = this.statusFilter;
|
||||
} else {
|
||||
// 列表仅展示以下四种状态,过滤掉 created/submitted/rejected
|
||||
where.status = ['approved', 'checking', 'completed', 'cancelled'];
|
||||
}
|
||||
if (Object.keys(where).length) {
|
||||
params.where = where;
|
||||
}
|
||||
return params;
|
||||
},
|
||||
extractRecordPayload(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 {};
|
||||
},
|
||||
extractRecordList(payload, response) {
|
||||
const candidates = [
|
||||
payload?.list,
|
||||
payload?.rows,
|
||||
payload?.items,
|
||||
payload?.records,
|
||||
payload?.data?.list,
|
||||
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 [];
|
||||
},
|
||||
resolveRecordTotal(payload, response, list) {
|
||||
const pagination = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
|
||||
const candidates = [
|
||||
pagination?.total,
|
||||
pagination?.count,
|
||||
payload?.pagination?.total,
|
||||
payload?.total,
|
||||
payload?.count,
|
||||
payload?.totalCount,
|
||||
response?.data?.pagination?.total,
|
||||
response?.data?.total,
|
||||
response?.total,
|
||||
Array.isArray(list) ? list.length : 0
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
const value = Number(candidates[i]);
|
||||
if (Number.isFinite(value) && value >= 0) return value;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
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 '';
|
||||
},
|
||||
formatDateTime(value) {
|
||||
if (value === null || value === undefined || value === '') return '';
|
||||
const date = new Date(String(value).trim());
|
||||
if (Number.isNaN(date.getTime())) return String(value).trim();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hour = String(date.getHours()).padStart(2, '0');
|
||||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||||
const second = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
},
|
||||
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 'record-card__value--success';
|
||||
}
|
||||
if (key === 'checking') {
|
||||
return 'record-card__value--warning';
|
||||
}
|
||||
if (key === 'rejected') {
|
||||
return 'record-card__value--danger';
|
||||
}
|
||||
if (key === 'cancelled') {
|
||||
return 'record-card__value--muted';
|
||||
}
|
||||
if (key === 'approved') {
|
||||
return 'record-card__value--strong';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
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;
|
||||
},
|
||||
normalizeRecordList(list) {
|
||||
if (!Array.isArray(list)) return [];
|
||||
return list
|
||||
.map((item, index) => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
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 operator = this.firstValue(source, [
|
||||
'creator_name', 'creatorName', 'operator_name', 'operatorName',
|
||||
'create_user', 'createUser', 'creator', 'created_by', 'createdBy'
|
||||
]);
|
||||
const timeValue = this.firstValue(source, [
|
||||
'created_at', 'createdAt', 'create_time', 'createTime'
|
||||
]);
|
||||
const status = this.firstValue(source, ['status', 'check_status', 'checkStatus', 'state']);
|
||||
const totalItems = this.firstValue(source, ['total_items', 'totalItems']);
|
||||
const checkedItems = this.firstValue(source, ['checked_items', 'checkedItems']);
|
||||
let progressText = '';
|
||||
if (totalItems !== '') {
|
||||
progressText = checkedItems !== '' ? `${checkedItems}/${totalItems}` : `0/${totalItems}`;
|
||||
}
|
||||
const id = this.firstValue(source, ['id', 'check_id', 'checkId', 'task_id', 'taskId'])
|
||||
|| `${this.currentPage}-${index + 1}`;
|
||||
return {
|
||||
id,
|
||||
checkNo,
|
||||
title,
|
||||
typeText: this.composeType(typeValue, modeValue),
|
||||
operator,
|
||||
progressText,
|
||||
status,
|
||||
statusText: this.statusText(status),
|
||||
statusClass: this.statusClass(status),
|
||||
timeText: this.formatDateTime(timeValue)
|
||||
};
|
||||
})
|
||||
.filter(item => !!(item.checkNo || item.title || item.operator));
|
||||
},
|
||||
async loadRecordList(page = this.currentPage) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await this.$http('check.list', this.buildRecordParams(targetPage));
|
||||
const payload = this.extractRecordPayload(response);
|
||||
const list = this.extractRecordList(payload, response);
|
||||
this.recordList = this.normalizeRecordList(list);
|
||||
this.paginationTotal = this.resolveRecordTotal(payload, response, list);
|
||||
const params = buildCheckListParams({
|
||||
page: targetPage,
|
||||
pageSize: this.pageSize,
|
||||
keyword: this.keyword,
|
||||
statusFilter: this.statusFilter
|
||||
});
|
||||
const response = await this.$http('check.list', params);
|
||||
const payload = extractObjectPayload(response);
|
||||
const list = extractListPayload(payload, response);
|
||||
this.recordList = normalizeCheckRecords(list, targetPage);
|
||||
this.paginationTotal = resolveListTotal(payload, response, list);
|
||||
const pageInfo = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
|
||||
const pageNo = Number(pageInfo?.page ?? payload?.page ?? targetPage);
|
||||
this.currentPage = Number.isFinite(pageNo) && pageNo > 0 ? pageNo : targetPage;
|
||||
@ -488,129 +252,6 @@ export default {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 搜索区 */
|
||||
.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;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content__close {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 状态筛选行(横向滚动) */
|
||||
.filter-row {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.filter-scroll {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-group__item {
|
||||
flex: none;
|
||||
height: 56rpx;
|
||||
padding: 0 24rpx;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.filter-group__item + .filter-group__item {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.filter-group__item--active {
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.28);
|
||||
}
|
||||
|
||||
.filter-group__item-text {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group__item--active .filter-group__item-text {
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 列表区 */
|
||||
.detail-scroll {
|
||||
flex: 1;
|
||||
@ -647,77 +288,6 @@ export default {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
padding: 4rpx 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.record-card--stripe {
|
||||
background: #dde9fb;
|
||||
border-color: #dfe7f5;
|
||||
}
|
||||
|
||||
.record-card--stripe .record-card__label {
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.record-card__row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f0f2f5;
|
||||
}
|
||||
|
||||
.record-card__row--last {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.record-card__label {
|
||||
flex-shrink: 0;
|
||||
width: 160rpx;
|
||||
font-size: 36rpx;
|
||||
color: #8a9099;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.record-card__value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 40rpx;
|
||||
color: #303133;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.record-card__value--strong {
|
||||
font-weight: 600;
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.record-card__value--success {
|
||||
font-weight: 600;
|
||||
color: #18a058;
|
||||
}
|
||||
|
||||
.record-card__value--warning {
|
||||
font-weight: 600;
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.record-card__value--danger {
|
||||
font-weight: 600;
|
||||
color: #e64340;
|
||||
}
|
||||
|
||||
.record-card__value--muted {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.safe-area-bottom {
|
||||
height: calc(20rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
524
src/pages/warehouse/inventoryCountLocation.vue
Normal file
524
src/pages/warehouse/inventoryCountLocation.vue
Normal file
@ -0,0 +1,524 @@
|
||||
<template>
|
||||
<view class="inv-loc-page">
|
||||
<view class="normar_container">
|
||||
<page-nav :title="navTitle">
|
||||
<template #right>
|
||||
<view v-if="editable" class="nav-more-btn" :class="{ 'nav-more-btn--disabled': submitting }" @click="showActionsPopup = true">
|
||||
<u-icon name="more-dot-fill" size="40rpx" color="#303133"></u-icon>
|
||||
</view>
|
||||
</template>
|
||||
</page-nav>
|
||||
|
||||
<!-- 扫码/输入商品条码 → 直接打开「添加商品记录」弹窗 -->
|
||||
<count-search-panel
|
||||
v-if="editable"
|
||||
v-model="scanKeyword"
|
||||
placeholder="扫描/输入商品条码,点「添加」记入本库位"
|
||||
action-text="添加"
|
||||
@search="handleKeywordAdd"
|
||||
@clear="handleKeywordClear"
|
||||
@scan="handleCameraScan"
|
||||
/>
|
||||
|
||||
<scroll-view
|
||||
class="inv-loc-scroll"
|
||||
scroll-y
|
||||
refresher-enabled
|
||||
:refresher-triggered="refreshing"
|
||||
refresher-background="#f8f9fa"
|
||||
@refresherrefresh="handleRefresh"
|
||||
@refresherrestore="handleRefresherRestore"
|
||||
>
|
||||
<view class="inv-loc-card">
|
||||
<view class="inv-loc-card__row">
|
||||
<text class="inv-loc-card__label">盘点单号</text>
|
||||
<text class="inv-loc-card__value">{{ checkNo || '--' }}</text>
|
||||
</view>
|
||||
<view class="inv-loc-card__row">
|
||||
<text class="inv-loc-card__label">库位</text>
|
||||
<text class="inv-loc-card__value">{{ locationCode || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="showLocationName" class="inv-loc-card__row">
|
||||
<text class="inv-loc-card__label">库位名称</text>
|
||||
<text class="inv-loc-card__value">{{ locationName }}</text>
|
||||
</view>
|
||||
<view class="inv-loc-card__row">
|
||||
<text class="inv-loc-card__label">盘点明细</text>
|
||||
<text class="inv-loc-card__value">#{{ detailId || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading && !row" class="inv-loc-tip">加载中...</view>
|
||||
|
||||
<view v-if="!editable" class="inv-loc-tip">当前盘点任务状态不可作业,仅可查看</view>
|
||||
|
||||
<count-location-detail :row="row" :editable="editable" @delete="handleRecordDelete" />
|
||||
|
||||
<view v-if="!row && !loading" class="inv-loc-tip">未获取到库位明细数据,请返回列表重试</view>
|
||||
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 右上角「...」菜单(标记空库位收在这里) -->
|
||||
<count-actions-popup
|
||||
:show="showActionsPopup"
|
||||
title="库位操作"
|
||||
:can-mark-empty="editable"
|
||||
:submitting="submitting"
|
||||
@close="showActionsPopup = false"
|
||||
@mark-empty="handleMenuMarkEmpty"
|
||||
/>
|
||||
|
||||
<!-- 添加商品记录(stock.check.report) -->
|
||||
<count-record-add-popup
|
||||
ref="recordAddPopup"
|
||||
:show="showRecordAdd"
|
||||
:detail-id="detailId"
|
||||
:location="locationCode"
|
||||
:store-id="storeId"
|
||||
:prefill-keyword="pendingBarcode"
|
||||
@close="closeAddPopup"
|
||||
@confirm="handleRecordAddConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CountSearchPanel from './inventoryCount-comps/CountSearchPanel.vue';
|
||||
import CountLocationDetail from './inventoryCount-comps/CountLocationDetail.vue';
|
||||
import CountRecordAddPopup from './inventoryCount-comps/CountRecordAddPopup.vue';
|
||||
import CountActionsPopup from './inventoryCount-comps/CountActionsPopup.vue';
|
||||
import {
|
||||
normalizeScanResult,
|
||||
extractObjectPayload,
|
||||
normalizeLocationWorkDetail,
|
||||
buildReportParams
|
||||
} from './inventoryCount-comps/countModel.js';
|
||||
|
||||
/** query 参数解码(H5 可能已解码,容错处理非法百分号) */
|
||||
function decodeParam(value) {
|
||||
const raw = String(value === undefined || value === null ? '' : value);
|
||||
if (!raw) return '';
|
||||
try {
|
||||
return decodeURIComponent(raw);
|
||||
} catch (error) {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 库位盘点明细页(从盘点作业宫格列表点击/扫码进入)
|
||||
* 入参:detail_id(盘点明细ID,必需,兼容 id/detailId 别名)+ task_id(盘点任务ID,上报用)
|
||||
* + check_no / store_id / status(展示与搜索用,可选)
|
||||
* 数据:stock.check.workDataDetail(仅传 detail_id 即可拿到该库位的单行作业数据)
|
||||
* 能力:查看该库位状态与商品记录 + 添加商品记录 / 标记空库位(check.report)
|
||||
*/
|
||||
export default {
|
||||
components: {
|
||||
CountSearchPanel,
|
||||
CountLocationDetail,
|
||||
CountRecordAddPopup,
|
||||
CountActionsPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
taskId: '',
|
||||
detailId: '',
|
||||
checkNo: '',
|
||||
storeId: null,
|
||||
taskStatus: '',
|
||||
row: null,
|
||||
loading: false,
|
||||
refreshing: false,
|
||||
scanKeyword: '',
|
||||
showRecordAdd: false,
|
||||
showActionsPopup: false,
|
||||
pendingBarcode: '',
|
||||
submitting: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
navTitle() {
|
||||
return this.row && this.row.title ? this.row.title : '库位明细';
|
||||
},
|
||||
// 仅 approved/checking 可作业(未传 status 时先按可作业处理,由接口 400 兜底)
|
||||
editable() {
|
||||
if (!this.taskStatus) return true;
|
||||
return this.taskStatus === 'approved' || this.taskStatus === 'checking';
|
||||
},
|
||||
showLocationName() {
|
||||
return !!this.locationName && this.locationName !== this.locationCode;
|
||||
},
|
||||
// 库位编码/名称直接从明细数据取(接口不再需要列表页传)
|
||||
locationCode() {
|
||||
return String((this.row && this.row.location) || '');
|
||||
},
|
||||
locationName() {
|
||||
return String((this.row && this.row.locationName) || '');
|
||||
}
|
||||
},
|
||||
onLoad(options = {}) {
|
||||
// 明细ID:std 字段为 detail_id,兼容 id / detailId 别名(页面只需这一个 id 即可拉明细)
|
||||
this.detailId = String(options.detail_id || options.detailId || options.id || '').trim();
|
||||
// 任务ID:check.report 需要;兼容 id 与 task_id 两种写法
|
||||
this.taskId = String(options.task_id || options.taskId || options.id || '').trim();
|
||||
this.checkNo = decodeParam(options.check_no || options.checkNo);
|
||||
this.taskStatus = decodeParam(options.status).trim().toLowerCase();
|
||||
const storeId = options.store_id === undefined || options.store_id === null ? '' : String(options.store_id);
|
||||
this.storeId = storeId === '' || storeId === 'null' || storeId === 'undefined' ? null : storeId;
|
||||
|
||||
this.loadRow();
|
||||
this.syncBroadcastWithMode();
|
||||
},
|
||||
onShow() {
|
||||
this.syncBroadcastWithMode();
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
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(`[inventoryCountLocation] broadcast/${action} 调用失败:`, error));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[inventoryCountLocation] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
syncBroadcastWithMode() {
|
||||
if (this.editable) {
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('start');
|
||||
} else {
|
||||
this.safeDispatchBroadcast('stop');
|
||||
}
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
if (!this.editable) return;
|
||||
const code = normalizeScanResult(result);
|
||||
if (!code) return;
|
||||
this.handleScanKeyword(code);
|
||||
},
|
||||
handleCameraScan() {
|
||||
if (!this.editable) return;
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = normalizeScanResult(res);
|
||||
if (code) this.handleScanKeyword(code);
|
||||
},
|
||||
fail: () => {}
|
||||
});
|
||||
},
|
||||
/** 扫码回填:弹窗已打开时直接带码查询,便于连续扫码录入 */
|
||||
handleScanKeyword(code) {
|
||||
const keyword = String(code || '').trim();
|
||||
if (!keyword || !this.editable) return;
|
||||
this.scanKeyword = keyword;
|
||||
if (this.showRecordAdd) {
|
||||
const popup = this.$refs.recordAddPopup;
|
||||
if (popup && typeof popup.applyKeyword === 'function') {
|
||||
popup.applyKeyword(keyword);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.openAddPopup(keyword);
|
||||
},
|
||||
handleKeywordAdd() {
|
||||
if (!this.editable) return;
|
||||
const keyword = String(this.scanKeyword || '').trim();
|
||||
if (!keyword) {
|
||||
uni.showToast({ title: '请输入或扫描商品条码', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this.handleScanKeyword(keyword);
|
||||
},
|
||||
handleKeywordClear() {
|
||||
this.scanKeyword = '';
|
||||
},
|
||||
// ===== 添加商品记录 / 标记空库位 =====
|
||||
openAddPopup(barcode) {
|
||||
this.pendingBarcode = String(barcode || '').trim();
|
||||
this.showRecordAdd = true;
|
||||
},
|
||||
closeAddPopup() {
|
||||
this.showRecordAdd = false;
|
||||
this.pendingBarcode = '';
|
||||
},
|
||||
// 右上角菜单:标记空库位(先关菜单再确认)
|
||||
handleMenuMarkEmpty() {
|
||||
this.showActionsPopup = false;
|
||||
this.handleMarkEmpty();
|
||||
},
|
||||
handleMarkEmpty() {
|
||||
if (!this.detailId) {
|
||||
uni.showToast({ title: '缺少盘点明细ID', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showModal({
|
||||
title: '标记空库位',
|
||||
content: `确认库位「${this.locationCode || this.detailId}」为空?该库位已有的商品记录会被清除。`,
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
await this.submitReport({ isEmpty: true }, '已标记空库位');
|
||||
}
|
||||
});
|
||||
},
|
||||
handleRecordAddConfirm(payload) {
|
||||
// 提交成功后收起抽屉并清空表单;失败时保留输入便于重试
|
||||
if (!payload || !payload.detailId) return;
|
||||
this.submitReport(payload, '已添加', { closePopup: true });
|
||||
},
|
||||
/** 清空添加弹窗的输入框(搜索词/选中项/数量) */
|
||||
resetAddPopupForm() {
|
||||
const popup = this.$refs.recordAddPopup;
|
||||
if (popup && typeof popup.resetForm === 'function') {
|
||||
popup.resetForm();
|
||||
}
|
||||
},
|
||||
/** 删除单条商品记录(stock.check.recordDelete,按 record_id) */
|
||||
handleRecordDelete(child) {
|
||||
if (!this.editable) return;
|
||||
const recordId = child && child.recordId;
|
||||
if (!recordId) {
|
||||
uni.showToast({ title: '该记录不支持删除', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.taskId) {
|
||||
uni.showToast({ title: '缺少盘点任务ID', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showModal({
|
||||
title: '删除商品记录',
|
||||
content: `确认删除「${child.title || '该商品'}」本条记录?`,
|
||||
confirmText: '删除',
|
||||
confirmColor: '#f56c6c',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
await this.removeRecords([recordId]);
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 调用 recordDelete 并刷新当前库位明细 */
|
||||
async removeRecords(recordIds) {
|
||||
if (!this.editable || !this.taskId) return false;
|
||||
const ids = (Array.isArray(recordIds) ? recordIds : [recordIds])
|
||||
.map(id => Number(id))
|
||||
.filter(id => Number.isFinite(id) && id > 0);
|
||||
if (!ids.length) return false;
|
||||
if (this.submitting) return false;
|
||||
this.submitting = true;
|
||||
try {
|
||||
const response = await this.$http('check.recordDelete', {
|
||||
id: Number(this.taskId),
|
||||
record_ids: ids
|
||||
});
|
||||
if (response?.flag === 'failure') {
|
||||
uni.showToast({ title: response.message || '删除失败', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
const payload = extractObjectPayload(response);
|
||||
const deleted = Number(payload.deleted_count);
|
||||
const skipped = Array.isArray(payload.skipped_ids) ? payload.skipped_ids.length : 0;
|
||||
let title = '已删除';
|
||||
if (Number.isFinite(deleted)) title = `已删除 ${deleted} 条`;
|
||||
if (skipped) title += `,跳过 ${skipped} 条`;
|
||||
uni.showToast({ title, icon: 'none', duration: 1600 });
|
||||
await this.loadRow();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('[inventoryCountLocation] 删除作业记录失败:', error);
|
||||
uni.showToast({ title: '删除失败', icon: 'none' });
|
||||
return false;
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
},
|
||||
/** 统一上报(check.report):添加商品记录 / 标记空库位 */
|
||||
async submitReport(payload, successText, options = {}) {
|
||||
if (!this.editable || !this.taskId) return false;
|
||||
if (!payload || !payload.detailId) {
|
||||
uni.showToast({ title: '缺少盘点明细ID', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
const isEmpty = !!payload.isEmpty;
|
||||
const quantity = Number(payload.quantity);
|
||||
if (!isEmpty && (!Number.isInteger(quantity) || quantity < 0)) {
|
||||
uni.showToast({ title: '实盘数量须为不小于0的整数', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
if (this.submitting) return false;
|
||||
this.submitting = true;
|
||||
try {
|
||||
const response = await this.$http('check.report', buildReportParams(this.taskId, {
|
||||
detailId: payload.detailId,
|
||||
location: payload.location,
|
||||
quantity,
|
||||
stockId: payload.stockId,
|
||||
barcode: payload.barcode,
|
||||
itemName: payload.itemName,
|
||||
isEmpty
|
||||
}));
|
||||
if (response?.flag === 'failure') {
|
||||
uni.showToast({ title: response.message || '上报失败', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
uni.showToast({ title: successText || '已记录', icon: 'success', duration: 600 });
|
||||
await this.loadRow();
|
||||
// 提交成功后清空表单并收起底部抽屉
|
||||
if (options.closePopup) {
|
||||
this.resetAddPopupForm();
|
||||
this.closeAddPopup();
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('[inventoryCountLocation] 盘点上报失败:', error);
|
||||
uni.showToast({ title: '盘点上报失败', icon: 'none' });
|
||||
return false;
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
},
|
||||
// ===== 下拉刷新 =====
|
||||
async handleRefresh() {
|
||||
// 防重入:同一手势可能被重复触发
|
||||
if (this.refreshing) return;
|
||||
this.refreshing = true;
|
||||
try {
|
||||
await this.loadRow();
|
||||
} finally {
|
||||
this.refreshing = false;
|
||||
}
|
||||
},
|
||||
handleRefresherRestore() {
|
||||
this.refreshing = false;
|
||||
},
|
||||
// ===== 数据加载(stock.check.workDataDetail,只需传 detail_id)=====
|
||||
async loadRow() {
|
||||
if (!this.detailId) {
|
||||
uni.showToast({ title: '缺少盘点明细ID', icon: 'none' });
|
||||
return null;
|
||||
}
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await this.$http('check.workDataDetail', {
|
||||
detail_id: Number(this.detailId)
|
||||
});
|
||||
if (response?.flag === 'failure') {
|
||||
// 状态不允许(如已完成)时后端返回 400,按只读展示
|
||||
this.taskStatus = '';
|
||||
this.row = null;
|
||||
uni.showToast({ title: response.message || '明细加载失败', icon: 'none' });
|
||||
return null;
|
||||
}
|
||||
const row = normalizeLocationWorkDetail(extractObjectPayload(response));
|
||||
this.row = row;
|
||||
return row;
|
||||
} catch (error) {
|
||||
console.error('[inventoryCountLocation] 库位明细加载失败:', error);
|
||||
uni.showToast({ title: '库位明细加载失败', icon: 'none' });
|
||||
return null;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.inv-loc-page {
|
||||
height: 100vh;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.normar_container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.inv-loc-scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
padding: 20rpx 0 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.inv-loc-card {
|
||||
margin: 0 12rpx 16rpx;
|
||||
padding: 8rpx 28rpx;
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.inv-loc-card__row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 14rpx 0;
|
||||
border-bottom: 1rpx solid #f5f6f8;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.inv-loc-card__label {
|
||||
flex-shrink: 0;
|
||||
width: 160rpx;
|
||||
font-size: 28rpx;
|
||||
color: #8a9099;
|
||||
}
|
||||
|
||||
.inv-loc-card__value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.inv-loc-tip {
|
||||
margin: 0 12rpx 16rpx;
|
||||
padding: 24rpx;
|
||||
background: #fff8e6;
|
||||
border: 2rpx solid #ffe1a8;
|
||||
border-radius: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #b8811a;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.safe-area-bottom {
|
||||
height: 20rpx;
|
||||
}
|
||||
|
||||
/* 右上角「...」菜单入口 */
|
||||
.nav-more-btn {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.nav-more-btn--disabled {
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user