mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat tarifa maquinas
This commit is contained in:
30
httpdocs/assets/js/safekat/components/forms/formClass.js
Normal file
30
httpdocs/assets/js/safekat/components/forms/formClass.js
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
|
||||
class FormClass
|
||||
{
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.formData = null
|
||||
}
|
||||
|
||||
validateField()
|
||||
{
|
||||
|
||||
}
|
||||
setAsValid(field)
|
||||
{
|
||||
}
|
||||
setAsInvalid(field){}
|
||||
addSuccessFeedback(field){}
|
||||
addErrorFeedback(field){}
|
||||
getFormData() {
|
||||
let data = {}
|
||||
this.item.serializeArray().forEach((e) => {
|
||||
data[e.name] = e.value
|
||||
}
|
||||
)
|
||||
this.formData = data
|
||||
return this.formData
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import TarifaMaquina from "../../tarifaMaquina.js"
|
||||
|
||||
|
||||
$(() => {
|
||||
const tarifaMaquinaAcabado = new TarifaMaquina($("#tarifa_maquina_component"),"acabado");
|
||||
tarifaMaquinaAcabado.init()
|
||||
})
|
||||
@ -0,0 +1,7 @@
|
||||
import TarifaMaquina from "../../tarifaMaquina.js"
|
||||
|
||||
|
||||
$(() => {
|
||||
const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"encuadernacion");
|
||||
tarifaMaquina.init()
|
||||
})
|
||||
@ -0,0 +1,7 @@
|
||||
import TarifaMaquina from "../../tarifaMaquina.js"
|
||||
|
||||
|
||||
$(() => {
|
||||
const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"extra");
|
||||
tarifaMaquina.init()
|
||||
})
|
||||
@ -0,0 +1,7 @@
|
||||
import TarifaMaquina from "../../tarifaMaquina.js"
|
||||
|
||||
|
||||
$(() => {
|
||||
const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"manipulado");
|
||||
tarifaMaquina.init()
|
||||
})
|
||||
@ -0,0 +1,7 @@
|
||||
import TarifaMaquina from "../../tarifaMaquina.js"
|
||||
|
||||
|
||||
$(() => {
|
||||
const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"preimpresion");
|
||||
tarifaMaquina.init()
|
||||
})
|
||||
94
httpdocs/assets/js/safekat/pages/tarifas/tarifaMaquina.js
Normal file
94
httpdocs/assets/js/safekat/pages/tarifas/tarifaMaquina.js
Normal file
@ -0,0 +1,94 @@
|
||||
import ClassSelect from "../../components/select2.js";
|
||||
import Ajax from "../../components/ajax.js";
|
||||
class TarifaMaquina {
|
||||
constructor(domItem, type = "acabado") {
|
||||
this.item = domItem
|
||||
this.type = type
|
||||
this.tarifaId = this.item.data("id")
|
||||
this.btnNewTarifaMaquina = this.item.find("#btn-new-tarifa-maquina")
|
||||
this.selectTarifaMaquina = new ClassSelect(this.item.find("#select-tarifa-maquina"), `/tarifas/maquinas/${this.type}/select`, "Seleccione una maquina", true);
|
||||
this.selectMaquinaTarea = new ClassSelect(this.item.find("#select-maquina-tarea"), `/tarifas/maquinas/tareas/select`, "Seleccione una tarea", true);
|
||||
this.datatableItem = this.item.find("#table-tarifa-maquinas")
|
||||
this.datatableColumns = [
|
||||
{ data: 'maquinaNombre', searchable: false, sortable: false },
|
||||
{ data: 'tareaNombre', searchable: false, sortable: false },
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
return `<div class="btn-group btn-group-xs">
|
||||
<a type="button" class="btn btn-xs tarifa-maquina-btn-delete" data-id="${d}"><i class="ti ti-trash ti-sm mx-2"></i></a>
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
init() {
|
||||
// this.btnNewTarifaMaquina.prop("disabled",true)
|
||||
this.selectMaquinaTarea.init()
|
||||
this.selectTarifaMaquina.init()
|
||||
this.datatable = this.datatableItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
serverSide: true,
|
||||
pageLength: 25,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: `/tarifas/maquinas/${this.type}/datatable/${this.tarifaId}`
|
||||
});
|
||||
this.events();
|
||||
}
|
||||
events() {
|
||||
this.btnNewTarifaMaquina.on("click", this.handleNewTarifaMaquina.bind(this));
|
||||
this.datatable.on("click", ".tarifa-maquina-btn-delete", this.handleDeleteTarifaMaquina.bind(this))
|
||||
}
|
||||
handleNewTarifaMaquina() {
|
||||
let key = `tarifa_${this.type}_id`
|
||||
let bodyData = {
|
||||
maquina_id: this.selectTarifaMaquina.getVal(),
|
||||
maquina_tarea_id: this.selectMaquinaTarea.getVal()
|
||||
}
|
||||
bodyData[key] = this.tarifaId;
|
||||
|
||||
const ajax = new Ajax(
|
||||
`/tarifas/maquinas/${this.type}`,
|
||||
bodyData,
|
||||
null,
|
||||
this.handleNewTarifaMaquinaSuccess.bind(this),
|
||||
this.handleNewTarifaMaquinaError.bind(this),
|
||||
)
|
||||
ajax.post()
|
||||
}
|
||||
handleNewTarifaMaquinaSuccess(response) {
|
||||
this.datatable.ajax.reload()
|
||||
this.selectMaquinaTarea.reset()
|
||||
this.selectTarifaMaquina.reset()
|
||||
console.log(response)
|
||||
}
|
||||
handleNewTarifaMaquinaError(error) { }
|
||||
|
||||
handleDeleteTarifaMaquina(event) {
|
||||
const tarifaMaquinaId = $(event.currentTarget).data("id")
|
||||
const ajax = new Ajax(
|
||||
`/tarifas/maquinas/${this.type}/${tarifaMaquinaId}`,
|
||||
null,
|
||||
null,
|
||||
this.handleDeleteTarifaMaquinaSuccess.bind(this),
|
||||
this.handleDeleteTarifaMaquinaError.bind(this),
|
||||
)
|
||||
ajax.delete()
|
||||
}
|
||||
handleDeleteTarifaMaquinaSuccess() {
|
||||
this.datatable.ajax.reload()
|
||||
}
|
||||
handleDeleteTarifaMaquinaError() { }
|
||||
|
||||
}
|
||||
export default TarifaMaquina
|
||||
Reference in New Issue
Block a user