투표수정정
This commit is contained in:
parent
f4f5ac45f6
commit
47ab2b6054
@ -4,10 +4,6 @@
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'WriteButton',
|
||||
methods: {
|
||||
},
|
||||
};
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,55 +1,71 @@
|
||||
<template>
|
||||
<div class="card mb-6">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title mb-1"><div class="list-group-item list-group-item-action d-flex align-items-center cursor-pointer">
|
||||
<img
|
||||
class="rounded-circle user-avatar border border-3 w-px-40"
|
||||
:src="`${baseUrl}upload/img/profile/${data.localVote.MEMBERPRF}`"
|
||||
:style="`border-color: ${data.localVote.usercolor} !important;`"
|
||||
alt="user"
|
||||
/>
|
||||
<div class="w-100">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="user-info">
|
||||
<h6 class="mb-1">{{ data.localVote.MEMBERNAM }}</h6>
|
||||
<div class="card-body" v-if="!data.localVote.LOCVOTDEL" >
|
||||
<h5 class="card-title mb-1"><div class="list-group-item list-group-item-action d-flex align-items-center cursor-pointer">
|
||||
<img
|
||||
class="rounded-circle user-avatar border border-3 w-px-40"
|
||||
:src="`${baseUrl}upload/img/profile/${data.localVote.MEMBERPRF}`"
|
||||
:style="`border-color: ${data.localVote.usercolor} !important;`"
|
||||
alt="user"
|
||||
/>
|
||||
<div class="w-100">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="user-info">
|
||||
<h6 class="mb-1">{{ data.localVote.MEMBERNAM }}</h6>
|
||||
</div>
|
||||
<div class="add-btn d-flex align-items-center">
|
||||
<!-- 투표완료시 -->
|
||||
<i v-if="data.yesVotetotal == '1'" class="bx bxs-check-circle link-success"></i>
|
||||
<!-- 투표작성자만 수정/삭제/종료 가능 -->
|
||||
<div v-if="userStore.user.id === data.localVote.LOCVOTREG">
|
||||
<button
|
||||
v-if="!data.localVote.LOCVOTDDT"
|
||||
type="button"
|
||||
class="bx btn btn-danger"
|
||||
@click="endBtn(data.localVote.LOCVOTSEQ)"
|
||||
>종료</button>
|
||||
<EditBtn v-if="!data.localVote.LOCVOTDDT" @click="updateVote(data.localVote.LOCVOTSEQ)"/>
|
||||
<DeleteBtn @click="voteDelete(data.localVote.LOCVOTSEQ)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="add-btn">
|
||||
<!-- 투표완료시 -->
|
||||
<i class="bx bxs-check-circle link-success"></i>
|
||||
<!-- 투표작성자만 수정/삭제/종료 가능 -->
|
||||
<button
|
||||
v-if="userStore.user.id === data.localVote.LOCVOTREG"
|
||||
type="button" class="bx btn btn-danger">종료</button>
|
||||
<EditBtn />
|
||||
<DeleteBtn />
|
||||
</div>
|
||||
</div>
|
||||
</h5>
|
||||
<h5>{{ data.localVote.LOCVOTTTL }}</h5>
|
||||
<div class="mb-1">{{ data.localVote.formatted_LOCVOTRDT }} ~ {{ data.localVote.formatted_LOCVOTEDT }}</div>
|
||||
<!-- 투표완료시-->
|
||||
<button v-if="data.yesVotetotal > 0 && !data.localVote.LOCVOTDDT" class="btn btn-primary btn-sm" >재투표</button>
|
||||
<!-- 투표안했을시-->
|
||||
<div v-if="data.localVote.LOCVOTDDT && data.voteResult.length == 0">
|
||||
<small class="text-primary text-uppercase">투표 결과없음 (😂아무도 투표하지 않았습니다)</small>
|
||||
</div>
|
||||
<div v-else>
|
||||
<vote-card-check
|
||||
v-if="data.yesVotetotal == 0"
|
||||
@addContents="addContents"
|
||||
@checkedNames="checkedNames"
|
||||
:data="data.voteDetails"
|
||||
:voteInfo="data.localVote"
|
||||
:total="data.voteDetails.length "/>
|
||||
<!-- 투표완/미완 인원 -->
|
||||
<vote-user-list v-if="!data.localVote.LOCVOTDDT"
|
||||
:data="data.voteMembers"/>
|
||||
<!-- 투표 결과 -->
|
||||
<div v-if="data.localVote.LOCVOTDDT" class="mt-3">
|
||||
<vote-result-list :data="data.voteResult" @randomList="randomList" :randomResultNum="data.localVote.LOCVOTRES"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</h5>
|
||||
<h5>{{ data.localVote.LOCVOTTTL }}</h5>
|
||||
<div class="mb-1">{{ data.localVote.formatted_LOCVOTRDT }} ~ {{ data.localVote.formatted_LOCVOTEDT }}</div>
|
||||
<!-- 투표완료시-->
|
||||
<button v-if="data.yesVotetotal > 0" class="btn btn-primary btn-sm" >재투표</button>
|
||||
<!-- 투표안했을시-->
|
||||
<vote-card-check
|
||||
v-if="data.yesVotetotal == 0"
|
||||
@addContents="addContents"
|
||||
@checkedNames="checkedNames"
|
||||
:data="data.voteDetails"
|
||||
:voteInfo="data.localVote"
|
||||
:total="data.voteDetails.length "/>
|
||||
<!-- 투표완/미완 인원 -->
|
||||
<vote-user-list
|
||||
:data="data.voteMembers"/>
|
||||
<!-- 투표 결과 -->
|
||||
<vote-result-list />
|
||||
</div>
|
||||
<div v-else class="card-body">
|
||||
<h5>{{ data.localVote.LOCVOTTTL }}</h5>
|
||||
삭제된 투표입니다.
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import EditBtn from '@c/button/EditBtn.vue';
|
||||
import DeleteBtn from '@c/button/DeleteBtn.vue';
|
||||
import voteUserList from '@c/voteboard/voteUserList.vue';
|
||||
@ -63,19 +79,51 @@ const props = defineProps({
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
randomresult: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
|
||||
|
||||
const userStore = useUserInfoStore();
|
||||
const emit = defineEmits(['addContents','checkedNames']);
|
||||
const currentDate = new Date();
|
||||
const voteEndDate = new Date(props.data.localVote.formatted_LOCVOTEDT.replace(' ', 'T'));
|
||||
voteEndDate.setDate(voteEndDate.getDate() + 1);
|
||||
// 종료 여부 계산
|
||||
const isVoteEnded = computed(() => {
|
||||
return currentDate > voteEndDate;
|
||||
});
|
||||
|
||||
const emit = defineEmits(['addContents','checkedNames','endVoteId','voteEnded','randomList','voteDelete','updateVote']);
|
||||
onMounted(() => {
|
||||
if (isVoteEnded.value && !props.data.localVote.LOCVOTDDT) {
|
||||
emit('voteEnded', { id: props.data.localVote.LOCVOTSEQ });
|
||||
}
|
||||
});
|
||||
const addContents = (itemList, voteId) =>{
|
||||
emit('addContents',itemList,voteId)
|
||||
}
|
||||
const checkedNames = (numList) =>{
|
||||
emit('checkedNames',numList);
|
||||
}
|
||||
const endBtn = (voteid) =>{
|
||||
voteEndDate.setTime(currentDate.getTime()); // 현재 날짜로 설정
|
||||
emit('endVoteId',voteid);
|
||||
}
|
||||
const voteDelete = (voteid) =>{
|
||||
emit('voteDelete',voteid);
|
||||
}
|
||||
const randomList = (random) =>{
|
||||
emit('randomList',random,props.data.localVote.LOCVOTSEQ);
|
||||
}
|
||||
const updateVote = (voteid) =>{
|
||||
emit('updateVote',voteid);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.disabled-class {
|
||||
pointer-events: none; /* 클릭 방지 */
|
||||
opacity: 0.5; /* 흐리게 표시 */
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -3,9 +3,15 @@
|
||||
<card
|
||||
@addContents="addContents"
|
||||
@checkedNames="checkedNames"
|
||||
@endVoteId="endVoteId"
|
||||
@voteEnded="voteEnded"
|
||||
@voteDelete="voteDelete"
|
||||
@randomList="randomList"
|
||||
@updateVote="updateVote"
|
||||
v-for="(item, index) in data"
|
||||
:key="index"
|
||||
:data="item" />
|
||||
:data="item"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -16,14 +22,30 @@ const props = defineProps({
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
|
||||
});
|
||||
const emit = defineEmits(['addContents','checkedNames']);
|
||||
const emit = defineEmits(['addContents','checkedNames','endVoteId','voteEnded','voteDelete']);
|
||||
const addContents = (itemList ,voteId) =>{
|
||||
emit('addContents',itemList ,voteId);
|
||||
}
|
||||
const checkedNames = (numList) =>{
|
||||
emit('checkedNames',numList);
|
||||
}
|
||||
const endVoteId = (VoteId) =>{
|
||||
emit('endVoteId',VoteId);
|
||||
}
|
||||
const voteEnded = (id) =>{
|
||||
emit('voteEnded',id);
|
||||
}
|
||||
const voteDelete = (id) =>{
|
||||
emit('voteDelete',id);
|
||||
}
|
||||
const updateVote = (id) =>{
|
||||
emit('updateVote',id);
|
||||
}
|
||||
const randomList = (randomList , id) =>{
|
||||
emit('randomList',randomList,id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -2,14 +2,15 @@
|
||||
<div>
|
||||
<ul class="timeline mb-0">
|
||||
<li class="timeline-item ps-6 ">
|
||||
<span class="timeline-indicator-advanced timeline-indicator-success border-0 shadow-none">
|
||||
<span class="timeline-indicator-advanced timeline-indicator-primary border-0 shadow-none">
|
||||
<i class="icon-base bx bx-check-circle"></i>
|
||||
</span>
|
||||
<div class="timeline-event ps-1">
|
||||
<div class="timeline-header">
|
||||
<small class="text-success text-uppercase">투표결과</small>
|
||||
<small class="text-primary text-uppercase">투표결과</small>
|
||||
</div>
|
||||
<h6 class="my-50">돼지고기 </h6>
|
||||
<h6 v-if="data" class="my-50">{{ data[0].LOCVOTCON }}</h6>
|
||||
<h6 v-if="randomResultNum" class="my-50">{{randomResultNum }}</h6>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@ -17,6 +18,16 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
required: false,
|
||||
},
|
||||
randomResultNum: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -2,9 +2,10 @@
|
||||
<div class="card mb-6 border border-2 border-primary rounded primary-shadow">
|
||||
<div class="card-body">
|
||||
<!-- 1위가 여러개일때 -->
|
||||
<vote-result-random />
|
||||
<vote-result-random v-if="topVoters.length > 1" :data="topVoters" :randomResultNum="randomResultNum"
|
||||
@randomList="randomList"/>
|
||||
<!-- 1위가 하나일때-->
|
||||
<vote-result-card />
|
||||
<vote-result-card v-if="topVoters.length == 1" :data="topVoters"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -12,6 +13,28 @@
|
||||
<script setup>
|
||||
import voteResultRandom from '@c/voteboard/voteResultRandom.vue';
|
||||
import voteResultCard from '@c/voteboard/voteResultCard.vue';
|
||||
import { computed } from 'vue';
|
||||
const emit = defineEmits(['randomList']);
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
randomResultNum: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
// 가장 많은 투표를 받은 항목들 (1위)
|
||||
const topVoters = computed(() => {
|
||||
// 가장 높은 VOTE_COUNT 찾기
|
||||
const maxVoteCount = Math.max(...props.data.map(item => item.VOTE_COUNT));
|
||||
// VOTE_COUNT가 가장 높은 항목들 필터링
|
||||
return props.data.filter(item => item.VOTE_COUNT === maxVoteCount);
|
||||
});
|
||||
const randomList = (random) =>{
|
||||
emit('randomList',random);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -1,14 +1,55 @@
|
||||
<template>
|
||||
<div v-if="!isRandom && !randomResultNum">
|
||||
<h6><i class="icon-base bx bx-error icon-lg link-warning"></i> 1위가 중복 되었습니다</h6>
|
||||
<!-- 중복된 1위 리스트 -->
|
||||
<vote-result-random-list />
|
||||
<vote-result-random-list
|
||||
v-for="(item,index) in data"
|
||||
:key="index"
|
||||
:data="item"
|
||||
:randomResultNum="randomResultNum"/>
|
||||
</div>
|
||||
<div v-if="isRandom === false && randomResultNum">
|
||||
<vote-result-card :randomResultNum="randomResultNum"/>
|
||||
</div>
|
||||
|
||||
<button v-if="isRandom" class="btn btn-primary" type="button" disabled="">
|
||||
<span class="spinner-grow me-1" role="status" aria-hidden="true"></span>
|
||||
랜덤뽑기중..
|
||||
</button>
|
||||
<div class="d-grid w-100 mt-6">
|
||||
<button class="btn btn-primary" data-bs-target="#upgradePlanModal" data-bs-toggle="modal">랜덤 1위 뽑기</button>
|
||||
<button v-if="!isRandom && !randomResultNum" @click="randomList" class="btn btn-primary">랜덤 1위 뽑기</button>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import voteResultRandomList from "@c/voteboard/voteResultRandomList.vue"
|
||||
import voteResultCard from '@c/voteboard/voteResultCard.vue';
|
||||
import { ref, watch } from "vue";
|
||||
const emit = defineEmits(['randomList']);
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
randomResultNum: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
const isRandom = ref(false);
|
||||
const randomList = () =>{
|
||||
isRandom.value = true;
|
||||
emit('randomList', props.data);
|
||||
}
|
||||
|
||||
watch(() => props.randomResultNum, (newVal) => {
|
||||
if (newVal) {
|
||||
setTimeout(() => {
|
||||
isRandom.value = false;
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<ul class="list-unstyled g-2 my-6 ">
|
||||
<li class="mb-1 d-flex align-items-center ">
|
||||
<div class="d-flex align-items-center lh-1 me-4 mb-4 mb-sm-0">
|
||||
<span class="badge badge-dot text-bg-warning me-1"></span> 돼지고기
|
||||
<span class="badge badge-dot text-bg-warning me-1"></span> {{ data.LOCVOTCON }}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@ -11,7 +11,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// voteCommon.js
|
||||
import { ref } from "vue";
|
||||
|
||||
export function voteCommon(isVOte= false) {
|
||||
const itemList = ref(isVOte ? [] : [{ content: "", url: "" }, { content: "", url: "" }]);
|
||||
export function voteCommon(isVote= false) {
|
||||
const itemList = ref(isVote ? [] : [{ content: "", url: "" }, { content: "", url: "" }]);
|
||||
|
||||
const addItem = () => {
|
||||
if (itemList.value.length < 10) {
|
||||
@ -11,9 +11,9 @@ export function voteCommon(isVOte= false) {
|
||||
};
|
||||
|
||||
const removeItem = (index) => {
|
||||
if (!isVOte && index >= 2) {
|
||||
if (!isVote && index >= 2) {
|
||||
itemList.value.splice(index, 1);
|
||||
} else if (isVOte && itemList.value.length > 0) {
|
||||
} else if (isVote && itemList.value.length > 0) {
|
||||
itemList.value.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
15
src/stores/voteDetail.js
Normal file
15
src/stores/voteDetail.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useVoteStore = defineStore("vote", {
|
||||
state: () => ({
|
||||
selectedVote: {}
|
||||
}),
|
||||
actions: {
|
||||
setVoteData(data) {
|
||||
this.selectedVote = data;
|
||||
},
|
||||
clearVoteData() {
|
||||
this.selectedVote = {};
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<RouterView />
|
||||
<RouterView />
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name : 'voteboard',
|
||||
inheritAttrs : false,
|
||||
name : 'voteboard',
|
||||
inheritAttrs : false,
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -3,39 +3,46 @@
|
||||
<div class="row g-3">
|
||||
<div class="mt-8">
|
||||
<!-- 투표 작성 -->
|
||||
<router-link to="/voteboard/write"><WriteBtn /></router-link>
|
||||
<!-- 내가한 투표 보기 -->
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="form-check me-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="deliveryAdd" checked="">
|
||||
<label class="form-check-label" for="deliveryAdd">내가 한 투표</label>
|
||||
</div>
|
||||
<WriteBtn @click="voteWrite" />
|
||||
<!-- 투표마감/투표중 셀렉트 -->
|
||||
<FormSelect class="col-3" name="cate" :isLabel="false" title="투표상태" :data="categoryList" @update:data="category = $event" />
|
||||
<FormSelect class="col-3" name="cate" :isLabel="false" title="투표상태" :data="categoryList" @update:data="category = $event" @change="selectHandler"/>
|
||||
<!-- 내가한 투표 보기 -->
|
||||
<div class="p-4">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1" v-model="ischeked" @change="changeCheck">
|
||||
<label class="form-check-label" for="defaultCheck1"> 내가 한 투표 </label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 투표리스트 -->
|
||||
<div v-if="!voteListCardData" class="mt66"> ❌❌등록된 투표가 없습니다.❌❌</div>
|
||||
<vote-list
|
||||
:data="voteListCardData"
|
||||
@addContents="addContents"
|
||||
@checkedNames="checkedNames"/>
|
||||
@checkedNames="checkedNames"
|
||||
@endVoteId="endVoteId"
|
||||
@voteEnded="voteEnded"
|
||||
@voteDelete="voteDelete"
|
||||
@updateVote="updateVote"
|
||||
@randomList="randomList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 페이지네이션 -->
|
||||
<div class="row g-3">
|
||||
<div class="mt-8">
|
||||
<Pagination
|
||||
v-if="PageData.pages"
|
||||
v-bind="PageData"
|
||||
@update:currentPage="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 페이지네이션 -->
|
||||
<div class="row g-3">
|
||||
<div class="mt-8">
|
||||
<Pagination
|
||||
v-if="PageData.pages"
|
||||
v-bind="PageData"
|
||||
@update:currentPage="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { getCurrentInstance, onMounted, ref } from 'vue';
|
||||
import Pagination from '@c/pagination/Pagination.vue';
|
||||
import router from '@/router';
|
||||
import FormSelect from '@c/input/FormSelect.vue';
|
||||
import { useToastStore } from '@s/toastStore';
|
||||
import QEditor from '@c/editor/QEditor.vue';
|
||||
@ -43,30 +50,58 @@ import $api from '@api';
|
||||
import Quill from 'quill';
|
||||
import WriteBtn from '@c/button/WriteBtn.vue';
|
||||
import voteList from '@c/voteboard/voteCardList.vue';
|
||||
import { useVoteStore } from '@s/voteDetail';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const toastStore = useToastStore();
|
||||
const category = ref('0');
|
||||
const categoryList = ['전체','투표마감', '투표중'];
|
||||
const categoryList = ['전체','투표마감','투표중'];
|
||||
const PageData = ref([]);
|
||||
const voteListCardData = ref([]);
|
||||
const titleAlert = ref(false);
|
||||
const addContent = ref('');
|
||||
const currentPage = ref(1);
|
||||
const voteset = ref(0);
|
||||
const ischeked = ref(false);
|
||||
const selectedVote = ref({}); // 선택된 투표 데이터
|
||||
const router = useRouter();
|
||||
|
||||
onMounted(async () => {
|
||||
getvoteList();
|
||||
});
|
||||
const voteStore = useVoteStore();
|
||||
//글작성
|
||||
const voteWrite = () => {
|
||||
voteStore.setVoteData(selectedVote.value);
|
||||
console.log("Pinia 상태 업데이트됨:", voteStore.selectedVote);
|
||||
router.push('/voteboard/write');
|
||||
};
|
||||
|
||||
const changeCheck = () =>{
|
||||
getvoteList();
|
||||
}
|
||||
//투표목록
|
||||
const getvoteList = async () => {
|
||||
console.log('pagee',currentPage.value)
|
||||
const response = await $api.get('vote/getVoteList',{
|
||||
params: { page: currentPage.value }
|
||||
});
|
||||
if (response.data.status === "OK") {
|
||||
PageData.value = response.data.data;
|
||||
voteListCardData.value = response.data.data.list;
|
||||
const response = await $api.get('vote/getVoteList',{
|
||||
params:
|
||||
{
|
||||
page: currentPage.value
|
||||
,voteset:voteset.value
|
||||
,myVote:ischeked.value ? '1':'0'
|
||||
}
|
||||
};
|
||||
});
|
||||
if (response.data.status === "OK") {
|
||||
PageData.value = response.data.data;
|
||||
voteListCardData.value = response.data.data.list;
|
||||
}
|
||||
};
|
||||
const selectHandler = () =>{
|
||||
voteset.value = category.value;
|
||||
getvoteList();
|
||||
}
|
||||
|
||||
//투표항목추가
|
||||
const addContents = (itemList, voteId) =>{
|
||||
const addContents = (itemList, voteId) => {
|
||||
$api.post('vote/insertWord',{
|
||||
itemList :itemList
|
||||
,voteId :voteId
|
||||
@ -78,7 +113,7 @@ const addContents = (itemList, voteId) =>{
|
||||
})
|
||||
}
|
||||
//투표하기
|
||||
const checkedNames = (numList) =>{
|
||||
const checkedNames = (numList) => {
|
||||
$api.post('vote/insertCheckedNums',{
|
||||
checkedList :numList
|
||||
,votenum : numList[0].LOCVOTSEQ
|
||||
@ -89,7 +124,50 @@ const checkedNames = (numList) =>{
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//투표종료
|
||||
const endVoteId = (endVoteId) => {
|
||||
$api.patch('vote/updateEndData',{
|
||||
endVoteId :endVoteId
|
||||
}).then((res)=>{
|
||||
if(res.data.status === 'OK'){
|
||||
toastStore.onToast('투표가 종료되었습니다.', 's');
|
||||
getvoteList();
|
||||
}
|
||||
})
|
||||
}
|
||||
//기한 지난 투표 종료
|
||||
const voteEnded = async (id) =>{
|
||||
await endVoteId(id.id);
|
||||
}
|
||||
//투표 삭제
|
||||
const voteDelete =(id) =>{
|
||||
$api.patch('vote/updateDeleteData',{
|
||||
deleteVoteId :id
|
||||
}).then((res)=>{
|
||||
if(res.data.status === 'OK'){
|
||||
toastStore.onToast('투표가 삭제되었습니다.', 's');
|
||||
getvoteList();
|
||||
}
|
||||
})
|
||||
}
|
||||
//랜덤 1위 뽑기
|
||||
const randomList = (data,id) =>{
|
||||
$api.post('vote/randomList',{
|
||||
randomList :data
|
||||
,voteid:id
|
||||
}).then((res)=>{
|
||||
if(res.data.status === 'OK'){
|
||||
toastStore.onToast('랜덤뽑기 진행되었습니다.', 's');
|
||||
getvoteList();
|
||||
}
|
||||
})
|
||||
}
|
||||
//수정
|
||||
const updateVote = (id) =>{
|
||||
const voteData = voteListCardData.value.find((item) => item.localVote.LOCVOTSEQ === id);
|
||||
selectedVote.value = voteData;
|
||||
voteWrite();
|
||||
}
|
||||
// 페이지 변경
|
||||
const handlePageChange = async (page) => {
|
||||
currentPage.value=page;
|
||||
|
||||
@ -5,66 +5,66 @@
|
||||
<div class="user-list-container">
|
||||
<ul class="timeline mb-1">
|
||||
<li class="timeline-item timeline-item-transparent">
|
||||
<span class="timeline-point timeline-point-info"></span>
|
||||
<div class="timeline-event">
|
||||
<div class="timeline-header mb-2">
|
||||
<h6 class="mb-0">투표 인원</h6>
|
||||
</div>
|
||||
<UserList @userListInfo="userSet" @user-list-update="handleUserListUpdate" class="mb-3" />
|
||||
<div v-if="UserListAlert" class="red">2명이상 선택해주세요 </div>
|
||||
<form-input
|
||||
title="제목"
|
||||
name="title"
|
||||
:is-essential="true"
|
||||
:is-alert="titleAlert"
|
||||
v-model="title"
|
||||
/>
|
||||
<form-input
|
||||
title="종료날짜"
|
||||
name="endDate"
|
||||
type="date"
|
||||
:is-essential="true"
|
||||
:is-alert="endDateAlert"
|
||||
v-model="endDate"
|
||||
/>
|
||||
<!-- 항목 입력 반복 -->
|
||||
<div v-for="(item, index) in itemList" :key="index" class="d-flex align-items-center mb-2 position-relative">
|
||||
<form-input
|
||||
class="flex-grow-1 me-2"
|
||||
:title="'항목 ' + (index + 1)"
|
||||
:name="'content' + index"
|
||||
:is-essential="index < 2"
|
||||
:is-alert="contentAlerts[index]"
|
||||
v-model="item.content"
|
||||
/>
|
||||
<link-input v-model="item.url" />
|
||||
<delete-btn @click="removeItem(index)" :disabled="index < 2" class="ms-2" />
|
||||
</div>
|
||||
<plus-btn @click="addItem" :disabled="itemList.length >= 10" class="mb-3" />
|
||||
<div>
|
||||
<label class="list-group-item">
|
||||
<input
|
||||
class="form-check-input me-1"
|
||||
type="checkbox"
|
||||
id="addvoteitem"
|
||||
v-model="addvoteitem"
|
||||
/>
|
||||
항목 추가여부
|
||||
</label>
|
||||
<label class="list-group-item">
|
||||
<input
|
||||
class="form-check-input me-1"
|
||||
type="checkbox"
|
||||
id="addvotemulti"
|
||||
v-model="addvotemulti"
|
||||
<span class="timeline-point timeline-point-info"></span>
|
||||
<div class="timeline-event">
|
||||
<div class="timeline-header mb-2">
|
||||
<h6 class="mb-0">투표 인원</h6>
|
||||
</div>
|
||||
<UserList @userListInfo="userSet" @user-list-update="handleUserListUpdate" class="mb-3" />
|
||||
<div v-if="UserListAlert" class="red">2명이상 선택해주세요 </div>
|
||||
<form-input
|
||||
title="제목"
|
||||
name="title"
|
||||
:is-essential="true"
|
||||
:is-alert="titleAlert"
|
||||
:v-model="title"
|
||||
/>
|
||||
다중투표 허용여부
|
||||
</label>
|
||||
<form-input
|
||||
title="종료날짜"
|
||||
name="endDate"
|
||||
type="date"
|
||||
:is-essential="true"
|
||||
:is-alert="endDateAlert"
|
||||
v-model="endDate"
|
||||
:min="today"
|
||||
/>
|
||||
<!-- 항목 입력 반복 -->
|
||||
<div v-for="(item, index) in itemList" :key="index" class="d-flex align-items-center mb-2 position-relative">
|
||||
<form-input
|
||||
class="flex-grow-1 me-2"
|
||||
:title="'항목 ' + (index + 1)"
|
||||
:name="'content' + index"
|
||||
:is-essential="index < 2"
|
||||
:is-alert="contentAlerts[index]"
|
||||
v-model="item.content"
|
||||
/>
|
||||
<link-input v-model="item.url" />
|
||||
<delete-btn @click="removeItem(index)" :disabled="index < 2" class="ms-2" />
|
||||
</div>
|
||||
<plus-btn @click="addItem" :disabled="itemList.length >= 10" class="mb-3" />
|
||||
<div>
|
||||
<label class="list-group-item">
|
||||
<input
|
||||
class="form-check-input me-1"
|
||||
type="checkbox"
|
||||
id="addvoteitem"
|
||||
v-model="addvoteitem"
|
||||
/>
|
||||
항목 추가여부
|
||||
</label>
|
||||
<label class="list-group-item">
|
||||
<input
|
||||
class="form-check-input me-1"
|
||||
type="checkbox"
|
||||
id="addvotemulti"
|
||||
v-model="addvotemulti"
|
||||
/>
|
||||
다중투표 허용여부
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="mb-4 d-flex justify-content-end">
|
||||
<button type="button" class="btn btn-info" @click="goList">
|
||||
<i class="bx bx-left-arrow-alt"></i>
|
||||
@ -80,7 +80,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, toRaw } from "vue";
|
||||
import { onMounted, ref, toRaw } from "vue";
|
||||
import UserList from "@c/user/UserList.vue";
|
||||
import formInput from "@c/input/FormInput.vue";
|
||||
import { useToastStore } from "@s/toastStore";
|
||||
@ -90,7 +90,12 @@ import $api from "@api";
|
||||
import router from "@/router";
|
||||
import LinkInput from "@/components/voteboard/voteLinkInput.vue";
|
||||
import { voteCommon } from '@s/voteCommon';
|
||||
import { useUserStore } from '@s/userList';
|
||||
import { useRoute } from "vue-router";
|
||||
import { useVoteStore } from "@s/voteDetail";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const today = new Date().toISOString().substring(0, 10);
|
||||
const toastStore = useToastStore();
|
||||
const activeUserList = ref([]);
|
||||
const disabledUsers = ref([]);
|
||||
@ -101,7 +106,6 @@ const UserListAlert = ref(false);
|
||||
const title = ref("");
|
||||
const endDate = ref("");
|
||||
const { itemList, addItem, removeItem } = voteCommon();
|
||||
|
||||
const userListTotal = ref(0);
|
||||
const addvoteitem = ref(false);
|
||||
const addvotemulti= ref(false);
|
||||
@ -111,6 +115,13 @@ const userSet = ({ userList, userTotal }) => {
|
||||
userListTotal.value = userTotal;
|
||||
};
|
||||
|
||||
const voteStore = useVoteStore();
|
||||
|
||||
onMounted(()=>{
|
||||
console.log('상세데이터',voteStore.selectedVote);
|
||||
})
|
||||
|
||||
|
||||
const handleUserListUpdate = ({ activeUsers, disabledUsers: updatedDisabledUsers }) => {
|
||||
activeUserList.value = activeUsers;
|
||||
disabledUsers.value = updatedDisabledUsers;
|
||||
@ -119,56 +130,51 @@ const handleUserListUpdate = ({ activeUsers, disabledUsers: updatedDisabledUsers
|
||||
|
||||
const saveValid = () => {
|
||||
let valid = true;
|
||||
|
||||
if (disabledUsers.value.length === 0) {
|
||||
activeUserList.value = [...userStore.userList];
|
||||
}
|
||||
if (title.value === '') {
|
||||
titleAlert.value = true;
|
||||
valid = false;
|
||||
} else {
|
||||
titleAlert.value = false;
|
||||
}
|
||||
|
||||
if (endDate.value === '') {
|
||||
endDateAlert.value = true;
|
||||
valid = false;
|
||||
} else {
|
||||
endDateAlert.value = false;
|
||||
}
|
||||
|
||||
if (itemList.value[0].content === '') {
|
||||
contentAlerts.value[0] = true;
|
||||
valid = false;
|
||||
} else {
|
||||
contentAlerts.value[0] = false;
|
||||
}
|
||||
|
||||
if (itemList.value[1].content === '') {
|
||||
contentAlerts.value[1] = true;
|
||||
valid = false;
|
||||
} else {
|
||||
contentAlerts.value[1] = false;
|
||||
}
|
||||
|
||||
if (activeUserList.value.length < 2) {
|
||||
UserListAlert.value = true;
|
||||
valid = false;
|
||||
} else {
|
||||
UserListAlert.value = false;
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
saveVote();
|
||||
}
|
||||
};
|
||||
|
||||
const saveVote = () => {
|
||||
console.log('activeUserList',activeUserList.value)
|
||||
const unwrappedUserList = toRaw(activeUserList.value);
|
||||
const listId = unwrappedUserList.map(item => ({
|
||||
id: item.MEMBERSEQ,
|
||||
}));
|
||||
$api.post('vote/insertWord',{
|
||||
addvoteIs :addvoteitem ? '1' :'0'
|
||||
,votemMltiIs :addvotemulti ? '1' :'0'
|
||||
addvoteIs :addvoteitem.value === false ? '0' :'1'
|
||||
,votemMltiIs: addvotemulti.value === false ? '0' : '1'
|
||||
,title :title.value
|
||||
,endDate :endDate.value
|
||||
,itemList :itemList.value
|
||||
@ -180,11 +186,9 @@ const saveVote = () => {
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
const goList = () => {
|
||||
router.push('/voteboard');
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user