zhaoxiaohai 2 年之前
父節點
當前提交
154a2f3481
共有 4 個文件被更改,包括 129 次插入12 次删除
  1. 85 5
      packageA/target/index.js
  2. 6 5
      packageA/target/index.json
  3. 26 1
      packageA/target/index.scss
  4. 12 1
      packageA/target/index.wxml

+ 85 - 5
packageA/target/index.js

@@ -2,8 +2,14 @@ const _Http = getApp().globalData.http;
 
 Page({
     data: {
+        showText: "全部",
+        popupShow: false,
+        activeId: null,
+        mainActiveIndex: 0,
         active: "业绩目标",
         targetYear: null,
+        hrid: null,
+        departmentid: null,
         "year": new Date().getFullYear().toString(),
         "content": {
             "nocache": true,
@@ -29,10 +35,77 @@ Page({
         }],
     },
     onLoad(options) {
-        this.getData();
+        /* 获取部门列表 */
+        _Http.basic({
+            "id": 20220922113302,
+            "content": {
+                pageSize: 9999
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            let hrList = res.data.map(v => {
+                v.hr.unshift({
+                    name: v.depname + ' (包含所有下级)',
+                    hrid: v.departmentid
+                })
+                return {
+                    id: v.departmentid,
+                    text: v.depname,
+                    children: v.hr.map(value => {
+                        const text = value.position ? value.name + ` (${value.position})` : value.name
+                        return {
+                            id: value.hrid,
+                            text
+                        }
+                    })
+                }
+            })
+            this.setData({
+                hrList
+            })
+        });
     },
     onShow() {
-        console.log(123123)
+        this.getData();
+    },
+    onClickNav({
+        detail
+    }) {
+        this.setData({
+            mainActiveIndex: detail.index
+        })
+    },
+    onClickItem({
+        detail
+    }) {
+        let hrid = null,
+            departmentid = null;
+        if (detail.text.includes('包含所有下级')) {
+            departmentid = detail.id
+        } else {
+            hrid = detail.id
+        };
+        let text = detail.text.split("(")[0];
+        this.setData({
+            hrid,
+            departmentid,
+            activeId: detail.id,
+            text
+        })
+    },
+    /* 切换分析对象 */
+    openPupop() {
+        this.setData({
+            popupShow: true
+        })
+    },
+    onClose() {
+        this.setData({
+            popupShow: false
+        })
     },
     toDetail() {
         if (this.data.active == "业绩目标") {
@@ -45,12 +118,19 @@ Page({
             })
         }
     },
-    getData() {
+    getData(e) {
+        console.log(e)
+        if (e) this.setData({
+            showText: this.data.text ? this.data.text : '全部'
+        })
+        let content = this.data.content;
+        if (this.data.hrid) content.hrid = this.data.hrid;
+        if (this.data.departmentid) content.departmentid = this.data.departmentid;
         _Http.basic({
             "id": 20220920133102,
-            "content": this.data.content
+            content
         }).then(res => {
-            console.log(res)
+            this.onClose()
             if (res.msg != '成功') return wx.showToast({
                 title: res.data,
                 icon: "none"

+ 6 - 5
packageA/target/index.json

@@ -1,7 +1,8 @@
 {
-  "usingComponents": {
-    "brokenLine": "./modules/brokenLine/index",
-    "histogram": "./modules/histogram/index"
-  },
-  "navigationBarTitleText": "销售目标"
+    "usingComponents": {
+        "brokenLine": "./modules/brokenLine/index",
+        "histogram": "./modules/histogram/index",
+        "van-tree-select": "@vant/weapp/tree-select/index"
+    },
+    "navigationBarTitleText": "销售目标"
 }

+ 26 - 1
packageA/target/index.scss

@@ -1,3 +1,18 @@
+.header {
+    height: 90rpx;
+    line-height: 90rpx;
+    width: 100vw;
+    text-align: center;
+    font-size: 28rpx;
+    font-family: PingFang SC-Bold, PingFang SC;
+    font-weight: bold;
+    color: #333333;
+    border-bottom: 1rpx solid #dddddd;
+    box-sizing: border-box;
+    position: fixed;
+    top: 0;
+}
+
 .tab-class {
     font-size: 28rpx;
     font-family: PingFang SC-Bold, PingFang SC;
@@ -128,7 +143,7 @@
     align-items: center;
     bottom: 0;
     background-color: #fff;
-    z-index: 999999999999999999999999999999999999999;
+    z-index: 9;
 
     .but {
         width: 500rpx;
@@ -140,4 +155,14 @@
         font-weight: bold;
         color: #FFFFFF;
     }
+}
+
+.content-item-class {
+    font-size: 28rpx !important;
+    font-family: PingFang SC-Regular, PingFang SC !important;
+    color: #000000;
+}
+
+.content-active-class {
+    color: #3874F6 !important;
 }

+ 12 - 1
packageA/target/index.wxml

@@ -2,9 +2,10 @@
     <van-tab title="业绩目标" />
     <van-tab title="业绩项目目标" />
 </van-tabs>
+
 <!-- 过滤 -->
 <view class="filtrate">
-    <view>全部<text class="iconfont icon-daoruxialajiantou" /></view>
+    <view bindtap="openPupop">{{showText}}<text class="iconfont icon-daoruxialajiantou" /></view>
     <view catchtap="openActions">
         {{actionSheet}}<text class="iconfont icon-daoruxialajiantou" />
     </view>
@@ -14,6 +15,16 @@
 </view>
 <van-action-sheet show="{{ showActions }}" actions="{{ actions }}" bind:select='select' bind:cancel='cancelActions' cancel-text="取消" />
 
+
+<van-popup show="{{ popupShow }}" position="bottom" custom-style="height:100%;" round closeable bind:close="onClose">
+    <view class="header">选择分析对象</view>
+    <view style="height: 90rpx;" />
+    <van-tree-select items="{{ hrList }}" content-item-class='content-item-class' content-active-class='content-active-class' height='calc(100% - 170rpx)' main-active-index="{{ mainActiveIndex }}" active-id="{{ activeId }}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
+    <view class="footer" style="height: 170rpx;">
+        <van-button custom-class='but' catchtap="getData">确定</van-button>
+    </view>
+</van-popup>
+
 <view class="box">
     <view class="label">
         <text class="iconfont icon-a-shouyeshujugaikuangzhanshishuju" />