7729-devToTest_2430 #2739
|
@ -7,7 +7,7 @@ module.exports = {
|
|||
name: 'buy-label',
|
||||
mixins: [vnReport],
|
||||
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));
|
||||
const date = new Date();
|
||||
this.weekNum = moment(date).isoWeek();
|
||||
|
|
|
@ -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.`size`,
|
||||
i.category,
|
||||
|
@ -15,4 +26,6 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
|
|||
LEFT JOIN producer p ON p.id = i.producerFk
|
||||
LEFT JOIN ink ON ink.id = i.inkFk
|
||||
LEFT JOIN origin o ON o.id = i.originFk
|
||||
WHERE b.entryFk = ?
|
||||
JOIN numbers num
|
||||
WHERE b.entryFk = ?
|
||||
AND num.n <= b.stickers
|
Loading…
Reference in New Issue