Browse Source

feat: cargo集货.货物体积增加计算单位切换.显示逻辑优化.

peter 3 weeks ago
parent
commit
7c86253efc
1 changed files with 22 additions and 5 deletions
  1. 22 5
      src/pages/cargo-consolidation-request/index.vue

+ 22 - 5
src/pages/cargo-consolidation-request/index.vue

@@ -625,13 +625,19 @@
         label-position="right"
         label-width="95px"
       >
-        <el-form-item label="length (m)">
+        <el-form-item label="长短单位">
+          <el-radio-group v-model="unitType">
+            <el-radio-button :label="1">米 (m)</el-radio-button>
+            <el-radio-button :label="2">厘米 (cm)</el-radio-button>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item :label="`length (${unitType === 1 ? 'm' : 'cm'})`">
           <el-input v-model="cubeForm.l"></el-input>
         </el-form-item>
-        <el-form-item label="width (m)">
+        <el-form-item :label="`width (${unitType === 1 ? 'm' : 'cm'})`">
           <el-input v-model="cubeForm.w"></el-input>
         </el-form-item>
-        <el-form-item label="height (m)">
+        <el-form-item :label="`height (${unitType === 1 ? 'm' : 'cm'})`">
           <el-input v-model="cubeForm.h"></el-input>
         </el-form-item>
         <el-form-item label="箱数(整数)">
@@ -689,6 +695,9 @@ import {
   ElDrawer,
   ElDialog,
   ElCheckbox,
+  ElRadio,
+  ElRadioGroup,
+  ElRadioButton,
 } from 'element-plus'
 import cloneDeep from 'lodash.clonedeep'
 import dayjs from 'dayjs'
@@ -1388,6 +1397,7 @@ const closeMapDrawer = () => {
   mapDrawerVisible.value = false
 }
 let cubeDialogVisible = ref(-1)
+let unitType = ref(1) // 1:m 2:cm
 let cubeForm = ref({
   l: '',
   w: '',
@@ -1397,14 +1407,21 @@ let cubeForm = ref({
 let cubeForm2 = ref({
   c: '' as string | number, // 体积
 })
+watch(unitType, () => {
+  cubeForm.value.l = Number(cubeForm.value.l) * (unitType.value === 1 ? 0.01 : 100) + ''
+  cubeForm.value.w = Number(cubeForm.value.w) * (unitType.value === 1 ? 0.01 : 100) + ''
+  cubeForm.value.h = Number(cubeForm.value.h) * (unitType.value === 1 ? 0.01 : 100) + ''
+})
 watch(
   cubeForm,
   () => {
-    cubeForm2.value.c =
+    cubeForm2.value.c = (
       Number(cubeForm.value.l) *
       Number(cubeForm.value.w) *
       Number(cubeForm.value.h) *
-      Number(cubeForm.value.Carton)
+      Number(cubeForm.value.Carton) *
+      (unitType.value === 2 ? 0.000001 : 1)
+    ).toFixed(2)
   },
   {
     immediate: true,