|
|
@@ -2,10 +2,9 @@
|
|
|
<div>
|
|
|
<b-row class="prize-list-wrapper">
|
|
|
<b-col md="6">
|
|
|
- <b-card title="獎項列表">
|
|
|
- <b-card-text>所有獎項,點擊獎項以抽取</b-card-text>
|
|
|
+ <b-card title="獎項列表" style="height:75vh;">
|
|
|
<b-table responsive hover :items="getPrizeList(prizeList)" bordered :fields="fields" @row-clicked="click"
|
|
|
- v-b-modal.modal-draw-error>
|
|
|
+ v-b-modal.modal-center style="max-height: 65vh; overflow: auto;">
|
|
|
<template #cell(ICON)="data" class="text-center">
|
|
|
<div class="text-center">
|
|
|
<feather-icon :icon="data.value" />
|
|
|
@@ -14,25 +13,28 @@
|
|
|
</b-table>
|
|
|
</b-card>
|
|
|
</b-col>
|
|
|
- <b-modal id="modal-center" centered title="抽獎" cancel-variant="outline-secondary" cancel-title="Close"
|
|
|
- ok-title="Accept" @ok="test">
|
|
|
- <label>獎品:</label>
|
|
|
- <b-form-input v-model="prize" :disabled=true />
|
|
|
- <br>
|
|
|
- <label>地區: </label>
|
|
|
- <v-select multiple v-model="placeSelected" :options="placeOption" />
|
|
|
- <br>
|
|
|
- <label>數量: </label>
|
|
|
- <b-form-spinbutton v-model="drawNumber" min="1" :max=drawMax />
|
|
|
- </b-modal>
|
|
|
|
|
|
- <b-modal id="modal-draw-error" centered title="抽獎" ok-title="Close">
|
|
|
- <label>獎品數量以抽完</label>
|
|
|
+ <b-modal id="modal-center" centered title="抽獎" cancel-variant="outline-secondary" cancel-title="Close"
|
|
|
+ :ok-only="draw_zero" ok-title="Accept" @ok="draw">
|
|
|
+ <div v-if="draw_zero">
|
|
|
+ <label>獎品數量以抽完</label>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <label>獎品:</label>
|
|
|
+ <b-form-input v-model="prize" :disabled=true />
|
|
|
+ <br>
|
|
|
+ <label>地區: </label>
|
|
|
+ <v-select multiple v-model="region" :options="regionOption" />
|
|
|
+ <br>
|
|
|
+ <label>數量: </label>
|
|
|
+ <b-form-spinbutton v-model="drawNumber" min="1" :max=drawMax />
|
|
|
+ </div>
|
|
|
</b-modal>
|
|
|
|
|
|
<b-col md="6">
|
|
|
- <b-card title="抽獎紀錄">
|
|
|
- <b-table responsive :items="getRecipientsList(recipientsList)" bordered>
|
|
|
+ <b-card title="抽獎紀錄" style="height:75vh;">
|
|
|
+ <b-table responsive :items="getRecipientsList(recipientsList)" bordered
|
|
|
+ style="max-height: 65vh; overflow: auto;">
|
|
|
<template #cell(ICON)="data" class="text-center">
|
|
|
<div class="text-center">
|
|
|
<feather-icon :icon="data.value" />
|
|
|
@@ -68,13 +70,15 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ activity: [],
|
|
|
userList: [],
|
|
|
+ userIdList: [],
|
|
|
prizeList: [],
|
|
|
recipientsList: [],
|
|
|
|
|
|
fields: ['獎項', '數量'],
|
|
|
- placeOption: ['北區', '中區', '南區', '來賓'],
|
|
|
- placeSelected: ['北區', '中區', '南區', '來賓'],
|
|
|
+ regionOption: ['北區', '中區', '南區', '來賓'],
|
|
|
+ region: ['北區', '中區', '南區', '來賓'],
|
|
|
drawMax: 1,
|
|
|
drawNumber: 1,
|
|
|
|
|
|
@@ -84,18 +88,34 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- useJwt.postData('/api/user/index').then(res => {
|
|
|
+ this.activity = this.$route.params.activity;
|
|
|
+ console.log(this.activity);
|
|
|
+
|
|
|
+ useJwt.postData('/api/check_in/index_by_activity', { activityId: this.activity.id }).then(res => {
|
|
|
this.userList = res.data;
|
|
|
});
|
|
|
|
|
|
- useJwt.postData('/api/prize/index').then(res => {
|
|
|
+ useJwt.postData('/api/user/index').then(res => {
|
|
|
+ this.userIdList = res.data;
|
|
|
+ });
|
|
|
+
|
|
|
+ useJwt.postData('/api/prize/index_by_activity', { activityId: this.activity.id }).then(res => {
|
|
|
this.prizeList = res.data;
|
|
|
});
|
|
|
|
|
|
- useJwt.postData('/api/recipients/index').then(res => {
|
|
|
+ useJwt.postData('/api/recipients/index_by_activity', { activityId: this.activity.id }).then(res => {
|
|
|
this.recipientsList = res.data;
|
|
|
});
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ draw_zero() {
|
|
|
+ if (this.drawMax == 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
getPrizeList(prizeList) {
|
|
|
var output = [];
|
|
|
@@ -116,7 +136,8 @@ export default {
|
|
|
getRecipientsList(recipientsList) {
|
|
|
var output = [];
|
|
|
recipientsList.forEach(element => {
|
|
|
- output.push({ '獎項': this.getPrizeName(element.prize_id), '獲獎人': this.userList[element.user_id], '時間': element.created_at });
|
|
|
+ console.log(element.created_at);
|
|
|
+ output.push({ '獎項': this.getPrizeName(element.prize_id), '獲獎人': this.userIdList[element.user_id], '時間': this.dateFormat(element.created_at) });
|
|
|
});
|
|
|
return output;
|
|
|
},
|
|
|
@@ -127,7 +148,7 @@ export default {
|
|
|
this.drawNumber = 1;
|
|
|
},
|
|
|
draw() {
|
|
|
- useJwt.postData('/api/check_in/drawP', { number: this.drawNumber, region: this.placeSelected }).then(res => {
|
|
|
+ useJwt.postData('/api/check_in/draw_by_region', { deadline: this.activity.deadline, region: this.region, number: this.drawNumber }).then(res => {
|
|
|
res.data.forEach(element => {
|
|
|
console.log(element);
|
|
|
useJwt.postData('/api/prize/draw', { prizeId: this.prizeId }).then(p => {
|
|
|
@@ -144,15 +165,21 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
updateDataset() {
|
|
|
- useJwt.postData('/api/prize/index').then(res => {
|
|
|
+ useJwt.postData('/api/prize/index_by_activity', { activityId: this.activity.id }).then(res => {
|
|
|
this.prizeList = res.data;
|
|
|
});
|
|
|
- useJwt.postData('/api/recipients/index').then(res => {
|
|
|
+ useJwt.postData('/api/recipients/index_by_activity', { activityId: this.activity.id }).then(res => {
|
|
|
this.recipientsList = res.data;
|
|
|
});
|
|
|
},
|
|
|
- test() {
|
|
|
- console.log(this.placeSelected);
|
|
|
+ dateFormat(date) {
|
|
|
+ var d = new Date(date);
|
|
|
+ return d.getFullYear()
|
|
|
+ + '/' + (d.getMonth() + 1).toString().padStart(2, '0')
|
|
|
+ + '/' + d.getDay().toString().padStart(2, '0')
|
|
|
+ + '/' + d.getHours().toString().padStart(2, '0')
|
|
|
+ + ':' + d.getMinutes().toString().padStart(2, '0')
|
|
|
+ + ':' + d.getSeconds().toString().padStart(2, '0');
|
|
|
},
|
|
|
},
|
|
|
}
|