1
This commit is contained in:
parent
ce6ff6d406
commit
55e06d51aa
@ -680,26 +680,26 @@ export function quickInbound(data: QuickInboundParams): Promise<QuickInboundResp
|
|||||||
|
|
||||||
export type ReceivingCompareMatchStatus = 'matched' | 'entry_only' | string
|
export type ReceivingCompareMatchStatus = 'matched' | 'entry_only' | string
|
||||||
|
|
||||||
/** 逐行对照项(comparison 数组元素) */
|
/** 逐行对照项(comparison / entry_only / receiving_only 数组元素) */
|
||||||
export type ReceivingCompareRow = {
|
export type ReceivingCompareRow = {
|
||||||
|
entry_item_id?: number
|
||||||
stock_id?: number
|
stock_id?: number
|
||||||
item_code?: string
|
|
||||||
warehouse_item_code?: string
|
warehouse_item_code?: string
|
||||||
product_code?: string
|
|
||||||
item_name?: string
|
|
||||||
product_name?: string
|
|
||||||
warehouse_item_name?: string
|
warehouse_item_name?: string
|
||||||
barcode?: string
|
warehouse_item_spec?: string
|
||||||
entry_plan_qty?: number
|
/** 入库计划数量 */
|
||||||
entry_received_qty?: number
|
entry_count?: number
|
||||||
plan_qty?: number
|
/** 入库已收数量 */
|
||||||
count?: number
|
entry_received?: number
|
||||||
received_quantity?: number
|
receiving_detail_id?: number | null
|
||||||
receiving_qty?: number
|
receiving_product_code?: string | null
|
||||||
receiving_quantity?: number
|
receiving_product_name?: string | null
|
||||||
actual_quantity?: number
|
/** 收货实际数量 */
|
||||||
box_quantity?: number
|
receiving_actual_quantity?: number | null
|
||||||
receiving_allocated?: number
|
/** 收货已分配数量 */
|
||||||
|
receiving_allocated?: number | null
|
||||||
|
/** 收货可用数量 */
|
||||||
|
receiving_available?: number | null
|
||||||
match_status?: ReceivingCompareMatchStatus
|
match_status?: ReceivingCompareMatchStatus
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
@ -729,11 +729,26 @@ export type ReceivingCompareSummary = {
|
|||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 单个收货单对照结果(comparisons 数组元素) */
|
||||||
|
export type ReceivingCompareItem = {
|
||||||
|
receiving_id?: number
|
||||||
|
receiving_number?: string
|
||||||
|
/** 对照状态:matched / error 等 */
|
||||||
|
status?: string
|
||||||
|
comparison?: ReceivingCompareRow[]
|
||||||
|
entry_only?: ReceivingCompareRow[]
|
||||||
|
receiving_only?: ReceivingCompareRow[]
|
||||||
|
summary?: ReceivingCompareSummary
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
export type ReceivingCompareParams = {
|
export type ReceivingCompareParams = {
|
||||||
/** 入库单ID */
|
/** 入库单ID */
|
||||||
entry_order_id: number
|
entry_order_id: number
|
||||||
/** 收货单ID */
|
/** 收货单ID,单个时使用,与 receiving_ids 二选一 */
|
||||||
receiving_id: number
|
receiving_id?: number
|
||||||
|
/** 收货单ID数组,优先使用;与 receiving_id 二选一 */
|
||||||
|
receiving_ids?: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ReceivingCompareResponse = {
|
export type ReceivingCompareResponse = {
|
||||||
@ -741,16 +756,16 @@ export type ReceivingCompareResponse = {
|
|||||||
message?: string
|
message?: string
|
||||||
entry_order_id?: number
|
entry_order_id?: number
|
||||||
entry_order_code?: string
|
entry_order_code?: string
|
||||||
receiving_id?: number
|
/** 各收货单对照结果列表 */
|
||||||
receiving_number?: string
|
comparisons?: ReceivingCompareItem[]
|
||||||
comparison?: ReceivingCompareRow[]
|
/** 校验失败的收货单列表 */
|
||||||
entry_only?: ReceivingCompareRow[]
|
errors?: Array<{ receiving_id?: number; message?: string; [key: string]: unknown }>
|
||||||
receiving_only?: ReceivingCompareRow[]
|
/** 总体汇总统计 */
|
||||||
summary?: ReceivingCompareSummary
|
total_summary?: ReceivingCompareSummary
|
||||||
data?: Partial<Omit<ReceivingCompareResponse, 'data'>>
|
data?: Partial<Omit<ReceivingCompareResponse, 'data'>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 入库单与收货单商品对照 */
|
/** 入库单与收货单商品对照(支持单个或多个收货单) */
|
||||||
export function receivingCompare(
|
export function receivingCompare(
|
||||||
data: ReceivingCompareParams
|
data: ReceivingCompareParams
|
||||||
): Promise<ReceivingCompareResponse> {
|
): Promise<ReceivingCompareResponse> {
|
||||||
|
|||||||
@ -23,6 +23,22 @@
|
|||||||
<span class="summary-label">订单状态</span>
|
<span class="summary-label">订单状态</span>
|
||||||
<el-tag size="small" :type="entryOrderStatusTag">{{ entryOrderStatusLabel }}</el-tag>
|
<el-tag size="small" :type="entryOrderStatusTag">{{ entryOrderStatusLabel }}</el-tag>
|
||||||
</span>
|
</span>
|
||||||
|
<span v-if="entryExpressCode" class="summary-inline">
|
||||||
|
<span class="summary-label">运单号</span>
|
||||||
|
<span class="summary-value">{{ entryExpressCode }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryLogisticsName" class="summary-inline">
|
||||||
|
<span class="summary-label">物流公司</span>
|
||||||
|
<span class="summary-value">{{ entryLogisticsName }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryPurchaseOrderCode" class="summary-inline">
|
||||||
|
<span class="summary-label">单据编号</span>
|
||||||
|
<span class="summary-value">{{ entryPurchaseOrderCode }}</span>
|
||||||
|
</span>
|
||||||
|
<span v-if="entryRemark" class="summary-inline summary-inline--remark">
|
||||||
|
<span class="summary-label">备注</span>
|
||||||
|
<span class="summary-value summary-value--remark">{{ entryRemark }}</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bind-dialog-body">
|
<div class="bind-dialog-body">
|
||||||
@ -56,6 +72,7 @@
|
|||||||
v-for="row in compareRows"
|
v-for="row in compareRows"
|
||||||
:key="row.rowKey"
|
:key="row.rowKey"
|
||||||
class="compare-row"
|
class="compare-row"
|
||||||
|
:class="{ 'compare-row--matched': row.matchStatus === 'matched' }"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="compare-cell"
|
class="compare-cell"
|
||||||
@ -170,7 +187,7 @@ import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
|||||||
import { useResizeObserver } from '@vueuse/core'
|
import { useResizeObserver } from '@vueuse/core'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import type { TableInstance } from 'element-plus'
|
import type { TableInstance } from 'element-plus'
|
||||||
import { getReceivingList, getReceivingDetail } from '@/api/storage_receiving/receiving'
|
import { getReceivingList } from '@/api/storage_receiving/receiving'
|
||||||
import {
|
import {
|
||||||
bindReceiving,
|
bindReceiving,
|
||||||
getEntryDetail,
|
getEntryDetail,
|
||||||
@ -178,6 +195,7 @@ import {
|
|||||||
type BindReceivingResponse,
|
type BindReceivingResponse,
|
||||||
type EntryDetailItem,
|
type EntryDetailItem,
|
||||||
type ReceivingCompareResponse,
|
type ReceivingCompareResponse,
|
||||||
|
type ReceivingCompareItem,
|
||||||
type ReceivingCompareRow,
|
type ReceivingCompareRow,
|
||||||
} from '@/api/storage.entry/entry'
|
} from '@/api/storage.entry/entry'
|
||||||
import {
|
import {
|
||||||
@ -216,6 +234,7 @@ type CompareDisplayRow = {
|
|||||||
entryQty: string | number
|
entryQty: string | number
|
||||||
receivingName: string
|
receivingName: string
|
||||||
receivingQty: string | number
|
receivingQty: string | number
|
||||||
|
matchStatus?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -286,13 +305,36 @@ const entryOrderStatusLabel = computed(() => {
|
|||||||
|
|
||||||
const entryOrderStatusTag = computed(() => getEntryOrderStatusTagType(props.row?.order_status))
|
const entryOrderStatusTag = computed(() => getEntryOrderStatusTagType(props.row?.order_status))
|
||||||
|
|
||||||
|
const entryRemark = computed(() => {
|
||||||
|
const remark = props.row?.remark
|
||||||
|
return remark !== null && remark !== undefined && String(remark).trim() ? String(remark).trim() : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryExpressCode = computed(() => {
|
||||||
|
const code = props.row?.express_code
|
||||||
|
return code !== null && code !== undefined && String(code).trim() ? String(code).trim() : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryLogisticsName = computed(() => {
|
||||||
|
const name = props.row?.logistics_name
|
||||||
|
return name !== null && name !== undefined && String(name).trim() ? String(name).trim() : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const entryPurchaseOrderCode = computed(() => {
|
||||||
|
const code = props.row?.purchase_order_code
|
||||||
|
return code !== null && code !== undefined && String(code).trim() ? String(code).trim() : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const isEntryFullyCovered = ref(false)
|
||||||
|
|
||||||
const canSubmitBind = computed(
|
const canSubmitBind = computed(
|
||||||
() =>
|
() =>
|
||||||
!!entryOrderId.value &&
|
!!entryOrderId.value &&
|
||||||
selectedReceivingRows.value.length > 0 &&
|
selectedReceivingRows.value.length > 0 &&
|
||||||
!bindSubmitting.value &&
|
!bindSubmitting.value &&
|
||||||
!compareLoading.value &&
|
!compareLoading.value &&
|
||||||
!receivingListLoading.value
|
!receivingListLoading.value &&
|
||||||
|
isEntryFullyCovered.value
|
||||||
)
|
)
|
||||||
|
|
||||||
function isApiSuccess(res: { code?: number; flag?: string } | null | undefined): boolean {
|
function isApiSuccess(res: { code?: number; flag?: string } | null | undefined): boolean {
|
||||||
@ -349,42 +391,18 @@ function mapEntryItem(item: EntryDetailItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapReceivingDetailItem(item: Record<string, unknown>) {
|
|
||||||
return {
|
|
||||||
name: pickText(item, ['product_name', 'warehouse_item_name', 'item_name']),
|
|
||||||
qty: pickQty(item, ['actual_quantity', 'receiving_qty', 'quantity', 'box_quantity']),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildCompareRowsFromSides(
|
|
||||||
entryList: Array<{ name: string; qty: string | number }>,
|
|
||||||
receivingList: Array<{ name: string; qty: string | number }>
|
|
||||||
): CompareDisplayRow[] {
|
|
||||||
const maxLen = Math.max(entryList.length, receivingList.length)
|
|
||||||
if (!maxLen) return []
|
|
||||||
return Array.from({ length: maxLen }, (_, index) => ({
|
|
||||||
rowKey: `row-${index}`,
|
|
||||||
entryName: entryList[index]?.name ?? '—',
|
|
||||||
entryQty: entryList[index]?.qty ?? '—',
|
|
||||||
receivingName: receivingList[index]?.name ?? '—',
|
|
||||||
receivingQty: receivingList[index]?.qty ?? '—',
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasCompareEntryData(record: Record<string, unknown>): boolean {
|
function hasCompareEntryData(record: Record<string, unknown>): boolean {
|
||||||
return !!(
|
return !!(
|
||||||
pickTextOrEmpty(record, ['item_code', 'warehouse_item_code', 'product_code']) ||
|
pickTextOrEmpty(record, ['warehouse_item_code']) ||
|
||||||
pickTextOrEmpty(record, ['item_name', 'warehouse_item_name', 'product_name']) ||
|
pickTextOrEmpty(record, ['warehouse_item_name']) ||
|
||||||
pickQty(record, ['entry_plan_qty', 'plan_qty', 'count', 'entry_received_qty', 'received_quantity']) !==
|
pickQty(record, ['entry_count', 'entry_received']) !== '—'
|
||||||
'—'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasCompareReceivingData(record: Record<string, unknown>): boolean {
|
function hasCompareReceivingData(record: Record<string, unknown>): boolean {
|
||||||
return !!(
|
return !!(
|
||||||
pickTextOrEmpty(record, ['item_code', 'warehouse_item_code', 'product_code']) ||
|
pickTextOrEmpty(record, ['receiving_product_name']) ||
|
||||||
pickTextOrEmpty(record, ['item_name', 'warehouse_item_name', 'product_name']) ||
|
pickQty(record, ['receiving_actual_quantity', 'receiving_allocated', 'receiving_available']) !== '—'
|
||||||
pickQty(record, ['receiving_qty', 'receiving_quantity', 'actual_quantity', 'quantity']) !== '—'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,47 +417,23 @@ function buildCompareRowsFromApi(records: ReceivingCompareRow[]): CompareDisplay
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
rowKey: `compare-${index}-${status || 'row'}`,
|
rowKey: `compare-${index}-${status || 'row'}`,
|
||||||
|
matchStatus: status || '',
|
||||||
entryName: hasEntry
|
entryName: hasEntry
|
||||||
? pickText(raw, ['item_name', 'warehouse_item_name', 'product_name'])
|
? pickText(raw, ['warehouse_item_name'])
|
||||||
: '—',
|
: '—',
|
||||||
entryQty: hasEntry
|
entryQty: hasEntry
|
||||||
? pickQty(raw, [
|
? pickQty(raw, ['entry_count', 'entry_received'])
|
||||||
'entry_plan_qty',
|
|
||||||
'plan_qty',
|
|
||||||
'count',
|
|
||||||
'entry_received_qty',
|
|
||||||
'received_quantity',
|
|
||||||
'total_planned',
|
|
||||||
])
|
|
||||||
: '—',
|
: '—',
|
||||||
receivingName: hasReceiving
|
receivingName: hasReceiving
|
||||||
? pickText(raw, ['item_name', 'warehouse_item_name', 'product_name'])
|
? pickText(raw, ['receiving_product_name', 'warehouse_item_name'])
|
||||||
: '—',
|
: '—',
|
||||||
receivingQty: hasReceiving
|
receivingQty: hasReceiving
|
||||||
? pickQty(raw, ['receiving_qty', 'receiving_quantity', 'actual_quantity', 'quantity', 'box_quantity'])
|
? pickQty(raw, ['receiving_available', 'receiving_actual_quantity', 'receiving_allocated', 'entry_count'])
|
||||||
: '—',
|
: '—',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareRowsLackQty(rows: CompareDisplayRow[]): boolean {
|
|
||||||
return rows.length > 0 && rows.every((row) => row.entryQty === '—' && row.receivingQty === '—')
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldUseSideCompareFallback(
|
|
||||||
apiRows: CompareDisplayRow[],
|
|
||||||
entryMapped: Array<{ name: string; qty: string | number }>,
|
|
||||||
receivingMapped: Array<{ name: string; qty: string | number }>
|
|
||||||
): boolean {
|
|
||||||
if (!apiRows.length) return true
|
|
||||||
if (compareRowsLackQty(apiRows)) return true
|
|
||||||
const entryQtyMissing =
|
|
||||||
entryMapped.length > 0 && apiRows.every((row) => row.entryQty === '—')
|
|
||||||
const receivingQtyMissing =
|
|
||||||
receivingMapped.length > 0 && apiRows.every((row) => row.receivingQty === '—')
|
|
||||||
return entryQtyMissing || receivingQtyMissing
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildEntryOnlyCompareRows(): CompareDisplayRow[] {
|
function buildEntryOnlyCompareRows(): CompareDisplayRow[] {
|
||||||
return entryItems.value.map((item, index) => {
|
return entryItems.value.map((item, index) => {
|
||||||
const mapped = mapEntryItem(item)
|
const mapped = mapEntryItem(item)
|
||||||
@ -478,6 +472,7 @@ function resetReceivingState() {
|
|||||||
selectedReceivingRows.value = []
|
selectedReceivingRows.value = []
|
||||||
compareRows.value = []
|
compareRows.value = []
|
||||||
entryItems.value = []
|
entryItems.value = []
|
||||||
|
isEntryFullyCovered.value = false
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
pagination.pageSize = 10
|
pagination.pageSize = 10
|
||||||
pagination.total = 0
|
pagination.total = 0
|
||||||
@ -516,20 +511,11 @@ async function loadEntryItems() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadReceivingDetailItems(receivingId: number): Promise<Record<string, unknown>[]> {
|
|
||||||
const res: any = await getReceivingDetail({
|
|
||||||
id: receivingId,
|
|
||||||
pagination: { page: 1, pageSize: 500 },
|
|
||||||
})
|
|
||||||
if (!isApiSuccess(res) || !res.data) return []
|
|
||||||
const receivingData = res.data.receiving || {}
|
|
||||||
if (Array.isArray(receivingData.details)) return receivingData.details
|
|
||||||
if (Array.isArray(res.data.list)) return res.data.list
|
|
||||||
if (Array.isArray(res.data.details)) return res.data.details
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
async function refreshCompareRows() {
|
async function refreshCompareRows() {
|
||||||
|
if (compareLoading.value) return
|
||||||
|
|
||||||
|
isEntryFullyCovered.value = false
|
||||||
|
|
||||||
const selected = selectedReceivingRows.value
|
const selected = selectedReceivingRows.value
|
||||||
if (!selected.length) {
|
if (!selected.length) {
|
||||||
compareRows.value = buildEntryOnlyCompareRows()
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
@ -538,47 +524,89 @@ async function refreshCompareRows() {
|
|||||||
|
|
||||||
compareLoading.value = true
|
compareLoading.value = true
|
||||||
try {
|
try {
|
||||||
if (selected.length === 1 && entryOrderId.value) {
|
if (!entryOrderId.value) {
|
||||||
const firstSelected = selected[0]
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
const receivingId = Number(firstSelected?.id)
|
return
|
||||||
if (Number.isFinite(receivingId) && receivingId > 0) {
|
}
|
||||||
const res = await receivingCompare({
|
|
||||||
entry_order_id: entryOrderId.value,
|
|
||||||
receiving_id: receivingId,
|
|
||||||
})
|
|
||||||
if (isApiSuccess(res)) {
|
|
||||||
const payload = (
|
|
||||||
res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res
|
|
||||||
) as ReceivingCompareResponse
|
|
||||||
const records = [
|
|
||||||
...(Array.isArray(payload.comparison) ? payload.comparison : []),
|
|
||||||
...(Array.isArray(payload.entry_only) ? payload.entry_only : []),
|
|
||||||
...(Array.isArray(payload.receiving_only) ? payload.receiving_only : []),
|
|
||||||
]
|
|
||||||
const entryMapped = entryItems.value.map(mapEntryItem)
|
|
||||||
const receivingMapped = (await loadReceivingDetailItems(receivingId)).map(mapReceivingDetailItem)
|
|
||||||
|
|
||||||
if (records.length) {
|
const eid = entryOrderId.value
|
||||||
const apiRows = buildCompareRowsFromApi(records)
|
const ids = selected
|
||||||
compareRows.value = shouldUseSideCompareFallback(apiRows, entryMapped, receivingMapped)
|
.map((row) => Number(row.id))
|
||||||
? buildCompareRowsFromSides(entryMapped, receivingMapped)
|
.filter((id) => Number.isFinite(id) && id > 0)
|
||||||
: apiRows
|
|
||||||
} else {
|
if (!eid || !ids.length) {
|
||||||
compareRows.value = buildCompareRowsFromSides(entryMapped, receivingMapped)
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await receivingCompare({
|
||||||
|
entry_order_id: eid,
|
||||||
|
receiving_ids: ids,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!isApiSuccess(res)) {
|
||||||
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = (
|
||||||
|
res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res
|
||||||
|
) as ReceivingCompareResponse
|
||||||
|
|
||||||
|
const allRecords: ReceivingCompareRow[] = []
|
||||||
|
const seenKeys = new Set<string>()
|
||||||
|
// 按 warehouse_item_code 跟踪最佳匹配状态:matched > entry_only
|
||||||
|
const itemMatchStatus = new Map<string, string>()
|
||||||
|
|
||||||
|
for (const item of (payload.comparisons ?? [])) {
|
||||||
|
const records = [
|
||||||
|
...(Array.isArray(item.comparison) ? item.comparison : []),
|
||||||
|
...(Array.isArray(item.receiving_only) ? item.receiving_only : []),
|
||||||
|
]
|
||||||
|
for (const record of records) {
|
||||||
|
const raw = record as Record<string, unknown>
|
||||||
|
const ms = String(raw.match_status ?? '').toLowerCase()
|
||||||
|
// 收货侧可用量为 0 则不展示(无实际可绑定量)
|
||||||
|
if (!raw.warehouse_item_code && Number(raw.receiving_available) === 0) continue
|
||||||
|
const key = String(raw.warehouse_item_code ?? Math.random())
|
||||||
|
|
||||||
|
// 更新该商品的最佳匹配状态
|
||||||
|
const prev = itemMatchStatus.get(key)
|
||||||
|
if (!prev || (prev === 'entry_only' && ms === 'matched')) {
|
||||||
|
itemMatchStatus.set(key, ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!seenKeys.has(key)) {
|
||||||
|
seenKeys.add(key)
|
||||||
|
allRecords.push(record)
|
||||||
|
} else if (ms === 'matched') {
|
||||||
|
// 已存在 entry_only 记录,现在遇到 matched,覆盖更新
|
||||||
|
const idx = allRecords.findIndex((r) => {
|
||||||
|
const rRaw = r as Record<string, unknown>
|
||||||
|
return String(rRaw.warehouse_item_code ?? '') === key
|
||||||
|
})
|
||||||
|
if (idx >= 0) {
|
||||||
|
allRecords[idx] = record
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const receivingMapped: Array<{ name: string; qty: string | number }> = []
|
// 只要有一个 entry_only 的商品从未被任何收货单 matched,则不算完全覆盖
|
||||||
for (const row of selected) {
|
let hasUnmatchedEntry = false
|
||||||
const receivingId = Number(row.id)
|
for (const [, status] of itemMatchStatus) {
|
||||||
if (!Number.isFinite(receivingId) || receivingId <= 0) continue
|
if (status === 'entry_only') {
|
||||||
const details = await loadReceivingDetailItems(receivingId)
|
hasUnmatchedEntry = true
|
||||||
details.forEach((item) => receivingMapped.push(mapReceivingDetailItem(item)))
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isEntryFullyCovered.value = !hasUnmatchedEntry
|
||||||
|
|
||||||
|
if (allRecords.length) {
|
||||||
|
compareRows.value = buildCompareRowsFromApi(allRecords)
|
||||||
|
} else {
|
||||||
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
}
|
}
|
||||||
compareRows.value = buildCompareRowsFromSides(entryItems.value.map(mapEntryItem), receivingMapped)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载对照数据失败:', error)
|
console.error('加载对照数据失败:', error)
|
||||||
compareRows.value = buildEntryOnlyCompareRows()
|
compareRows.value = buildEntryOnlyCompareRows()
|
||||||
@ -590,9 +618,12 @@ async function refreshCompareRows() {
|
|||||||
|
|
||||||
function handleReceivingSelectionChange(rows: ReceivingListItem[]) {
|
function handleReceivingSelectionChange(rows: ReceivingListItem[]) {
|
||||||
selectedReceivingRows.value = rows || []
|
selectedReceivingRows.value = rows || []
|
||||||
void refreshCompareRows()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(selectedReceivingRows, () => {
|
||||||
|
void refreshCompareRows()
|
||||||
|
})
|
||||||
|
|
||||||
async function loadReceivingList() {
|
async function loadReceivingList() {
|
||||||
if (!entryStoreId.value) {
|
if (!entryStoreId.value) {
|
||||||
receivingList.value = []
|
receivingList.value = []
|
||||||
@ -606,9 +637,11 @@ async function loadReceivingList() {
|
|||||||
try {
|
try {
|
||||||
const res = await getReceivingList({
|
const res = await getReceivingList({
|
||||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||||
|
filterDepleted: true,
|
||||||
where: {
|
where: {
|
||||||
store_id: { operator: 'eq', value: entryStoreId.value, type: 'number' },
|
store_id: { operator: 'eq', value: entryStoreId.value, type: 'number' },
|
||||||
is_review: { operator: 'eq', value: 1, type: 'number' },
|
is_review: { operator: 'eq', value: 1, type: 'number' },
|
||||||
|
storage_status: { operator: 'in', value: ['none', 'partial'], type: 'text' },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!isApiSuccess(res)) {
|
if (!isApiSuccess(res)) {
|
||||||
@ -780,6 +813,17 @@ watch(
|
|||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.summary-inline--remark {
|
||||||
|
flex-basis: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-value--remark {
|
||||||
|
max-width: 600px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.bind-dialog-body {
|
.bind-dialog-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
@ -911,6 +955,17 @@ watch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.compare-row--matched {
|
||||||
|
.compare-cell {
|
||||||
|
background: #67c23a !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compare-cell--qty {
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.compare-cell--qty {
|
.compare-cell--qty {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: #606266;
|
color: #606266;
|
||||||
|
|||||||
@ -190,16 +190,19 @@ const itemBindingRows = ref<ItemBindingRow[]>([])
|
|||||||
const comparePreview = ref<ReceivingCompareResponse | null>(null)
|
const comparePreview = ref<ReceivingCompareResponse | null>(null)
|
||||||
const activeCompareReceivingId = ref<number | null>(null)
|
const activeCompareReceivingId = ref<number | null>(null)
|
||||||
|
|
||||||
const compareSummaryItems = computed(() =>
|
const compareSummaryItems = computed(() => {
|
||||||
buildReceivingCompareSummaryItems(comparePreview.value?.summary as Record<string, unknown> | undefined)
|
const first = comparePreview.value?.comparisons?.[0]
|
||||||
)
|
return buildReceivingCompareSummaryItems(first?.summary as Record<string, unknown> | undefined)
|
||||||
|
})
|
||||||
|
|
||||||
const compareRows = computed<ComparePreviewRow[]>(() => {
|
const compareRows = computed<ComparePreviewRow[]>(() => {
|
||||||
if (!comparePreview.value) return []
|
if (!comparePreview.value) return []
|
||||||
|
const first = comparePreview.value.comparisons?.[0]
|
||||||
|
if (!first) return []
|
||||||
const records = [
|
const records = [
|
||||||
...(comparePreview.value.comparison ?? []),
|
...(first.comparison ?? []),
|
||||||
...(comparePreview.value.entry_only ?? []),
|
...(first.entry_only ?? []),
|
||||||
...(comparePreview.value.receiving_only ?? []),
|
...(first.receiving_only ?? []),
|
||||||
]
|
]
|
||||||
return records.map((record, index) => mapCompareRow(record, index))
|
return records.map((record, index) => mapCompareRow(record, index))
|
||||||
})
|
})
|
||||||
|
|||||||
@ -318,9 +318,12 @@ export function canDirectInboundOperate(status: unknown): boolean {
|
|||||||
return !['COMPLETED', 'CANCELLED'].includes(upper) && upper !== '已完成' && upper !== '已作废'
|
return !['COMPLETED', 'CANCELLED'].includes(upper) && upper !== '已完成' && upper !== '已作废'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 是否允许绑定收货(未完成、未作废) */
|
/** 是否允许绑定收货(仅 CREATED / 已创建 状态可操作) */
|
||||||
export function canBindEntryOrder(status: unknown): boolean {
|
export function canBindEntryOrder(status: unknown): boolean {
|
||||||
return canDirectInboundOperate(status)
|
if (status === null || status === undefined || status === '') return false
|
||||||
|
const normalized = String(status).trim()
|
||||||
|
const upper = normalized.toUpperCase()
|
||||||
|
return upper === 'CREATED' || normalized === '已创建'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** storage.entry.list 虚拟 where 字段(需原样传 boolean,不能包 operator) */
|
/** storage.entry.list 虚拟 where 字段(需原样传 boolean,不能包 operator) */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user