Browse Source

Merge branch 'dev' of http://39.101.133.168:8807/qimaohong/deepChartBack into dev

zhaowenkang/feature-20260206140254-后台AI复盘二期
songjie 4 weeks ago
parent
commit
dc202c7a24
  1. 3
      .env.development
  2. 3
      .env.production
  3. 56
      src/api/eventManagement.js
  4. 76
      src/layout/Layout.vue
  5. 26
      src/router/index.js
  6. 568
      src/views/EventManagement/ContentConfiguration.vue
  7. 426
      src/views/EventManagement/WinningRecords.vue

3
.env.development

@ -1,2 +1,3 @@
VITE_API_BASE_URL = "https://dbqb.legu168.cn/adminApi"
VITE_API_BASE_URL_LINK = "https://dbqb.legu168.cn/hljw/api/haiwai/user/login_jwcode"
VITE_API_BASE_URL_LINK = "https://dbqb.legu168.cn/hljw/api/haiwai/user/login_jwcode"
VITE_API_BASE_URLXXCG=https://api.homilychart.com/

3
.env.production

@ -1,2 +1,3 @@
VITE_API_BASE_URL = "https://dcapi.homilychart.com/prod/deepchart"
VITE_API_BASE_URL_LINK = "https://api.homilychart.com/hljw/api/haiwai/user/login_jwcode"
VITE_API_BASE_URL_LINK = "https://api.homilychart.com/hljw/api/haiwai/user/login_jwcode"
VITE_API_BASE_URLXXCG=https://api.homilychart.com/

56
src/api/eventManagement.js

@ -0,0 +1,56 @@
import request from '../utils/myAxios';
var base_url = import.meta.env.VITE_API_BASE_URL
// 获取用户抽奖记录
export function userLuckyDrawListApi(params) {
return request({
url: base_url + "/admin/luckyDraw/list",
method: "post",
data: params,
});
}
// 导出用户抽奖记录
export function exportUserLuckyDrawListApi(params) {
return request({
url: base_url + "/admin/luckyDraw/export/create",
method: "post",
data: params,
});
}
// 获取配置列表
export function getContentListApi(params) {
return request({
url: base_url + "/admin/luckyDraw/getContentList",
method: "post",
data: params,
});
}
// 添加奖品
export function addDrawConfigApi(params) {
return request({
url: base_url + "/admin/luckyDraw/addDrawConfig",
method: "post",
data: params,
});
}
// 删除奖品
export function deleteDrawApi(params) {
return request({
url: base_url + "/admin/luckyDraw/deleteDraw",
method: "post",
data: params,
});
}
// 修改奖品状态
export function changeStatusApi(params) {
return request({
url: base_url + "/admin/luckyDraw/changeStatus",
method: "post",
data: params,
});
}

76
src/layout/Layout.vue

@ -10,7 +10,8 @@
</div>
<!-- 侧边栏菜单 -->
<el-menu class="sidebar-menu" background-color="transparent" router :default-active="lastActivePath" :unique-opened="true">
<el-menu class="sidebar-menu" background-color="transparent" router :default-active="lastActivePath">
<!-- 第一层循环遍历父路由 (: 用户权限管理活动管理) -->
<el-sub-menu v-for="parentRoute in filteredSidebarRoutes" :key="parentRoute.name" :index="`/${parentRoute.path}`">
<!-- 父目录 -->
<template #title>
@ -19,12 +20,27 @@
</el-icon>
<span class="sidebar-parent-text">{{ parentRoute.meta.title }}</span>
</template>
<!-- 子目录 -->
<el-menu-item v-for="childRoute in parentRoute.filteredChildren" :key="childRoute.name" :index="`/${parentRoute.path}/${childRoute.path}`" :to="`/${parentRoute.path}/${childRoute.path}`" class="sidebar-child-container">
<el-icon class="sidebar-child-icon" />
<span class="sidebar-child-text">{{ childRoute.meta.title }}</span>
</el-menu-item>
<!-- 第二层循环遍历子路由 -->
<template v-for="childRoute in parentRoute.filteredChildren" :key="childRoute.name">
<!-- 如果有孙子菜单新年幸运签渲染为子目录 el-sub-menu -->
<el-sub-menu v-if="childRoute.children && childRoute.children.length > 0" :index="`/${parentRoute.path}/${childRoute.path}`">
<template #title>
<el-icon class="sidebar-child-icon" />
<span class="sidebar-child-text">{{ childRoute.meta.title }}</span>
</template>
<!-- 第三层循环遍历孙子路由 (: 历史记录内容配置) -->
<el-menu-item v-for="grandChild in childRoute.children" :key="grandChild.name" :index="`/${parentRoute.path}/${childRoute.path}/${grandChild.path}`" class="sidebar-grandchild-container">
<span class="sidebar-grandchild-text">{{ grandChild.meta.title }}</span>
</el-menu-item>
</el-sub-menu>
<!-- 如果没有子菜单行情期限渲染为点击项 el-menu-item -->
<el-menu-item v-else :index="`/${parentRoute.path}/${childRoute.path}`" class="sidebar-child-container">
<el-icon class="sidebar-child-icon" />
<span class="sidebar-child-text">{{ childRoute.meta.title }}</span>
</el-menu-item>
</template>
</el-sub-menu>
</el-menu>
@ -110,8 +126,21 @@ const filteredSidebarRoutes = computed(() => {
return allParentRoutes
.map((parentRoute) => {
const filteredChildren =
parentRoute.children?.filter((childRoute) => {
// children []
const rawChildren = parentRoute.children || [];
const filteredChildren = rawChildren
.map((childRoute) => {
// childRoute
const newChild = { ...childRoute };
if (newChild.children && newChild.children.length > 0) {
newChild.children = newChild.children.filter(
(grandChild) => grandChild.meta?.showSidebar === true
);
}
return newChild;
})
.filter((childRoute) => {
//
if (childRoute.meta?.showSidebar !== true) return false;
@ -128,7 +157,7 @@ const filteredSidebarRoutes = computed(() => {
//
return false;
}) || [];
});
return { ...parentRoute, filteredChildren };
})
.filter((parentRoute) => parentRoute.filteredChildren.length > 0);
@ -143,6 +172,13 @@ const validMenuIndexes = computed(() => {
//
parentRoute.filteredChildren.forEach((childRoute) => {
indexes.push(`/${parentRoute.path}/${childRoute.path}`);
//
if (childRoute.children && childRoute.children.length > 0) {
childRoute.children.forEach((grandChild) => {
// ()
indexes.push(`/${parentRoute.path}/${childRoute.path}/${grandChild.path}`);
});
}
});
});
return indexes;
@ -345,13 +381,29 @@ onMounted(async () => {
line-height: 22px;
}
.sidebar-grandchild-text {
position: absolute;
left: 78px;
top: 15px;
height: 33px;
overflow: hidden;
color: #03071f;
text-overflow: ellipsis;
white-space: nowrap;
font-family: "PingFang SC", sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
/* 子目录选中态样式 */
.sidebar-child-container.is-active {
.sidebar-child-container.is-active,.sidebar-grandchild-container.is-active {
background: #ffffff !important; /* 选中后容器变为白色 */
}
/* 选中态文字样式 */
.sidebar-child-container.is-active .sidebar-child-text {
.sidebar-child-container.is-active .sidebar-child-text,.sidebar-grandchild-container.is-active .sidebar-grandchild-text {
color: #ff0000 !important; /* 选中后文字红色 */
font-weight: 500;
}

26
src/router/index.js

@ -100,6 +100,32 @@ const routes = [
meta: { title: '用户活跃度统计', showSidebar: true }
}
]
},
{
path: 'EventManagement',
name: 'EventManagement',
meta: { title: '活动管理', icon: "Management", showSidebar: true, isParentNav: true },
children: [
{
path: 'NewYearAct',
name: 'NewYearAct',
meta: { title: '新年幸运签', showSidebar: true },
children: [
{
path: 'winningRecords',
name: 'winningRecords',
component: () => import('../views/EventManagement/WinningRecords.vue'),
meta: { title: '历史记录', showSidebar: true }
},
{
path: 'contentConfiguration',
name: 'contentConfiguration',
component: () => import('../views/EventManagement/ContentConfiguration.vue'),
meta: { title: '内容配置', showSidebar: true }
},
]
},
]
}
]
}

568
src/views/EventManagement/ContentConfiguration.vue

@ -0,0 +1,568 @@
<template>
<div class="page-container">
<div class="search-container">
<el-button type="danger" @click="add">添加</el-button>
</div>
<!-- 数据 -->
<el-table
:data="tableData"
style="width: 100%; margin-top: 20px"
header-cell-class-name="table-header"
@sort-change="handleSortChange"
:default-sort="{ prop: null, order: null }"
class="table-rounded"
:loading="tableLoading"
>
<el-table-column
prop="id"
label="序号"
align="center"
header-align="center"
width="80"
>
<template #default="scope">
{{ (currentPage - 1) * pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column
prop="prize_type"
label="类型"
align="center"
header-align="center"
/>
<el-table-column
prop="prize_name"
label="物品名称"
align="center"
header-align="center"
/>
<el-table-column
prop="stick_type"
label="福签"
align="center"
header-align="center"
/>
<el-table-column
prop="probability"
label="概率"
align="center"
header-align="center"
/>
<el-table-column label="状态" prop="status">
<template #default="scope">
<el-switch
v-model="scope.row.status"
:active-value="1"
:inactive-value="0"
inline-prompt
style="
--el-switch-on-color: #13ce66;
--el-switch-off-color: #ff4949;
"
active-text="ON"
inactive-text="OFF"
:before-change="() => beforeChangeState(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column
prop="time"
label="时间"
align="center"
header-align="center"
/>
<el-table-column label="操作" align="center" header-align="center">
<template #default="scope">
<el-button type="text" @click="deleteDraw(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<div class="demo-pagination-block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 15, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="datatotal"
/>
</div>
<el-dialog v-model="dialogFormVisible" width="500" :show-close="false">
<el-form
:model="form"
style="width: 400px; margin: 0 auto"
:rules="rules"
ref="formRef"
>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" clearable>
<el-option
v-for="item in prizeTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item :label="nameConfig.label" :prop="nameConfig.prop">
<el-input
v-model="form[nameConfig.prop]"
:type="nameConfig.type"
autocomplete="off"
:placeholder="nameConfig.placeholder"
clearable
/>
</el-form-item>
<el-form-item label="概率" prop="probability">
<el-input
v-model.number="form.probability"
type="number"
autocomplete="off"
placeholder="请输入概率"
clearable
>
<template #append>%</template>
</el-input>
<div class="tip">(小于等于100%)</div>
</el-form-item>
<el-form-item label="福签" prop="stick_type">
<el-select
v-model="form.stick_type"
placeholder="请选择类型"
clearable
>
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="图片" prop="img">
<el-upload
ref="uploadRef"
v-model:file-list="fileList"
class="avatar-uploader"
:action="uploadUrl"
:limit="1"
list-type="picture-card"
:on-success="handleSuccess"
:before-upload="beforeUpload"
:on-remove="handleRemove"
:on-exceed="handleExceed"
>
<el-icon><Plus /></el-icon>
</el-upload>
<div class="tip">
大小180*180像素支持PNGJPG格式图片需小于500K
</div>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="danger" @click="submitForm(formRef)">
提交
</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, computed, watch } from "vue";
import { ElMessage, genFileId, ElMessageBox } from "element-plus";
import router from "../../router";
import {
getContentListApi,
addDrawConfigApi,
deleteDrawApi,
changeStatusApi,
} from "../../api/eventManagement";
const uploadUrl = import.meta.env.VITE_API_BASE_URLXXCG + "hljw/api/aws/upload";
const uploadRef = ref();
const fileList = ref([]);
const formRef = ref();
const form = reactive({
stick_type: "",
type: "",
item_name: "",
num: null,
probability: null,
img: "",
});
const typeOptions = ref([
{ label: "好运签", value: 1 },
{ label: "福气签", value: 2 },
{ label: "富贵签", value: 3 },
{ label: "财神签", value: 4 },
{ label: "上上签", value: 5 },
{ label: "锦鲤签", value: 6 },
]);
const prizeTypeOptions = ref([
{ label: "金币", value: 2 },
{ label: "金豆", value: 3 },
{ label: "Token", value: 1 },
{ label: "实物", value: 4 },
]);
const nameConfig = computed(() => {
switch (form.type) {
case 1: // Token
return { label: "数量", placeholder: "请输入Token数量", prop: "num", type: "number" };
case 2: //
return { label: "数量", placeholder: "请输入金币数量", prop: "num", type: "number" };
case 3: //
return { label: "数量", placeholder: "请输入金豆数量", prop: "num", type: "number" };
default: //
return { label: "名称", placeholder: "请输入物品名称", prop: "item_name", type: "text" };
}
});
const handleSuccess = (response, uploadFile) => {
form.img = response.data.url;
};
const beforeUpload = (rawFile) => {
if (!rawFile.type.startsWith("image/")) {
ElMessage.error("请上传图片文件!");
return false;
} else if (rawFile.size / 1024 > 500) {
ElMessage.error("图片大小必须小于500K!");
return false;
}
return true;
};
const handleRemove = (file, fileList) => {
form.img = "";
};
const handleExceed = (files) => {
// 1.
uploadRef.value.clearFiles();
const file = files[0];
// 2. uid key
file.uid = genFileId();
// 3.
uploadRef.value.handleStart(file);
// 4.
uploadRef.value.submit();
};
// token
const token = localStorage.getItem("token");
const dialogFormVisible = ref(false);
const rules = computed(() => {
const baseRules = {
stick_type: [{ required: true, message: "请选择类型", trigger: "change" }],
type: [{ required: true, message: "请选择类型", trigger: "change" }],
probability: [
{ required: true, message: "请输入概率", trigger: "blur" },
//
{ validator: validateNum, trigger: "blur" },
],
img: [{ required: true, message: "请上传图片", trigger: "change" }], // change
};
if ([1, 2, 3].includes(form.type)) {
return {
...baseRules,
num: [
{ required: true, message: "请输入数量", trigger: "blur" },
//
{ validator: validateNum, trigger: "blur" },
],
};
} else {
return {
...baseRules,
item_name: [
{ required: true, message: "请输入物品名称", trigger: "blur" },
],
};
}
});
watch(
() => form.type,
() => {
//
form.item_name = "";
form.num = null;
//
if (formRef.value) {
formRef.value.clearValidate(["item_name", "num"]);
}
}
);
const validateNum = (rule, value, callback) => {
// required
if (value === "" || value === null || value === undefined) {
callback();
return;
}
//
if (Number(value) < 0) {
callback(new Error("不能为负数"));
} else {
callback();
}
};
//
const tableData = ref([]);
const tableLoading = ref(false);
const datatotal = ref(0);
//
const currentPage = ref(1);
const pageSize = ref(15);
const beforeChangeState = (row) => {
return new Promise(async (resolve, reject) => {
try {
const targetStatus = row.status === 1 ? 0 : 1;
await changeStatusApi({
token: token,
id: row.id,
status: targetStatus,
});
ElMessage.success("状态更新成功");
resolve(true);
// fetchTableData();
} catch (error) {
// reject()switch
reject(new Error("状态更新失败"));
}
});
};
//
const resetForm = () => {
form.stick_type = "";
form.type = "";
form.item_name = "";
form.num = null;
form.probability = null;
form.img = "";
fileList.value = [];
};
//
const add = () => {
resetForm();
dialogFormVisible.value = true;
};
const submitForm = async () => {
try {
await formRef.value.validate();
const requestParams = {
token: token,
stick_type: form.stick_type,
type: form.type,
probability: form.probability,
img: form.img,
};
if ([1, 2, 3].includes(form.type)) {
requestParams.num = Number(form.num);
} else {
requestParams.item_name = form.item_name;
}
const data = await addDrawConfigApi(requestParams);
ElMessage.success("添加成功");
dialogFormVisible.value = false;
fetchTableData();
} catch (error) {}
};
const deleteDraw = async (row) => {
try {
await ElMessageBox.confirm("确定要删除吗?", "确认删除", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
confirmButtonClass: "custom-confirm-btn",
});
const requestParams = {
token: token,
id: row.id,
};
const data = await deleteDrawApi(requestParams);
ElMessage.success("删除成功");
fetchTableData();
} catch (error) {
if (error === "cancel") {
//
ElMessage.info("已取消删除");
} else {
//
ElMessage.error("删除失败");
}
}
};
//
const fetchTableData = async () => {
try {
tableLoading.value = true;
const requestParams = {
token: token,
page: currentPage.value,
page_size: pageSize.value,
};
const data = await getContentListApi(requestParams);
tableData.value = data.list;
datatotal.value = data.total;
} catch (error) {
console.error("获取表格数据失败:", error);
tableData.value = [];
datatotal.value = 0;
} finally {
tableLoading.value = false;
}
};
// +
onMounted(() => {
fetchTableData();
});
//
const handleSizeChange = (val) => {
pageSize.value = val;
fetchTableData();
console.log(`每页 ${val}`);
};
const handleCurrentChange = (val) => {
currentPage.value = val;
fetchTableData();
console.log(`当前页: ${val}`);
};
</script>
<style scoped>
/* 父容器 */
.page-container {
position: relative;
min-height: 600px;
}
/* 搜索区域 */
.search-container {
display: flex;
height: auto;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 12px;
align-self: stretch;
border-radius: 8px;
background: #fefaf9;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
padding: 15px;
margin-bottom: 20px;
}
/* 表格样式 */
.table-rounded {
border-radius: 12px !important;
overflow: hidden !important;
border: 1px solid #e4e7ed !important;
height: 750px;
}
.table-header {
text-align: center !important;
font-weight: 800 !important;
font-size: 15px !important;
color: #333 !important;
background-color: #f8f9fa !important;
}
.el-table__cell {
border-right: none !important;
border-bottom: 1px solid #e4e7ed !important;
}
.el-table__header th.el-table__cell {
border-right: none !important;
border-bottom: 1px solid #e4e7ed !important;
}
.el-table__row:hover .el-table__cell {
background-color: #fafafa !important;
}
/* 分页组件样式 */
.demo-pagination-block {
display: flex;
width: 100%;
height: 44px;
padding: 0 16px;
align-items: center;
gap: 16px;
position: absolute;
margin-top: 10px;
border-radius: 0 0 3px 3px;
border-top: 1px solid #eaeaea;
background: #fefbfb;
box-sizing: border-box;
}
.tip {
font-size: 12px;
color: #8c939d;
}
.avatar-uploader .avatar {
width: 120px;
height: 120px;
display: block;
}
</style>
<style>
.custom-confirm-btn {
background: #e13d52;
border-color: #e13d52;
color: white !important;
border-radius: 6px !important;
padding: 8px 16px !important;
}
.custom-confirm-btn:hover {
background: #d88b95;
border-color: #d88b95;
}
.avatar-uploader .el-upload {
border: 1px dashed var(--el-border-color);
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: var(--el-transition-duration-fast);
}
.avatar-uploader .el-upload:hover {
border-color: var(--el-color-primary);
}
.el-icon.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 120px;
height: 120px;
text-align: center;
}
</style>

426
src/views/EventManagement/WinningRecords.vue

@ -0,0 +1,426 @@
<template>
<div class="page-container">
<!-- 搜索区域 -->
<div class="search-container">
<div class="search-group">
<span class="form-label">账号</span>
<el-input
v-model="searchForm.dccode"
placeholder="请输入账号"
clearable
style="height: 36px; width: 140px"
/>
<span class="form-label">地区</span>
<el-select
v-model="searchForm.country"
placeholder="请选择地区"
clearable
filterable
style="height: 36px; width: 160px"
:loading="isRegionLoading"
>
<el-option
v-for="region in regionList"
:key="region.ID"
:label="region.Name"
:value="region.ID"
/>
</el-select>
<span class="form-label">物品类型</span>
<el-select
v-model="searchForm.prize_type"
placeholder="请选择类型"
style="height: 36px; width: 160px"
clearable
>
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<div class="button-group">
<el-button type="primary" @click="search">搜索</el-button>
<el-button type="success" @click="exportExcel">导出Excel列表</el-button>
<el-button color="#626aef" @click="exportList">查看导出列表</el-button>
<el-button type="primary" @click="resetBn">重置</el-button>
</div>
</div>
<!-- 数据 -->
<el-table
:data="tableData"
style="width: 100%; margin-top: 20px"
header-cell-class-name="table-header"
@sort-change="handleSortChange"
:default-sort="{ prop: null, order: null }"
class="table-rounded"
:loading="tableLoading"
>
<el-table-column
prop="id"
label="序号"
align="center"
header-align="center"
width="80"
>
<template #default="scope">
{{ (currentPage - 1) * pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column
prop="dccode"
label="账号"
align="center"
header-align="center"
/>
<el-table-column
prop="name"
label="姓名"
align="center"
header-align="center"
/>
<el-table-column
prop="market"
label="地区"
align="center"
header-align="center"
/>
<el-table-column
prop="prize_name"
label="物品名称"
align="center"
header-align="center"
/>
<el-table-column
prop="stick_type"
label="福签"
align="center"
header-align="center"
/>
<el-table-column
prop="prize_count"
label="数量"
align="center"
header-align="center"
/>
<el-table-column
prop="created_at"
label="时间"
align="center"
header-align="center"
/>
</el-table>
<!-- 分页组件 -->
<div class="demo-pagination-block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 15, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="datatotal"
/>
</div>
</div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue";
import { ElMessage } from "element-plus";
import { marketListApi } from "../../api/userPermissions";
import { userLuckyDrawListApi, exportUserLuckyDrawListApi } from "../../api/eventManagement";
import router from "../../router";
// token
const token = localStorage.getItem("token");
const typeOptions = ref([
{ label: "金币", value: 2 },
{ label: "金豆", value: 3 },
{ label: "Token", value: 1 },
{ label: "实物", value: 4 },
]);
//
const searchForm = reactive({
dccode: "",
country: "",
prize_type: "",
});
//
const sortProp = ref(null);
const sortOrder = ref(null);
//
const tableData = ref([]);
const tableLoading = ref(false);
const datatotal = ref(0);
//
const currentPage = ref(1);
const pageSize = ref(15);
//
const regionList = ref([]);
const isRegionLoading = ref(false);
//
const originList = ref([]);
const isOriginLoading = ref(false);
// 0
const disabledDate = (time) => {
return time.getTime() < new Date().getTime() - 8.64e7;
};
//
const formatDate = (date) => {
if (!date) return "";
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}/${month}/${day}`;
};
// HLid
const checkHlids = () => {
//
if (!hlidsInput.value.trim()) {
ElMessage.error("请输入HLid");
return false;
}
//
const hlidList = hlidsInput.value
.split("\n")
.map((item) => item.trim())
.filter((item) => item)
.filter((item, index, self) => self.indexOf(item) === index); //
// 1000
if (hlidList.length > 1000) {
ElMessage.error("HLid数量不能超过1000个");
return false;
}
// 8
const hlidReg = /^\d{8}$/;
for (const hlid of hlidList) {
if (!hlidReg.test(hlid)) {
ElMessage.error(`有HLid格式错误:${hlid},请重新输入`);
return false;
}
}
return true;
};
//
const resetForm = () => {
hlidsInput.value = "";
timeType.value = "";
expireTime.value = "";
delayValue.value = "";
delayUnit.value = "";
remark.value = "";
operator.value = "";
};
//
const fetchRegionList = async () => {
try {
isRegionLoading.value = true;
const data = await marketListApi({
token: token,
app_form: "en",
});
regionList.value = data.list;
} catch (error) {
console.error("获取地区列表失败:", error);
regionList.value = [];
} finally {
isRegionLoading.value = false;
}
};
//
const fetchTableData = async () => {
try {
tableLoading.value = true;
const requestParams = {
token: token,
dccode: searchForm.dccode,
country: searchForm.country,
prize_type: searchForm.prize_type,
page: currentPage.value,
page_size: pageSize.value,
};
const data = await userLuckyDrawListApi(requestParams);
tableData.value = data.list;
datatotal.value = data.total;
} catch (error) {
console.error("获取表格数据失败:", error);
tableData.value = [];
datatotal.value = 0;
} finally {
tableLoading.value = false;
}
};
// +
onMounted(() => {
fetchRegionList();
fetchTableData();
});
//
const search = () => {
currentPage.value = 1;
fetchTableData();
};
// Excel
const exportExcel = async () => {
const requestParams = {
token: token,
dccode: searchForm.dccode,
country: searchForm.country,
prize_type: searchForm.prize_type,
};
const data = await exportUserLuckyDrawListApi(requestParams);
console.log(data);
if (data != "") {
ElMessage.success("已导出");
}
};
//
const exportList = () => {
router.push({
path: '/userPermissions/export'
});
};
//
const resetBn = () => {
searchForm.dccode = "";
searchForm.country = "";
searchForm.prize_type = "";
currentPage.value = 1;
pageSize.value = 15;
fetchTableData();
};
//
const handleSizeChange = (val) => {
pageSize.value = val;
fetchTableData();
console.log(`每页 ${val}`);
};
const handleCurrentChange = (val) => {
currentPage.value = val;
fetchTableData();
console.log(`当前页: ${val}`);
};
</script>
<style scoped>
/* 父容器 */
.page-container {
position: relative;
min-height: 600px;
}
/* 搜索区域 */
.search-container {
display: flex;
height: auto;
justify-content: center;
align-items: flex-start;
gap: 12px;
align-self: stretch;
border-radius: 8px;
background: #fefaf9;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
padding: 15px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.search-group {
display: flex;
align-items: center;
gap: 15px;
}
/* 搜索标签文字 */
.form-label {
font-weight: 800 !important;
font-size: 15px;
color: #333;
font-family: "SimHei", "Heiti SC", "Microsoft YaHei", sans-serif !important;
font-weight: 500;
}
/* 按钮组 */
.button-group {
display: flex;
align-items: center;
gap: 0px !important;
margin-left: auto;
}
/* 按钮样式 */
.button-group .el-button {
padding: 6px 10px !important;
font-size: 14px !important;
height: 36px !important;
}
/* 表格样式 */
.table-rounded {
border-radius: 12px !important;
overflow: hidden !important;
border: 1px solid #e4e7ed !important;
height: 750px;
}
.table-header {
text-align: center !important;
font-weight: 800 !important;
font-size: 15px !important;
color: #333 !important;
background-color: #f8f9fa !important;
}
.el-table__cell {
border-right: none !important;
border-bottom: 1px solid #e4e7ed !important;
}
.el-table__header th.el-table__cell {
border-right: none !important;
border-bottom: 1px solid #e4e7ed !important;
}
.el-table__row:hover .el-table__cell {
background-color: #fafafa !important;
}
/* 分页组件样式 */
.demo-pagination-block {
display: flex;
width: 100%;
height: 44px;
padding: 0 16px;
align-items: center;
gap: 16px;
position: absolute;
margin-top: 10px;
border-radius: 0 0 3px 3px;
border-top: 1px solid #eaeaea;
background: #fefbfb;
box-sizing: border-box;
}
</style>
Loading…
Cancel
Save