Răsfoiți Sursa

refactor(order): 优化订单详情页面展示逻辑

- 修改发票信息组件中的发票状态显示文本
- 优化关联订单数据的处理逻辑,移除冗余代码
- 修复未回款金额的显示字段

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe 2 luni în urmă
părinte
comite
6f1fa12f95

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

@@ -116,11 +116,11 @@ export default {
       if (val == -2) {
           return '已冲红'
       } else if (val == -1) {
-          return '失败'
+          return '开票失败'
       } else if (val == 0) {
-          return '开票中'
+          return '已申请'
       } else if (val == 1) {
-          return '成功'
+          return '已开具'
       }
     },
     getInvoiceStatus(val) {

+ 71 - 61
src/views/create-order/components/order-detail-submodule/OrderDetailCardProductList.vue

@@ -23,7 +23,7 @@
                 >
                 <div v-if="item.key === 'linkedOrder'" class="linkedOrder">
                   {{ item.label }}:
-                  <RelatedOrderTable v-if="product[item.key].length" :table-data="associationTableData">
+                  <RelatedOrderTable v-if="product.linkedOrder && Object.keys(product.linkedOrder).length" :table-data="product.options">
                   </RelatedOrderTable>
                   <span v-else>-</span>
                 </div>
@@ -68,7 +68,7 @@
                   {{ item.label }}:{{ product.filter.num || '-' }}个
                 </div>
                 <div v-else-if="item.key === 'sale_final_price'">
-                  {{ item.label }}:¥{{ getFilteredValue(product[item.key], item.filter)}}
+                  {{ item.label }}:¥{{ product.filter.num }}
                 </div>
 
                 <div v-else>{{ item.label }}:{{ getFilteredValue(product[item.key], item.filter) || '-' }}</div>
@@ -194,18 +194,14 @@ export default {
         { 
           prop:'service_type',
           label: '付费类型',
-          width: 80,
-          render (row) {
-            return paymentTypeOptions.find(item => item.value === row.service_type)?.label || '-'
-          }
+          width: 80
         },
         { 
           prop:'create_time',
           label: '创建时间', 
           width: 102
         } 
-      ],
-      parsedFilter: {}
+      ]
     }
   },
   watch: {
@@ -220,35 +216,7 @@ export default {
   computed: {
     ...mapState({
       orderDetail: state => state.order.orderDetail
-    }),
-    // 对options展开
-    associationTableData() {
-      const arr = []
-      this.productData.forEach(item => {
-        if (Array.isArray(item.linkedOrder) && item.linkedOrder.length > 0) {
-          item.linkedOrder.forEach(t => {
-            arr.push({
-              ...item,
-              linkedId: item.linkedId,
-              _linkedId: `${item.linkedId}-${t.order_code}`,
-              linkedOrderSplit: t,
-            })
-          })
-        } else {
-          // 关联订单只有1个的情况
-          arr.push({
-            ...item,
-            _linkedId: item.linkedId + '',
-          })
-        }
-      })
-      return arr.map(t => {
-        return {
-          ...t,
-          ...this.sortTableText(t),
-        }
-      })
-    },
+    })
   },
   mounted() {
     this.beforeInit();
@@ -283,10 +251,50 @@ export default {
               const dataCount = this.buildDataCount(product, parsedFilter);
               const subAccountCount = this.buildSubAccountCount(product, parsedFilter);
               const mainAccountCount = '1个';
-              const linkedOrder = this.processLinkedOrder(product);
+              // const linkedOrder = this.processLinkedOrder(product);
               const finalPrice = this.formatNumber(product.final_price);
               let originalPrice = this.formatNumber(product.original_price);
-              this.parsedFilter = parsedFilter;
+              const linkedOrder = product.linkedOrder || {}; // 关联订单信息
+              const { buySubject, empowerCount, name, serviceStartTime, serviceEndTime, provinceCount, orderArr } = linkedOrder || {}
+
+              const options = [{
+                buySubject,
+                comboId: 0, // 套餐id
+                empowerCount, // 人数
+                name,
+                phone: this.orderData.personPhone, // 开通权益手机号
+                provinceCount, // 订阅省份
+                serviceStartTime, // 服务开始时间
+                serviceEndTime, // 结束时间
+                serviceList: [],
+                linkedOrder: orderArr,
+                vipExist: false, //当前服务是否在有限期内
+                
+              }]
+              const item = options[0]
+              const arr = []
+              if (Array.isArray(item.linkedOrder) && item.linkedOrder.length > 0) {
+                item.linkedOrder.forEach(t => {
+                  arr.push({
+                    ...item,
+                    linkedId: item.linkedId,
+                    _linkedId: `${item.linkedId}-${t.order_code}`,
+                    linkedOrderSplit: t,
+                  })
+                })
+              } else {
+                // 关联订单只有1个的情况
+                arr.push({
+                  ...item,
+                  _linkedId: item.linkedId + '',
+                })
+              }
+              const associationOrder = arr.map(t => {
+                return {
+                  ...t,
+                  ...this.sortTableText(t),
+                }
+              })
 
               const newProduct = {
                 ...product,
@@ -303,6 +311,7 @@ export default {
                 original_price: originalPrice,
                 supExplanation,
                 ..._productArr[index] || {},
+                options: associationOrder
               };
 
               newProduct._a = showActivityCardRateModule(_productArr, newProduct)
@@ -446,13 +455,13 @@ export default {
       return '';
     },
     // 处理关联订单数据。
-    processLinkedOrder(product) {
-      if (product.linkedOrder && Object.keys(product.linkedOrder).length > 0) {
-        const orderList = [product.linkedOrder];
-        return this.flattenLinkOrderList(orderList);
-      }
-      return [];
-    },
+    // processLinkedOrder(product) {
+    //   if (product.linkedOrder && Object.keys(product.linkedOrder).length > 0) {
+    //     const orderList = [product.linkedOrder];
+    //     return this.flattenLinkOrderList(orderList);
+    //   }
+    //   return [];
+    // },
 
     // 设置合同金额合计和标准售价合计,以及计算折扣率总和。
     setTotalAmounts(productData) {
@@ -465,21 +474,21 @@ export default {
       this.orderData.rate_total = Number(totalOriginalPrice) ? rateTotal : '无法计算';
     },
 
-    flattenLinkOrderList(linkOrderList) {
-      const result = [];
-      if (!linkOrderList || linkOrderList.length === 0) return result;
-      linkOrderList.forEach(item => {
-        const { orderArr, ...rest } = item; // 拆分 orderArr 和其他字段
-        if (!orderArr || orderArr.length === 0) return;
-        orderArr.forEach(order => {
-          result.push({
-            ...rest,           // 非 orderArr 的字段(如 name, empowerCount 等)
-            ...order          // orderArr 中的字段(如 order_code, service_type 等)
-          });
-        });
-      });
-      return result;
-    },
+    // flattenLinkOrderList(linkOrderList) {
+    //   const result = [];
+    //   if (!linkOrderList || linkOrderList.length === 0) return result;
+    //   linkOrderList.forEach(item => {
+    //     const { orderArr, ...rest } = item; // 拆分 orderArr 和其他字段
+    //     if (!orderArr || orderArr.length === 0) return;
+    //     orderArr.forEach(order => {
+    //       result.push({
+    //         ...rest,           // 非 orderArr 的字段(如 name, empowerCount 等)
+    //         ...order          // orderArr 中的字段(如 order_code, service_type 等)
+    //       });
+    //     });
+    //   });
+    //   return result;
+    // },
 
     shouldRenderItem(item, product) {
       if (item.condition && typeof item.condition === 'function') {
@@ -588,6 +597,7 @@ export default {
     
     orderServiceType(val) {
       const matchedOption = paymentTypeOptions.find(option => option.value === val);
+      console.log(matchedOption, 'matchedOption');
       return matchedOption ? matchedOption.label : val; // 如果未找到匹配项,返回原始值
     },
   }

+ 1 - 1
src/views/create-order/components/order-detail-submodule/PaymentInfo.vue

@@ -9,7 +9,7 @@
           已回款金额:{{isBackstageOrder ? '¥' + returnAmount(returnRes?.returnMoney) : '-'}} 
         </div>
         <div class="payment-info-item">
-          未回款金额:{{ isBackstageOrder? '¥' + returnAmount(returnRes?.noReturnMoney) : '-' }}
+          未回款金额:{{ isBackstageOrder? '¥' + returnAmount(returnRes?.remainingMoney) : '-' }}
         </div>
       </div>
     </InfoCard>