main
parent
bbeda9e09f
commit
d2b82cba13
@ -0,0 +1,52 @@
|
|||||||
|
import request from "../utils/request";
|
||||||
|
|
||||||
|
// 获取彩票列表
|
||||||
|
export function getLotteryListApi(page, limit, classify) {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/${page}/${limit}?classify=${classify}`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取今日开奖通告
|
||||||
|
export function getTodayLotteryApi() {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/last`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取彩票详情
|
||||||
|
export function getLotteryDetailApi(id) {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/get/${id}`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除彩票记录
|
||||||
|
export function deleteLotteryApi(id) {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/remove/${id}`,
|
||||||
|
method: "delete",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存彩票记录
|
||||||
|
export function saveLotteryApi(data) {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/save`,
|
||||||
|
method: "post",
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新彩票记录
|
||||||
|
export function updateLotteryApi(data) {
|
||||||
|
return request({
|
||||||
|
url: `/admin/lottery/update`,
|
||||||
|
method: "put",
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,207 @@
|
|||||||
|
<template>
|
||||||
|
<div class="game-management">
|
||||||
|
<a-tabs v-model:activeKey="activeTab">
|
||||||
|
<a-tab-pane v-for="type in gameTypes" :key="type.key" :tab="type.label">
|
||||||
|
<a-table :columns="columns" :data-source="filteredData" :rowKey="record => record.id">
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<a-space>
|
||||||
|
<a-button type="link" @click="editItem(record)">编辑</a-button>
|
||||||
|
<a-button type="link" @click="deleteItem(record)">删除</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-tab-pane>
|
||||||
|
<template #rightExtra>
|
||||||
|
<a-button type="primary" @click="showAddModal">新增</a-button>
|
||||||
|
</template>
|
||||||
|
</a-tabs>
|
||||||
|
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="modalVisible"
|
||||||
|
:title="(modalMode === 'add' ? '新增' : '编辑') + currentGameTypeLabel"
|
||||||
|
@ok="handleModalOk"
|
||||||
|
@cancel="handleModalCancel"
|
||||||
|
width="600px"
|
||||||
|
>
|
||||||
|
<a-form :model="formState" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||||
|
<a-form-item label="日期" name="date" :rules="[{ required: true, message: '请选择日期' }]">
|
||||||
|
<a-date-picker v-model:value="formState.date" style="width: 100%" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="比赛" name="match" :rules="[{ required: true, message: '请输入比赛' }]">
|
||||||
|
<a-input v-model:value="formState.match" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="玩法" name="playType" :rules="[{ required: true, message: '请输入玩法' }]">
|
||||||
|
<a-input v-model:value="formState.playType" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="方向" name="direction" :rules="[{ required: true, message: '请输入方向' }]">
|
||||||
|
<a-input v-model:value="formState.direction" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="SP值" name="spValue" :rules="[{ required: true, message: '请输入SP值' }]">
|
||||||
|
<a-input-number v-model:value="formState.spValue" :min="0" :step="0.01" style="width: 100%" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, reactive, computed, onMounted } from 'vue';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
const gameTypes = [
|
||||||
|
{ key: 'julong_zhongaobei', label: '聚龙中高倍' },
|
||||||
|
{ key: 'julong_zongjinqiu', label: '聚龙总进球' },
|
||||||
|
{ key: 'julong_shibei', label: '聚龙十倍' },
|
||||||
|
{ key: 'julong_2', label: '聚龙2.0' },
|
||||||
|
{ key: 'julong_gaobei', label: '聚龙高倍' },
|
||||||
|
{ key: 'julong_lanqiu', label: '聚龙篮球' },
|
||||||
|
{ key: 'julong_3', label: '聚龙3.0' },
|
||||||
|
{ key: 'julong_pailie3', label: '聚龙排列三' },
|
||||||
|
{ key: 'julong_kuaile8', label: '聚龙快乐八' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const activeTab = ref(gameTypes[0].key);
|
||||||
|
const modalVisible = ref(false);
|
||||||
|
const modalMode = ref('add');
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{ title: '日期', dataIndex: 'date', key: 'date' },
|
||||||
|
{ title: '比赛', dataIndex: 'match', key: 'match' },
|
||||||
|
{ title: '玩法', dataIndex: 'playType', key: 'playType' },
|
||||||
|
{ title: '方向', dataIndex: 'direction', key: 'direction' },
|
||||||
|
{ title: 'SP值', dataIndex: 'spValue', key: 'spValue' },
|
||||||
|
{ title: '操作', key: 'action' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const data = reactive({});
|
||||||
|
gameTypes.forEach(type => {
|
||||||
|
data[type.key] = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
const formState = reactive({
|
||||||
|
id: null,
|
||||||
|
date: dayjs(),
|
||||||
|
match: '',
|
||||||
|
playType: '',
|
||||||
|
direction: '',
|
||||||
|
spValue: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const filteredData = computed(() => {
|
||||||
|
return data[activeTab.value] || [];
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentGameTypeLabel = computed(() => {
|
||||||
|
return gameTypes.find(type => type.key === activeTab.value)?.label || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
const showAddModal = () => {
|
||||||
|
modalMode.value = 'add';
|
||||||
|
Object.assign(formState, {
|
||||||
|
id: null,
|
||||||
|
date: dayjs(),
|
||||||
|
match: '',
|
||||||
|
playType: '',
|
||||||
|
direction: '',
|
||||||
|
spValue: 0
|
||||||
|
});
|
||||||
|
modalVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const editItem = (record) => {
|
||||||
|
modalMode.value = 'edit';
|
||||||
|
Object.assign(formState, {
|
||||||
|
...record,
|
||||||
|
date: dayjs(record.date),
|
||||||
|
});
|
||||||
|
modalVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteItem = async (record) => {
|
||||||
|
try {
|
||||||
|
// Implement API call to delete item
|
||||||
|
// await deleteGameApi(record.id);
|
||||||
|
const index = data[activeTab.value].findIndex(item => item.id === record.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
data[activeTab.value].splice(index, 1);
|
||||||
|
}
|
||||||
|
message.success('删除成功');
|
||||||
|
} catch (error) {
|
||||||
|
message.error('删除失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleModalOk = async () => {
|
||||||
|
try {
|
||||||
|
const newData = {
|
||||||
|
...formState,
|
||||||
|
date: formState.date.format('YYYY-MM-DD'),
|
||||||
|
};
|
||||||
|
if (modalMode.value === 'add') {
|
||||||
|
// Implement API call to add item
|
||||||
|
// const response = await addGameApi(newData);
|
||||||
|
// newData.id = response.data.id;
|
||||||
|
newData.id = Date.now(); // Temporary ID for demonstration
|
||||||
|
data[activeTab.value].push(newData);
|
||||||
|
} else {
|
||||||
|
// Implement API call to update item
|
||||||
|
// await updateGameApi(newData);
|
||||||
|
const index = data[activeTab.value].findIndex(item => item.id === newData.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
data[activeTab.value][index] = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message.success(modalMode.value === 'add' ? '添加成功' : '编辑成功');
|
||||||
|
modalVisible.value = false;
|
||||||
|
} catch (error) {
|
||||||
|
message.error(modalMode.value === 'add' ? '添加失败' : '编辑失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleModalCancel = () => {
|
||||||
|
modalVisible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
// Implement API call to fetch data for each game type
|
||||||
|
// For now, we'll use mock data
|
||||||
|
gameTypes.forEach(type => {
|
||||||
|
data[type.key] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
date: '2023-05-20',
|
||||||
|
match: '曼城 vs 切尔西',
|
||||||
|
playType: '让球',
|
||||||
|
direction: '主队',
|
||||||
|
spValue: 1.75,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
date: '2023-05-21',
|
||||||
|
match: '利物浦 vs 阿森纳',
|
||||||
|
playType: '大小球',
|
||||||
|
direction: '大球',
|
||||||
|
spValue: 2.05,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
message.error('获取数据失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchData();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.game-management {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
Loading…
Reference in New Issue