From d3d9554ead6d597cb99d0a11f2d0d5b48254a900 Mon Sep 17 00:00:00 2001 From: huanshuo-W <15258427350@163.com> Date: Thu, 10 Jul 2025 16:22:40 +0800 Subject: [PATCH] =?UTF-8?q?Feature:=20=E7=9A=AE=E5=B8=A6=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/BeltSpecificationCalculate.vue | 244 +++++++++++++++++- src/components/ParamInputField.vue | 2 + src/locale/en.json | 14 +- src/locale/zh.json | 14 +- 4 files changed, 265 insertions(+), 9 deletions(-) diff --git a/src/components/Modules/BeltSpecificationCalculate.vue b/src/components/Modules/BeltSpecificationCalculate.vue index 112bcb7..df0ca35 100644 --- a/src/components/Modules/BeltSpecificationCalculate.vue +++ b/src/components/Modules/BeltSpecificationCalculate.vue @@ -1,11 +1,241 @@ - - - + const { t, locale } = useI18n() + + const currentSelect = ref('') + const currentSelectIndex = ref(0) + + const selects = computed(() => [ + t('50_120Series'), + t('200_Series'), + t('600_Series'), + t('new_50_120Series'), + t('new_200_Series'), + t('custom'), + ]) + + const maxWheelbase = ref(createParam(900, 'mm')) + const hubDiameter = ref(createParam(215, 'mm')) + const paperCoreDiameter = ref(createParam(76.2, 'mm')) + const paperRollWallThickness = ref(createParam(10, 'mm')) + + const result = computed(() => { + const hubCircumference = Math.PI * hubDiameter.value.value + const paperRollExternalDiameter = paperCoreDiameter.value.value + paperRollWallThickness.value.value + const paperRollCircumference = Math.PI * paperRollExternalDiameter + + const recommendBeltLength = Math.round((paperRollCircumference + hubCircumference + (maxWheelbase.value.value - 50) * 2) / 10) * 10 + + const beltWidthMapping = [ + { threshold: 20, width: 10 }, + { threshold: 25, width: 15 }, + { threshold: 32, width: 20 }, + { threshold: 40, width: 25 }, + { threshold: 70, width: 30 }, + { threshold: 95, width: 40 }, + { threshold: 125, width: 50 }, + { threshold: 150, width: 60 }, + { threshold: 204, width: 80 }, + { threshold: 380, width: 105 }, + { threshold: 950, width: 120 }, + { threshold: 1200, width: 150 }, + { threshold: 5000, width: 200 }, + ] + + const beltThicknessMapping = [ + { threshold: 10, thickness: 6 }, + { threshold: 15, thickness: 8 }, + { threshold: 20, thickness: 10 }, + { threshold: 30, thickness: 12 }, + ] + + function getBeltWidth (circumference: number): number { + const mapping = beltWidthMapping.find(item => circumference < item.threshold) + return mapping ? mapping.width : 0 + } + + function getBeltThickness (width: number): number { + const mapping = beltThicknessMapping.find(item => width < item.threshold) + return mapping ? mapping.thickness : 15 + } + + const recommendBeltWidth = getBeltWidth(paperRollCircumference) + const recommendBeltThickness = getBeltThickness(paperRollWallThickness.value.value) + + return { + recommendBeltLength: createParam(recommendBeltLength, 'mm'), + recommendBeltWidth: createParam(recommendBeltWidth, 'mm'), + recommendBeltThickness: createParam(recommendBeltThickness, 'mm'), + } + }) + + // 机器型号预设参数配置 + const machineConfigs = computed(() => { + return { + [t('50_120Series')]: { + maxWheelbase: 900, + hubDiameter: 215, + }, + [t('200_Series')]: { + maxWheelbase: 1100, + hubDiameter: 245, + }, + [t('600_Series')]: { + maxWheelbase: 1675, + hubDiameter: 320, + }, + [t('new_50_120Series')]: { + maxWheelbase: 900, + hubDiameter: 240, + }, + [t('new_200_Series')]: { + maxWheelbase: 1100, + hubDiameter: 268, + }, + } + }) + + // 选择机器型号时更新参数 + function updateParams (machineModel: string): void { + const config = machineConfigs.value[machineModel] + currentSelectIndex.value = selects.value.indexOf(machineModel) + if (config) { + maxWheelbase.value = createParam(config.maxWheelbase, 'mm') + hubDiameter.value = createParam(config.hubDiameter, 'mm') + } + } + + // 当前处于自定义模式 + const isCustomMode = computed(() => { + return currentSelect.value === t('custom') + }) + + onMounted(() => { + // 初始化时设置默认选择 + currentSelect.value = selects.value[0] + updateParams(currentSelect.value) + }) + + // 监听语言变化 + watch(locale, () => { + // 更新当前选择的机器型号 + currentSelect.value = selects.value[currentSelectIndex.value] + updateParams(currentSelect.value) + }) + + diff --git a/src/components/ParamInputField.vue b/src/components/ParamInputField.vue index 0a3cd65..cb7ca16 100644 --- a/src/components/ParamInputField.vue +++ b/src/components/ParamInputField.vue @@ -1,6 +1,7 @@