employee->root_id]; $where[] = ['state', '=', '待审核']; $where[] = ['verified', '=', 0]; $count = Employee::where($where)->count(); View::assign('count', $count); View::assign('root', $request->employee->root_id); return View::fetch(); } /** * 获取公司下的组织结构与小程序设置 */ public function struct() { $datastr = OrgLogic::struc(request()->employee['root_id']); $datastr = json_decode($datastr, true); return json(['code' => 0, 'data' => $datastr]); } public function removenode() { $id = input('id'); // 原结构获取 // $datastr = OrgLogic::struc(request()->employee->root_id); //$org = OrgModel::where([['id', '=', $id]])->findOrEmpty(); $org = OrgModel::where([['id', '=', $id], ['path', 'like', request()->employee->root_id . '-%']])->findOrEmpty(); if ($org->isEmpty()) return json(['code' => 1, 'msg' => '删除失败,机构不存在']); if (!$org->level) { return json(['code' => 101, 'msg' => '根节点不可删除!']); } // 判断节点是否是该企业节点 $path = explode('-', $org->path); if ($path[0] != request()->employee->root_id) return json(['code' => 1, 'msg' => '删除失败,机构不存在']); $result = OrgLogic::disnode($id, $msg); if ($result !== true) { return json(['code' => $result, 'msg' => $msg]); } dataStatistics(request()->employee->root_id,'org_count',1,'dec');//manage应用首页统计数据 return json(['code' => 0, 'msg' => '删除成功']); } /** * 部门资源交接 */ public function receive($from, $to) { $check = OrgModel::where([['id', 'in', [$from, $to]], ['path', 'like', request()->employee->root_id . '-%']])->count(); if ($check != 2) return json(['code' => 1, 'msg' => '异常请求']); // 被交接部门查找 $fromOrg = OrgModel::find($from); // 被交接子部门查找 $delIds = OrgModel::where([['path', 'like', $fromOrg->path . '%']])->column('id'); /** 资源交接 */ // 交接客户 Customer::where([['org_id', 'in', $delIds]])->update(['org_id' => $to]); // 交接线索 CustomerClue::where([['org_id', 'in', $delIds]])->update(['org_id' => $to]); // 交接足迹 Footprints::where([['org_id', 'in', $delIds]])->update(['org_id' => $to]); // 交接资源库(资源导入记录) CrmImportLog::where([['org_id', 'in', $delIds]])->update(['org_id' => $to]); // 删除部门 OrgModel::where([['id', 'in', $delIds]])->delete(); return json(['code' => 0, 'msg' => '交接完成']); } public function addnode() { $request = request(); $param = $request->only(['id', 'pid', 'name', 'org_type']); // 如果是修改 if (isset($param['id']) && !empty($param['id'])) { Db::startTrans(); $theObj = OrgModel::where([['id', '=', $param['id']], ['path', 'like', $request->employee->root_id . '-%']])->find(); if (empty($theObj)) return json(['code' => 1, 'msg' => '数据不存在']); $oldName = $theObj->info; $theObj->info = preg_replace('/\/[^\/]*$/', '/' . $param['name'], $theObj->info); $theObj->name = $param['name']; $theObj->save(); // 子部门名称修改 $childs = OrgModel::where([['path', 'like', $theObj->path . '%'], ['id', '<>', $theObj->id]])->select(); foreach ($childs as $item) { $item->info = preg_replace("/^" . preg_quote($oldName, '/') . "/", $theObj->info, $item->info); $item->save(); } Db::commit(); return json(['code' => 0, 'msg' => '更新成功']); } else { $theObj = OrgModel::where([['id', '=', $param['pid']], ['path', 'like', $request->employee->root_id . '-%']])->find(); if (empty($theObj)) return json(['code' => 1, 'msg' => '添加失败']); $org = OrgModel::create([ 'pid' => $param['pid'], 'name' => $param['name'], 'org_type' => !empty($param['org_type']) ? $param['org_type'] : $theObj->org_type, 'level' => $theObj->level + 1, 'info' => $theObj->info . '/' . $param['name'] ]); $org->path = $theObj->path . $org->id . '-'; $org->save(); dataStatistics($request->employee->root_id,'org_count',1,'inc');//manage应用首页统计数据 return json(['code' => 0, 'data' => $org->id]); } } // public function invitelink() // { // $orgid = input('orgid'); // $therole = input('therole'); // $is_manager = input('is_manager'); // $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); // $cryptedstr = $aec->encrypt('orgid=' . $orgid . '&role=' . $therole . '&is_manager=' . $is_manager . '&pos=1&ts=' . time()); // $link = Request()->domain() . '/index/index/invite/?al=' . $cryptedstr; // return json_encode(['code' => 0, 'msg' => '获取成功', 'link' => $link]); // } public function employee() { $org = input('org', '', 'intval'); $param['page'] = input('page', 1); $param['limit'] = input('limit', 10); if (empty($org)) { $org = request()->employee->root_id; } $employee = EmployeeLogic::employeelist($org, [], $param['page'], $param['limit']); $data = []; foreach($employee as $item){ $data[] = ['id'=>$item['id'], 'name'=>$item['name']]; } return json(['code' => 0, 'data' => $data]); } public function employee4resource($org, $keyword = '') { $param['page'] = input('page', 1); $param['limit'] = input('limit', 10); $where = []; if ($keyword) { $where[] = ['name', 'like', '%' . $keyword . '%']; } $employee = EmployeeLogic::employeelist4resource($org, $where, $param['page'], $param['limit']); return json(['code' => 0, 'data' => $employee]); } // /** // * 小程序绑定 // */ // public function miniprogram() // { // $request = request(); // $param = $request->param(); // $param['root_id'] = $request->employee->root_id; // $program = Miniprogram::where([['root_id', '=', $param['root_id']]])->findOrEmpty(); // $accessToken = getAccessToken($param['appid'], $param['secret']); // if (empty($accessToken)) return json(['code' => 1, 'msg' => '配置失败,appid,secret不正确或小程序业务域名未配置']); // // 邀请二维码生成 // $miniQr = new Qrcode(); // // 1)管理员二维码 // $qr = $miniQr->getUnlimited($accessToken, [ // 'scene' => 'manager=' . $param['root_id'], // 'page' => 'mycustomer/pages/invite/invite', // 'width' => '280px', // 'check_path' => false // ]); // $rs = json_decode($qr, true); // if (!is_null($rs)) { // trace($rs, 'error'); // return json(['code' => 1, 'msg' => '配置失败,appid,secret不正确或小程序业务域名未配置']); // } // $managerQr = 'invite' . DIRECTORY_SEPARATOR . uniqid() . '.jpeg'; // ossContentUpload($managerQr, $qr); // // 2)员工二维码 // $qr = $miniQr->getUnlimited($accessToken, [ // 'scene' => 'employee=' . $param['root_id'], // 'page' => 'mycustomer/pages/invite/invite', // 'width' => '280px', // 'check_path' => false // ]); // $rs = json_decode($qr, true); // if (!is_null($rs)) { // return json(['code' => 1, 'msg' => '配置失败,appid,secret不正确或小程序业务域名未配置']); // } // $employeeQr = 'invite' . DIRECTORY_SEPARATOR . uniqid() . '.jpeg'; // ossContentUpload($employeeQr, $qr); // $param['manager_qr'] = $managerQr; // $param['employee_qr'] = $employeeQr; // $param['accesstoken'] = $accessToken; // $param['expire'] = time() + 7100; // $param['company'] = OrgModel::where('id', $param['root_id'])->value('name'); // // 检测id是否是root // $program->save($param); // return json(['code' => 0, 'msg' => '保存成功', 'data' => $param]); // } public function transfer($id, $pid) { $request = request(); $theObj = OrgModel::where([['id', '=', $id], ['path', 'like', $request->employee->root_id . '-%']])->find(); // 根组织不可迁移 if (empty($theObj) || $theObj->pid == 0) return json(['code' => 1, 'msg' => '转移失败']); // 判断是从上级往下级迁移 $isChildren = OrgModel::where([['id', '=', $pid], ['path', 'like', $theObj->path . '%']])->count(); if ($isChildren) return json(['code' => 1, 'msg' => '不能将上级部门转移到自身的子部门中']); $pObj = OrgModel::where([['id', '=', $pid], ['path', 'like', $request->employee->root_id . '-%']])->find(); if (empty($pObj)) return json(['code' => 1, 'msg' => '转移失败']); if ($pObj->org_type == 2 && $theObj->org_type != 2) return json(['code' => 1, 'msg' => '销售部不能能迁移到设计部门下']); // 克隆原数据 $oldObj = clone $theObj; $theObj->level = $pObj->level + 1; $theObj->path = $pObj->path . $theObj->id . '-'; $theObj->pid = $pObj->id; $theObj->info = $pObj->info . '/' . $theObj->name; $theObj->save(); // 子组织迁移修改 $childrens = OrgModel::where([['path', 'like', $oldObj->path . '%']])->select(); foreach ($childrens as $child) { $child->level = $child->level - $oldObj->level + $theObj->level; $child->path = preg_replace('/^' . $oldObj->path . '/', $theObj->path, $child->path); $child->info = preg_replace('/^' . str_replace('/', '\/', $oldObj->info) . '/', $theObj->info, $child->info); $child->save(); } return json(['code' => 0, 'msg' => '迁移成功']); } /** * 更改领导 */ public function leaders($id, $leader) { $request = request(); // 将检索该部门下的所有领导更新成员工 $leaderIds = Employee::where(['org_id' => $id, 'root_id' => $request->employee->root_id, 'is_manager' => 1])->column('id'); $removeLeader = array_diff($leaderIds, $leader); $setLeader = array_diff($leader, $leaderIds); Employee::where([['org_id', '=', $id], ['root_id', '=', $request->employee->root_id], ['id', 'in', $setLeader]])->update(['is_manager' => 1]); Employee::where([['org_id', '=', $id], ['root_id', '=', $request->employee->root_id], ['id', 'in', $removeLeader]])->update(['is_manager' => 0]); $orgName = OrgModel::where([['id', '=', $id], ['path', 'like', $request->employee->root_id . '-%']])->value('name'); if ($setLeader && $orgName) event(new Msg($setLeader, '您被' . $request->employee->name . '添加为' . $orgName . '负责人身份,请知晓!', 'setleader')); if ($removeLeader) event(new Msg($removeLeader, '您的负责人身份被' . $request->employee->name . '移除了,请知晓!', 'removeleader')); // Employee::where(['org_id' => $id, 'root_id' => request()->employee->root_id])->update(['is_manager' => 0]); // 更新该部门下的领导 // Employee::where([['org_id', '=', $id], ['root_id', '=', request()->employee->root_id], ['id', 'in', $leader]])->update(['is_manager' => 1]); return json(['code' => 0, 'msg' => '更改成功']); } /** * 设置企业 */ public function company() { $request = request(); $data = Company::where(['root_id' => $request->employee->root_id])->find(); View::assign('data', $data); View::assign('logo', $data->getData('logo')); $disable_day_setting = Setting::where([['name', '=', 'disable_day'], ['root_id', '=', $request->employee->root_id]])->findOrEmpty(); $disable_day = ''; if (!$disable_day_setting->isEmpty()) { $disable_day = $disable_day_setting['content']; } View::assign('disable_day', $disable_day); return View::fetch(); } //单独获取vr链接地址 public function company_vrlist() { $request = request(); $list = CompanyVrshow::where([['root_id','=',$request->employee->root_id],['type','=',1]])->field('id,name,url')->select()->toArray(); if(empty($list)) $list = [['id'=>'','name'=>'','url'=>'']]; return json(['code'=>0,'data'=>$list,'msg'=>'获取成功']); } /** * 删除公司的vr展厅链接地址 */ public function del_companyvr() { $request = request(); $param = $request->only(['id']); $data = CompanyVrshow::where([['root_id','=',$request->employee->root_id],['type','=',1],['id','=',$param['id']]])->find(); if(empty($data)) return json(['code'=>1,'msg'=>'数据不存在']); $ms = $data->delete(); if($ms){ return json(['code'=>0,'msg'=>'删除成功']); }else{ return json(['code'=>1,'msg'=>'删除失败']); } } public function setting() { $request = request(); $data = Company::where(['root_id' => $request->employee->root_id])->find(); $param = $request->only(['logo', 'company_name', 'tel', 'logo_file', 'company_introduction' => '', 'company_address' => '', 'vr_address' => '', 'vr_show' => '']); $url = 'hnweizhihui.xiaohongwu'; $jurl = 'web.xiaohongwu'; if ($param['vr_address']) { $param['vr_address'] = $this->vrlink_set($param['vr_address']); } if ($param['vr_show']) { $cpvrmod = new CompanyVrshow; //$param['vr_show'] = $this->vrlink_set($param['vr_show']); foreach(json_decode($param['vr_show'],true) as $k=>$v){ if($v['id']) $save[] = ['id'=>$v['id'],'name'=>$v['name'],'url'=>$this->vrlink_set($v['url'])]; else $add[] = ['name'=>$v['name'],'url'=>$this->vrlink_set($v['url']),'root_id'=>$request->employee->root_id,'type'=>1]; } if(!empty($save)) $cpvrmod->saveAll($save); if(!empty($add)) $cpvrmod->saveAll($add); $param['vr_show'] = ''; } if (empty($param['logo']) && empty($param['logo_file'])) return json(['code' => 1, 'msg' => '请上传LOGO']); if (!empty($param['logo_file'])) $param['logo'] = $param['logo_file']; $data->save($param); // 三天未进入小程序 准入小程序锁定 $disable_day = input('disable_day', '', 'intval'); $disable_day_setting = Setting::where([['name', '=', 'disable_day'], ['root_id', '=', $request->employee->root_id]])->findOrEmpty(); if ($disable_day_setting->isEmpty()) { Setting::create(['name'=> 'disable_day', 'root_id'=> $request->employee->root_id, 'content'=> $disable_day, 'state'=> 1]); } else { $disable_day_setting->content = $disable_day; $disable_day_setting->save(); } return json(['code' => 0, 'msg' => '保存成功']); } /** * 部门人员树 */ public function tree($data, $pid = 0, $persons) { $new_arr = []; foreach ($data as $k => $v) { if ($v['pid'] == $pid) { $persions = isset($persons[$v['id']]) ? $persons[$v['id']] : []; $children = $this->tree($data, $v['id'], $persons); $v['children'] = array_merge_recursive($children, $persions); if (empty($v['children'])) $v['disabled'] = true; $new_arr[] = $v; } } return $new_arr; } /** * 指派人员 * @param $id */ public function get_person() { $root_id = request()->employee->root_id; $keyword = input('keyword', ''); //所有员工 $w1[] = ['root_id', '=', $root_id]; $w1[] = ['state', '=', '在职']; $w1[] = ['org_id', '>', 0]; $w1[] = ['uid', '>', 0]; if ($keyword) { $w1[] = ['name', 'like', '%' . $keyword . '%']; } $employee = Employee::where($w1)->field('id,name title,org_id,is_manager')->order('is_manager desc,id desc')->select()->toArray(); foreach ($employee as $k => &$v) { $v['selected'] = false; $v['children'] = []; $v['all_count'] = 0; $v['title'] = $v['is_manager'] ? $v['title'] . '(负责人)' : $v['title']; $v['org_class'] = 'org_' . $v['org_id']; $v['per_class'] = 'per_' . $v['id']; $v['type'] = 'per'; } $persons = []; foreach ($employee as $k => $v1) { $persons[$v1['org_id']][] = $v1; } $where = [ ['path', 'like', $root_id . '-%'], ['status', '=', 1] ]; $count = Employee::where([['root_id', '=', $root_id], ['state', '=', '在职'], ['uid', '>', 0]])->group('org_id')->column('count(*) count', 'org_id'); $allnodes = OrgModel::where($where)->field('id,pid,name title,level,org_type,info,path')->order('level asc, id asc')->select()->toarray(); foreach ($allnodes as $k => $v) { $allnodes[$k]['count'] = isset($count[$v['id']]) ? $count[$v['id']] : 0; //本部门人数 $allnodes[$k]['all_count'] = 0; //包含子部门总数 $allnodes[$k]['org_class'] = 'org_' . $v['id']; $allnodes[$k]['per_class'] = 'per_org_' . $v['id']; $allnodes[$k]['type'] = 'org'; foreach ($allnodes as $k2 => $v2) { if (strpos($v2['path'], $v['path']) !== false) { $allnodes[$k]['all_count'] = isset($count[$v2['id']]) ? $count[$v2['id']] + $allnodes[$k]['all_count'] : $allnodes[$k]['all_count']; } } $allnodes[$k]['title'] = $allnodes[$k]['title'] . ' (' . $allnodes[$k]['all_count'] . ')'; } $tree = $this->tree($allnodes, 0, $persons); $info = Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->value('content'); return json(['code' => 0, 'data' => $tree, 'checkOrg' => $info]); } /** * 设置不受限制人员 */ public function set_unlimited_employee() { $setting = Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->findOrEmpty(); $assign_employee = $setting->isEmpty() ? '' : $setting['content']; if (!request()->isAjax()) { $count = $assign_employee ? count(explode(',', $assign_employee)) : 0; view::assign('count', $count); return View::fetch(); } $pid = input('pid', '', 'trim'); //多选框选中id $type = input('type', '', 'trim'); //选中类型,人/部门 $res = input('res', '', 'trim'); //选择结果 1选中,0取消 $data = []; $a = 0; if ($type == 'per' && $pid) { $data[] = 'per_' . $pid; $pid = [$pid]; $a = 1; } elseif ($type == 'org' && $pid) { $data[] = 'org_' . $pid; $org = OrgModel::where([['id', '=', $pid]])->value('path'); $orgs = OrgModel::where([['path', 'like', $org . '%']])->column('id'); $pid = Employee::where([['root_id', '=', request()->employee->root_id], ['org_id', 'in', $orgs], ['state', '=', '在职'], ['uid', '>', 0]])->order('is_manager desc,id desc')->column('id'); $a = 1; foreach ($pid as $v) { $data[] = 'per_' . $v; } foreach ($orgs as $v2) { $data[] = 'org_' . $v2; } } $assign_employee = explode(',', $assign_employee); if ($a) { $arr = array_filter(array_diff($assign_employee, $pid)); $arr = $res ? array_merge($pid, $arr) : $arr; $arr = array_unique($arr); //过滤运营人员,旧bug导致选择根部门时,运营人员也会在内 $arr = Employee::where([['id', 'in', $arr], ['uid', '>', 0], ['state', '=', '在职']])->column('id'); //查询指派人的组织 if ($setting->isEmpty()) { $add = ['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited', 'content' => implode(',', $arr)]; Setting::create($add); } else { Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->update(['content' => implode(',', $arr)]); } } return json(['code' => 0, 'data' => $data]); } /* * 不受限制员工列表 */ public function get_unlimited_employee() { $page = input('page', 0, 'intval'); $limit = input('limit', 0, 'intval'); $keyword = input('keyword', '', 'trim'); if ($keyword) { $w[] = ['name', 'like', '%' . $keyword . '%']; } $setting = Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->findOrEmpty(); $arr = $setting->isEmpty() ? '' : $setting['content']; $arr = $arr ? explode(',', $arr) : []; $w[] = ['id', 'in', $arr]; $w[] = ['state', '=', '在职']; $w[] = ['uid', '>', 0]; if ($page && $limit) { $data = Employee::with('orgName')->where($w)->visible(['name', 'org_name', 'id', 'is_manager'])->page($page, $limit)->select()->toArray(); } else { $data = Employee::with('orgName')->where($w)->visible(['name', 'org_name', 'id', 'is_manager'])->select()->toArray(); } $count = Employee::where($w)->count(); foreach ($data as $k => $v) { $data[$k]['xh'] = $k + 1; } return json(['code' => 0, 'data' => $data, 'count' => $count]); } /** * 删除已设置不受限制员工 */ public function delete_unlimited_employee() { $eid = input('eid', '', 'intval'); if ($eid) { if ($eid == -1) { Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->update(['content' => '']); } else { $setting = Setting::where(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited'])->findOrEmpty(); $arr = $setting->isEmpty() ? '' : $setting['content']; $arr = array_filter(array_diff(explode(',', $arr), [$eid])); if ($setting->isEmpty()) { Setting::create(['root_id' => request()->employee->root_id, 'name' => 'disable_day_unlimited', 'content'=> implode(',', $arr)]); } else { $setting->save(['content' => implode(',', $arr)]); } } } return json(['code' => 0, 'data' => '取消成功', 'msg' => '取消成功']); } //vr链接设置修改 public function vrlink_set($vr_link) { //2023-05-04 志远装饰app创建的vr作品 if (strpos($vr_link,'/vr/#')) return $vr_link; // 旧域名 替换成 新域名 $links = [ 'xiaohongwu' => 'hnweizhihui.xiaohongwu.nczyzs.com', 'kujiale' => 'pano337.p.kujiale.com', 'justeasy' => 'vr-17.justeasy.nczyzs.com', '3d66' => 'vr.3d66.nczyzs.com', ]; $url = parse_url($vr_link); if ($url === false || !isset($url['host'])) { echo json_encode(['code' => 1, 'msg' => '链接格式错误']); exit; } if (strpos($url['host'], 'xiaohongwu') !== false) { return str_replace($url['host'], $links['xiaohongwu'], $vr_link); } if (strpos($url['host'], 'kujiale') !== false) { return str_replace($url['host'], $links['kujiale'], $vr_link); } if (strpos($url['host'], 'justeasy') !== false) { return str_replace($url['host'], $links['justeasy'], $vr_link); } if (strpos($url['host'], '3d66') !== false) { return str_replace($url['host'], $links['3d66'], $vr_link); } echo json_encode(['code' => 1, 'msg' => '无效的VR链接']); exit; } //奖励规则设置 public function reward_rule() { $request = request(); $where[] = ['code', '=', 'talkskill_credits']; $where[] = ['root_id', '=', $request->employee->root_id]; $data['talkskill_credits'] = CreditsSetting::where($where)->value('value') ?: 1; $where2[] = ['code', '=', 'talkskill_contribution_value']; $where2[] = ['root_id', '=', $request->employee->root_id]; $data['talkskill_contribution_value'] = CreditsSetting::where($where2)->value('value') ?: 1; $where3[] = ['code', '=', 'talkskill_person1']; $where3[] = ['root_id', '=', $request->employee->root_id]; $person1 = CreditsSetting::where($where3)->value('value'); $data['talkskill_person1'] = $person1 ? json_decode($person1, true) : ['person1' => 1, 'credits1' => 1]; $where4[] = ['code', '=', 'talkskill_person2']; $where4[] = ['root_id', '=', $request->employee->root_id]; $person2 = CreditsSetting::where($where4)->value('value'); $data['talkskill_person2'] = $person2 ? json_decode($person2, true) : ['person2' => 1, 'credits2' => 1]; $where5[] = ['code', '=', 'material_case_value']; $where5[] = ['root_id', '=', $request->employee->root_id]; $data['material_case_value'] = CreditsSetting::where($where5)->value('value') ?: 1; $where6[] = ['code', '=', 'material_case_integral']; $where6[] = ['root_id', '=', $request->employee->root_id]; $material_case_integral = CreditsSetting::where($where6)->value('value'); if ((int)$material_case_integral > 0) $material_case_integral = null; $data['material_case_integral'] = $material_case_integral ? json_decode($material_case_integral, true) : ['case_num' => 1, 'case_integral' => 2]; View::assign('data', $data); return View::fetch(); } //奖励规则设置 public function reward_rule_save() { $request = request(); $param = Request::only(['up', 'answer', 'person1', 'credits1', 'person2', 'credits2', 'upcase', 'case_num', 'case_integral']); if (isset($param['up'])) { credits($request->employee->root_id, $param['up'], 'talkskill_credits', 0); //积分 } if (isset($param['answer'])) { credits($request->employee->root_id, $param['answer'], 'talkskill_contribution_value', 0); //贡献值 } if (isset($param['person1']) && isset($param['credits1'])) { $json = json_encode(['person1' => $param['person1'], 'credits1' => $param['credits1']]); credits($request->employee->root_id, $json, 'talkskill_person1', 0); //贡献值 } if (isset($param['person2']) && isset($param['credits2'])) { $json = json_encode(['person2' => $param['person2'], 'credits2' => $param['credits2']]); credits($request->employee->root_id, $json, 'talkskill_person2', 0); //贡献值 } if (isset($param['upcase'])) { credits($request->employee->root_id, $param['upcase'], 'material_case_value', 0); //贡献值 } if (isset($param['case_num']) && isset($param['case_integral'])) { $json = json_encode(['case_num' => $param['case_num'], 'case_integral' => $param['case_integral']]); credits($request->employee->root_id, $json, 'material_case_integral', 0); //案例被使用积分 } return json(['code' => 0, 'msg' => '保存成功']); } //设计师管理 public function designer() { $designerOrg = OrgModel::field('id,info as name')->withAttr('name', function($value){ $v = explode('/', $value); return implode('/', array_slice($v, -2)); })->where([['path', 'like', request()->employee['root_id'].'-%'], ['org_type', '=', 2]])->order('level asc, id asc')->select(); View::assign('designerOrg', $designerOrg); return View::fetch(); } //添加设计师 public function add_designer() { return View::fetch(); } //编辑设计师 public function edit_designer() { $id = input('id', 0); View::assign('id', $id); $token = request()->employee; $w[] = ['employee_id', '=', $id]; $w[] = ['root_id', '=', $token['root_id']]; $row = Designer::where($w)->findOrEmpty(); if ($row->isEmpty()) { $row['headimgurl'] = ''; $row['vcr'] = ''; $row['work_years'] = ''; $row['position'] = ''; $row['design_concept'] = ''; $row['good_at'] = ''; $row['good_house'] = ''; $row['headimgurls'] = ''; } else { $row->headimgurls = $row->getData('headimgurl'); $row->vcrurl = $row->getData('vcr'); $row = $row->toArray(); } // var_dump($row['headimgurls']);die; View::assign('data', $row); $condition = [['root_id', '=', $token['root_id']]]; //风格获取 $decostyles = Decostyle::where($condition)->where([['type', '=', 0]])->field('name')->select()->toArray(); $arr = $row['good_at'] ?: []; foreach ($decostyles as $k => $v) { $decostyles[$k]['value'] = $v['name']; $decostyles[$k]['selected'] = in_array($v['name'], $arr); } $decostyles = json_encode($decostyles); // var_dump($decostyles);die; View::assign('decostyles', $decostyles); //户型获取 $housetype = Housetype::where($condition)->field('name')->select()->toArray(); $arr = $row['good_house'] ?: []; foreach ($housetype as $k => $v) { $housetype[$k]['value'] = $v['name']; $housetype[$k]['selected'] = in_array($v['name'], $arr); } // var_dump($housetype);die; $housetype = json_encode($housetype); View::assign('housetype', $housetype); return View::fetch(); } /* * 富文本图片 */ public function imgUpload() { $bindUrl = config('app.ali_oss_bindurl'); $data = [ 'src' => 'http://' . $bindUrl . '/' . Request::param('file'), 'title' => '' ]; return json(['code' => 0, 'msg' => '', 'data' => $data]); } }