Browse Source

set只有一次+能输入负数

lihuilin/feature-20250718094329-25周年庆后台
wangxiangwen 4 weeks ago
parent
commit
14bcca097a
  1. 76
      activitylink/src/views/zhongchou/activity/set/index.vue
  2. 1
      activitylink/src/views/zhongchou/index.vue

76
activitylink/src/views/zhongchou/activity/set/index.vue

@ -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>
&nbsp;&nbsp;分钟
&nbsp;&nbsp;&nbsp;&nbsp;
<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>
&nbsp;&nbsp;分钟
&nbsp;&nbsp;&nbsp;&nbsp;
<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>
&nbsp;&nbsp;&nbsp;&nbsp;
<el-button type="primary" @click="openConfirmDialog('one')">确认</el-button>
&nbsp;&nbsp;&nbsp;&nbsp;
@ -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>
&nbsp;&nbsp;&nbsp;&nbsp;
<el-button type="primary" @click="openConfirmDialog('two')">确认</el-button>
&nbsp;&nbsp;&nbsp;&nbsp;
@ -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 {

1
activitylink/src/views/zhongchou/index.vue

@ -43,7 +43,6 @@ const handleLogout = () => {
console.error('退出错误:', error);
}
}).catch(() => {
router.back()
ElMessage.info('已取消退出');
});
};

Loading…
Cancel
Save