This commit is contained in:
yin 2026-10-02 18:09:50 +08:00
parent 9913eba441
commit ef732ca2c6
3 changed files with 0 additions and 261 deletions

View File

@ -578,7 +578,6 @@ export function stockCheckList(
// ============ stock.check.addDetail ============
<<<<<<< HEAD
/**
* stock.check.addDetail 请求参数(与任务 type 对齐:商品类传 stock_ids,库位类传 locations / location_ids)
*
@ -591,15 +590,11 @@ export function stockCheckList(
* 兼容:type=all 且已存在商品明细行(改造前创建的旧任务)时,继续按商品模式接受 stock_ids。
* 幂等:已存在同盘点项(商品行 stock_id / 库位行 location_code)自动跳过(计入 skipped)。
*/
=======
/** stock.check.addDetail 请求参数(与任务 type 对齐:商品类传 stock_ids,库位类传 location_ids/locations) */
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
export type StockCheckAddDetailParams = {
/** 盘点任务ID */
id: number
/**
* 商品库存ID列表(wms_stock_warehouse.id):type=store/goods 按商品盘点时使用,
<<<<<<< HEAD
* 与 locations / location_ids 按任务类型二选一
*/
stock_ids?: number[]
@ -607,23 +602,6 @@ export type StockCheckAddDetailParams = {
* 库位编码列表(wms_location_space.space_code):type=all/location 按库位盘点时使用,
* 与 stock_ids 按任务类型二选一;**与 location_ids 同时传入时被忽略(location_ids 优先)**;
* **type=all 未传库位且未传 location_ids 时由后端自动拉取全仓库启用库位生成盘点范围**
=======
* 与 location_ids/locations 按任务类型二选一
*/
stock_ids?: number[]
/**
* 库位ID列表(wms_location_space.id):type=all/location 按库位盘点时使用,
* **优先于 locations**(与 locations 同时传时 locations 被忽略),
* 服务端直接按 id + warehouse_id 查库校验,不再按编码二次解析;
* 查不到的 ID 记入 invalid_location_ids(不报错)
*/
location_ids?: number[]
/** 库位ID列表(驼峰别名,兼容写法;location_ids 优先) */
locationIds?: number[]
/**
* 库位编码列表(wms_location_space.space_code):仅传编码时按 warehouse_id + space_code 匹配,
* 不存在的编码记入 invalid_locations;**type=all 未传库位且未传库位ID时由后端自动拉取全仓库启用库位**
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
*/
locations?: string[]
/** 库位编码列表(兼容别名;locations 优先,两者都传时以 locations 为准) */
@ -654,20 +632,7 @@ export type StockCheckAddDetailResponse = {
total_items: number
}
<<<<<<< HEAD
/** stock.check.addDetail:添加盘点明细(仅 created/rejected 允许;同盘点项幂等跳过) */
=======
/**
* stock.check.addDetail:添加盘点明细(商品或库位,按任务盘点类型决定)
*
* - 仅 created/rejected 允许;stock_ids 与 location_ids/locations 按任务类型二选一
* (传错维度后端报 400:按库位盘点传 stock_ids / 按商品盘点传 locations 或 location_ids)
* - 已存在同盘点项(商品行 stock_id / 库位行 location_code)自动跳过(幂等)
* - 完成后重算主表 total_items
*
* 注:兼容入口 stock.check.addLocationDetail 是 addDetail 库位ID路径的薄封装,前端无需单独接入。
*/
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
export function stockCheckAddDetail(
data: StockCheckAddDetailParams
): Promise<StockCheckEnvelope<StockCheckAddDetailResponse>> {
@ -744,7 +709,6 @@ export function stockCheckAddLocationDetail(
// ============ stock.check.detailDelete ============
<<<<<<< HEAD
/** stock.check.detailDelete 请求参数(**批量删除**,单次上限 200) */
export type StockCheckDetailDeleteParams = {
/** 盘点任务ID */
@ -759,17 +723,6 @@ export type StockCheckDetailDeleteParams = {
/** 盘点明细ID数组(驼峰别名,兼容写法,单值自动转数组;detail_ids 优先) */
detailIds?: number[] | number
/** 盘点明细ID(旧版单值写法,自动转数组;detail_ids / detailIds 优先) */
=======
/** stock.check.detailDelete 请求参数(批量;单次上限 200) */
export type StockCheckDetailDeleteParams = {
/** 盘点任务ID */
id: number
/** 盘点明细ID数组(单次上限 200;优先级 detail_ids > detailIds > detail_id) */
detail_ids?: number[]
/** 盘点明细ID数组(驼峰别名,兼容写法) */
detailIds?: number[]
/** 旧版单值写法(自动转数组;detail_ids/detailIds 优先) */
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
detail_id?: number
}
@ -786,20 +739,12 @@ export type StockCheckDetailDeleteResponse = {
}
/**
<<<<<<< HEAD
* stock.check.detailDelete:**批量删除盘点明细**(从任务中移除若干商品 / 库位行)
*
* - 仅主表状态 created/rejected 允许删除
* - 未命中的明细ID(不存在或不属于当前仓库)计入 `skipped_ids`,不报错
* - 命中明细若存在作业记录(wms_stock_check_record)会防御性一并删除
* (正常流程 created/rejected 状态不应有记录)
=======
* stock.check.detailDelete:**批量**删除盘点明细(从任务中移除商品/库位行)
*
* - 仅主表状态 created/rejected 允许删除(非该状态报错)
* - 单次最多 200 条;未命中的明细ID计入 skipped_ids(不报错)
* - 命中明细批量删除,并防御性清理 wms_stock_check_record(正常流程该状态不应有记录)
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
* - 删除后服务端重算主表 total_items
*/
export function stockCheckDetailDelete(

View File

@ -12,7 +12,6 @@
行级聚合(checked_quantity/diff_quantity)**已含未知商品**,故不再平铺 unknown_items,
改为在「商品名称」列提示「含未知商品 N 项」,避免合计重复展示
- 库位行(scope_type=location,type=all/location):一行一个库位 + 行内商品各一行
<<<<<<< HEAD
(result 的 stocks[] 平铺)+ **未知商品各一行**(unknown_items 平铺,带「未知」标记);
行级合计不单独展示(只展示明细),所以平铺不会重复
2. 盘点作业:行内上报(stock.check.report,**覆盖式**:同明细+同商品+同库位重复上报为更新)
@ -26,17 +25,6 @@
未盘商品明细按实盘 0 计入盘亏与差异行数,未盘库位明细不计差异)
4. 「添加商品 / 添加库位」交给宿主 index.vue 打开 CheckStockPickerDialog(emit add-items)
5. 作业图片列:result 的 records[].images(RecordImages 缩略图 + 点击放大)
=======
(result 的 stocks[] 平铺;无商品时保留库位行本身、商品列为 —)
上报需带 stock_id → 商品行直接上报;同明细的「明细类型 / 库位」单元格合并显示
2. 盘点作业:行内或批量上报(stock.check.report,**覆盖式**:
商品行=同明细+同库位;库位行=同明细+同商品+同库位,均重复上报为更新)
3. 批量删除明细(stock.check.detailDelete,仅 created/rejected):勾选行按**明细ID**去重提交,
单次上限 200 条;未命中的明细ID由服务端计入 skipped_ids(不报错)
4. 完成盘点(stock.check.finish,允许部分未盘完成:
未盘商品明细按实盘 0 计入盘亏与差异行数,未盘库位明细不计差异)
5. 「添加商品 / 添加库位」交给宿主 index.vue 打开 CheckStockPickerDialog(emit add-items)
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
状态约束(与后端一致):
- created/rejected → 可添加明细(商品类 addDetail / 库位类 addLocationDetail)
@ -53,17 +41,6 @@
<el-button v-if="canAddItems" size="small" type="primary" plain @click="emit('add-items')">
{{ isLocationTask ? '添加库位' : '添加商品' }}
</el-button>
<el-button
v-if="canAddItems"
size="small"
type="danger"
plain
:disabled="!selectedDetailIds.length"
:loading="deleting"
@click="deleteSelected"
>
批量删除明细{{ selectedDetailIds.length ? `(${selectedDetailIds.length})` : '' }}
</el-button>
<el-button
v-if="canReport && !isLocationTask"
size="small"
@ -106,10 +83,7 @@
size="small"
:height="tableHeight"
:span-method="spanMethod"
@selection-change="handleSelectionChange"
>
<!-- 批量删除:仅 created/rejected(可增删明细)时提供勾选,按明细ID去重提交 -->
<el-table-column v-if="canAddItems" type="selection" width="45" :reserve-selection="true" />
<el-table-column type="index" label="#" width="56" align="center" :index="indexMethod" />
<!-- 明细类型:商品行 / 库位行(同一单内由任务 type 决定,显式标注便于核对) -->
<el-table-column label="明细类型" width="90" align="center">
@ -275,7 +249,6 @@ import RecordImages from './RecordImages.vue'
import CheckReportDialog from './CheckReportDialog.vue'
import {
stockCheckDetail,
stockCheckDetailDelete,
stockCheckFinish,
stockCheckMarkEmpty,
stockCheckReport,
@ -586,8 +559,6 @@ async function loadItems() {
stats.checked = Number(check.checked_items ?? 0) || 0
stats.diff = Number(check.diff_items ?? 0) || 0
resetInputs()
selectedRows.value = []
nextTick(() => tableRef.value?.clearSelection?.())
page.value = 1
} catch (e: any) {
console.error('[stockcheck] 加载盘点明细失败', e)
@ -668,72 +639,6 @@ function resetInputs() {
}
}
// ============================================================
// 批量删除明细(stock.check.detailDelete,仅 created/rejected)
// ============================================================
const selectedRows = ref<Record<string, any>[]>([])
const deleting = ref(false)
/** 选中行对应的明细ID(按明细去重:库位行平铺后同一明细可能对应多行) */
const selectedDetailIds = computed<number[]>(() => {
const ids = selectedRows.value.map((row) =>
Number(row?.detail_id ?? row?.item?.id ?? row?.id)
)
return [...new Set(ids.filter((id) => Number.isFinite(id) && id > 0))]
})
function handleSelectionChange(rows: Record<string, any>[]) {
selectedRows.value = Array.isArray(rows) ? rows : []
}
/** 批量删除选中的盘点明细(单次上限 200,与后端一致) */
async function deleteSelected() {
const ids = selectedDetailIds.value
if (!ids.length) {
ElMessage.warning('请先勾选要删除的盘点明细')
return
}
if (ids.length > 200) {
ElMessage.warning(`单次最多删除 200 条明细(已选 ${ids.length} 条),请分批删除`)
return
}
try {
await ElMessageBox.confirm(
`确定删除选中的 ${ids.length} 个盘点明细?删除后需重新添加。`,
'批量删除盘点明细',
{ confirmButtonText: '确定删除', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
deleting.value = true
try {
const res: any = await stockCheckDetailDelete({ id: taskId.value, detail_ids: ids })
if (!isCheckApiSuccess(res)) {
throw new Error(res?.message || '删除盘点明细失败')
}
const data = res.data ?? res
const deletedCount = Number(data.deleted_count ?? 0)
const skippedIds: number[] = Array.isArray(data.skipped_ids) ? data.skipped_ids : []
if (skippedIds.length) {
ElMessage.warning(
`已删除 ${deletedCount} 条明细,跳过 ${skippedIds.length} 条(不存在或不属于当前仓库)`
)
} else {
ElMessage.success(`已删除 ${deletedCount} 条盘点明细`)
}
// loadItems 内部会重置页码与勾选
await loadItems()
emit('changed')
} catch (e: any) {
console.error('[stockcheck] 删除盘点明细失败', e)
ElMessage.error(e?.message || '删除盘点明细失败')
} finally {
deleting.value = false
}
}
// ============================================================
// 上报实盘(stock.check.report)
// ============================================================

View File

@ -2,7 +2,6 @@
CheckStockPickerDialog — 添加盘点明细
两种模式(由来源盘点单的 type 决定):
<<<<<<< HEAD
- 商品类(type=store/goods):从 storage.inventory.list 选商品 → stock.check.addDetail 传 stock_ids
- 库位类(type=all/location):从库位列表(index.searchSpace)勾选库位 →
· 已勾选库位 → stock.check.addLocationDetail 传 location_ids(库位ID直查,不解析编码)
@ -11,16 +10,6 @@
无效项提示:addLocationDetail → invalid_location_ids;addDetail → invalid_stock_ids / invalid_locations。
仅 created(新建)/ rejected(驳回)状态可添加,后端会校验。
=======
- 商品类(type=store/goods):从 storage.inventory.list 选商品 → 传 stock_ids
- 库位类(type=all/location):LocationPicker 逐层下拉(仓库 → 库区 → 货架 → 库位)选择
→ 传 **location_ids**(wms_location_space.id,服务端按 id + warehouse_id 直查校验,
优先于 locations 编码;新契约下不再走编码二次解析)
· type=all 不选库位 = 不传库位/库位ID,由后端自动拉取全仓启用库位
响应含 invalid_stock_ids(商品)/ invalid_locations(无效编码)/ invalid_location_ids(无效库位ID)三类无效项,
均需在提示中体现。仅 created(新建)/ rejected(驳回)状态可添加,后端会校验。
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
-->
<template>
<el-dialog
@ -104,11 +93,7 @@
</div>
</template>
<<<<<<< HEAD
<!-- ===== 库位类任务:勾选库位(location_ids)→ addLocationDetail ===== -->
=======
<!-- ===== 库位类任务:逐层下拉(仓库 → 库区 → 货架 → 库位)选择 → locations ===== -->
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
<template v-else>
<el-alert
type="info"
@ -116,7 +101,6 @@
show-icon
:title="locationAlertText"
/>
<<<<<<< HEAD
<!-- 库位筛选 -->
<div class="picker-filters">
@ -217,23 +201,12 @@
<div class="stat-text">已识别 {{ locationCodes.length }} 个库位编码</div>
</el-collapse-item>
</el-collapse>
=======
<LocationPicker v-model="locationIds" :allow-empty="taskType === 'all'" />
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
</template>
</div>
<template #footer>
<div class="dialog-footer">
<<<<<<< HEAD
<span class="selected-tip">{{ submitChannelTip }}</span>
=======
<span class="selected-tip">
{{ isLocationMode
? `已选 ${locationIds.length} 个库位`
: `已选 ${selectedRows.length} 行 · 去重后 ${selectedStockIds.length} 个商品` }}
</span>
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
<div class="footer-buttons">
<el-button size="small" @click="handleVisibleChange(false)">取消</el-button>
<el-button
@ -262,7 +235,6 @@ import {
stockCheckAddLocationDetail,
type StockCheckAddDetailParams
} from '@/api/stock.check/stock.check'
import LocationPicker from '../components/LocationPicker.vue'
import { isCheckApiSuccess, isLocationScopeType } from '../config/template-config'
defineOptions({ name: 'CheckStockPickerDialog' })
@ -291,7 +263,6 @@ const dialogTitle = computed(() => {
return isLocationMode.value ? `添加盘点库位${suffix}` : `添加盘点商品${suffix}`
})
<<<<<<< HEAD
// ===== 库位模式:库位选择(多选,主通道) =====
const spaceFilters = reactive({ keyword: '' })
const spaceRows = ref<Record<string, any>[]>([])
@ -342,21 +313,6 @@ const canSubmit = computed(() => {
selectedLocationIds.value.length > 0 || locationCodes.value.length > 0 || props.taskType === 'all'
)
}
=======
// ===== 库位模式 =====
/** 已选库位ID(wms_location_space.id,由 LocationPicker 逐层选择维护;type=all 可留空) */
const locationIds = ref<number[]>([])
const locationAlertText = computed(() =>
props.taskType === 'all'
? '按库位盘点(默认全仓):逐层选择库位,不选时由后端自动拉取全仓库启用库位生成盘点范围。'
: '按库位盘点:请逐层(仓库 → 库区 → 货架)选择要盘点的库位;不存在的库位会被后端列入无效库位。'
)
/** 库位模式:选了库位,或 all 类型(允许不选=全仓) */
const canSubmit = computed(() => {
if (isLocationMode.value) return locationIds.value.length > 0 || props.taskType === 'all'
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
return selectedStockIds.value.length > 0
})
@ -417,15 +373,11 @@ function handleClosed() {
selectedRows.value = []
selectedSpaceRows.value = []
rows.value = []
<<<<<<< HEAD
spaceRows.value = []
spacePagination.page = 1
spacePagination.total = 0
spaceFilters.keyword = ''
locationText.value = ''
=======
locationIds.value = []
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
submitting.value = false
}
@ -658,7 +610,6 @@ async function submitLocationRows(taskId: number) {
}
const payload: StockCheckAddDetailParams = { id: taskId }
<<<<<<< HEAD
if (locationCodes.value.length > 0) {
payload.locations = locationCodes.value
} else if (props.taskType === 'all') {
@ -670,33 +621,6 @@ async function submitLocationRows(taskId: number) {
{ confirmButtonText: '确定继续', cancelButtonText: '取消', type: 'warning' }
)
} catch {
=======
if (isLocationMode.value) {
const ids = locationIds.value
if (!ids.length) {
if (props.taskType !== 'all') {
ElMessage.warning('请至少选择一个库位')
return
}
// type=all:不传库位(也不传库位ID),由后端自动拉取全仓启用库位
try {
await ElMessageBox.confirm(
'未选择库位,将由后端自动拉取全仓库启用库位生成盘点范围,确定继续?',
'添加盘点库位',
{ confirmButtonText: '确定继续', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
} else {
// 新契约:库位ID直查(id + warehouse_id 校验,不再按编码二次解析),优先于 locations
payload.location_ids = ids
}
} else {
const stockIds = selectedStockIds.value
if (!stockIds.length) {
ElMessage.warning('请先勾选要盘点的商品')
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
return
}
} else {
@ -707,36 +631,12 @@ async function submitLocationRows(taskId: number) {
submitting.value = true
try {
const res: any = await stockCheckAddDetail(payload)
<<<<<<< HEAD
const data = res?.data ?? res
const result = resolveAddResult(res, {
codes: toStringList(data?.invalid_locations),
// 编码通道一般不会返回库位ID无效项,兜底提示(addDetail 响应的新增字段)
ids: toNumberList(data?.invalid_location_ids)
})
=======
if (!isCheckApiSuccess(res)) {
throw new Error(res?.message || '添加盘点明细失败')
}
const data = res.data ?? res
const added = Number(data.added ?? 0)
const skipped = Number(data.skipped ?? 0)
const invalidStocks: number[] = Array.isArray(data.invalid_stock_ids) ? data.invalid_stock_ids : []
const invalidLocations: string[] = Array.isArray(data.invalid_locations) ? data.invalid_locations : []
const invalidLocationIds: number[] = Array.isArray(data.invalid_location_ids)
? data.invalid_location_ids
: []
const parts = [`新增 ${added} 项`]
if (skipped) parts.push(`跳过已存在 ${skipped} 项`)
if (invalidStocks.length) parts.push(`无效商品 ${invalidStocks.length} 个`)
if (invalidLocations.length) parts.push(`无效库位编码 ${invalidLocations.length} 个`)
if (invalidLocationIds.length) parts.push(`无效库位 ${invalidLocationIds.length} 个`)
if (invalidStocks.length || invalidLocations.length || invalidLocationIds.length) {
ElMessage.warning(parts.join(','))
} else {
ElMessage.success(parts.join(','))
}
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
emit('update:visible', false)
emit('success', result)
} catch (e: any) {
@ -780,7 +680,6 @@ watch(
pagination.total = 0
selectedRows.value = []
rows.value = []
<<<<<<< HEAD
locationText.value = ''
spaceFilters.keyword = ''
spacePagination.page = 1
@ -794,12 +693,6 @@ watch(
// 两种模式各自拉数据:商品模式拉库存列表,库位模式拉库位列表
if (isLocationMode.value) void loadSpaceRows()
else void loadRows()
=======
locationIds.value = []
nextTick(() => tableRef.value?.clearSelection?.())
// 库位模式不需要拉库存列表
if (!isLocationMode.value) void loadRows()
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
}
)
</script>
@ -840,7 +733,6 @@ watch(
color: #909399;
}
<<<<<<< HEAD
/* 库位模式:预览已识别的库位编码 */
.location-preview {
display: flex;
@ -876,9 +768,6 @@ watch(
.location-tag {
margin: 0;
}
=======
/* 库位模式:已选的库位编码由 LocationPicker 内部展示预览 */
>>>>>>> eb305306eb361e3daf832ac0dc9afa2ed0a35415
.stat-text {
font-size: 12px;