|
|
|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
<ElDialog
|
|
|
|
|
v-model="visible"
|
|
|
|
|
:title="$t('page.configPage.createRefPreviewTitle')"
|
|
|
|
|
width="980px"
|
|
|
|
|
width="860px"
|
|
|
|
|
align-center
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
@close="handleClose"
|
|
|
|
|
@@ -31,15 +31,26 @@
|
|
|
|
|
size="small"
|
|
|
|
|
class="preview-table"
|
|
|
|
|
>
|
|
|
|
|
<ElTableColumn :label="$t('page.table.dicePoints')" prop="grid_number" width="120" align="center" />
|
|
|
|
|
<ElTableColumn label="start_index" prop="start_index" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.endIndex')" prop="id" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.tier')" prop="tier" width="90" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.displayText')" prop="ui_text" min-width="110" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.realEv')" prop="real_ev" width="110" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.remark')" prop="remark" min-width="140" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.weight')" prop="weight" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.configPage.createRefPreviewDiff')" min-width="220" align="center">
|
|
|
|
|
<ElTableColumn :label="$t('page.table.dicePoints')" prop="grid_number" width="90" align="center" />
|
|
|
|
|
<ElTableColumn label="start" prop="start_index" width="78" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.endIndex')" prop="id" width="78" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.displayText')" prop="ui_text" width="90" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.realEv')" prop="real_ev" width="90" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.remark')" prop="remark" min-width="80" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.weight')" width="130" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<ElInputNumber
|
|
|
|
|
v-model="row.weight"
|
|
|
|
|
:min="1"
|
|
|
|
|
:max="10000"
|
|
|
|
|
:step="1"
|
|
|
|
|
controls-position="right"
|
|
|
|
|
size="small"
|
|
|
|
|
class="weight-input"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</ElTableColumn>
|
|
|
|
|
<ElTableColumn :label="$t('page.configPage.createRefPreviewDiff')" min-width="120" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<span v-if="row?.diff_changed" class="diff-text">
|
|
|
|
|
{{ formatDiff(row) }}
|
|
|
|
|
@@ -62,15 +73,26 @@
|
|
|
|
|
size="small"
|
|
|
|
|
class="preview-table"
|
|
|
|
|
>
|
|
|
|
|
<ElTableColumn :label="$t('page.table.dicePoints')" prop="grid_number" width="120" align="center" />
|
|
|
|
|
<ElTableColumn label="start_index" prop="start_index" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.endIndex')" prop="id" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.tier')" prop="tier" width="90" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.displayText')" prop="ui_text" min-width="110" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.realEv')" prop="real_ev" width="110" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.remark')" prop="remark" min-width="140" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.weight')" prop="weight" width="110" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.configPage.createRefPreviewDiff')" min-width="220" align="center">
|
|
|
|
|
<ElTableColumn :label="$t('page.table.dicePoints')" prop="grid_number" width="90" align="center" />
|
|
|
|
|
<ElTableColumn label="start" prop="start_index" width="78" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.endIndex')" prop="id" width="78" align="center" />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.displayText')" prop="ui_text" width="90" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.realEv')" prop="real_ev" width="90" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.remark')" prop="remark" min-width="80" align="center" show-overflow-tooltip />
|
|
|
|
|
<ElTableColumn :label="$t('page.table.weight')" width="120" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<ElInputNumber
|
|
|
|
|
v-model="row.weight"
|
|
|
|
|
:min="1"
|
|
|
|
|
:max="10000"
|
|
|
|
|
:step="1"
|
|
|
|
|
controls-position="right"
|
|
|
|
|
size="small"
|
|
|
|
|
class="weight-input"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</ElTableColumn>
|
|
|
|
|
<ElTableColumn :label="$t('page.configPage.createRefPreviewDiff')" min-width="120" align="center">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<span v-if="row?.diff_changed" class="diff-text">
|
|
|
|
|
{{ formatDiff(row) }}
|
|
|
|
|
@@ -175,15 +197,74 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toWeight(v: unknown): number {
|
|
|
|
|
const num = typeof v === 'number' && !Number.isNaN(v) ? v : Number(v)
|
|
|
|
|
if (Number.isNaN(num)) return 1
|
|
|
|
|
return Math.max(1, Math.min(10000, Math.floor(num)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function collectDesiredWeights(): Record<string, number> {
|
|
|
|
|
const map: Record<string, number> = {}
|
|
|
|
|
for (const t of tierKeys) {
|
|
|
|
|
const tierData = preview.value?.[t]
|
|
|
|
|
if (!tierData) continue
|
|
|
|
|
const cw = Array.isArray(tierData[0]) ? tierData[0] : []
|
|
|
|
|
const ccw = Array.isArray(tierData[1]) ? tierData[1] : []
|
|
|
|
|
for (const r of cw) {
|
|
|
|
|
const gn = r?.grid_number != null ? Number(r.grid_number) : NaN
|
|
|
|
|
if (!Number.isNaN(gn)) map[`0:${gn}`] = toWeight(r?.weight)
|
|
|
|
|
}
|
|
|
|
|
for (const r of ccw) {
|
|
|
|
|
const gn = r?.grid_number != null ? Number(r.grid_number) : NaN
|
|
|
|
|
if (!Number.isNaN(gn)) map[`1:${gn}`] = toWeight(r?.weight)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return map
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function applyWeights(desired: Record<string, number>) {
|
|
|
|
|
const res: any = await api.weightRatioList({ dept_id: props.deptId })
|
|
|
|
|
const raw = res?.data ?? res
|
|
|
|
|
const items: Array<{ id: number; weight: number }> = []
|
|
|
|
|
for (const t of tierKeys) {
|
|
|
|
|
const tierData = raw?.[t]
|
|
|
|
|
if (!tierData) continue
|
|
|
|
|
const list0 = Array.isArray(tierData[0]) ? tierData[0] : []
|
|
|
|
|
const list1 = Array.isArray(tierData[1]) ? tierData[1] : []
|
|
|
|
|
for (const r of list0) {
|
|
|
|
|
const rid = r?.reward_id != null ? Number(r.reward_id) : 0
|
|
|
|
|
const gn = r?.grid_number != null ? Number(r.grid_number) : NaN
|
|
|
|
|
if (rid > 0 && !Number.isNaN(gn)) {
|
|
|
|
|
const w = desired[`0:${gn}`]
|
|
|
|
|
if (w != null) items.push({ id: rid, weight: w })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (const r of list1) {
|
|
|
|
|
const rid = r?.reward_id != null ? Number(r.reward_id) : 0
|
|
|
|
|
const gn = r?.grid_number != null ? Number(r.grid_number) : NaN
|
|
|
|
|
if (rid > 0 && !Number.isNaN(gn)) {
|
|
|
|
|
const w = desired[`1:${gn}`]
|
|
|
|
|
if (w != null) items.push({ id: rid, weight: w })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (items.length > 0) {
|
|
|
|
|
await api.batchUpdateWeights(items, { dept_id: props.deptId })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleImport() {
|
|
|
|
|
submitting.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res: any = await api.createRewardReference({ dept_id: props.deptId })
|
|
|
|
|
const data = res?.data ?? res
|
|
|
|
|
if (data?.unchanged) {
|
|
|
|
|
ElMessage.success(t('page.configPage.createRefPreviewImportNoop'))
|
|
|
|
|
} else {
|
|
|
|
|
const desired = collectDesiredWeights()
|
|
|
|
|
if (!meta.unchanged) {
|
|
|
|
|
await api.createRewardReference({ dept_id: props.deptId })
|
|
|
|
|
await applyWeights(desired)
|
|
|
|
|
ElMessage.success(t('page.configPage.createRefPreviewImportOk'))
|
|
|
|
|
} else {
|
|
|
|
|
// 映射未变化:直接保存权重即可
|
|
|
|
|
await applyWeights(desired)
|
|
|
|
|
ElMessage.success(t('page.configPage.createRefPreviewWeightsSaved'))
|
|
|
|
|
}
|
|
|
|
|
emit('success')
|
|
|
|
|
handleClose()
|
|
|
|
|
@@ -210,12 +291,12 @@
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.dialog-body {
|
|
|
|
|
min-height: 240px;
|
|
|
|
|
min-height: 120px;
|
|
|
|
|
}
|
|
|
|
|
.preview-tip {
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
padding: 10px 12px;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
padding: 8px 10px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: var(--el-text-color-regular);
|
|
|
|
|
background: var(--el-fill-color-light);
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
@@ -225,7 +306,10 @@
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
}
|
|
|
|
|
.preview-table {
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
}
|
|
|
|
|
.weight-input {
|
|
|
|
|
width: 110px;
|
|
|
|
|
}
|
|
|
|
|
:deep(.row-diff td) {
|
|
|
|
|
background: var(--el-color-warning-light-9);
|
|
|
|
|
@@ -239,5 +323,23 @@
|
|
|
|
|
.diff-text-ok {
|
|
|
|
|
color: var(--el-text-color-secondary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 减少弹窗内容区与表格留白 */
|
|
|
|
|
:deep(.el-dialog__body) {
|
|
|
|
|
padding: 12px 14px;
|
|
|
|
|
}
|
|
|
|
|
:deep(.el-tabs__header) {
|
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
|
}
|
|
|
|
|
:deep(.el-tabs__item) {
|
|
|
|
|
height: 34px;
|
|
|
|
|
line-height: 34px;
|
|
|
|
|
}
|
|
|
|
|
:deep(.el-table .cell) {
|
|
|
|
|
padding: 4px 6px;
|
|
|
|
|
}
|
|
|
|
|
:deep(.el-table__row) {
|
|
|
|
|
height: 34px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|