提交
This commit is contained in:
1 parent
dacfdc9ff6
commit
f9676f8759
906 files changed
+533306
-12946
No files matched your search
@@ -0,0 +1,337 @@
|
||||
<template>
|
||||
<SystemViewDialog
|
||||
v-model:visible="visible"
|
||||
:title="contractInfo.contractName || '合同详情'"
|
||||
:icon="Document"
|
||||
width="calc(100vw - 100px)"
|
||||
:code="contractInfo.contractNo"
|
||||
code-label="合同编号"
|
||||
:meta="viewHeroMeta"
|
||||
:sections="viewSections"
|
||||
:loading="loading"
|
||||
:grid-columns="2"
|
||||
dialog-class="contract-view-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
append-to-body
|
||||
>
|
||||
<template #products>
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
:data="contractInfo.products || []"
|
||||
class="list-table"
|
||||
stripe
|
||||
empty-text="暂无产品明细"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" header-align="center" />
|
||||
<el-table-column label="产品名称" prop="productName" min-width="140" align="center" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column label="型号/规格" prop="productModel" min-width="120" align="center" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.productModel || row.model || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" prop="unit" min-width="80" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="row.unit"
|
||||
:type="dictStore.getTagType('crm_product_unit', row.unit)"
|
||||
size="small"
|
||||
>
|
||||
{{ dictStore.getLabel('crm_product_unit', row.unit) }}
|
||||
</el-tag>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="quantity" min-width="90" align="right" header-align="right" />
|
||||
<el-table-column label="单价" min-width="110" align="right" header-align="right">
|
||||
<template #default="{ row }">¥{{ formatAmount(row.price) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="小计" min-width="110" align="right" header-align="right">
|
||||
<template #default="{ row }">¥{{ formatAmount(row.subtotal) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #attachments>
|
||||
<AttachmentUploadField
|
||||
v-if="attachmentValue"
|
||||
:model-value="attachmentValue"
|
||||
disabled
|
||||
/>
|
||||
<p v-else class="view-empty-hint">暂无附件</p>
|
||||
</template>
|
||||
|
||||
<template #approval>
|
||||
<div v-if="approvalList.length" class="contract-approval-flow-scroll">
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="item in approvalList"
|
||||
:key="item.id"
|
||||
:timestamp="item.approvalTime || '—'"
|
||||
placement="top"
|
||||
>
|
||||
<div class="contract-approval-card">
|
||||
<div class="contract-approval-card-head">
|
||||
<span class="contract-approval-card-user">{{ item.approverName || '—' }}</span>
|
||||
<el-tag
|
||||
v-if="item.approvalResult === 'approved'"
|
||||
type="success"
|
||||
size="small"
|
||||
>已通过</el-tag>
|
||||
<el-tag
|
||||
v-else-if="item.approvalResult === 'rejected'"
|
||||
type="danger"
|
||||
size="small"
|
||||
>已拒绝</el-tag>
|
||||
<el-tag
|
||||
v-else-if="item.approvalResult === 'pending'"
|
||||
type="info"
|
||||
size="small"
|
||||
>待审批</el-tag>
|
||||
</div>
|
||||
<p v-if="item.approvalOpinion" class="contract-approval-opinion">
|
||||
{{ item.approvalOpinion }}
|
||||
</p>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</div>
|
||||
<p v-else class="view-empty-hint">暂无审批记录</p>
|
||||
</template>
|
||||
</SystemViewDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Document } from '@element-plus/icons-vue'
|
||||
import SystemViewDialog, {
|
||||
type ViewField,
|
||||
type ViewSection
|
||||
} from '@/components/business/system-view-dialog/index.vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { getContract, listContractApproval } from '@/api/crm/contract'
|
||||
import { getOpportunity } from '@/api/crm/opportunity'
|
||||
import { getQuote } from '@/api/crm/quote'
|
||||
import type { ContractApprovalVO, ContractVO } from '@/api/crm/contract/types'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const contractInfo = ref<ContractVO>({} as ContractVO)
|
||||
const approvalList = ref<ContractApprovalVO[]>([])
|
||||
|
||||
function formatAmount(amount?: number | string | null) {
|
||||
if (amount == null || amount === '') return '0.00'
|
||||
const num = typeof amount === 'string' ? parseFloat(amount) : amount
|
||||
if (Number.isNaN(num)) return '0.00'
|
||||
return num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
}
|
||||
|
||||
function tagField(
|
||||
label: string,
|
||||
dictType: string,
|
||||
value?: string | null,
|
||||
extra?: Partial<ViewField>
|
||||
): ViewField {
|
||||
return {
|
||||
label,
|
||||
value: value ? dictStore.getLabel(dictType, value) : '—',
|
||||
tagType: value ? dictStore.getTagType(dictType, value) : undefined,
|
||||
...extra
|
||||
}
|
||||
}
|
||||
|
||||
const attachmentValue = computed(() => {
|
||||
const c = contractInfo.value
|
||||
const parts = [c.contractFile, c.attachmentFiles].filter(Boolean)
|
||||
return parts.join(',')
|
||||
})
|
||||
|
||||
const viewHeroMeta = computed(() => {
|
||||
const c = contractInfo.value
|
||||
const parts: string[] = []
|
||||
if (c.customerName) parts.push(c.customerName)
|
||||
if (c.status) parts.push(dictStore.getLabel('crm_contract_status', c.status))
|
||||
if (c.signDate) parts.push(`签订 ${c.signDate}`)
|
||||
return parts.join(' · ')
|
||||
})
|
||||
|
||||
const viewSections = computed<ViewSection[]>(() => {
|
||||
const c = contractInfo.value
|
||||
if (!c?.id) return []
|
||||
|
||||
const basicFields: ViewField[] = [
|
||||
tagField('合同类型', 'crm_contract_type', c.contractType),
|
||||
tagField('合同模版', 'crm_contract_template', c.contractTemplate),
|
||||
{ label: '客户名称', value: c.customerName },
|
||||
{ label: '关联商机', value: c.opportunityName || '—' },
|
||||
{ label: '关联报价单', value: c.quoteNo || '—' },
|
||||
{ label: '联系人', value: c.contactName },
|
||||
{ label: '联系电话', value: c.contactMobile },
|
||||
{ label: '签订日期', value: c.signDate },
|
||||
{ label: '合同期限', value: c.startDate && c.endDate ? `${c.startDate} ~ ${c.endDate}` : '—' },
|
||||
{ label: '负责人', value: c.ownerUserName },
|
||||
tagField('合同状态', 'crm_contract_status', c.status),
|
||||
tagField('审批状态', 'crm_approval_status', c.approvalStatus)
|
||||
]
|
||||
|
||||
const amountFields: ViewField[] = [
|
||||
{ label: '合同金额', value: `¥${formatAmount(c.amount)}`, money: true },
|
||||
{ label: '已回款金额', value: `¥${formatAmount(c.receivedAmount)}`, money: true },
|
||||
{ label: '未回款金额', value: `¥${formatAmount(c.unreceivedAmount)}`, money: true },
|
||||
{ label: '已开票金额', value: `¥${formatAmount(c.invoiceAmount)}`, money: true }
|
||||
]
|
||||
|
||||
const partyFields: ViewField[] = [
|
||||
{ label: '甲方', value: c.partyA },
|
||||
{ label: '甲方联系人', value: c.partyAContact },
|
||||
{ label: '甲方电话', value: c.partyAMobile },
|
||||
{ label: '乙方', value: c.partyB },
|
||||
{ label: '乙方联系人', value: c.partyBContact },
|
||||
{ label: '乙方电话', value: c.partyBMobile },
|
||||
tagField('结算方式', 'crm_settlement_method', c.settlementMethod)
|
||||
]
|
||||
|
||||
const sections: ViewSection[] = [
|
||||
{ title: '基本信息', fields: basicFields },
|
||||
{ title: '金额信息', fields: amountFields },
|
||||
{ title: '签约主体', fields: partyFields },
|
||||
{
|
||||
title: '产品明细',
|
||||
fields: [],
|
||||
slot: 'products'
|
||||
},
|
||||
{
|
||||
title: '合同附件',
|
||||
fields: [],
|
||||
slot: 'attachments'
|
||||
},
|
||||
{
|
||||
title: '审批记录',
|
||||
fields: [],
|
||||
slot: 'approval'
|
||||
}
|
||||
]
|
||||
|
||||
if (c.paymentTerms) {
|
||||
sections.push({
|
||||
title: '付款条款',
|
||||
fields: [{ label: '付款条款', value: c.paymentTerms, span: true }]
|
||||
})
|
||||
}
|
||||
|
||||
if (c.deliveryTerms) {
|
||||
sections.push({
|
||||
title: '交付条款',
|
||||
fields: [{ label: '交付条款', value: c.deliveryTerms, span: true }]
|
||||
})
|
||||
}
|
||||
|
||||
if (c.remark) {
|
||||
sections.push({
|
||||
title: '备注',
|
||||
fields: [{ label: '备注', value: c.remark, span: true }]
|
||||
})
|
||||
}
|
||||
|
||||
return sections
|
||||
})
|
||||
|
||||
async function loadDetail(id: string | number) {
|
||||
loading.value = true
|
||||
try {
|
||||
await dictStore.loadAllDict()
|
||||
const res = await getContract(id)
|
||||
contractInfo.value = (res as any)?.data || res || ({} as ContractVO)
|
||||
|
||||
if (contractInfo.value?.opportunityId) {
|
||||
try {
|
||||
const oppRes = await getOpportunity(contractInfo.value.opportunityId)
|
||||
if (oppRes?.data) {
|
||||
contractInfo.value.opportunityName = oppRes.data.opportunityName
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
if (contractInfo.value?.quoteId) {
|
||||
try {
|
||||
const quoteRes = await getQuote(contractInfo.value.quoteId)
|
||||
if (quoteRes?.data) {
|
||||
contractInfo.value.quoteNo = quoteRes.data.quoteNo
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const approvalRes = await listContractApproval(id)
|
||||
approvalList.value = (approvalRes as any)?.data || approvalRes || []
|
||||
} catch {
|
||||
approvalList.value = []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
contractInfo.value = {} as ContractVO
|
||||
approvalList.value = []
|
||||
ElMessage.error('加载合同详情失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function open(id: string | number) {
|
||||
visible.value = true
|
||||
contractInfo.value = {} as ContractVO
|
||||
approvalList.value = []
|
||||
await loadDetail(id)
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.contract-approval-flow-scroll {
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.contract-approval-card {
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.contract-approval-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.contract-approval-card-user {
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.contract-approval-opinion {
|
||||
margin: 8px 0 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: #64748b;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.contract-view-dialog.system-view-dialog {
|
||||
&.el-dialog {
|
||||
max-width: calc(100vw - 100px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user