xiaohaizhao há 6 meses atrás
pai
commit
700a15a4f0

+ 126 - 63
packageA/targetBoard/index.js

@@ -25,6 +25,7 @@ Page({
         date: Date.now(),
         date: Date.now(),
       }
       }
     }).then(res => {
     }).then(res => {
+      console.log("当前业务员区域", res)
       if (res.code != 1) return wx.showToast({
       if (res.code != 1) return wx.showToast({
         title: res.msg,
         title: res.msg,
         icon: "none"
         icon: "none"
@@ -81,120 +82,178 @@ Page({
       class: 'mzp'
       class: 'mzp'
     }];
     }];
 
 
-    let total = [];
     _Http.basic({
     _Http.basic({
       "id": "2025103015304303",
       "id": "2025103015304303",
       "content": {
       "content": {
         "pageNumber": 1,
         "pageNumber": 1,
         "pageSize": 20,
         "pageSize": 20,
         "year": 2025,
         "year": 2025,
-        date: Date.now(),
+        date123: Date.now(),
         "where": {
         "where": {
           "areaname2": "",
           "areaname2": "",
-          "areaname3": this.data.currentUser.areaname,
+          "areaname3": this.data.currentUser.areaname == '全国' ? '' : this.data.currentUser.areaname,
           "province": "",
           "province": "",
           "status": "启用"
           "status": "启用"
         }
         }
       }
       }
     }).then(res => {
     }).then(res => {
-      // console.log("回款明细", res)
+      console.log("回款明细", res)
       if (res.code != 1) return wx.showToast({
       if (res.code != 1) return wx.showToast({
         title: res.msg,
         title: res.msg,
         icon: "none"
         icon: "none"
       });
       });
+      let areaMap = new Map();
       let paymentDetails = res.data.map((v, index1) => {
       let paymentDetails = res.data.map((v, index1) => {
+        // 初始化基础列
         v.cols = [{
         v.cols = [{
-          label: '区域',
-          value: v.areaname3,
-          style: 'width:150rpx;'
-        }, {
-          label: '省份',
-          value: v.province,
-          style: 'width:120rpx;'
-        }, {
-          label: '经销商名称',
-          value: v.enterprisename,
-          style: 'width:220rpx;	position: sticky;left: 0;border-right:1px solid #999;z-index: 1;'
-        }]
+            label: '区域',
+            value: v.areaname3,
+            style: 'width:150rpx;'
+          },
+          {
+            label: '省份',
+            value: v.province,
+            style: 'width:120rpx;'
+          },
+          {
+            label: '经销商名称',
+            value: v.enterprisename,
+            style: 'width:220rpx; position: sticky; left: 0; border-right:1px solid #999; z-index: 1;'
+          }
+        ];
 
 
-        let item = total.find(t => t.areaname3 === v.areaname3);
+        // 查找或创建区域项(Map 替代 find)
+        let item = areaMap.get(v.areaname2);
         if (!item) {
         if (!item) {
           item = {
           item = {
-            areaname3: v.areaname3,
+            areaname2: v.areaname2,
             row: []
             row: []
-          }
-          total.push(item);
+          };
+          areaMap.set(v.areaname2, item);
         }
         }
-        for (let index = 1; index <= 12; index++) {
+
+        // 遍历12个月数据
+        for (let month = 1; month <= 12; month++) {
           keys.forEach((s, si) => {
           keys.forEach((s, si) => {
-            const key = s.key + index + '' + s.number,
-              value = v[key];
+            const key = `${s.key}${month}${s.number}`;
+            const value = Number(v[key]) || 0;
+
+            // 添加列
             v.cols.push({
             v.cols.push({
               ...s,
               ...s,
               value: this.CNY(value)
               value: this.CNY(value)
-            })
+            });
             delete v[key];
             delete v[key];
-            if (!item.row[index - 1]) item.row[index - 1] = [];
+
+            // 初始化行数据
+            if (!item.row[month - 1]) item.row[month - 1] = [];
+
+            // 判断是否参与合计
             if (['现金账户回款', '小计', '工程账户回款'].includes(s.label)) {
             if (['现金账户回款', '小计', '工程账户回款'].includes(s.label)) {
-              item.row[index - 1][si] = (item.row[index - 1][si] || 0) + (value - 0);
+              item.row[month - 1][si] = (item.row[month - 1][si] || 0) + value;
             } else {
             } else {
-              item.row[index - 1][si] = item.row[index - 1][si] || 0;
+              item.row[month - 1][si] = item.row[month - 1][si] || 0;
             }
             }
-          })
+          });
         }
         }
-        item.index = index1 + total.length;
-        return v
-      })
-      const monthWidth = this.getTotalWidth(keys),
-        headerRow = [{
+
+        // 暂存插入位置
+        item.index = index1 + areaMap.size;
+        return v;
+      });
+
+      // 将 Map 转回数组
+      const total = Array.from(areaMap.values());
+
+      // 初始化表头
+      const monthWidth = this.getTotalWidth(keys);
+
+      let headerRow = [{
           label: '',
           label: '',
           value: '',
           value: '',
           style: 'width:150rpx;'
           style: 'width:150rpx;'
-        }, {
+        },
+        {
           label: '',
           label: '',
           value: '',
           value: '',
           style: 'width:120rpx;'
           style: 'width:120rpx;'
-        }, {
+        },
+        {
           label: '月份',
           label: '月份',
           value: '',
           value: '',
-          style: 'width:220rpx;	position: sticky;left: 0;border-right:1px solid #999;z-index: 1;'
-        }];
+          style: 'width:220rpx; position: sticky; left: 0; border-right:1px solid #999; z-index: 1;'
+        }
+      ];
+
+      // ✅ 新增:一次性生成 12 个月标题列
+      for (let month = 1; month <= 12; month++) {
+        headerRow.push({
+          label: `${this.data.currentYear}-${month}月`,
+          value: '',
+          style: `width: ${monthWidth}rpx; text-align: center; border-top: 1px solid #999;`
+        });
+      }
+
+      // 合计行插入
       total.forEach((t, ti) => {
       total.forEach((t, ti) => {
         t.cols = [{
         t.cols = [{
-          label: '区域',
-          value: '',
-          style: 'width:150rpx;'
-        }, {
-          label: '省份',
-          value: '',
-          style: 'width:120rpx;'
-        }, {
-          label: '经销商名称',
-          value: t.areaname3 + '合计',
-          style: 'width:220rpx;	position: sticky;left: 0;border-right:1px solid #999;z-index: 1;'
-        }]
-        t.row.forEach((r, ri) => {
-          if (ti == 1) headerRow.push({
-            label: `${this.data.currentYear}-${ri + 1}月`,
+            label: '区域',
             value: '',
             value: '',
-            style: `width: ${monthWidth}rpx;text-align: center;border-top: 1px solid #999;`
-          })
+            style: 'width:150rpx;'
+          },
+          {
+            label: '省份',
+            value: '',
+            style: 'width:120rpx;'
+          },
+          {
+            label: '经销商名称',
+            value: `${t.areaname2}合计`,
+            style: 'width:220rpx; position: sticky; left: 0; border-right:1px solid #999; z-index: 1;'
+          }];
+
+        t.row.forEach((r, ri) => {
           keys.forEach((s, si) => {
           keys.forEach((s, si) => {
+            const isSummaryField = ['现金账户回款', '小计', '工程账户回款'].includes(s.label);
+            const rawValue = r[si] || 0;
+            const displayValue = isSummaryField ? this.CNY(rawValue) : '-';
             t.cols.push({
             t.cols.push({
               ...s,
               ...s,
-              value: this.CNY(r[si] || 0)
-            })
-          })
-        })
-        let index = t.index;
+              value: displayValue
+            });
+          });
+        });
+
+        const index = t.index;
         delete t.index;
         delete t.index;
-        paymentDetails.splice(index, 0, t)
-      })
+        paymentDetails.splice(index, 0, t);
+      });
       this.setData({
       this.setData({
-        paymentDetails,
         totalWidth: paymentDetails.length ? this.getTotalWidth(paymentDetails[0].cols) : this.data.totalWidth,
         totalWidth: paymentDetails.length ? this.getTotalWidth(paymentDetails[0].cols) : this.data.totalWidth,
         headerRow: paymentDetails.length ? headerRow : []
         headerRow: paymentDetails.length ? headerRow : []
-      })
+      });
+
+      // 分批渲染数据
+      const BATCH_SIZE = 100; // 每批渲染条数
+      let renderedData = [];
+      let currentIndex = 0;
+
+      const renderBatch = () => {
+        if (currentIndex < paymentDetails.length) {
+          const nextBatch = paymentDetails.slice(currentIndex, currentIndex + BATCH_SIZE);
+          renderedData = renderedData.concat(nextBatch);
+          this.setData({
+            paymentDetails: renderedData
+          });
+          currentIndex += BATCH_SIZE;
+
+          // 延迟渲染下一批,避免阻塞主线程
+          setTimeout(renderBatch, 0);
+        }
+      };
+
+      // 开始分批渲染
+      renderBatch();
     })
     })
   },
   },
   getTotalWidth(cols) {
   getTotalWidth(cols) {
@@ -217,6 +276,7 @@ Page({
         date: Date.now(),
         date: Date.now(),
       }
       }
     }).then(res => {
     }).then(res => {
+      console.log("业务员及其下属区域", res)
       if (res.code != 1) return wx.showToast({
       if (res.code != 1) return wx.showToast({
         title: res.msg,
         title: res.msg,
         icon: "none"
         icon: "none"
@@ -238,6 +298,7 @@ Page({
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "year": this.data.currentYear,
         "year": this.data.currentYear,
         "month": this.data.currentMonth,
         "month": this.data.currentMonth,
+        hrid: wx.getStorageSync('userMsg').hrid,
         date: Date.now(),
         date: Date.now(),
       }
       }
     }).then(res => {
     }).then(res => {
@@ -272,6 +333,7 @@ Page({
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "year": this.data.currentYear,
         "year": this.data.currentYear,
         "month": this.data.currentMonth,
         "month": this.data.currentMonth,
+        hrid: wx.getStorageSync('userMsg').hrid,
         date: Date.now(),
         date: Date.now(),
       }
       }
     }).then(res => {
     }).then(res => {
@@ -303,6 +365,7 @@ Page({
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "sa_saleareaid": this.data.currentUser.sa_saleareaid,
         "year": this.data.currentYear,
         "year": this.data.currentYear,
         "months": this.data.months, // 默认或用户选择的月份区间
         "months": this.data.months, // 默认或用户选择的月份区间
+        hrid: wx.getStorageSync('userMsg').hrid,
         date: Date.now(),
         date: Date.now(),
       }
       }
     }).then(res => {
     }).then(res => {

+ 1 - 1
packageA/targetBoard/index.scss

@@ -85,7 +85,7 @@
 				}
 				}
 
 
 				&-value {
 				&-value {
-					font-size: 40rpx;
+					font-size: 30rpx;
 					font-weight: bold;
 					font-weight: bold;
 					color: #000;
 					color: #000;
 
 

+ 8 - 8
packageA/targetBoard/index.wxml

@@ -6,7 +6,7 @@
 	<view class="title">
 	<view class="title">
 		营销区域
 		营销区域
 
 
-		<picker mode='selector' range='{{areaList}}' value="{{currentUser.rowindex-1}}" range-key='key' class="right-box" bindchange='changeSalearea'>
+		<picker mode='selector' wx:if="{{currentUser.key}}" range='{{areaList}}' value="{{currentUser.rowindex-1}}" range-key='key' class="right-box" bindchange='changeSalearea'>
 			{{currentUser.key}}
 			{{currentUser.key}}
 		</picker>
 		</picker>
 	</view>
 	</view>
@@ -27,7 +27,7 @@
 				<view class='grid-container-item-value'>{{ monthlyMetrics.completedamount  }}</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.completedamount  }}</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
-				<view class='grid-container-item-label'>上月完成额超出部分</view>
+				<view class='grid-container-item-label'>上月超额完成</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.previousexceed  }}</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.previousexceed  }}</view>
 			</view>
 			</view>
 		</view>
 		</view>
@@ -61,7 +61,7 @@
 		</view>
 		</view>
 		<view class="grid-container">
 		<view class="grid-container">
 			<view class="grid-container-item">
 			<view class="grid-container-item">
-				<view class='grid-container-item-label'>完成额超出100%的部分</view>
+				<view class='grid-container-item-label'>超额完成部分</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.completedamountexceed100 }}</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.completedamountexceed100 }}</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
@@ -69,9 +69,9 @@
 				<view class='grid-container-item-value'>{{ monthlyMetrics.actualcompletedamount }}</view>
 				<view class='grid-container-item-value'>{{ monthlyMetrics.actualcompletedamount }}</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
-				<view class='grid-container-item-label'>当月实际完成\n百分比</view>
+				<view class='grid-container-item-label'>当月实际完成%</view>
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
-					monthlyMetrics.actualcompletedpercentage  }}</view>
+					monthlyMetrics.actualcompletedpercentage }}%</view>
 			</view>
 			</view>
 		</view>
 		</view>
 	</view>
 	</view>
@@ -89,7 +89,7 @@
 				<view class='grid-container-item-value'>{{ quarterlyMetrics.completedamount }}</view>
 				<view class='grid-container-item-value'>{{ quarterlyMetrics.completedamount }}</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
-				<view class='grid-container-item-label'>上季度完成额超出部分</view>
+				<view class='grid-container-item-label'>上季度超额完成</view>
 				<view class='grid-container-item-value'>{{ quarterlyMetrics.previousexceed}}</view>
 				<view class='grid-container-item-value'>{{ quarterlyMetrics.previousexceed}}</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
@@ -107,7 +107,7 @@
 			<view class="grid-container-item">
 			<view class="grid-container-item">
 				<view class='grid-container-item-label'>季度百分比</view>
 				<view class='grid-container-item-label'>季度百分比</view>
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
-					quarterlyMetrics.actualcompletedpercentage }}</view>
+					quarterlyMetrics.actualcompletedpercentage }}%</view>
 			</view>
 			</view>
 		</view>
 		</view>
 	</view>
 	</view>
@@ -146,7 +146,7 @@
 			<view class="grid-container-item">
 			<view class="grid-container-item">
 				<view class='grid-container-item-label'>百分比</view>
 				<view class='grid-container-item-label'>百分比</view>
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
 				<view class='grid-container-item-value' style="color: #D9001B;">{{
-					overallMetrics.actualcompletedpercentage }}</view>
+					overallMetrics.actualcompletedpercentage }}%</view>
 			</view>
 			</view>
 			<view class="grid-container-item">
 			<view class="grid-container-item">
 				<view class='grid-container-item-label'>距70%差额</view>
 				<view class='grid-container-item-label'>距70%差额</view>