From 96c224f71d9e6677175b909285961fa4b67a7a3d Mon Sep 17 00:00:00 2001 From: 170-carry Date: Thu, 30 Apr 2026 20:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AC=A1=E6=9C=88=E6=94=BF=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/src/api/legacy/team.ts | 4 + apps/src/views/team/team-policy-page.vue | 109 +++++++++++++++++++++-- 2 files changed, 107 insertions(+), 6 deletions(-) diff --git a/apps/src/api/legacy/team.ts b/apps/src/api/legacy/team.ts index d57f76b..e5e0757 100644 --- a/apps/src/api/legacy/team.ts +++ b/apps/src/api/legacy/team.ts @@ -6,12 +6,16 @@ export interface LegacyPageResult> { } export interface LegacyTeamPolicyItem { + activatedTime?: number | string; countryCode?: string; createTime?: number | string; createUserNickname?: string; + effectiveMonth?: number | string; + effectiveStartTime?: number | string; historyRelease?: boolean; id?: number | string; policy?: Array>; + policyStatus?: string; policyType?: string; region?: number | string; release?: boolean; diff --git a/apps/src/views/team/team-policy-page.vue b/apps/src/views/team/team-policy-page.vue index d73d1c1..b16fd45 100644 --- a/apps/src/views/team/team-policy-page.vue +++ b/apps/src/views/team/team-policy-page.vue @@ -74,6 +74,22 @@ const policies = ref>>([]); const countryList = ref>>([]); const currentRewardRow = ref>({}); +const POLICY_STATUS_LABELS: Record = { + ACTIVE: '生效中', + CANCELLED: '已取消', + DRAFT: '草稿', + HISTORY: '历史', + SCHEDULED: '待生效', +}; + +const POLICY_STATUS_COLORS: Record = { + ACTIVE: 'blue', + CANCELLED: 'default', + DRAFT: 'default', + HISTORY: 'green', + SCHEDULED: 'orange', +}; + const query = reactive({ countryCode: '', policyType: props.policyType === 'SALARY_DIAMOND' ? 'SALARY_DIAMOND' : '', @@ -111,9 +127,14 @@ const countryOptions = computed(() => function createFormData() { return { + activatedTime: '', countryCode: '', + effectiveMonth: '', + effectiveStartTime: '', + historyRelease: false, id: '', policy: [] as Array>, + policyStatus: 'DRAFT', policyType: props.policyType, region: '', release: false, @@ -306,8 +327,13 @@ function handleRewardSuccess(rewards: Array>) { function handleEditHistory(item: LegacyTeamPolicyItem) { policies.value = clonePolicies(item.policy); + formData.activatedTime = item.activatedTime ? String(item.activatedTime) : ''; formData.countryCode = item.countryCode ? String(item.countryCode) : query.countryCode; + formData.effectiveMonth = item.effectiveMonth ? String(item.effectiveMonth) : ''; + formData.effectiveStartTime = item.effectiveStartTime ? String(item.effectiveStartTime) : ''; + formData.historyRelease = Boolean(item.historyRelease); formData.id = item.id ? String(item.id) : ''; + formData.policyStatus = item.policyStatus || (item.release ? 'ACTIVE' : 'DRAFT'); formData.region = item.region ? String(item.region) : ''; formData.title = item.title || ''; formData.release = Boolean(item.release); @@ -335,9 +361,11 @@ async function handleDeleteHistory(id?: number | string) { }); } -async function persistPolicy(release: boolean) { +async function persistPolicy(release: boolean, policyStatus = release ? 'ACTIVE' : 'DRAFT') { + const previousPolicyStatus = formData.policyStatus; formData.countryCode = query.countryCode; formData.policy = clonePolicies(policies.value).map(normalizePolicyItem); + formData.policyStatus = policyStatus; formData.region = query.region; formData.release = release; formData.sysOrigin = query.sysOrigin; @@ -357,10 +385,24 @@ async function persistPolicy(release: boolean) { loading.value = true; try { - await teamPolicyAdd({ + const id = policyStatus === 'SCHEDULED' && previousPolicyStatus !== 'SCHEDULED' + ? '' + : formData.id; + const payload: Record = { ...formData, + id, title: String(formData.title || '').trim(), - }); + }; + if (!payload.effectiveMonth) { + delete payload.effectiveMonth; + } + if (!payload.effectiveStartTime) { + delete payload.effectiveStartTime; + } + if (!payload.activatedTime) { + delete payload.activatedTime; + } + await teamPolicyAdd(payload); message.success('保存成功'); } finally { loading.value = false; @@ -369,13 +411,22 @@ async function persistPolicy(release: boolean) { function handleSave(release: boolean) { if (!release) { - void persistPolicy(false); + void persistPolicy(false, 'DRAFT'); return; } Modal.confirm({ title: '确定对外发布当前政策吗?', async onOk() { - await persistPolicy(true); + await persistPolicy(true, 'ACTIVE'); + }, + }); +} + +function handleScheduleNextMonth() { + Modal.confirm({ + title: '确定保存为次月自动生效政策吗?', + async onOk() { + await persistPolicy(false, 'SCHEDULED'); }, }); } @@ -389,6 +440,25 @@ function getCountryLabel(item: Record) { return item?.country?.aliasName || item?.country?.enName || '-'; } +function getPolicyStatus(item: Record) { + if (item.policyStatus) { + return String(item.policyStatus); + } + if (item.release) { + return 'ACTIVE'; + } + return item.historyRelease ? 'HISTORY' : 'DRAFT'; +} + +function getPolicyStatusLabel(item: Record) { + const status = getPolicyStatus(item); + return POLICY_STATUS_LABELS[status] || status || '-'; +} + +function getPolicyStatusColor(item: Record) { + return POLICY_STATUS_COLORS[getPolicyStatus(item)] || 'default'; +} + watch( sysOriginOptions, (options) => { @@ -499,6 +569,18 @@ onMounted(() => { {{ meta.policyTypeLabel }} +
+
状态
+ + {{ getPolicyStatusLabel(data) }} + +
+
+
生效时间
+
+ {{ data.effectiveStartTime ? formatDate(data.effectiveStartTime) : '-' }} +
+
{ > 保存并发布 + @@ -759,6 +847,9 @@ onMounted(() => { class="history-card" >
+ + {{ getPolicyStatusLabel(item) }} + {
创建时间: {{ formatDate(item.createTime) }}
+
+ 生效时间: {{ formatDate(item.effectiveStartTime) }} +