fix(pl): 证件建档按客户查询可添加合同,避免列表为空。
改用 CRM listContract 按 customerId 拉取,不再只取最近合同再前端过滤。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
71927bedef
commit
eae5654f01
3 files changed
+115
-7
No files matched your search
@@ -512,6 +512,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { 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'
|
||||
import MpWebviewShell from '@/layouts/MpWebviewShell.vue'
|
||||
import MpBusinessHeader from '@/components/mp/MpBusinessHeader.vue'
|
||||
@@ -540,11 +542,14 @@
|
||||
} from '@/views/pl/quota-cert/model'
|
||||
import {
|
||||
bindingsFromPurchaseCerts,
|
||||
contractsForCustomer,
|
||||
exactCustomerMatches,
|
||||
matchPurchaseCert,
|
||||
scopeProductsFromLines
|
||||
} from '@/views/pl/quota-cert/contract-binder-rules'
|
||||
import {
|
||||
certArchiveContractListQuery,
|
||||
filterAvailableBindingContracts
|
||||
} from '@/views/pl/quota-cert/cert-archive-contract-query'
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { showCrmConfirmDialog } from '@/utils/mp-crm-confirm'
|
||||
@@ -928,19 +933,39 @@
|
||||
if (current === epoch) ElMessage.warning('客户匹配失败,请手工选择')
|
||||
}
|
||||
}
|
||||
function toContractOption(row: ContractVO): ContractOption {
|
||||
return {
|
||||
id: String(row.id),
|
||||
contractNo: row.contractNo || '',
|
||||
contractName: row.contractName || '',
|
||||
contractType: row.contractType,
|
||||
customerId: row.customerId != null ? String(row.customerId) : '',
|
||||
customerName: row.customerName,
|
||||
status: row.status,
|
||||
signDate: row.signDate || null
|
||||
}
|
||||
}
|
||||
async function searchContracts(keyword = '') {
|
||||
const current = epoch
|
||||
const query = certArchiveContractListQuery(bindingCustomer.value.id, keyword)
|
||||
if (!query) {
|
||||
contractOptions.value = []
|
||||
return
|
||||
}
|
||||
try {
|
||||
const rows = await quotaCertApi.contracts(keyword)
|
||||
const result = await listContract(query)
|
||||
if (current !== epoch) return
|
||||
const taken = new Set(
|
||||
(form.value.contractBindings || []).map((row: CertificateContractBinding) => row.contractId)
|
||||
const taken = (form.value.contractBindings || []).map(
|
||||
(row: CertificateContractBinding) => row.contractId
|
||||
)
|
||||
contractOptions.value = contractsForCustomer(rows, bindingCustomer.value).filter(
|
||||
(row) => !taken.has(row.id)
|
||||
contractOptions.value = filterAvailableBindingContracts(result.rows || [], taken).map(
|
||||
toContractOption
|
||||
)
|
||||
} catch {
|
||||
if (current === epoch) contractOptions.value = []
|
||||
if (current === epoch) {
|
||||
contractOptions.value = []
|
||||
ElMessage.warning('合同加载失败,请重试')
|
||||
}
|
||||
}
|
||||
}
|
||||
function openContracts() {
|
||||
|
||||
Reference in new issue
Block a user