mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
imposiciones
This commit is contained in:
@ -0,0 +1,66 @@
|
||||
|
||||
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: '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: '_all' },
|
||||
],
|
||||
serverSide: true,
|
||||
pageLength: 25,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableColumns,
|
||||
ajax: '/imposiciones/datatable',
|
||||
});
|
||||
}
|
||||
initEsquema() {
|
||||
this.datatableEsquema = this.item.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
columnDefs: [
|
||||
{ className: 'dt-center', targets: '_all' },
|
||||
],
|
||||
serverSide: true,
|
||||
pageLength: 25,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: this.datatableEsquemaColumns,
|
||||
ajax: '/imposiciones/esquema/datatable',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default ImposicionDatatable;
|
||||
@ -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;
|
||||
@ -0,0 +1,179 @@
|
||||
import Ajax from '../ajax.js'
|
||||
import ImposicionEsquemaDrawing from '../imposicionEsquemaDrawing.js';
|
||||
|
||||
class ImposicionEsquemaForm {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.drawing = new ImposicionEsquemaDrawing($("#imposicion-esquema-drawing"))
|
||||
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() {
|
||||
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")
|
||||
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;
|
||||
195
httpdocs/assets/js/safekat/components/forms/ImposicionForm.js
Normal file
195
httpdocs/assets/js/safekat/components/forms/ImposicionForm.js
Normal 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;
|
||||
@ -0,0 +1,164 @@
|
||||
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 = 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() {
|
||||
return this.dw.renderer.domElement.outerHTML
|
||||
}
|
||||
}
|
||||
|
||||
export default ImposicionEsquemaDrawing
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import Imposicion from "./imposicion.js"
|
||||
|
||||
$(() => {
|
||||
console.log("Imposicion")
|
||||
let imposicion = new Imposicion()
|
||||
imposicion.edit()
|
||||
})
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import Imposicion from "./imposicion.js"
|
||||
|
||||
$(() => {
|
||||
console.log("Imposicion Esquema")
|
||||
let imposicion = new Imposicion()
|
||||
imposicion.init_imposicion_esquema_form()
|
||||
})
|
||||
@ -0,0 +1,56 @@
|
||||
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))
|
||||
|
||||
}
|
||||
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.datatableEsquema.ajax.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default Imposicion
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import Imposicion from "./imposicion.js"
|
||||
|
||||
$(() => {
|
||||
console.log("Imposicion")
|
||||
let imposicion = new Imposicion()
|
||||
imposicion.new()
|
||||
})
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import Imposicion from "./imposicion.js"
|
||||
|
||||
$(() => {
|
||||
console.log("Imposicion")
|
||||
let imposicion = new Imposicion()
|
||||
imposicion.view()
|
||||
})
|
||||
@ -6,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()
|
||||
})
|
||||
Reference in New Issue
Block a user