次月政策
This commit is contained in:
parent
9dbb25287d
commit
96c224f71d
@ -6,12 +6,16 @@ export interface LegacyPageResult<T = Record<string, any>> {
|
||||
}
|
||||
|
||||
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<Record<string, any>>;
|
||||
policyStatus?: string;
|
||||
policyType?: string;
|
||||
region?: number | string;
|
||||
release?: boolean;
|
||||
|
||||
@ -74,6 +74,22 @@ const policies = ref<Array<Record<string, any>>>([]);
|
||||
const countryList = ref<Array<Record<string, any>>>([]);
|
||||
const currentRewardRow = ref<Record<string, any>>({});
|
||||
|
||||
const POLICY_STATUS_LABELS: Record<string, string> = {
|
||||
ACTIVE: '生效中',
|
||||
CANCELLED: '已取消',
|
||||
DRAFT: '草稿',
|
||||
HISTORY: '历史',
|
||||
SCHEDULED: '待生效',
|
||||
};
|
||||
|
||||
const POLICY_STATUS_COLORS: Record<string, string> = {
|
||||
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<Record<string, any>>,
|
||||
policyStatus: 'DRAFT',
|
||||
policyType: props.policyType,
|
||||
region: '',
|
||||
release: false,
|
||||
@ -306,8 +327,13 @@ function handleRewardSuccess(rewards: Array<Record<string, any>>) {
|
||||
|
||||
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<string, any> = {
|
||||
...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<string, any>) {
|
||||
return item?.country?.aliasName || item?.country?.enName || '-';
|
||||
}
|
||||
|
||||
function getPolicyStatus(item: Record<string, any>) {
|
||||
if (item.policyStatus) {
|
||||
return String(item.policyStatus);
|
||||
}
|
||||
if (item.release) {
|
||||
return 'ACTIVE';
|
||||
}
|
||||
return item.historyRelease ? 'HISTORY' : 'DRAFT';
|
||||
}
|
||||
|
||||
function getPolicyStatusLabel(item: Record<string, any>) {
|
||||
const status = getPolicyStatus(item);
|
||||
return POLICY_STATUS_LABELS[status] || status || '-';
|
||||
}
|
||||
|
||||
function getPolicyStatusColor(item: Record<string, any>) {
|
||||
return POLICY_STATUS_COLORS[getPolicyStatus(item)] || 'default';
|
||||
}
|
||||
|
||||
watch(
|
||||
sysOriginOptions,
|
||||
(options) => {
|
||||
@ -499,6 +569,18 @@ onMounted(() => {
|
||||
{{ meta.policyTypeLabel }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div>
|
||||
<div class="policy-head__label">状态</div>
|
||||
<Tag :color="getPolicyStatusColor(data)">
|
||||
{{ getPolicyStatusLabel(data) }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div>
|
||||
<div class="policy-head__label">生效时间</div>
|
||||
<div class="policy-head__value">
|
||||
{{ data.effectiveStartTime ? formatDate(data.effectiveStartTime) : '-' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
@ -718,6 +800,12 @@ onMounted(() => {
|
||||
>
|
||||
保存并发布
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
@click="handleScheduleNextMonth"
|
||||
>
|
||||
保存并次月生效
|
||||
</Button>
|
||||
<Button @click="cancelEditing">
|
||||
返回
|
||||
</Button>
|
||||
@ -759,6 +847,9 @@ onMounted(() => {
|
||||
class="history-card"
|
||||
>
|
||||
<div class="history-card__tags">
|
||||
<Tag :color="getPolicyStatusColor(item)">
|
||||
{{ getPolicyStatusLabel(item) }}
|
||||
</Tag>
|
||||
<Tag
|
||||
v-if="item.historyRelease"
|
||||
color="green"
|
||||
@ -781,6 +872,12 @@ onMounted(() => {
|
||||
<div class="history-card__meta">
|
||||
创建时间: {{ formatDate(item.createTime) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="item.effectiveStartTime"
|
||||
class="history-card__meta"
|
||||
>
|
||||
生效时间: {{ formatDate(item.effectiveStartTime) }}
|
||||
</div>
|
||||
<Space>
|
||||
<Button
|
||||
size="small"
|
||||
@ -832,7 +929,7 @@ onMounted(() => {
|
||||
border-radius: 16px;
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
margin-bottom: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user