diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html index 370674f16..2ab6a3009 100644 --- a/print/templates/reports/collection-label/collection-label.html +++ b/print/templates/reports/collection-label/collection-label.html @@ -4,37 +4,36 @@ - - + + - - + + - + - + - + - + - + - + - + - +
{{levelV}}{{tags.levelV}} /{{clientFk}}{{shipped}}{{tags.clientFk}}{{tags.shipped}}
{{barcode}} {{workerCode}}{{tags.workerCode}}
{{labelCount}}{{tags.labelCount}}
{{packingTypeFk}}{{tags.itemPackingTypeFk}}
{{agencyDescripton}}{{tags.agencyDescripton}} {{lineCount}}{{tags.lineCount}}
{{nickname}}{{tags.nickname}} {{agencyHour}}{{tags.agencyHour}}
- - + \ No newline at end of file diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js index 189f0d553..773824c5f 100644 --- a/print/templates/reports/collection-label/collection-label.js +++ b/print/templates/reports/collection-label/collection-label.js @@ -6,45 +6,27 @@ const qrcode = require('qrcode'); module.exports = { name: 'collection-label', async serverPrefetch() { - this.collectionTicket = await this.fetchItem(this.collectionTicketId); - this.tags = await this.fetchItemTags(this.collectionTicketId); - this.barcode = await this.getBarcodeBase64(this.collectionTicketId); + this.isCollection = await this.isCollection(this.param); + this.tags = await this.fetchCollectionTicket(this.isCollection, this.param, this.param); + this.barcode = await this.getBarcodeBase64(this.param); - if (!this.collectionTicket) + if (!this.tags) throw new Error('Something went wrong'); }, - - computed: { - dated() { - const filters = this.$options.filters; - - return filters.date(new Date(), '%W/%d'); - }, - labelPage() { - const labelNumber = this.labelNumber ? this.labelNumber : 1; - const totalLabels = this.totalLabels ? this.totalLabels : 1; - - return `${labelNumber}/${totalLabels}`; - } - }, methods: { - fetchItem(id, warehouseId) { - return this.findOneFromDef('item', [id, warehouseId]); + isCollection(param) { + return this.findOneFromDef('isCollection', [param]); }, - fetchItemTags(itemId) { - return this.rawSqlFromDef('itemTags', [itemId]).then(rows => { + fetchCollectionTicket(isCollection, param, param) { + return this.rawSqlFromDef('collectionTicket', [isCollection, param, param]).then(rows => { const tags = {}; rows.forEach(row => tags[row.code] = row.value); return tags; }); }, - getBarcodeBase64(itemId) { - return qrcode.toDataURL(itemId, {margin: 0}); - }, - packing() { - const stems = this.item.stems ? this.item.stems : 1; - return `${this.item.packing}x${stems}`; + getBarcodeBase64(param) { + return qrcode.toDataURL(param, {margin: 0}); } }, components: { @@ -52,17 +34,8 @@ module.exports = { 'report-footer': reportFooter.build() }, props: { - itemId: { + param: { required: true - }, - warehouseId: { - required: true - }, - labelNumber: { - type: String - }, - totalLabels: { - type: String } } -}; +}; \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/collection copy.sql b/print/templates/reports/collection-label/sql/collection copy.sql deleted file mode 100644 index 96a2bdf43..000000000 --- a/print/templates/reports/collection-label/sql/collection copy.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT c.itemPackingTypeFk, - CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, - CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV, - tc.ticketFk, - LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription, - am.name, - t.clientFk, - CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , - CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size, - w.code workerCode, - tt.labelCount, - IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) agencyHour, - t.shipped, - COUNT(*) lineCount, - t.nickName - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.collection c ON c.id = tc.collectionFk - LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level` - AND cc.wagon = tc.wagon - AND cc.trainFk = c.trainFk - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.worker w ON w.id = c.workerFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id - LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id - LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk - WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) - GROUP BY t.id - ORDER BY cc.`code`; \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/collection.sql b/print/templates/reports/collection-label/sql/collectionTicket.sql similarity index 100% rename from print/templates/reports/collection-label/sql/collection.sql rename to print/templates/reports/collection-label/sql/collectionTicket.sql diff --git a/print/templates/reports/collection-label/sql/collectionOrTicket.sql b/print/templates/reports/collection-label/sql/isCollection.sql similarity index 100% rename from print/templates/reports/collection-label/sql/collectionOrTicket.sql rename to print/templates/reports/collection-label/sql/isCollection.sql