* Copyright (c) 2021-Present XiHanFun and contributors.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*/
import type { DataRow, DatasetSchema } from '@xihan-report/core'
export const salesDataset: DatasetSchema = {
id: 'sales',
title: '销售订单',
fields: [
{ name: 'orderId', type: 'string', title: '订单号' },
{ name: 'date', type: 'date', title: '日期' },
{ name: 'region', type: 'string', title: '区域' },
{ name: 'category', type: 'string', title: '品类' },
{ name: 'channel', type: 'string', title: '渠道' },
{ name: 'quantity', type: 'number', title: '数量' },
{ name: 'amount', type: 'number', title: '金额' },
],
}
const REGIONS = ['华东', '华北', '华南']
const CATEGORIES = ['办公用品', '电子产品']
const CHANNELS = ['线上', '门店']
function buildRows(): DataRow[] {
const rows: DataRow[] = []
for (let month = 1; month <= 6; month++) {
REGIONS.forEach((region, r) => {
CATEGORIES.forEach((category, c) => {
CHANNELS.forEach((channel, h) => {
const quantity = 10 + ((month * 7 + r * 5 + c * 3 + h * 2) % 23)
const price = c === 0 ? 18 : 260
rows.push({
orderId: `SO-2026${String(month).padStart(2, '0')}-${String(rows.length + 1).padStart(3, '0')}`,
date: `2026-${String(month).padStart(2, '0')}-${String(3 + r * 7 + h * 3).padStart(2, '0')}`,
region,
category,
channel,
quantity,
amount: quantity * price,
})
})
})
})
}
return rows
}
export const salesRows: readonly DataRow[] = buildRows()