feat: new

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-08 00:48:54 +08:00
parent 18c5429b58
commit bea54865ea
30 changed files with 1149 additions and 373 deletions

View File

@@ -72,6 +72,7 @@ export const defaultPrizeList=<IPrizeConfig[]>[
},
desc:'一等奖',
isShow:true,
isUsed:false,
frequency:1,
},
{
@@ -87,6 +88,7 @@ export const defaultPrizeList=<IPrizeConfig[]>[
},
desc:'二等奖',
isShow:true,
isUsed:false,
frequency:1,
},
{
@@ -102,6 +104,7 @@ export const defaultPrizeList=<IPrizeConfig[]>[
},
desc:'三等奖',
isShow:true,
isUsed:false,
frequency:1,
},
{
@@ -117,6 +120,7 @@ export const defaultPrizeList=<IPrizeConfig[]>[
},
desc:'超级大奖',
isShow:true,
isUsed:false,
frequency:1,
},
{
@@ -132,6 +136,7 @@ export const defaultPrizeList=<IPrizeConfig[]>[
},
desc:'特别奖',
isShow:true,
isUsed:false,
frequency:1,
}
]

View File

@@ -6,6 +6,7 @@ export const useGlobalConfig = defineStore('global', {
return {
globalConfig: {
rowCount: 12,
isSHowPrizeList:true,
theme: {
name: 'dark',
detail: { primary: '#0f5fd3' },
@@ -13,6 +14,7 @@ export const useGlobalConfig = defineStore('global', {
cardWidth: 140,
cardHeight: 200,
textColor: '#ffffff',
luckyCardColor:'#ECB1AC',
textSize: 30
},
musicList: defaultMusicList,
@@ -37,6 +39,10 @@ export const useGlobalConfig = defineStore('global', {
getCardColor(state) {
return state.globalConfig.theme.cardColor;
},
// 获取中奖颜色
getLuckyColor(state) {
return state.globalConfig.theme.luckyCardColor;
},
// 获取文字颜色
getTextColor(state) {
return state.globalConfig.theme.textColor;
@@ -59,6 +65,10 @@ export const useGlobalConfig = defineStore('global', {
// 获取图片列表
getImageList(state) {
return state.globalConfig.imageList;
},
// 获取是否显示奖品列表
getIsShowPrizeList(state) {
return state.globalConfig.isSHowPrizeList;
}
},
@@ -77,6 +87,10 @@ export const useGlobalConfig = defineStore('global', {
setCardColor(cardColor: string) {
this.globalConfig.theme.cardColor = cardColor;
},
// 设置中奖颜色
setLuckyCardColor(luckyCardColor: string) {
this.globalConfig.theme.luckyCardColor = luckyCardColor;
},
// 设置文字颜色
setTextColor(textColor: string) {
this.globalConfig.theme.textColor = textColor;
@@ -143,14 +157,20 @@ export const useGlobalConfig = defineStore('global', {
clearImageList() {
this.globalConfig.imageList = [];
},
// 设置是否显示奖品列表
setIsShowPrizeList(isShowPrizeList: boolean) {
this.globalConfig.isSHowPrizeList = isShowPrizeList;
},
// 重置所有配置
reset() {
this.globalConfig = {
rowCount: 12,
isSHowPrizeList:true,
theme: {
name: 'dark',
detail: { primary: '#0f5fd3' },
cardColor: 'rgba(0, 255, 255)',
luckyCardColor:'#ECB1AC',
cardWidth: 200,
cardHeight: 140,
textColor: '#ffffff',

View File

@@ -1,114 +1,114 @@
import { defineStore } from 'pinia';
import { IPersonConfig } from '@/types/personConfig';
export const usePersonConfig = defineStore('person', {
state() {
return {
personConfig:{
alreadyPersonList:[] as IPersonConfig[],
notPersonList:[] as IPersonConfig[],
tableRowCount:12,
showField:[] as any[]
}
};
},
getters: {
// 获取全部配置
getPersonConfig(state) {
return state.personConfig;
state() {
return {
personConfig: {
alreadyPersonList: [] as IPersonConfig[],
notPersonList: [] as IPersonConfig[],
tableRowCount: 12,
showField: [] as any[]
}
};
},
// 获取已中奖人员名单
getAlreadyPersonList(state) {
return state.personConfig.alreadyPersonList;
},
// 获取未中奖人员名单
getNotPersonList(state) {
return state.personConfig.notPersonList;
},
// 获取所有人员名单
getAllPersonList(state) {
return state.personConfig.alreadyPersonList.concat(state.personConfig.notPersonList);
},
// 获取table列数
getTableRowCount(state) {
return state.personConfig.tableRowCount;
},
// 获取要展示那些字段
getShowField(state) {
return state.personConfig.showField;
}
},
actions: {
// 添加未中奖人员
addNotPersonList(personList: IPersonConfig[]) {
if(personList.length<=0){
return
}
personList.forEach((item: IPersonConfig) => {
this.personConfig.notPersonList.push(item);
});
},
// 添加已中奖人员
addAlreadyPersonList(personList: IPersonConfig[]) {
if(personList.length<=0){
return
}
personList.forEach((item: IPersonConfig) => {
this.personConfig.alreadyPersonList.push(item);
this.personConfig.notPersonList = this.personConfig.notPersonList.filter((item: IPersonConfig) => item.id!== item.id);
});
},
// 删除指定人员
deletePerson(person:IPersonConfig){
console.log('delperson:',person);
if(person.id!=undefined||person.id!=null){
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id!== person.id);
this.personConfig.notPersonList = this.personConfig.notPersonList.filter((item: IPersonConfig) => item.id!== person.id);
getters: {
// 获取全部配置
getPersonConfig(state) {
return state.personConfig;
},
// 获取已中奖人员名单
getAlreadyPersonList(state) {
return state.personConfig.alreadyPersonList;
},
// 获取未中奖人员名单
getNotPersonList(state) {
return state.personConfig.notPersonList;
},
// 获取所有人员名单
getAllPersonList(state) {
return state.personConfig.alreadyPersonList.concat(state.personConfig.notPersonList);
},
// 获取table列数
getTableRowCount(state) {
return state.personConfig.tableRowCount;
},
// 获取要展示那些字段
getShowField(state) {
return state.personConfig.showField;
}
},
// 删除所有人员
deleteAllPerson() {
this.personConfig.alreadyPersonList = [];
this.personConfig.notPersonList = [];
},
// 设置table列数
setTableRowCount(tableRowCount: number) {
this.personConfig.tableRowCount = tableRowCount;
},
// 设置要展示那些字段
setShowFields(showField: any[]) {
this.personConfig.showField = showField;
},
// 重置所有人员
resetPerson() {
this.personConfig.alreadyPersonList = [];
this.personConfig.notPersonList = [];
},
// 重置已中奖人员
resetAlreadyPerson() {
// 把已中奖人员合并到未中奖人员,要验证是否已存在
if(this.personConfig.alreadyPersonList.length>0){
this.personConfig.notPersonList = this.personConfig.notPersonList.concat(this.personConfig.alreadyPersonList);
actions: {
// 添加未中奖人员
addNotPersonList(personList: IPersonConfig[]) {
if (personList.length <= 0) {
return
}
personList.forEach((item: IPersonConfig) => {
this.personConfig.notPersonList.push(item);
});
},
// 添加已中奖人员
addAlreadyPersonList(personList: IPersonConfig[]) {
if (personList.length <= 0) {
return
}
personList.forEach((person: IPersonConfig) => {
this.personConfig.notPersonList = this.personConfig.notPersonList.filter((item: IPersonConfig) =>
item.id !== person.id)
this.personConfig.alreadyPersonList.push(person);
});
},
// 删除指定人员
deletePerson(person: IPersonConfig) {
if (person.id != undefined || person.id != null) {
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id !== person.id);
this.personConfig.notPersonList = this.personConfig.notPersonList.filter((item: IPersonConfig) => item.id !== person.id);
}
},
// 删除所有人员
deleteAllPerson() {
this.personConfig.alreadyPersonList = [];
}
this.personConfig.notPersonList = [];
},
// 设置table列数
setTableRowCount(tableRowCount: number) {
this.personConfig.tableRowCount = tableRowCount;
},
// 设置要展示那些字段
setShowFields(showField: any[]) {
this.personConfig.showField = showField;
},
// 重置所有人员
resetPerson() {
this.personConfig.alreadyPersonList = [];
this.personConfig.notPersonList = [];
},
// 重置已中奖人员
resetAlreadyPerson() {
// 把已中奖人员合并到未中奖人员,要验证是否已存在
if (this.personConfig.alreadyPersonList.length > 0) {
this.personConfig.notPersonList = this.personConfig.notPersonList.concat(this.personConfig.alreadyPersonList);
this.personConfig.alreadyPersonList = [];
}
},
// 重置所有配置
reset() {
this.personConfig = {
alreadyPersonList: [] as IPersonConfig[],
notPersonList: [] as IPersonConfig[],
tableRowCount: 12,
showField: [] as string[]
}
},
},
// 重置所有配置
reset() {
this.personConfig = {
alreadyPersonList:[] as IPersonConfig[],
notPersonList:[] as IPersonConfig[],
tableRowCount:12,
showField:[] as string[]
}
persist: {
enabled: true,
strategies: [
{
// 如果要存储在localStorage中
storage: localStorage,
key: 'personConfig',
},
],
},
},
persist: {
enabled: true,
strategies: [
{
// 如果要存储在localStorage中
storage: localStorage,
key: 'personConfig',
},
],
},
});

View File

@@ -1,68 +1,108 @@
import { defineStore } from 'pinia';
import { IPrizeConfig } from '@/types/prizeConfig';
import {defaultPrizeList} from './data';
import { defaultPrizeList } from './data';
export const usePrizeConfig = defineStore('prize', {
state() {
return {
prizeConfig:{
prizeList:defaultPrizeList,
}
};
},
getters: {
// 获取全部配置
getPrizeConfigAll(state) {
return state.prizeConfig;
state() {
return {
prizeConfig: {
prizeList: defaultPrizeList,
currentPrize: {
id: '001',
name: '一等奖',
sort: 1,
isAll: true,
count: 1,
picture: {
id: '0',
name: '一等奖',
url: 'https://24years.top/resource/image/image1.png'
},
desc: '一等奖',
isShow: true,
isUsed: false,
frequency: 1,
} as IPrizeConfig
}
};
},
// 获取奖品列表
getPrizeConfig(state) {
return state.prizeConfig.prizeList;
getters: {
// 获取全部配置
getPrizeConfigAll(state) {
return state.prizeConfig;
},
// 获取奖品列表
getPrizeConfig(state) {
return state.prizeConfig.prizeList;
},
// 根据id获取配置
getPrizeConfigById(state) {
return (id: number | string) => {
return state.prizeConfig.prizeList.find(item => item.id === id);
}
},
// 获取当前奖项
getCurrentPrize(state) {
return state.prizeConfig.currentPrize;
},
},
// 根据id获取配置
getPrizeConfigById(state) {
return (id: number|string) => {
return state.prizeConfig.prizeList.find(item => item.id === id);
}
},
},
actions: {
// 设置奖项
setPrizeConfig(prizeList:IPrizeConfig[]) {
this.prizeConfig.prizeList = prizeList;
},
// 添加奖项
addPrizeConfig(prizeConfigItem: IPrizeConfig) {
this.prizeConfig.prizeList.push(prizeConfigItem);
},
// 删除奖项
deletePrizeConfig(prizeConfigItemId: number|string) {
this.prizeConfig.prizeList = this.prizeConfig.prizeList.filter(item => item.id!== prizeConfigItemId);
},
// 更新奖项数据
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
const index = this.prizeConfig.prizeList.findIndex(item => item.id === prizeConfigItem.id);
this.prizeConfig.prizeList[index] = prizeConfigItem;
},
// 删除全部奖项
deleteAllPrizeConfig() {
this.prizeConfig.prizeList = [];
},
// 重置所有配置
resetDefault() {
this.prizeConfig = {
prizeList:defaultPrizeList,
actions: {
// 设置奖项
setPrizeConfig(prizeList: IPrizeConfig[]) {
this.prizeConfig.prizeList = prizeList;
},
// 添加奖项
addPrizeConfig(prizeConfigItem: IPrizeConfig) {
this.prizeConfig.prizeList.push(prizeConfigItem);
},
// 删除奖项
deletePrizeConfig(prizeConfigItemId: number | string) {
this.prizeConfig.prizeList = this.prizeConfig.prizeList.filter(item => item.id !== prizeConfigItemId);
},
// 更新奖项数据
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
const index = this.prizeConfig.prizeList.findIndex(item => item.id === prizeConfigItem.id);
this.prizeConfig.prizeList[index] = prizeConfigItem;
},
// 删除全部奖项
deleteAllPrizeConfig() {
this.prizeConfig.prizeList = [];
},
// 设置当前奖项
setCurrentPrize(prizeConfigItem: IPrizeConfig) {
this.prizeConfig.currentPrize = prizeConfigItem;
},
// 重置所有配置
resetDefault() {
this.prizeConfig = {
prizeList: defaultPrizeList,
currentPrize: {
id: '001',
name: '一等奖',
sort: 1,
isAll: true,
count: 1,
picture: {
id: '0',
name: '一等奖',
url: 'https://24years.top/resource/image/image1.png'
},
desc: '一等奖',
isShow: true,
isUsed: false,
frequency: 1,
},
}
}
},
},
persist: {
enabled: true,
strategies: [
{
// 如果要存储在localStorage
storage: localStorage,
key: 'personConfig',
},
],
},
persist: {
enabled: true,
strategies: [
{
// 如果要存储在localStorage中
storage: localStorage,
key: 'personConfig',
},
],
},
});