- Add status checker + admin secure packages + upgrade enum + add sentry + upgrade to sitemap generator + bump to CRMV2 - Set customer role enum and user role enum - Update customer migration to set roles - phpcbf - faker local to fr - update lang - composer update - bump laravel ui - Redo all user crud - npm bump - Create admin command - rearrange views - redo all auth system - redo customer pro bo
308 lines
13 KiB
Vue
308 lines
13 KiB
Vue
<template>
|
|
<div class="pro--objectifs">
|
|
<div class="objectifs--form">
|
|
<h2 class="post-title">Fixer un objectif de prix</h2>
|
|
<transition name="fade">
|
|
<div class="alert alert-success" v-show="processing">
|
|
{{ response }}
|
|
</div>
|
|
</transition>
|
|
<transition name="fade">
|
|
<div class="alert alert-success" v-show="success">
|
|
{{ response }}
|
|
</div>
|
|
</transition>
|
|
<transition name="fade">
|
|
<div class="alert alert-danger" v-show="errors">
|
|
{{ response }}
|
|
<ul>
|
|
<li v-for="error in errors">{{ error }}</li>
|
|
</ul>
|
|
</div>
|
|
</transition>
|
|
<form method="" action="">
|
|
<div class="flex row">
|
|
<select name="produit" id="produit" v-model="objectif.produit" @change="populate">
|
|
<option value="--">Selectionner un produit*</option>
|
|
<option v-for="produit in enums['produit']" :value="produit.value">{{ produit.value }}</option>
|
|
</select>
|
|
<select name="qualite" v-model="objectif.qualite">
|
|
<option value="--">Qualité</option>
|
|
<option v-for="qualite in qualiteEnums" :value="qualite.value">{{ qualite.value }}</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex row">
|
|
<select name="campagne" v-model="objectif.campagne" @change="populate">
|
|
<option value="--">Choisir une campagne</option>
|
|
<option v-for="campagne in campagneEnums" :value="campagne.value">{{ campagne.value }}</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex row">
|
|
<select name="quantite" v-model="objectif.quantite">
|
|
<option value="0">Choisir une quantité* (en TM)</option>
|
|
<option value="30">30</option>
|
|
<option value="50">50</option>
|
|
<option value="60">60</option>
|
|
<option value="90">90</option>
|
|
<option value="100">100</option>
|
|
<option value="120">120</option>
|
|
<option value="150">150</option>
|
|
</select>
|
|
<span>ou saisir une quantité</span>
|
|
<input type="number" name="qtty" id="qtty" v-model="objectif.quantite" placeholder="0" value="">
|
|
</div>
|
|
<div class="flex row">
|
|
<span>Saisir un prix €/TM*</span>
|
|
<input type="number" name="price" id="price" v-model="objectif.prix" placeholder="0" value="" min=0
|
|
step="any" required>
|
|
<select name="echeance" v-model="objectif.echeance">
|
|
<option value="--">Choisir une échéance*</option>
|
|
<option v-for="echeance in echeanceEnums" :value="echeance.value">{{ echeance.value }}</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex row">
|
|
<span>Volume restant à commercialiser</span>
|
|
<input type="number" name="remaining_volume" id="remaining_volume" v-model="objectif.volume_restant"
|
|
placeholder="0" value="">
|
|
</div>
|
|
<!--<div class="flex row">
|
|
<span>Observations</span>
|
|
<input type="text" name="observations" id="observations" v-model="objectif.observations" placeholder="Commentaire">
|
|
</div>-->
|
|
<div class="validate">
|
|
<span>* Champs obligatoires</span>
|
|
<button class="first-btn" @click.prevent="saveData()" :disabled="processing">
|
|
Enregistrer l'objectif
|
|
<div class="spinner-border spinner-border-sm text-light" role="status" v-show="processing">
|
|
<span class="sr-only">Enregistrement...</span>
|
|
</div>
|
|
</button>
|
|
<!--<input type="submit" value="Enregistrer l'objectif" class="first-btn">-->
|
|
</div>
|
|
<div class="flex row disclaimer">
|
|
Quand votre objectif sera atteint, un mail et sms vous sera adressé pour contacter votre Technico
|
|
Commercial avant 17h45.
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="objectifs--list">
|
|
<h2 class="post-title">Mes objectifs en cours</h2>
|
|
<div class="objectifs--header">
|
|
<div></div>
|
|
<div>Qté</div>
|
|
<div>Prod</div>
|
|
<div>Qualité</div>
|
|
<div>Prix</div>
|
|
<div>Echéance</div>
|
|
<div><!-- statut --></div>
|
|
<div><!-- actions --></div>
|
|
</div>
|
|
<div v-for="(item, index) in myobjectives" v-bind:key="item.id" class="objectifs--row">
|
|
<div>{{ item.campagne }}</div>
|
|
<div>{{ item.quantite }} TM</div>
|
|
<div>{{ item.produit }}</div>
|
|
<div class="smallest">{{ item.qualite }}</div>
|
|
<div>{{ item.prix }} €</div>
|
|
<div>{{ item.echeance }}</div>
|
|
<div :class="'status status--' + item.status_id">{{ item.status.label }}</div>
|
|
<div class="action">
|
|
<svg width="25" height="25" @click.prevent="removeItem(index)">
|
|
<use xlink:href="#croix" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<svg>
|
|
<symbol id="croix" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
x="0px" y="0px" viewBox="0 0 87.3 85.8" style="enable-background:new 0 0 87.3 85.8;" xml:space="preserve">
|
|
<path
|
|
d="M78.4,43.5c0,19.3-15.6,34.9-34.9,34.9c-19.3,0-34.9-15.6-34.9-34.9c0-19.3,15.6-34.9,34.9-34.9C62.8,8.7,78.4,24.3,78.4,43.5z" />
|
|
<line x1="30.9" y1="30.9" x2="56.2" y2="56.2" />
|
|
<line x1="56.2" y1="30.9" x2="30.9" y2="56.2" />
|
|
</symbol>
|
|
</svg>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
mounted() {
|
|
console.log('Objectives Component mounted.');
|
|
this.enums = JSON.parse(this.formEnums);
|
|
this.objectif = JSON.parse(this.dbobjectif);
|
|
this.myobjectives = JSON.parse(this.dbmyObjectives);
|
|
},
|
|
props: [
|
|
'name',
|
|
'dbobjectif',
|
|
'dbmyObjectives',
|
|
'formEnums',
|
|
],
|
|
data() {
|
|
return {
|
|
objectif: [],
|
|
myobjectives: [],
|
|
enums: [],
|
|
qualiteEnums: [],
|
|
campagneEnums: [],
|
|
echeanceEnums: [],
|
|
processing: false,
|
|
success: false,
|
|
errors: false,
|
|
response: '',
|
|
}
|
|
},
|
|
watch: {
|
|
|
|
},
|
|
methods: {
|
|
populate(event) {
|
|
// console.log(event.target.name);
|
|
// console.log(event.target.value);
|
|
//en l'état on ne peuple qu'a partir de produit
|
|
switch (event.target.name) {
|
|
case 'produit':
|
|
this.qualiteEnums = this.enums['qualite'][event.target.value];
|
|
// selection de la première qualité systématique
|
|
this.objectif.qualite = this.qualiteEnums[0].value;
|
|
this.campagneEnums = this.enums['campagne'][event.target.value];
|
|
break;
|
|
case 'campagne':
|
|
let selectProduit = document.getElementById('produit').value;
|
|
console.log(selectProduit);
|
|
this.echeanceEnums = this.enums['echeance'][selectProduit][event.target.value];
|
|
break;
|
|
default:
|
|
console.log(event.target.name);
|
|
}
|
|
},
|
|
checkForm() {
|
|
this.errors = [];
|
|
|
|
if (this.objectif.produit == '--') {
|
|
this.errors.push("Veuillez choisir un produit");
|
|
}
|
|
if (this.objectif.qualite == '--') {
|
|
this.errors.push("Veuillez choisir une qualité");
|
|
}
|
|
if (this.objectif.campagne == '--') {
|
|
this.errors.push("Veuillez choisir une campgane");
|
|
}
|
|
if (!this.objectif.quantite) {
|
|
this.errors.push("Veuillez indiquer une quantite");
|
|
}
|
|
if (!this.objectif.prix) {
|
|
this.errors.push("Veuillez indiquer un prix");
|
|
}
|
|
if (this.objectif.echeance == '--') {
|
|
this.errors.push("Veuillez choisir une echéance");
|
|
}
|
|
|
|
|
|
|
|
if (!this.errors.length) {
|
|
return true;
|
|
} else {
|
|
this.response = "Veuillez corriger les erreurs suivantes :";
|
|
}
|
|
},
|
|
removeItem(index) {
|
|
if (confirm("Êtes-vous sûr(e) ?")) {
|
|
if (this.myobjectives[index].id !== null) {
|
|
this.processing = true;
|
|
this.response = "Suppression en cours...";
|
|
window.axios.post('/pro/ajax/delete-objectif', {
|
|
id: this.myobjectives[index].id,
|
|
}).then(
|
|
(response) => {
|
|
let result = response.data;
|
|
switch (result) {
|
|
case 0: case 2:
|
|
// 0 = Supprimé, 2 = Pas encore en base, supprimer juste dans la vue
|
|
this.response = "Suppression terminée !";
|
|
this.myobjectives.splice(index, 1);
|
|
this.processing = false;
|
|
break;
|
|
case 3:
|
|
// 1 = Non supprimer car pa autorisé
|
|
this.response = "Erreur : Suppression impossible";
|
|
setTimeout(() => {
|
|
this.processing = false;
|
|
}, 1500);
|
|
break;
|
|
}
|
|
}
|
|
).catch((error) => {
|
|
console.log(error);
|
|
this.response = "Erreur lors de la suppression.";
|
|
this.processing = false;
|
|
});
|
|
} else {
|
|
this.myobjectives.splice(index, 1);
|
|
}
|
|
}
|
|
},
|
|
saveData() {
|
|
let formOk = this.checkForm();
|
|
if (formOk) {
|
|
this.processing = true;
|
|
this.success = false;
|
|
this.errors = false;
|
|
this.response = "En cours de sauvegarde..."
|
|
window.axios.post('/pro/ajax/save-objectif', {
|
|
objectif: this.objectif,
|
|
}).then(
|
|
(response) => {
|
|
this.objectif = JSON.parse(this.dbobjectif);
|
|
this.success = true;
|
|
this.response = "Sauvegarde terminée !";
|
|
this.processing = false;
|
|
//send response.data to the list
|
|
this.myobjectives.push(response.data);
|
|
}
|
|
).catch((error) => {
|
|
//on réactive le bouton
|
|
this.processing = false;
|
|
this.errors = true;
|
|
this.response = "Erreur lors de la sauvegarde.";
|
|
if (error.response) {
|
|
// The request was made and the server responded with a status code
|
|
// that falls out of the range of 2xx
|
|
console.log(error.response.data);
|
|
console.log(error.response.status);
|
|
console.log(error.response.headers);
|
|
|
|
console.log("Err", err);
|
|
console.log("2", err.response.data);
|
|
} else if (error.request) {
|
|
// The request was made but no response was received
|
|
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
// http.ClientRequest in node.js
|
|
console.log(error.request);
|
|
} else {
|
|
// Something happened in setting up the request that triggered an Error
|
|
console.log('Error', error.message);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.fade-enter-active,
|
|
.fade-leave-active {
|
|
transition: opacity .5s;
|
|
}
|
|
|
|
.fade-enter,
|
|
.fade-leave-to
|
|
|
|
/* .fade-leave-active below version 2.1.8 */
|
|
{
|
|
opacity: 0;
|
|
}
|
|
</style>
|