fix(pl): 补齐客户品类证件额度三期收口项。

完善 H5 建档、归档待完善引导、齐备上传入口与新规则只读提示,并同步计划验收状态与单测。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-14 23:57:36 +08:00
1 parent 208c93d192
commit b0c1bca683
12 files changed
+439 -73

No files matched your search

+2
View File
@@ -64,6 +64,7 @@ export interface QuotaCert extends Omit<CertBody, 'status'> {
createTime?: string
certType?: CertType
derivedCategoryIds?: string[]
customerName?: string | null
}
export interface ScopeProduct {
id?: string
@@ -330,6 +331,7 @@ export interface PlanQuota {
canSaveConfiguration?: boolean
arrangeBlockMessage?: string
quotaCertWaived?: boolean
certQuotaRuleVersion?: 'legacy' | 'customer_category' | string
configuration: Partial<QuotaConfiguration>
sourceOptions: QuotaSourceOption[]
usages: Record<string, any>[]
@@ -1602,8 +1602,13 @@
async function showArchiveQuotaBlockDialog(message: string, title = '不能归档') {
const html = `<p class="pl-arrange-block-text">${escapeArchiveBlockText(message)}</p>`
if (title !== '用证没有完成') {
await ElMessageBox.alert(html, title, {
const pendingFulfill =
message.includes('待完善') || message.includes('完善并关闭') || message.includes('证书齐备待完善')
if (title !== '用证没有完成' || pendingFulfill) {
const guide = pendingFulfill
? `${html}<p class="pl-arrange-block-text">新规则下证书齐备只放行安排,不能绕过归档挂证。请到「证书齐备 → 待完善并关闭」上传证件并执行完善并关闭后再归档。</p>`
: html
await ElMessageBox.alert(guide, title, {
type: 'warning',
confirmButtonText: '知道了',
dangerouslyUseHTMLString: true,
@@ -1612,7 +1617,8 @@
}).catch(() => undefined)
return undefined
}
const readyHtml = `${html}<p class="pl-arrange-block-text">如果购买证、运输证还没上传,可以标记证书齐备。标记后这次归档不再校验,也不扣减这两证的额度。</p>`
// 仅旧规则(legacy)允许在归档时标记证书齐备以跳过额度
const readyHtml = `${html}<p class="pl-arrange-block-text">如果购买证、运输证还没上传,可以标记证书齐备。仅旧规则计划标记后这次归档不再校验、不扣这两证额度;新规则计划请走「待完善并关闭」。</p>`
try {
await ElMessageBox.confirm(readyHtml, title, {
type: 'warning',
@@ -17,7 +17,14 @@
<span>当前车号</span>
<strong>{{ plan.licensePlate || '待安排' }}</strong>
</div>
<p v-if="viewOnly && plan.canSaveConfiguration === false" class="quota-note"
<p
v-if="viewOnly && plan.certQuotaRuleVersion === 'customer_category'"
class="quota-note"
>新规则计划由系统按客户+品类自动选证,本页仅查看占用;安排不提供手工选证。</p
>
<p
v-else-if="viewOnly && plan.canSaveConfiguration === false"
class="quota-note"
>已安排计划请从调整运输提交用证变更;已归档计划仅查看占用。</p
>
<template v-if="viewOnly">
@@ -154,17 +154,54 @@
/>
</section>
<section class="mp-wv-section">
<h3>客户与品类</h3>
<p class="plan-empty-hint">
新规则按系统客户选证;购买证还需绑定证用品类。运输证品类由引用的购买证自动汇总。安排时不再依赖合同产品绑定。
</p>
<van-field
:model-value="systemCustomerLabel"
label="系统客户"
label-align="top"
readonly
:is-link="form.status !== 'void' && form.status !== 'closed'"
placeholder="搜索并选择客户"
required
@click="form.status !== 'void' && form.status !== 'closed' && openSystemCustomer()"
/>
<van-field
v-if="kind === 'purchase'"
:model-value="categoryLabel"
label="证用品类"
label-align="top"
readonly
:is-link="form.status !== 'void' && form.status !== 'closed'"
placeholder="选择证用品类"
required
@click="form.status !== 'void' && form.status !== 'closed' && openCategories()"
/>
<van-field
v-else
:model-value="derivedCategoryLabel"
label="适用品类"
label-align="top"
readonly
placeholder="引用购买证并保存后自动汇总"
/>
</section>
<section class="mp-wv-section mp-plan-cert-list">
<h3>绑定合同产品</h3>
<h3>历史:绑定合同产品(旧规则,可选)</h3>
<p v-if="form.bindingsEditable === false" class="plan-empty-hint">
当前仅展示可见合同,绑定范围不可编辑。证面信息仍可保存。
</p>
<p v-else class="plan-empty-hint">
仅兼容旧合同绑证数据。新规则选证以客户+品类为准,可不填。
<template v-if="kind === 'purchase'"
>识别后按购买单位或个人的名称或姓名自动填入名称完全一致的客户。选择合同后带出全部产品。</template
>识别后仍可按购买单位自动匹配客户并带出合同产品。</template
>
<template v-else>运输证识别后,会把匹配购买证上的合同和产品带到这里。</template>
未保存的产品可以移除,已保存的只能设为不可用。点底部保存后写入。<template
未保存的产品可以移除,已保存的只能设为不可用。<template
v-if="hasLockedBinding"
>已有用证,不能增删产品。产品可以设为不可用。</template
>
@@ -172,7 +209,7 @@
<van-field
v-if="form.bindingsEditable !== false && form.status !== 'void' && form.status !== 'closed'"
:model-value="bindingCustomer.customerName"
label="客户名称"
label="合同客户"
label-align="top"
readonly
is-link
@@ -380,7 +417,11 @@
teleport="body"
class="mp-cert-form-sheet mp-cert-contract-sheet"
>
<van-nav-bar title="选择客户" left-text="关闭" @click-left="customerOpen = false" />
<van-nav-bar
:title="customerPickMode === 'system' ? '选择系统客户' : '选择合同客户'"
left-text="关闭"
@click-left="customerOpen = false"
/>
<van-search
v-model="customerKeyword"
placeholder="客户名称"
@@ -403,6 +444,31 @@
</button>
</div>
</van-popup>
<van-popup
v-model:show="categoryOpen"
position="bottom"
round
teleport="body"
class="mp-cert-form-sheet mp-cert-contract-sheet"
>
<van-nav-bar title="选择证用品类" left-text="关闭" @click-left="categoryOpen = false" />
<div class="mp-cert-contract-sheet__list">
<p v-if="categoryLoading" class="plan-empty-hint">正在加载品类…</p>
<p v-else-if="!categoryOptions.length" class="plan-empty-hint">暂无启用中的证用品类。</p>
<button
v-for="item in categoryOptions"
:key="item.id"
class="mp-cert-contract-card"
type="button"
@click="pickCategory(item)"
>
<span class="mp-cert-contract-card__no">{{ item.categoryName || '—' }}</span>
<span v-if="item.categoryCode" class="mp-cert-contract-card__meta">{{
item.categoryCode
}}</span>
</button>
</div>
</van-popup>
<van-popup
v-model:show="contractOpen"
position="bottom"
@@ -511,7 +577,7 @@
<script setup lang="ts">
import { ElMessage } from 'element-plus'
import { fetchCustomerOptions } from '@/api/crm/customer'
import { fetchCustomerDetail, fetchCustomerOptions } from '@/api/crm/customer'
import { listContract } from '@/api/crm/contract'
import type { ContractVO } from '@/api/crm/contract/types'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
@@ -519,7 +585,9 @@
import MpBusinessHeader from '@/components/mp/MpBusinessHeader.vue'
import PlanDateField from '../plan/PlanDateField.vue'
import {
certCategoryApi,
quotaCertApi,
type CertCategory,
type CertType,
type CertificateContractBinding,
type ContractOption,
@@ -618,8 +686,24 @@
const contractOptions = ref<ContractOption[]>([])
const customerOptions = ref<{ id: string; customerName?: string; customerNo?: string }[]>([])
const bindingCustomer = ref<{ id: string; customerName: string }>({ id: '', customerName: '' })
const systemCustomer = ref<{ id: string; customerName: string }>({ id: '', customerName: '' })
const customerPickMode = ref<'system' | 'binding'>('binding')
const categoryOpen = ref(false)
const categoryLoading = ref(false)
const categoryOptions = ref<CertCategory[]>([])
const customerLoading = ref(false)
const linesLoading = ref(false)
const systemCustomerLabel = computed(() => systemCustomer.value.customerName || '')
const categoryLabel = computed(() => {
const id = String(form.value.categoryId || '')
return categoryOptions.value.find((item) => item.id === id)?.categoryName || ''
})
const derivedCategoryLabel = computed(() => {
const ids = (form.value.derivedCategoryIds || []) as string[]
if (!ids.length) return ''
const names = new Map(categoryOptions.value.map((item) => [item.id, item.categoryName]))
return ids.map((id) => names.get(id) || id).join('、')
})
const purchases = ref<QuotaCert[]>([])
const lines = ref<ContractProduct[]>([])
const productNames = ref(new Map<string, string>())
@@ -662,6 +746,7 @@
lockedPlates.value = []
linkedRefIds.value = []
clearBindingCustomer()
clearSystemCustomer()
pendingContract.value = undefined
picked.value = new Set()
lines.value = []
@@ -887,6 +972,10 @@
function clearBindingCustomer() {
bindingCustomer.value = { id: '', customerName: '' }
}
function clearSystemCustomer() {
systemCustomer.value = { id: '', customerName: '' }
form.value.customerId = null
}
async function searchCustomers(keyword = '') {
const current = epoch
customerLoading.value = true
@@ -900,28 +989,70 @@
if (current === epoch) customerLoading.value = false
}
}
async function loadCategories() {
categoryLoading.value = true
try {
categoryOptions.value = (await certCategoryApi.list({ status: '1' })) || []
} catch {
categoryOptions.value = []
} finally {
categoryLoading.value = false
}
}
function openCustomers() {
if (saving.value || recognizing.value || linesLoading.value) return
customerPickMode.value = 'binding'
customerKeyword.value = ''
customerOpen.value = true
void searchCustomers('')
}
function openSystemCustomer() {
if (saving.value || recognizing.value) return
customerPickMode.value = 'system'
customerKeyword.value = ''
customerOpen.value = true
void searchCustomers('')
}
function openCategories() {
if (saving.value || recognizing.value) return
categoryOpen.value = true
if (!categoryOptions.value.length) void loadCategories()
}
function pickCustomer(item: { id: string; customerName?: string }) {
bindingCustomer.value = { id: item.id, customerName: item.customerName || '' }
if (customerPickMode.value === 'system') {
systemCustomer.value = { id: item.id, customerName: item.customerName || '' }
form.value.customerId = item.id
touch('customerId')
} else {
bindingCustomer.value = { id: item.id, customerName: item.customerName || '' }
}
customerOpen.value = false
}
function pickCategory(item: CertCategory) {
form.value.categoryId = item.id
touch('categoryId')
categoryOpen.value = false
}
async function matchBuyerCustomer(name: string, current: number) {
const buyer = name.trim()
if (!buyer || bindingCustomer.value.id || form.value.bindingsEditable === false) return
if (!buyer) return
try {
const result = await fetchCustomerOptions({ keyword: buyer, limit: 200 })
if (current !== epoch || bindingCustomer.value.id) return
if (current !== epoch) return
const matches = exactCustomerMatches(extractCustomers(result), buyer)
if (matches.length === 1) {
bindingCustomer.value = {
const matched = {
id: String(matches[0].id),
customerName: matches[0].customerName || buyer
}
if (!systemCustomer.value.id) {
systemCustomer.value = matched
form.value.customerId = matched.id
touch('customerId')
}
if (!bindingCustomer.value.id && form.value.bindingsEditable !== false) {
bindingCustomer.value = matched
}
return
}
ElMessage.warning(
@@ -1044,6 +1175,30 @@
pendingContract.value = undefined
productOpen.value = false
}
async function syncSystemCustomerFromForm(cert?: QuotaCert | Record<string, any>) {
const id = String(cert?.customerId || form.value.customerId || '')
if (!id) {
clearSystemCustomer()
return
}
const certRecord = (cert || {}) as Record<string, any>
let name =
String(certRecord.customerName || '').trim() ||
systemCustomer.value.customerName ||
customerOptions.value.find((item) => item.id === id)?.customerName ||
''
if (!name) {
try {
const detail = (await fetchCustomerDetail({ id })) as Record<string, any>
const data = detail?.data || detail
name = String(data?.customerName || '').trim() || id
} catch {
name = id
}
}
systemCustomer.value = { id, customerName: name }
form.value.customerId = id
}
async function load() {
const current = ++epoch
loading.value = true
@@ -1052,6 +1207,7 @@
error.value = ''
originals.clear()
try {
void loadCategories()
if (creating.value) {
const entryMode = form.value.entryMode === 'manual' ? 'manual' : 'image_parse'
form.value = {
@@ -1065,6 +1221,7 @@
recognitionImage.value = ''
contractBriefs.value = new Map()
clearBindingCustomer()
clearSystemCustomer()
if (kind.value === 'transport')
purchases.value = await quotaCertApi.list('purchase').catch(() => [])
return
@@ -1074,7 +1231,9 @@
quotaCertApi.certificateContracts(kind.value, certId.value).catch(() => [])
])
if (current !== epoch) return
contractBriefs.value = new Map(contracts.map((item) => [item.id, item]))
contractBriefs.value = new Map(
contracts.map((item) => [item.id, item] as [string, ContractOption])
)
const names = new Map<string, string>()
await Promise.all(
(cert.contractBindings || []).map(async (binding) => {
@@ -1091,6 +1250,7 @@
...certPayload(kind.value, cert),
status: cert.status,
totalQty: inputQty(cert.totalQty),
derivedCategoryIds: (cert as QuotaCert & { derivedCategoryIds?: string[] }).derivedCategoryIds || [],
contractBindings: (cert.contractBindings || []).map((binding) => ({
...binding,
products: binding.products.map((product) => ({ ...product }))
@@ -1109,6 +1269,7 @@
.map((row) => String(row.id))
: []
clearBindingCustomer()
await syncSystemCustomerFromForm(cert)
if (kind.value === 'transport')
purchases.value = await quotaCertApi.list('purchase').catch(() => [])
} catch {
@@ -1132,6 +1293,14 @@
ElMessage.warning(`请填写${missing}`)
return
}
if (!form.value.customerId) {
ElMessage.warning('请选择系统客户')
return
}
if (kind.value === 'purchase' && !form.value.categoryId) {
ElMessage.warning('请选择证用品类')
return
}
if (attachmentCount(form.value.attachmentUrls) !== 1) {
ElMessage.warning('请保留且仅上传一张证件附件')
return
@@ -1188,6 +1357,7 @@
lockedPlates.value = []
linkedRefIds.value = []
clearBindingCustomer()
clearSystemCustomer()
ElMessage.success('证件已保存,请上传下一张证件')
} else if (props.popup) {
ElMessage.success('证件已保存')
@@ -1210,12 +1380,15 @@
].map((field) => field[0])
const hasContent =
keys.some((key) => form.value[key] != null && form.value[key] !== '') ||
form.value.customerId ||
form.value.categoryId ||
form.value.contractBindings?.length ||
form.value.purchaseRefs?.length ||
form.value.vehicleNumbersJson?.length
if (hasContent) {
try {
await showCrmConfirmDialog({
kind: 'default',
title: '切换证件类型',
message: '切换证件类型将清空证面信息,保留建档方式、附件和系统备注。是否继续?'
})
@@ -1238,6 +1411,7 @@
lockedPlates.value = []
linkedRefIds.value = []
clearBindingCustomer()
clearSystemCustomer()
if (value === 'transport') purchases.value = await quotaCertApi.list('purchase').catch(() => [])
}
function recognitionCurrent(current: number, targetKind: CertType, image: string) {
+16 -1
View File
@@ -23,6 +23,12 @@
>
<el-icon><CircleCheck /></el-icon>批量完善并关闭
</el-button>
<el-button v-if="listMode === 'fulfill'" @click="goUploadCert('purchase')">
<el-icon><Upload /></el-icon>上传购买证
</el-button>
<el-button v-if="listMode === 'fulfill'" @click="goUploadCert('transport')">
<el-icon><Upload /></el-icon>上传运输证
</el-button>
<el-button v-if="keyword || hasActiveFilters" @click="reset">
<el-icon><RefreshLeft /></el-icon>清除筛选
</el-button>
@@ -148,7 +154,16 @@
getPlPlanFollowStatusLabel,
getPlPlanFollowStatusTagType
} from '@/utils/pl-display'
import { CircleCheck, Refresh, RefreshLeft } from '@element-plus/icons-vue'
import { CircleCheck, Refresh, RefreshLeft, Upload } from '@element-plus/icons-vue'
const router = useRouter()
function goUploadCert(kind: 'purchase' | 'transport') {
void router.push({
path: '/pl/cert-upload/quota-cert',
query: { kind, create: '1' }
})
}
const keyword = ref('')
const page = ref(1)
+7 -1
View File
@@ -1667,7 +1667,7 @@
form.value.referencesEditable === false && !!row.id && linkedRefIds.value.includes(row.id)
)
}
function onPurchaseArchiveChange() {
function onPurchaseArchiveChange(_row?: { purchaseCertId?: string | null }) {
edited.add('purchaseRefs')
}
function referencesLocked() {
@@ -1749,9 +1749,15 @@
if (current === authEpoch && !disposed && typeof route.query.contractId === 'string')
scopeDialog.value?.open(route.query.contractId)
if (current === authEpoch && !disposed && route.query.create === '1' && canEdit.value) {
const createKind =
route.query.kind === 'transport' || route.query.kind === 'purchase'
? (route.query.kind as CertType)
: kind.value
kind.value = createKind
await edit()
const nextQuery = { ...route.query }
delete nextQuery.create
delete nextQuery.kind
router.replace({ query: nextQuery })
}
}
@@ -3,6 +3,13 @@
<div v-if="!embedded" class="panel-top"
><h2 class="title-bar-heading">{{ mode === 'contract' ? '合同用证' : '证件用量' }}</h2></div
>
<el-alert
v-if="!embedded && mode === 'contract' && customerRuleActive"
class="mb-3"
type="warning"
:closable="false"
title="新规则已生效:安排选证改为客户+证用品类,本页合同绑证仅供历史查看与旧规则计划,请勿再作为新计划的用证操作入口。"
/>
<div v-if="!contractId" class="list-toolbar"
><div class="list-toolbar-row cert-list-toolbar-row">
<ListQuickSearchInput
@@ -188,6 +195,7 @@
import { fetchGetMenuCodes } from '@/api/auth'
import { useUserStore } from '@/store/modules/user'
import {
certQuotaRuleApi,
quotaCertApi,
quotaStatisticsApi,
type ContractStatistics,
@@ -219,6 +227,7 @@
)
const user = useUserStore()
const router = useRouter()
const customerRuleActive = ref(false)
const allowed = ref(false),
canEdit = ref(false),
loading = ref(false),
@@ -530,6 +539,7 @@
clear()
allowed.value = false
canEdit.value = false
customerRuleActive.value = false
sessionKey.value++
if (!user.accessToken || !props.active) return
const current = epoch
@@ -541,6 +551,11 @@
canEdit.value =
allowed.value &&
(!!p.all || !!p.isSuperAdmin || (p.menuCodes || []).includes('pl:quota-cert:edit'))
if (props.mode === 'contract' && !props.embedded) {
const rule = await certQuotaRuleApi.get().catch(() => null)
if (current !== epoch) return
customerRuleActive.value = !!rule?.configured
}
await load()
} catch {
if (current === epoch) error.value = '权限加载失败,请重新打开页面'