diff --git a/app/controller/api/v1/Common.php b/app/controller/api/v1/Common.php index 1aa715c..b9c303c 100644 --- a/app/controller/api/v1/Common.php +++ b/app/controller/api/v1/Common.php @@ -5,6 +5,7 @@ namespace app\controller\api\v1; use app\controller\api\Base; use app\model\Account; use app\model\CheckLog; +use app\model\Outsource; use app\model\OvertimeLog; use app\model\Position; use app\model\Worksite; @@ -27,6 +28,7 @@ class Common extends Base 'worksiteList', 'positionList', 'notice', + 'team', ]; /** @@ -246,4 +248,26 @@ class Common extends Base return $this->json(0, 'success', ['notice' => 1, 'msg' => $checkLog['refund_reason'], 'id' => $checkLog['id']]); } + + // 班组列表 + public function team(): Json + { + $worksiteId = input('worksite_id/d'); + $keyword = input('keyword/s'); + + $where = []; + + if (!isset($worksiteId) || $worksiteId <= 0) { + return $this->json(4001, '请选择工地'); + } + + $where[] = ['worksite_id', '=', $worksiteId]; + if (!empty($keyword)) { + $where[] = ['keyword', 'like', '%'.$keyword.'%']; + } + + $res = Outsource::where($where)->order('sort', 'desc')->order('id', 'desc')->select(); + + return $this->json(0, 'success', $res); + } } \ No newline at end of file diff --git a/app/controller/api/v1/Worker.php b/app/controller/api/v1/Worker.php index be1e65f..3b71613 100644 --- a/app/controller/api/v1/Worker.php +++ b/app/controller/api/v1/Worker.php @@ -79,6 +79,7 @@ class Worker extends Base 'bank_card_img|银行卡拍照' => 'require', 'id_front|身份证正面' => 'require', 'id_back|身份证反面' => 'require', + 'outsource_id|班组' => 'require', 'address_now|现住址' => 'require', ]; @@ -97,7 +98,7 @@ class Worker extends Base $fields = [ 'real_name', 'mobile', 'pay', 'emergency_contact', 'emergency_phone', 'bank_card_name', 'bank_card_number', 'bank_name', 'card_number', 'position', 'worksite_id', 'certificate', 'address_now', 'province', 'city', 'area', - 'id_front', 'id_back', 'bank_card_img', 'work_experience' + 'id_front', 'id_back', 'bank_card_img', 'work_experience', 'outsource_id' ]; $post = array_filter($post, function ($item, $key) use ($fields) { return in_array($key, $fields); diff --git a/app/model/Account.php b/app/model/Account.php index 744fe48..c347af1 100644 --- a/app/model/Account.php +++ b/app/model/Account.php @@ -56,8 +56,9 @@ class Account extends Base { $user = self::alias('a') ->leftJoin('position p', 'a.position = p.id') + ->leftJoin('outsource o', 'a.outsource_id = o.id') ->where('a.id', $accountId) - ->field('a.*,p.name as position_name') + ->field('a.*,p.name as position_name,o.name as team_name') ->find(); if (empty($user)) {