test stat
This commit is contained in:
parent
3e1a205162
commit
68a4791032
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
headers: {
|
||||
type: Array as () => string[],
|
||||
required: true,
|
||||
|
@ -12,7 +12,6 @@ defineProps({
|
|||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table class="min-w-full border-collapse mt-4 bg-white shadow rounded-lg overflow-hidden">
|
||||
<thead class="bg-gray-100 text-left">
|
||||
|
@ -23,8 +22,19 @@ defineProps({
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, rowIndex) in rows" :key="rowIndex" class="hover:bg-gray-50">
|
||||
<td v-for="(cell, cellIndex) in row" :key="cellIndex" class="px-4 py-2 border-b">
|
||||
<tr
|
||||
v-for="(row, rowIndex) in rows"
|
||||
:key="rowIndex"
|
||||
:class="[
|
||||
'hover:bg-gray-50',
|
||||
row.isSubRow ? 'text-xs bg-gray-100' : '' // Применяем text-xs только для подстрок
|
||||
]"
|
||||
>
|
||||
<td
|
||||
v-for="(cell, cellIndex) in row"
|
||||
:key="cellIndex"
|
||||
class="px-4 py-2 border-b"
|
||||
>
|
||||
{{ cell }}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -5,10 +5,8 @@ const props = defineProps({
|
|||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
function generateTableData(data, config, showDetails = true) {
|
||||
const headers = config.map(c => c.label)
|
||||
|
||||
const rows = []
|
||||
|
||||
for (const key in data) {
|
||||
|
@ -35,29 +33,46 @@ function generateTableData(data, config, showDetails = true) {
|
|||
return ''
|
||||
})
|
||||
|
||||
rows.push(mainRow)
|
||||
// Добавляем флаг isSubRow: false для основной строки
|
||||
mainRow.isSubRow = false
|
||||
|
||||
// Подстроки (если нужно)
|
||||
if (entries.length > 1 && showDetails) {
|
||||
if (entries.length > 1) {
|
||||
rows.push(mainRow)
|
||||
}
|
||||
|
||||
// Подстроки
|
||||
if (showDetails) {
|
||||
let subRowIndex = 0
|
||||
for (const entry of entries) {
|
||||
const isOnlyOne = entries.length === 1
|
||||
const isFirst = subRowIndex === 0
|
||||
|
||||
const subRow = config.map(c => {
|
||||
if (c.key === 'key') return ''
|
||||
if (c.key === 'count') return 1
|
||||
if (c.key === 'key') {
|
||||
return isOnlyOne ? key : '-'
|
||||
}
|
||||
if (c.key === 'count') {
|
||||
return 1
|
||||
}
|
||||
const value = entry[c.key]
|
||||
if (typeof value === 'number') {
|
||||
return value.toFixed(c.precision ?? 6)
|
||||
}
|
||||
return value ?? '-'
|
||||
})
|
||||
|
||||
// Добавляем служебные метки в подстроку
|
||||
subRow.isSubRow = isOnlyOne ? false : true
|
||||
subRow.isFirstSubRow = isFirst
|
||||
subRow.indexSubRow = subRowIndex++
|
||||
subRow.parentKey = key
|
||||
|
||||
rows.push(subRow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
headers,
|
||||
rows
|
||||
}
|
||||
return { headers, rows }
|
||||
}
|
||||
const standardTableData = computed(() => {
|
||||
const standard = props.statsData?.Standard || {}
|
||||
|
@ -73,7 +88,6 @@ const weldTableData = computed(() => {
|
|||
return generateTableData(weld, [
|
||||
{ key: 'key', label: 'Сварка' },
|
||||
{ key: 'count', label: 'Элементов' },
|
||||
{ key: 'dummy', label: '-' }, // пустая колонка
|
||||
{ key: 'length', label: 'Длина шва', total: true, precision: 6 }
|
||||
])
|
||||
})
|
||||
|
@ -85,6 +99,7 @@ const sheetTableData = computed(() => {
|
|||
{ key: 'count', label: 'Количество' },
|
||||
{ key: 'name', label: 'Имя детали' },
|
||||
{ key: 'radius', label: 'Радиус гиба', precision: 1 },
|
||||
// { key: 'folds', label: 'Количество гибов', precision: 0 },
|
||||
{ key: 'area', label: 'Площадь (м²)', total: true, precision: 6 },
|
||||
{ key: 'mass', label: 'Масса (кг)', total: true, precision: 6 }
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue