@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "log-lottery",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
1
src/components.d.ts
vendored
1
src/components.d.ts
vendored
@@ -8,6 +8,7 @@ export {}
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
DaiysuiTable: typeof import('./components/DaiysuiTable/index.vue')['default']
|
||||
EditSeparateDialog: typeof import('./components/NumberSeparate/EditSeparateDialog.vue')['default']
|
||||
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
|
||||
ImageSync: typeof import('./components/ImageSync/index.vue')['default']
|
||||
PlayMusic: typeof import('./components/PlayMusic/index.vue')['default']
|
||||
|
||||
99
src/components/NumberSeparate/EditSeparateDialog.vue
Normal file
99
src/components/NumberSeparate/EditSeparateDialog.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<script setup lang='ts'>
|
||||
import { ref, watch, onMounted, toRefs } from 'vue'
|
||||
import { Separate } from '@/types/storeType'
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
totalNumber: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
separatedNumber: {
|
||||
type: Array<Separate>,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
const emits = defineEmits(['clearData'])
|
||||
|
||||
const separatedNumberRef = ref()
|
||||
const { separatedNumber, totalNumber } = toRefs(props)
|
||||
const scaleList = ref<number[]>([])
|
||||
const editScale = (item: number) => {
|
||||
if (item == totalNumber.value) {
|
||||
return
|
||||
}
|
||||
if (scaleList.value.includes(item)) {
|
||||
const index = scaleList.value.indexOf(item)
|
||||
scaleList.value.splice(index, 1)
|
||||
separatedNumber.value.splice(index, 1)
|
||||
}
|
||||
else {
|
||||
scaleList.value.push(item)
|
||||
scaleList.value.sort((a, b) => a - b)
|
||||
}
|
||||
}
|
||||
const clearData = () => {
|
||||
separatedNumberRef.value.close()
|
||||
emits('clearData')
|
||||
}
|
||||
watch(scaleList, (val: number[]) => {
|
||||
separatedNumber.value = []
|
||||
for (let i = 1; i < scaleList.value.length; i++) {
|
||||
separatedNumber.value[i-1] = {
|
||||
id: i.toString(),
|
||||
count: val[i] - val[i - 1],
|
||||
isUsedCount:0,
|
||||
}
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
watch(totalNumber, (val) => {
|
||||
if (val <= 0) {
|
||||
return
|
||||
}
|
||||
separatedNumberRef.value.showModal()
|
||||
scaleList.value = new Array(separatedNumber.value.length + 1).fill(totalNumber.value)
|
||||
for (let i = separatedNumber.value.length - 1; i >= 0; i--) {
|
||||
scaleList.value[i] = scaleList.value[i + 1] - separatedNumber.value[i].count
|
||||
}
|
||||
if(scaleList.value[0]!==0){
|
||||
scaleList.value.unshift(0)
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
// 阻止esc事件
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dialog id="my_modal_1" ref="separatedNumberRef" class="z-50 overflow-hidden border-none modal">
|
||||
<div class="overflow-hidden modal-box">
|
||||
<h3 class="pb-6 text-lg font-bold">提示!</h3>
|
||||
<p class="pb-8">单次抽取只能抽取10位</p>
|
||||
<div class="flex justify-between px-3 text-center separated-number">
|
||||
<div v-for="item in props.totalNumber" :key="item"
|
||||
class="relative flex flex-col items-center cursor-pointer">
|
||||
<div class="absolute mb-12 text-center tooltip -top-5 hover:text-lg" data-tip="左键切割右键取消"
|
||||
@click.left="editScale(item)">
|
||||
<span> {{ item }}</span>
|
||||
</div>
|
||||
<div class="text-center" :class="scaleList.includes(item) ? 'text-red-500 font-extrabold' : ''">|</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<!-- if there is a button in form, it will close the modal -->
|
||||
<button class="btn" @click="clearData">关闭</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</template>
|
||||
|
||||
<style lang='scss' scoped></style>
|
||||
File diff suppressed because one or more lines are too long
@@ -1,14 +1,14 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defaultMusicList,defaultImageList,defaultPatternList } from './data'
|
||||
import {IMusic,IImage} from '@/types/storeType';
|
||||
import { defaultMusicList, defaultImageList, defaultPatternList } from './data'
|
||||
import { IMusic, IImage } from '@/types/storeType';
|
||||
// import { IPrizeConfig } from '@/types/storeType';
|
||||
export const useGlobalConfig = defineStore('global', {
|
||||
state() {
|
||||
return {
|
||||
globalConfig: {
|
||||
rowCount: 17,
|
||||
isSHowPrizeList:true,
|
||||
topTitle:'大明内阁六部御前奏对',
|
||||
isSHowPrizeList: true,
|
||||
topTitle: '大明内阁六部御前奏对',
|
||||
theme: {
|
||||
name: 'dark',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
@@ -16,17 +16,17 @@ export const useGlobalConfig = defineStore('global', {
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor:'#ECB1AC',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor:'#1b66c9',
|
||||
patternList:defaultPatternList as number[],
|
||||
patternColor: '#1b66c9',
|
||||
patternList: defaultPatternList as number[],
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList:defaultImageList as IImage[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
},
|
||||
currentMusic: {
|
||||
item:defaultMusicList[0],
|
||||
paused:true,
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -71,11 +71,11 @@ export const useGlobalConfig = defineStore('global', {
|
||||
return state.globalConfig.theme.textSize;
|
||||
},
|
||||
// 获取图案颜色
|
||||
getPatterColor(state){
|
||||
getPatterColor(state) {
|
||||
return state.globalConfig.theme.patternColor;
|
||||
},
|
||||
// 获取图案列表
|
||||
getPatternList(state){
|
||||
getPatternList(state) {
|
||||
return state.globalConfig.theme.patternList;
|
||||
},
|
||||
// 获取音乐列表
|
||||
@@ -164,10 +164,10 @@ export const useGlobalConfig = defineStore('global', {
|
||||
}
|
||||
},
|
||||
// 设置当前播放音乐
|
||||
setCurrentMusic(musicItem: IMusic,paused:boolean=true) {
|
||||
this.currentMusic={
|
||||
item:musicItem,
|
||||
paused:paused,
|
||||
setCurrentMusic(musicItem: IMusic, paused: boolean = true) {
|
||||
this.currentMusic = {
|
||||
item: musicItem,
|
||||
paused: paused,
|
||||
}
|
||||
},
|
||||
// 重置音乐列表
|
||||
@@ -179,7 +179,7 @@ export const useGlobalConfig = defineStore('global', {
|
||||
this.globalConfig.musicList = [] as IMusic[];
|
||||
},
|
||||
// 添加图片
|
||||
addImage(image:IImage){
|
||||
addImage(image: IImage) {
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].name === image.name) {
|
||||
return;
|
||||
@@ -211,29 +211,28 @@ export const useGlobalConfig = defineStore('global', {
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.globalConfig = {
|
||||
rowCount: 12,
|
||||
topTitle:'大明内阁六部御前奏对',
|
||||
isSHowPrizeList:true,
|
||||
rowCount: 17,
|
||||
isSHowPrizeList: true,
|
||||
topTitle: '大明内阁六部御前奏对',
|
||||
theme: {
|
||||
name: 'dark',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: 'rgba(0, 255, 255)',
|
||||
luckyCardColor:'#ECB1AC',
|
||||
cardWidth: 200,
|
||||
cardHeight: 140,
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor: '#1b66c9',
|
||||
patternList:defaultPatternList,
|
||||
|
||||
patternList: defaultPatternList as number[],
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList:defaultImageList as IImage[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
},
|
||||
this.currentMusic= {
|
||||
item:defaultMusicList[0] as IMusic,
|
||||
paused:true,
|
||||
}
|
||||
this.currentMusic = {
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
persist: {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const usePersonConfig = defineStore('person', {
|
||||
return !item.prizeId.includes(currentPrize.id as string);
|
||||
});
|
||||
|
||||
return data
|
||||
return data
|
||||
},
|
||||
// 获取已中奖人员名单
|
||||
getAlreadyPersonList(state) {
|
||||
|
||||
@@ -8,33 +8,41 @@ export const usePrizeConfig = defineStore('prize', {
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: {
|
||||
id: '001',
|
||||
name: '一等奖',
|
||||
name: '三等奖',
|
||||
sort: 1,
|
||||
isAll: true,
|
||||
count: 1,
|
||||
isUsedCount:0,
|
||||
isAll: false,
|
||||
count: 12,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '0',
|
||||
name: '一等奖',
|
||||
url: 'https://24years.top/resource/image/image1.png'
|
||||
id: '2',
|
||||
name: '三等奖',
|
||||
url: 'https://24years.top/resource/image/image3.png'
|
||||
},
|
||||
desc: '一等奖',
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '三等奖',
|
||||
isShow: true,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig,
|
||||
temporaryPrize:{
|
||||
temporaryPrize: {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount:0,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: ''
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
@@ -50,7 +58,7 @@ export const usePrizeConfig = defineStore('prize', {
|
||||
},
|
||||
// 获取奖品列表
|
||||
getPrizeConfig(state) {
|
||||
return state.prizeConfig.prizeList;
|
||||
return state.prizeConfig.prizeList;
|
||||
},
|
||||
// 根据id获取配置
|
||||
getPrizeConfigById(state) {
|
||||
@@ -63,7 +71,7 @@ return state.prizeConfig.prizeList;
|
||||
return state.prizeConfig.currentPrize;
|
||||
},
|
||||
// 获取临时的奖项
|
||||
getTemporaryPrize(state){
|
||||
getTemporaryPrize(state) {
|
||||
return state.prizeConfig.temporaryPrize;
|
||||
},
|
||||
|
||||
@@ -83,16 +91,16 @@ return state.prizeConfig.prizeList;
|
||||
},
|
||||
// 更新奖项数据
|
||||
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
|
||||
const prizeListLength=this.prizeConfig.prizeList.length;
|
||||
if(prizeConfigItem.isUsed&&prizeListLength){
|
||||
for(let i=0;i<prizeListLength;i++){
|
||||
if(!this.prizeConfig.prizeList[i].isUsed){
|
||||
const prizeListLength = this.prizeConfig.prizeList.length;
|
||||
if (prizeConfigItem.isUsed && prizeListLength) {
|
||||
for (let i = 0; i < prizeListLength; i++) {
|
||||
if (!this.prizeConfig.prizeList[i].isUsed) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
@@ -107,17 +115,17 @@ return state.prizeConfig.prizeList;
|
||||
},
|
||||
// 设置临时奖项
|
||||
setTemporaryPrize(prizeItem: IPrizeConfig) {
|
||||
if(prizeItem.isShow==false){
|
||||
for(let i=0;i<this.prizeConfig.prizeList.length;i++){
|
||||
if(this.prizeConfig.prizeList[i].isUsed==false){
|
||||
if (prizeItem.isShow == false) {
|
||||
for (let i = 0; i < this.prizeConfig.prizeList.length; i++) {
|
||||
if (this.prizeConfig.prizeList[i].isUsed == false) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
|
||||
|
||||
break
|
||||
break
|
||||
}
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
|
||||
return
|
||||
return
|
||||
}
|
||||
|
||||
this.prizeConfig.temporaryPrize = prizeItem
|
||||
@@ -130,7 +138,7 @@ return
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount:0,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
@@ -148,22 +156,26 @@ return
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: {
|
||||
id: '001',
|
||||
name: '一等奖',
|
||||
name: '三等奖',
|
||||
sort: 1,
|
||||
isAll: true,
|
||||
count: 1,
|
||||
isUsedCount:0,
|
||||
isAll: false,
|
||||
count: 12,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '0',
|
||||
name: '一等奖',
|
||||
url: 'https://24years.top/resource/image/image1.png'
|
||||
id: '2',
|
||||
name: '三等奖',
|
||||
url: 'https://24years.top/resource/image/image3.png'
|
||||
},
|
||||
desc: '一等奖',
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '三等奖',
|
||||
isShow: true,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig,
|
||||
temporaryPrize:{} as IPrizeConfig
|
||||
temporaryPrize: {} as IPrizeConfig
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,42 +2,51 @@ export interface IPersonConfig {
|
||||
id: number;
|
||||
uid: string;
|
||||
name: string;
|
||||
department:string;
|
||||
identity:string;
|
||||
isWin:boolean;
|
||||
x:number;
|
||||
y:number
|
||||
department: string;
|
||||
identity: string;
|
||||
isWin: boolean;
|
||||
x: number;
|
||||
y: number
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
prizeName:string[];
|
||||
prizeId:string[];
|
||||
prizeName: string[];
|
||||
prizeId: string[];
|
||||
prizeTime: string[];
|
||||
}
|
||||
export interface IPrizeConfig {
|
||||
id: number|string;
|
||||
name:string;
|
||||
sort:number;
|
||||
isAll:boolean;
|
||||
count:number;
|
||||
isUsedCount:number,
|
||||
picture:{
|
||||
id:string|number,
|
||||
name:string,
|
||||
url:string
|
||||
};
|
||||
desc:string;
|
||||
isShow:boolean;
|
||||
isUsed:boolean,
|
||||
frequency:number;
|
||||
export type Separate = {
|
||||
id: string,
|
||||
count: number,
|
||||
isUsedCount: number,
|
||||
}
|
||||
export interface IMusic{
|
||||
id:string,
|
||||
name:string,
|
||||
url:string,
|
||||
export interface IPrizeConfig {
|
||||
id: number | string;
|
||||
name: string;
|
||||
sort: number;
|
||||
isAll: boolean;
|
||||
count: number;
|
||||
isUsedCount: number,
|
||||
picture: {
|
||||
id: string | number,
|
||||
name: string,
|
||||
url: string
|
||||
};
|
||||
separateCount: {
|
||||
enable: boolean,
|
||||
countList: Separate[],
|
||||
};
|
||||
desc: string;
|
||||
isShow: boolean;
|
||||
isUsed: boolean,
|
||||
frequency: number;
|
||||
}
|
||||
export interface IMusic {
|
||||
id: string,
|
||||
name: string,
|
||||
url: string,
|
||||
}
|
||||
|
||||
export interface IImage{
|
||||
id:string,
|
||||
name:string,
|
||||
url:string,
|
||||
export interface IImage {
|
||||
id: string,
|
||||
name: string,
|
||||
url: string,
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ import PatternSetting from './components/PatternSetting.vue'
|
||||
|
||||
const globalConfig = useStore().globalConfig
|
||||
const personConfig = useStore().personConfig
|
||||
const prizeConfig= useStore().prizeConfig
|
||||
const { getTopTitle: topTitle, getTheme: localTheme, getPatterColor: patternColor, getPatternList: patternList, getCardColor: cardColor, getLuckyColor: luckyCardColor, getTextColor: textColor, getCardSize: cardSize, getTextSize: textSize, getRowCount: rowCount, getIsShowPrizeList: isShowPrizeList } = storeToRefs(globalConfig)
|
||||
const { getAlreadyPersonList: alreadyPersonList, getNotPersonList: notPersonList } = storeToRefs(personConfig)
|
||||
const colorPickerRef = ref()
|
||||
|
||||
const resetDataDialogRef=ref()
|
||||
interface ThemeDaType {
|
||||
[key: string]: any
|
||||
}
|
||||
@@ -87,6 +88,14 @@ const resetPattern = () => {
|
||||
globalConfig.resetPatternList()
|
||||
}
|
||||
|
||||
const resetData=()=>{
|
||||
globalConfig.reset();
|
||||
personConfig.reset();
|
||||
prizeConfig.resetDefault();
|
||||
// 刷新页面
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
// const handleChangeShowFields = (fieldItem: any) => {
|
||||
// formData.value.showField.map((item) => {
|
||||
// if (item.label === fieldItem.label) {
|
||||
@@ -144,7 +153,24 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dialog id="my_modal_1" ref="resetDataDialogRef" class="border-none modal">
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">提示!</h3>
|
||||
<p class="py-4">该操作会重置所有数据,是否继续?</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog" class="flex gap-3">
|
||||
<!-- if there is a button in form, it will close the modal -->
|
||||
<button class="btn" @click="resetDataDialogRef.close()">取消</button>
|
||||
<button class="btn" @click="resetData">确定</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
<div>
|
||||
<h2>全局配置</h2>
|
||||
<div class="mb-8">
|
||||
<button class="btn btn-sm btn-primary" @click="resetDataDialogRef.showModal()">重置所有数据</button>
|
||||
</div>
|
||||
<label class="flex flex-row items-center w-full gap-24 mb-10 form-control">
|
||||
<div class="">
|
||||
<div class="label">
|
||||
|
||||
@@ -135,7 +135,7 @@ onMounted(() => {
|
||||
<dialog id="my_modal_1" ref="resetDataDialog" class="border-none modal">
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">提示!</h3>
|
||||
<p class="py-4">该操作会重置所有人员数据,是否继续?</p>
|
||||
<p class="py-4">该操作会清空人员中奖信息,是否继续?</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog" class="flex gap-3">
|
||||
<!-- if there is a button in form, it will close the modal -->
|
||||
@@ -159,7 +159,9 @@ onMounted(() => {
|
||||
</div>
|
||||
</dialog>
|
||||
<div class="min-w-1000px">
|
||||
<div class="flex gap-3 justify-">
|
||||
|
||||
<h2>人员管理</h2>
|
||||
<div class="flex gap-3">
|
||||
<button class="btn btn-error btn-sm" @click="delAllDataDialog.showModal()">全部删除</button>
|
||||
<div class="tooltip tooltip-bottom" data-tip="下载文件后,请在excel中填写数据,并保存为xlsx格式">
|
||||
<a class="no-underline btn btn-secondary btn-sm" download="人口登记表.xlsx" target="_blank"
|
||||
@@ -172,13 +174,13 @@ onMounted(() => {
|
||||
<input type="file" class="" id="explore" style="display: none" @change="handleFileChange"
|
||||
:accept="limitType" />
|
||||
|
||||
<span class="btn btn-primary btn-sm">上传文件</span>
|
||||
<span class="btn btn-primary btn-sm">导入人员数据</span>
|
||||
</div>
|
||||
</label>
|
||||
<!-- <button class="btn btn-primary btn-sm">上传excel</button> -->
|
||||
|
||||
</div>
|
||||
<button class="btn btn-error btn-sm" @click="resetDataDialog.showModal()">重置数据</button>
|
||||
<button class="btn btn-error btn-sm" @click="resetDataDialog.showModal()">重置人员数据</button>
|
||||
<button class="btn btn-accent btn-sm" @click="exportData">导出结果</button>
|
||||
<div>
|
||||
<span>中奖人数:</span>
|
||||
|
||||
@@ -105,6 +105,8 @@ const tableColumnsDetail = [
|
||||
|
||||
<template>
|
||||
<div class="overflow-y-auto">
|
||||
|
||||
<h2>已中奖人员管理</h2>
|
||||
<div class="flex items-center justify-start gap-10">
|
||||
<!-- <button class="btn btn-error btn-sm" @click="deleteAll">全部删除</button> -->
|
||||
<div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import useStore from '@/store'
|
||||
import { IPrizeConfig } from '@/types/storeType'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import localforage from 'localforage'
|
||||
import EditSeparateDialog from '@/components/NumberSeparate/EditSeparateDialog.vue'
|
||||
|
||||
const imageDbStore = localforage.createInstance({
|
||||
name: 'imgStore'
|
||||
@@ -15,6 +16,9 @@ const { getPrizeConfig: localPrizeList, getCurrentPrize: currentPrize } = storeT
|
||||
const { getImageList: localImageList } = storeToRefs(globalConfig)
|
||||
const prizeList = ref(localPrizeList)
|
||||
const imgList = ref<any[]>([])
|
||||
|
||||
const selectedPrize = ref<IPrizeConfig | null>()
|
||||
|
||||
const addPrize = () => {
|
||||
const defaultPrizeCOnfig: IPrizeConfig = {
|
||||
id: new Date().getTime().toString(),
|
||||
@@ -22,12 +26,16 @@ const addPrize = () => {
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount:0,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '',
|
||||
name: '',
|
||||
url: ''
|
||||
},
|
||||
separateCount: {
|
||||
enable: false,
|
||||
countList: []
|
||||
},
|
||||
desc: '',
|
||||
isUsed: false,
|
||||
isShow: true,
|
||||
@@ -35,6 +43,49 @@ const addPrize = () => {
|
||||
}
|
||||
prizeConfig.addPrizeConfig(defaultPrizeCOnfig)
|
||||
}
|
||||
|
||||
const selectPrize = (item: IPrizeConfig) => {
|
||||
selectedPrize.value = item
|
||||
selectedPrize.value.isUsedCount = 0
|
||||
selectedPrize.value.isUsed = false
|
||||
|
||||
if (selectedPrize.value.separateCount.countList.length > 1) {
|
||||
return
|
||||
}
|
||||
selectedPrize.value.separateCount = {
|
||||
enable: true,
|
||||
countList: [
|
||||
{
|
||||
id: '0',
|
||||
count: item.count,
|
||||
isUsedCount: 0,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const changePrizeStatus=(item:IPrizeConfig)=>{
|
||||
if(item.isUsed==true){
|
||||
item.isUsedCount=0;
|
||||
if(item.separateCount&&item.separateCount.countList.length){
|
||||
item.separateCount.countList.forEach((countItem:any)=>{
|
||||
countItem.isUsedCount=0;
|
||||
})
|
||||
}
|
||||
}
|
||||
else{
|
||||
item.isUsedCount=item.count;
|
||||
if(item.separateCount&&item.separateCount.countList.length){
|
||||
item.separateCount.countList.forEach((countItem:any)=>{
|
||||
countItem.isUsedCount=countItem.count;
|
||||
})
|
||||
}
|
||||
}
|
||||
item.isUsed=!item.isUsed
|
||||
}
|
||||
const clearSelectedPrize = () => {
|
||||
selectedPrize.value = null
|
||||
}
|
||||
const resetDefault = () => {
|
||||
prizeConfig.resetDefault()
|
||||
}
|
||||
@@ -70,9 +121,10 @@ const delAll = async () => {
|
||||
onMounted(() => {
|
||||
getImageDbStore()
|
||||
})
|
||||
watch(() => prizeList.value, (val:IPrizeConfig[]) => {
|
||||
watch(() => prizeList.value, (val: IPrizeConfig[]) => {
|
||||
prizeConfig.setPrizeConfig(val)
|
||||
}, { deep: true })
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -84,7 +136,14 @@ watch(() => prizeList.value, (val:IPrizeConfig[]) => {
|
||||
<button class="btn btn-error btn-sm" @click="delAll">全部删除</button>
|
||||
|
||||
</div>
|
||||
<ul>
|
||||
<div role="alert" class="w-full my-4 alert alert-info">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="w-6 h-6 stroke-current shrink-0">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
<span>进行操作可能会重置数据,请谨慎操作</span>
|
||||
</div>
|
||||
<ul class="p-0 m-0">
|
||||
<li v-for="item in prizeList" :key="item.id" class="flex gap-10"
|
||||
:class="currentPrize.id == item.id ? 'border-1 border-dotted rounded-xl' : null">
|
||||
<label class="max-w-xs mb-10 form-control">
|
||||
@@ -97,38 +156,43 @@ watch(() => prizeList.value, (val:IPrizeConfig[]) => {
|
||||
:class="prizeList.indexOf(item) == prizeList.length - 1 ? 'opacity-0 cursor-default' : ''"></svg-icon>
|
||||
</div>
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<label class="w-1/2 max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">名称</span>
|
||||
</div>
|
||||
<input type="text" v-model="item.name" placeholder="名称"
|
||||
class="w-full max-w-xs input-sm input input-bordered" />
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<label class="w-1/2 max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">是否全员参加</span>
|
||||
<span class="label-text">全员参加</span>
|
||||
</div>
|
||||
<input type="checkbox" :checked="item.isAll" @change="item.isAll = !item.isAll"
|
||||
class="mt-2 border-solid checkbox checkbox-secondary border-1" />
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<label class="w-1/2 max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">获奖人数</span>
|
||||
<span class="label-text">抽奖人数</span>
|
||||
</div>
|
||||
<input type="number" v-model="item.count" placeholder="获奖人数"
|
||||
class="w-full max-w-xs input-sm input input-bordered" />
|
||||
class="w-full max-w-xs p-0 m-0 input-sm input input-bordered" />
|
||||
<div class="tooltip tooltip-bottom" :data-tip="'已抽取:'+item.isUsedCount + '/' + item.count">
|
||||
<progress class="w-full progress" :value="item.isUsedCount" :max="item.count"></progress>
|
||||
</div>
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<!-- <label class="w-1/2 max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">已获奖人数</span>
|
||||
</div>
|
||||
<input disabled type="number" v-model="item.isUsedCount" placeholder="获奖人数" class="w-full max-w-xs input-sm input input-bordered" />
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<input disabled type="number" v-model="item.isUsedCount" placeholder="获奖人数"
|
||||
class="w-full max-w-xs input-sm input input-bordered" />
|
||||
</label> -->
|
||||
<label class="w-1/2 max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">已抽取</span>
|
||||
</div>
|
||||
<input type="checkbox" :checked="item.isUsed" @change="item.isUsed?(()=>{item.isUsed=false;item.isUsedCount=0})():(()=>{item.isUsed=true;item.isUsedCount=item.count})()"
|
||||
<input type="checkbox" :checked="item.isUsed"
|
||||
@change="changePrizeStatus(item)"
|
||||
class="mt-2 border-solid checkbox checkbox-secondary border-1" />
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
@@ -136,28 +200,31 @@ watch(() => prizeList.value, (val:IPrizeConfig[]) => {
|
||||
<span class="label-text">图片</span>
|
||||
</div>
|
||||
<select class="w-full max-w-xs select select-warning select-sm" v-model="item.picture">
|
||||
|
||||
|
||||
<option v-if="item.picture.id" :value="{id:'',name:'',url:''}"><span>❌</span></option>
|
||||
<option v-if="item.picture.id" :value="{ id: '', name: '', url: '' }"><span>❌</span></option>
|
||||
<option disabled selected>选择一张图片</option>
|
||||
<option v-for="picItem in localImageList" :key="picItem.id" :value="picItem">{{ picItem.name }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<!-- <label class="w-full max-w-xs mb-10 form-control">
|
||||
<label class="w-full max-w-xs mb-10 form-control" v-if="item.separateCount">
|
||||
<div class="label">
|
||||
<span class="label-text">展示在主界面</span>
|
||||
<span class="label-text">单次抽取个数</span>
|
||||
</div>
|
||||
<input type="checkbox" :checked="item.isShow" @change="item.isShow = !item.isShow"
|
||||
class="mt-2 border-solid checkbox checkbox-secondary border-1" />
|
||||
</label> -->
|
||||
<!-- <label class="w-full max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">抽取次数</span>
|
||||
<div class="flex justify-start w-full h-full" @click="selectPrize(item)">
|
||||
<ul class="flex flex-wrap w-full h-full gap-1 p-0 pt-1 m-0 cursor-pointer"
|
||||
v-if="item.separateCount.countList.length">
|
||||
<li class="relative flex items-center justify-center w-8 h-8 bg-slate-600/60 separated"
|
||||
v-for="se in item.separateCount.countList" :key="se.id">
|
||||
<div class="flex items-center justify-center w-full h-full tooltip" :data-tip="'已抽取:'+se.isUsedCount + '/' + se.count">
|
||||
<div class="absolute left-0 z-50 h-full bg-blue-300/80"
|
||||
:style="`width:${se.isUsedCount * 100 / se.count}%`"></div>
|
||||
<span>{{ se.count }}</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<button v-else class="btn btn-secondary btn-xs">设置</button>
|
||||
</div>
|
||||
<input type="text" v-model="item.frequency" placeholder="抽取次数"
|
||||
class="w-full max-w-xs input-sm input input-bordered" />
|
||||
</label> -->
|
||||
</label>
|
||||
<label class="w-full max-w-xs mb-10 form-control">
|
||||
<div class="label">
|
||||
<span class="label-text">操作</span>
|
||||
@@ -168,6 +235,9 @@ watch(() => prizeList.value, (val:IPrizeConfig[]) => {
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div></template>
|
||||
<EditSeparateDialog :totalNumber="selectedPrize?.count" :separated-number="selectedPrize?.separateCount.countList"
|
||||
@clearData="clearSelectedPrize" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang='scss' scoped></style>
|
||||
|
||||
@@ -17,7 +17,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-10 ml-3">
|
||||
<div class="w-3/4 mb-10 ml-3">
|
||||
<div class="markdown-body" v-dompurify-html="readmeHtml"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<script setup lang='ts'>
|
||||
|
||||
import StarsBackground from '../../components/StarsBackground/index.vue'
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<StarsBackground></StarsBackground>
|
||||
<button class="btn btn-error">打印</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -403,21 +403,20 @@ const stopLottery = async () => {
|
||||
intervalTimer.value = null
|
||||
canOperate.value = false
|
||||
rollBall(0, 1)
|
||||
// 抽奖池是否为全体人员
|
||||
// 每次最多抽十个
|
||||
luckyCount.value = 10
|
||||
const leftover = currentPrize.value.count - currentPrize.value.isUsedCount
|
||||
leftover < luckyCount.value ? luckyCount.value = leftover : luckyCount
|
||||
if (personPool.value.length < leftover) {
|
||||
toast.open({
|
||||
message: '抽奖人数不够',
|
||||
type: 'warning',
|
||||
position: 'top-right',
|
||||
duration: 10000
|
||||
})
|
||||
// 自定义抽奖个数
|
||||
|
||||
return;
|
||||
let leftover = currentPrize.value.count - currentPrize.value.isUsedCount
|
||||
const customCount=currentPrize.value.separateCount
|
||||
if(customCount&&customCount.enable&&customCount.countList.length>0){
|
||||
for(let i=0;i<customCount.countList.length;i++){
|
||||
if(customCount.countList[i].isUsedCount<customCount.countList[i].count){
|
||||
leftover=customCount.countList[i].count-customCount.countList[i].isUsedCount
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
leftover < luckyCount.value ? luckyCount.value = leftover : luckyCount
|
||||
for (let i = 0; i < luckyCount.value; i++) {
|
||||
if (personPool.value.length > 0) {
|
||||
const randomIndex = Math.round(Math.random() * (personPool.value.length - 1))
|
||||
@@ -465,6 +464,16 @@ const continueLottery = async () => {
|
||||
if (!canOperate.value) {
|
||||
return
|
||||
}
|
||||
|
||||
const customCount=currentPrize.value.separateCount
|
||||
if(customCount&&customCount.enable&&customCount.countList.length>0){
|
||||
for(let i=0;i<customCount.countList.length;i++){
|
||||
if(customCount.countList[i].isUsedCount<customCount.countList[i].count){
|
||||
customCount.countList[i].isUsedCount+= luckyCount.value
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentPrize.value.isUsedCount += luckyCount.value
|
||||
luckyCount.value = 0
|
||||
if (currentPrize.value.isUsedCount >= currentPrize.value.count) {
|
||||
|
||||
@@ -4,6 +4,9 @@ module.exports = {
|
||||
corePlugins: {
|
||||
preflight: false
|
||||
},
|
||||
theme: {
|
||||
|
||||
},
|
||||
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
|
||||
plugins: [require('@tailwindcss/typography'), require('daisyui')],
|
||||
daisyui: {
|
||||
|
||||
Reference in New Issue
Block a user