feat(crm): 新增合同运输计划合法使用证明页签并隔离权限与异步会话。
This commit is contained in:
1 parent
cd33a387a4
commit
144a3cb236
2 files changed
+412
-4
No files matched your search
@@ -513,7 +513,7 @@
|
||||
|
||||
<el-tab-pane v-if="canViewQuotaCert" label="合同证件与额度" name="quota" lazy>
|
||||
<ContractQuotaPanel
|
||||
v-if="detailActiveTab === 'quota' && detailContract?.id"
|
||||
v-if="visible && detailActiveTab === 'quota' && detailContract?.id && String(detailContract.id) === String(currentDetailId)"
|
||||
:key="detailContract.id"
|
||||
:contract-id="String(detailContract.id)"
|
||||
:active="detailActiveTab === 'quota'"
|
||||
@@ -521,6 +521,16 @@
|
||||
/>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane v-if="canViewProof" label="运输计划合法使用证明" name="proof" lazy>
|
||||
<StopDocuments
|
||||
v-if="visible && detailActiveTab === 'proof' && detailContract?.id && String(detailContract.id) === String(currentDetailId)"
|
||||
:key="detailContract.id"
|
||||
:contract-id="String(detailContract.id)"
|
||||
:active="detailActiveTab === 'proof'"
|
||||
embedded
|
||||
/>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 回款记录 -->
|
||||
<el-tab-pane label="回款记录" name="payment">
|
||||
<div class="panel dialog-list-panel">
|
||||
@@ -992,6 +1002,7 @@
|
||||
import { ref, reactive, computed, onMounted, defineAsyncComponent, nextTick, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { isFrameworkContractType, isContractEditableStatus, getContractReeditConfirmMessage } from '../contractType'
|
||||
import {
|
||||
displayFrameworkMoney,
|
||||
@@ -1056,6 +1067,7 @@ import ContractFormDialog from './ContractFormDialog.vue';
|
||||
import ViewKvTable from '@/components/business/system-view-dialog/ViewKvTable.vue';
|
||||
import type { ViewField } from '@/components/business/system-view-dialog/types';
|
||||
import ContractQuotaPanel from '@/views/pl/contract-quota/ContractQuotaPanel.vue';
|
||||
import StopDocuments from '@/views/pl/legal-use-document/StopDocuments.vue';
|
||||
import PlContractLinkedPlansPanel from '@/components/business/pl-contract-linked-plans-panel/index.vue';
|
||||
import {
|
||||
parseSettlementClauseDrafts,
|
||||
@@ -1097,7 +1109,9 @@ import {
|
||||
|
||||
const dictStore = useDictStore();
|
||||
const router = useRouter();
|
||||
const user = useUserStore()
|
||||
const canViewQuotaCert = ref(false)
|
||||
const canViewProof = ref(false)
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -1116,6 +1130,43 @@ const detailLoading = ref(false);
|
||||
const detailActiveTab = ref('contract');
|
||||
const currentDetailId = ref<string | number>();
|
||||
const detailContract = ref<ContractVO>();
|
||||
// 权限会话与详情请求各自计数,互不取消初始化或刷新。
|
||||
let permissionEpoch = 0
|
||||
let detailEpoch = 0
|
||||
const sessionScope = computed(() => JSON.stringify([
|
||||
user.accessToken,
|
||||
user.getUserInfo
|
||||
]))
|
||||
watch([visible, sessionScope], async ([isVisible]) => {
|
||||
const epoch = ++permissionEpoch
|
||||
canViewQuotaCert.value = false
|
||||
canViewProof.value = false
|
||||
if (['quota', 'proof'].includes(detailActiveTab.value)) detailActiveTab.value = 'contract'
|
||||
if (!isVisible || !user.accessToken) return
|
||||
try {
|
||||
const perms = await fetchGetMenuCodes()
|
||||
if (epoch !== permissionEpoch) return
|
||||
const all = !!perms.all || !!perms.isSuperAdmin
|
||||
canViewQuotaCert.value = all || (perms.menuCodes || []).includes('pl:quota-cert:list')
|
||||
canViewProof.value = all || (perms.menuCodes || []).includes('pl:legal-use-document:list')
|
||||
} catch {
|
||||
// 失败时保持无权限;下次打开重新加载。
|
||||
}
|
||||
}, { flush: 'sync' })
|
||||
watch([visible, currentDetailId, sessionScope], ([isVisible]) => {
|
||||
++detailEpoch
|
||||
detailLoading.value = false
|
||||
// 关闭后的复制/编辑动作仍需读取本次合同;重新打开或切换范围时清空。
|
||||
if (isVisible) detailContract.value = undefined
|
||||
}, { flush: 'sync' })
|
||||
watch(sessionScope, () => {
|
||||
visible.value = false
|
||||
handleDetailDrawerClose()
|
||||
}, { flush: 'sync' })
|
||||
onBeforeUnmount(() => {
|
||||
++permissionEpoch
|
||||
++detailEpoch
|
||||
})
|
||||
/** 供方 / 需方信息展开状态(默认缩略,两侧共用) */
|
||||
const partiesExpanded = ref(false);
|
||||
const detailPaymentList = ref<any[]>([]);
|
||||
@@ -1275,17 +1326,22 @@ function getContractPdfCanvasScale() {
|
||||
const loadDetailData = async () => {
|
||||
if (!currentDetailId.value) return;
|
||||
|
||||
const epoch = ++detailEpoch
|
||||
const isCurrent = () => epoch === detailEpoch && visible.value
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
const res = await getContractDetail(String(currentDetailId.value));
|
||||
if (!isCurrent()) return
|
||||
detailContract.value = res.data;
|
||||
|
||||
await enrichContractProductAliasDisplay(detailContract.value?.products || [])
|
||||
if (!isCurrent()) return
|
||||
|
||||
// 加载关联商机名称
|
||||
if (detailContract.value?.opportunityId) {
|
||||
try {
|
||||
const oppRes = await getOpportunity(detailContract.value.opportunityId);
|
||||
if (!isCurrent()) return
|
||||
if (oppRes?.data) {
|
||||
detailContract.value.opportunityName = oppRes.data.opportunityName;
|
||||
}
|
||||
@@ -1298,6 +1354,7 @@ const loadDetailData = async () => {
|
||||
if (detailContract.value?.quoteId) {
|
||||
try {
|
||||
const quoteRes = await getQuote(detailContract.value.quoteId);
|
||||
if (!isCurrent()) return
|
||||
if (quoteRes?.data) {
|
||||
detailContract.value.quoteNo = quoteRes.data.quoteNo;
|
||||
}
|
||||
@@ -1306,13 +1363,14 @@ const loadDetailData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCurrent()) return
|
||||
// 加载审批记录
|
||||
loadDetailApprovalRecords();
|
||||
|
||||
// 异步加载附件信息
|
||||
loadDetailContractAttachments();
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
if (isCurrent()) detailLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3288,8 +3346,6 @@ const handleGeneratePdfFromDialog = async () => {
|
||||
|
||||
onMounted(async () => {
|
||||
await dictStore.loadAllDict();
|
||||
const perms = await fetchGetMenuCodes()
|
||||
canViewQuotaCert.value = !!perms.all || !!perms.isSuperAdmin || (perms.menuCodes || []).includes('pl:quota-cert:list')
|
||||
});
|
||||
|
||||
function formatPlanQty(value: unknown) {
|
||||
|
||||
Reference in new issue
Block a user