CP解绑金币
This commit is contained in:
parent
e4147ec2fa
commit
0730d0609a
@ -33,6 +33,14 @@ interface CpLevelConfig {
|
||||
requiredIntimacyValue: number;
|
||||
}
|
||||
|
||||
type RelationType = 'BROTHER' | 'CP' | 'SISTERS';
|
||||
|
||||
const relationTypeOptions: Array<{ label: string; value: RelationType }> = [
|
||||
{ label: 'CP', value: 'CP' },
|
||||
{ label: 'Brother', value: 'BROTHER' },
|
||||
{ label: 'Sisters', value: 'SISTERS' },
|
||||
];
|
||||
|
||||
function defaultLevel(level: number): CpLevelConfig {
|
||||
return {
|
||||
cabinConfigId: null,
|
||||
@ -46,6 +54,14 @@ function defaultLevels() {
|
||||
return Array.from({ length: 5 }, (_, index) => defaultLevel(index + 1));
|
||||
}
|
||||
|
||||
function defaultDismissConsumeGolds(): Record<RelationType, number> {
|
||||
return {
|
||||
BROTHER: 0,
|
||||
CP: 0,
|
||||
SISTERS: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const accessStore = useAccessStore();
|
||||
const sysOriginOptions = computed(() => {
|
||||
const options = getAllowedSysOrigins(accessStore.accessCodes || []);
|
||||
@ -68,6 +84,7 @@ const columns = [
|
||||
|
||||
const form = reactive({
|
||||
configured: false,
|
||||
dismissConsumeGolds: defaultDismissConsumeGolds(),
|
||||
sysOrigin: '',
|
||||
levels: defaultLevels(),
|
||||
});
|
||||
@ -96,10 +113,16 @@ function normalizeLevels(levels: Array<Record<string, any>> | undefined) {
|
||||
|
||||
function applyConfig(result: Record<string, any> | null | undefined) {
|
||||
const value = result ?? {};
|
||||
const dismissConsumeGolds = value.dismissConsumeGolds || {};
|
||||
form.configured = Boolean(value.configured);
|
||||
form.sysOrigin = String(
|
||||
value.sysOrigin || form.sysOrigin || sysOriginOptions.value[0]?.value || '',
|
||||
);
|
||||
form.dismissConsumeGolds = {
|
||||
BROTHER: Number(dismissConsumeGolds.BROTHER || 0),
|
||||
CP: Number(dismissConsumeGolds.CP || 0),
|
||||
SISTERS: Number(dismissConsumeGolds.SISTERS || 0),
|
||||
};
|
||||
form.levels = normalizeLevels(value.levels);
|
||||
}
|
||||
|
||||
@ -117,6 +140,13 @@ async function loadConfig() {
|
||||
}
|
||||
|
||||
function validateLevels() {
|
||||
for (const item of relationTypeOptions) {
|
||||
const gold = Number(form.dismissConsumeGolds[item.value] || 0);
|
||||
if (gold < 0) {
|
||||
message.error(`${item.label} 解绑金币不能小于 0`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
let previous = -1;
|
||||
for (const item of form.levels) {
|
||||
const requiredValue = Number(item.requiredIntimacyValue || 0);
|
||||
@ -133,6 +163,14 @@ function validateLevels() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildDismissConsumeGolds() {
|
||||
const result = defaultDismissConsumeGolds();
|
||||
for (const item of relationTypeOptions) {
|
||||
result[item.value] = Number(form.dismissConsumeGolds[item.value] || 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
if (!validateLevels()) {
|
||||
return;
|
||||
@ -141,6 +179,7 @@ async function submitForm() {
|
||||
try {
|
||||
await saveResidentCpConfig({
|
||||
sysOrigin: form.sysOrigin,
|
||||
dismissConsumeGolds: buildDismissConsumeGolds(),
|
||||
levels: form.levels.map((item) => ({
|
||||
cabinConfigId: item.cabinConfigId || null,
|
||||
level: item.level,
|
||||
@ -160,8 +199,8 @@ function handleSave() {
|
||||
async onOk() {
|
||||
await submitForm();
|
||||
},
|
||||
title: '确认保存 CP 等级积分配置?',
|
||||
content: '保存后 Flutter 端 CP 权益配置接口会读取新的 5 级亲密值。',
|
||||
title: '确认保存 CP 配置?',
|
||||
content: '保存后 Flutter 端 CP 权益配置接口会读取新的等级亲密值和解绑金币。',
|
||||
});
|
||||
}
|
||||
|
||||
@ -189,7 +228,7 @@ watch(
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Spin :spinning="loading">
|
||||
<Card :bordered="false" title="CP 等级积分配置">
|
||||
<Card :bordered="false" title="CP 配置">
|
||||
<Space class="toolbar" wrap>
|
||||
<Select
|
||||
v-model:value="form.sysOrigin"
|
||||
@ -208,6 +247,23 @@ watch(
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
<div class="section-title">解绑金币配置</div>
|
||||
<Space class="gold-fields" wrap>
|
||||
<div
|
||||
v-for="item in relationTypeOptions"
|
||||
:key="item.value"
|
||||
class="gold-field"
|
||||
>
|
||||
<div class="field-label">{{ item.label }}</div>
|
||||
<InputNumber
|
||||
v-model:value="form.dismissConsumeGolds[item.value]"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
style="width: 180px"
|
||||
/>
|
||||
</div>
|
||||
</Space>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="form.levels"
|
||||
@ -244,4 +300,18 @@ watch(
|
||||
.toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 8px 0 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.gold-fields {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
margin-bottom: 6px;
|
||||
color: rgb(80 80 80);
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user