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