second commit

This commit is contained in:
Guillermo Bonet 2022-10-04 13:06:59 +02:00
parent 23726b6e60
commit 2c7cce4b36
5 changed files with 25 additions and 88 deletions

View File

@ -4,37 +4,36 @@
<table class="grid"> <table class="grid">
<tbody> <tbody>
<tr> <tr>
<td rowspan="6"><span class="vertical">{{levelV}}</span></td> <td rowspan="6"><span class="vertical">{{tags.levelV}}</span></td>
<td id="right">{{ticketFk}}</td> <td id="right">{{tags.ticketFk}}</td>
<td>/</td> <td>/</td>
<td id="left">{{clientFk}}</td> <td id="left">{{tags.clientFk}}</td>
<td colspan="2">{{shipped}}</td> <td colspan="2">{{tags.shipped}}</td>
</tr> </tr>
<tr> <tr>
<td colspan="3" rowspan="3" class="center">{{barcode}}</td> <td colspan="3" rowspan="3" class="center"><img v-bind:src="barcode"/></td>
<td></td> <td></td>
<td class="outline">{{workerCode}}</td> <td class="outline">{{tags.workerCode}}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td class="outline">{{labelCount}}</td> <td class="outline">{{tags.labelCount}}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td class="outline">{{packingTypeFk}}</td> <td class="outline">{{tags.itemPackingTypeFk}}</td>
</tr> </tr>
<tr> <tr>
<td colspan="3" id="agencyDescripton" class="center">{{agencyDescripton}}</span></td> <td colspan="3" id="agencyDescripton" class="center">{{tags.agencyDescripton}}</span></td>
<td></td> <td></td>
<td id="bold">{{lineCount}}</td> <td id="bold">{{tags.lineCount}}</td>
</tr> </tr>
<tr> <tr>
<td colspan="3" id="nickname" class="center">{{nickname}}</td> <td colspan="3" id="nickname" class="center">{{tags.nickname}}</td>
<td></td> <td></td>
<td id="bold">{{agencyHour}}</td> <td id="bold">{{tags.agencyHour}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </html>

View File

@ -6,45 +6,27 @@ const qrcode = require('qrcode');
module.exports = { module.exports = {
name: 'collection-label', name: 'collection-label',
async serverPrefetch() { async serverPrefetch() {
this.collectionTicket = await this.fetchItem(this.collectionTicketId); this.isCollection = await this.isCollection(this.param);
this.tags = await this.fetchItemTags(this.collectionTicketId); this.tags = await this.fetchCollectionTicket(this.isCollection, this.param, this.param);
this.barcode = await this.getBarcodeBase64(this.collectionTicketId); this.barcode = await this.getBarcodeBase64(this.param);
if (!this.collectionTicket) if (!this.tags)
throw new Error('Something went wrong'); 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: { methods: {
fetchItem(id, warehouseId) { isCollection(param) {
return this.findOneFromDef('item', [id, warehouseId]); return this.findOneFromDef('isCollection', [param]);
}, },
fetchItemTags(itemId) { fetchCollectionTicket(isCollection, param, param) {
return this.rawSqlFromDef('itemTags', [itemId]).then(rows => { return this.rawSqlFromDef('collectionTicket', [isCollection, param, param]).then(rows => {
const tags = {}; const tags = {};
rows.forEach(row => tags[row.code] = row.value); rows.forEach(row => tags[row.code] = row.value);
return tags; return tags;
}); });
}, },
getBarcodeBase64(itemId) { getBarcodeBase64(param) {
return qrcode.toDataURL(itemId, {margin: 0}); return qrcode.toDataURL(param, {margin: 0});
},
packing() {
const stems = this.item.stems ? this.item.stems : 1;
return `${this.item.packing}x${stems}`;
} }
}, },
components: { components: {
@ -52,17 +34,8 @@ module.exports = {
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
}, },
props: { props: {
itemId: { param: {
required: true required: true
},
warehouseId: {
required: true
},
labelNumber: {
type: String
},
totalLabels: {
type: String
} }
} }
}; };

View File

@ -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)), '') 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`;