yanym 5 роки тому
батько
коміт
edd0a622ae

+ 2 - 2
dorm-manager-wx/pages/student/statistics/statistics.wxml

@@ -12,7 +12,7 @@
           <view class="data-text">{{startdata}}</view>
         </view>
         <image class="jiantou" src="/images/jiantou-bottom.png"></image>
-      </view>      
+      </view>
     </picker>
   </view>
   <view class="top-line">
@@ -24,7 +24,7 @@
           <view class="data-text">{{enddata}}</view>
         </view>
         <image class="jiantou" src="/images/jiantou-bottom.png"></image>
-      </view>      
+      </view>
     </picker>
   </view>
 </view>

+ 89 - 7
dorm-manager-wx/pages/teacher/statistics/statistics.js

@@ -10,11 +10,17 @@ Page({
    * 页面的初始数据
    */
   data: {
+    userInfo: '',
     totalInfo: '',
     startDate: '2019-10-29',
     endDate: '2019-10-29',
-    scopeIndex: 0,
-    scopeArray: ['全部人员'],
+    listCollege: '',
+    listDept: '',
+    userArray: [
+      [],
+      []
+    ],
+    value: [0, 0],
     weiguiList: []
   },
 
@@ -30,12 +36,80 @@ Page({
     })
   },
 
-  bindScopeChange: function(e) {
-    this.setData({
-      scopeIndex: e.detail.value
+  getCollegeInfo: function(e) {
+    const that = this;
+    util.httpRequest(api.getDeptInfo, {
+      companyId: that.data.userInfo.companyId,
+      level: 1
+    }, 'post').then(res => {
+      let arrayCollege = [];
+      if (res.data.length >= 1) {
+        for (let i = 0; i < res.data.length; i++) {
+          arrayCollege.push(res.data[i].deptName)
+          if (i == res.data.length - 1) {
+            let userArray = that.data.userArray;
+            userArray[0] = arrayCollege;
+            that.setData({
+              userArray: userArray,
+              listCollege: res.data
+            })
+            that.getDeptInfo();
+          }
+        }
+      }
+    })
+  },
+
+  getDeptInfo: function(e) {
+    const that = this;
+    util.httpRequest(api.getDeptInfo, {
+      companyId: that.data.userInfo.companyId,
+      parentId: that.data.listCollege[that.data.value[0]].deptId
+    }, 'post').then(res => {
+      let arrayDept = [];
+      if (res.data.length >= 1) {
+        for (let i = 0; i < res.data.length; i++) {
+          arrayDept.push(res.data[i].deptName)
+          if (i == res.data.length - 1) {
+            let userArray = that.data.userArray
+            userArray[1] = arrayDept
+            that.setData({
+              userArray: userArray,
+              listDept: res.data
+            })
+            that.getStatisticsInfo();
+          }
+        }
+      } else {
+        let userArray = that.data.userArray;
+        userArray[1] = arrayDept
+        that.setData({
+          userArray: userArray,
+          listDept: '',
+          list: ''
+        })
+      }
     })
   },
 
+  bindUserChange: function(e) {
+
+  },
+
+  columnChange: function(e) {
+    const that = this;
+    let value = that.data.value
+    value[e.detail.column] = e.detail.value
+    that.setData({
+      value: value
+    })
+    if (e.detail.column == 0) {
+      that.getDeptInfo()
+    } else if (e.detail.column == 1) {
+      that.getStatisticsInfo();
+    }
+  },
+
   getChart: function(e) {
     const that = this;
     ringChart = new wxCharts({
@@ -91,9 +165,16 @@ Page({
 
   getStatisticsInfo: function(e) {
     const that = this;
+    let deptId;
+    if (that.data.listDept != '') {
+      deptId = that.data.listDept[that.data.value[1]].deptId
+    } else {
+      deptId = that.data.listCollege[that.data.value[0]].deptId
+    }
     util.httpRequest(api.getStatisticsInfo, {
       start: that.data.startDate,
-      end: that.data.endDate
+      end: that.data.endDate,
+      deptId: deptId
     }, 'post').then(res => {
       that.setData({
         totalInfo: res.data.data
@@ -133,7 +214,8 @@ Page({
    */
   onLoad: function(options) {
     const that = this;
-    that.getStatisticsInfo();
+    that.data.userInfo = wx.getStorageSync('user');
+    that.getCollegeInfo();
     that.getUnInInfo();
     that.getOutAndInInfo();
   },

+ 2 - 2
dorm-manager-wx/pages/teacher/statistics/statistics.wxml

@@ -34,9 +34,9 @@
       <view class="desc-t">查询范围</view>
     </view>
     <view class="my-row my-align-c">
-      <picker value="{{scopeIndex}}" range="{{scopeArray}}" bindchange="bindScopeChange">
+      <picker value="{{value}}" mode='multiSelector' range="{{userArray}}" bindchange="bindUserChange" bindcolumnchange='columnChange'>
         <view class="desc-t">
-          {{scopeArray[scopeIndex]}}
+          {{userArray[0][value[0]]}}{{userArray[1][value[1]]}}
         </view>
       </picker>
       <image src="/images/jiantou-bottom.png" class="icon-bottom"></image>

+ 1 - 1
dorm-manager-wx/utils/api.js

@@ -101,7 +101,7 @@ const index = 2,
     getVisitorCheckInfo: 'visitor/visitorInfo.if', //获取审批中和已审批的访客信息
     getDeviceInfo: 'access/selectDevices.if', //获取所有设备信息
     getPassInfo: '/access/getAccess.if', //通行记录
-    getStatisticsInfo: '/access/statistics.if', //考勤统计
+    getStatisticsInfo: '/access/statisticsBy.if', //考勤统计
     getOutAndInInfo: '/access/outAndIn.if', //已出已归记录
     getVisitorInfo: '/visitor/searchInviteVisitor.if', //查询访客详情
     getVisitorCheck: '/visitor/approvalAlumniVisitor.if', //访客信息审批