run maintanance

This commit is contained in:
Alessandro Francia
2018-06-19 16:05:19 +02:00
parent c3ae6e9635
commit d826952e8a
3 changed files with 30 additions and 6 deletions
@@ -53,6 +53,7 @@
</div>
<div class="maintenance-box-right" :class="{'enableMaintenance': enableMaintenance}">
<maintenance-card :can-edit="selectedMaintenance != null ? selectedMaintenance.canEdit : false"
:can-perform="selectedMaintenance != null ? selectedMaintenance.canPerform : false"
:expiration="selectedMaintenance != null ? expirationDate(selectedMaintenance.type, selectedMaintenance.missingDays) : ''"
:selectedMaintenance="selectedMaintenance ? selectedMaintenance : {}"
:note-maintenance="selectedMaintenance ? noteMaintenance : {}"
@@ -11,8 +11,8 @@
<div class="body">
<div class="box scrollable">
<div class="title-box">{{selectedMaintenance.description}}</div>
<div class="subtitle" v-if="getDaysFromLastExpiration(selectedMaintenance.lastExpirationDate)">Ultimo intervento effettuato {{getDaysFromLastExpiration(selectedMaintenance.lastExpirationDate)}} gg fa</div>
<div class="subtitle" v-if="!getDaysFromLastExpiration(selectedMaintenance.lastExpirationDate)">Non esiste nessuna manutenzione</div>
<div class="subtitle" v-if="existMantainance()">Ultimo intervento effettuato {{getDaysFromLastExpiration(selectedMaintenance)}} gg fa</div>
<div class="subtitle" v-if="existMantainance()">Non esiste nessuna manutenzione</div>
<div class="info">
<!-- <div class="estimated-time">
<div class="title">Tempo stimato</div>
@@ -92,7 +92,7 @@
<div class="footer">
<div class="title-footer">{{'maintenance_card_label_footer' | localize("Segna questa manutenzione come ")}} <div> {{'maintenance_card_label_execute' | localize("eseguita")}}</div></div>
<div class="right-footer">
<button class="btn">{{'maintenance_card_label_btn_footer' | localize("Eseguita")}}</button>
<button class="btn" :disabled="!canPerform" @click="onClickRunMaintenance(selectedMaintenance)">{{'maintenance_card_label_btn_footer' | localize("Eseguita")}}</button>
</div>
</div>
</div>
@@ -110,6 +110,7 @@ export default {
selectedMaintenance: {default: {}},
noteMaintenance: {default: []},
canEdit:{ default: false },
canPerform: {default: false}
// enableModifyNote: {default: true}
},
data(){
@@ -118,7 +119,8 @@ export default {
selectedNoteMaintenance: {},
note: {},
currentNoteMaintenance: {},
limitationList: 3
limitationList: 3,
lastPerformDate: ""
}
},
components: {
@@ -192,11 +194,26 @@ export default {
}
},
getDaysFromLastExpiration(m){
debugger
if(m){
return moment(m).fromNow();
var today = moment(new Date());
var end = moment(m.lastPerformedDate);
this.lastPerformDate = moment.duration(today.diff(end));
return this.lastPerformDate._data.days;
}
else{
return m;
return null;
}
},
async onClickRunMaintenance(m){
await new MaintenanceService().RunMaintenance(m);
},
existMantainance(){
if(this.selectedMaintenance.lastPerformedDate){
return true;
}
else{
return false;
}
}
}
@@ -39,5 +39,11 @@ export class MaintenanceService extends baseRestService {
maintenanceActions.modifyNoteMaintenance(store, model);
return result;
}
async RunMaintenance(model){
debugger
let result = await this.Post<server.Maintenance>(this.BASE_URL + "maintenance/" + model.id + "/performe", model, true);
model.lastPerformedDate = result;
maintenanceActions.updateMaintenance(store, model);
}
}