提交
This commit is contained in:
1 parent
33c038b8d9
commit
54b27a3f0e
253 files changed
+30060
-14298
No files matched your search
@@ -173,34 +173,6 @@ export function usePlPlanArrangeActions() {
|
||||
ElMessage.success('已复制司机链接')
|
||||
}
|
||||
|
||||
function buildAllSiteLinksText(records?: TransportSiteLink[]) {
|
||||
const list = records || siteRecords.value
|
||||
return list
|
||||
.filter(item => item.siteUrl)
|
||||
.map(item => `${item.productName || '现场链接'}:${item.siteUrl}`)
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
async function copySiteUrl(url?: string) {
|
||||
const target = (url || siteRecords.value.find(item => item.siteUrl)?.siteUrl || '').trim()
|
||||
if (!target) {
|
||||
ElMessage.warning('暂无现场链接')
|
||||
return
|
||||
}
|
||||
await navigator.clipboard.writeText(target)
|
||||
ElMessage.success('已复制现场链接')
|
||||
}
|
||||
|
||||
async function copyAllSiteUrls(records?: TransportSiteLink[]) {
|
||||
const text = buildAllSiteLinksText(records)
|
||||
if (!text) {
|
||||
ElMessage.warning('暂无现场链接')
|
||||
return
|
||||
}
|
||||
await navigator.clipboard.writeText(text)
|
||||
ElMessage.success('已复制全部现场链接')
|
||||
}
|
||||
|
||||
function resolveSiteRecordProductText(record: TransportSiteLink) {
|
||||
const product = products.value.find(item => item.id === record.planProductId)
|
||||
if (product) {
|
||||
@@ -316,8 +288,6 @@ export function usePlPlanArrangeActions() {
|
||||
buildPlanSummaryText,
|
||||
buildSiteSummaryText,
|
||||
copyDriverUrl,
|
||||
copySiteUrl,
|
||||
copyAllSiteUrls,
|
||||
copySiteSummary,
|
||||
copyPlanSummary,
|
||||
copyPoundSlipQrcode
|
||||
|
||||
@@ -45,30 +45,20 @@ export function formatPlProductNameWithHazardMarks(product: HazardFlagProduct) {
|
||||
return `${name}${marks.join(' ')}`
|
||||
}
|
||||
|
||||
/** 从 CRM 产品主数据补全易制毒/易制爆标识(合同明细通常不带该字段) */
|
||||
/** 从 CRM 产品主数据读取易制毒/易制爆标识(覆盖计划产品快照字段) */
|
||||
export async function enrichPlanProductsHazardFromCrm<T extends HazardFlagProduct & { productId: string }>(
|
||||
products: T[]
|
||||
): Promise<T[]> {
|
||||
if (!products.length) return products
|
||||
|
||||
const needLookupIds = [
|
||||
...new Set(
|
||||
products
|
||||
.filter(product => {
|
||||
if (!product.productId) return false
|
||||
const flags = resolveProductHazardFlags(product)
|
||||
const needsHazard = !flags.isToxic && !flags.isExplosive
|
||||
const needsTaxRate = product.taxRate == null
|
||||
return needsHazard || needsTaxRate
|
||||
})
|
||||
.map(product => product.productId)
|
||||
)
|
||||
const lookupIds = [
|
||||
...new Set(products.map(product => product.productId).filter(Boolean))
|
||||
]
|
||||
if (!needLookupIds.length) return products
|
||||
if (!lookupIds.length) return products
|
||||
|
||||
const hazardMap = new Map<string, { isToxic: number; isExplosive: number; taxRate?: number }>()
|
||||
await Promise.all(
|
||||
needLookupIds.map(async productId => {
|
||||
lookupIds.map(async productId => {
|
||||
try {
|
||||
const res = await fetchProductDetail({ id: productId })
|
||||
const data = (res as { data?: Record<string, unknown> }).data ?? res
|
||||
@@ -86,13 +76,12 @@ export async function enrichPlanProductsHazardFromCrm<T extends HazardFlagProduc
|
||||
)
|
||||
|
||||
return products.map(product => {
|
||||
const flags = resolveProductHazardFlags(product)
|
||||
const fromCrm = hazardMap.get(product.productId)
|
||||
if (!fromCrm) return product
|
||||
return {
|
||||
...product,
|
||||
isToxic: flags.isToxic ? product.isToxic : fromCrm.isToxic,
|
||||
isExplosive: flags.isExplosive ? product.isExplosive : fromCrm.isExplosive,
|
||||
isToxic: fromCrm.isToxic,
|
||||
isExplosive: fromCrm.isExplosive,
|
||||
taxRate: product.taxRate ?? fromCrm.taxRate
|
||||
}
|
||||
})
|
||||
@@ -104,6 +93,32 @@ export function findMissingHazardCerts(products: PlanProduct[]) {
|
||||
)
|
||||
}
|
||||
|
||||
export function planHasHazardProducts(products: PlanProduct[] | undefined) {
|
||||
return (products ?? []).some(p => isHazardProduct(p))
|
||||
}
|
||||
|
||||
export function isHazardCertReady(plan: { hazardCertReady?: number } | null | undefined) {
|
||||
return Number(plan?.hazardCertReady ?? 0) === 1
|
||||
}
|
||||
|
||||
/** 含危化品且尚未人工确认证书齐备时,阻断安排运输 */
|
||||
export function shouldBlockTransportForHazardCert(
|
||||
plan: { hazardCertReady?: number; products?: PlanProduct[] } | null | undefined,
|
||||
products?: PlanProduct[]
|
||||
) {
|
||||
const prods = products ?? plan?.products
|
||||
if (!planHasHazardProducts(prods)) return false
|
||||
return !isHazardCertReady(plan)
|
||||
}
|
||||
|
||||
export function buildMissingHazardCertReadyMessage(
|
||||
plan: { hazardCertReady?: number; products?: PlanProduct[] } | null | undefined,
|
||||
products?: PlanProduct[]
|
||||
) {
|
||||
if (!shouldBlockTransportForHazardCert(plan, products)) return ''
|
||||
return '该计划危化品证书尚未确认齐备'
|
||||
}
|
||||
|
||||
export function buildMissingHazardCertMessage(products: PlanProduct[]) {
|
||||
const missing = findMissingHazardCerts(products)
|
||||
if (!missing.length) return ''
|
||||
|
||||
Reference in new issue
Block a user