Преглед изворни кода

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

- 修改电子协议下载功能,增加未知订单处理
- 优化产品列表展示,增加数据条数和补充说明字段
- 调整订单总结展示,移除不必要的过滤器
- 优化回款信息展示,根据订单类型控制显示内容

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe пре 2 месеци
родитељ
комит
c0d261a266

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

@@ -131,6 +131,7 @@ export default {
         e_contract_remark,
       } = this.$refs.editContractArchiveModule.pageForm
       const params = {
+        orderCode: this.orderDetail.orderData.order_code,
         contractTime: dateFormatter(signTime, 'yyyy-MM-dd'),
         e_contract_type: e_contract_type,
         e_contract_userA_type: e_contract_userA_type,

+ 27 - 8
src/views/create-order/components/order-detail-submodule/OrderActions.vue

@@ -221,12 +221,16 @@ export default {
       noDownloadMsg: [],
       noWxAliMsg: [],
       noScanMsg: [],
-      payCodeShow: false
+      payCodeShow: false,
+      orderDownloadDisabled: false,
+      downloadInfo: {}
     }
   },
   created () {
     const { id } = this.$route.params
     this.orderCode = id
+    this.doDownload()
+
   },
   watch: {
     editdialogVisible(n) {
@@ -314,7 +318,8 @@ export default {
           action: () => {
             this.doAction('下载电子协议')
           },
-          show: true
+          show: true,
+          disabled: this.orderDownloadDisabled
         },
         {
           text: '微信/支付宝付款码',
@@ -529,6 +534,17 @@ export default {
         nameList.push(`.${suffix}`)
         return nameList.join('')
     },
+    async doDownload () { 
+      const { error_code, error_msg, data} = await ajaxGetContractPdf({ orderCode: this.orderCode })
+      if(error_code !== 0 && error_msg === '未知订单') {
+        this.orderDownloadDisabled = true
+      }
+      this.downLoadInfo = {
+        error_code,
+        error_msg,
+        data
+      }
+    },
     // 文件下载,跨域无效
     downloadFile(url, filename) {
         const link = document.createElement('a')
@@ -552,17 +568,20 @@ export default {
         }
         case '下载电子协议': {
           this.$emit('loading', true)
-          const { error_code: code, error_msg: msg, data} = await ajaxGetContractPdf({ orderCode: this.orderCode })
+          const { error_code: code, error_msg: msg, data} = this.downLoadInfo
           if (code === 0) {
             const fileUrl = data
             const filename = this.getEContractFilename(fileUrl)
             this.downloadFile(fileUrl, filename)
           } else {
-            this.downloadProtocolVisible = true
-            if(msg.indexOf(',') > -1) {
-              this.noDownloadMsg = msg.split(',')
-            } else {
-              this.noDownloadMsg = [msg]
+            // 未知订单,不允许下载协议,也不显示原因弹窗
+            if(!this.orderDownloadDisabled) {
+              this.downloadProtocolVisible = true
+              if(msg.indexOf(',') > -1) {
+                this.noDownloadMsg = msg.split(',')
+              } else {
+                this.noDownloadMsg = [msg]
+              }
             }
           }
           this.$emit('loading', false)

+ 34 - 10
src/views/create-order/components/order-detail-submodule/OrderDetailCardProductList.vue

@@ -39,7 +39,7 @@
                   <span class="red-chong" v-if="setRedPunchDisplay('折扣率')">(红冲过)</span>
                 </div>
                 <div v-else-if="item.key === 'final_price'">
-                  {{ item.label }}:¥{{ getFilteredValue(product[item.key], item.filter) || '-' }}
+                  {{ item.label }}:¥{{ getFilteredValue(product[item.key], item.filter) }}
                   <span class="red-chong" v-if="setRedPunchDisplay('合同金额')">(红冲过)</span>
                 </div>
                 <div v-else-if="item.key === 'original_price'">
@@ -122,6 +122,7 @@ export default {
         { label: '升级内容', key: 'supServicelds', span: 3, condition: (product) => product.supServicelds },
         { label: '产品规格', key: 'productName', span: 3},
         { label: '服务列表', key: 'bigServiceNames', span: 1, condition: (product) => product.productName && product.productName.includes('自定义') &&  product.product_code === 'dyh001'},
+        { label: '数据条数', key: 'data_count', span: 1, condition: (product) => product.data_count && product.data_count !== '-'},
         { label: '有效周期', key: 'validity_period', span: 1},
         { label: '合同金额', key: 'final_price', span: 3},
         { label: '标准售价', key: 'original_price', span: 3},
@@ -129,6 +130,7 @@ export default {
         { label: '子账号数量', key: 'subAccountCount', span: 1, condition: () => this.parsedFilter.buyAccountCount && this.parsedFilter.giftAccountCount },
         { label: '主账号数量', key: 'mainAccountCount', span: 1 },
         { label: '关联订单', key: 'linkedOrder', span: 1},
+        { label: '补充说明', key: 'supExplanation', span: 1, condition: (product) => product.supExplanation && product.supExplanation !== '-' },
         { label: '开通权益手机号', key: 'phone', span: 3},
         { label: '服务开始时间', key: 'service_starttime', span: 3},
         { label: '服务结束时间', key: 'service_endtime', span: 3}
@@ -222,12 +224,11 @@ export default {
               const bigServiceNames = product.product_type === '大会员' ? await this.buildBigServiceNames(serviceIds) : '';
               const rate = this.calculateDiscountRate(product);
               const validityPeriod = this.calculateValidityPeriod(
-                parsedFilter.buy_cycle,
-                parsedFilter.buy_type,
-                parsedFilter.give_cycle,
-                parsedFilter.give_type,
+                parsedFilter,
                 product
               );
+              const supExplanation = parsedFilter.supExplanation
+              const dataCount = this.buildDataCount(product, parsedFilter);
               const subAccountCount = this.buildSubAccountCount(product, parsedFilter);
               const mainAccountCount = '1个';
               const linkedOrder = this.processLinkedOrder(product);
@@ -240,12 +241,14 @@ export default {
                 filter: parsedFilter,
                 rate,
                 validity_period: validityPeriod,
+                data_count: dataCount,
                 subAccountCount,
                 mainAccountCount,
                 linkedOrder,
                 bigServiceNames,
                 final_price: finalPrice,
                 original_price: originalPrice,
+                supExplanation,
                 ..._productArr[index] || {},
               };
 
@@ -391,8 +394,25 @@ export default {
       }
       return true;
     },
+    buildDataCount(product, parsedFilter) {
+      const { pNum, give_cycle } = parsedFilter;
+      const totalNums = Number(pNum) + (Number(give_cycle) || 0);
+      const { product_type } = product;
+      const includeProductType = ['数据流量包', '历史数据', '结构化数据']
+      if(includeProductType.includes(product_type)) {
+        return `${totalNums}条`; 
+      } else {
+        return '';
+      }
 
-    calculateValidityPeriod(buyCycle, buyType, giveCycle, giveType, product) {
+    },
+    calculateValidityPeriod(parsedFilter, product) {
+      const { buy_cycle, buy_type, give_cycle, give_type, validYear } = parsedFilter
+      const { product_type, returned_open } = product
+      const returned_opens = returned_open === 1 ? '(全额回款当日开通)' : '';
+      if(product_type === '数据流量包') {
+        return `${validYear}年${returned_opens}`;
+      }
       let totalMonths = 0;
       let buyText = '';
       let giveText = '';
@@ -431,14 +451,13 @@ export default {
 
         return { months, text };
       };
-      const buyResult = processCycle(buyCycle, buyType);
-      const giveResult = processCycle(giveCycle, giveType);
+      const buyResult = processCycle(buy_cycle, buy_type);
+      const giveResult = processCycle(give_cycle, give_type);
       totalMonths = buyResult.months + giveResult.months;
       buyText = buyResult.text;
       giveText = giveResult.text;
-      const returned_open = product.returned_open === '1' ? '(全额回款当日开通)' : '';
       if(totalMonths === 0) return '-'
-      return `付费${buyText},赠送${giveText},合计<span class="color_main">${totalMonths.toFixed(0)}</span>个月${returned_open}`;
+      return `付费${buyText},赠送${giveText},合计<span class="color_main">${totalMonths.toFixed(0)}</span>个月${returned_opens}`;
     },
 
     getValidityPeriodHtml(product, item) {
@@ -449,6 +468,11 @@ export default {
 
     // 替代过滤器的通用方法
     getFilteredValue(value, filterName) {
+      console.log('getFilteredValue', value, filterName)
+      // 判断value是否是数字,或者是字符串数字
+      if (typeof value === 'number' || /^\d+$/.test(value)) {
+        if(!value) return '0.00'
+      }
       if (!filterName) return value || '-';
       return this[filterName](value);
     },

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

@@ -47,7 +47,7 @@ export default {
         { label: '折扣率', key: 'rate_total' },
         { label: '销售费用', key: 'commission'},
         { label: '净合同金额合计', key: 'pure_amount'},
-        { label: '0元订单类型', key: 'zero_type', filter: 'zeroOrderTypeData', condition: () => this.orderData.final_price_total === '0.00' },
+        { label: '0元订单类型', key: 'zero_type', condition: () => this.orderData.final_price_total === '0.00' },
       ],
       orderData: {},
       productData: [],
@@ -303,10 +303,6 @@ export default {
       if (!filterName) return value || '-';
       return this[filterName](value);
     },
-    // 0元订单类型数据处理
-    zeroOrderTypeData(val) {
-      return orderMoney0TypeOptions.find(item => item.value === val)?.label || '-';
-    },
     
     // 格式化数字,保留两位小数
     formatNumber(num, x = 2) {

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

@@ -3,13 +3,13 @@
     <InfoCard title="回款概览">
       <div class="payment-info-content">
         <div class="payment-info-item">
-          回款状态:{{ returnStatus }}
+          回款状态:{{ isBackstageOrder ? returnStatus : '-' }}
         </div>
         <div class="payment-info-item">
-          已回款金额:¥{{ returnAmount(returnRes?.returnMoney) }}
+          已回款金额:{{isBackstageOrder ? '¥' + returnAmount(returnRes?.returnMoney) : '-'}} 
         </div>
         <div class="payment-info-item">
-          未回款金额:¥{{ returnAmount(returnRes?.remainingMoney) }}
+          未回款金额:{{ isBackstageOrder? '¥' + returnAmount(returnRes?.noReturnMoney) : '-' }}
         </div>
       </div>
     </InfoCard>
@@ -234,6 +234,10 @@ export default {
     ...mapState({
       orderDetail: state => state.order.orderDetail 
     }),
+    // 是否是管理后台创建的订单 1为是 0不是
+    isBackstageOrder () {
+      return this.orderDetail?.orderData?.is_backstage_order || 0;
+    },
     returnStatus() {
       const val = this.orderDetail?.orderData?.return_status || 0;
       if (val == 0) {