次月政策
This commit is contained in:
parent
9dbb25287d
commit
96c224f71d
@ -6,12 +6,16 @@ export interface LegacyPageResult<T = Record<string, any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LegacyTeamPolicyItem {
|
export interface LegacyTeamPolicyItem {
|
||||||
|
activatedTime?: number | string;
|
||||||
countryCode?: string;
|
countryCode?: string;
|
||||||
createTime?: number | string;
|
createTime?: number | string;
|
||||||
createUserNickname?: string;
|
createUserNickname?: string;
|
||||||
|
effectiveMonth?: number | string;
|
||||||
|
effectiveStartTime?: number | string;
|
||||||
historyRelease?: boolean;
|
historyRelease?: boolean;
|
||||||
id?: number | string;
|
id?: number | string;
|
||||||
policy?: Array<Record<string, any>>;
|
policy?: Array<Record<string, any>>;
|
||||||
|
policyStatus?: string;
|
||||||
policyType?: string;
|
policyType?: string;
|
||||||
region?: number | string;
|
region?: number | string;
|
||||||
release?: boolean;
|
release?: boolean;
|
||||||
|
|||||||
@ -74,6 +74,22 @@ const policies = ref<Array<Record<string, any>>>([]);
|
|||||||
const countryList = ref<Array<Record<string, any>>>([]);
|
const countryList = ref<Array<Record<string, any>>>([]);
|
||||||
const currentRewardRow = ref<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({
|
const query = reactive({
|
||||||
countryCode: '',
|
countryCode: '',
|
||||||
policyType: props.policyType === 'SALARY_DIAMOND' ? 'SALARY_DIAMOND' : '',
|
policyType: props.policyType === 'SALARY_DIAMOND' ? 'SALARY_DIAMOND' : '',
|
||||||
@ -111,9 +127,14 @@ const countryOptions = computed(() =>
|
|||||||
|
|
||||||
function createFormData() {
|
function createFormData() {
|
||||||
return {
|
return {
|
||||||
|
activatedTime: '',
|
||||||
countryCode: '',
|
countryCode: '',
|
||||||
|
effectiveMonth: '',
|
||||||
|
effectiveStartTime: '',
|
||||||
|
historyRelease: false,
|
||||||
id: '',
|
id: '',
|
||||||
policy: [] as Array<Record<string, any>>,
|
policy: [] as Array<Record<string, any>>,
|
||||||
|
policyStatus: 'DRAFT',
|
||||||
policyType: props.policyType,
|
policyType: props.policyType,
|
||||||
region: '',
|
region: '',
|
||||||
release: false,
|
release: false,
|
||||||
@ -306,8 +327,13 @@ function handleRewardSuccess(rewards: Array<Record<string, any>>) {
|
|||||||
|
|
||||||
function handleEditHistory(item: LegacyTeamPolicyItem) {
|
function handleEditHistory(item: LegacyTeamPolicyItem) {
|
||||||
policies.value = clonePolicies(item.policy);
|
policies.value = clonePolicies(item.policy);
|
||||||
|
formData.activatedTime = item.activatedTime ? String(item.activatedTime) : '';
|
||||||
formData.countryCode = item.countryCode ? String(item.countryCode) : query.countryCode;
|
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.id = item.id ? String(item.id) : '';
|
||||||
|
formData.policyStatus = item.policyStatus || (item.release ? 'ACTIVE' : 'DRAFT');
|
||||||
formData.region = item.region ? String(item.region) : '';
|
formData.region = item.region ? String(item.region) : '';
|
||||||
formData.title = item.title || '';
|
formData.title = item.title || '';
|
||||||
formData.release = Boolean(item.release);
|
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.countryCode = query.countryCode;
|
||||||
formData.policy = clonePolicies(policies.value).map(normalizePolicyItem);
|
formData.policy = clonePolicies(policies.value).map(normalizePolicyItem);
|
||||||
|
formData.policyStatus = policyStatus;
|
||||||
formData.region = query.region;
|
formData.region = query.region;
|
||||||
formData.release = release;
|
formData.release = release;
|
||||||
formData.sysOrigin = query.sysOrigin;
|
formData.sysOrigin = query.sysOrigin;
|
||||||
@ -357,10 +385,24 @@ async function persistPolicy(release: boolean) {
|
|||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await teamPolicyAdd({
|
const id = policyStatus === 'SCHEDULED' && previousPolicyStatus !== 'SCHEDULED'
|
||||||
|
? ''
|
||||||
|
: formData.id;
|
||||||
|
const payload: Record<string, any> = {
|
||||||
...formData,
|
...formData,
|
||||||
|
id,
|
||||||
title: String(formData.title || '').trim(),
|
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('保存成功');
|
message.success('保存成功');
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -369,13 +411,22 @@ async function persistPolicy(release: boolean) {
|
|||||||
|
|
||||||
function handleSave(release: boolean) {
|
function handleSave(release: boolean) {
|
||||||
if (!release) {
|
if (!release) {
|
||||||
void persistPolicy(false);
|
void persistPolicy(false, 'DRAFT');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确定对外发布当前政策吗?',
|
title: '确定对外发布当前政策吗?',
|
||||||
async onOk() {
|
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 || '-';
|
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(
|
watch(
|
||||||
sysOriginOptions,
|
sysOriginOptions,
|
||||||
(options) => {
|
(options) => {
|
||||||
@ -499,6 +569,18 @@ onMounted(() => {
|
|||||||
{{ meta.policyTypeLabel }}
|
{{ meta.policyTypeLabel }}
|
||||||
</Tag>
|
</Tag>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
@ -718,6 +800,12 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
保存并发布
|
保存并发布
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
@click="handleScheduleNextMonth"
|
||||||
|
>
|
||||||
|
保存并次月生效
|
||||||
|
</Button>
|
||||||
<Button @click="cancelEditing">
|
<Button @click="cancelEditing">
|
||||||
返回
|
返回
|
||||||
</Button>
|
</Button>
|
||||||
@ -759,6 +847,9 @@ onMounted(() => {
|
|||||||
class="history-card"
|
class="history-card"
|
||||||
>
|
>
|
||||||
<div class="history-card__tags">
|
<div class="history-card__tags">
|
||||||
|
<Tag :color="getPolicyStatusColor(item)">
|
||||||
|
{{ getPolicyStatusLabel(item) }}
|
||||||
|
</Tag>
|
||||||
<Tag
|
<Tag
|
||||||
v-if="item.historyRelease"
|
v-if="item.historyRelease"
|
||||||
color="green"
|
color="green"
|
||||||
@ -781,6 +872,12 @@ onMounted(() => {
|
|||||||
<div class="history-card__meta">
|
<div class="history-card__meta">
|
||||||
创建时间: {{ formatDate(item.createTime) }}
|
创建时间: {{ formatDate(item.createTime) }}
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="item.effectiveStartTime"
|
||||||
|
class="history-card__meta"
|
||||||
|
>
|
||||||
|
生效时间: {{ formatDate(item.effectiveStartTime) }}
|
||||||
|
</div>
|
||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
@ -832,7 +929,7 @@ onMounted(() => {
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user