style: 积分管理
This commit is contained in:
@@ -36,5 +36,7 @@ export const request = async (url: string, options: RequestInit = {}) => {
|
|||||||
// API URL 生成器
|
// API URL 生成器
|
||||||
export const authApi = (path: string) => `/auth/${path}`;
|
export const authApi = (path: string) => `/auth/${path}`;
|
||||||
|
|
||||||
|
export const bizApi = (path: string) => `/biz/${path}`;
|
||||||
|
|
||||||
// 登录接口
|
// 登录接口
|
||||||
export const loginApi = (path: string) => `/auth/${path}`;
|
export const loginApi = (path: string) => `/auth/${path}`;
|
||||||
|
|||||||
@@ -1,9 +1,399 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
import { request, authApi, bizApi } from "@/api/utils";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "membershipPoint"
|
name: "membershipPoint"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
height?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
height: null
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// 定义查询参数
|
||||||
|
const queryParams = ref({
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
userId: "",
|
||||||
|
companyId: "",
|
||||||
|
memberType: "",
|
||||||
|
memberLevel: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义表格数据
|
||||||
|
const tableData = ref([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const total = ref(0);
|
||||||
|
|
||||||
|
// 公司列表数据
|
||||||
|
const companyOptions = ref([]);
|
||||||
|
|
||||||
|
// 添加会员类型选项
|
||||||
|
const memberTypeOptions = [
|
||||||
|
{ value: "1", label: "普通会员" },
|
||||||
|
{ value: "2", label: "包年会员" },
|
||||||
|
{ value: "3", label: "季度会员" },
|
||||||
|
{ value: "4", label: "月度会员" }
|
||||||
|
];
|
||||||
|
|
||||||
|
// 获取公司列表
|
||||||
|
const getCompanyList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await request(bizApi("getCompanyPrimaryInfo"), {
|
||||||
|
method: "POST"
|
||||||
|
});
|
||||||
|
if (res.status === 200) {
|
||||||
|
companyOptions.value = res.data.map(item => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.companyName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取公司列表失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 前端用户列表数据
|
||||||
|
const frontendUserOptions = ref([]);
|
||||||
|
// 获取前端用户列表
|
||||||
|
const getFrontendUserList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await request(bizApi("getFrontendUserPrimaryInfo"), {
|
||||||
|
method: "POST"
|
||||||
|
});
|
||||||
|
if (res.status === 200) {
|
||||||
|
frontendUserOptions.value = res.data.map(item => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.name
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取公司列表失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取积分列表
|
||||||
|
const getPointList = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const params = { ...queryParams.value };
|
||||||
|
const data = await request("/biz/membershipPointPage", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(params)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data.status === 200) {
|
||||||
|
tableData.value = data.data.rows;
|
||||||
|
total.value = data.data.records;
|
||||||
|
} else {
|
||||||
|
ElMessage.error(data.msg || "获取数据失败");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取积分列表失败:", error);
|
||||||
|
ElMessage.error(error.message || "获取数据失败");
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 搜索方法
|
||||||
|
const handleSearch = () => {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getPointList();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置方法
|
||||||
|
const handleReset = () => {
|
||||||
|
queryParams.value = {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
userId: "",
|
||||||
|
companyId: "",
|
||||||
|
memberType: "",
|
||||||
|
memberLevel: ""
|
||||||
|
};
|
||||||
|
getPointList();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 分页改变
|
||||||
|
const handleSizeChange = (val: number) => {
|
||||||
|
queryParams.value.pageSize = val;
|
||||||
|
getPointList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCurrentChange = (val: number) => {
|
||||||
|
queryParams.value.pageNum = val;
|
||||||
|
getPointList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns: TableColumnList = [
|
||||||
|
{
|
||||||
|
label: "用户名称",
|
||||||
|
prop: "userId",
|
||||||
|
width: "120",
|
||||||
|
formatter: row => {
|
||||||
|
const user = frontendUserOptions.value.find(
|
||||||
|
item => item.value == row.userId
|
||||||
|
);
|
||||||
|
return user ? user.label : "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "是否公司",
|
||||||
|
prop: "isCompany",
|
||||||
|
width: "100",
|
||||||
|
formatter: row => {
|
||||||
|
return row.isCompany ? "是" : "否";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "所属公司",
|
||||||
|
prop: "companyId",
|
||||||
|
width: "180",
|
||||||
|
formatter: row => {
|
||||||
|
const company = companyOptions.value.find(
|
||||||
|
item => item.value === row.companyId
|
||||||
|
);
|
||||||
|
return company ? company.label : "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "总积分",
|
||||||
|
prop: "totalPoints",
|
||||||
|
width: "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "会员类型",
|
||||||
|
prop: "memberType",
|
||||||
|
width: "120",
|
||||||
|
formatter: row => {
|
||||||
|
const type = memberTypeOptions.find(item => item.value == row.memberType);
|
||||||
|
return type ? type.label : "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "会员等级",
|
||||||
|
prop: "memberLevel",
|
||||||
|
width: "120"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "会员开始时间",
|
||||||
|
prop: "memberStartTime",
|
||||||
|
width: "160",
|
||||||
|
formatter: row => {
|
||||||
|
return row.memberStartTime
|
||||||
|
? dayjs(row.memberStartTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "会员截止时间",
|
||||||
|
prop: "memberExpireTime",
|
||||||
|
width: "160",
|
||||||
|
formatter: row => {
|
||||||
|
return row.memberExpireTime
|
||||||
|
? dayjs(row.memberExpireTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "创建时间",
|
||||||
|
prop: "createTime",
|
||||||
|
width: "160",
|
||||||
|
formatter: row => {
|
||||||
|
return row.createTime
|
||||||
|
? dayjs(row.createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "操作",
|
||||||
|
fixed: "right",
|
||||||
|
width: "150",
|
||||||
|
slot: "operation"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// 添加操作方法
|
||||||
|
const handleDetail = row => {
|
||||||
|
console.log("查看明细", row);
|
||||||
|
// TODO: 实现查看明细逻辑
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = row => {
|
||||||
|
console.log("编辑", row);
|
||||||
|
// TODO: 实现编辑逻辑
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = row => {
|
||||||
|
ElMessageBox.confirm("确认删除该记录?", "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
try {
|
||||||
|
// TODO: 调用删除接口
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
getPointList(); // 刷新列表
|
||||||
|
} catch (error) {
|
||||||
|
console.error("删除失败:", error);
|
||||||
|
ElMessage.error(error.message || "删除失败");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// 取消删除
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 页面加载时获取数据
|
||||||
|
onMounted(() => {
|
||||||
|
getPointList();
|
||||||
|
getCompanyList(); // 获取公司列表数据
|
||||||
|
getFrontendUserList(); // 获取前端用户列表数据
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1>积分管理</h1>
|
<div class="membershipPoint-container">
|
||||||
|
<div class="search-box">
|
||||||
|
<el-form ref="queryForm" :model="queryParams" :inline="true">
|
||||||
|
<el-form-item label="用户" prop="userId">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.userId"
|
||||||
|
placeholder="请选择用户"
|
||||||
|
clearable
|
||||||
|
class="user-select"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in frontendUserOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="所属公司" prop="companyId">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.companyId"
|
||||||
|
placeholder="请选择公司"
|
||||||
|
clearable
|
||||||
|
class="company-select"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in companyOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="会员类型" prop="memberType">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.memberType"
|
||||||
|
placeholder="请选择会员类型"
|
||||||
|
clearable
|
||||||
|
class="member-type-select"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in memberTypeOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="会员等级" prop="memberLevel">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.memberLevel"
|
||||||
|
placeholder="请输入会员等级"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleSearch"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||||
|
<el-button @click="handleReset">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<pure-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="tableData"
|
||||||
|
:columns="columns"
|
||||||
|
:height="height"
|
||||||
|
row-key="id"
|
||||||
|
>
|
||||||
|
<template #operation="{ row }">
|
||||||
|
<el-button link type="primary" size="small" @click="handleDetail(row)">
|
||||||
|
明细
|
||||||
|
</el-button>
|
||||||
|
<el-button link type="primary" size="small" @click="handleEdit(row)">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button link type="danger" size="small" @click="handleDelete(row)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
</pure-table>
|
||||||
|
|
||||||
|
<div class="pagination-container">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="queryParams.pageNum"
|
||||||
|
v-model:page-size="queryParams.pageSize"
|
||||||
|
:page-sizes="[10, 20, 30, 50]"
|
||||||
|
:total="total"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.membershipPoint-container {
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
:deep(.el-form-item) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-select {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.member-type-select {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-select {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user