zhanglinxin vor 1 Jahr
Ursprung
Commit
443963f7d3

+ 7 - 0
application/api/controller/Dingtalk.php

@@ -2,6 +2,7 @@
 
 namespace app\api\controller;
 
+use app\common\constant\CommonConstant;
 use app\common\model\Department;
 use app\common\model\User;
 use app\common\service\DingtalkService;
@@ -141,4 +142,10 @@ class Dingtalk extends Base
         $url = input('url') ?: '';
         $this->success('获取鉴权需要的参数',DingtalkService::generateAuthSignature($url));
     }
+
+    // 更新员工和部门
+    public function renew(){
+        DingtalkService::renew();
+        $this->success('更新员工和部门成功');
+    }
 }

+ 3 - 2
application/api/controller/Member.php

@@ -3,7 +3,7 @@
 namespace app\api\controller;
 
 use app\common\constant\CommonConstant;
-use app\common\model\Department;
+use app\common\service\UserService;
 use hg\apidoc\annotation as Apidoc;
 
 /**
@@ -38,7 +38,8 @@ class Member extends Base
     {
         $user = $this->user;
         unset($user['status'],$user['is_deleted'],$user['create_at']);
-        $user['department_list'] = Department::field('dept_id,name')->where('dept_id', 'in', $user['department'])->select();
+        $department_data = UserService::get_user_department_list($user['department']);;
+        $user['department_list'] = $department_data;
         $user['subject_image'] = 'https://static-legacy.dingtalk.com/media/lADPDgfLSTijRwbNA0jNAlg_600_840.jpg';
         $user['subject'] = '学校名称';
         $this->success('获取成功', $user);

+ 0 - 71
application/approve/controller/ApproveMaintainUser.php

@@ -17,8 +17,6 @@ namespace app\approve\controller;
 
 use app\common\constant\CommonConstant;
 use app\common\constant\MaintainConstant;
-use app\common\model\Department;
-use app\common\service\UserService;
 use library\Controller;
 
 /**
@@ -66,75 +64,6 @@ class ApproveMaintainUser extends Controller
      */
     protected function _index_page_filter(&$data)
     {
-        if($data){
-//            $this->user_list = UserService::get_list(1);
-//            $user_object = array_column($this->user_list->toArray(),null,'userid');
-//            $department_list = Department::column('dept_id,name');
-//            foreach ($data as &$value) {
-//                // 所属部门
-//                $department_ids = explode(',',$value['department']);
-//                $department_text = '';
-//                foreach ($department_ids as $val){
-//                    if(array_key_exists($val,$department_list)){
-//                        $department_text .= $department_list[$val].',';
-//                    }
-//                }
-//                $value['department_text'] = $department_text;
-//                // 员工的直属主管
-//                $manager_text = !empty($value['manager_userid']) && array_key_exists($value['manager_userid'],$user_object) ? $user_object[$value['manager_userid']]['name'] : '';
-//                $value['manager_text'] = $manager_text;
-//            }
-        }
-    }
-
-
-    /**
-     * 编辑
-     * @auth true
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\exception\PDOException
-     */
-    public function edit()
-    {
-        $this->title = '编辑';
-        $this->_form($this->table, 'form');
-    }
-
-    /**
-     * 表单处理
-     * @param array $data
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    protected function _form_filter(&$data)
-    {
-        // 编辑
-        if($data['id'] > 0){
-            if($this->request->isGet()) {
-                $department_list = Department::column('dept_id,name');
-                // 所属部门
-                $department_ids = explode(',',$data['department']);
-                $department_text = '';
-                foreach ($department_ids as $val){
-                    if(array_key_exists($val,$department_list)){
-                        $department_text .= $department_list[$val].',';
-                    }
-                }
-                $data['department_text'] = $department_text;
-                $this->user_list = UserService::get_list(1);
-            }
-            if($this->request->isPost()){
-                if (isset_full($data, 'signature_status')) {
-                    if(!in_array($data['signature_status'],[CommonConstant::SIGNATURE_STATUS_3,CommonConstant::SIGNATURE_STATUS_4])){
-                        unset($data['signature_status']);
-                    }
-                }
-            }
-        }
     }
 
 

+ 1 - 4
application/common/service/ApproveInfoService.php

@@ -12,7 +12,6 @@ use app\common\model\ApproveStockGoods;
 use app\common\model\ApproveEvectionPeerUser;
 use app\common\model\ApproveInfo;
 use app\common\model\ApproveUseGoods;
-use app\common\model\Department;
 use app\common\model\Goods;
 use app\common\model\GoodsCategory;
 use app\common\model\GoodsStock;
@@ -823,9 +822,7 @@ class ApproveInfoService
                     }
                 }
                 // 部门列表
-                $department_data = Department::field('dept_id,name')
-                    ->where('dept_id', 'in', $info['department'])
-                    ->select();
+                $department_data = UserService::get_user_department_list($info['department']);
                 // 关联的合同呈批申请
                 $contract = ApproveInfo::field('id,reason')
                     ->where('module', CommonConstant::MODULE_9)

+ 7 - 0
application/common/service/DingtalkService.php

@@ -2,6 +2,7 @@
 
 namespace app\common\service;
 
+use app\common\constant\CommonConstant;
 use app\extend\Dingtalk\Sample;
 
 /**
@@ -141,4 +142,10 @@ class DingtalkService
         return compact("agentId","corpId","nonceStr","timeStamp","signature","url");
     }
 
+    /**
+     * 更新员工和部门
+     **/
+    public static function renew(){
+        $department_list = UserService::get_department_column();
+    }
 }

+ 23 - 1
application/common/service/UserService.php

@@ -3,8 +3,8 @@
 namespace app\common\service;
 
 use app\common\constant\CommonConstant;
-use app\common\constant\MaintainConstant;
 use app\common\model\ApproveMaintainUser;
+use app\common\model\Department;
 use app\common\model\User;
 
 /**
@@ -45,4 +45,26 @@ class UserService
         return $list;
     }
 
+    /**
+     * 部门列表
+     **/
+    public static function get_department_column(){
+        $list = Department::where('is_deleted',CommonConstant::IS_DELETED_0)
+            ->column('dept_id,name');
+        return $list;
+    }
+
+    /**
+     * 根据用户的所属部门获取部门列表
+     *
+     * @param string $dept_ids 部门ids
+     **/
+    public static function get_user_department_list($dept_ids){
+        $list = Department::field('dept_id,name')
+            ->where('dept_id', 'in', $dept_ids)
+            ->where('is_deleted',CommonConstant::IS_DELETED_0)
+            ->select();
+        return $list;
+    }
+
 }

+ 3 - 4
application/user/controller/Member.php

@@ -16,7 +16,6 @@
 namespace app\user\controller;
 
 use app\common\constant\CommonConstant;
-use app\common\model\Department;
 use app\common\service\UserService;
 use library\Controller;
 
@@ -75,9 +74,9 @@ class Member extends Controller
     protected function _index_page_filter(&$data)
     {
         if($data){
+            $department_list = UserService::get_department_column();
             $this->user_list = UserService::get_list(1);
             $user_object = array_column($this->user_list->toArray(),null,'userid');
-            $department_list = Department::column('dept_id,name');
             foreach ($data as &$value) {
                 // 所属部门
                 $department_ids = explode(',',$value['department']);
@@ -123,7 +122,8 @@ class Member extends Controller
         // 编辑
         if($data['id'] > 0){
             if($this->request->isGet()) {
-                $department_list = Department::column('dept_id,name');
+                $department_list = UserService::get_department_column();
+                $this->user_list = UserService::get_list(1);
                 // 所属部门
                 $department_ids = explode(',',$data['department']);
                 $department_text = '';
@@ -133,7 +133,6 @@ class Member extends Controller
                     }
                 }
                 $data['department_text'] = $department_text;
-                $this->user_list = UserService::get_list(1);
             }
             if($this->request->isPost()){
                 if (isset_full($data, 'signature_status')) {