Эх сурвалжийг харах

refactor(create-order): 优化订单详情卡片中的服务列表和周期计算

- 修改已购服务和补充服务的计算逻辑,使用不同的变量名以提高代码可读性
- 优化总天数计算逻辑,增加对小于30天情况的特殊处理
- 移除不必要的 console.log 语句,清理代码

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe 2 сар өмнө
parent
commit
5594dfee0c

+ 11 - 8
src/views/create-order/components/order-detail-submodule/OrderDetailCardProductList.vue

@@ -373,9 +373,9 @@ export default {
               
               // 已购服务
               // 不同的值组成的数组
-              // differentValues = serviceIds.filter(value => !supServiceIds.includes(value));
-              const serviceIdsArr = serviceIds.map(id => parseInt(id));
-              const baseServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(serviceIdsArr);
+              differentValues = serviceIds.filter(value => !supServiceIds.includes(value));
+              const differentValuesArr = differentValues.map(id => parseInt(id));
+              const baseServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(differentValuesArr);
               const baseServiceData = Array.isArray(baseServiceIdsArr)? baseServiceIdsArr.join('、') : ''
               // 补充服务
               // 相同的值组成的数组
@@ -516,14 +516,12 @@ export default {
           days += value * 365;
           text = `${value}年`;
         }
-        console.log(days, text, 'processCycle');
         return { days, text };
       };
 
       // 计算购买和赠送部分
       const buyResult = processCycle(buy_cycle, buy_type);
       const giveResult = processCycle(give_cycle, give_type);
-      console.log(buyResult, giveResult, 'buyResult, giveResult');
 
       // 总天数
       const totalDays = buyResult.days + giveResult.days;
@@ -536,7 +534,14 @@ export default {
         if(totalDays % 30 === 0) {
           totalText = `${Math.floor(totalDays / 30)}个月`;
         } else {
-          totalText = `${Math.floor(totalDays / 30)}个月${totalDays % 30}天`; 
+          // 如果天数小于30天,则不显示月,只显示天
+          const isHas30Days = totalDays / 30 < 1;
+          totalText = `${isHas30Days ? totalDays % 30 : Math.floor(totalDays / 30)}个月${totalDays % 30}日`;
+          if(isHas30Days) {
+            totalText = `${totalDays % 30}日`;
+          } else {
+            totalText = `${Math.floor(totalDays / 30)}个月${totalDays % 30}日`;
+          }
         }
       }
       // 如果总天数为365或者365的整数倍,则显示为totalText/365*12个月,
@@ -544,7 +549,6 @@ export default {
         totalText = `${Math.floor(totalDays / 365) * 12}个月`; 
       }
       
-      console.log(totalText, 'totalText');
       const giveResultText = giveResult.text ? `赠送${giveResult.text},` : '';
       return `付费${buyResult.text},${giveResultText}合计<span class="color_main">${totalText}</span>${returned_opens}`;
     },
@@ -579,7 +583,6 @@ export default {
     
     orderServiceType(val) {
       const matchedOption = paymentTypeOptions.find(option => option.value === val);
-      console.log(matchedOption, 'matchedOption');
       return matchedOption ? matchedOption.label : val; // 如果未找到匹配项,返回原始值
     },
   }

+ 3 - 4
src/views/create-order/components/order-detail-submodule/SelectOrderDetailCard.vue

@@ -497,7 +497,6 @@ export default {
       this.productData = productData;
     },
     sortTableText(service) {
-      console.log('service', service)
       const order = service.linkedOrderSplit || {}
       return {
         productTypeText: service.name || '-',
@@ -555,9 +554,9 @@ export default {
 
               // 已购服务
               // 不同的值组成的数组
-              // differentValues = serviceIds.filter(value => !supServiceIds.includes(value));
-              const serviceIdsArr = serviceIds.map(id => parseInt(id));
-              const baseServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(serviceIdsArr);
+              differentValues = serviceIds.filter(value => !supServiceIds.includes(value));
+              const differentValuesArr = differentValues.map(id => parseInt(id));
+              const baseServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(differentValuesArr);
               const baseServiceData = Array.isArray(baseServiceIdsArr)? baseServiceIdsArr.join('、') : ''
               // 补充服务
               // 相同的值组成的数组

+ 0 - 1
src/views/create-order/components/product-info-submodule/ServiceList.vue

@@ -619,7 +619,6 @@ export default {
       if (names_str.includes('业主分析') && !idArr.includes(5)) {
         idArr.push(5) // 添加基础服务
       }
-      console.log(`serviceList选中服务: `, idArr.sort((a, b) => a - b), nameArr)
       return {
         idArr: [...new Set(idArr)], // 数组去重
         nameArr,

+ 0 - 1
src/views/create-order/components/schema-form/resort/index.js

@@ -125,7 +125,6 @@ export function sortOrderInfo(order = {}) {
       return new OrderProductCardItem(undefined, undefined, config)
     })
   }
-  console.log('sortOrderInfo', order, {pageFormValue,productArr})
   return {
     pageFormValue,
     productArr,