This commit is contained in:
zlwu committed 2026-08-31 08:28:36 +08:00
1 parent 19c5aaa8f5
commit 69fa5b1fa8
38 files changed
+15226 -11921

No files matched your search

@@ -1,5 +1,7 @@
import { ElMessageBox } from 'element-plus'
import type { ContractQtyReminder, ContractQtyReminderItem } from '@/api/pl'
import { useDictStore } from '@/store/modules/dict'
import { getProductUnitLabel } from '@/utils/crm-product-display'
export const CONTRACT_QTY_VIOLATION_CODE = 'CONTRACT_QTY_OVERFLOW'
@@ -40,6 +42,13 @@ function stopKindLabel(kind?: string): string {
return kind || ''
}
/** 将单位字典值(如 dun)转为展示文案(如 吨) */
function resolveUnitLabel(unit?: string): string {
if (!unit) return '—'
const dictStore = useDictStore()
return getProductUnitLabel((type, value) => dictStore.getLabel(type, value), unit)
}
export function extractContractQtyViolationDetail(error: unknown): {
message: string
items: Array<Record<string, unknown>>
@@ -134,7 +143,7 @@ export function buildContractQtyDialogHtml(
.map((row) => {
const name = escapeHtml(row.productName || row.productId || '—')
const model = escapeHtml(row.model || '—')
const unit = escapeHtml(row.unit || '—')
const unit = escapeHtml(resolveUnitLabel(row.unit))
const contractQty = row.framework
? '按客户需求'
: escapeHtml(formatQty(row.contractQty))
@@ -24,3 +24,26 @@ export function filterProductsByAllowedProductIds<T extends { productId?: string
if (!allowed.size) return []
return (products || []).filter((row) => allowed.has(String(row.productId || '').trim()))
}
/**
* 找出不在装货产品列表中的送货产品(仅提醒,不拦截)。
* 返回展示名列表(去重)。
*/
export function findDeliveryProductsMissingFromLoad(
deliveryProducts: Array<{ productId?: string | null; productName?: string | null }> | null | undefined,
loadProducts: Array<{ productId?: string | null }> | null | undefined
): string[] {
const loadIds = new Set(
(loadProducts || []).map((row) => String(row?.productId || '').trim()).filter(Boolean)
)
const names: string[] = []
const seen = new Set<string>()
for (const row of deliveryProducts || []) {
const pid = String(row?.productId || '').trim()
if (!pid || loadIds.has(pid) || seen.has(pid)) continue
seen.add(pid)
const name = String(row?.productName || '').trim() || pid
names.push(name)
}
return names
}