Merge branch 'main' into 'feat/catalogo'

Main

See merge request jjimenez/safekat!718
This commit is contained in:
Ignacio Martinez Navajas
2025-04-21 12:07:04 +00:00
547 changed files with 2700 additions and 1216 deletions

View File

@ -0,0 +1,84 @@
import ClassSelect from "../select2.js";
import Ajax from "../ajax.js";
class ImposicionDatatable {
constructor(domItem) {
this.item = domItem
this.datatableColumns = [
{ data: 'id', searchable: true, sortable: true },
{ data: 'ancho', searchable: true, sortable: true },
{ data: 'alto', searchable: true, sortable: true },
{ data: 'unidades', searchable: true, sortable: true },
{ data: 'orientacion', searchable: true, sortable: true },
{ data: 'maquina', searchable: true, sortable: true },
{ data: 'etiqueta', searchable: true, sortable: true },
{ data: 'esquema', searchable: true, sortable: true, render: this.renderImposicionEsquemaCell.bind(this) },
{ data: 'action', searchable: true, sortable: true },
]
this.datatableEsquemaColumns = [
{ data: 'name', searchable: true, sortable: true },
{ data: 'action', searchable: true, sortable: true },
]
}
init() {
this.datatable = this.item.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
columnDefs: [
{ className: 'dt-center', targets: [0, 1, 2, 3, 4, 5, 6] },
],
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/imposiciones/datatable',
createdRow: (row, data, dataIndex) => {
this.createSelectImposicion(row, data)
}
});
// this.datatable.on("draw.dt", this.createSelectImposicion.bind(this))
this.item.on("change", ".imposicion-esquema-select", this.handleChangeImposicionEsquema.bind(this))
}
renderImposicionEsquemaCell(d, t) {
return `<select name="imposicion_esquema_id" data-id="${d.imposicionId}" class="select2 form-control imposicion-esquema-select" data-input>
</select>`
}
createSelectImposicion(row, data) {
let selectEsquema = new ClassSelect($(row).find(".imposicion-esquema-select"), '/imposiciones/esquema/select', 'Seleccione un esquema', true)
selectEsquema.init()
if (data.esquema.esquemaId) {
selectEsquema.setOption(data.esquema.esquemaId, data.esquema.esquemaName)
}
}
handleChangeImposicionEsquema(event) {
let imposicionId = $(event.currentTarget).data("id")
let ajax = new Ajax(`/imposiciones/${imposicionId}`,
{
"imposicion_esquema_id": $(event.currentTarget).val(),
},
null,
this.handleChangeImposicionEsquemaSuccess.bind(this),
this.handleChangeImposicionEsquemaError.bind(this))
if (imposicionId) {
ajax.post()
}
}
handleChangeImposicionEsquemaSuccess(response) {
popSuccessAlert(response.message)
}
handleChangeImposicionEsquemaError() { }
}
export default ImposicionDatatable;

View File

@ -0,0 +1,35 @@
class ImposicionEsquemaDatatable {
constructor(domItem) {
this.item = domItem
this.datatableColumns = [
{ data: 'id', searchable: false, sortable: true },
{ data: 'name', searchable: true, sortable: true },
{ data: 'action', searchable: true, sortable: true },
]
}
init() {
this.datatable = this.item.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: '/imposiciones/esquema/datatable',
});
}
}
export default ImposicionEsquemaDatatable;

View File

@ -0,0 +1,188 @@
import Ajax from '../ajax.js'
import ImposicionEsquemaDrawing from '../imposicionEsquemaDrawing.js';
class ImposicionEsquemaForm {
constructor(domItem) {
this.item = domItem
if ($("#imposicion-esquema-drawing").length > 0) {
this.drawing = new ImposicionEsquemaDrawing($("#imposicion-esquema-drawing"))
} else {
this.drawing = null
}
this.modelId = this.item.data("id");
this.btnSubmitUpdateImposicion = this.item.find("#btnSubmitUpdateImposicionEsquema")
this.btnSubmitNewImposicion = this.item.find("#btnSubmitNewImposicionEsquema")
this.initialData = {
"name": null,
"rows": null,
"columns": null,
"rotativa": null,
"orientacion": null,
"cosido": null,
"svg_schema": null,
}
this.formData = this.initialData
}
load(status = false) {
if (status) {
Notiflix.Block.circle('.section-block');
} else {
Notiflix.Block.remove('.section-block');
}
}
init() {
if (this.drawing) {
this.drawing.setOrientation($("#esquema-orientacion").val())
this.item.on("change", "#esquema-rows", (event) => {
let rows = $(event.currentTarget).val()
this.drawing.setRows(rows)
})
this.item.on("change", "#esquema-rotativa", (event) => {
let rotativa = $(event.currentTarget).prop("checked")
this.drawing.setRotativa(rotativa)
})
this.item.on("change", "#esquema-cosido", (event) => {
let cosido = $(event.currentTarget).prop("checked")
this.drawing.setCosido(cosido)
})
this.item.on("change", "#esquema-orientacion", (event) => {
let orientation = $(event.currentTarget).val()
this.drawing.setOrientation(orientation)
})
this.item.on("change", "#esquema-columns", (event) => {
let columns = $(event.currentTarget).val()
this.drawing.setColumns(columns)
})
if (this.modelId) {
this.btnSubmitUpdateImposicion.on("click", this.handleUpdate.bind(this))
this.handleGetData()
} else {
this.initNew()
}
}
}
initNew() {
this.btnSubmitUpdateImposicion.on("click", this.handleNew.bind(this))
}
handleGetData() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/find/${this.modelId}`, null, null, this.handleGetDataSuccess.bind(this), this.handleGetDataError.bind(this))
if (this.modelId) {
ajax.get()
} else {
this.load(false)
}
}
getFormData() {
let data = {}
this.item.serializeArray().forEach((e) => {
let input = this.item.find(`input[name=${e.name}]`)
if (input) {
if (input.attr("type") != "checkbox") {
data[e.name] = e.value
}
}
}
)
this.formData = data
this.formData["svg_schema"] = this.drawing.getSVG()
this.formData["rotativa"] = this.drawing.rotativa == true ? 1 : 0;
this.formData["cosido"] = this.drawing.cosido == true ? 1 : 0;
return this.formData
}
setFormData(data) {
this.drawing.rows = data.rows
this.drawing.columns = data.columns
this.drawing.rotativa = data.rotativa
this.drawing.cosido = data.cosido
this.drawing.drawSchema()
Object.entries(data).forEach(([key, value], index) => {
let input = this.item.find(`input[name=${key}]`)
if (input) {
if (input.attr("type") == "checkbox") {
this.item.find(`input[name=${key}]`).prop("checked", value)
} else {
this.item.find(`input[name=${key}]`).val(value)
}
}
this.item.find(`select[name=${key}]`).val(value)
})
}
disable() {
Object.entries(this.initialData).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).prop("disabled", "disabled")
this.item.find(`select[name=${key}]`).prop("disabled", "disabled")
})
}
handleGetDataSuccess(response) {
this.setFormData(response)
this.load(false)
}
handleGetDataError() { }
handleNew() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/create`, this.getFormData(), null, this.postSuccessNew.bind(this), this.postErrorNew.bind(this))
ajax.post()
}
handleUpdate() {
this.load(true)
let ajax = new Ajax(`/imposiciones/esquema/${this.modelId}`, this.getFormData(), null, this.postSuccess.bind(this), this.postError.bind(this))
ajax.post()
}
handleDelete(id) {
let ajax = new Ajax(`/imposiciones/esquema/${id}`, null, null, this.deleteSuccess.bind(this), this.deleteError.bind(this))
ajax.delete()
}
deleteSuccess(response) {
popSuccessAlert(response.message)
}
deleteError(error) {
popErrorAlert(error.responseJSON.message)
}
postSuccess(response) {
this.load(false)
this.setFormData(response.data)
popSuccessAlert(response.message)
}
postError(error) {
this.load(false)
popErrorAlert(error.responseJSON.message)
this.validationErrors(error.responseJSON.errors)
}
postSuccessNew(response) {
this.load(false)
this.disable()
this.item.find(".invalid-feedback").remove()
this.btnSubmitNewImposicion.addClass("d-none")
this.btnSubmitUpdateImposicion.addClass("d-none")
popSuccessAlert(response.message)
}
postErrorNew(error) {
this.load(false)
this.validationErrors(error.responseJSON.errors)
popErrorAlert(error.responseJSON.message)
}
validationErrors(errors) {
this.item.find(".invalid-feedback").remove()
Object.entries(errors).forEach(([key, value], index) => {
let el = this.item.find(`input[name=${key}]`)
this.addError(el, value)
})
}
addError(el, error) {
el.addClass("is-invalid")
el.parent().append(`<div class="invalid-feedback">${error}</div>`)
}
}
export default ImposicionEsquemaForm;

View File

@ -0,0 +1,195 @@
import Ajax from '../ajax.js'
import ClassSelect from '../select2.js'
class ImposicionForm {
constructor(domItem) {
this.item = domItem
this.modelId = this.item.data("id");
this.btnSubmitUpdateImposicion = this.item.find("#btnSubmitUpdateImposicion")
this.btnSubmitNewImposicion = this.item.find("#btnSubmitNewImposicion")
this.selectImposicionEsquemaItem = this.item.find("#imposicion-esquema-select")
this.renderSchemaDiv = this.item.find("#imposicion-esquema-render");
this.schemaLink = this.item.find(".imposicion-esquema-link")
this.selectImposicionEsquema = new ClassSelect(this.selectImposicionEsquemaItem, '/imposiciones/esquema/select', 'Seleccione un esquema', true)
this.imposicionEsquemaData = {}
this.initialData = {
"ancho": null,
"alto": null,
"unidades": null,
"etiqueta": null,
"maquina": null,
"orientacion": null
}
this.formData = this.initialData
}
initSelectImposicionEsquema() {
this.selectImposicionEsquema.init()
this.selectImposicionEsquema.onChange(this.handleGetImposicionEsquema.bind(this))
}
resize() {
let w = this.renderSchemaDiv.width()
let h = this.renderSchemaDiv.height()
let svgX = this.renderSchemaDiv.find("svg").width()
this.renderSchemaDiv.find("svg").attr("width", w)
this.renderSchemaDiv.find("svg").attr("height", h)
this.renderSchemaDiv.find("svg").attr('viewBox', `0 0 ${svgX} ${h + 100}`);
}
load(status = false) {
if (status) {
Notiflix.Block.circle('.section-block');
} else {
Notiflix.Block.remove('.section-block');
}
}
loadSchema(status = false) {
if (status) {
Notiflix.Block.circle('.section-block-esquema');
} else {
Notiflix.Block.remove('.section-block-esquema');
}
}
init() {
this.btnSubmitUpdateImposicion.on("click", this.handleUpdate.bind(this))
this.handleGetData()
this.initSelectImposicionEsquema()
this.schemaLink.attr("disabled", "disabled")
$(window).on("resize", this.resize.bind(this))
}
initNew() {
this.btnSubmitNewImposicion.on("click", this.handleNew.bind(this))
this.initSelectImposicionEsquema()
this.schemaLink.attr("disabled", "disabled")
$(window).on("resize", this.resize.bind(this))
}
handleGetImposicionEsquema() {
this.loadSchema(true)
let imposicion_esquema_id = this.selectImposicionEsquema.getVal()
let ajax = new Ajax(`/imposiciones/esquema/find/${imposicion_esquema_id}`, null, null, this.handleGetImposicionEsquemaSuccess.bind(this), this.handleGetDataError.bind(this))
if (imposicion_esquema_id) {
ajax.get()
} else {
this.loadSchema(false)
this.renderSchemaDiv.find("svg").empty()
}
}
handleGetImposicionEsquemaSuccess(response) {
this.renderSchemaDiv.empty()
this.imposicionEsquemaData = response
this.renderSchemaDiv.append(response.svg_schema)
let svgX = this.renderSchemaDiv.width()
let svgY = this.renderSchemaDiv.height()
this.schemaLink.removeAttr("disabled")
this.schemaLink.attr("href", `/imposiciones/esquema/edit/${response.id}`)
this.renderSchemaDiv.find("svg").attr('viewBox', `0 0 ${svgX} ${svgY}`);
this.resize()
this.loadSchema(false)
}
handleGetImposicionEsquemaError(error) {
this.loadSchema(false)
}
handleGetData() {
this.load(true)
let ajax = new Ajax(`/imposiciones/find/${this.modelId}`, null, null, this.handleGetDataSuccess.bind(this), this.handleGetDataError.bind(this))
ajax.get()
}
getFormData() {
let data = {}
this.item.serializeArray().forEach((e) => {
data[e.name] = e.value
}
)
this.formData = data
return this.formData
}
setFormData(data) {
Object.entries(data).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).val(value)
this.item.find(`select[name=${key}]`).val(value)
if (key == "imposicion_esquema" && value) {
this.selectImposicionEsquema.setOption(value.id, value.name)
this.schemaLink.removeAttr("disabled")
this.schemaLink.attr("href", `/imposiciones/esquema/edit/${value.id}`)
}
})
}
disable() {
Object.entries(this.initialData).forEach(([key, value], index) => {
this.item.find(`input[name=${key}]`).prop("disabled", "disabled")
this.item.find(`select[name=${key}]`).prop("disabled", "disabled")
})
}
handleGetDataSuccess(response) {
this.setFormData(response)
this.load(false)
}
handleGetDataError() { }
handleNew() {
this.load(true)
let ajax = new Ajax(`/imposiciones/create`, this.getFormData(), null, this.postSuccessNew.bind(this), this.postErrorNew.bind(this))
ajax.post()
}
handleUpdate() {
this.load(true)
let ajax = new Ajax(`/imposiciones/${this.modelId}`, this.getFormData(), null, this.postSuccess.bind(this), this.postError.bind(this))
ajax.post()
}
handleDelete(id) {
let ajax = new Ajax(`/imposiciones/${id}`, null, null, this.deleteSuccess.bind(this), this.deleteError.bind(this))
ajax.delete()
}
deleteSuccess(response) {
popSuccessAlert(response.message)
}
deleteError(error) {
popErrorAlert(error.responseJSON.message)
}
postSuccess(response) {
this.load(false)
this.setFormData(response.data)
popSuccessAlert(response.message)
}
postError(error) {
this.load(false)
popErrorAlert(error.responseJSON.message)
this.validationErrors(error.responseJSON.errors)
}
postSuccessNew(response) {
this.load(false)
this.disable()
this.item.find(".invalid-feedback").remove()
this.btnSubmitNewImposicion.addClass("d-none")
popSuccessAlert(response.message)
}
postErrorNew(error) {
this.load(false)
this.validationErrors(error.responseJSON.errors)
popErrorAlert(error.responseJSON.message)
}
validationErrors(errors) {
this.item.find(".invalid-feedback").remove()
Object.entries(errors).forEach(([key, value], index) => {
let el = this.item.find(`input[name=${key}]`)
this.addError(el, value)
})
}
addError(el, error) {
el.addClass("is-invalid")
el.parent().append(`<div class="invalid-feedback">${error}</div>`)
}
}
export default ImposicionForm;

View File

@ -0,0 +1,174 @@
class ImposicionEsquemaDrawing {
constructor(domItem) {
this.item = domItem;
this.params = { fitted: true }
this.rectangleDimensions = {
width: 50,
height: 100,
}
this.rectangleCosidoDimensions = {
width: 50 * 2,
height: 100,
}
this.offsetX = this.rectangleDimensions.width + 20
this.offsetY = this.rectangleDimensions.height + 20
this.offsetCosidoX = this.rectangleCosidoDimensions.width + 20
this.offsetCosidoY = this.rectangleCosidoDimensions.height + 20
this.dw = null
if (this.item.length > 0) {
this.dw = new Two(this.params).appendTo(this.item[0])
}
this.rows = 1
this.columns = 1
this.rotativa = false
this.cosido = false
this.drawingShapes = []
this.textShapes = []
this.vectorShapes = []
this.orientation = "H"
this.drawSchema()
}
setMatrix(rows, columns) {
this.rows = rows
this.columns = columns
}
setOrientation(orientation) {
this.orientation = orientation
this.drawSchema()
}
setRotativa(rotativa) {
this.rotativa = rotativa
this.drawSchema()
}
setCosido(rotativa) {
this.cosido = rotativa
this.drawSchema()
}
setRows(rows) {
this.rows = rows
this.drawSchema()
}
setColumns(columns) {
this.columns = columns
this.drawSchema()
}
init() {
}
cutPaperForm() {
this.textShapes.forEach((element, index) => {
element.scale = new Two.Vector(1, -1)
})
}
mirror(element) {
if (this.rotativa == false) {
element.scale = new Two.Vector(1, -1)
}
}
remove() {
this.drawingShapes.forEach(element => {
element.remove()
});
this.textShapes.forEach(element => {
element.remove()
});
this.vectorShapes.forEach(element => {
element.remove()
});
}
drawRows(y = 0) {
for (let index = 0; index < this.columns; index++) {
let rectangle = this.dw.makeRectangle(this.rectangleDimensions.width / 2 + this.offsetX * index, this.rectangleDimensions.height / 2 + y, this.rectangleDimensions.width, this.rectangleDimensions.height)
let text = this.dw.makeText("A", this.rectangleDimensions.width / 2 + this.offsetX * index, this.rectangleDimensions.height / 2 + y)
if ((index + 1) % 2) {
this.mirror(text)
}
this.textShapes.push(text)
this.drawingShapes.push(rectangle)
}
}
drawRowsCosido(y = 0) {
for (let index = 0; index < this.columns; index++) {
let rectangle = this.dw.makeRectangle(this.rectangleCosidoDimensions.width / 2 + this.offsetCosidoX * index, this.rectangleCosidoDimensions.height / 2 + y, this.rectangleCosidoDimensions.width, this.rectangleCosidoDimensions.height)
let textA = this.dw.makeText("N", this.rectangleCosidoDimensions.width / 4 + this.offsetCosidoX * index, this.rectangleCosidoDimensions.height / 2 + y)
let textB = this.dw.makeText("1", this.rectangleCosidoDimensions.width * 3 / 4 + this.offsetCosidoX * index, this.rectangleCosidoDimensions.height / 2 + y)
let line = this.dw.makeLine(rectangle.position.x, y, rectangle.position.x, this.rectangleCosidoDimensions.height + y)
this.textShapes.push(textA)
this.textShapes.push(textB)
this.drawingShapes.push(rectangle)
this.drawingShapes.push(line)
}
}
drawOrientation() {
let vector;
if (this.orientation == "H") {
vector = this.dw.makeArrow(0, (this.offsetY) * this.rows, (this.offsetX) * (this.columns), (this.offsetY) * this.rows)
this.dw.renderer.setSize((this.offsetX) * this.columns, (this.offsetY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
} else {
vector = this.dw.makeArrow((this.offsetX) * this.columns, 0, (this.offsetX) * this.columns, (this.offsetY) * this.rows)
this.dw.renderer.setSize((this.offsetX) * this.columns, (this.offsetY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
}
vector.linewidth = "3px"
this.vectorShapes.push(vector)
}
drawOrientationCosido() {
let vector;
if (this.orientation == "H") {
vector = this.dw.makeArrow(-this.rectangleDimensions.width / 2, (this.offsetCosidoY) * this.rows, (this.offsetCosidoX) * (this.columns), (this.offsetCosidoY) * this.rows)
this.dw.renderer.setSize((this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
let width = (this.offsetCosidoX) * this.columns * 1.1
let height = (this.offsetCosidoY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
} else {
vector = this.dw.makeArrow((this.offsetCosidoX) * this.columns, 0, (this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
this.dw.renderer.setSize((this.offsetCosidoX) * this.columns, (this.offsetCosidoY) * this.rows)
let width = (this.offsetX) * this.columns * 1.1
let height = (this.offsetY) * this.rows * 1.1
Two.SVGRenderer.Utils.setAttributes(this.dw.renderer.domElement, { viewBox: `0 0 ${width} ${height}` })
}
vector.linewidth = "3px"
this.vectorShapes.push(vector)
}
drawSchema() {
this.remove();
for (let index = 0; index < this.rows; index++) {
if (this.cosido) {
this.drawRowsCosido(this.offsetY * index)
} else {
this.drawRows(this.offsetY * index)
}
}
if (this.cosido) {
this.drawOrientationCosido()
} else {
this.drawOrientation()
}
this.dw.update()
}
getSVG() {
if (this.dw) {
return this.dw.renderer.domElement.outerHTML
} else {
return null
}
}
}
export default ImposicionEsquemaDrawing

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.edit()
})

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion Esquema")
let imposicion = new Imposicion()
imposicion.init_imposicion_esquema_form()
})

View File

@ -0,0 +1,59 @@
import { alertConfirmationDelete } from "../../../components/alerts/sweetAlert.js"
import ImposicionDatatable from "../../../components/datatables/ImposicionDatatable.js"
import ImposicionEsquemaDatatable from "../../../components/datatables/ImposicionEsquemaDatatable.js"
import ImposicionEsquemaForm from "../../../components/forms/ImposicionEsquemaForm.js"
import ImposicionForm from "../../../components/forms/ImposicionForm.js"
class Imposicion {
constructor() {
this.itemTable = $("#tableOfImposiciones")
this.itemEsquemaTable = $("#imposicion-esquema-table")
this.itemForm = $("#form-imposicion")
this.itemEsquemaForm = $("#form-imposicion-esquema")
this.imposicionDatatable = new ImposicionDatatable(this.itemTable)
this.imposicionEsquemaDatatable = new ImposicionEsquemaDatatable(this.itemEsquemaTable)
}
view() {
this.imposicionDatatable.init()
this.imposicionEsquemaDatatable.init()
this.itemTable.on("click", ".imposicion-delete", this.deleteRow.bind(this))
this.itemEsquemaTable.on("click", ".imposicion-esquema-delete", this.deleteEsquemaRow.bind(this))
this.imposicionEsquemaForm = new ImposicionEsquemaForm(this.itemEsquemaForm)
this.imposicionForm = new ImposicionForm(this.itemForm)
}
edit() {
this.imposicionForm = new ImposicionForm(this.itemForm)
this.imposicionForm.init()
}
new() {
this.imposicionForm.initNew()
}
init_imposicion_esquema_form() {
this.imposicionEsquemaForm = new ImposicionEsquemaForm(this.itemEsquemaForm)
this.imposicionEsquemaForm.init()
}
deleteRow(event) {
let modelId = $(event.currentTarget).data("id")
alertConfirmationDelete().then((result) => {
if (result.isConfirmed) {
this.imposicionForm.handleDelete(modelId)
this.imposicionDatatable.datatable.ajax.reload()
}
})
}
deleteEsquemaRow(event) {
let modelId = $(event.currentTarget).data("id")
alertConfirmationDelete().then((result) => {
if (result.isConfirmed) {
this.imposicionEsquemaForm.handleDelete(modelId)
this.imposicionEsquemaDatatable.datatable.ajax.reload()
}
})
}
}
export default Imposicion

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.new()
})

View File

@ -0,0 +1,8 @@
import Imposicion from "./imposicion.js"
$(() => {
console.log("Imposicion")
let imposicion = new Imposicion()
imposicion.view()
})

View File

@ -1,5 +1,4 @@
$(() => {
console.log("PDF")
var opt = {
margin: 2,
filename: "PDF_OrdenTrabajo_" + $(".pdf-wrapper").data("id") + ".pdf",
@ -7,6 +6,6 @@ $(() => {
html2canvas: { scale: 4 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
let elementToPdf = $('body')[0]
let elementToPdf = $('body')[0]
html2pdf().set(opt).from(elementToPdf).save()
})

View File

@ -26,7 +26,7 @@ class DisenioCubierta {
this.divPapelEspecial = this.domItem.find("#divPapelEspecialCubierta");
this.papelEspecial = new ClassSelect($("#papelEspecialCubiertaSel"),
'/papelesgenericos/selectpapelespecial',
'/configuracion/papelesgenericos/selectpapelespecial',
window.translations["selectPapel"],
false,
{
@ -59,7 +59,7 @@ class DisenioCubierta {
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
this.papelGuardas = new ClassSelect($("#papelGuardas"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
@ -77,7 +77,7 @@ class DisenioCubierta {
true,
);
this.gramajeGuardas = new ClassSelect($("#gramajeGuardas"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectGramaje"],
false,
{
@ -106,7 +106,7 @@ class DisenioCubierta {
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
this.sobrecubierta = this.domItem.find("#addSobrecubierta");
this.papelSobrecubierta = new ClassSelect($("#papelSobrecubierta"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
@ -124,7 +124,7 @@ class DisenioCubierta {
true,
);
this.gramajeSobrecubierta = new ClassSelect($("#gramajeSobrecubierta"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
@ -147,7 +147,7 @@ class DisenioCubierta {
this.configuracionFaja = this.domItem.find(".config-faja");
this.faja = this.domItem.find("#addFaja");
this.papelFaja = new ClassSelect($("#papelFaja"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectPapel"],
false,
{
@ -165,7 +165,7 @@ class DisenioCubierta {
true,
);
this.gramajeFaja = new ClassSelect($("#gramajeFaja"),
'/papelesgenericos/getpapelcliente',
'/configuracion/papelesgenericos/getpapelcliente',
window.translations["selectGramaje"],
false,
{
@ -988,7 +988,7 @@ class DisenioCubierta {
this.divGramajeCubierta.empty();
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tipo: 'colorhq',
@ -1014,7 +1014,7 @@ class DisenioCubierta {
this.papelCubierta = this.papelEspecial.getVal();
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
papel: this.papelCubierta,
@ -1146,7 +1146,7 @@ class DisenioCubierta {
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
this.divGramajeCubierta.empty();
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
papel: papel,

View File

@ -51,7 +51,7 @@ class DisenioInterior {
this.rl_papel_interior_color = $("#rl_papel_interior_color");
this.papelEspecial = new ClassSelect($("#papelEspecialInterior"),
'/papelesgenericos/selectpapelespecial',
'/configuracion/papelesgenericos/selectpapelespecial',
window.translations["selectPapel"],
false,
{
@ -66,7 +66,7 @@ class DisenioInterior {
}
);
this.papelEspecialColor = new ClassSelect($("#papelEspecialInteriorColor"),
'/papelesgenericos/selectpapelespecial',
'/configuracion/papelesgenericos/selectpapelespecial',
window.translations["selectPapel"],
false,
{
@ -121,7 +121,7 @@ class DisenioInterior {
if (papeles == 'color') {
this.divGramajeInteriorColor.empty();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),
@ -140,7 +140,7 @@ class DisenioInterior {
if (papeles == 'negro' || papeles == null) {
this.divGramajeInterior.empty();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),
@ -900,7 +900,7 @@ class DisenioInterior {
this.divPapelEspecialInterior.addClass("d-none");
this.papelEspecialInterior.empty();
this.divGramajeInterior.empty();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),
@ -932,7 +932,7 @@ class DisenioInterior {
let tipo = this.getTipoImpresion();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),
@ -982,7 +982,7 @@ class DisenioInterior {
this.divPapelEspecialInteriorColor.addClass("d-none");
this.divPapelEspecialInteriorColor.empty();
this.divGramajeInteriorColor.empty();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),
@ -1010,7 +1010,7 @@ class DisenioInterior {
let tipo = this.getTipoImpresionColor();
new Ajax('/papelesgenericos/getpapelcliente',
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
{
[this.csrf_token]: this.csrf_hash,
tirada: $('#tirada').val(),

View File

@ -16,6 +16,9 @@ class OrdenTrabajo {
this.tareaCommentModal = new Modal($("#modalCommentTarea"))
this.alertOrdenTrabajo = this.item.find("#alert-orden-trabajo");
this.btnFinalizarPedido = this.item.find("#btn-finalizar-orden-pedido")
this.btnReactivarOt = this.item.find("#btn-reactivar-orden-pedido")
this.isOtFinalizada = false;
this.btnResetTareas = this.item.find("#btn-reset-tareas")
this.pedidoEnEsperaCheck = this.item.find("#ot-pedido-espera");
this.pedidoEnEsperaBy = this.item.find("#pedido_espera_by");
@ -140,6 +143,8 @@ class OrdenTrabajo {
this.otForm.on("click", "#btn-upload-portada", this.handleUploadPortada.bind(this))
this.otForm.on("click", "#btn-delete-portada", this.handleDeletePortada.bind(this))
this.btnFinalizarPedido.on("click", this.handleFinalizarPedido.bind(this))
this.btnReactivarOt.on("click", this.handleReactivarPedido.bind(this))
this.tareasTableItem.on("click", ".ot-tarea-btn-delete", this.handleTareaDeleteConfirmation.bind(this))
this.item.on("click", "#btn-reset-tareas", this.handleResetTareasDeleteConfirmation.bind(this))
this.otForm.on("click", ".ot-tarea-comment", this.handleNoteTarea.bind(this))
@ -190,14 +195,14 @@ class OrdenTrabajo {
}
_renderMaquinaSelectTable(d, t) {
this.tareasId.push(d.id)
return `<select id="select-maquina-tarea-${d.id}" data-maquina-id="${d.maquina_id}" data-id="${d.id}" name="maquina_id" class="select2 form-select select-maquina-tarea-datatable ${d.maquina_id ? '' : 'is-invalid'}">
return `<select id="select-maquina-tarea-${d.id}" data-maquina-id="${d.maquina_id}" data-id="${d.id}" name="maquina_id" class="select2 form-select select-maquina-tarea-datatable ${d.maquina_id ? '' : 'is-invalid'}" ${this.isOtFinalizada ? "disabled" : ""}>
<option value="${d.maquina_id}" selected="selected">${d.maquina_name ?? ''}</option>
</select>`
}
_renderImposicionSelectTable(d, t) {
let render = `<select id="select-imposicion-tarea-${d.id}" data-imposicion-id="${d.imposicion_id}" data-id="${d.id}" name="imposicion_id" class="select2 form-select select-imposicion-tarea-datatable ${d.imposicion_id ? '' : 'is-invalid'}">
let render = `<select id="select-imposicion-tarea-${d.id}" data-imposicion-id="${d.imposicion_id}" data-id="${d.id}" name="imposicion_id" class="select2 form-select select-imposicion-tarea-datatable ${d.imposicion_id ? '' : 'is-invalid'}" ${this.isOtFinalizada ? "disabled" : ""}>
<option value="${d.imposicion_id}" selected="selected">${d.name ?? ''}</option>
</select>`
return render
@ -206,8 +211,10 @@ class OrdenTrabajo {
_renderActionCell(d, t) {
let cell = `<div class="d-flex justify-content-start align-items-center gap-1">
<a type="button" class="btn btn-xs ot-tarea-comment" data-id="${d.id}"><i class="ti ti-${d.comment ? "message" : "note"} ti-sm mx-2"></i></a>
<a type="button" class="btn btn-xs ot-tarea-btn-delete" data-id="${d.id}"><i class="ti ti-trash ti-sm mx-2"></i></a>
<a type="button" class="btn btn-xs ot-tarea-comment" data-id="${d.id}">
<i class="ti ti-${d.comment ? "message" : "note"} ti-sm mx-2"></i>
</a>
<a type="button" class="btn btn-xs ot-tarea-btn-delete" data-id="${d.id}"><i class="ti ti-trash ti-sm mx-2 ${this.isOtFinalizada ? "d-none" : ""}" ></i></a>
</div>`
return cell;
}
@ -215,7 +222,7 @@ class OrdenTrabajo {
return `
<div class="d-flex justify-content-between aling-items-center gap-2 orden-tarea-cell">
<input type="text" style="min-width:5rem" data-id="${d.id}" class="form-control form-control-sm orden-tarea mr-2" name="orden" value="${d.orden}">
<input type="text" style="min-width:5rem" data-id="${d.id}" class="form-control form-control-sm orden-tarea mr-2" name="orden" value="${d.orden}" ${this.isOtFinalizada ? "disabled" : ""}>
<div class="btn-group-vertical">
<button type="button" class="btn btn-primary btn-outlined btn-xs increase-order"><i class="ti ti-chevron-up ti-xs"></i></button>
<button type="button" class="btn btn-primary btn-xs decrease-order" data-id="${d.id}"><i class="ti ti-chevron-down ti-xs"></i></button>
@ -351,6 +358,7 @@ class OrdenTrabajo {
this.fillOtDetails()
this.fillOtDates()
this.fillPreimpresionReview()
this.isOtFinalizada = this.summaryData.ot.estado == "F";
this.datatableTareas.ajax.reload()
} catch (error) {
console.error(error)
@ -649,7 +657,7 @@ class OrdenTrabajo {
this.handleEstadoChangeSuccess.bind(this),
this.handleEstadoChangeError.bind(this)
);
alertConfirmAction("Esta acción marcará la orden de trabjao como FINALIZADA")
alertConfirmAction("Esta acción marcará la orden de trabajo como FINALIZADA")
.then(result => {
if (result.isConfirmed) {
ajax.post()
@ -660,8 +668,28 @@ class OrdenTrabajo {
popSuccessAlert(response.message)
this.alertOrdenTrabajo.removeClass("alert-info").addClass("alert-success")
this.btnFinalizarPedido.prop("disabled", true);
window.location.reload();
}
handleEstadoChangeError() { }
handleReactivarPedido() {
const ajax = new Ajax(
"/produccion/ordentrabajo/update",
{
orden_trabajo_id: this.modelId,
estado: 'I'
},
null,
this.handleEstadoChangeSuccess.bind(this),
this.handleEstadoChangeError.bind(this)
);
alertConfirmAction("Esta acción reactivará la orden de trabajo.")
.then(result => {
if (result.isConfirmed) {
ajax.post()
}
})
}
handleTareaDeleteConfirmation(event) {
const orden_tarea_id = $(event.currentTarget).data("id")
alertConfirmationDelete("¿Estás seguro de realizar esta acción?")

View File

@ -39,14 +39,11 @@ body{
align-content : center;
justify-content: center;
font-weight: bold;
font-size : 20px;
font-size : 14px;
}
.esquema{
display: flex;
justify-content:center;
width: 100%;
justify-items: center;
}
.pagina-imposicion-outer-start{
@ -89,10 +86,7 @@ body{
}
.esquema-imposicion-wrapper{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.imposicion{
display: flex;
@ -173,10 +167,11 @@ table td{
color: white;
}
.cmyk{
background-image: url('/themes/vuexy/img/safekat/presupuestos/cmyk.png')
background-image: url('/themes/vuexy/img/safekat/presupuestos/cmyk.png');
background-size: 110px;
text-shadow: 0px 0px 1px black;
stroke:black;
color : white;
text-shadow: 0px 0px 2px black;
stroke:white;
}
.bn{
background : black;