|
|
@ -1,93 +1,140 @@ |
|
|
|
<template> |
|
|
|
<el-card style="margin-top:50px; min-height: 90vh; max-height: 90vh;"> |
|
|
|
<div class="data-settings"> |
|
|
|
<br><br><br><br><br> |
|
|
|
<el-button type="primary" @click="goBack"> |
|
|
|
<i class="el-icon-back"></i> 返回 |
|
|
|
</el-button> |
|
|
|
|
|
|
|
<el-card style="margin-top:50px; min-height: 90vh; max-height: 90vh;"> |
|
|
|
<div class="data-settings"> |
|
|
|
<!-- 返回按钮 --> |
|
|
|
<h3>数据设置:</h3> |
|
|
|
|
|
|
|
<br><br><br><br><br> |
|
|
|
<el-button type="primary" @click="goBack"> |
|
|
|
<i class="el-icon-back"></i> 返回 |
|
|
|
</el-button> |
|
|
|
<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> |
|
|
|
|
|
|
|
<h3>数据设置:</h3> |
|
|
|
<!-- 市场一 --> |
|
|
|
<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>设置初始数据:</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="initialData" placeholder="分钟" size="large"></el-input-number> |
|
|
|
分钟 |
|
|
|
|
|
|
|
<el-button type="primary" @click="openInitialConfirmDialog">确认</el-button> |
|
|
|
</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>当前美股助力次数:{{ usStockBoostCount }} 次</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="usStockAddCount" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
|
|
|
|
<el-button type="primary" @click="openConfirmDialog('us')">确认</el-button> |
|
|
|
|
|
|
|
<label>前端展示次数:{{ usStockDisplayCount }} 次</label> |
|
|
|
</div> |
|
|
|
<!-- 时间数据 --> |
|
|
|
<div class="setting-item"> |
|
|
|
<label>当前初始数据为:{{ initialData }} 分钟</label> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="setting-item"> |
|
|
|
<label>当前港股助力次数:{{ hkStockBoostCount }} 次</label> |
|
|
|
<el-input-number :precision="0" :min="0" v-model="hkStockAddCount" placeholder="设置添加次数" size="large"></el-input-number> |
|
|
|
|
|
|
|
<el-button type="primary" @click="openConfirmDialog('hk')">确认</el-button> |
|
|
|
|
|
|
|
<label>前端展示次数:{{ hkStockDisplayCount }} 次</label> |
|
|
|
</div> |
|
|
|
<!-- 确认对话框 --> |
|
|
|
<el-dialog v-model="showConfirmDialog" title="确认添加" width="30%"> |
|
|
|
<span>您确定要添加这些次数吗?</span> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="showConfirmDialog = false">取 消</el-button> |
|
|
|
<el-button type="primary" @click="confirmAdd">确 定</el-button> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 确认对话框 --> |
|
|
|
<el-dialog v-model="showConfirmDialog" title="确认添加" width="30%"> |
|
|
|
<span>您确定要添加这些次数吗?</span> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="showConfirmDialog = false">取 消</el-button> |
|
|
|
<el-button type="primary" @click="confirmAdd">确 定</el-button> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 初始数据确认对话框 --> |
|
|
|
<el-dialog v-model="showInitialConfirmDialog" title="确认设置初始数据" width="30%"> |
|
|
|
<span>您确定要设置初始数据为 {{ initialData }} 分钟吗?</span> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button @click="showInitialConfirmDialog = false">取 消</el-button> |
|
|
|
<el-button type="primary" @click="confirmInitialData">确 定</el-button> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</el-card> |
|
|
|
<!-- 初始数据确认对话框 --> |
|
|
|
<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> |
|
|
|
</div> |
|
|
|
</el-card> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { ref } from 'vue'; |
|
|
|
import { ref, onMounted } from 'vue'; |
|
|
|
import { useRouter } from 'vue-router'; |
|
|
|
|
|
|
|
import { showsetDetail , showaddDetail , setTime } from '@/api/manage/activity' |
|
|
|
import { useactivitytone } from '@/stone/activityStone' |
|
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
const router = useRouter(); |
|
|
|
const activityStone = useactivitytone() |
|
|
|
// 响应式数据 |
|
|
|
const initialData = ref(0); |
|
|
|
const setinitiaData = ref(0); |
|
|
|
const addCountOne = ref(null); |
|
|
|
const addCountTwo = ref(null); |
|
|
|
const showConfirmDialog = ref(false); |
|
|
|
const showInitialConfirmDialog = ref(false); |
|
|
|
const pendingAction = ref(null); // 存储待执行的操作类型 ('one' or 'two') |
|
|
|
|
|
|
|
// 数据定义 |
|
|
|
const initialData = ref(null); |
|
|
|
const usStockBoostCount = ref(234); |
|
|
|
const usStockAddCount = ref(null); |
|
|
|
const usStockDisplayCount = ref(345); |
|
|
|
// API返回的数据 |
|
|
|
const marketOne = ref(''); // 市场一类型 |
|
|
|
const marketTwo = ref(''); // 市场二类型 |
|
|
|
const markerOneTotal = ref(0); // 市场一总助力次数 |
|
|
|
const markerTwoTotal = ref(0); // 市场二总助力次数 |
|
|
|
const showOne = ref(0); // 市场一前端展示次数 |
|
|
|
const showTwo = ref(0); // 市场二前端展示次数 |
|
|
|
|
|
|
|
const hkStockBoostCount = ref(164); |
|
|
|
const hkStockAddCount = ref(null); |
|
|
|
const hkStockDisplayCount = ref(355); |
|
|
|
// 市场类型映射 |
|
|
|
// const marketNames = { |
|
|
|
// 'usa': '美股', |
|
|
|
// 'hk': '港股' |
|
|
|
// }; |
|
|
|
|
|
|
|
// 弹窗控制 |
|
|
|
const showConfirmDialog = ref(false); |
|
|
|
// 计算市场名称 |
|
|
|
const marketOneName = ref(''); |
|
|
|
const marketTwoName = ref(''); |
|
|
|
|
|
|
|
const showInitialConfirmDialog = ref(false); |
|
|
|
const pendingInitialData = ref(''); |
|
|
|
let pendingAction = ref(null); // 存储待执行的操作类型 ('us' or 'hk') |
|
|
|
// 获取数据 |
|
|
|
const fetchData = async () => { |
|
|
|
try { |
|
|
|
const response = await showsetDetail(activityStone.selectactivityId); |
|
|
|
const data = response.data; |
|
|
|
console.log(data); |
|
|
|
// 设置数据 |
|
|
|
marketOne.value = data.marketOne; |
|
|
|
marketTwo.value = data.marketTwo; |
|
|
|
markerOneTotal.value = data.markerOneTotal; |
|
|
|
markerTwoTotal.value = data.markerTwoTotal; |
|
|
|
showOne.value = data.showOne; |
|
|
|
showTwo.value = data.showTwo; |
|
|
|
initialData.value = data.time; |
|
|
|
|
|
|
|
// 设置市场名称 |
|
|
|
marketOneName.value = data.marketOne; |
|
|
|
marketTwoName.value = data.marketTwo; |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('获取数据失败:', error); |
|
|
|
// 可以添加错误处理逻辑 |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 组件挂载时获取数据 |
|
|
|
onMounted(() => { |
|
|
|
fetchData(); |
|
|
|
}); |
|
|
|
|
|
|
|
// 打开确认弹窗 |
|
|
|
const openConfirmDialog = (type) => { |
|
|
|
if ((type === 'us' && usStockAddCount.value) || (type === 'hk' && hkStockAddCount.value)) { |
|
|
|
if ((type === 'one' && addCountOne.value !== null) || |
|
|
|
(type === 'two' && addCountTwo.value !== null)) { |
|
|
|
pendingAction.value = type; |
|
|
|
showConfirmDialog.value = true; |
|
|
|
} |
|
|
@ -95,38 +142,122 @@ const openConfirmDialog = (type) => { |
|
|
|
|
|
|
|
// 打开初始数据确认弹窗 |
|
|
|
const openInitialConfirmDialog = () => { |
|
|
|
if (initialData.value) { |
|
|
|
pendingInitialData.value = initialData.value; |
|
|
|
if (initialData.value !== null) { |
|
|
|
showInitialConfirmDialog.value = true; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const cancelset = () => { |
|
|
|
showInitialConfirmDialog.value = false |
|
|
|
setinitiaData.value = 0 |
|
|
|
}; |
|
|
|
|
|
|
|
// 确定设置初始数据 |
|
|
|
// 确定设置初始数据 |
|
|
|
const confirmInitialData = () => { |
|
|
|
// 这里可以发送请求或保存数据 |
|
|
|
console.log('已设置初始数据:', pendingInitialData.value); |
|
|
|
const confirmInitialData = async () => { |
|
|
|
try { |
|
|
|
const id = activityStone.selectactivityId |
|
|
|
const time = setinitiaData.value |
|
|
|
|
|
|
|
// 清空输入框并关闭弹窗 |
|
|
|
initialData.value = null; |
|
|
|
showInitialConfirmDialog.value = false; |
|
|
|
}; |
|
|
|
if (!id) { |
|
|
|
ElMessage.warning('未获取到活动ID') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (time === null || time <= 0) { |
|
|
|
ElMessage.warning('请输入有效的分钟数') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const response = await setTime( |
|
|
|
id, |
|
|
|
time |
|
|
|
) |
|
|
|
|
|
|
|
if (response.code === 200) { |
|
|
|
await fetchData() |
|
|
|
showInitialConfirmDialog.value = false |
|
|
|
setinitiaData.value=0 |
|
|
|
ElMessage.success('设置成功') |
|
|
|
|
|
|
|
} else { |
|
|
|
ElMessage.error(response.message || '设置失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('设置初始数据失败:', error) |
|
|
|
ElMessage.error('请求失败,请重试') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 确定添加 |
|
|
|
const confirmAdd = () => { |
|
|
|
const confirmAdd = async () => { |
|
|
|
const type = pendingAction.value; |
|
|
|
if (type === 'us') { |
|
|
|
usStockBoostCount.value += parseInt(usStockAddCount.value); |
|
|
|
usStockDisplayCount.value = usStockBoostCount.value; |
|
|
|
usStockAddCount.value = null; |
|
|
|
} else if (type === 'hk') { |
|
|
|
hkStockBoostCount.value += parseInt(hkStockAddCount.value); |
|
|
|
hkStockDisplayCount.value = hkStockBoostCount.value; |
|
|
|
hkStockAddCount.value = null; |
|
|
|
|
|
|
|
if (type === 'one' && addCountOne.value !== null && addCountOne.value > 0) { |
|
|
|
markerOneTotal.value += parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
|
|
|
|
// 调用接口 |
|
|
|
try { |
|
|
|
const response = await showaddDetail( |
|
|
|
activityStone.selectactivityId, |
|
|
|
marketOne.value, |
|
|
|
addCountOne.value |
|
|
|
); |
|
|
|
|
|
|
|
if (response.code === 200) { |
|
|
|
fetchData(); |
|
|
|
ElMessage.success('助力次数添加成功'); |
|
|
|
} else { |
|
|
|
ElMessage.error(response.message || '添加失败'); |
|
|
|
// 可选:回滚操作 |
|
|
|
markerOneTotal.value -= parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
|
ElMessage.error('请求失败,请重试'); |
|
|
|
// 回滚操作 |
|
|
|
markerOneTotal.value -= parseInt(addCountOne.value); |
|
|
|
showOne.value = markerOneTotal.value; |
|
|
|
} |
|
|
|
|
|
|
|
addCountOne.value = null; |
|
|
|
|
|
|
|
} else if (type === 'two' && addCountTwo.value !== null && addCountTwo.value > 0) { |
|
|
|
markerTwoTotal.value += parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
|
|
|
|
// 调用接口 |
|
|
|
try { |
|
|
|
const response = await showaddDetail( |
|
|
|
activityStone.selectactivityId, |
|
|
|
marketTwo.value, |
|
|
|
addCountTwo.value |
|
|
|
); |
|
|
|
|
|
|
|
if (response.code === 200) { |
|
|
|
fetchData(); |
|
|
|
ElMessage.success('助力次数添加成功'); |
|
|
|
} else { |
|
|
|
ElMessage.error(response.message || '添加失败'); |
|
|
|
// 回滚 |
|
|
|
markerTwoTotal.value -= parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('添加助力次数失败:', error); |
|
|
|
ElMessage.error('请求失败,请重试'); |
|
|
|
// 回滚 |
|
|
|
markerTwoTotal.value -= parseInt(addCountTwo.value); |
|
|
|
showTwo.value = markerTwoTotal.value; |
|
|
|
} |
|
|
|
|
|
|
|
addCountTwo.value = null; |
|
|
|
} |
|
|
|
|
|
|
|
// 清空动作并关闭弹窗 |
|
|
|
pendingAction.value = null; |
|
|
|
showConfirmDialog.value = false; |
|
|
|
pendingAction.value = null; |
|
|
|
}; |
|
|
|
|
|
|
|
// 返回上一页 |
|
|
@ -135,45 +266,43 @@ const goBack = () => { |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.data-settings { |
|
|
|
background-color: #ffffff; |
|
|
|
padding: 40px; |
|
|
|
border-radius: 16px; |
|
|
|
width: 100%; |
|
|
|
max-width: 800px; |
|
|
|
margin: 0 auto; |
|
|
|
font-size: 1.2rem; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item { |
|
|
|
margin-bottom: 25px; |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: flex-start; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item label { |
|
|
|
margin-right: 20px; |
|
|
|
font-size: 1.1rem; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item input { |
|
|
|
width: 150px; |
|
|
|
height: 40px; |
|
|
|
font-size: 1.1rem; |
|
|
|
text-align: center; |
|
|
|
margin-right: 20px; |
|
|
|
} |
|
|
|
|
|
|
|
.el-button { |
|
|
|
height: 40px; |
|
|
|
font-size: 1.1rem; |
|
|
|
padding: 0 20px; |
|
|
|
} |
|
|
|
|
|
|
|
h3 { |
|
|
|
font-size: 1.8rem; |
|
|
|
margin-bottom: 20px; |
|
|
|
} |
|
|
|
</style> |
|
|
|
<style scoped> |
|
|
|
.data-settings { |
|
|
|
background-color: #ffffff; |
|
|
|
padding: 40px; |
|
|
|
border-radius: 16px; |
|
|
|
width: 100%; |
|
|
|
max-width: 800px; |
|
|
|
margin: 0 auto; |
|
|
|
font-size: 1.2rem; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item { |
|
|
|
margin-bottom: 25px; |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: flex-start; |
|
|
|
flex-wrap: wrap; |
|
|
|
} |
|
|
|
|
|
|
|
.setting-item label { |
|
|
|
margin-right: 20px; |
|
|
|
font-size: 1.1rem; |
|
|
|
min-width: 200px; |
|
|
|
} |
|
|
|
|
|
|
|
.el-input-number { |
|
|
|
width: 180px; |
|
|
|
} |
|
|
|
|
|
|
|
.el-button { |
|
|
|
height: 40px; |
|
|
|
font-size: 1.1rem; |
|
|
|
padding: 0 20px; |
|
|
|
} |
|
|
|
|
|
|
|
h3 { |
|
|
|
font-size: 1.8rem; |
|
|
|
margin-bottom: 20px; |
|
|
|
} |
|
|
|
</style> |