mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 18:21:50 +08:00
Fix label preview double refresh and unit issues [SCI-7396]
This commit is contained in:
parent
c7ee068893
commit
31b075ea8c
2 changed files with 11 additions and 10 deletions
|
@ -101,7 +101,7 @@
|
|||
DPMM_RESOLUTION_OPTIONS,
|
||||
DPI_RESOLUTION_OPTIONS,
|
||||
optionsOpen: false,
|
||||
width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm ,
|
||||
width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm,
|
||||
height: this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm,
|
||||
unit: this.template.attributes.unit,
|
||||
density: this.template.attributes.density,
|
||||
|
@ -125,19 +125,16 @@
|
|||
},
|
||||
watch: {
|
||||
unit() {
|
||||
this.recalculateUnits();
|
||||
this.setDefaults();
|
||||
},
|
||||
zpl() {
|
||||
this.refreshPreview();
|
||||
},
|
||||
template() {
|
||||
this.unit = this.template.attributes.unit
|
||||
this.width = this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm
|
||||
this.height = this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm
|
||||
this.unit = this.template.attributes.unit
|
||||
this.density = this.template.attributes.density
|
||||
|
||||
this.refreshPreview()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -159,6 +156,8 @@
|
|||
refreshPreview() {
|
||||
if (this.zpl.length === 0) return;
|
||||
|
||||
this.base64Image = null;
|
||||
|
||||
$.ajax({
|
||||
url: this.previewUrl,
|
||||
type: 'GET',
|
||||
|
@ -184,7 +183,9 @@
|
|||
});
|
||||
},
|
||||
updateUnit(unit) {
|
||||
if (this.unit === unit) return;
|
||||
this.unit = unit;
|
||||
this.recalculateUnits();
|
||||
this.$emit('unit:update', this.unit);
|
||||
},
|
||||
updateDensity(density) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div ref="modal" class="modal fade" id="modal-print-repository-row-label" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div v-if="printers_dropdown.length > 0" class="printers-available">
|
||||
<div v-if="availablePrinters.length > 0" class="printers-available">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<p class="modal-title">
|
||||
|
@ -24,7 +24,7 @@
|
|||
</label>
|
||||
<DropdownSelector
|
||||
:disableSearch="true"
|
||||
:options="printers_dropdown"
|
||||
:options="availablePrinters"
|
||||
:selectorId="`LabelPrinterSelector`"
|
||||
@dropdown:changed="selectPrinter"
|
||||
/>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<DropdownSelector
|
||||
ref="labelTemplateDropdown"
|
||||
:disableSearch="true"
|
||||
:options="templates_dropdown"
|
||||
:options="availableTemplates"
|
||||
:selectorId="`LabelTemplateSelector`"
|
||||
:optionLabel="templateOption"
|
||||
:onOpen="initTooltip"
|
||||
|
@ -138,7 +138,7 @@
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
templates_dropdown() {
|
||||
availableTemplates() {
|
||||
let templates = this.templates;
|
||||
if (this.selectedPrinter && this.selectedPrinter.attributes.type_of === 'zebra') {
|
||||
templates = templates.filter(i => i.attributes.type === 'ZebraLabelTemplate')
|
||||
|
@ -155,7 +155,7 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
printers_dropdown() {
|
||||
availablePrinters() {
|
||||
return this.printers.map(i => {
|
||||
return {
|
||||
value: i.id,
|
||||
|
|
Loading…
Reference in a new issue