瀏覽代碼

feat: 优先选中数据包逻辑修改

zhangyuhan 4 年之前
父節點
當前提交
c1f04dc54e
共有 1 個文件被更改,包括 45 次插入24 次删除
  1. 45 24
      src/web/templates/pc/createOrderPage.html

+ 45 - 24
src/web/templates/pc/createOrderPage.html

@@ -680,18 +680,24 @@
             online: false
         }
 
+        function checkMaxOfSurplus () {
+            return pageDataMap.msgCount <= maxItem.surplus
+        }
+
         // 数据流量包
         if (pageDataMap.dataExportPackInfo) {
             var parentDom = $("#select-ent-datapack .switch-dataType")
             // 数据流量包  线下
             if (pageDataMap.dataExportPackInfo.entPack) {
                 pageDataMap.dataExportPackInfo.entPack.forEach(function (v) {
-                    if (v.surplusToday >= maxItem.surplus) {
-                        maxItem = {
-                            entId:  v.entId,
-                            level: -1,
-                            surplus: v.surplusToday,
-                            online: false
+                    if (!checkMaxOfSurplus()) {
+                        if (v.surplusToday >= maxItem.surplus) {
+                            maxItem = {
+                                entId:  v.entId,
+                                level: -1,
+                                surplus: v.entAllCount >= v.surplusToday ? v.surplusToday : v.entAllCount,
+                                online: false
+                            }
                         }
                     }
                     var tempDom = $("#select-ent-item-template").clone()
@@ -704,27 +710,31 @@
             }
             // 数据流量包  线上
             if (pageDataMap.dataExportPackInfo.personalPack) {
-                if (pageDataMap.dataExportPackInfo.personalPack.normalTotal > 0) {
-                    if (pageDataMap.dataExportPackInfo.personalPack.normalTotal >= maxItem.surplus) {
-                        maxItem = {
-                            entId: -1,
-                            level: 1,
-                            surplus: pageDataMap.dataExportPackInfo.personalPack.normalTotal,
-                            online: true
+                if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal > 0) {
+                    if (!checkMaxOfSurplus()) {
+                        if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal >= maxItem.surplus) {
+                            maxItem = {
+                                entId: -1,
+                                level: 2,
+                                surplus: pageDataMap.dataExportPackInfo.personalPack.seniorTotal,
+                                online: true
+                            }
                         }
                     }
-                    createTempDom(1, parentDom)
+                    createTempDom(2, parentDom)
                 }
-                if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal > 0) {
-                    if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal >= maxItem.surplus) {
-                        maxItem = {
-                            entId: -1,
-                            level: 2,
-                            surplus: pageDataMap.dataExportPackInfo.personalPack.seniorTotal,
-                            online: true
+                if (pageDataMap.dataExportPackInfo.personalPack.normalTotal > 0) {
+                    if (!checkMaxOfSurplus()) {
+                        if (pageDataMap.dataExportPackInfo.personalPack.normalTotal >= maxItem.surplus) {
+                            maxItem = {
+                                entId: -1,
+                                level: 1,
+                                surplus: pageDataMap.dataExportPackInfo.personalPack.normalTotal,
+                                online: true
+                            }
                         }
                     }
-                    createTempDom(2, parentDom)
+                    createTempDom(1, parentDom)
                 }
             }
             // 移除模版
@@ -738,6 +748,17 @@
                 // 默认加载第一项去重数据
                 var attrId =  parentDom.children('.no-select').eq(0).attr('data-id')
                 var attrLevel = parentDom.children('.no-select').eq(0).attr('data-level')
+                // 都不满足时默认选中线下
+                if (!checkMaxOfSurplus() && maxItem.online) {
+                    if (attrId) {
+                        maxItem = {
+                            entId:  attrId,
+                            level: -1,
+                            surplus: 0,
+                            online: false
+                        }
+                    }
+                }
                 if (maxItem.online) {
                     attrLevel = maxItem.level
                     attrId = -1
@@ -747,12 +768,12 @@
                     attrId = maxItem.entId
                     parentDom.children('.no-select[data-id="'+attrId+'"]').addClass('active')
                 }
-                if (attrId) {
+                if (attrId != -1) {
                     pageDataMap.typeMap['数据流量包'].entId = attrId
                     getExportForRepeatInfo({
                         entId: attrId
                     }, false)
-                } else if (attrLevel) {
+                } else if (attrLevel != -1) {
                     pageDataMap.typeMap['数据流量包'].level = attrLevel
                     pageDataMap.typeMap['数据流量包'].online = true
                     getExportForRepeatInfo({