feat: 保存运输证件、报销付款和开发流程的当前实现。
补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7325a0aa52
commit
8e9536332a
202 files changed
+19200
-2054
No files matched your search
@@ -175,8 +175,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<slot name="beside" />
|
||||
</div>
|
||||
<span v-if="!disabled && !compact" class="upload-hint">{{ hint }}</span>
|
||||
<span v-if="hint && !disabled && !compact" class="upload-hint">{{ hint }}</span>
|
||||
|
||||
<el-dialog
|
||||
v-model="previewVisible"
|
||||
|
||||
@@ -1552,8 +1552,8 @@
|
||||
const archiveBody: PlanArchiveBody = JSON.parse(JSON.stringify(buildArchiveBody()))
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (productRows.value.some(p => Number(p.isToxic) === 1)) {
|
||||
const value = await quotaSettlementDialog.value?.open(targetId, isAdjustMode.value)
|
||||
if (isAdjustMode.value && productRows.value.some(p => Number(p.isToxic) === 1)) {
|
||||
const value = await quotaSettlementDialog.value?.open(targetId, true)
|
||||
if (!current() || !value) return
|
||||
Object.assign(archiveBody, value)
|
||||
}
|
||||
@@ -1566,13 +1566,62 @@
|
||||
innerVisible.value = false
|
||||
} catch (e: unknown) {
|
||||
if (!current() || (e as { cancelled?: boolean }).cancelled) return
|
||||
const message = e instanceof Error ? e.message : isAdjustMode.value ? '保存失败' : '归档失败'
|
||||
const message = archiveFailureMessage(e, isAdjustMode.value ? '保存失败' : '归档失败')
|
||||
if (message.includes('不能归档')) {
|
||||
await showArchiveQuotaBlockDialog(message)
|
||||
return
|
||||
}
|
||||
ElMessage.error(message)
|
||||
} finally {
|
||||
if (session === archiveSession) submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function archiveFailureMessage(error: unknown, fallback: string) {
|
||||
const detail = (error as { response?: { data?: { detail?: unknown; msg?: unknown } } })?.response?.data
|
||||
const raw = detail?.detail ?? detail?.msg
|
||||
if (typeof raw === 'string' && raw.trim()) return raw
|
||||
if (error instanceof Error && error.message && !error.message.startsWith('Request failed')) return error.message
|
||||
return fallback
|
||||
}
|
||||
|
||||
function escapeArchiveBlockText(value: string) {
|
||||
return value
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
async function showArchiveQuotaBlockDialog(message: string, title = '不能归档') {
|
||||
const html = `<p class="pl-arrange-block-text">${escapeArchiveBlockText(message)}</p>`
|
||||
if (title !== '用证没有完成') {
|
||||
await ElMessageBox.alert(html, title, {
|
||||
type: 'warning',
|
||||
confirmButtonText: '知道了',
|
||||
dangerouslyUseHTMLString: true,
|
||||
customClass: 'pl-arrange-block-msgbox',
|
||||
closeOnClickModal: false
|
||||
}).catch(() => undefined)
|
||||
return undefined
|
||||
}
|
||||
const readyHtml = `${html}<p class="pl-arrange-block-text">如果购买证、运输证还没上传,可以标记证书齐备。标记后这次归档不再校验,也不扣减这两证的额度。</p>`
|
||||
try {
|
||||
await ElMessageBox.confirm(readyHtml, title, {
|
||||
type: 'warning',
|
||||
confirmButtonText: '证书齐备',
|
||||
cancelButtonText: '知道了',
|
||||
dangerouslyUseHTMLString: true,
|
||||
customClass: 'pl-arrange-block-msgbox',
|
||||
closeOnClickModal: false,
|
||||
distinguishCancelAndClose: true
|
||||
})
|
||||
return 'ready' as const
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function applyArchiveOverageHighlight(items: Array<Record<string, unknown>>) {
|
||||
const ids = new Set(
|
||||
items.map((item) => String(item.stopProductId || '').trim()).filter(Boolean)
|
||||
@@ -1593,14 +1642,24 @@
|
||||
const archiveBody = { ...frozenBody, confirmOverage }
|
||||
const signature = JSON.stringify({ planId: targetId, archiveBody })
|
||||
if (signature !== quotaArchiveAttempt.signature) quotaArchiveAttempt = { signature, id: crypto.randomUUID() }
|
||||
const response = await planApi.archive(targetId, { ...archiveBody, operationId: quotaArchiveAttempt.id })
|
||||
const response = await planApi.archive(
|
||||
targetId,
|
||||
{ ...archiveBody, operationId: quotaArchiveAttempt.id },
|
||||
{ skipErrorMessage: true }
|
||||
)
|
||||
if (!current()) return
|
||||
const saved = pickBxData<Plan & { quotaSettlementError?: string }>(response)
|
||||
if (saved?.quotaSettlementError) {
|
||||
// 业务异常已作为一次请求提交;补齐条件后允许新尝试,不回放旧异常。
|
||||
quotaArchiveAttempt = { signature: '', id: '' }
|
||||
const message = `实际数量已保存,额度结转未完成:${saved.quotaSettlementError}`
|
||||
await ElMessageBox.alert(message, '用证结转异常', { type: 'warning' })
|
||||
const message = saved.quotaSettlementError
|
||||
const choice = await showArchiveQuotaBlockDialog(message, '用证没有完成')
|
||||
if (choice === 'ready' && current()) {
|
||||
await planApi.markQuotaCertReady(targetId)
|
||||
if (!current()) return
|
||||
await submitArchiveWithOverageConfirm(targetId, frozenBody, current, confirmOverage)
|
||||
return
|
||||
}
|
||||
const error = new Error(message) as Error & { cancelled?: boolean }
|
||||
error.cancelled = true
|
||||
throw error
|
||||
@@ -1796,6 +1855,20 @@
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.el-message-box.pl-arrange-block-msgbox {
|
||||
width: 520px;
|
||||
max-width: 92vw;
|
||||
|
||||
.pl-arrange-block-text {
|
||||
margin: 0;
|
||||
color: #c2410c;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.el-dialog.pl-plan-archive-dialog.dialog-form-layout {
|
||||
width: min(2400px, calc(100vw - 24px)) !important;
|
||||
max-width: min(2400px, calc(100vw - 24px));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<PlPlanQuotaDialog ref="quotaDialog" />
|
||||
<MobilePlPlanForm v-if="isPageVariant" :controller="mobileController">
|
||||
<template #load>
|
||||
<el-form label-position="top" label-width="100px" class="pl-dialog-form">
|
||||
@@ -616,8 +615,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import PlPlanQuotaDialog from '@/components/business/pl-plan-quota-dialog/index.vue'
|
||||
const quotaDialog = ref<InstanceType<typeof PlPlanQuotaDialog>>()
|
||||
let arrangeAttempt = { signature: '', id: '' }
|
||||
import PlanArrangeSheets from '@/views/m/pl/plan/PlanArrangeSheets.vue'
|
||||
const arrangeSheetsRef = ref<InstanceType<typeof PlanArrangeSheets> | null>(null)
|
||||
@@ -664,6 +661,8 @@
|
||||
type Vehicle,
|
||||
type VehiclePersonnelRow
|
||||
} from '@/api/pl'
|
||||
import { planQuotaApi, type QuotaSourceOption } from '@/api/pl/quota-cert'
|
||||
import { toxicArrangeBlockMessage } from '@/utils/pl-quota-cert-waiver'
|
||||
import { arrangeBlockedMessage, isExecutionStarted } from '@/utils/pl-plan-action-guards'
|
||||
import {
|
||||
usePlRemoteCarrierOptions,
|
||||
@@ -2597,10 +2596,46 @@
|
||||
return `${driver.personnelName}${phone}${suffix}`
|
||||
}
|
||||
|
||||
function escapeArrangeBlockText(value: string) {
|
||||
return value
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
async function showArrangeBlockDialog(message: string) {
|
||||
const html = `<p class="pl-arrange-block-text">${escapeArrangeBlockText(message)}</p>`
|
||||
await ElMessageBox.alert(html, '无法安排运输', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '知道了',
|
||||
dangerouslyUseHTMLString: true,
|
||||
customClass: 'pl-arrange-block-msgbox',
|
||||
closeOnClickModal: false
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
function toxicContractCertBindingMessage(rows: QuotaSourceOption[]) {
|
||||
const missing = new Map<string, string>()
|
||||
for (const row of rows) {
|
||||
if (isPlInternalCustomerName(row.partyName)) continue
|
||||
const certificates = row.certificates || []
|
||||
const ready =
|
||||
certificates.some((cert) => cert.certType === 'purchase') &&
|
||||
certificates.some((cert) => cert.certType === 'transport')
|
||||
if (ready) continue
|
||||
const key = row.contractId || row.contractNo || row.productName || row.sourceStopProductId
|
||||
missing.set(key, row.contractNo || '未编号合同')
|
||||
}
|
||||
if (!missing.size) return ''
|
||||
return `合同${[...missing.values()].join('、')}尚未绑定购买证和运输证,请先到合同中绑定后再安排运输`
|
||||
}
|
||||
|
||||
async function performArrangeAfterSave(
|
||||
planId: string,
|
||||
generation = pageLoadGeneration
|
||||
): Promise<boolean> {
|
||||
generation = pageLoadGeneration,
|
||||
options?: { skipConfirm?: boolean }
|
||||
): Promise<boolean | 'cert-binding'> {
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
const arrangePresenter = createArrangePresenter(generation)
|
||||
const detailRes = await planApi.get(planId)
|
||||
@@ -2627,33 +2662,44 @@
|
||||
const rawProducts = Array.isArray(plan.products) ? plan.products : []
|
||||
const enrichedProducts = await enrichPlanProductsHazardFromCrm(rawProducts)
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
const quotaConfiguration = enrichedProducts.some(p => Number(p.isToxic) === 1)
|
||||
? await quotaDialog.value?.open(planId, true, { targetLicensePlate: currentVehiclePlate.value, targetTrailerNo: selectedVehicle.value?.trailerNo || null })
|
||||
: undefined
|
||||
if (enrichedProducts.some(p => Number(p.isToxic) === 1) && !quotaConfiguration) return false
|
||||
|
||||
const isRearrange = plan.transportStatus === 'arranged'
|
||||
const dibangSelected = planHasAnyDibangSelected(plan, loadForm.value, deliveryForms.value)
|
||||
let historical = { hasHistoricalDibang: false, hasHistoricalSiteLinks: false }
|
||||
if (isRearrange) {
|
||||
historical = await loadArrangeHistoricalFlags(planId)
|
||||
if (enrichedProducts.some((product) => Number(product.isToxic) === 1)) {
|
||||
const quota = await planQuotaApi.get(planId, true)
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
const rows = (quota?.stopProducts || []).filter((row) => row.isToxic)
|
||||
const unbound = rows.length
|
||||
? toxicContractCertBindingMessage(rows)
|
||||
: '易制毒产品尚未绑定购买证和运输证,请先到合同中绑定后再安排运输'
|
||||
const bound = toxicArrangeBlockMessage(quota, unbound)
|
||||
if (bound) {
|
||||
if (isPageVariant.value) await arrangePresenter({ title: '无法安排运输', message: bound })
|
||||
else await showArrangeBlockDialog(bound)
|
||||
return 'cert-binding'
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await confirmBeforePlanArrange({
|
||||
isRearrange,
|
||||
plan,
|
||||
hasHistoricalDibang: historical.hasHistoricalDibang,
|
||||
hasHistoricalSiteLinks: historical.hasHistoricalSiteLinks,
|
||||
hasAnyDibangSelected: dibangSelected,
|
||||
presenter: isPageVariant.value ? arrangePresenter : undefined
|
||||
})
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
} catch (error) {
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
if (error === 'cancel') return false
|
||||
throw error
|
||||
const isRearrange = plan.transportStatus === 'arranged'
|
||||
if (!options?.skipConfirm) {
|
||||
const dibangSelected = planHasAnyDibangSelected(plan, loadForm.value, deliveryForms.value)
|
||||
let historical = { hasHistoricalDibang: false, hasHistoricalSiteLinks: false }
|
||||
if (isRearrange) {
|
||||
historical = await loadArrangeHistoricalFlags(planId)
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
}
|
||||
try {
|
||||
await confirmBeforePlanArrange({
|
||||
isRearrange,
|
||||
plan,
|
||||
hasHistoricalDibang: historical.hasHistoricalDibang,
|
||||
hasHistoricalSiteLinks: historical.hasHistoricalSiteLinks,
|
||||
hasAnyDibangSelected: dibangSelected,
|
||||
presenter: isPageVariant.value ? arrangePresenter : undefined
|
||||
})
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
} catch (error) {
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
if (error === 'cancel') return false
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const payload = buildArrangePayloadFromPlanForm({
|
||||
@@ -2673,10 +2719,14 @@
|
||||
getUnitLabel
|
||||
})
|
||||
|
||||
const signature = JSON.stringify({planId, payload, quotaConfiguration})
|
||||
const signature = JSON.stringify({ planId, payload })
|
||||
if (signature !== arrangeAttempt.signature) arrangeAttempt = { signature, id: crypto.randomUUID() }
|
||||
try {
|
||||
await submitPlanArrange(planId, { ...payload, operationId: arrangeAttempt.id, quotaConfiguration }, isPageVariant.value ? arrangePresenter : undefined)
|
||||
await submitPlanArrange(
|
||||
planId,
|
||||
{ ...payload, operationId: arrangeAttempt.id },
|
||||
isPageVariant.value ? arrangePresenter : undefined
|
||||
)
|
||||
if (!isPageSubmitCurrent(generation)) return false
|
||||
} catch {
|
||||
return false
|
||||
@@ -3427,7 +3477,44 @@
|
||||
mirrorPlanProductsFromLoad()
|
||||
const commonPayload = {
|
||||
...buildPlanCommonPayload({ allowClearTransport: isEdit.value }),
|
||||
saveMode: 'formal' as const
|
||||
saveMode: (
|
||||
mode === 'rearrange' ||
|
||||
(mode === 'saveAndArrange' && loadedTransportStatus.value === 'arranged')
|
||||
? 'rearrange'
|
||||
: 'formal'
|
||||
) as 'formal' | 'rearrange'
|
||||
}
|
||||
if (commonPayload.saveMode === 'rearrange') {
|
||||
const current = loadedPlanSnapshot.value
|
||||
if (!current?.id) {
|
||||
ElMessage.error('计划尚未加载完成,无法调整运输')
|
||||
return
|
||||
}
|
||||
if (isExecutionStarted(current)) {
|
||||
ElMessage.warning(arrangeBlockedMessage(current))
|
||||
return
|
||||
}
|
||||
const historical = await loadArrangeHistoricalFlags(current.id)
|
||||
if (!isPageSubmitCurrent(generation)) return
|
||||
try {
|
||||
await confirmBeforePlanArrange({
|
||||
isRearrange: true,
|
||||
plan: current,
|
||||
hasHistoricalDibang: historical.hasHistoricalDibang,
|
||||
hasHistoricalSiteLinks: historical.hasHistoricalSiteLinks,
|
||||
hasAnyDibangSelected: planHasAnyDibangSelected(
|
||||
current,
|
||||
loadForm.value,
|
||||
deliveryForms.value
|
||||
),
|
||||
presenter: isPageVariant.value ? createArrangePresenter(generation) : undefined
|
||||
})
|
||||
} catch (error) {
|
||||
if (!isPageSubmitCurrent(generation)) return
|
||||
if (error === 'cancel') return
|
||||
throw error
|
||||
}
|
||||
if (!isPageSubmitCurrent(generation)) return
|
||||
}
|
||||
let planId = props.planId || ''
|
||||
const wasCreate = !isEdit.value
|
||||
@@ -3463,15 +3550,17 @@
|
||||
|
||||
if ((mode === 'saveAndArrange' || mode === 'rearrange') && planId) {
|
||||
if (isPageVariant.value) mobileSavedPlanId.value = planId
|
||||
const arranged = await performArrangeAfterSave(planId, generation)
|
||||
const arranged = await performArrangeAfterSave(planId, generation, {
|
||||
skipConfirm: commonPayload.saveMode === 'rearrange'
|
||||
})
|
||||
if (!isPageSubmitCurrent(generation)) return
|
||||
if (!arranged) {
|
||||
if (arranged !== true) {
|
||||
// 计划已落库;关闭新建窗,避免停留在创建态再次点击又生成一张
|
||||
if (wasCreate) {
|
||||
if (arranged !== 'cert-binding' && wasCreate) {
|
||||
ElMessage.warning(
|
||||
'计划已创建成功,但未能安排运输。请至列表查看;若因危化证未就绪,请先完成【危化品证上传】后再安排。'
|
||||
)
|
||||
} else {
|
||||
} else if (arranged !== 'cert-binding') {
|
||||
ElMessage.warning('计划已保存,但未能安排运输。请稍后在列表中重试安排。')
|
||||
}
|
||||
innerVisible.value = false
|
||||
@@ -4354,6 +4443,19 @@
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.el-message-box.pl-arrange-block-msgbox {
|
||||
width: 520px;
|
||||
max-width: 92vw;
|
||||
|
||||
.pl-arrange-block-text {
|
||||
margin: 0;
|
||||
color: #c2410c;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
|
||||
.el-dialog.pl-contract-line-picker-dialog {
|
||||
.pkg-spec-wrap-col .cell {
|
||||
white-space: normal;
|
||||
|
||||
@@ -2,34 +2,130 @@
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="`计划用证 · ${plan?.planNo || ''}`"
|
||||
width="1080px"
|
||||
width="1240px"
|
||||
class="dialog-form-layout quota-dialog"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!busy"
|
||||
:show-close="!busy"
|
||||
@closed="!visible && cancel()"
|
||||
>
|
||||
<div v-loading="loading">
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
:title="
|
||||
forSupplement
|
||||
? '仅为超过原预占的实际量选择补充证件。保留原来源与分配顺序,提交归档时重新校验;本次选择不扣额度。'
|
||||
: '绑定不扣额度。正式安排时按当前合同、证件与来源重新校验并预占;合法使用证明可后补。'
|
||||
"
|
||||
/>
|
||||
<template v-if="plan">
|
||||
<p>当前车号:{{ plan.licensePlate || '待安排' }}</p>
|
||||
<p
|
||||
v-if="!forArrange && !forSupplement && plan.canSaveConfiguration === false"
|
||||
class="form-tip"
|
||||
<div class="quota-meta">
|
||||
<span>当前车号</span>
|
||||
<strong>{{ plan.licensePlate || '待安排' }}</strong>
|
||||
</div>
|
||||
<p v-if="viewOnly && plan.canSaveConfiguration === false" class="quota-note"
|
||||
>已安排计划请从调整运输提交用证变更;已归档计划仅查看占用。</p
|
||||
>
|
||||
<section class="view-section">
|
||||
<h3>{{ isPerStop ? '1. 全部装送段用证需求' : '1. 原口径:唯一计量侧与装送配对' }}</h3>
|
||||
<el-table v-if="isPerStop" :data="measured" stripe>
|
||||
<template v-if="viewOnly">
|
||||
<h3 class="dialog-section-title">全部装送段用证需求</h3>
|
||||
<div class="quota-table-wrap">
|
||||
<el-table class="quota-table" :data="plan.sourceOptions" stripe border>
|
||||
<el-table-column label="段产品" min-width="220"
|
||||
><template #default="{ row }">{{
|
||||
sourceLabel(`${row.sourceStopType}:${row.sourceStopProductId}`, plan.sourceOptions)
|
||||
}}</template></el-table-column
|
||||
>
|
||||
<el-table-column prop="contractNo" label="关联合同" min-width="170"
|
||||
><template #default="{ row }">{{ row.contractNo || '未关联合同' }}</template></el-table-column
|
||||
>
|
||||
<el-table-column prop="partyName" label="装送单位" min-width="180" />
|
||||
<el-table-column label="需用量" min-width="120"
|
||||
><template #default="{ row }"
|
||||
>{{ qtyText(row.quantity) }} {{ unitText(row.unit) }}</template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="购买证" min-width="210"
|
||||
><template #default="{ row }"
|
||||
><div class="cert-tags">
|
||||
<el-tag
|
||||
v-for="cert in certsOf(row, 'purchase')"
|
||||
:key="cert.certId"
|
||||
class="cert-face-tag"
|
||||
effect="plain"
|
||||
@click="showCertFace(cert)"
|
||||
>{{ cert.certNo }}</el-tag
|
||||
>
|
||||
<el-tag v-if="!certsOf(row, 'purchase').length" type="info" effect="plain"
|
||||
>未绑定</el-tag
|
||||
>
|
||||
</div></template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column label="运输证" min-width="210"
|
||||
><template #default="{ row }"
|
||||
><div class="cert-tags">
|
||||
<el-tag
|
||||
v-for="cert in certsOf(row, 'transport')"
|
||||
:key="cert.certId"
|
||||
class="cert-face-tag"
|
||||
effect="plain"
|
||||
@click="showCertFace(cert)"
|
||||
>{{ cert.certNo }}</el-tag
|
||||
>
|
||||
<el-tag v-if="!certsOf(row, 'transport').length" type="info" effect="plain"
|
||||
>未绑定</el-tag
|
||||
>
|
||||
</div></template
|
||||
></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
</div>
|
||||
<p v-if="!groups.length" class="quota-note">当前计划没有易制毒产品,无需购买证、运输证额度。</p>
|
||||
<section v-if="faceTabs.length" class="quota-face">
|
||||
<h3 class="dialog-section-title">关联证件证面</h3>
|
||||
<el-tabs v-model="faceTab" class="quota-face-tabs">
|
||||
<el-tab-pane v-for="tab in faceTabs" :key="tab.key" :label="tab.label" :name="tab.key">
|
||||
<p v-if="!tab.cert" class="quota-note">没有读到这张证的证面档案。</p>
|
||||
<template v-else>
|
||||
<section
|
||||
v-for="(group, groupIndex) in faceGroups(tab.cert, tab.kind)"
|
||||
:key="groupIndex"
|
||||
class="quota-face-group"
|
||||
>
|
||||
<h4 v-if="group.title">{{ group.title }}</h4>
|
||||
<ViewKvTable :fields="group.fields" mode="dual" />
|
||||
</section>
|
||||
<section v-if="tab.kind === 'transport'" class="quota-face-group">
|
||||
<h4>证面引用</h4>
|
||||
<el-table
|
||||
v-if="tab.cert.purchaseRefs?.length"
|
||||
:data="tab.cert.purchaseRefs"
|
||||
stripe
|
||||
border
|
||||
>
|
||||
<el-table-column label="引用类型" min-width="160">
|
||||
<template #default="{ row }">{{
|
||||
refLabels[row.referenceType] || row.referenceType || '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="referenceNo" label="购买许可/备案/出口许可证号" min-width="240" />
|
||||
<el-table-column label="对应购买证" min-width="180">
|
||||
<template #default="{ row }">{{
|
||||
purchases.find((item) => item.id === row.purchaseCertId)?.certNo ||
|
||||
(row.purchaseCertId ? '无查看权限或已失效' : '未关联')
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<p v-else class="quota-note">没有证面引用。</p>
|
||||
</section>
|
||||
<section v-if="tab.cert.attachmentUrls" class="quota-face-group">
|
||||
<h4>证件附件</h4>
|
||||
<AttachmentUploadField :model-value="tab.cert.attachmentUrls" disabled />
|
||||
</section>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</section>
|
||||
</template>
|
||||
<section v-else class="view-section">
|
||||
<h3 class="dialog-section-title">{{
|
||||
isPerStop ? '全部装送段用证需求' : '原口径:唯一计量侧与装送配对'
|
||||
}}</h3>
|
||||
<el-table v-if="isPerStop" :data="measured" stripe border>
|
||||
<el-table-column label="段产品" min-width="200"
|
||||
><template #default="{ row }">{{
|
||||
sourceLabel(`${row.sourceStopType}:${row.sourceStopProductId}`, measured)
|
||||
@@ -39,9 +135,19 @@
|
||||
<el-table-column prop="partyName" label="单位" min-width="160" />
|
||||
<el-table-column label="需用量" min-width="120"
|
||||
><template #default="{ row }"
|
||||
>{{ row.quantity }} {{ row.unit }}</template
|
||||
>{{ qtyText(row.quantity) }} {{ unitText(row.unit) }}</template
|
||||
></el-table-column
|
||||
>
|
||||
<el-table-column v-if="viewOnly" label="购买证" min-width="180"
|
||||
><template #default="{ row }">{{
|
||||
certText(row, 'purchase')
|
||||
}}</template></el-table-column
|
||||
>
|
||||
<el-table-column v-if="viewOnly" label="运输证" min-width="180"
|
||||
><template #default="{ row }">{{
|
||||
certText(row, 'transport')
|
||||
}}</template></el-table-column
|
||||
>
|
||||
</el-table>
|
||||
<p v-if="!groups.length">当前计划没有易制毒产品,无需购买证、运输证额度。</p>
|
||||
<div v-for="group in isPerStop ? [] : groups" :key="group.id" class="view-section">
|
||||
@@ -60,8 +166,13 @@
|
||||
class="view-section"
|
||||
>
|
||||
<p
|
||||
>{{ source.partyName || '未填写单位' }} · {{ source.quantity }} {{ source.unit }} ·
|
||||
{{ source.model }}</p
|
||||
>{{ source.partyName || '未填写单位' }} · {{ qtyText(source.quantity) }}
|
||||
{{ unitText(source.unit) }} · {{ source.model }}</p
|
||||
>
|
||||
<p v-if="viewOnly"
|
||||
>购买证:{{ certText(source, 'purchase') }};运输证:{{
|
||||
certText(source, 'transport')
|
||||
}}</p
|
||||
>
|
||||
<el-select
|
||||
v-if="opposite(group).length"
|
||||
@@ -76,13 +187,60 @@
|
||||
v-for="other in opposite(group)"
|
||||
:key="other.sourceStopProductId"
|
||||
:value="other.sourceStopProductId"
|
||||
:label="`${other.partyName || '未填写单位'} · ${other.quantity} ${other.unit} · ${other.productName}`"
|
||||
:label="`${other.partyName || '未填写单位'} · ${qtyText(other.quantity)} ${unitText(other.unit)} · ${other.productName}`"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="groups.length" class="view-section">
|
||||
<section v-if="viewOnly && conversions.length" class="conversion-section">
|
||||
<h3 class="dialog-section-title">单位不一致,填写换算系数</h3>
|
||||
<p class="quota-note"
|
||||
>只列出计划单位和证面单位不同的段次。系数表示 1 个计划单位等于多少证面单位,计划数量保持不变。</p
|
||||
>
|
||||
<article v-for="group in conversionGroups" :key="group.sourceId" class="conversion-group">
|
||||
<header class="conversion-group-head">
|
||||
<h4>{{ sourceLabel(group.sourceId, measured) }}</h4>
|
||||
<p
|
||||
>计划数量 {{ qtyText(group.source.quantity) }}
|
||||
{{ unitText(group.source.unit) }}</p
|
||||
>
|
||||
</header>
|
||||
<div class="conversion-grid">
|
||||
<section v-for="row in group.rows" :key="conversionKey(row)" class="conversion-card">
|
||||
<div class="conversion-card-head">
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="plain"
|
||||
:type="row.cert.certType === 'purchase' ? 'success' : 'primary'"
|
||||
>{{ row.cert.certType === 'purchase' ? '购买证' : '运输证' }}</el-tag
|
||||
>
|
||||
<strong>{{ row.cert.certNo }}</strong>
|
||||
</div>
|
||||
<label>换算系数</label>
|
||||
<div class="conversion-factor">
|
||||
<span>1 {{ unitText(row.source.unit) }} =</span>
|
||||
<el-input
|
||||
v-model="coefficients[conversionKey(row)]"
|
||||
:disabled="busy || plan.canSaveConfiguration === false"
|
||||
placeholder="系数"
|
||||
/>
|
||||
<span>{{ unitText(row.cert.quantityUnit) }}</span>
|
||||
</div>
|
||||
<p class="conversion-preview" :class="{ 'is-empty': !conversionPreview(row) }">{{
|
||||
conversionPreview(row) ? `证面数量 ${conversionPreview(row)}` : '填写系数后显示证面数量'
|
||||
}}</p>
|
||||
<label>换算依据</label>
|
||||
<el-input
|
||||
v-model="conversionInput(row).note"
|
||||
:disabled="busy || plan.canSaveConfiguration === false"
|
||||
placeholder="选填"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
<section v-if="groups.length && !viewOnly" class="view-section">
|
||||
<h3>2. 选择合同产品适用的证件</h3>
|
||||
<el-form label-position="top" :disabled="busy"
|
||||
><div class="form-grid-2">
|
||||
@@ -118,9 +276,9 @@
|
||||
<div v-for="(source, i) in context.sources" :key="i" class="view-section">
|
||||
<p
|
||||
>{{ source.source_stop_type === 'load' ? '装货' : '送货' }}计量:{{
|
||||
source.quantity
|
||||
qtyText(source.quantity)
|
||||
}}
|
||||
{{ source.unit }};车号 {{ source.snapshot.vehicle || '未填写' }}</p
|
||||
{{ unitText(source.unit) }};车号 {{ source.snapshot.vehicle || '未填写' }}</p
|
||||
>
|
||||
<p v-for="stop in source.snapshot.stops" :key="stop.id"
|
||||
>{{ stop.supplier_name || stop.customer_name || '未填写单位' }} ·
|
||||
@@ -159,7 +317,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
<section v-if="groups.length" class="view-section">
|
||||
<section v-if="groups.length && !viewOnly" class="view-section">
|
||||
<h3>3. 不同单位人工换算(同单位无需填写)</h3>
|
||||
<p v-if="forSupplement" class="form-tip"
|
||||
>这里只填写超出原预占部分的来源量及证面量;原预占内的实际量在上一层核对。不得重复计算两部分。</p
|
||||
@@ -174,7 +332,7 @@
|
||||
v-for="source in measured"
|
||||
:key="source.sourceStopProductId"
|
||||
:value="`${source.sourceStopType}:${source.sourceStopProductId}`"
|
||||
:label="`${source.productName} · ${source.partyName || ''} · ${source.quantity} ${source.unit}`"
|
||||
:label="`${source.productName} · ${source.partyName || ''} · ${qtyText(source.quantity)} ${unitText(source.unit)}`"
|
||||
/></el-select>
|
||||
<el-select
|
||||
:model-value="`${row.permitKind}:${row.permitId}`"
|
||||
@@ -185,7 +343,7 @@
|
||||
v-for="item in selected"
|
||||
:key="item.kind + item.cert.id"
|
||||
:value="`${item.kind}:${item.cert.id}`"
|
||||
:label="`${item.cert.certNo}(${item.cert.quantityUnit})`"
|
||||
:label="`${item.cert.certNo}(${unitText(item.cert.quantityUnit)})`"
|
||||
/></el-select>
|
||||
<el-input
|
||||
v-model="row.sourceQuantity"
|
||||
@@ -196,7 +354,7 @@
|
||||
:disabled="busy"
|
||||
placeholder="换算后的证面数量"
|
||||
/>
|
||||
<el-input v-model="row.note" :disabled="busy" placeholder="换算依据(必填)" />
|
||||
<el-input v-model="row.note" :disabled="busy" placeholder="换算依据(选填)" />
|
||||
<el-button :disabled="busy" @click="config.manualAllocations.splice(i, 1)"
|
||||
><el-icon><Delete /></el-icon>移除此项</el-button
|
||||
>
|
||||
@@ -216,7 +374,7 @@
|
||||
><el-icon><Plus /></el-icon>添加人工换算</el-button
|
||||
>
|
||||
</section>
|
||||
<section v-if="!forSupplement" class="view-section"
|
||||
<section v-if="!forSupplement && !viewOnly" class="view-section"
|
||||
><h3>4. 预览分配</h3>
|
||||
<el-button :loading="busy" @click="preview"
|
||||
><el-icon><Search /></el-icon>重新计算</el-button
|
||||
@@ -236,12 +394,13 @@
|
||||
class="view-section"
|
||||
>
|
||||
<strong
|
||||
>{{ row.certType === 'purchase' ? '购买证' : '运输证' }} · 需求 {{ row.demand }}
|
||||
{{ row.unit }}</strong
|
||||
>{{ row.certType === 'purchase' ? '购买证' : '运输证' }} · 需求
|
||||
{{ qtyText(row.demand) }} {{ unitText(row.unit) }}</strong
|
||||
>
|
||||
<p v-if="row.availableUpperBound !== null">
|
||||
适用余额至多 {{ row.availableUpperBound }} {{ row.unit }};缺口至少
|
||||
{{ row.gapLowerBound }} {{ row.unit }}
|
||||
适用余额至多 {{ qtyText(row.availableUpperBound) }}
|
||||
{{ unitText(row.unit) }};缺口至少 {{ qtyText(row.gapLowerBound) }}
|
||||
{{ unitText(row.unit) }}
|
||||
</p>
|
||||
<p>{{ readableReason(row.reason) }}</p>
|
||||
<p>{{
|
||||
@@ -258,19 +417,21 @@
|
||||
min-width="190" /><el-table-column
|
||||
prop="sourceQuantity"
|
||||
label="来源量"
|
||||
min-width="100" /><el-table-column
|
||||
prop="permitQuantity"
|
||||
label="证面量"
|
||||
min-width="100" /><el-table-column
|
||||
prop="permitUnit"
|
||||
label="证面单位"
|
||||
min-width="100" /><el-table-column
|
||||
prop="allocationSeq"
|
||||
label="结转顺序"
|
||||
min-width="100"
|
||||
><template #default="{ row }">{{
|
||||
qtyText(row.sourceQuantity)
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="permitQuantity" label="证面量" min-width="100"
|
||||
><template #default="{ row }">{{
|
||||
qtyText(row.permitQuantity)
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="permitUnit" label="证面单位" min-width="100"
|
||||
><template #default="{ row }">{{
|
||||
unitText(row.permitUnit)
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="allocationSeq" label="结转顺序" min-width="100"
|
||||
/></el-table>
|
||||
</template>
|
||||
<p class="form-tip">预览不占用额度;正式保存前余额变化将重新校验。</p>
|
||||
</section>
|
||||
<section v-if="plan.usages.length" class="view-section"
|
||||
><h3>已有占用与结转</h3
|
||||
@@ -284,40 +445,61 @@
|
||||
usageLabels[row.usageStatus] || row.usageStatus
|
||||
}}</el-tag></template
|
||||
></el-table-column
|
||||
><el-table-column
|
||||
prop="quantityUnit"
|
||||
label="证面单位"
|
||||
min-width="100" /><el-table-column
|
||||
prop="reservedQty"
|
||||
label="预占量"
|
||||
min-width="120" /><el-table-column
|
||||
prop="usedQty"
|
||||
label="使用量"
|
||||
min-width="120" /></el-table
|
||||
></section>
|
||||
><el-table-column prop="quantityUnit" label="证面单位" min-width="100"
|
||||
><template #default="{ row }">{{
|
||||
unitText(row.quantityUnit)
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="reservedQty" label="预占量" min-width="120"
|
||||
><template #default="{ row }">{{
|
||||
qtyText(row.reservedQty)
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="usedQty" label="使用量" min-width="120"
|
||||
><template #default="{ row }">{{ qtyText(row.usedQty) }}</template></el-table-column
|
||||
></el-table
|
||||
></section
|
||||
>
|
||||
</template>
|
||||
</div>
|
||||
<template #footer
|
||||
><el-button :disabled="busy" @click="cancel"
|
||||
><el-icon><Close /></el-icon>取消</el-button
|
||||
><el-icon><Close /></el-icon
|
||||
>{{ viewOnly && !conversions.length ? '关闭' : '取消' }}</el-button
|
||||
><el-button
|
||||
v-if="!viewOnly || (conversions.length && plan?.canSaveConfiguration !== false)"
|
||||
type="primary"
|
||||
:disabled="
|
||||
loading || !plan || (!forArrange && !forSupplement && plan.canSaveConfiguration === false)
|
||||
"
|
||||
:loading="busy"
|
||||
@click="accept"
|
||||
@click="viewOnly ? saveConversion() : accept()"
|
||||
><el-icon><Check /></el-icon
|
||||
>{{
|
||||
forSupplement ? '确认补充分配候选' : forArrange ? '确认本次用证配置' : '保存配置'
|
||||
forSupplement ? '确认补充分配候选' : forArrange ? '确认本次用证配置' : '保存换算'
|
||||
}}</el-button
|
||||
></template
|
||||
>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { perStop, measuredSources, configurationPayload, sourceLabel } from './stop-model'
|
||||
import {
|
||||
perStop,
|
||||
measuredSources,
|
||||
configurationPayload,
|
||||
sourceLabel,
|
||||
unitConversions,
|
||||
coefficientFromQuantities,
|
||||
permitQuantityFromCoefficient
|
||||
} from './stop-model'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
import ViewKvTable from '@/components/business/system-view-dialog/ViewKvTable.vue'
|
||||
import type { ViewField } from '@/components/business/system-view-dialog/types'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import {
|
||||
certFormGroups,
|
||||
formatCertQty
|
||||
} from '@/views/pl/quota-cert/model'
|
||||
import { Check, Close, Delete, Plus, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
planQuotaApi,
|
||||
@@ -351,7 +533,8 @@
|
||||
context = ref<QuotaContext>(),
|
||||
result = ref<QuotaPreview>()
|
||||
const sides = reactive<Record<string, string>>({}),
|
||||
pairs = reactive<Record<string, string[]>>({})
|
||||
pairs = reactive<Record<string, string[]>>({}),
|
||||
coefficients = reactive<Record<string, string>>({})
|
||||
let previewVehicle: QuotaPreviewVehicle = {}
|
||||
let revision = 0
|
||||
let epoch = 0,
|
||||
@@ -374,7 +557,26 @@
|
||||
return [...values.values()]
|
||||
})
|
||||
const isPerStop = computed(() => perStop(plan.value))
|
||||
const viewOnly = computed(() => !forArrange.value && !forSupplement.value)
|
||||
const measured = computed(() => measuredSources(plan.value, sides))
|
||||
const conversions = computed(() =>
|
||||
viewOnly.value ? unitConversions(plan.value, measured.value) : []
|
||||
)
|
||||
const conversionGroups = computed(() => {
|
||||
const grouped = new Map<
|
||||
string,
|
||||
{ sourceId: string; source: QuotaSourceOption; rows: typeof conversions.value }
|
||||
>()
|
||||
for (const row of conversions.value) {
|
||||
const current = grouped.get(row.sourceId)
|
||||
if (current) current.rows.push(row)
|
||||
else grouped.set(row.sourceId, { sourceId: row.sourceId, source: row.source, rows: [row] })
|
||||
}
|
||||
for (const group of grouped.values()) {
|
||||
group.rows.sort((a, b) => Number(a.cert.certType !== 'purchase') - Number(b.cert.certType !== 'purchase'))
|
||||
}
|
||||
return [...grouped.values()]
|
||||
})
|
||||
const selected = computed(() => [
|
||||
...purchases.value
|
||||
.filter((c) => config.value.purchaseCertIds.includes(c.id))
|
||||
@@ -383,6 +585,110 @@
|
||||
.filter((c) => config.value.transportCertIds.includes(c.id))
|
||||
.map((cert) => ({ kind: 'transport' as const, cert }))
|
||||
])
|
||||
const faceTab = ref('')
|
||||
const certStatusLabels: Record<string, string> = {
|
||||
draft: '待核对',
|
||||
active: '已启用',
|
||||
suspended: '已停用',
|
||||
closed: '已核销',
|
||||
void: '已作废'
|
||||
}
|
||||
const refLabels: Record<string, string> = {
|
||||
purchase_permit: '购买许可证',
|
||||
purchase_filing: '购买备案证明',
|
||||
export_permit: '出口许可证',
|
||||
unknown: '待确认'
|
||||
}
|
||||
const longFaceKeys = new Set([
|
||||
'buyerAddress',
|
||||
'sellerAddress',
|
||||
'shipperAddress',
|
||||
'carrierAddressPhone',
|
||||
'routeText',
|
||||
'purchasePurpose',
|
||||
'packagingText',
|
||||
'remark'
|
||||
])
|
||||
const faceTabs = computed(() => {
|
||||
const seen = new Set<string>()
|
||||
const tabs: {
|
||||
key: string
|
||||
label: string
|
||||
kind: CertType
|
||||
certNo: string
|
||||
cert: QuotaCert | null
|
||||
}[] = []
|
||||
const push = (kind: string, id: string, certNo: string) => {
|
||||
if (kind !== 'purchase' && kind !== 'transport') return
|
||||
const key = `${kind}:${id || certNo}`
|
||||
if ((!id && !certNo) || seen.has(key)) return
|
||||
seen.add(key)
|
||||
const pool = kind === 'purchase' ? purchases.value : transports.value
|
||||
const cert = pool.find((item) => item.id === id) || null
|
||||
const number = cert?.certNo || certNo || '证号未提供'
|
||||
tabs.push({
|
||||
key,
|
||||
kind,
|
||||
cert,
|
||||
certNo: number,
|
||||
label: `${kind === 'purchase' ? '购买证' : '运输证'} ${number}`
|
||||
})
|
||||
}
|
||||
for (const row of plan.value?.stopProducts || []) {
|
||||
for (const cert of row.certificates || []) push(cert.certType, cert.certId, cert.certNo)
|
||||
}
|
||||
for (const usage of plan.value?.usages || []) {
|
||||
push(String(usage.certType || ''), String(usage.certId || ''), String(usage.certNoSnapshot || ''))
|
||||
}
|
||||
tabs.sort(
|
||||
(a, b) =>
|
||||
Number(a.kind !== 'purchase') - Number(b.kind !== 'purchase') ||
|
||||
a.certNo.localeCompare(b.certNo)
|
||||
)
|
||||
return tabs
|
||||
})
|
||||
watch(faceTabs, (tabs) => {
|
||||
if (!tabs.some((tab) => tab.key === faceTab.value)) faceTab.value = tabs[0]?.key || ''
|
||||
})
|
||||
function showCertFace(cert: { certType: string; certId: string; certNo: string }) {
|
||||
faceTab.value = `${cert.certType}:${cert.certId || cert.certNo}`
|
||||
}
|
||||
function faceValue(cert: QuotaCert, key: string) {
|
||||
if (key === 'status') return certStatusLabels[cert.status] || cert.status || '—'
|
||||
if (key === 'totalQty') {
|
||||
const qty = qtyText(cert.totalQty)
|
||||
const unit = unitText(cert.quantityUnit)
|
||||
return unit && qty !== '—' ? `${qty} ${unit}` : qty
|
||||
}
|
||||
if (key === 'quantityUnit') return unitText(cert.quantityUnit) || '—'
|
||||
if (key === 'remark') return String(cert.remark || '').trim() || '—'
|
||||
const raw = cert[key as keyof QuotaCert]
|
||||
if (raw == null || raw === '') return '—'
|
||||
return typeof raw === 'string' || typeof raw === 'number' ? String(raw) : '—'
|
||||
}
|
||||
function faceGroups(cert: QuotaCert, kind: CertType) {
|
||||
const groups = certFormGroups(kind).map((group, index) => {
|
||||
const fields: ViewField[] = group.fields.map((field) => ({
|
||||
label: field[1],
|
||||
value:
|
||||
field[0] === 'vehicleNumbersJson'
|
||||
? cert.vehicleNumbersJson?.filter(Boolean).join('、') || '—'
|
||||
: faceValue(cert, field[0]),
|
||||
span:
|
||||
longFaceKeys.has(field[0]) || field[0] === 'vehicleNumbersJson'
|
||||
? ('full' as const)
|
||||
: undefined
|
||||
}))
|
||||
if (index === 0) fields.unshift({ label: '状态', value: faceValue(cert, 'status') })
|
||||
return { title: group.title, fields }
|
||||
})
|
||||
groups[groups.length - 1].fields.push({
|
||||
label: '系统备注',
|
||||
value: faceValue(cert, 'remark'),
|
||||
span: 'full'
|
||||
})
|
||||
return groups
|
||||
}
|
||||
const usageLabels: Record<string, string> = {
|
||||
reserved: '已预占',
|
||||
in_transit: '执行中',
|
||||
@@ -413,8 +719,111 @@
|
||||
}))
|
||||
)
|
||||
)
|
||||
function qtyText(value: unknown) {
|
||||
return formatCertQty(value)
|
||||
}
|
||||
function inputQty(value: unknown) {
|
||||
const text = qtyText(value)
|
||||
return text === '—' ? '' : text
|
||||
}
|
||||
function unitText(unit?: string | null) {
|
||||
const label = getProductUnitLabel(useDictStore().getLabel, unit)
|
||||
return !label || label === '—' ? '' : label
|
||||
}
|
||||
function boundCerts(row: QuotaSourceOption) {
|
||||
return (
|
||||
plan.value?.stopProducts?.find(
|
||||
(item) =>
|
||||
item.sourceStopType === row.sourceStopType &&
|
||||
item.sourceStopProductId === row.sourceStopProductId
|
||||
)?.certificates || []
|
||||
)
|
||||
}
|
||||
function certsOf(row: QuotaSourceOption, kind: CertType) {
|
||||
return boundCerts(row).filter((cert) => cert.certType === kind)
|
||||
}
|
||||
function certText(row: QuotaSourceOption, kind: CertType) {
|
||||
const list = boundCerts(row).filter((cert) => cert.certType === kind)
|
||||
return list.length
|
||||
? list
|
||||
.map((cert) => cert.certNo)
|
||||
.join('、')
|
||||
: '未绑定'
|
||||
}
|
||||
function conversionKey(row: { sourceId: string; cert: { certType: string; certId: string } }) {
|
||||
return `${row.sourceId}:${row.cert.certType}:${row.cert.certId}`
|
||||
}
|
||||
function resetCoefficients() {
|
||||
for (const key of Object.keys(coefficients)) delete coefficients[key]
|
||||
}
|
||||
function syncViewConversions() {
|
||||
const previous = config.value.manualAllocations
|
||||
config.value.manualAllocations = conversions.value.map((row) => {
|
||||
const old = previous.find(
|
||||
(item) =>
|
||||
item.sourceId === row.sourceId &&
|
||||
item.permitKind === row.cert.certType &&
|
||||
item.permitId === row.cert.certId
|
||||
)
|
||||
return (
|
||||
old || {
|
||||
permitKind: row.cert.certType,
|
||||
sourceId: row.sourceId,
|
||||
permitId: row.cert.certId,
|
||||
sourceQuantity: inputQty(row.source.quantity),
|
||||
permitQuantity: '',
|
||||
note: ''
|
||||
}
|
||||
)
|
||||
})
|
||||
const keys = new Set(conversions.value.map((row) => conversionKey(row)))
|
||||
for (const key of Object.keys(coefficients)) if (!keys.has(key)) delete coefficients[key]
|
||||
for (const row of conversions.value) {
|
||||
const key = conversionKey(row)
|
||||
if (coefficients[key]) continue
|
||||
const saved = config.value.manualAllocations.find(
|
||||
(item) =>
|
||||
item.sourceId === row.sourceId &&
|
||||
item.permitKind === row.cert.certType &&
|
||||
item.permitId === row.cert.certId
|
||||
)
|
||||
coefficients[key] = coefficientFromQuantities(saved?.sourceQuantity, saved?.permitQuantity)
|
||||
}
|
||||
}
|
||||
function conversionPreview(row: (typeof conversions.value)[number]) {
|
||||
const permit = permitQuantityFromCoefficient(
|
||||
row.source.quantity,
|
||||
coefficients[conversionKey(row)]
|
||||
)
|
||||
return permit ? `${qtyText(permit)} ${unitText(row.cert.quantityUnit)}` : ''
|
||||
}
|
||||
function conversionInput(row: (typeof conversions.value)[number]) {
|
||||
return config.value.manualAllocations.find(
|
||||
(item) =>
|
||||
item.sourceId === row.sourceId &&
|
||||
item.permitKind === row.cert.certType &&
|
||||
item.permitId === row.cert.certId
|
||||
)!
|
||||
}
|
||||
async function saveConversion() {
|
||||
if (!viewOnly.value || !conversions.value.length || !plan.value || busy.value) return
|
||||
for (const row of conversions.value) {
|
||||
const input = conversionInput(row)
|
||||
const permit = permitQuantityFromCoefficient(
|
||||
row.source.quantity,
|
||||
coefficients[conversionKey(row)]
|
||||
)
|
||||
if (!permit || !input) {
|
||||
ElMessage.warning('请填写大于 0 的换算系数')
|
||||
return
|
||||
}
|
||||
input.sourceQuantity = inputQty(row.source.quantity)
|
||||
input.permitQuantity = permit
|
||||
}
|
||||
await accept()
|
||||
}
|
||||
function certLabel(c: QuotaCert) {
|
||||
return `${c.certNo} · 可用 ${c.availableQty} ${c.quantityUnit}`
|
||||
return `${c.certNo} · 可用 ${qtyText(c.availableQty)} ${unitText(c.quantityUnit)}`
|
||||
}
|
||||
function opposite(group: (typeof groups.value)[number]) {
|
||||
return group[sides[group.id] === 'load' ? 'delivery' : 'load']
|
||||
@@ -539,7 +948,7 @@
|
||||
try {
|
||||
await planQuotaApi.save(id, value)
|
||||
if (!isCurrent()) return
|
||||
ElMessage.success('用证配置已保存')
|
||||
ElMessage.success('换算已保存')
|
||||
resolve?.(value)
|
||||
resolve = undefined
|
||||
visible.value = false
|
||||
@@ -573,6 +982,7 @@
|
||||
previewVehicle = vehicle
|
||||
Object.keys(sides).forEach((k) => delete sides[k])
|
||||
Object.keys(pairs).forEach((k) => delete pairs[k])
|
||||
resetCoefficients()
|
||||
try {
|
||||
const [p, b, t] = await Promise.all([
|
||||
planQuotaApi.get(id),
|
||||
@@ -606,6 +1016,7 @@
|
||||
}
|
||||
for (const row of config.value.sourceMapping || [])
|
||||
pairs[row.sourceStopProductId] = [...row.relatedStopProductIds]
|
||||
if (!arrange && !supplement) syncViewConversions()
|
||||
return await new Promise((r) => {
|
||||
resolve = r
|
||||
loading.value = false
|
||||
@@ -629,6 +1040,7 @@
|
||||
context.value = undefined
|
||||
result.value = undefined
|
||||
config.value = empty()
|
||||
resetCoefficients()
|
||||
loading.value = false
|
||||
busy.value = false
|
||||
resolve?.(undefined)
|
||||
@@ -650,6 +1062,67 @@
|
||||
.quota-dialog :deep(.el-select) {
|
||||
width: 100%;
|
||||
}
|
||||
.quota-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
color: var(--mint-text-secondary, #475569);
|
||||
}
|
||||
.quota-meta strong {
|
||||
color: var(--mint-text, #0f172a);
|
||||
font-size: 15px;
|
||||
}
|
||||
.quota-note {
|
||||
margin: 0 0 14px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.dialog-section-title {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.quota-table-wrap {
|
||||
overflow-x: auto;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.quota-table {
|
||||
width: 100%;
|
||||
min-width: 1080px;
|
||||
}
|
||||
.cert-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
.cert-face-tag {
|
||||
cursor: pointer;
|
||||
}
|
||||
.quota-face {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.quota-face-tabs :deep(.el-tabs__header) {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.quota-face-tabs :deep(.el-tabs__item) {
|
||||
font-size: 14px;
|
||||
}
|
||||
.quota-face-tabs :deep(.el-tabs__item.is-active) {
|
||||
color: #10b981;
|
||||
}
|
||||
.quota-face-tabs :deep(.el-tabs__active-bar) {
|
||||
background-color: #10b981;
|
||||
}
|
||||
.quota-face-group {
|
||||
margin-top: 14px;
|
||||
}
|
||||
.quota-face-group h4 {
|
||||
margin: 0 0 8px;
|
||||
color: var(--mint-text, #0f172a);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.view-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
@@ -664,4 +1137,76 @@
|
||||
.view-section .el-input {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.conversion-section {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.conversion-group {
|
||||
margin-top: 12px;
|
||||
padding: 14px 16px 16px;
|
||||
border: 1px solid var(--mint-border, #e5e7eb);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
.conversion-group-head h4 {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.conversion-group-head p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--mint-text-secondary, #475569);
|
||||
font-size: 13px;
|
||||
}
|
||||
.conversion-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.conversion-card {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--mint-border, #e5e7eb);
|
||||
border-radius: 8px;
|
||||
background: var(--mint-bg-page, #f7faf8);
|
||||
}
|
||||
.conversion-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.conversion-card-head strong {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 14px;
|
||||
}
|
||||
.conversion-card label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
color: var(--mint-text-secondary, #475569);
|
||||
font-size: 13px;
|
||||
}
|
||||
.conversion-factor {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.conversion-factor .el-input {
|
||||
width: 120px;
|
||||
}
|
||||
.conversion-preview {
|
||||
min-height: 20px;
|
||||
margin: 8px 0 12px;
|
||||
color: var(--mint-primary-dark, #059669);
|
||||
font-size: 13px;
|
||||
}
|
||||
.conversion-preview.is-empty {
|
||||
color: var(--mint-text-muted, #94a3b8);
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.conversion-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { PlanQuota, QuotaConfiguration, QuotaSourceOption } from '@/api/pl/quota-cert'
|
||||
import { normalizeProductUnitValue } from '@/utils/crm-product-display'
|
||||
import { formatCertQty } from '@/views/pl/quota-cert/model'
|
||||
|
||||
export const perStop = (plan?: PlanQuota) =>
|
||||
(plan?.measurementVersion || plan?.configuration.measurementVersion) === 'per_stop_v2'
|
||||
@@ -27,6 +29,93 @@ export function configurationPayload(
|
||||
}
|
||||
}
|
||||
|
||||
export function sameCertUnit(left?: string | null, right?: string | null) {
|
||||
const planUnit = String(left || '').trim()
|
||||
const certUnit = String(right || '').trim()
|
||||
if (!planUnit || !certUnit) return false
|
||||
return normalizeProductUnitValue(planUnit) === normalizeProductUnitValue(certUnit)
|
||||
}
|
||||
|
||||
export function coefficientFromQuantities(source: unknown, permit: unknown) {
|
||||
const sourceQty = Number(source)
|
||||
const permitQty = Number(permit)
|
||||
if (!sourceQty || !Number.isFinite(sourceQty) || !Number.isFinite(permitQty) || permitQty <= 0)
|
||||
return ''
|
||||
const value = permitQty / sourceQty
|
||||
return Number.isFinite(value) && value > 0 ? String(Number(value.toPrecision(12))) : ''
|
||||
}
|
||||
|
||||
export function permitQuantityFromCoefficient(quantity: unknown, coefficient: unknown) {
|
||||
const qty = Number(quantity)
|
||||
const factor = Number(String(coefficient ?? '').trim())
|
||||
if (!Number.isFinite(qty) || !(factor > 0)) return ''
|
||||
const value = qty * factor
|
||||
return Number.isFinite(value) ? String(Number(value.toPrecision(12))) : ''
|
||||
}
|
||||
|
||||
export function unitConversions(plan: PlanQuota | undefined, sources: QuotaSourceOption[]) {
|
||||
return sources.flatMap((source) => {
|
||||
const certs =
|
||||
plan?.stopProducts?.find(
|
||||
(row) =>
|
||||
row.sourceStopType === source.sourceStopType &&
|
||||
row.sourceStopProductId === source.sourceStopProductId
|
||||
)?.certificates || []
|
||||
return certs
|
||||
.filter((cert) => cert.quantityUnit && source.unit && !sameCertUnit(source.unit, cert.quantityUnit))
|
||||
.map((cert) => ({
|
||||
sourceId: `${source.sourceStopType}:${source.sourceStopProductId}`,
|
||||
source,
|
||||
cert
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
export interface LegacyProductGroup {
|
||||
id: string
|
||||
name: string
|
||||
load: QuotaSourceOption[]
|
||||
delivery: QuotaSourceOption[]
|
||||
}
|
||||
|
||||
export function legacyGroups(plan?: PlanQuota): LegacyProductGroup[] {
|
||||
const values = new Map<string, LegacyProductGroup>()
|
||||
for (const row of plan?.sourceOptions || []) {
|
||||
const current = values.get(row.planProductId) || {
|
||||
id: row.planProductId,
|
||||
name: row.productName,
|
||||
load: [],
|
||||
delivery: []
|
||||
}
|
||||
current[row.sourceStopType].push(row)
|
||||
values.set(row.planProductId, current)
|
||||
}
|
||||
return [...values.values()]
|
||||
}
|
||||
|
||||
/** 原口径打开时恢复已保存的计量侧和另一侧配对;两侧都有且未保存时留空,等用户选择。 */
|
||||
export function initialLegacySelection(plan?: PlanQuota) {
|
||||
const sides: Record<string, string> = {}
|
||||
const pairs: Record<string, string[]> = {}
|
||||
for (const row of plan?.sourceOptions || []) pairs[row.sourceStopProductId] = []
|
||||
for (const row of plan?.configuration?.sourceMapping || []) {
|
||||
pairs[row.sourceStopProductId] = [...(row.relatedStopProductIds || [])]
|
||||
}
|
||||
for (const group of legacyGroups(plan)) {
|
||||
const old = plan?.configuration?.sourceMapping?.find((item) =>
|
||||
group[item.sourceStopType].some((row) => row.sourceStopProductId === item.sourceStopProductId)
|
||||
)
|
||||
sides[group.id] =
|
||||
old?.sourceStopType ||
|
||||
(group.load.length && !group.delivery.length
|
||||
? 'load'
|
||||
: group.delivery.length && !group.load.length
|
||||
? 'delivery'
|
||||
: '')
|
||||
}
|
||||
return { sides, pairs }
|
||||
}
|
||||
|
||||
export function sourceLabel(id: string, sources: QuotaSourceOption[]) {
|
||||
const source = sources.find((s) => `${s.sourceStopType}:${s.sourceStopProductId}` === id)
|
||||
return source
|
||||
@@ -34,7 +123,10 @@ export function sourceLabel(id: string, sources: QuotaSourceOption[]) {
|
||||
: '来源已不可用'
|
||||
}
|
||||
|
||||
export function stopUsageRows(plan: PlanQuota) {
|
||||
export function stopUsageRows(
|
||||
plan: PlanQuota,
|
||||
labelUnit: (unit?: string | null) => string = (unit) => unit || '—'
|
||||
) {
|
||||
return (plan.stopProducts || plan.sourceOptions.map((s) => ({ ...s, isToxic: true }))).map(
|
||||
(source) => {
|
||||
const text = (kind: string) => {
|
||||
@@ -58,8 +150,8 @@ export function stopUsageRows(plan: PlanQuota) {
|
||||
i.sourceStopProductId === source.sourceStopProductId
|
||||
)
|
||||
.map((i: any) => {
|
||||
const unit = i.quantityUnit || u.quantityUnit || '—'
|
||||
return `${u.certNoSnapshot || '证号未提供'} · 预占 ${i.reservedQty ?? '—'} ${unit} · 已用 ${i.usedQty ?? '—'} ${unit}`
|
||||
const unit = labelUnit(i.quantityUnit || u.quantityUnit)
|
||||
return `${u.certNoSnapshot || '证号未提供'} · 预占 ${formatCertQty(i.reservedQty)} ${unit} · 已用 ${formatCertQty(i.usedQty)} ${unit}`
|
||||
})
|
||||
)
|
||||
const bound = (source.certificates || []).filter(
|
||||
@@ -78,7 +170,8 @@ export function stopUsageRows(plan: PlanQuota) {
|
||||
)
|
||||
lines.push(
|
||||
...bound.map(
|
||||
(c) => `${c.certNo} · 已绑定 · 预占 0 ${c.quantityUnit} · 已用 0 ${c.quantityUnit}`
|
||||
(c) =>
|
||||
`${c.certNo} · 已绑定 · 预占 ${formatCertQty(0)} ${labelUnit(c.quantityUnit)} · 已用 ${formatCertQty(0)} ${labelUnit(c.quantityUnit)}`
|
||||
)
|
||||
)
|
||||
if (source.bindingsReadable === false) lines.push('合同或证件不可读取')
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
>
|
||||
<span class="pl-stop-feedback-ticket__text">{{ product.productName || '产品' }}</span>
|
||||
<span class="pl-stop-feedback-ticket__text pl-stop-feedback-ticket__text--qty">
|
||||
{{ formatDriverProductQty(product) }}
|
||||
{{ formatDriverQty(product) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,9 +79,9 @@
|
||||
<span class="pl-stop-feedback-ticket__text">{{ product.productName || '产品' }}</span>
|
||||
<span class="pl-stop-feedback-ticket__text pl-stop-feedback-ticket__text--qty">
|
||||
<span class="pl-stop-feedback-ticket__val pl-stop-feedback-ticket__val--highlight">{{
|
||||
formatSiteProductQty(product).qty
|
||||
formatSiteQty(product).qty
|
||||
}}</span>
|
||||
<span class="pl-stop-feedback-ticket__unit">{{ formatSiteProductQty(product).unit }}</span>
|
||||
<span class="pl-stop-feedback-ticket__unit">{{ formatSiteQty(product).unit }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -225,8 +225,10 @@
|
||||
import { formatKgToTon } from '@/components/business/db/db-related-view'
|
||||
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
|
||||
import type { PlPlanTransportDibangRow } from '@/composables/usePlPlanViewDetail'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||||
import { formatDriverProductQty, formatSiteProductQty } from './qty-display'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -268,9 +270,14 @@
|
||||
'update:siteAttachmentUrls': [value: string]
|
||||
}>()
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const driverAttachRef = ref<InstanceType<typeof AttachmentUploadField> | null>(null)
|
||||
const siteAttachRef = ref<InstanceType<typeof AttachmentUploadField> | null>(null)
|
||||
|
||||
function resolveUnitLabel(dictType: string, value: string) {
|
||||
return dictStore.getLabel(dictType, value)
|
||||
}
|
||||
|
||||
const isInternalCustomer = computed(() => isPlInternalCustomerName(props.customerName))
|
||||
|
||||
const showSiteCard = computed(() => isInternalCustomer.value)
|
||||
@@ -382,18 +389,12 @@
|
||||
return text || '—'
|
||||
}
|
||||
|
||||
function formatDriverProductQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
const qty = product.actualQty
|
||||
const unit = product.unit || '吨'
|
||||
if (qty == null) return '—'
|
||||
return `${qty} ${unit}`
|
||||
function formatDriverQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
return formatDriverProductQty(product, resolveUnitLabel)
|
||||
}
|
||||
|
||||
function formatSiteProductQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
const qty = product.actualQty ?? product.quantity
|
||||
const unit = product.unit || '吨'
|
||||
if (qty == null) return { qty: '—', unit: '' }
|
||||
return { qty: String(qty), unit: ` ${unit}` }
|
||||
function formatSiteQty(product: NonNullable<TransportStopFeedback['products']>[number]) {
|
||||
return formatSiteProductQty(product, resolveUnitLabel)
|
||||
}
|
||||
|
||||
function resolvePlanProductRow(row: PlPlanTransportDibangRow) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
|
||||
type UnitLabelResolver = (dictType: string, value: string) => string
|
||||
|
||||
export function feedbackUnitLabel(
|
||||
unit: string | null | undefined,
|
||||
getLabel: UnitLabelResolver
|
||||
): string {
|
||||
const raw = String(unit || '').trim()
|
||||
if (!raw) return '吨'
|
||||
const label = getProductUnitLabel(getLabel, raw).trim()
|
||||
return !label || label === '—' ? raw : label
|
||||
}
|
||||
|
||||
export function formatDriverProductQty(
|
||||
product: { actualQty?: number | null; unit?: string | null },
|
||||
getLabel: UnitLabelResolver
|
||||
): string {
|
||||
const qty = product.actualQty
|
||||
if (qty == null) return '—'
|
||||
return `${qty} ${feedbackUnitLabel(product.unit, getLabel)}`
|
||||
}
|
||||
|
||||
export function formatSiteProductQty(
|
||||
product: {
|
||||
actualQty?: number | null
|
||||
quantity?: number | null
|
||||
unit?: string | null
|
||||
},
|
||||
getLabel: UnitLabelResolver
|
||||
): { qty: string; unit: string } {
|
||||
const qty = product.actualQty ?? product.quantity
|
||||
if (qty == null) return { qty: '—', unit: '' }
|
||||
return { qty: String(qty), unit: ` ${feedbackUnitLabel(product.unit, getLabel)}` }
|
||||
}
|
||||
@@ -74,15 +74,16 @@
|
||||
>单位<span class="pl-stop-field-required" aria-hidden="true">*</span></span
|
||||
>
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-if="sharedEditable && !unitLocked(row)"
|
||||
v-model="row.unit"
|
||||
class="pl-plan-product-cell-control pl-stop-product-dual-dict"
|
||||
dict-type="crm_product_unit"
|
||||
placeholder="单位"
|
||||
/>
|
||||
<template v-else>
|
||||
<span class="pl-stop-product-dual-item__readonly">{{
|
||||
resolveDictLabel('crm_product_unit', row.unit)
|
||||
<span class="pl-stop-product-dual-item__readonly">{{ unitLabel(row) }}</span>
|
||||
<span v-if="row.contractUnitNote" class="pl-stop-unit-note">{{
|
||||
row.contractUnitNote
|
||||
}}</span>
|
||||
</template>
|
||||
</div>
|
||||
@@ -370,7 +371,7 @@
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<DictSelect
|
||||
v-if="sharedEditable"
|
||||
v-if="sharedEditable && !unitLocked(row)"
|
||||
v-model="row.unit"
|
||||
class="pl-plan-product-cell-control"
|
||||
dict-type="crm_product_unit"
|
||||
@@ -380,6 +381,9 @@
|
||||
<template v-else>
|
||||
<DictTag v-if="row.unit" dict-type="crm_product_unit" :value="row.unit" />
|
||||
<span v-else>—</span>
|
||||
<span v-if="row.contractUnitNote" class="pl-stop-unit-note">{{
|
||||
row.contractUnitNote
|
||||
}}</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -592,12 +596,15 @@
|
||||
resolveStopUnitPrice
|
||||
} from '@/utils/pl-plan-stop-form'
|
||||
import {
|
||||
alignStopProductUnitToContract,
|
||||
allowedPackageSpecsForStopProduct,
|
||||
collectStopContractIds,
|
||||
contractLineChoicesForProduct,
|
||||
normalizePackageSpec,
|
||||
stopProductUnitLocked,
|
||||
type ContractProductRowLite
|
||||
} from '@/utils/pl-plan-contract-product'
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
import { getDeliveryMethodLabel } from '@/composables/usePlContractToPlan'
|
||||
import {
|
||||
applyBrandSelectChange,
|
||||
@@ -745,8 +752,41 @@
|
||||
row.contractId = choice.contractId
|
||||
row.contractProductId = choice.id
|
||||
row.contractNo = choice.contractNo
|
||||
if (choice.unit) {
|
||||
row.unit = choice.unit
|
||||
row.contractUnitNote = ''
|
||||
}
|
||||
}
|
||||
|
||||
function unitLocked(row: PlanStopProductFormRow) {
|
||||
return stopProductUnitLocked(row)
|
||||
}
|
||||
|
||||
function unitLabel(row: PlanStopProductFormRow) {
|
||||
return getProductUnitLabel((dictType, value) => dictStore.getLabel(dictType, value), row.unit)
|
||||
}
|
||||
|
||||
function unitFieldLabel(row: PlanStopProductFormRow) {
|
||||
const label = unitLabel(row)
|
||||
const note = String(row.contractUnitNote || '').trim()
|
||||
return note ? `${label}。${note}` : label
|
||||
}
|
||||
|
||||
watch(
|
||||
() =>
|
||||
(props.products || [])
|
||||
.map((row) => `${row.contractProductId || ''}:${row.unit || ''}`)
|
||||
.join('|') +
|
||||
'#' +
|
||||
(props.contractProductRows || []).map((row) => `${row.id || ''}:${row.unit || ''}`).join('|'),
|
||||
() => {
|
||||
for (const row of props.products || []) {
|
||||
if (!alignStopProductUnitToContract(row, props.contractProductRows)) continue
|
||||
row.contractUnitNote = `合同单位是${unitLabel(row)},请按该单位核对计划数量`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const untaggedContractHint = computed(() => {
|
||||
const names = (props.products || []).filter(rowNeedsContractLine).map((row) => {
|
||||
const name = String(row.standardProductName || row.productName || row.productNo || '未命名产品').trim()
|
||||
@@ -991,7 +1031,7 @@
|
||||
arrangeQtyCache.value = next
|
||||
return ensureArrangeQty(row)
|
||||
}
|
||||
const mobileController = reactive({ retryMobileArrangeQty, onPackageChange, props, sharedEditable, aliasBrandManageable, canRemove, showAvailableQty, packageOptionsFor, useContractPackageSelect, resolvePackageDisplay, resolveProductContractNo, rowNeedsContractLine, contractLineChoices, bindContractLine, untaggedContractHint, resolveDictLabel, dictStore, handleAliasChange, handleBrandChange, handleAliasBrandManaged, openAliasBrandManage, aliasBrandManageVisible, aliasBrandManageProductId, aliasBrandManageProductName, aliasBrandManageMode, formatAvailableDisplay, canOpenArrangeQty, ensureArrangeQty, readArrangeQty, isPlanQtyOverAvailable, handleRemove, formatBrandConstraintLabel, formatStopQty, formatStopPrice, resolveStopActualQty, resolveStopUnitPrice, formatStopArchiveAmount })
|
||||
const mobileController = reactive({ retryMobileArrangeQty, onPackageChange, props, sharedEditable, aliasBrandManageable, canRemove, showAvailableQty, packageOptionsFor, useContractPackageSelect, resolvePackageDisplay, resolveProductContractNo, rowNeedsContractLine, contractLineChoices, bindContractLine, unitLocked, unitFieldLabel, untaggedContractHint, resolveDictLabel, dictStore, handleAliasChange, handleBrandChange, handleAliasBrandManaged, openAliasBrandManage, aliasBrandManageVisible, aliasBrandManageProductId, aliasBrandManageProductName, aliasBrandManageMode, formatAvailableDisplay, canOpenArrangeQty, ensureArrangeQty, readArrangeQty, isPlanQtyOverAvailable, handleRemove, formatBrandConstraintLabel, formatStopQty, formatStopPrice, resolveStopActualQty, resolveStopUnitPrice, formatStopArchiveAmount })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -1092,6 +1132,14 @@
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.pl-stop-unit-note {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.pl-stop-contract-gap {
|
||||
margin: 0 0 8px;
|
||||
padding: 8px 12px;
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
:close-on-click-modal="false"
|
||||
@closed="!visible && cancel()"
|
||||
>
|
||||
<p class="form-tip"
|
||||
>异单位按实际量重新填写,不沿用安排时换算比例。每个来源、每类证件的分配合计必须与本次实际数量一致;0
|
||||
也须明确填写。</p
|
||||
<p v-if="rows.length" class="form-tip"
|
||||
>下面只列出计划单位和证面单位不同的分配。请填写本次实际计划量和证面量,并写明换算依据。填 0
|
||||
也要写上。</p
|
||||
>
|
||||
<p v-if="!rows.length" class="form-tip"
|
||||
>当前原分配均为同单位,系统按本次各来源实际数量和原顺序结转。</p
|
||||
<p v-else class="form-tip"
|
||||
>证面数量按安排时保存的换算系数和本次实际数量自动计算,不用再填换算。</p
|
||||
>
|
||||
<el-checkbox v-model="allowSupplement">实际量超出原预占,需要补充分配</el-checkbox>
|
||||
<el-checkbox v-model="allowSupplement">已用证件剩余额度不够,需要再选其他证件</el-checkbox>
|
||||
<template v-if="allowSupplement">
|
||||
<p class="form-tip"
|
||||
>下方填写原分配部分的实际来源量和本次实际证面量。超出原来源量的部分在补充候选中填写;仅证面量增加时选择对应原证补差。来源量增加需双证覆盖,系统不沿用换算比例。补充校验失败将保存真实数量及异常,保持原账。</p
|
||||
>已经使用的证件还能扣的额度不够时,再选择其他购买证和运输证。原证件能覆盖的部分会先扣完。</p
|
||||
>
|
||||
<el-button :loading="choosing" @click="chooseSupplement"
|
||||
><el-icon><Plus /></el-icon
|
||||
@@ -30,25 +30,27 @@
|
||||
{{ supplementConfiguration.transportCertIds.length }} 张;提交时重新校验余额和条件。</p
|
||||
>
|
||||
</template>
|
||||
<section v-for="row in rows" :key="row.key" class="view-section">
|
||||
<h3>{{ row.certNo }} · {{ row.kind === 'purchase' ? '购买证' : '运输证' }}</h3>
|
||||
<p>{{ row.productName }} · {{ row.sourceLabel }} · 结转顺序 {{ row.seq }}</p>
|
||||
<p
|
||||
>安排分配:{{ row.plannedSource }} {{ row.sourceUnit }} → {{ row.plannedPermit }}
|
||||
{{ row.permitUnit }}</p
|
||||
<section v-for="row in rows" :key="row.key" class="settlement-card">
|
||||
<h3>{{ row.kind === 'purchase' ? '购买证' : '运输证' }} {{ row.certNo }}</h3>
|
||||
<p class="settlement-meta">{{ row.productName }}</p>
|
||||
<p class="settlement-meta">{{ row.sourceLabel }}<template v-if="row.seq"> · 扣证顺序 {{ row.seq }}</template></p>
|
||||
<p class="settlement-meta"
|
||||
>安排时 {{ row.plannedSource }} {{ row.sourceUnitLabel }},证面
|
||||
{{ row.plannedPermit }} {{ row.permitUnitLabel }}</p
|
||||
>
|
||||
<el-form label-position="top"
|
||||
><div class="form-grid-2">
|
||||
<el-form-item :label="`本证分配的实际来源量(${row.sourceUnit})`"
|
||||
><el-input v-model="row.value.sourceQuantity" placeholder="包括真实 0"
|
||||
/></el-form-item>
|
||||
<el-form-item :label="`实际证面量(${row.permitUnit})`"
|
||||
><el-input v-model="row.value.permitQuantity" placeholder="包括真实 0"
|
||||
/></el-form-item>
|
||||
<el-form-item label="本次换算依据" class="form-col-span-2"
|
||||
><el-input v-model="row.value.note" type="textarea"
|
||||
/></el-form-item> </div
|
||||
></el-form>
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item :label="`本次实际计划量(${row.sourceUnitLabel})`">
|
||||
<el-input v-model="row.value.sourceQuantity" placeholder="0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="`本次实际证面量(${row.permitUnitLabel})`">
|
||||
<el-input v-model="row.value.permitQuantity" placeholder="0" />
|
||||
</el-form-item>
|
||||
<el-form-item label="换算依据" class="form-col-span-2">
|
||||
<el-input v-model="row.value.note" type="textarea" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</section>
|
||||
<el-form v-if="adjustment || allowSupplement" label-position="top">
|
||||
<el-form-item label="实际用量更正/补分配理由(必填)"
|
||||
@@ -110,8 +112,8 @@
|
||||
certNo: string
|
||||
productName: string
|
||||
sourceLabel: string
|
||||
sourceUnit: string
|
||||
permitUnit: string
|
||||
sourceUnitLabel: string
|
||||
permitUnitLabel: string
|
||||
plannedSource: string
|
||||
plannedPermit: string
|
||||
seq: number
|
||||
@@ -127,49 +129,22 @@
|
||||
allowSupplement.value = false
|
||||
choosing.value = false
|
||||
supplementConfiguration.value = undefined
|
||||
const plan = await planQuotaApi.get(planId)
|
||||
await planQuotaApi.get(planId)
|
||||
if (current !== epoch) return
|
||||
const values = plan.usages
|
||||
.filter((u) => u.usageStatus !== 'released')
|
||||
.flatMap((u) =>
|
||||
(u.items || []).map((i: any) => ({
|
||||
u,
|
||||
i,
|
||||
source: `${i.sourceStopType}:${i.sourceStopProductId}`,
|
||||
key: `${u.certType}:${i.sourceStopType}:${i.sourceStopProductId}`
|
||||
}))
|
||||
)
|
||||
const foreign = new Set(
|
||||
values.filter((v) => v.i.sourceUnit !== v.u.quantityUnit).map((v) => v.key)
|
||||
)
|
||||
rows.value = values
|
||||
.filter((v) => foreign.has(v.key))
|
||||
.map(({ u, i, source }) => ({
|
||||
key: i.id,
|
||||
kind: u.certType,
|
||||
certNo: u.certNoSnapshot,
|
||||
productName:
|
||||
plan.sourceOptions.find((s) => s.sourceStopProductId === i.sourceStopProductId)
|
||||
?.productName || '',
|
||||
sourceLabel: `${i.sourceStopType === 'load' ? '装货' : '送货'} ${i.sourceStopProductId.slice(-6)}`,
|
||||
sourceUnit: i.sourceUnit,
|
||||
permitUnit: u.quantityUnit,
|
||||
plannedSource: i.allocatedSourceQty,
|
||||
plannedPermit: i.plannedCertQty,
|
||||
seq: i.allocationSeq,
|
||||
value: {
|
||||
permitKind: u.certType,
|
||||
permitId: u.certId,
|
||||
sourceId: source,
|
||||
sourceQuantity: '',
|
||||
permitQuantity: '',
|
||||
note: ''
|
||||
}
|
||||
}))
|
||||
rows.value = []
|
||||
adjustment.value = adjust
|
||||
reason.value = ''
|
||||
sourceNote.value = ''
|
||||
evidenceUrls.value = ''
|
||||
if (!adjust && !rows.value.length) {
|
||||
return {
|
||||
quotaAllowSupplement: false,
|
||||
quotaManualActuals: [],
|
||||
quotaReason: '',
|
||||
quotaSourceNote: '',
|
||||
quotaEvidenceUrls: ''
|
||||
}
|
||||
}
|
||||
visible.value = true
|
||||
return new Promise((r) => (resolve = r))
|
||||
}
|
||||
@@ -240,3 +215,19 @@
|
||||
)
|
||||
onBeforeUnmount(() => cancel())
|
||||
</script>
|
||||
<style scoped>
|
||||
.settlement-card {
|
||||
margin-top: 16px;
|
||||
padding: 12px 16px 4px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.settlement-card h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.settlement-meta {
|
||||
margin: 0 0 4px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user