增加期数

This commit is contained in:
yziiy
2026-01-07 18:02:51 +08:00
parent 43b5895df6
commit d9d14eddee
3 changed files with 112 additions and 105 deletions

View File

@@ -9,9 +9,9 @@ import {
getBlindBoxRule,
settingBlindBoxRule
} from "@/api/modules/blindBox";
import TurntableView from './Turntable.vue';
import TurntableView from "./Turntable.vue";
import editForm from "./form.vue";
import settingRuleView from './settingRule.vue'
import settingRuleView from "./settingRule.vue";
import { addDialog } from "@/components/ReDialog";
import { message } from "@/utils/message";
export function useData() {
@@ -28,22 +28,23 @@ export function useData() {
});
const searchForm = ref({
gift_id: "",
gift_name: "",
gift_name: ""
});
const activeName = ref(0)
const typeList = ref([])
const activeName = ref(0);
const typeList = ref([]);
const statisticsList = ref([
{ label: "每期总次数", prop: "total_count" },
{ label: "每期总礼物价值(收入)", prop: "total_price" },
{
label: "每期总抽奖花费(支出)", prop: "total_cost"
label: "每期总抽奖花费(支出)",
prop: "total_cost"
},
{ label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" },
{ label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" }
// { label: "今日抽奖人数", prop: "today_count_user" },
// { label: "今日抽奖次数", prop: "today_total_count" },
// { label: "今日抽奖收入", prop: "today_total_price" },
])
const statisticsData = ref({})
]);
const statisticsData = ref({});
const searchLabel = ref([
{ label: "礼物ID", prop: "gift_id", type: "input" },
{ label: "礼物名称", prop: "gift_name", type: "input" }
@@ -90,14 +91,18 @@ export function useData() {
label: "公屏",
prop: "is_public_screen",
cellRenderer: ({ row }) => (
<el-tag type={row.is_public_screen === 1 ? 'success' : 'error'}>{row.is_public_screen === 1 ? '是' : '否'}</el-tag>
<el-tag type={row.is_public_screen === 1 ? "success" : "error"}>
{row.is_public_screen === 1 ? "是" : "否"}
</el-tag>
)
},
{
label: "全服播报",
prop: "is_public_server",
cellRenderer: ({ row }) => (
<el-tag type={row.is_public_server === 1 ? 'success' : 'error'}>{row.is_public_server === 1 ? '是' : '否'}</el-tag>
<el-tag type={row.is_public_server === 1 ? "success" : "error"}>
{row.is_public_server === 1 ? "是" : "否"}
</el-tag>
)
},
{
@@ -111,23 +116,23 @@ export function useData() {
slot: "operation"
}
]);
const onSearch = async (formData) => {
const onSearch = async formData => {
loading.value = true;
searchForm.value = { ...formData }
searchForm.value = { ...formData };
const { data, code } = await queryBlindBoxList({
...formData,
gift_bag_id: activeName.value,
page: pagination.value.currentPage,
page_limit: pagination.value.pageSize,
page_limit: pagination.value.pageSize
});
if (code) {
tableList.value = data.lists.map(ele => {
return {
...ele, ...data.total
}
...ele,
...data.total
};
});
statisticsData.value = data.total_data
statisticsData.value = data.total_data;
pagination.value.total = data.count;
pagination.value.currentPage = data.page;
}
@@ -142,32 +147,33 @@ export function useData() {
onSearch(searchForm.value);
};
const getType = async () => {
const { code, data } = await queryBoxTypeList({ activities_id: 5 })
typeList.value = code ? data.map(ele => {
return {
label: ele.name,
value: ele.id
}
}) : []
if (code) handleClick(data[0].id)
}
const handleClick = (id) => {
activeName.value = id
const { code, data } = await queryBoxTypeList({ activities_id: 5 });
typeList.value = code
? data.map(ele => {
return {
label: ele.name,
value: ele.id
};
})
: [];
if (code) handleClick(data[0].id);
};
const handleClick = id => {
activeName.value = id;
onSearch(searchForm.value);
}
//
};
//
const resetSetting = async () => {
const { data, code } = await resetBlindBoxRule({
gift_bag_id: activeName.value
})
});
if (code) {
message(`重置成功`, {
type: "success"
});
handleClick(activeName.value);
}
}
};
const handleDelete = async rowData => {
const { code } = await removeBlindBoxData({ id: rowData.id });
if (code) {
@@ -197,7 +203,7 @@ export function useData() {
const saveData = async form => {
const { code } = await addBlindBoxData({
...form,
gift_bag_id: activeName.value,
gift_bag_id: activeName.value
});
if (code) {
message("新增成功", { type: "success" });
@@ -238,7 +244,9 @@ export function useData() {
});
};
const setting = async () => {
const { data, code } = await getBlindBoxRule({ gift_bag_id: activeName.value })
const { data, code } = await getBlindBoxRule({
gift_bag_id: activeName.value
});
addDialog({
title: `设置盲盒规则`,
props: {
@@ -248,7 +256,8 @@ export function useData() {
},
width: "40%",
closeOnClickModal: false,
contentRenderer: () => h(settingRuleView, { ref: formRef, formInline: null }),
contentRenderer: () =>
h(settingRuleView, { ref: formRef, formInline: null }),
beforeSure: (done, { options }) => {
const FormRef = formRef.value.getRef();
const curData = options.props.formInline;
@@ -265,12 +274,12 @@ export function useData() {
FormRef.validate(valid => {
if (valid) {
// console.log("curData", curData);
saveData(curData)
saveData(curData);
}
});
}
});
}
};
// 开奖记录
const openLotteryRecord = () => {
addDialog({
@@ -281,9 +290,10 @@ export function useData() {
fullscreen: true,
hideFooter: true,
closeOnClickModal: false,
contentRenderer: () => h(TurntableView, { ref: formRef, formInline: null })
contentRenderer: () =>
h(TurntableView, { ref: formRef, formInline: null })
});
}
};
return {
searchForm,
searchLabel,
@@ -307,4 +317,4 @@ export function useData() {
setting,
openLotteryRecord
};
}
}

View File

@@ -2,12 +2,8 @@
// 开奖记录
import { ref, onMounted, nextTick } from "vue";
import SearchForm from "@/components/SearchForm/index.vue";
import {
queryBoxTypeList
} from "@/api/modules/blindBox";
import {
queryTurntableRecord
} from "@/api/modules/room";
import { queryBoxTypeList } from "@/api/modules/blindBox";
import { queryTurntableRecord } from "@/api/modules/room";
const searchLabel = ref([
{
label: "盲盒礼包",
@@ -21,19 +17,19 @@ const searchLabel = ref([
{ label: "开始时间", prop: "stime", type: "date" },
{ label: "结束时间", prop: "etime", type: "date" }
]);
const props = defineProps(["roomId", 'BagId', 'giftBagId']);
const props = defineProps(["roomId", "BagId", "giftBagId"]);
// console.log('传递过来的参数', )
const typeList = ref([])
const formatDate = (date) => {
const typeList = ref([]);
const formatDate = date => {
// 获取年份
const year = date.getFullYear();
// 获取月份,并将其转为两位数格式
const month = String(date.getMonth() + 1).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, "0");
// 获取日期,并将其转为两位数格式
const day = String(date.getDate()).padStart(2, '0');
const day = String(date.getDate()).padStart(2, "0");
// 返回格式化后的日期字符串
return `${year}-${month}-${day} 00:00:00`;
}
};
const getTodayAndWeekAgo = () => {
const today = new Date(); // 获取今天的日期对象
const weekAgo = new Date(); // 获取当前日期对象
@@ -44,7 +40,7 @@ const getTodayAndWeekAgo = () => {
today: formatDate(today),
weekAgo: formatDate(weekAgo)
};
}
};
const searchForm = ref({
gift_bag_id: "",
user_id: "",
@@ -59,18 +55,19 @@ const pagination = ref({
currentPage: 1,
background: true
});
const statisticsData = ref()
const tableList = ref([])
const statisticsData = ref();
const tableList = ref([]);
const statisticsList = ref([
{ label: "总抽奖次数", prop: "total" },
{ label: "总抽奖金额(支出)", prop: "total_money" },
{
label: "总礼物价值(收入)", prop: "total_gift_money"
label: "总礼物价值(收入)",
prop: "total_gift_money"
},
{ label: "统计(收入/支出)", prop: "ratio", tip: "%" },
{ label: "盈亏(收入-支出)", prop: "profit_loss" },
{ label: "盈亏比(盈亏/支出)", prop: "profit_loss_ratio", tip: "%" },
])
{ label: "盈亏比(盈亏/支出)", prop: "profit_loss_ratio", tip: "%" }
]);
const dynamicflowColumns = ref([
{
label: "ID",
@@ -80,10 +77,10 @@ const dynamicflowColumns = ref([
label: "盲盒转盘类型",
prop: "gift_bag_type"
},
// {
// label: "期数",
// prop: "periods"
// },
{
label: "期数",
prop: "periods"
},
{
label: "开奖人ID",
prop: "user_name"
@@ -116,75 +113,77 @@ const dynamicflowColumns = ref([
label: "创建时间",
prop: "createtime"
}
])
]);
const getType = async () => {
const { code, data } = await queryBoxTypeList({ activities_id: 5 })
typeList.value = code ? data.map(ele => {
return {
label: ele.name,
value: ele.id
}
}) : []
if (code) {
searchLabel.value[0].optionList = typeList.value
searchForm.value.gift_bag_id = Number(props.giftBagId) || data[0].id
nextTick(() => {
getData(searchForm.value)
const { code, data } = await queryBoxTypeList({ activities_id: 5 });
typeList.value = code
? data.map(ele => {
return {
label: ele.name,
value: ele.id
};
})
: [];
if (code) {
searchLabel.value[0].optionList = typeList.value;
searchForm.value.gift_bag_id = Number(props.giftBagId) || data[0].id;
nextTick(() => {
getData(searchForm.value);
});
}
}
const getData = async (formData) => {
searchForm.value = { ...formData }
};
const getData = async formData => {
searchForm.value = { ...formData };
const { data, code } = await queryTurntableRecord({
...formData,
page: pagination.value.currentPage,
page_limit: pagination.value.pageSize,
room_id: props.roomId
})
});
if (code) {
tableList.value = data.lists.map(ele => {
return {
...ele, ...data.total_data,
is_public_screen: data.is_public_screen === 1 ? '显示' : '隐藏',
is_public_server: data.is_public_server === 1 ? '显示' : '隐藏',
is_world_show: data.is_world_show === 1 ? '显示' : '隐藏',
}
...ele,
...data.total_data,
is_public_screen: data.is_public_screen === 1 ? "显示" : "隐藏",
is_public_server: data.is_public_server === 1 ? "显示" : "隐藏",
is_world_show: data.is_world_show === 1 ? "显示" : "隐藏"
};
});
statisticsData.value = data.total_data
statisticsData.value = data.total_data;
pagination.value.total = data.count;
pagination.value.currentPage = data.page;
}
}
};
const handleSizeChange = (val: number) => {
pagination.value.pageSize = val;
getData(searchForm.value)
getData(searchForm.value);
};
const handleCurrentChange = (val: number) => {
pagination.value.currentPage = val;
getData(searchForm.value)
getData(searchForm.value);
};
onMounted(() => {
getType()
})
getType();
});
</script>
<template>
<div class="viewPage" v-if="typeList && typeList.length">
<div v-if="typeList && typeList.length" class="viewPage">
<SearchForm class="pb-2 mt-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="getData" />
<div class="content-flex" v-if="statisticsData">
<div class="box" v-for="(ele, index) in statisticsList">
<div v-if="statisticsData" class="content-flex">
<div v-for="(ele, index) in statisticsList" class="box">
<el-statistic :precision="2" decimal-separator="." :value="statisticsData[ele.prop] || 0"
:suffix="ele.tip || ''" :title="ele.label"></el-statistic>
<span></span>
:suffix="ele.tip || ''" :title="ele.label" />
<span />
</div>
</div>
<pure-table class="mt-5" ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto"
<pure-table ref="tableRef" class="mt-5" align-whole="center" showOverflowTooltip table-layout="auto"
default-expand-all row-key="id" :adaptiveConfig="{ offsetBottom: 108 }" :data="tableList"
:columns="dynamicflowColumns" :pagination="{ ...pagination }" :header-cell-style="{
background: 'var(--el-fill-color-light)',
color: 'var(--el-text-color-primary)'
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
</pure-table>
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange" />
</div>
</template>
<style lang="scss" scoped>
@@ -203,6 +202,6 @@ onMounted(() => {
margin-bottom: 20px;
text-align: center;
align-items: center;
justify-content: space-between
justify-content: space-between;
}
</style>
</style>

View File

@@ -35,9 +35,7 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
onProxyReq: (proxyReq, req, res) => {
if (req.method === 'OPTIONS') {
proxyReq.method = 'OPTIONS';
// https://test.vespa.qxyushen.top
// 'http://yushenggliht.qxyushen.top'
res.setHeader('Access-Control-Allow-Origin', 'http://ysmanagementconsole.qxyushen.top');
res.setHeader('Access-Control-Allow-Origin', 'http://yushenggliht.qxyushen.top');
// res.setHeader('Access-Control-Allow-Origin', 'https://test.vespa.qxyushen.top');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');