Переглянути джерело

1、完成首页切换日期查询成交额和收款额

zhoux 2 роки тому
батько
коміт
6f181659f7

+ 2 - 0
api/pages/mac/account.js

@@ -14,6 +14,8 @@ module.exports = {
 		getAccount:'get_account/',
 		getReceivableAccountItem:'get_receivable_account_item/',
 		getReceivableAccountItemCount:'get_account_item_count/',
+		// 查询应收收款总额(制单员权限)
+		getReceivableAccountSum:'get_receivable_account_sum',
 	},
 
 	routeUrl: {

+ 71 - 10
pages/home-page/home-page.js

@@ -21,15 +21,18 @@ Page({
    * 页面的初始数据
    */
   data: {
+    dateType: 'week',// week本周, month本月
     swiperIndex: 0,
-    imageUrl:config.image_url + '/static/img/',
+    imageUrl: config.image_url + '/static/img/',
     advertisementList: [], // 广告数据
     // 分页flg
     pageFlag: false,
     comMenuList: [],// 常用功能
     companyName: null,
-    transactionAmount: '¥11,850.00',
-    collectionAmount: '¥10,850.00',
+    // 成交额
+    transactionAmount: 0,
+    // 收款额
+    collectionAmount: 0,
     //功能分类-大功能模块-页面
     functionItems: [
       {
@@ -132,12 +135,68 @@ Page({
   * @author : 周兴
   * @date : 2024/4/1
   */
-  changeCp(){
+  changeCp() {
     wx.navigateTo({
       url: '/pages/company/company',
     })
   },
   /**
+  * @desc : 切换日期查询成交额和收款额
+  * @author : 周兴
+  * @date : 2024/4/1
+  */
+  changeDate() {
+    let dateType = this.data.dateType;
+    dateType = dateType == 'month' ? 'week' : 'month';
+    console.log('dateType',dateType);
+    // 查询应收和收款
+    this.getReceivableAccountSum(dateType);
+    this.setData({
+      dateType: dateType
+    })
+  },
+  /**
+  * @desc : 查询应收和收款
+  * @author : 周兴
+  * @date : 2024/4/3
+  */
+  getReceivableAccountSum(dateType) {
+
+    let now = new Date();
+    let params = {
+      staffId: app.globalData.user.staffId,
+    }
+    // 本周
+    if (dateType == 'week') {
+      params['accDateStart'] = now.getWeekFirstDay()
+      params['accDateEnd'] = now.getWeekLastDay()
+    } else if (dateType == 'month') {
+      params['accDateStart'] = now.getFirstDateStr()
+      params['accDateEnd'] = now.getLastDateStr()
+    }
+    let service = app.globalData['accountService']
+    api.request(service.prefix + service.getReceivableAccountSum, 'POST', params).then(res => {
+      if (res.data.code == Constants.SUCESS_CODE) {
+        console.log('eee', res.data);
+        if (res.data && res.data.data) {
+          this.setData({
+            transactionAmount: res.data.data.receivable,
+            collectionAmount: res.data.data.receipt,
+          })
+        }
+        // if (res.data && res.data.data) {
+        //   let advertisementList = res.data.data
+        //   advertisementList.forEach(it => {
+        //     it.adPath = config.image_url + it.adPath
+        //   })
+        //   this.setData({
+        //     advertisementList: advertisementList
+        //   })
+        // }
+      }
+    });
+  },
+  /**
   * @desc : 查询广告
   * @author : 周兴
   * @date : 2024/4/1
@@ -145,18 +204,18 @@ Page({
   getAdvertisement() {
     let params = {
       appCode: Constants.APP_CODE,
-      gradeCode:app.globalData.company.gradeCode
+      gradeCode: app.globalData.company.gradeCode
     }
     let service = app.globalData['advertisementService']
     api.request(service.prefix + service.selectByCond, 'POST', params).then(res => {
       if (res.data.code == Constants.SUCESS_CODE) {
-        if(res.data && res.data.data){
+        if (res.data && res.data.data) {
           let advertisementList = res.data.data
-          advertisementList.forEach(it=>{
+          advertisementList.forEach(it => {
             it.adPath = config.image_url + it.adPath
           })
           this.setData({
-            advertisementList:advertisementList
+            advertisementList: advertisementList
           })
         }
       }
@@ -254,15 +313,17 @@ Page({
       }
     })
     this.setData({
-      companyName:app.globalData.company.cpName
+      companyName: app.globalData.company.cpName
     })
     // 查询广告数据
     this.getAdvertisement();
+    // 查询应收和收款额
+    this.getReceivableAccountSum(this.data.dateType);
     // options 中的 scene  
     if (options.scene) {
       // var scene = options.scene
       var scene = decodeURLComponent(options.scene)
-    let openid = scene.s
+      let openid = scene.s
 
       // 邀请员工的确认
       wx.navigateTo({

+ 8 - 6
pages/home-page/home-page.wxml

@@ -5,7 +5,7 @@
 <!-- 顶部 -->
 <view class="head">
   <!-- 公司 -->
-  <view class="company" >
+  <view class="company">
     <view style="display: flex;align-items: center;" catchtap="changeCp">
       <view style="margin-right: 10rpx;">
         {{companyName?companyName:''}}
@@ -13,14 +13,16 @@
       <image src="/static/image/triangle.png" style="width: 28rpx;height:28rpx;"></image>
     </view>
     <!-- 本月本周 -->
-    <view class="current_month_week">
-      <view>{{$t['currentWeek']}}</view>
-      <view style="color: #b6b6b6;">{{$t['currentMonth']}}</view>
+    <view style="display: flex;justify-content: center;width: calc(100% - 100rpx);">
+      <view class="current_month_week">
+        <view class="current_week_text" style="color:{{dateType=='week'?'#ffffff':'#b6b6b6'}}" catchtap="changeDate">{{$t['currentWeek']}}</view>
+        <view class="current_month_text" style="color:{{dateType=='month'?'#ffffff':'#b6b6b6'}}" catchtap="changeDate">{{$t['currentMonth']}}</view>
+      </view>
     </view>
     <view style="height: 1rpx;background-color: white;margin-top: 20rpx; width: 90%;"></view>
     <view class="current_month_week_amount">
-      <view>{{$t['transactionAmount']}} {{transactionAmount}}</view>
-      <view>{{$t['collectionAmount']}} {{collectionAmount}}</view>
+      <dk-cell contentFontSize="17" height="25rpx" left="0rpx" contentColor="#FFFFFF" title="{{$t['transactionAmount']}}" content="{{ transactionAmount}}"></dk-cell>
+      <dk-cell contentFontSize="17" height="25rpx" left="0rpx" contentColor="#FFFFFF" title="{{$t['collectionAmount']}}" content="{{ collectionAmount}}"></dk-cell>
     </view>
   </view>
 </view>

+ 17 - 4
pages/home-page/home-page.wxss

@@ -21,21 +21,34 @@ page {
   color: #F8F9FD;
 }
 
+
 .current_month_week {
-  width: 80%;
+  width: 100%;
   margin-top: 40rpx;
   font-size: 28rpx;
   display: flex;
-  justify-content: space-around;
+  justify-content: space-between;
   align-items: center;
 }
 
+.current_week_text{
+  width: 30%;
+  display: flex;
+  justify-content: flex-end;
+}
+
+.current_month_text{
+  width: 30%;
+  display: flex;
+  justify-content: flex-start;
+}
+
 .current_month_week_amount {
-  width: 80%;
+  width: 85%;
   margin-top: 20rpx;
   font-size: 28rpx;
   display: flex;
-  justify-content: space-around;
+  justify-content: space-between;
   align-items: center;
 }
 

+ 1 - 1
utils/prototype/prototypeDatetime.js

@@ -286,7 +286,7 @@ Date.prototype.getFirstDateStr = function () {
  */
 Date.prototype.getLastDateStr = function () {
   let year = this.getFullYear();
-  let month = this.getMonth() + 1;
+  let month =  String(this.getMonth() + 1).padStart(2, '0')
   let day = new Date(year, month, 0).getDate();
   return year + '-' + month + '-' + day;
 }