Feature: 纸管重量计算
This commit is contained in:
@ -1,11 +1,141 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="calculator-container">
|
||||
<v-row>
|
||||
<!-- 参数输入区域 -->
|
||||
<v-col
|
||||
cols="12"
|
||||
lg="6"
|
||||
md="6"
|
||||
>
|
||||
<v-card
|
||||
class="pa-6 parameter-card"
|
||||
elevation="8"
|
||||
rounded="xl"
|
||||
>
|
||||
<v-card-title class="text-h5 mb-6 d-flex align-center">
|
||||
<v-icon
|
||||
class="mr-3"
|
||||
color="primary"
|
||||
icon="mdi-tune"
|
||||
size="large"
|
||||
/>
|
||||
{{ $t('parameters') }}
|
||||
</v-card-title>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
v-model="paperRollLength"
|
||||
:label="`${$t('paperRollLength')}(${paperRollLength.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
v-model="paperDensity"
|
||||
:label="`${$t('paperDensity')}(${paperDensity.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
v-model="productionAmount"
|
||||
:label="`${$t('productionAmount')}(${productionAmount.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
v-model="paperCoreDiameter"
|
||||
:label="`${$t('paperCoreDiameter')}(${paperCoreDiameter.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
v-model="paperRollWallThickness"
|
||||
:label="`${$t('paperRollWallThickness')}(${paperRollWallThickness.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-divider class="my-6" />
|
||||
|
||||
<v-row>
|
||||
<v-btn
|
||||
block
|
||||
color="warning"
|
||||
prepend-icon="mdi-refresh"
|
||||
size="large"
|
||||
variant="outlined"
|
||||
>
|
||||
{{ $t('reset') }}
|
||||
</v-btn>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<!-- 计算结果区域 -->
|
||||
<v-col
|
||||
cols="12"
|
||||
lg="6"
|
||||
md="6"
|
||||
>
|
||||
<v-card
|
||||
class="pa-6 result-card"
|
||||
elevation="8"
|
||||
rounded="xl"
|
||||
>
|
||||
<v-card-title class="text-h5 mb-6 d-flex align-center">
|
||||
<v-icon
|
||||
class="mr-3"
|
||||
color="primary"
|
||||
icon="mdi-tune"
|
||||
size="large"
|
||||
/>
|
||||
{{ $t('results') }}
|
||||
</v-card-title>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<ResultCard
|
||||
:label="`${$t('singlePaperTubeWeight')}(${singlePaperTubeWeight.unit})`"
|
||||
:value="singlePaperTubeWeight"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ResultCard
|
||||
:label="`${$t('totalPaperTubeWeight')}(${totalPaperTubeWeight.unit})`"
|
||||
:value="totalPaperTubeWeight"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="sass">
|
||||
<script setup lang="ts">
|
||||
import ParamInputField from '@/components/ParamInputField.vue'
|
||||
import { createParam, type Param } from '@/types/param'
|
||||
|
||||
</style>
|
||||
const paperRollLength = ref<Param>(createParam(1000, 'mm'))
|
||||
const paperDensity = ref<Param>(createParam(0.76, 'g/cm³'))
|
||||
const productionAmount = ref<Param>(createParam(1000, '支'))
|
||||
const paperCoreDiameter = ref<Param>(createParam(76.2, 'mm'))
|
||||
const paperRollWallThickness = ref<Param>(createParam(10, 'mm'))
|
||||
|
||||
const singlePaperTubeWeight = computed(() => {
|
||||
const paperCoreRadius = paperCoreDiameter.value.value / 2
|
||||
const paperRollExternalDiameter = paperCoreDiameter.value.value + 2 * paperRollWallThickness.value.value
|
||||
const paperRollExternalRadius = paperRollExternalDiameter / 2
|
||||
const paperRollVolume = paperRollLength.value.value * Math.PI * (Math.pow(paperRollExternalRadius, 2) - Math.pow(paperCoreRadius, 2))
|
||||
const weight = paperRollVolume * paperDensity.value.value / 1_000_000
|
||||
return createParam(weight, 'kg')
|
||||
})
|
||||
|
||||
const totalPaperTubeWeight = computed(() => {
|
||||
const weight = singlePaperTubeWeight.value.value * productionAmount.value.value
|
||||
return createParam(weight, 'kg')
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-text-field
|
||||
<v-text-field
|
||||
density="compact"
|
||||
hide-details
|
||||
:label="label"
|
||||
|
||||
38
src/components/ResultCard.vue
Normal file
38
src/components/ResultCard.vue
Normal file
@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="mb-4"
|
||||
elevation="3"
|
||||
rounded="lg"
|
||||
>
|
||||
<v-card-title class="bg-primary from-primary to-secondary text-white">
|
||||
<v-icon
|
||||
class="mr-2"
|
||||
icon="mdi-calculator-variant"
|
||||
/>
|
||||
{{ label }}
|
||||
</v-card-title>
|
||||
<v-card-text class="text-h5 py-6 text-center">
|
||||
<v-chip
|
||||
class="text-h6 pa-4"
|
||||
color="primary"
|
||||
label
|
||||
size="large"
|
||||
variant="outlined"
|
||||
>
|
||||
{{ value.value.toFixed(4) }} {{ value.unit }}
|
||||
</v-chip>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Param } from '@/types/param'
|
||||
|
||||
interface Props {
|
||||
label: string
|
||||
value: Param
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
Reference in New Issue
Block a user