Merge branch 'khj'

This commit is contained in:
khj0414 2025-03-21 15:05:09 +09:00
commit 7c5437312b
5 changed files with 63 additions and 20 deletions

View File

@ -5,6 +5,7 @@
<span v-if="isEssential" class="text-danger">*</span>
</label>
<div class="col-md-10">
{{ min }}
<div class="d-flex align-items-center">
<input
:id="name"

View File

@ -104,9 +104,10 @@ const topVoters = computed(() => {
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
const userStore = useUserInfoStore();
const currentDate = new Date();
const voteEndDate = new Date(props.data.localVote.formatted_LOCVOTEDT.replace(' ', 'T'));
voteEndDate.setDate(voteEndDate.getDate() + 1);
const offset = new Date().getTimezoneOffset() * 60000
const today = new Date(Date.now() - offset);
const currentDate = today.toISOString().substring(0,16);
const voteEndDate = props.data.localVote.LOCVOTEDT.substring(0,16);
//
const isVoteEnded = computed(() => {
return currentDate > voteEndDate;
@ -114,7 +115,7 @@ const isVoteEnded = computed(() => {
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 });
emit('voteEnded', { id: props.data.localVote.LOCVOTSEQ });
}
checkVoteCompletion();
});
@ -125,7 +126,7 @@ watch(() => props.data.localVote.total_voted, () => {
//
const checkVoteCompletion = () => {
if (props.data.localVote.total_votable === props.data.localVote.total_voted && !props.data.localVote.LOCVOTDDT) {
if (props.data.localVote.total_votable === props.data.localVote.total_voted && props.data.localVote.LOCVOTDDT == '') {
emit('voteEnded', { id: props.data.localVote.LOCVOTSEQ });
}
};
@ -136,7 +137,6 @@ const checkedNames = (numList) =>{
emit('checkedNames',numList);
}
const endBtn = (voteid) =>{
voteEndDate.setTime(currentDate.getTime()); //
emit('endVoteId',voteid);
}
const voteDelete = (voteid) =>{

View File

@ -17,16 +17,23 @@
:is-alert="contentAlerts[index]"
v-model="item.content"
:is-btn="true"
@keyup="ValidHandler('content' + (index + 1))"
>
<template v-slot:append>
<delete-btn @click="removeItem(index)" />
</template>
</form-input>
<link-input v-model="item.url" class="mb-1"/>
<form-input
:title="'URL ' + (index + data.length + 1)"
:name="'url' + index"
v-model="item.url"
:is-essential="false"
class="mb-1"
/>
</div>
<div class="d-flex justify-content align-items-center mt-3">
<plus-btn @click="addItem" :disabled="total >= 10" />
<button class="btn btn-primary btn-icon m-1" @click="addContentSave(item.LOCVOTSEQ)" :disabled="isSaveDisabled">
<plus-btn @click="addItem" :disabled=" total >= 10" />
<button class="btn btn-primary btn-icon m-1" @click="addContentSave(item.LOCVOTSEQ ,index)" :disabled="isSaveDisabled">
<i class="bx bx-check"></i>
</button>
</div>
@ -46,20 +53,19 @@ import SaveBtn from '@c/button/SaveBtn.vue'
import FormInput from '@c/input/FormInput.vue';
import voteCardCheckList from '@c/voteboard/voteCardCheckList.vue';
import { computed, ref } from 'vue';
import LinkInput from "@/components/voteboard/voteLinkInput.vue";
import { voteCommon } from '@s/voteCommon';
import DeleteBtn from "@c/button/DeleteBtn.vue";
import { useToastStore } from '@s/toastStore';
import router from '@/router';
const toastStore = useToastStore();
const contentAlerts = ref(false);
const contentAlerts = ref([false, false]);
const titleAlert = ref(false);
const title = ref('');
const rink = ref('');
const { itemList, addItem, removeItem } = voteCommon(true);
const total = computed(() => props.total + itemList.value.length);
const isSaveDisabled = computed(() => {
return itemList.value.length === 0 || itemList.value.every(item => !item.content.trim());
return itemList.value.length === 0 || itemList.value.every(item => !item.content.trim() && !item.url.trim());
});
const props = defineProps({
data: {
@ -77,12 +83,35 @@ const props = defineProps({
});
const emit = defineEmits(['addContents','checkedNames']);
//
const addContentSave = (voteId) =>{
const addContentSave = (voteId,index) =>{
let valid = true;
const filteredItemList = itemList.value.filter(item => item.content && item.content.trim() !== '');
emit('addContents',filteredItemList,voteId);
itemList.value = [{ content: "", url: "" }];
itemList.value.forEach((item, index) => {
if (!item.content.trim() && item.url.trim()) {
contentAlerts.value[index] = true;
valid = false;
} else {
contentAlerts.value[index] = false;
}
});
if(valid){
emit('addContents',filteredItemList,voteId);
itemList.value = [{ content: "", url: "" }];
removeItem();
}
}
const ValidHandler = (field) => {
if (field.startsWith('content')) {
const index = parseInt(field.replace('content', '')) - 1;
if (!isNaN(index)) {
contentAlerts.value[index] = false;
}
}
};
const checkedNames = ref([]); //
const updateCheckedNames = (newValues) => {
checkedNames.value = newValues;

View File

@ -132,17 +132,18 @@ const checkedNames = (numList) => {
}
//
const endVoteId = (endVoteId) => {
console.log('endVoteId',endVoteId)
$api.patch('vote/updateEndData',{
endVoteId :endVoteId
}).then((res)=>{
if(res.data.status === 'OK'){
//toastStore.onToast(' .', 's');
getvoteList();
}
})
}
//
const voteEnded = async (id) =>{
console.log('voteEnded',id)
await endVoteId(id.id);
}
//

View File

@ -28,8 +28,8 @@
:is-essential="true"
:is-alert="endDateAlert"
v-model="endDate"
:min="today"
@change="ValidHandlerendDate"
:min="minDate"
@input="ValidHandlerendDate"
/>
</div>
@ -102,7 +102,7 @@
</template>
<script setup>
import { onMounted, ref, toRaw } from "vue";
import { nextTick, onMounted, ref, toRaw } from "vue";
import UserList from "@c/user/UserList.vue";
import formInput from "@c/input/FormInput.vue";
import { useToastStore } from "@s/toastStore";
@ -115,7 +115,10 @@ import { useUserStore } from '@s/userList';
import { useRoute } from "vue-router";
const userStore = useUserStore();
const today = new Date().toISOString().substring(0, 10);
// const offset = new Date().getTimezoneOffset() * 60000
// const today = new Date(Date.now() - offset);
// today.setDate(today.getDate() + 1);
// const minDate = today.toISOString().substring(0, 16);
const toastStore = useToastStore();
const activeUserList = ref([]);
const disabledUsers = ref([]);
@ -139,6 +142,15 @@ const focusDateInput = () => {
}
};
const minDate = ref('');
onMounted(() => {
nextTick(() => {
const offset = new Date().getTimezoneOffset() * 60000;
const today = new Date(Date.now() - offset);
today.setDate(today.getDate() + 1);
minDate.value = today.toISOString().substring(0, 16);
});
});
const userSet = ({ userList, userTotal }) => {
activeUserList.value = userList;