|
|
@ -8,38 +8,41 @@ |
|
|
|
|
|
|
|
<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> |
|
|
|
</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-button type="primary" @click="openConfirmDialog('one')">确认</el-button> |
|
|
|
|
|
|
|
<label>前端展示次数:{{ showOne }} 次</label> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 市场二 --> |
|
|
|
<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-button type="primary" @click="openConfirmDialog('two')">确认</el-button> |
|
|
|
|
|
|
|
<label>前端展示次数:{{ showTwo }} 次</label> |
|
|
|
</div> |
|
|
|
<!-- <div class="setting-item"> |
|
|
|
<label>初始数据:</label> |
|
|
|
<div>{{ initialData }}分钟</div> |
|
|
|
|
|
|
|
</div> --> |
|
|
|
|
|
|
|
<!-- 市场一 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<label class="fixed-label">当前{{ marketOneName }}市场助力次数:{{ markerOneTotal }} 次</label> |
|
|
|
<el-input v-model="addCountOne" |
|
|
|
placeholder="设置添加次数" |
|
|
|
size="large" |
|
|
|
class="fixed-input" |
|
|
|
|
|
|
|
@input="handleIntegerInput1"></el-input> |
|
|
|
<el-button type="primary" @click="openConfirmDialog('one')" class="fixed-button">确认</el-button> |
|
|
|
<label class="fixed-label">前端展示次数:{{ showOne }} 次</label> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 市场二 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<label class="fixed-label">当前{{ marketTwoName }}市场助力次数:{{ markerTwoTotal }} 次</label> |
|
|
|
<el-input v-model="addCountTwo" |
|
|
|
placeholder="设置添加次数" |
|
|
|
size="large" |
|
|
|
class="fixed-input" |
|
|
|
@input="handleIntegerInput2"></el-input> |
|
|
|
<el-button type="primary" @click="openConfirmDialog('two')" class="fixed-button">确认</el-button> |
|
|
|
<label class="fixed-label">前端展示次数:{{ showTwo }} 次</label> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 时间数据 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<!-- <div class="setting-item"> |
|
|
|
<label>当前初始数据为:{{ initialData }} 分钟</label> |
|
|
|
</div> |
|
|
|
</div> --> |
|
|
|
|
|
|
|
<!-- 确认对话框 --> |
|
|
|
<el-dialog v-model="showConfirmDialog" title="确认添加" width="30%"> |
|
|
@ -53,15 +56,15 @@ |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 初始数据确认对话框 --> |
|
|
|
<el-dialog v-model="showInitialConfirmDialog" title="确认设置初始数据" width="30%" @closed="cancelset"> |
|
|
|
<span>您确定要设置初始数据为 {{ setinitiaData }} 分钟吗?</span> |
|
|
|
<!-- <el-dialog v-model="showInitialConfirmDialog" title="确认设置初始数据" width="30%" @closed="cancelset"> |
|
|
|
<span>您确定要设置初始数据为 {{ setinitiaData }} 分钟吗?(只能修改一次!)</span> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="cancelset">取 消</el-button> |
|
|
|
<el-button type="primary" @click="confirmInitialData">确 定</el-button> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> --> |
|
|
|
</div> |
|
|
|
</el-card> |
|
|
|
</template> |
|
|
@ -82,7 +85,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(''); // 市场二类型 |
|
|
@ -128,7 +131,62 @@ const marketTwoName = ref(''); |
|
|
|
// } |
|
|
|
// }; |
|
|
|
|
|
|
|
const timerOne = ref(null); |
|
|
|
const timerTwo = ref(null); |
|
|
|
|
|
|
|
const handleIntegerInput1 = (value) => { |
|
|
|
// 清除之前的定时器 |
|
|
|
if (timerOne.value) { |
|
|
|
clearTimeout(timerOne.value); |
|
|
|
} |
|
|
|
|
|
|
|
// 1. 替换所有非数字和非负号的字符 |
|
|
|
let filtered = value.replace(/[^-0-9]/g, ''); |
|
|
|
|
|
|
|
// 2. 如果以负号开头,只保留第一个负号,其余负号删除 |
|
|
|
if (filtered.includes('-')) { |
|
|
|
const firstChar = filtered[0]; |
|
|
|
const rest = filtered.slice(1).replace(/-/g, ''); // 删除其余负号 |
|
|
|
filtered = firstChar === '-' ? '-' + rest : rest; |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 如果是单独的 '-',设置延迟校验 |
|
|
|
if (filtered === '-') { |
|
|
|
timerOne.value = setTimeout(() => { |
|
|
|
addCountOne.value = ''; |
|
|
|
timerOne.value = null; |
|
|
|
}, 1000); // 延迟200ms |
|
|
|
} else { |
|
|
|
// 4. 更新绑定值 |
|
|
|
addCountOne.value = filtered; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleIntegerInput2 = (value) => { |
|
|
|
// 清除之前的定时器 |
|
|
|
if (timerTwo.value) { |
|
|
|
clearTimeout(timerTwo.value); |
|
|
|
} |
|
|
|
|
|
|
|
// 同上逻辑 |
|
|
|
let filtered = value.replace(/[^-0-9]/g, ''); |
|
|
|
|
|
|
|
if (filtered.includes('-')) { |
|
|
|
const firstChar = filtered[0]; |
|
|
|
const rest = filtered.slice(1).replace(/-/g, ''); |
|
|
|
filtered = firstChar === '-' ? '-' + rest : rest; |
|
|
|
} |
|
|
|
|
|
|
|
// 如果是单独的 '-',设置延迟校验 |
|
|
|
if (filtered === '-') { |
|
|
|
timerTwo.value = setTimeout(() => { |
|
|
|
addCountTwo.value = ''; |
|
|
|
timerTwo.value = null; |
|
|
|
}, 1000); // 延迟200ms |
|
|
|
} else { |
|
|
|
addCountTwo.value = filtered; |
|
|
|
} |
|
|
|
}; |
|
|
|
const fetchData = async () => { |
|
|
|
try { |
|
|
|
// ✅ 修改传参方式为对象 |
|
|
@ -162,13 +220,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 +289,7 @@ const confirmInitialData = async () => { |
|
|
|
showInitialConfirmDialog.value = false |
|
|
|
setinitiaData.value=0 |
|
|
|
ElMessage.success('设置成功') |
|
|
|
ifshow(); |
|
|
|
|
|
|
|
} else { |
|
|
|
ElMessage.error(response.message || '设置失败') |
|
|
@ -235,7 +304,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 +326,7 @@ const confirmAdd = async () => { |
|
|
|
// 可选:回滚操作 |
|
|
|
markerOneTotal.value -= parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
fetchData(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
@ -267,7 +338,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 +359,7 @@ const confirmAdd = async () => { |
|
|
|
// 回滚 |
|
|
|
markerTwoTotal.value -= parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
fetchData(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
@ -325,25 +398,72 @@ 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; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
margin-bottom: 25px; |
|
|
|
} |
|
|
|
|
|
|
|
.fixed-label { |
|
|
|
width: 250px; /* 固定宽度 */ |
|
|
|
text-align: left; /* 右对齐,更美观 */ |
|
|
|
margin-right: 20px; /* 固定间距 */ |
|
|
|
white-space: nowrap; /* 防止换行 */ |
|
|
|
} |
|
|
|
|
|
|
|
.fixed-input { |
|
|
|
width: 230px; /* 固定宽度 */ |
|
|
|
margin-right: 30px; /* 固定间距 */ |
|
|
|
} |
|
|
|
|
|
|
|
.fixed-button { |
|
|
|
margin-right: 20px; /* 固定间距 */ |
|
|
|
} |
|
|
|
|
|
|
|
/* 确保最后一个 label 不需要右边距 */ |
|
|
|
.setting-item .fixed-label:last-child { |
|
|
|
margin-right: 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
h3 { |
|
|
|
font-size: 1.8rem; |
|
|
|
margin-bottom: 20px; |
|
|
|