feat(for): for

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-09 01:03:42 +08:00
parent bea54865ea
commit f34e850ff0
26 changed files with 500 additions and 404 deletions

View File

@@ -12,7 +12,7 @@ import { isRgbOrRgba, isHex } from '@/utils/color'
const globalConfig = useStore().globalConfig
const personConfig = useStore().personConfig
const { getTheme: localTheme, getCardColor: cardColor,getLuckyColor:luckyCardColor, getTextColor: textColor, getCardSize: cardSize, getTextSize: textSize, getRowCount: rowCount,getIsShowPrizeList:isShowPrizeList } = storeToRefs(globalConfig)
const {getTopTitle:topTitle, getTheme: localTheme, 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()
@@ -21,6 +21,7 @@ interface ThemeDaType {
}
const isRowCountChange = ref(0) //0未改变1改变,2加载中
const themeValue = ref(localTheme.value.name)
const topTitleValue= ref(structuredClone(topTitle.value))
const cardColorValue = ref(structuredClone(cardColor.value))
const luckyCardColorValue = ref(structuredClone(luckyCardColor.value))
const textColorValue = ref(structuredClone(textColor.value))
@@ -71,7 +72,7 @@ const resetPersonLayout = () => {
const newNotPersonList = newList.slice(alreadyLen, notLen + alreadyLen)
personConfig.deleteAllPerson()
personConfig.addNotPersonList(newNotPersonList)
personConfig.addAlreadyPersonList(newAlreadyPersonList)
personConfig.addAlreadyPersonList(newAlreadyPersonList,null)
isRowCountChange.value = 0
}, 1000)
@@ -130,6 +131,15 @@ onMounted(() => {
<template>
<div>
<label class="flex flex-row items-center w-full gap-24 mb-10 form-control">
<div class="">
<div class="label">
<span class="label-text">标题</span>
</div>
<input type="text" v-model="topTitleValue" placeholder="输入标题"
class="w-full max-w-xs input input-bordered" />
</div>
</label>
<label class="flex flex-row items-center w-full gap-24 mb-10 form-control">
<div class="">
<div class="label">

View File

@@ -5,7 +5,7 @@ import useStore from '@/store'
import {storeToRefs } from 'pinia'
import * as XLSX from 'xlsx'
import { readFile } from '@/utils/file'
import {filterData} from '@/utils'
import {filterData,addOtherInfo} from '@/utils'
import DaiysuiTable from '@/components/DaiysuiTable/index.vue'
const personConfig = useStore().personConfig
@@ -23,9 +23,9 @@ const handleFileChange = async (e: any) => {
let workSheet = workBook.Sheets[workBook.SheetNames[0]]
excelData.value = XLSX.utils.sheet_to_json(workSheet)
const uploadData = filterData(excelData.value,rowCount.value)
const allData=addOtherInfo(uploadData);
personConfig.resetPerson()
personConfig.addNotPersonList(uploadData)
personConfig.addNotPersonList(allData)
}
const deleteAll = () => {

View File

@@ -2,19 +2,22 @@
<script setup lang='ts'>
import { ref } from 'vue';
import useStore from '@/store'
import { storeToRefs } from 'pinia';
import DaiysuiTable from '@/components/DaiysuiTable/index.vue'
const personConfig = useStore().personConfig
const { getAlreadyPersonList: alreadyPersonList } = personConfig
const personList = ref<any[]>(
alreadyPersonList
)
const { getAlreadyPersonList: alreadyPersonList } = storeToRefs(personConfig)
// const personList = ref<any[]>(
// alreadyPersonList
// )
const deleteAll = () => {
personConfig.deleteAllPerson()
personList.value = alreadyPersonList
}
const handleMoveNotPerson=(row:any)=>{
personConfig.moveAlreadyToNot(row)
}
const tableColumns = [
@@ -34,14 +37,23 @@ const tableColumns = [
label: '职位',
props: 'other',
},
{
label:'奖品',
props:'prizeName'
},
{
label: '中奖时间',
props: 'prizeTime',
},
{
label: '操作',
actions: [
{
label: '编辑',
label: '移入未中奖名单',
type: 'btn-info',
onClick: (row: any) => {
console.log('编辑:', row)
handleMoveNotPerson(row)
}
},
{
@@ -63,7 +75,7 @@ const tableColumns = [
<button class="btn btn-error btn-sm" @click="deleteAll">全部删除</button>
</div>
<DaiysuiTable :tableColumns="tableColumns" :data="personList"></DaiysuiTable>
<DaiysuiTable :tableColumns="tableColumns" :data="alreadyPersonList"></DaiysuiTable>
</div>
</template>

View File

@@ -1,7 +1,7 @@
<script setup lang='ts'>
import { ref, onMounted,watch } from 'vue'
import { ref, onMounted, watch } from 'vue'
import useStore from '@/store'
import {storeToRefs } from 'pinia'
import { storeToRefs } from 'pinia'
import localforage from 'localforage'
import { IPrizeConfig } from '@/types/prizeConfig';
@@ -10,9 +10,9 @@ const imageDbStore = localforage.createInstance({
})
const prizeConfig = useStore().prizeConfig
const globalConfig = useStore().globalConfig
const { getPrizeConfig:localPrizeList} = storeToRefs(prizeConfig)
const { getPrizeConfig: localPrizeList, getCurrentPrize: currentPrize } = storeToRefs(prizeConfig)
const { getImageList:localImageList} = storeToRefs(globalConfig)
const { getImageList: localImageList } = storeToRefs(globalConfig)
const prizeList = ref(localPrizeList)
const imgList = ref<any[]>([])
const addPrize = () => {
@@ -22,10 +22,11 @@ const addPrize = () => {
sort: 0,
isAll: true,
count: 1,
isUsedCount:0,
picture: {
id:'',
name:'',
url:''
id: '',
name: '',
url: ''
},
desc: '',
isUsed: false,
@@ -34,7 +35,7 @@ const addPrize = () => {
}
prizeConfig.addPrizeConfig(defaultPrizeCOnfig)
}
const resetDefault=()=>{
const resetDefault = () => {
prizeConfig.resetDefault()
}
@@ -50,60 +51,65 @@ const getImageDbStore = async () => {
}
}
const sort = (item:any,isUp:number) => {
const itemIndex=prizeList.value.indexOf(item)
if(isUp==1){
prizeList.value.splice(itemIndex,1)
prizeList.value.splice(itemIndex-1,0,item)
}else{
prizeList.value.splice(itemIndex,1)
prizeList.value.splice(itemIndex+1,0,item)
const sort = (item: any, isUp: number) => {
const itemIndex = prizeList.value.indexOf(item)
if (isUp == 1) {
prizeList.value.splice(itemIndex, 1)
prizeList.value.splice(itemIndex - 1, 0, item)
} else {
prizeList.value.splice(itemIndex, 1)
prizeList.value.splice(itemIndex + 1, 0, item)
}
}
const delItem=(item:IPrizeConfig)=>{
const delItem = (item: IPrizeConfig) => {
prizeConfig.deletePrizeConfig(item.id)
// 更新奖项列表
}
const delAll=async ()=>{
await prizeConfig.deleteAllPrizeConfig()
const delAll = async () => {
await prizeConfig.deleteAllPrizeConfig()
}
onMounted(() => {
getImageDbStore()
})
watch(()=>prizeList,()=>{
watch(() => prizeList, () => {
prizeConfig.setPrizeConfig(prizeList.value)
},{deep:true})
}, { deep: true })
</script>
<template>
<div>
<h2>奖项配置</h2>
<div class="flex w-full gap-3">
<button class="btn btn-info btn-sm" @click="addPrize">添加</button>
<button class="btn btn-info btn-sm" @click="resetDefault">默认列表</button>
<button class="btn btn-error btn-sm" @click="delAll">全部删除</button>
</div>
<button class="btn btn-info btn-sm" @click="addPrize">添加</button>
<button class="btn btn-info btn-sm" @click="resetDefault">默认列表</button>
<button class="btn btn-error btn-sm" @click="delAll">全部删除</button>
</div>
<ul>
<li v-for="item in prizeList" :key="item.id" class="flex gap-10">
<li v-for="item in prizeList" :key="item.id" class="flex gap-10"
:class="currentPrize.id == item.id ? 'border-1 border-solid rounded-xl' : null">
<label class="max-w-xs mb-10 form-control">
<!-- 向上向下 -->
<div class="flex flex-col items-center gap-2 pt-5">
<svg-icon class="cursor-pointer hover:text-blue-400" :class="prizeList.indexOf(item)==0?'opacity-0 cursor-default':''" name="up" @click="sort(item,1)"></svg-icon>
<svg-icon class="cursor-pointer hover:text-blue-400" name="down" @click="sort(item,0)" :class="prizeList.indexOf(item)==prizeList.length-1?'opacity-0 cursor-default':''"></svg-icon>
<svg-icon class="cursor-pointer hover:text-blue-400"
:class="prizeList.indexOf(item) == 0 ? 'opacity-0 cursor-default' : ''" name="up"
@click="sort(item, 1)"></svg-icon>
<svg-icon class="cursor-pointer hover:text-blue-400" name="down" @click="sort(item, 0)"
: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">
<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" />
<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">
<div class="label">
<span class="label-text">是否全员参加</span>
</div>
<input type="checkbox" :checked="item.isAll" @change="item.isAll =!item.isAll"
<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">
@@ -113,39 +119,46 @@ watch(()=>prizeList,()=>{
<input type="number" v-model="item.count" placeholder="获奖人数"
class="w-full max-w-xs input-sm input input-bordered" />
</label>
<label class="w-full 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">
<div class="label">
<span class="label-text">图片</span>
</div>
<select class="w-full max-w-xs select select-warning select-sm" v-model="item.picture">
<select class="w-full max-w-xs select select-warning select-sm" v-model="item.picture">
<option disabled selected>选择一张图片</option>
<option v-for="picItem in localImageList" :key="picItem.id" :value="picItem">{{ picItem.name }}</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">
<div class="label">
<span class="label-text">展示在主界面</span>
</div>
<input type="checkbox" :checked="item.isShow" @change="item.isShow =!item.isShow"
<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>
<input type="text" v-model="item.frequency" placeholder="抽取次数" class="w-full max-w-xs input-sm input input-bordered" />
<input type="text" v-model="item.frequency" placeholder="抽取次数"
class="w-full max-w-xs input-sm input input-bordered" />
</label>
<label class="w-full max-w-xs mb-10 form-control">
<div class="label">
<span class="label-text">操作</span>
</div>
<div class="flex gap-2">
<button class="btn btn-error btn-sm" @click="delItem(item)">删除</button>
</div>
<button class="btn btn-error btn-sm" @click="delItem(item)">删除</button>
</div>
</label>
</li>
</ul>
</div>
</template>
</div></template>
<style lang='scss' scoped></style>

View File

@@ -71,11 +71,9 @@ const skip = (path: string) => {
</nav>
<nav>
<div class="grid grid-flow-col gap-4">
<a><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="fill-current">
<path
d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z">
</path>
</svg></a>
<a href="https://github.com/LOG1997/log-lottery" target="_blank" class="cursor-pointer">
<svg-icon name="github"></svg-icon>
</a>
<a><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="fill-current">
<path
d="M19.615 3.184c-3.604-.246-11.631-.245-15.23 0-3.897.266-4.356 2.62-4.385 8.816.029 6.185.484 8.549 4.385 8.816 3.6.245 11.626.246 15.23 0 3.897-.266 4.356-2.62 4.385-8.816-.029-6.185-.484-8.549-4.385-8.816zm-10.615 12.816v-8l8 3.993-8 4.007z">