feat: add reset all data in global config
This commit is contained in:
@@ -76,15 +76,7 @@ export const defaultPrizeList = <IPrizeConfig[]>[
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: [{
|
||||
id: '0',
|
||||
count: 6,
|
||||
isUsedCount: 0,
|
||||
}, {
|
||||
id: '1',
|
||||
count: 6,
|
||||
isUsedCount: 0,
|
||||
}]
|
||||
countList: []
|
||||
},
|
||||
desc: '三等奖',
|
||||
isShow: true,
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -30,8 +30,8 @@ export const usePersonConfig = defineStore('person', {
|
||||
const data = state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return !item.prizeId.includes(currentPrize.id as string);
|
||||
});
|
||||
|
||||
return data
|
||||
|
||||
return data
|
||||
},
|
||||
// 获取已中奖人员名单
|
||||
getAlreadyPersonList(state) {
|
||||
@@ -99,7 +99,7 @@ return data
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < alreadyPersonListLength; i++) {
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) =>
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) =>
|
||||
item.id !== person.id
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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,19 +115,19 @@ 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
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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 -->
|
||||
@@ -161,7 +161,7 @@ onMounted(() => {
|
||||
<div class="min-w-1000px">
|
||||
|
||||
<h2>人员管理</h2>
|
||||
<div class="flex gap-3 justify-">
|
||||
<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"
|
||||
@@ -180,7 +180,7 @@ onMounted(() => {
|
||||
<!-- <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>
|
||||
|
||||
Reference in New Issue
Block a user