Merge branch 'khj'

This commit is contained in:
khj0414 2025-03-11 14:27:01 +09:00
commit 936be84a6f
5 changed files with 31 additions and 14 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="card mb-6" :class="{'disabled-class': data.localVote.LOCVOTDDT}" > <div class="card mb-6" :class="{ 'disabled-class': data.localVote.LOCVOTDDT && (topVoters.length == 1 || data.localVote.LOCVOTRES || voteResult == 0)}">
<div class="card-body" v-if="!data.localVote.LOCVOTDEL" > <div class="card-body" v-if="!data.localVote.LOCVOTDEL" >
<h5 class="card-title mb-1"> <h5 class="card-title mb-1">
<div class="list-unstyled users-list d-flex align-items-center gap-1"> <div class="list-unstyled users-list d-flex align-items-center gap-1">
@ -15,10 +15,9 @@
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="user-info"> <div class="user-info">
<h6 class="mb-1">{{ data.localVote.MEMBERNAM }}</h6> <h6 class="mb-1">{{ data.localVote.MEMBERNAM }}</h6>
<!-- 투표완료시 -->
</div> </div>
<div class="add-btn d-flex align-items-center"> <div class="add-btn d-flex align-items-center">
<!-- 투표완료시 -->
<i v-if="yesVotetotal != '0'" class="bx bxs-check-circle link-success"></i>
<!-- 투표작성자만 수정/삭제/종료 가능 --> <!-- 투표작성자만 수정/삭제/종료 가능 -->
<div v-if="userStore.user.id === data.localVote.LOCVOTREG"> <div v-if="userStore.user.id === data.localVote.LOCVOTREG">
<button <button
@ -31,6 +30,7 @@
<DeleteBtn v-if="!data.localVote.LOCVOTDDT" @click="voteDelete(data.localVote.LOCVOTSEQ)" /> <DeleteBtn v-if="!data.localVote.LOCVOTDDT" @click="voteDelete(data.localVote.LOCVOTSEQ)" />
</div> </div>
<p v-if="data.localVote.LOCVOTDDT" class="btn-icon btn-danger rounded-2"><i class="bx bx-power-off"></i></p> <p v-if="data.localVote.LOCVOTDDT" class="btn-icon btn-danger rounded-2"><i class="bx bx-power-off"></i></p>
<i v-if="yesVotetotal != '0'" class="bx bxs-check-circle link-success"></i>
</div> </div>
</div> </div>
</div> </div>
@ -55,7 +55,7 @@
<!-- 투표 결과 --> <!-- 투표 결과 -->
<div v-if="data.localVote.LOCVOTDDT" class="mt-3"> <div v-if="data.localVote.LOCVOTDDT" class="mt-3">
<vote-result-list :data="data.voteDetails" @randomList="randomList" :randomResultNum="data.localVote.LOCVOTRES"/> <vote-result-list :data="topVoters" @randomList="randomList" :randomResultNum="data.localVote.LOCVOTRES" :locvotreg="data.localVote.LOCVOTREG"/>
</div> </div>
<!-- 투표완/미완 인원 --> <!-- 투표완/미완 인원 -->
<vote-user-list <vote-user-list
@ -96,6 +96,14 @@ const yesVotetotal = computed(() => {
return props.data.voteDetails.reduce((sum, item) => sum + item.yesvote, 0); return props.data.voteDetails.reduce((sum, item) => sum + item.yesvote, 0);
}); });
// (1)
const topVoters = computed(() => {
// VOTE_COUNT
const maxVoteCount = Math.max(...props.data.voteDetails.map(item => item.VOTE_COUNT));
// VOTE_COUNT
return props.data.voteDetails.filter(item => item.VOTE_COUNT === maxVoteCount);
});
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, ''); const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
const userStore = useUserInfoStore(); const userStore = useUserInfoStore();
const currentDate = new Date(); const currentDate = new Date();

View File

@ -2,7 +2,7 @@
<div class="card mb-6 border border-2 border-primary rounded primary-shadow"> <div class="card mb-6 border border-2 border-primary rounded primary-shadow">
<div class="card-body"> <div class="card-body">
<!-- 1위가 여러개일때 --> <!-- 1위가 여러개일때 -->
<vote-result-random v-if="topVoters.length > 1" :data="topVoters" :randomResultNum="randomResultNum" <vote-result-random v-if="topVoters.length > 1" :data="topVoters" :randomResultNum="randomResultNum" :locvotreg="locvotreg"
@randomList="randomList"/> @randomList="randomList"/>
<!-- 1위가 하나일때--> <!-- 1위가 하나일때-->
<vote-result-card v-if="topVoters.length == 1" :data="topVoters"/> <vote-result-card v-if="topVoters.length == 1" :data="topVoters"/>
@ -24,6 +24,10 @@ const props = defineProps({
type: String, type: String,
required: false, required: false,
}, },
locvotreg: {
type: Number,
required: false,
},
}); });
// (1) // (1)
const topVoters = computed(() => { const topVoters = computed(() => {

View File

@ -16,9 +16,8 @@
<span class="spinner-grow me-1" role="status" aria-hidden="true"></span> <span class="spinner-grow me-1" role="status" aria-hidden="true"></span>
random.. random..
</button> </button>
<div class="d-grid w-100 mt-6"> <div class="d-grid w-100 mt-6" v-if="userStore.user.id === locvotreg">
<button v-if="!isRandom && !randomResultNum" @click="randomList" class="btn btn-primary"><i class='bx bx-sync'></i></button> <button v-if="!isRandom && !randomResultNum" @click="randomList" class="btn btn-primary"><i class='bx bx-sync'></i></button>
</div> </div>
</template> </template>
@ -26,6 +25,7 @@
import voteResultRandomList from "@c/voteboard/voteResultRandomList.vue" import voteResultRandomList from "@c/voteboard/voteResultRandomList.vue"
import voteResultCard from '@c/voteboard/voteResultCard.vue'; import voteResultCard from '@c/voteboard/voteResultCard.vue';
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import { useUserInfoStore } from "@s/useUserInfoStore";
const emit = defineEmits(['randomList']); const emit = defineEmits(['randomList']);
const props = defineProps({ const props = defineProps({
data: { data: {
@ -36,7 +36,12 @@ const props = defineProps({
type: String, type: String,
required: false, required: false,
}, },
locvotreg: {
type: Number,
required: false,
},
}); });
const userStore = useUserInfoStore();
const isRandom = ref(false); const isRandom = ref(false);
const randomList = () =>{ const randomList = () =>{
isRandom.value = true; isRandom.value = true;

View File

@ -34,6 +34,7 @@
<Pagination <Pagination
v-if="PageData.pages" v-if="PageData.pages"
v-bind="PageData" v-bind="PageData"
:currentPage="currentPage"
@update:currentPage="handlePageChange" @update:currentPage="handlePageChange"
/> />
</div> </div>
@ -149,7 +150,6 @@ const voteDelete =(id) =>{
} }
// 1 // 1
const randomList = (data,id) =>{ const randomList = (data,id) =>{
isLoading.value = false;
$api.post('vote/randomList',{ $api.post('vote/randomList',{
randomList :data randomList :data
,voteid:id ,voteid:id
@ -158,7 +158,7 @@ const randomList = (data,id) =>{
toastStore.onToast('랜덤뽑기 진행되었습니다.', 's'); toastStore.onToast('랜덤뽑기 진행되었습니다.', 's');
setTimeout(() => { setTimeout(() => {
getvoteList(); getvoteList();
}, 2000); // 3000ms = 3 }, 1000);
} }
}) })
} }
@ -169,9 +169,9 @@ const updateVote = (id) =>{
voteWrite(); voteWrite();
} }
// //
const handlePageChange = async (page) => { const handlePageChange = (page) => {
currentPage.value=page; currentPage.value=page;
await getvoteList(); getvoteList();
}; };
</script> </script>
<style></style> <style></style>

View File

@ -31,7 +31,7 @@
@change="ValidHandlerendDate" @change="ValidHandlerendDate"
/> />
<!-- 항목 입력 반복 --> <!-- 항목 입력 반복 -->
<div v-for="(item, index) in itemList" :key="index" class="d-flex align-items-start"> <div v-for="(item, index) in itemList" :key="index" class="d-flex align-items-start ">
<div class="flex-grow-1 me-2 "> <div class="flex-grow-1 me-2 ">
<form-input <form-input
:title="'항목 ' + (index + 1)" :title="'항목 ' + (index + 1)"
@ -174,7 +174,7 @@ const saveVote = () => {
})); }));
$api.post('vote/insertWord',{ $api.post('vote/insertWord',{
addvoteIs :addvoteitem.value === false ? '0' :'1' addvoteIs :addvoteitem.value === false ? '0' :'1'
,votemMltiIs: addvotemulti.value === false ? '0' : '1' ,votemMltiIs :addvotemulti.value === false ? '0' : '1'
,title :title.value.trim() ,title :title.value.trim()
,endDate :endDate.value ,endDate :endDate.value
,itemList :filteredItemList ,itemList :filteredItemList
@ -207,6 +207,6 @@ const goList = () => {
<style scoped> <style scoped>
.item-input { .item-input {
max-width: 200px; max-width: 200px;
} }
</style> </style>