|
|
@ -9,17 +9,21 @@ |
|
|
|
<h3>数据设置:</h3> |
|
|
|
|
|
|
|
<div class="setting-item"> |
|
|
|
<label>设置初始数据:</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="setinitiaData" placeholder="分钟" size="large"></el-input-number> |
|
|
|
分钟 |
|
|
|
|
|
|
|
<el-button type="primary" @click="openInitialConfirmDialog">确认</el-button> |
|
|
|
<label>初始数据:</label> |
|
|
|
<div v-if="!isInitialDataSet"> |
|
|
|
<el-input-number :precision="0" v-model="setinitiaData" placeholder="分钟" size="large"></el-input-number> |
|
|
|
分钟 |
|
|
|
|
|
|
|
<el-button type="primary" @click="openInitialConfirmDialog">确认</el-button> |
|
|
|
</div> |
|
|
|
<div v-if="isInitialDataSet">{{ initialData }}分钟</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 市场一 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<label>当前{{ marketOneName }}市场助力次数:{{ markerOneTotal }} 次</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="addCountOne" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
<el-input-number :precision="0" v-model="addCountOne" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
|
|
|
|
<el-button type="primary" @click="openConfirmDialog('one')">确认</el-button> |
|
|
|
|
|
|
@ -29,7 +33,7 @@ |
|
|
|
<!-- 市场二 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<label>当前{{ marketTwoName }}市场助力次数:{{ markerTwoTotal }} 次</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="addCountTwo" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
<el-input-number :precision="0" v-model="addCountTwo" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
|
|
|
|
<el-button type="primary" @click="openConfirmDialog('two')">确认</el-button> |
|
|
|
|
|
|
@ -37,9 +41,9 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 时间数据 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<!-- <div class="setting-item"> |
|
|
|
<label>当前初始数据为:{{ initialData }} 分钟</label> |
|
|
|
</div> |
|
|
|
</div> --> |
|
|
|
|
|
|
|
<!-- 确认对话框 --> |
|
|
|
<el-dialog v-model="showConfirmDialog" title="确认添加" width="30%"> |
|
|
@ -54,7 +58,7 @@ |
|
|
|
|
|
|
|
<!-- 初始数据确认对话框 --> |
|
|
|
<el-dialog v-model="showInitialConfirmDialog" title="确认设置初始数据" width="30%" @closed="cancelset"> |
|
|
|
<span>您确定要设置初始数据为 {{ setinitiaData }} 分钟吗?</span> |
|
|
|
<span>您确定要设置初始数据为 {{ setinitiaData }} 分钟吗?(只能修改一次!)</span> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="cancelset">取 消</el-button> |
|
|
@ -82,7 +86,7 @@ const addCountTwo = ref(null); |
|
|
|
const showConfirmDialog = ref(false); |
|
|
|
const showInitialConfirmDialog = ref(false); |
|
|
|
const pendingAction = ref(null); // 存储待执行的操作类型 ('one' or 'two') |
|
|
|
|
|
|
|
const isInitialDataSet = ref(false); // 用于跟踪初始数据是否已经设置 |
|
|
|
// API返回的数据 |
|
|
|
const marketOne = ref(''); // 市场一类型 |
|
|
|
const marketTwo = ref(''); // 市场二类型 |
|
|
@ -162,13 +166,23 @@ const fetchData = async () => { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ifshow = () =>{ |
|
|
|
if(initialData.value >0) |
|
|
|
{ |
|
|
|
isInitialDataSet.value = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isInitialDataSet.value = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 组件挂载时获取数据 |
|
|
|
onMounted(() => { |
|
|
|
fetchData(); |
|
|
|
onMounted(async () => { |
|
|
|
await fetchData(); |
|
|
|
ifshow(); |
|
|
|
}); |
|
|
|
|
|
|
|
// 打开确认弹窗 |
|
|
@ -221,6 +235,7 @@ const confirmInitialData = async () => { |
|
|
|
showInitialConfirmDialog.value = false |
|
|
|
setinitiaData.value=0 |
|
|
|
ElMessage.success('设置成功') |
|
|
|
ifshow(); |
|
|
|
|
|
|
|
} else { |
|
|
|
ElMessage.error(response.message || '设置失败') |
|
|
@ -235,7 +250,8 @@ const confirmInitialData = async () => { |
|
|
|
const confirmAdd = async () => { |
|
|
|
const type = pendingAction.value; |
|
|
|
|
|
|
|
if (type === 'one' && addCountOne.value !== null && addCountOne.value > 0) { |
|
|
|
// 修改市场一的验证逻辑,移除 > 0 的检查 |
|
|
|
if (type === 'one' && addCountOne.value !== null && addCountOne.value !== 0) { |
|
|
|
markerOneTotal.value += parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
|
|
|
@ -256,6 +272,7 @@ const confirmAdd = async () => { |
|
|
|
// 可选:回滚操作 |
|
|
|
markerOneTotal.value -= parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
fetchData(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
@ -267,7 +284,8 @@ const confirmAdd = async () => { |
|
|
|
|
|
|
|
addCountOne.value = null; |
|
|
|
|
|
|
|
} else if (type === 'two' && addCountTwo.value !== null && addCountTwo.value > 0) { |
|
|
|
// 修改市场二的验证逻辑,移除 > 0 的检查 |
|
|
|
} else if (type === 'two' && addCountTwo.value !== null && addCountTwo.value !== 0) { |
|
|
|
markerTwoTotal.value += parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
|
|
|
@ -287,6 +305,7 @@ const confirmAdd = async () => { |
|
|
|
// 回滚 |
|
|
|
markerTwoTotal.value -= parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
fetchData(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
@ -325,23 +344,42 @@ const goBack = () => { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: flex-start; |
|
|
|
flex-wrap: wrap; |
|
|
|
flex-wrap: nowrap; |
|
|
|
gap: 15px; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item label { |
|
|
|
margin-right: 20px; |
|
|
|
font-size: 1.1rem; |
|
|
|
min-width: 200px; |
|
|
|
white-space: nowrap; |
|
|
|
flex: 0 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
/* 专门针对带有展示次数的项(市场一和市场二) */ |
|
|
|
.setting-item.has-show-label { |
|
|
|
flex-wrap: wrap; |
|
|
|
} |
|
|
|
|
|
|
|
/* 为市场项添加特殊处理 */ |
|
|
|
.setting-item:has(.el-input-number) label:first-child { |
|
|
|
flex: 0 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
/* 将展示次数标签推向右侧 */ |
|
|
|
.setting-item:has(.el-input-number) label:last-child { |
|
|
|
margin-left: auto; |
|
|
|
flex: 0 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
.el-input-number { |
|
|
|
width: 180px; |
|
|
|
flex: 0 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
.el-button { |
|
|
|
height: 40px; |
|
|
|
font-size: 1.1rem; |
|
|
|
padding: 0 20px; |
|
|
|
flex: 0 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
h3 { |
|
|
|