浏览代码

feat: 产品信息模块同步

zhangyuhan 2 月之前
父节点
当前提交
89ac0d4a57

+ 140 - 46
src/views/create-order/components/order-detail-submodule/SelectOrderDetailCard.vue

@@ -56,8 +56,8 @@
                   >
                     <div v-if="item.key === 'linkedOrder'" class="linkedOrder">
                       {{ item.label }}:
-                      <TableCard :span-method="objectSpanMethod" v-if="(product[item.key] || []).length" :table-data="product[item.key]" :columns="linkOrderColumns">
-                      </TableCard>
+                  <RelatedOrderTable v-if="product.linkedOrder && Object.keys(product.linkedOrder).length" :table-data="product.options">
+                  </RelatedOrderTable>
                       <span v-else>-</span>
                     </div>
                     <div v-else-if="item.key === 'subAccountCount'">
@@ -97,6 +97,13 @@
                     <div v-else-if="item.key ==='phone'">
                       {{ item.label }}:{{ orderData.user_phone || '-' }}
                     </div>
+                <div v-else-if="item.key === 'giftCount'">
+                  {{ item.label }}:{{ product.filter.num || '-' }}个
+                </div>
+                <div v-else-if="item.key === 'sale_final_price'">
+                  {{ item.label }}:¥{{ product.filter.num }}
+                </div>
+
                     <div v-else>{{ item.label }}:{{ getFilteredValue(product[item.key], item.filter) || '-' }}</div>
                   </div>
                 </div>
@@ -155,7 +162,7 @@
         </div>
       </div>
     </InfoCard>
-    <ServiceList v-show="false" ref="serviceListRef"></ServiceList>
+       <ServiceList v-show="false" :buySubject="orderData.buy_subject" ref="serviceListRef"></ServiceList>
   </div>
 </template>
 
@@ -167,12 +174,18 @@ import { div, calcDiscountRate, roundToTwoDecimals } from '@/utils/number/';
 import TableCard from '../../ui/TableCard.vue';
 import ServiceList from "@/views/create-order/components/product-info-submodule/ServiceList.vue";
 import {showActivityCardRateModule} from "@/views/create-order/hooks/utils";
+import RelatedOrderTable from '../product-info-submodule/RelatedOrderTable.vue';
+import { dateFormatter } from '@/utils/globalFun'
+import { maskPhone } from '@/utils/str/index'
+import { findPaymentType } from '@/views/create-order/hooks/format'
+
 export default {
   name: 'SelectOrderDetailCard',
   components: {
     ServiceList,
     InfoCard,
     ProductCard,
+    RelatedOrderTable,
     TableCard
   },
   props: {
@@ -221,9 +234,15 @@ export default {
         { label: '合同金额', key: 'final_price', span: 3},
         { label: '标准售价', key: 'original_price', span: 3},
         { label: '折扣率', key: 'rate', span: 3},
-        { label: '子账号数量', key: 'subAccountCount', span: 1, condition: () => this.parsedFilter.buyAccountCount && this.parsedFilter.giftAccountCount },
+        { label: '子账号数量', key: 'subAccountCount', span: 1, condition: (product) => product.filter.buyAccountCount || product.filter.giftAccountCount },
         { label: '主账号数量', key: 'mainAccountCount', span: 1 },
         { label: '关联订单', key: 'linkedOrder', span: 1},
+        { label: '赠品数量', key: 'giftCount', span: 1, condition: (product) => {
+          return product.tactics === '2' && product.filter.num && product.product_type !== '销售费用'
+        } },
+        { label: '销售费用', key: 'sale_final_price', span: 1, condition: (product) => {
+          return product.tactics === '2' && product.product_type === '销售费用'
+        }},
         { label: '补充说明', key: 'supExplanation', span: 1, condition: (product) => product.supExplanation && product.supExplanation !== '-' },
         { label: '开通权益手机号', key: 'phone', span: 3},
         { label: '服务开始时间', key: 'service_starttime', span: 3},
@@ -300,10 +319,7 @@ 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',
@@ -391,9 +407,9 @@ export default {
               try {
                 const parsedFilter = this.parseProductFilter(product);
                   const serviceIds = parsedFilter.serviceIds || [];
-
+              const supServiceIds = parsedFilter.supServiceIds || [];
                   // 等待异步方法完成
-              const bigServiceNames = product.product_type === '大会员' ? await this.buildBigServiceNames(serviceIds) : '';
+              const bigServiceNames = product.product_type === '大会员' ? await this.buildBigServiceNames(serviceIds, supServiceIds) : '';
                 const rate = this.calculateDiscountRate(product);
                 const validityPeriod = this.calculateValidityPeriod(
                 parsedFilter,
@@ -403,10 +419,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,
@@ -419,9 +475,11 @@ export default {
                   linkedOrder,
                     bigServiceNames,
                   final_price: finalPrice,
+                sale_final_price: finalPrice,
                 original_price: originalPrice,
                 supExplanation,
                 ..._productArr[index] || {},
+                options: associationOrder
                 };
 
               newProduct._a = showActivityCardRateModule(_productArr, newProduct)
@@ -438,6 +496,22 @@ export default {
       this.setTotalAmounts(productData);
       this.productData = productData;
     },
+    sortTableText(service) {
+      console.log('service', service)
+      const order = service.linkedOrderSplit || {}
+      return {
+        productTypeText: service.name || '-',
+        empowerCountText: service.empowerCount ? `${service.empowerCount}个` : '-',
+        serviceEndTimeText: service.serviceEndTime ? dateFormatter(service.serviceEndTime, 'yyyy-MM-dd') : '-',
+        buySubjectText: service.buySubject === 1 ? '个人' : '企业',
+        phone: service.phone,
+        short_phone: maskPhone(service.phone),
+        order_code: order.order_code || '-',
+        service_type: order.service_type || '-',
+        service_type_text: findPaymentType(order.service_type)?.label || '-',
+        create_time: order.create_time || '-',
+      }
+    },
     // 权限开通
     openPermissionActivation() {
       this.$refs.newDetailModel.permissionActivationShow = true;
@@ -459,7 +533,7 @@ export default {
       }
       return RETURN_BOOL[product] || false;
     },
-    buildBigServiceNames(serviceIds) {
+    buildBigServiceNames(serviceIds, supServiceIds) {
       return new Promise((resolve) => {
         if (!serviceIds || serviceIds.length === 0) {
           resolve('');
@@ -468,7 +542,7 @@ export default {
 
         // 避免修改原始数组,创建新的整型数组
         const numericServiceIds = serviceIds.map(id => parseInt(id));
-
+        let sameValues = [], differentValues = [];
         this.$nextTick(() => {
           try {
             const serviceListRef = this.$refs.serviceListRef;
@@ -476,10 +550,39 @@ export default {
               resolve('');
               return;
             }
+            if(supServiceIds && supServiceIds.length > 0) {
+              // 比较supServiceIds和serviceIds相同的值,并返回相同的值组成的数组,不同的值也返回一个数组
+
+              // 已购服务
+              // 不同的值组成的数组
+              // differentValues = serviceIds.filter(value => !supServiceIds.includes(value));
+              const serviceIdsArr = serviceIds.map(id => parseInt(id));
+              const baseServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(serviceIdsArr);
+              const baseServiceData = Array.isArray(baseServiceIdsArr)? baseServiceIdsArr.join('、') : ''
+              // 补充服务
+              // 相同的值组成的数组
+              sameValues = supServiceIds.filter(value => serviceIds.includes(value));
+              const supServiceIdsArr = sameValues.map(id => parseInt(id));
+              const resSupServiceIdsArr = serviceListRef.calcAlreadyBuyServiceNamesArr(supServiceIdsArr);
+              // 如果resSupServiceData中包含基础服务+企业管理,需要去掉, buy_subject为1时,去掉企业管理
+              const baseServiceIndex = resSupServiceIdsArr.findIndex(item =>
+                item === (this.orderData.buy_subject === 2 ? '基础服务+企业管理' : '基础服务')
+              );
+              if (baseServiceIndex !== -1) {
+                resSupServiceIdsArr.splice(baseServiceIndex, 1);
+              }
+              const resSupServiceData = Array.isArray(resSupServiceIdsArr)? resSupServiceIdsArr.join('、') : '';
 
+              // 如果有补充服务,就拼接,如果没有补充服务,就不拼接,直接返回原已购服务名连接字符串
+              const supplement = resSupServiceData ? `【补充服务】:${resSupServiceData}` : ''
+              // 最终服务字符串:补充服务名称;原已购服务名称
+              const serviceStr = `${supplement};【原已购服务】:${baseServiceData}`
+              resolve(serviceStr);
+            } else {
             const res = serviceListRef.calcAlreadyBuyServiceNamesArr(numericServiceIds);
             const serviceData = Array.isArray(res) ? res.join('、') : '';
             resolve(serviceData);
+            }
           } catch (error) {
             console.error('Error calculating service names:', error);
             resolve('');
@@ -521,23 +624,14 @@ export default {
       }
       return '';
     },
-
-    // 构造主账号数量字符串。
-    buildMainAccountCount(product) {
-      if (product.product_type === 'VIP订阅') {
-        return `付费1个,合计<span class="color_main">1</span>个`;
-      }
-      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) {
@@ -550,21 +644,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') {
@@ -652,7 +746,7 @@ export default {
     getFilteredValue(value, filterName) {
       // 判断value是否是数字,或者是字符串数字
       if (typeof value === 'number' || /^\d+$/.test(value)) {
-        if(!value) return '0.00'
+        if(!value && filterName !== 'orderServiceType') return '0.00'
       }
       if (!filterName) return value || '-';
       return this[filterName](value);

+ 10 - 6
src/views/order/components/new-detailModel.vue

@@ -112,7 +112,7 @@
       </div>
     </Modal>
     <!-- 退款登记 -->
-    <Modal :title="'退款登记'" v-model="tShow" class-name="order-model tui-model select-product-model" :mask-closable="false"
+    <Modal :title="'退款登记'" v-model="tShow" class-name="order-model select-product-model" :transfer="false" :mask-closable="false"
       @on-visible-change="visibleChange">
       <select-order-detail-card :orderDetail="data" ref="selectProduct" formType="退款"></select-order-detail-card>
 <!--      <Form ref="models" :model="models" :rules="refundRuleValidate" :label-width="110">-->
@@ -136,7 +136,7 @@
       </div>
     </Modal>
     <!-- 修正记录 -->
-    <Modal title="红冲" v-model="correctionShow" class-name="order-model tui-model select-product-model" :mask-closable="false"
+    <Modal title="红冲" v-model="correctionShow" class-name="order-model select-product-model" :transfer="false" :mask-closable="false"
       @on-visible-change="visibleChange">
       <!-- <label class="correctionLabel">请输入该订单最终准确的信息:</label> -->
       <Form ref="correctionModels" :model="models" :label-width="110">
@@ -1209,10 +1209,14 @@ export default {
       margin-left: 120px;
     }
   }
-}
-.select-product-model {
-  .ivu-modal {
-    width: 70vw !important;
+  .select-product-model {
+    .ivu-modal {
+      width: 900px !important;
+      min-width: 750px;
+      .linkedOrder {
+        flex-wrap: wrap;
+      }
+    }
   }
 }
 </style>