error presupuestos

This commit is contained in:
amazuecos
2024-10-18 16:00:10 +02:00
parent 23491b2e1a
commit f1df4559f7
13 changed files with 7367 additions and 318 deletions

View File

@ -4,8 +4,7 @@ class ErrorPresupuestoView {
this.item = domItem
this.datatableItem = this.item.find("#tableErrorPresupuesto")
this.datatableColumns = [
{ data: 'id', name: "id", searchable: true, sortable: false },
{ data: 'presupuestoTitulo',searchable: true, sortable: false },
{ data: 'presupuestoId', searchable: true, sortable: false },
{ data: 'presupuestoUser',searchable: true, sortable: false },
{ data: 'lastUser', searchable: true, sortable: false },
{ data: 'visto', searchable: false, sortable: false ,

View File

@ -1,44 +1,68 @@
import Ajax from "../../../components/ajax.js"
import Ajax from "../../../components/ajax.js";
import ajax from "../../../components/ajax.js"
class ErrorPresupuestoView {
class ErrorPresupuestoForm {
constructor(domItem) {
this.item = domItem
this.datatableItem = this.item.find("#tableErrorPresupuesto")
this.datatableColumns = [
{ data: 'id', searchable: true, sortable: false },
{ data: 'presupuestoTitulo', searchable: true, sortable: false },
{ data: 'presupuestoUser', searchable: true, sortable: false },
{ data: 'visto', searchable: false, sortable: false },
{ data: 'lastUser', searchable: true, sortable: false },
{
data: 'action', sortable: false, searchable: false,
render: (d, t) => {
return `
<div class="btn-group btn-group-sm">
<a href="javascript:void(0)" data-id="${d}" class="edit-error-presupuesto"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>
`
}
},
]
this.form = this.item.find("#error-presupuesto-form")
this.inputPresupuestoUserId = this.item.find("#presupuesto-user-id")
this.inputDatos = this.item.find("#datos-presupuesto")
this.inputComments = this.item.find("#comments-presupuesto")
this.errorPresupuestoId = this.item.find("#error-presupuesto-id").attr("value")
this.updateBtnIcon = this.item.find("#update-button-icon")
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
dom: 'Brtip',
serverSide: true,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/errores-presupuesto/datatable'
});
this.item.on("click",".button-update-comment",this.handlePostErrorPresupuesto.bind(this))
this.handleGetErrorPresupuesto()
}
handleGetErrorPresupuesto()
{
const ajax = new Ajax(
`/configuracion/errores-presupuesto/get/${this.errorPresupuestoId}`,
null,
null,
this.handleGetErrorPresupuestoSuccess.bind(this),
this.handleGetErrorPresupuestoError.bind(this)
)
ajax.get()
}
handleGetErrorPresupuestoSuccess(data){
this.inputPresupuestoUserId.val(data.data.presupuestoUser)
this.inputDatos.val(data.data.datos)
this.inputComments.val(data.data.comment)
this.updateBtnIcon.removeClass()
this.updateBtnIcon.addClass("ti ti-md ti-send")
}
handleGetErrorPresupuestoError(){}
handlePostErrorPresupuesto()
{
let data =
{
"comments" : this.inputComments.val()
}
this.updateBtnIcon.removeClass()
this.updateBtnIcon.addClass("spinner-border spinner-border-lg text-secondary")
const ajax = new Ajax(
`/configuracion/errores-presupuesto/edit/${this.errorPresupuestoId}`,
data,
null,
this.handlePostErrorPresupuestoSuccess.bind(this),
this.handlePostErrorPresupuestoError.bind(this)
)
ajax.post()
}
handlePostErrorPresupuestoSuccess(){
this.updateBtnIcon.removeClass()
this.updateBtnIcon.addClass("ti ti-md ti-check")
this.handleGetErrorPresupuesto()
}
handlePostErrorPresupuestoError(error){}
}
export default ErrorPresupuestoView;
export default ErrorPresupuestoForm;

View File

@ -0,0 +1,6 @@
import ErrorPresupuestoForm from "./errorPresupuestoForm.js";
$(document).ready(() => {
const errorPresupuestoForm = new ErrorPresupuestoForm($("#error-presupuesto-container"))
errorPresupuestoForm.init()
})