Rutas para faltantes y sobrantes
This commit is contained in:
parent
27390e4659
commit
6ad00b2de1
3 changed files with 49 additions and 3 deletions
|
@ -16,6 +16,16 @@ class GrupoDeCompra extends Model
|
|||
protected $table = 'grupos_de_compra';
|
||||
protected $hidden = ['password'];
|
||||
|
||||
public function faltantes()
|
||||
{
|
||||
return 'Faltantes de ' . $this->nombre;
|
||||
}
|
||||
|
||||
public function sobrantes()
|
||||
{
|
||||
return 'Sobrantes de ' . $this->nombre;
|
||||
}
|
||||
|
||||
public function toggleDevoluciones()
|
||||
{
|
||||
$this->devoluciones_habilitadas = !$this->devoluciones_habilitadas;
|
||||
|
|
|
@ -9,39 +9,67 @@
|
|||
</tabs-secciones>
|
||||
<div class="block pb-6" id="faltantes-seccion"
|
||||
:class="seccionActiva === 'faltantes-seccion' ? 'is-active' : 'is-hidden'">
|
||||
<p>Faltantes</p>
|
||||
<p>{{faltantes ?? 'nada aún'}}</p>
|
||||
</div>
|
||||
<div class="block pb-6" id="sobrantes-seccion"
|
||||
:class="seccionActiva === 'sobrantes-seccion' ? 'is-active' : 'is-hidden'">
|
||||
<p>Sobrantes</p>
|
||||
<p>{{sobrantes ?? 'nada aún'}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import TabsSecciones from "../comunes/TabsSecciones.vue";
|
||||
import Chismosa from "../pedidos/Chismosa.vue";
|
||||
|
||||
export default {
|
||||
name: "FaltantesYSobrantes",
|
||||
components: {
|
||||
TabsSecciones,
|
||||
Chismosa,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
gdc: undefined,
|
||||
tabs: [{ id: "faltantes", nombre: "Faltantes" },
|
||||
{ id: "sobrantes", nombre: "Sobrantes" }],
|
||||
tabActiva: "faltantes",
|
||||
seccionActiva: "faltantes-seccion",
|
||||
faltantes: undefined,
|
||||
sobrantes: undefined,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'$root.gdc' : {
|
||||
handler(newValue) {
|
||||
if (newValue) {
|
||||
this.gdc = newValue;
|
||||
this.actualizarFaltantes();
|
||||
this.actualizarSobrantes();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setSeccionActiva(tabId) {
|
||||
this.tabActiva = tabId;
|
||||
this.seccionActiva = tabId + "-seccion";
|
||||
},
|
||||
actualizarFaltantes() {
|
||||
axios.get(`/api/grupos-de-compra/${this.gdc}/faltantes`)
|
||||
.then(response => {
|
||||
this.faltantes = response.data['faltantes'];
|
||||
})
|
||||
},
|
||||
actualizarSobrantes() {
|
||||
axios.get(`/api/grupos-de-compra/${this.gdc}/sobrantes`)
|
||||
.then(response => {
|
||||
this.sobrantes = response.data['sobrantes'];
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -44,6 +44,14 @@ Route::middleware('api')->group(function () {
|
|||
$habilitadas = GrupoDeCompra::find($gdc)->toggleDevoluciones();
|
||||
return ['devoluciones' => $habilitadas];
|
||||
});
|
||||
Route::get('/{gdc}/faltantes', function($gdc) {
|
||||
$faltantes = GrupoDeCompra::find($gdc)->faltantes();
|
||||
return ['faltantes' => $faltantes];
|
||||
});
|
||||
Route::get('/{gdc}/sobrantes', function($gdc) {
|
||||
$sobrantes = GrupoDeCompra::find($gdc)->sobrantes();
|
||||
return ['sobrantes' => $sobrantes];
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('subpedidos')->group(function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue