Fix: 修改代码风格 & 优化脚本结构
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
rounded="xl"
|
||||
>
|
||||
<v-card-title class="text-h5 mb-6 d-flex align-center">
|
||||
<VIcon
|
||||
<v-icon
|
||||
class="mr-3"
|
||||
color="primary"
|
||||
icon="mdi-tune"
|
||||
@ -26,31 +26,31 @@
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperCoreDiameter"
|
||||
:label="`${$t('paperCoreDiameter')} (${paperCoreDiameter.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperRollExternalDiameter"
|
||||
:label="`${$t('paperRollExternalDiameter')} (${paperRollExternalDiameter.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperRollWidth"
|
||||
:label="`${$t('paperRollWidth')} (${paperRollWidth.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperDensity"
|
||||
:label="`${$t('paperDensity')} (${paperDensity.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperGrammage"
|
||||
:label="`${$t('paperGrammage')} (${paperGrammage.unit})`"
|
||||
/>
|
||||
@ -77,42 +77,42 @@
|
||||
lg="5"
|
||||
md="6"
|
||||
>
|
||||
<VCard
|
||||
<v-card
|
||||
class="pa-6 result-card"
|
||||
elevation="8"
|
||||
rounded="xl"
|
||||
>
|
||||
<VCardTitle class="text-h5 mb-6 d-flex align-center">
|
||||
<VIcon
|
||||
<v-card-title class="text-h5 mb-6 d-flex align-center">
|
||||
<v-icon
|
||||
class="mr-3"
|
||||
color="primary"
|
||||
icon="mdi-calculator"
|
||||
size="large"
|
||||
/>
|
||||
{{ $t('results') }}
|
||||
</VCardTitle>
|
||||
</v-card-title>
|
||||
|
||||
<VRow>
|
||||
<VCol cols="12">
|
||||
<ResultCard
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<result-card
|
||||
:label="$t('paperRollWeight')"
|
||||
:value="paperRollWeight"
|
||||
:value="result.paperRollWeight"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<ResultCard
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<result-card
|
||||
:label="$t('paperRollLength')"
|
||||
:value="paperRollLength"
|
||||
:value="result.paperRollLength"
|
||||
/>
|
||||
</VCol>
|
||||
<VCol cols="12">
|
||||
<ResultCard
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<result-card
|
||||
:label="$t('paperThickness')"
|
||||
:value="paperThickness"
|
||||
:value="result.paperThickness"
|
||||
/>
|
||||
</VCol>
|
||||
</VRow>
|
||||
</VCard>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
@ -128,30 +128,19 @@
|
||||
const paperDensity = ref<Param>(createParam(0.76, 'g/cm³'))
|
||||
const paperGrammage = ref<Param>(createParam(420, 'g/m²'))
|
||||
|
||||
const paperThickness = computed(() => {
|
||||
// 计算纸张厚度
|
||||
return createParam(paperGrammage.value.value / paperDensity.value.value / 1000, 'mm')
|
||||
})
|
||||
|
||||
const paperRollWeight = computed(() => {
|
||||
// 计算纸卷总重量
|
||||
const result = computed(() => {
|
||||
const paperRollExternalRadius = paperRollExternalDiameter.value.value / 2
|
||||
const paperCoreRadius = paperCoreDiameter.value.value / 2
|
||||
const paperRollVolume = (Math.PI * Math.pow(paperRollExternalRadius, 2) - Math.PI * Math.pow(paperCoreRadius, 2)) * paperRollWidth.value.value
|
||||
const weight = paperRollVolume * paperDensity.value.value / 1_000_000 // 计算重量
|
||||
return createParam(weight, 'kg')
|
||||
const paperThickness = paperGrammage.value.value / paperDensity.value.value / 1000 // 计算纸张厚度
|
||||
const paperRollWeight = paperRollVolume * paperDensity.value.value / 1_000_000 // 计算重量
|
||||
const paperRollLength = paperRollVolume / (paperThickness * paperRollWidth.value.value) / 1000 // 计算长度
|
||||
return {
|
||||
paperRollWeight: createParam(paperRollWeight, 'kg'),
|
||||
paperRollLength: createParam(paperRollLength, 'm'),
|
||||
paperThickness: createParam(paperThickness, 'mm'),
|
||||
}
|
||||
})
|
||||
|
||||
const paperRollLength = computed(() => {
|
||||
// 计算纸卷长度
|
||||
const paperRollExternalRadius = paperRollExternalDiameter.value.value / 2
|
||||
const paperCoreRadius = paperCoreDiameter.value.value / 2
|
||||
const paperRollVolume = (Math.PI * Math.pow(paperRollExternalRadius,
|
||||
2) - Math.PI * Math.pow(paperCoreRadius, 2)) * paperRollWidth.value.value
|
||||
const length = paperRollVolume / (paperThickness.value.value * paperRollWidth.value.value) / 1000
|
||||
return createParam(length, 'm')
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="sass">
|
||||
|
||||
@ -24,31 +24,31 @@
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperRollLength"
|
||||
:label="`${$t('paperRollLength')}(${paperRollLength.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperDensity"
|
||||
:label="`${$t('paperDensity')}(${paperDensity.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="productionAmount"
|
||||
:label="`${$t('productionAmount')}(${productionAmount.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperCoreDiameter"
|
||||
:label="`${$t('paperCoreDiameter')}(${paperCoreDiameter.unit})`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ParamInputField
|
||||
<param-input-field
|
||||
v-model="paperRollWallThickness"
|
||||
:label="`${$t('paperRollWallThickness')}(${paperRollWallThickness.unit})`"
|
||||
/>
|
||||
@ -94,15 +94,15 @@
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<ResultCard
|
||||
:label="`${$t('singlePaperTubeWeight')}(${singlePaperTubeWeight.unit})`"
|
||||
:value="singlePaperTubeWeight"
|
||||
<result-card
|
||||
:label="`${$t('singlePaperTubeWeight')}(${result.singlePaperTubeWeight.unit})`"
|
||||
:value="result.singlePaperTubeWeight"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<ResultCard
|
||||
:label="`${$t('totalPaperTubeWeight')}(${totalPaperTubeWeight.unit})`"
|
||||
:value="totalPaperTubeWeight"
|
||||
<result-card
|
||||
:label="`${$t('totalPaperTubeWeight')}(${result.totalPaperTubeWeight.unit})`"
|
||||
:value="result.totalPaperTubeWeight"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@ -122,17 +122,16 @@
|
||||
const paperCoreDiameter = ref<Param>(createParam(76.2, 'mm'))
|
||||
const paperRollWallThickness = ref<Param>(createParam(10, 'mm'))
|
||||
|
||||
const singlePaperTubeWeight = computed(() => {
|
||||
const result = 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')
|
||||
const singlePaperTubeWeight = paperRollVolume * paperDensity.value.value / 1_000_000
|
||||
const totalPaperTubeWeight = singlePaperTubeWeight * productionAmount.value.value
|
||||
return {
|
||||
singlePaperTubeWeight: createParam(singlePaperTubeWeight, 'kg'),
|
||||
totalPaperTubeWeight: createParam(totalPaperTubeWeight, 'kg'),
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user