This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
destination_plates.vue
90 lines (85 loc) · 2.18 KB
/
destination_plates.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
<b-container>
<b-row>
<b-col>
<PrintLabelsRouter />
<h1>Print destination plate labels</h1>
<p class="lead"></p>
<StatusAlert ref="statusAlert" />
<p>
<label for="selectPrinter">Which printer would you like to use?</label>
<b-form-select id="selectPrinter" v-model="printer" :options="printers"></b-form-select>
</p>
<p>
<label for="numberOfBarcodes">How may labels would you like to print?</label>
<b-form-input
id="numberOfBarcodes"
v-model="numberOfBarcodes"
type="number"
value="1"
min="1"
></b-form-input>
</p>
<p class="text-right">
<b-button
id="printLabels"
block
size="lg"
variant="success"
:disabled="isBusy"
@click="printLabels"
>
Print labels
<b-spinner v-show="isBusy" small></b-spinner>
</b-button>
</p>
</b-col>
</b-row>
</b-container>
</template>
<script>
import Sprint from '@/modules/sprint_general_labels'
import config from '@/nuxt.config'
import PrintLabelsRouter from '@/components/PrintLabelsRouter'
import StatusAlert from '@/components/StatusAlert'
export default {
components: {
PrintLabelsRouter,
StatusAlert,
},
props: {
printers: {
type: Array,
default() {
return config.publicRuntimeConfig.printers.split(',')
},
},
},
data() {
return {
printer: this.printers[0],
numberOfBarcodes: '1',
}
},
computed: {
isBusy() {
return this.$refs.statusAlert?.isBusy
},
},
methods: {
async printLabels() {
this.$refs.statusAlert.setStatus('Busy', 'Printing labels…')
const response = await Sprint.printDestinationPlateLabels({
numberOfBarcodes: this.numberOfBarcodes,
printer: this.printer,
})
if (response.success) {
this.$refs.statusAlert.setStatus('Success', response.message)
} else {
this.$refs.statusAlert.setStatus('Error', response.error)
}
},
},
}
</script>
<style></style>