feat(salix): refs #7648 #7648 buyLabels

This commit is contained in:
Javier Segarra 2024-07-16 12:45:31 +02:00
parent 6856ab0501
commit 8fe94772f3
4 changed files with 20 additions and 5 deletions

View File

@ -29,7 +29,8 @@ module.exports = Self => {
http: { http: {
path: '/:id/buy-label', path: '/:id/buy-label',
verb: 'GET' verb: 'GET'
} },
accessScopes: ['DEFAULT', 'read:multimedia']
}); });
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');

View File

@ -59,7 +59,7 @@
<tr> <tr>
<td colspan="3" class="barcode"> <td colspan="3" class="barcode">
<div v-html="getBarcode(buy.id)"></div> <div v-html="getBarcode(buy.id)"></div>
<span>{{buy.id}}</span> <span>{{buy.itemFk}}</span>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -7,7 +7,7 @@ module.exports = {
name: 'buy-label', name: 'buy-label',
mixins: [vnReport], mixins: [vnReport],
async serverPrefetch() { async serverPrefetch() {
this.buys = await this.rawSqlFromDef('buys', [this.id]); this.buys = await this.rawSqlFromDef('buys', [this.id, this.id]);
this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum));
const date = new Date(); const date = new Date();
this.weekNum = moment(date).isoWeek(); this.weekNum = moment(date).isoWeek();

View File

@ -1,4 +1,15 @@
SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, WITH RECURSIVE numbers AS (
SELECT 1 n
UNION ALL
SELECT n + 1
FROM numbers
WHERE n < (
SELECT MAX(stickers)
FROM buy
WHERE entryFk = ?
)
)
SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum,
i.name, i.name,
i.`size`, i.`size`,
i.category, i.category,
@ -8,10 +19,13 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
b.`grouping`, b.`grouping`,
i.stems, i.stems,
b.id, b.id,
b.itemFk,
p.name producer p.name producer
FROM buy b FROM buy b
JOIN item i ON i.id = b.itemFk JOIN item i ON i.id = b.itemFk
LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN producer p ON p.id = i.producerFk
LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
WHERE b.entryFk = ? JOIN numbers num
WHERE b.entryFk = ?
AND num.n <= b.stickers