85 lines
3.2 KiB
Vue
85 lines
3.2 KiB
Vue
<template>
|
|
<div>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
Instants gagnants
|
|
<button v-if="cangenerate" class="btn btn-sm btn-success float-right" @click="generate()"><i class="fas fa-cog"></i> Générer</button>
|
|
<button v-else class="btn btn-sm btn-success float-right" v-clipboard="() => clipboard" @click="copyToClipboard()">
|
|
<span v-show="!copying"><i class="far fa-copy"></i> Exporter</span>
|
|
<span v-show="copying"> <i class="fas fa-check"></i> Texte copié !</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div v-if="cangenerate">
|
|
Aucun instant gagnant pour le moment.
|
|
</div>
|
|
<table class="table table-sm table-striped text-center" v-else>
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th class="w-25" scope="col">Date d'apparition</th>
|
|
<th class="w-50" scope="col">Lot</th>
|
|
<th class="w-25" scope="col">Gagné</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="item in datas" v-bind:key="item.id">
|
|
<td>{{item.appear_date}}</td>
|
|
<td>{{item.prize.label_one}}</td>
|
|
<td>{{item.won === false ? "Non" : "Oui"}}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
mounted() {
|
|
console.log('Instant Win Component mounted.');
|
|
this.datas = JSON.parse(this.instantwin);
|
|
this.clipboard = "Voici la liste des instants gagnants :\n";
|
|
this.datas.forEach(
|
|
element => this.clipboard += "Le " + new Date(element.appear_date).toLocaleDateString() + " à "
|
|
+ element.appear_date.substring(element.appear_date.length - 8, element.appear_date.length - 3)
|
|
+ " - " + element.prize.label_one + "\n"
|
|
);
|
|
$('.toast').toast();
|
|
},
|
|
props: {
|
|
cangenerate: Number,
|
|
startdate: String,
|
|
enddate: String,
|
|
instantwin: String
|
|
},
|
|
data() {
|
|
return {
|
|
datas: [],
|
|
response: null,
|
|
clipboard: '',
|
|
copying: false
|
|
}
|
|
},
|
|
methods: {
|
|
generate() {
|
|
axios.get('/bo/ajax/instant-win-generate')
|
|
.then(
|
|
response => (this.datas = response.data)
|
|
)
|
|
.catch(function (error) {
|
|
console.log(error);
|
|
this.response = "Erreur lors de la génération.";
|
|
});
|
|
this.cangenerate = 0;
|
|
},
|
|
copyToClipboard() {
|
|
this.copying = true;
|
|
setTimeout(function() {
|
|
this.copying = false;
|
|
}.bind(this), 1000);
|
|
}
|
|
}
|
|
}
|
|
</script>
|