Ver Fonte

由部门改为区域

xiaohaizhao há 4 meses atrás
pai
commit
5a0846d22e

+ 78 - 59
components/organization/index.js

@@ -21,8 +21,8 @@ Component({
             type: Boolean
         },
         defaultIsleave: {
-            type: [Number, String],
-            value: 0
+            type: [Number, String], // 0 在职 1离职 空全部
+            value: "0"
         }
     },
     data: {
@@ -31,26 +31,26 @@ Component({
             name: ""
         },
         users: {
+            label: "业务员",
             active: {}
         },
-        isleave: 1,
+        isleave: "0",
         tabs: [{
-            value: 0,
+            value: "",
             name: "全部"
         }, {
-            value: 1,
+            value: "0",
             name: "在职"
         }, {
-            value: 2,
+            value: "1",
             name: "离职"
         }],
         searchValue: "",
-        depGroud: []
+        depGroud: [],
+        userObj: {}
     },
     lifetimes: {
-        attached: function () {
-            getApp().globalData.Language.getLanguagePackage(this)
-        }
+        attached: function () {}
     },
     methods: {
         searchChange({
@@ -72,68 +72,85 @@ Component({
                 isleave: e.currentTarget.dataset.value,
                 'result.isleave': e.currentTarget.dataset.value
             })
-            console.log("result", this.data.result)
-            this.initDepAndUser(false);
+            this.getUsers()
         },
         initDepAndUser(init = true) {
             if (init) this.setData({
                 takeEffect: "", //生效筛选项
                 result: {},
             })
-            let content = {
-                isleave: this.data.isleave
-            }
             return new Promise((resolve) => {
                 _Http.basic({
-                    "id": 20230620102004,
-                    content
+                    "classname": "webmanage.sale.salearea.salearea",
+                    "method": "query_area",
+                    "content": {},
                 }).then(res => {
-                    console.log("获取部门", res)
+                    console.log("获取区域", res)
                     if (this.data.isdep && this.data.depGroud.length == 0) this.setData({
                         depGroud: [{
-                            label: "部门",
-                            list: res.data.dep,
+                            label: "营销区域",
+                            list: res.data,
                             active: ""
                         }]
                     })
-                    console.log("depGroud", this.data.depGroud)
-                    console.log("result", this.data.result)
-                    console.log("active", this.data.active)
-
-                    if (this.data.isusers) {
-                        let active = this.data.users.active;
-                        if (this.data.defaultMy && this.data.result.name == '') {
-                            let user = res.data.hr.find(v => v.userid == wx.getStorageSync('userMsg').userid)
-                            if (user) {
-                                active = user.userid;
-                                resolve(user)
-                                this.setData({
-                                    takeEffect: "user",
-                                    result: user
-                                })
-                            } else {
-                                this.setData({
-                                    takeEffect: "",
-                                    result: {}
-                                })
-                            }
-                        }
+                    if (init) {
                         this.setData({
-                            users: {
-                                label: "业务员",
-                                list: res.data.hr,
-                                copyList: res.data.hr,
-                                active
-                            }
+                            isleave: this.data.defaultIsleave
                         })
+                        if (res.data.length) {
+                            this.selectDep({
+                                currentTarget: {
+                                    dataset: {
+                                        item: res.data[0],
+                                        index: 0
+                                    }
+                                }
+                            })
+                        }
                     }
-                    if (init) this.setData({
-                        isleave: this.data.defaultIsleave
+                    resolve(res.data.length ? res.data[0] : {
+                        sa_saleareaid: 0
                     })
-                    resolve({})
                 })
             })
         },
+        async getUsers(sa_saleareaid) {
+            let list = [],
+                userObj = this.data.userObj;
+            try {
+                if (sa_saleareaid && userObj['user' + sa_saleareaid].length) list = userObj['user' + sa_saleareaid];
+            } catch (error) {
+
+            }
+            if (!sa_saleareaid) sa_saleareaid = this.data.result.sa_saleareaid;
+            let res = {}
+            if (list.length == 0) res = await _Http.basic({
+                id: 20221011144603,
+                "content": {
+                    isExport: 0,
+                    isHasSub: 1,
+                    "pageNumber": 1,
+                    "pageSize": 999,
+                    "where": {
+                        "condition": "",
+                        status: this.data.isleave
+                    },
+                    sa_saleareaid
+                },
+            })
+            console.log("获取人员", res)
+            if (res.code == 1) {
+                userObj['user' + sa_saleareaid] = res.data;
+                list = res.data;
+            }
+
+            this.setData({
+                "users.list": list,
+                "users.copyList": JSON.parse(JSON.stringify(list)),
+                "users.active": {},
+                userObj
+            })
+        },
         selectDep(e) {
             const {
                 item,
@@ -141,22 +158,24 @@ Component({
             } = e.currentTarget.dataset;
             let depGroud = this.data.depGroud.slice(0, index + 1);
             depGroud[index].active = item.sa_saleareaid;
-            if (item.subdep.length) {
-                item.subdep.unshift(JSON.parse(JSON.stringify(item)))
-                item.subdep[0].depname = getApp().globalData.Language.getMapText('全部');
-                item.subdep[0].subdep = [];
+            if (item.subarea.length) {
+                item.subarea.unshift(JSON.parse(JSON.stringify(item)))
+                item.subarea[0].areaname = '全部';
+                item.subarea[0].subarea = [];
                 depGroud.push({
-                    label: item.depname + getApp().globalData.Language.getMapText('下级部门'),
-                    list: item.subdep,
+                    label: item.areaname + '下级区域',
+                    list: item.subarea,
                     active: item.sa_saleareaid
                 })
             }
-            item.name = item.depname
+            item.name = item.areaname
             item.isleave = this.data.isleave;
+            this.getUsers(item.sa_saleareaid)
             this.setData({
                 depGroud,
                 takeEffect: "dep",
-                result: item
+                result: item,
+                selectDepObj: item
             })
         },
         selectUser(e) {

+ 1 - 0
components/organization/index.scss

@@ -109,6 +109,7 @@
     .content {
         .active {
             border: 0px solid #3874F6;
+            padding: 0 18rpx;
             color: #333333;
             font-weight: bold;
             background-color: #F5F5F5;

+ 6 - 7
components/organization/index.wxml

@@ -1,25 +1,24 @@
-<!-- 部门筛选 -->
 <view wx:if="{{isdep}}" class="groud {{exclution && takeEffect !='dep' ? 'exclution' : '' }}" wx:for="{{depGroud}}" wx:key="label">
     <view class="title">
         <view class="label">
-            {{language[item.label]||item.label}}
+            {{item.label}}
         </view>
         <view class="tabs-box" wx:if="{{dimissionF && index==0}}">
-            <view class="item {{isleave == item.value?'active':''}}" wx:for="{{tabs}}" wx:key="{{item.value}}" data-value="{{item.value}}" bind:tap="changLeave">{{language[item.name]||item.name}}</view>
+            <view class="item {{isleave == item.value?'active':''}}" wx:for="{{tabs}}" wx:key="{{item.value}}" data-value="{{item.value}}" bind:tap="changLeave">{{item.name}}</view>
         </view>
     </view>
     <view class="content">
-        <van-button custom-class='but {{data.sa_saleareaid == item.active?" active":" "}}' wx:for="{{item.list}}" wx:for-item="data" wx:for-index="i" wx:key="i" data-item="{{data}}" data-index="{{index}}" data-i="{{i}}" bindtap="selectDep">{{data.depname}}</van-button>
+        <van-button custom-class='but {{data.sa_saleareaid == item.active?" active":" "}}' wx:for="{{item.list}}" wx:for-item="data" wx:for-index="i" wx:key="i" data-item="{{data}}" data-index="{{index}}" data-i="{{i}}" bindtap="selectDep">{{data.areaname}}</van-button>
     </view>
 </view>
 <!-- 人员筛选 -->
-<view wx:if="{{isusers}}" class="groud {{exclution && takeEffect != 'user'? 'exclution' : ''}}" wx:key="label">
+<view wx:if="{{isusers && users.copyList.length}}" class="groud {{exclution && takeEffect != 'user'? 'exclution' : ''}}" wx:key="label">
     <view class="title" style="align-items: center;">
         <view class="label">
-            {{language[users.label]||users.label}}
+            {{users.label}}
         </view>
         <view class="tabs-box" style="margin-right: 20rpx;">
-            <van-search value="{{ searchValue }}" shape='round' bind:change='searchChange' bind:clear='searchClear' placeholder="{{language['搜索姓名/账号']||'搜索姓名/账号'}}" />
+            <van-search value="{{ searchValue }}" shape='round' bind:change='searchChange' bind:clear='searchClear' placeholder="搜索姓名/账号" />
         </view>
     </view>
     <view class="content">

+ 1 - 1
components/timeRange/timeRange.wxml

@@ -12,7 +12,7 @@
             <view class="middle">至</view>
             {{enddate}}
         </view>
-        <view class="iconfont icon-xiangxiazhankai" />
+        <view class="iconfont icon-webxialaxuanxiangjiantou" />
     </view>
 </view>
 <van-action-sheet show="{{ showTimePicker }}" bind:click-overlay='cancelWhereType'>