diff --git a/src/api/business/hcs.js b/src/api/business/hcs.js index 47012a2..740b016 100644 --- a/src/api/business/hcs.js +++ b/src/api/business/hcs.js @@ -2,6 +2,43 @@ import request from '@/axios'; const baseUrl = '/blade-transport/hcs'; +/** 进程内缓存,避免列表页重复请求推送开关 */ +let immediateEnabledCache = null; +let immediateEnabledPromise = null; + +/** + * 查询 HCS 即时推送开关(thirdParty.hcs.push.immediate-enabled)。 + * 关闭时项目管理/合同管理隐藏「推送合规」「批量推送合规」。 + */ +export const getPushConfig = () => + request({ + url: `${baseUrl}/push-config`, + method: 'get', + }); + +export const loadHcsImmediateEnabled = () => { + if (immediateEnabledCache !== null) { + return Promise.resolve(immediateEnabledCache); + } + if (immediateEnabledPromise) { + return immediateEnabledPromise; + } + immediateEnabledPromise = getPushConfig() + .then(res => { + const data = res?.data?.data ?? res?.data ?? {}; + immediateEnabledCache = data.immediateEnabled === true || data.immediateEnabled === 'true'; + return immediateEnabledCache; + }) + .catch(() => { + immediateEnabledCache = false; + return false; + }) + .finally(() => { + immediateEnabledPromise = null; + }); + return immediateEnabledPromise; +}; + // 合规推送涉及 HCS 远程多次调用(风险校验+附件转传+起草),可达 20s+,覆盖全局 10s 超时 export const repush = (bizType, id) => request({ diff --git a/src/views/business/contract-manage.vue b/src/views/business/contract-manage.vue index 883ab62..709f8c5 100644 --- a/src/views/business/contract-manage.vue +++ b/src/views/business/contract-manage.vue @@ -33,6 +33,7 @@ 批量导出 {{ operation.label }} - + {{ hcsRepushingId === row.id ? '推送中…' : '推送合规' }} 删除 @@ -1090,7 +1095,12 @@ import 'nprogress/nprogress.css'; import { exportBlob } from '@/api/common'; import * as api from '@/api/business/contract-manage'; import { createFromContract } from '@/api/business/contract-change'; -import { repush as hcsRepush, repushBatch as hcsRepushBatch, getRisk } from '@/api/business/hcs'; +import { + getRisk, + loadHcsImmediateEnabled, + repush as hcsRepush, + repushBatch as hcsRepushBatch, +} from '@/api/business/hcs'; import { Position } from '@element-plus/icons-vue'; import { getMkPublicDetail } from '@/api/mk-process'; import { getList as getProjectList } from '@/api/business/project-apply'; @@ -1427,8 +1437,9 @@ export default { billCycleTypeOptions: ['固定截单日', '自然月', '自定义多周期'], detailLoading: false, detailRow: {}, - // 合规(HCS)推送/对账状态 + // 合规(HCS)推送/对账状态;受 thirdParty.hcs.push.immediate-enabled 控制显隐 hcsRepushingId: null, + hcsImmediateEnabled: false, detailContractFileRows: [], detailAttachmentRows: [], detailBillingPlanRows: [], @@ -1699,6 +1710,13 @@ export default { .catch(() => { this.mkEnabled = false; }); + loadHcsImmediateEnabled() + .then(enabled => { + this.hcsImmediateEnabled = !!enabled; + }) + .catch(() => { + this.hcsImmediateEnabled = false; + }); } if (this.isFormPage) this.initFormPage(); if (this.isDetailPage) this.initDetailPage(); @@ -1761,6 +1779,7 @@ export default { }, canHcsRepush(row) { return ( + this.hcsImmediateEnabled && ['approved', 'change_approved'].includes(row.approvalStatus) && row.hcsSyncStatus !== 'synced' ); diff --git a/src/views/business/project-apply.vue b/src/views/business/project-apply.vue index 3d9034d..0242715 100644 --- a/src/views/business/project-apply.vue +++ b/src/views/business/project-apply.vue @@ -55,7 +55,7 @@ @@ -154,7 +154,7 @@ {{ operation.label }} @@ -984,7 +984,11 @@ import { exportBlob } from '@/api/common'; import { defineAsyncComponent } from 'vue'; import * as api from '@/api/business/project-apply'; -import { repush as hcsRepush, repushBatch as hcsRepushBatch } from '@/api/business/hcs'; +import { + loadHcsImmediateEnabled, + repush as hcsRepush, + repushBatch as hcsRepushBatch, +} from '@/api/business/hcs'; import { Position } from '@element-plus/icons-vue'; import { getMkPublicDetail } from '@/api/mk-process'; import { @@ -1196,8 +1200,9 @@ export default { { label: '高风险', value: 'high', statKey: 'high' }, { label: '中风险', value: 'medium', statKey: 'medium' }, ], - // 合规(HCS)推送状态 + // 合规(HCS)推送状态;受 thirdParty.hcs.push.immediate-enabled 控制显隐 hcsRepushingId: null, + hcsImmediateEnabled: false, page: { pageSize: 10, pageSizes: [10, 20, 50, 100], @@ -1556,6 +1561,13 @@ export default { .catch(() => { this.mkEnabled = false; }); + loadHcsImmediateEnabled() + .then(enabled => { + this.hcsImmediateEnabled = !!enabled; + }) + .catch(() => { + this.hcsImmediateEnabled = false; + }); this.loadDeptOptions(); this.loadCargoTypeOptions(); this.loadTransportTypeOptions(); @@ -1790,6 +1802,7 @@ export default { }, canHcsRepush(row) { return ( + this.hcsImmediateEnabled && !this.readonlyScope && ['approved', 'change_approved'].includes(row.approvalStatus) && row.hcsSyncStatus !== 'synced'