first commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
declare (strict_types = 1);
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\api\BaseController;
|
||||
use app\user\model\Department as DepartmentModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Api extends BaseController
|
||||
{
|
||||
//删除档案记录相关
|
||||
public function del_profiles()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if (Db::name('AdminProfiles')->where('id', $id)->update(['delete_time'=>time()]) !== false) {
|
||||
return to_assign(0, "删除成功");
|
||||
} else {
|
||||
return to_assign(1, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
//一键调部门
|
||||
public function change_check()
|
||||
{
|
||||
$id = get_params("id");
|
||||
$data['id'] = $id;
|
||||
$data['connect_time'] = time();
|
||||
$data['status'] = 2;
|
||||
$detail = Db::name('DepartmentChange')->where('id', $id)->find();
|
||||
if (Db::name('DepartmentChange')->update($data) !== false) {
|
||||
Db::name('Admin')->where('id', $detail['uid'])->update(['did' => $detail['to_did']]);
|
||||
Db::name('DepartmentAdmin')->where(['admin_id'=>$detail['uid'],'department_id'=>$detail['to_did']])->delete();
|
||||
$info = Db::name('Admin')->where('id', $detail['uid'])->find();
|
||||
$model = new DepartmentModel();
|
||||
$auth_dids = $model->get_auth_departments($info);
|
||||
$son_dids = $model->get_son_departments($info);
|
||||
Db::name('Admin')->where('id',$detail['uid'])->update(['auth_dids'=>$auth_dids,'son_dids'=>$son_dids]);
|
||||
return to_assign(0, "操作成功");
|
||||
} else {
|
||||
return to_assign(1, "操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
//一键交接资料
|
||||
public function leave_check()
|
||||
{
|
||||
$id = get_params("id");
|
||||
$data['id'] = $id;
|
||||
$data['connect_time'] = time();
|
||||
$data['status'] = 2;
|
||||
$detail = Db::name('PersonalQuit')->where('id', $id)->find();
|
||||
$uid = $detail['uid'];
|
||||
$connect_uid = $detail['connect_id'];
|
||||
if (Db::name('PersonalQuit')->update($data) !== false) {
|
||||
//项目负责人
|
||||
Db::name('Project')->where([['director_uid','=',$uid],['status','<',3]])->update(['director_uid' => $connect_uid]);
|
||||
//任务负责人
|
||||
Db::name('ProjectTask')->where([['director_uid','=',$uid],['status','<',3]])->update(['director_uid' => $connect_uid]);
|
||||
//客户所属人
|
||||
$did = Db::name('Admin')->where('id', $connect_uid)->value('did');
|
||||
Db::name('Customer')->where([['belong_uid','=',$uid]])->update(['belong_uid' => $connect_uid,'belong_did'=>$did]);
|
||||
//合同
|
||||
Db::name('Contract')->where([['admin_id','=',$uid],['check_status','<',3]])->update(['admin_id' => $connect_uid]);
|
||||
Db::name('Admin')->where('id', $uid)->update(['status' => 2]);
|
||||
add_log('hand', $id);
|
||||
return to_assign(0, "交接成功");
|
||||
} else {
|
||||
return to_assign(1, "交接失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\validate\BasicUserCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Basic extends BaseController
|
||||
{
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where=[];
|
||||
if (!empty($param['types'])) {
|
||||
$where[] = ['types', '=', $param['types']];
|
||||
}
|
||||
$list = Db::name('BasicUser')->where($where)->order('create_time asc')->select();
|
||||
return to_assign(0, '', $list);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
//新建编辑
|
||||
public function add()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(BasicUserCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$res = Db::name('BasicUser')->strict(false)->field('title,types,id,update_time')->update($param);
|
||||
if ($res) {
|
||||
add_log('edit', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
try {
|
||||
validate(BasicUserCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = time();
|
||||
$insertId = Db::name('BasicUser')->strict(false)->field('title,types,id,create_time')->insertGetId($param);
|
||||
if ($insertId) {
|
||||
add_log('add', $insertId, $param);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//设置
|
||||
public function set()
|
||||
{
|
||||
$param = get_params();
|
||||
$res = Db::name('BasicUser')->strict(false)->field('id,status')->update($param);
|
||||
if ($res) {
|
||||
if($param['status'] == 0){
|
||||
add_log('disable', $param['id'], $param);
|
||||
}
|
||||
else if($param['status'] == 1){
|
||||
add_log('recovery', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
return to_assign(0, '操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Blacklist as BlacklistModel;
|
||||
use app\user\validate\BlacklistValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Blacklist extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new BlacklistModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$where=[];
|
||||
$whereOr=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
$list = $this->model->datalist($param,$where,$whereOr);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(BlacklistValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(BlacklistValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getById($id);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$detail = $this->model->getById($id);
|
||||
if (!empty($detail)) {
|
||||
View::assign('detail', $detail);
|
||||
return view();
|
||||
}
|
||||
else{
|
||||
return view(EEEOR_REPORTING,['code'=>404,'warning'=>'找不到页面']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
if (request()->isDelete()) {
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$this->model->delById($id);
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Care as CareModel;
|
||||
use app\user\validate\CareValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Care extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new CareModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['id|thing|remark', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (!empty($param['status'])) {
|
||||
$where[] = ['status', '=', $param['status']];
|
||||
}
|
||||
if (!empty($param['care_cate'])) {
|
||||
$where[] = ['care_cate', '=', $param['care_cate']];
|
||||
}
|
||||
if (!empty($param['uid'])) {
|
||||
$where[] = ['uid', '=', $param['uid']];
|
||||
}
|
||||
if (!empty($param['diff_time'])) {
|
||||
$diff_time =explode('~', $param['diff_time']);
|
||||
$where[] = ['care_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
|
||||
}
|
||||
$list = $this->model->datalist($where, $param);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['care_time'] = isset($param['care_time']) ? strtotime($param['care_time']) : 0;
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(CareValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(CareValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getById($id);
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$detail = $this->model->getById($id);
|
||||
if (!empty($detail)) {
|
||||
$detail['cate'] = Db::name('CareCate')->where('id',$detail['care_cate'])->value('title');
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
$detail['admin_name'] = Db::name('Admin')->where('id',$detail['admin_id'])->value('name');
|
||||
View::assign('detail', $detail);
|
||||
return view();
|
||||
}
|
||||
else{
|
||||
throw new \think\exception\HttpException(404, '找不到页面');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$this->model->delById($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\CareCate as CareCateModel;
|
||||
use app\user\validate\CareCateValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Carecate extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new CareCateModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = $this->model->select();
|
||||
return to_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(CareCateValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(CareCateValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getCateById($id);
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
$param = get_params();
|
||||
$res = $this->model->strict(false)->field('id,status')->update($param);
|
||||
if ($res) {
|
||||
if($param['status'] == 0){
|
||||
add_log('disable', $param['id'], $param);
|
||||
}
|
||||
else if($param['status'] == 1){
|
||||
add_log('recovery', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
return to_assign(0, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Department as DepartmentModel;
|
||||
use app\user\validate\DepartmentCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Department extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = Db::name('Department')->order('sort desc,id asc')->select()->toArray();
|
||||
foreach ($list as $key => &$v) {
|
||||
$admin_array = Db::name('Admin')->where([['id','in',$v['leader_ids']]])->column('name');
|
||||
$v['leader'] = split_array_field($admin_array);
|
||||
}
|
||||
$res = generateTree($list);
|
||||
return to_assign(0, '', $res);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加部门
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if ($param['id'] > 0) {
|
||||
try {
|
||||
validate(DepartmentCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$department_array = get_department_son($param['id']);
|
||||
if (in_array($param['pid'], $department_array)) {
|
||||
return to_assign(1, '上级部门不能是该部门本身或其下属部门');
|
||||
} else {
|
||||
Db::name('Department')->strict(false)->field(true)->update($param);
|
||||
$model = new DepartmentModel();
|
||||
$model->update_auth_dids_son_dids();
|
||||
add_log('edit', $param['id'], $param);
|
||||
return to_assign();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
validate(DepartmentCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$did = Db::name('Department')->strict(false)->field(true)->insertGetId($param);
|
||||
$model = new DepartmentModel();
|
||||
$model->update_auth_dids_son_dids();
|
||||
add_log('add', $did, $param);
|
||||
return to_assign();
|
||||
}
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$pid = isset($param['pid']) ? $param['pid'] : 0;
|
||||
$department = set_recursion(get_department());
|
||||
if ($id > 0) {
|
||||
$detail = Db::name('Department')->where(['id' => $id])->find();
|
||||
//获取子部门
|
||||
$department_array = get_department_son($id);
|
||||
$users = get_department_employee($id);
|
||||
View::assign('users', $users);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('department', $department);
|
||||
View::assign('pid', $pid);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
$id = get_params("id");
|
||||
$count = Db::name('Department')->where([['pid', '=', $id], ['status', '>=', 0]])->count();
|
||||
if ($count > 0) {
|
||||
return to_assign(1, "该部门下还有子部门,无法删除");
|
||||
}
|
||||
$users = Db::name('Admin')->where([['did', '=', $id], ['status', '>=', 0]])->count();
|
||||
if ($users > 0) {
|
||||
return to_assign(1, "该部门下还有员工,无法删除");
|
||||
}
|
||||
if (Db::name('Department')->delete($id) !== false) {
|
||||
add_log('delete', $id);
|
||||
return to_assign(0, "删除部门成功");
|
||||
} else {
|
||||
return to_assign(1, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Admin as AdminList;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Files extends BaseController
|
||||
{
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = array();
|
||||
$whereOr = array();
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['a.id|a.username|a.name|a.nickname|a.mobile|a.desc', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (isset($param['status']) && $param['status']!='') {
|
||||
$where[] = ['a.status', '=', $param['status']];
|
||||
}
|
||||
else{
|
||||
$where[] = ['a.status', '=', 1];
|
||||
}
|
||||
if (!empty($param['political'])) {
|
||||
$where[] = ['a.political', '=', $param['political']];
|
||||
}
|
||||
if (!empty($param['position_name'])) {
|
||||
$where[] = ['a.position_name', '=', $param['position_name']];
|
||||
}
|
||||
if (!empty($param['position_rank'])) {
|
||||
$where[] = ['a.position_rank', '=', $param['position_rank']];
|
||||
}
|
||||
if (!empty($param['did'])) {
|
||||
$admin_array = Db::name('DepartmentAdmin')->where('department_id',$param['did'])->column('admin_id');
|
||||
$map1=[
|
||||
['a.id','in',$admin_array],
|
||||
];
|
||||
$map2=[
|
||||
['a.did', '=', $param['did']],
|
||||
];
|
||||
$whereOr =[$map1,$map2];
|
||||
}
|
||||
$where[] = ['a.id', '>', 1];
|
||||
$list = AdminList::alias('a')
|
||||
->with('departments')
|
||||
->field('a.*,p.title as position,d.title as department')
|
||||
->join('Department d', 'd.id = a.did','left')
|
||||
->join('Position p', 'p.id = a.position_id','left')
|
||||
->where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->paginate(intval($this->pageSize))
|
||||
->order('a.id desc')
|
||||
->each(function ($item, $key) {
|
||||
//遍历次要部门数据
|
||||
$departments = $item->departments->toArray();
|
||||
if(empty($departments)){
|
||||
$item['departments'] = '-';
|
||||
}
|
||||
else{
|
||||
$item['departments'] = split_array_field($departments,'title');
|
||||
}
|
||||
if($item['political']==1){
|
||||
$item['political_str'] = '中共党员';
|
||||
}
|
||||
else if($item['political']==2){
|
||||
$item['political_str'] = '团员';
|
||||
}
|
||||
else{
|
||||
$item['political_str'] = '-';
|
||||
}
|
||||
$item['entry_time'] = to_date($item['entry_time'],'Y-m-d');
|
||||
$item['birthday_str'] = to_date($item['birthday'],'Y-m-d');
|
||||
$item['last_login_time'] = to_date('Y-m-d H:i', $item->last_login_time);
|
||||
$item['last_login_ip'] = empty($item['last_login_ip']) ? '-' : $item['last_login_ip'];
|
||||
return $item;
|
||||
});
|
||||
return table_assign(0, '', $list);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id'])?$param['id']:0;
|
||||
if (request()->isAjax()) {
|
||||
if($id == 1){
|
||||
return to_assign(1, '超级管理员信息不支持编辑');
|
||||
}
|
||||
$res = Db::name('Admin')->where(['id' => $id])->strict(false)->field(true)->update($param);
|
||||
if($res!==false){
|
||||
|
||||
//教育经历
|
||||
$edu_start_time = isset($param['edu_start_time']) ? $param['edu_start_time'] : '';
|
||||
$edu_end_time = isset($param['edu_end_time']) ? $param['edu_end_time'] : '';
|
||||
$edu_title = isset($param['edu_title']) ? $param['edu_title'] : '';
|
||||
$edu_speciality = isset($param['edu_speciality']) ? $param['edu_speciality'] : '';
|
||||
$edu_education = isset($param['edu_education']) ? $param['edu_education'] : '';
|
||||
$edu_remark = isset($param['edu_remark']) ? $param['edu_remark'] : '';
|
||||
$edu_id = isset($param['edu_id']) ? $param['edu_id'] : 0;
|
||||
|
||||
if ($edu_start_time) {
|
||||
foreach ($edu_start_time as $key => $value) {
|
||||
if (!$value && $value !=' ') {
|
||||
continue;
|
||||
}
|
||||
$data = [];
|
||||
$data['start_time'] = $value;
|
||||
$data['end_time'] = $edu_end_time[$key];
|
||||
$data['title'] = $edu_title[$key];
|
||||
$data['speciality'] = $edu_speciality[$key];
|
||||
$data['education'] = $edu_education[$key];
|
||||
$data['remark'] = $edu_remark[$key];
|
||||
$data['admin_id'] = $id;
|
||||
$data['types'] = 1;
|
||||
if($edu_id[$key]>0){
|
||||
$data['id'] = $edu_id[$key];
|
||||
$data['update_time'] = time();
|
||||
Db::name('AdminProfiles')->strict(false)->field(true)->update($data);
|
||||
}
|
||||
else{
|
||||
$data['create_uid'] = $this->uid;
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$eid = Db::name('AdminProfiles')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//工作经历
|
||||
$work_start_time = isset($param['work_start_time']) ? $param['work_start_time'] : '';
|
||||
$work_end_time = isset($param['work_end_time']) ? $param['work_end_time'] : '';
|
||||
$work_title = isset($param['work_title']) ? $param['work_title'] : '';
|
||||
$work_position = isset($param['work_position']) ? $param['work_position'] : '';
|
||||
$work_remark = isset($param['work_remark']) ? $param['work_remark'] : '';
|
||||
$work_id = isset($param['work_id']) ? $param['work_id'] : 0;
|
||||
|
||||
if ($work_start_time) {
|
||||
foreach ($work_start_time as $key => $value) {
|
||||
if (!$value && $value !=' ') {
|
||||
continue;
|
||||
}
|
||||
$data = [];
|
||||
$data['start_time'] = $value;
|
||||
$data['end_time'] = $work_end_time[$key];
|
||||
$data['title'] = $work_title[$key];
|
||||
$data['position'] = $work_position[$key];
|
||||
$data['remark'] = $work_remark[$key];
|
||||
$data['admin_id'] = $id;
|
||||
$data['types'] = 2;
|
||||
if($work_id[$key]>0){
|
||||
$data['id'] = $work_id[$key];
|
||||
$data['update_time'] = time();
|
||||
Db::name('AdminProfiles')->strict(false)->field(true)->update($data);
|
||||
}
|
||||
else{
|
||||
$data['create_uid'] = $this->uid;
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$eid = Db::name('AdminProfiles')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//相关证书
|
||||
$certificate_start_time = isset($param['certificate_start_time']) ? $param['certificate_start_time'] : '';
|
||||
$certificate_title = isset($param['certificate_title']) ? $param['certificate_title'] : '';
|
||||
$certificate_authority = isset($param['certificate_authority']) ? $param['certificate_authority'] : '';
|
||||
$certificate_remark = isset($param['certificate_remark']) ? $param['certificate_remark'] : '';
|
||||
$certificate_id = isset($param['certificate_id']) ? $param['certificate_id'] : 0;
|
||||
|
||||
if ($certificate_start_time) {
|
||||
foreach ($certificate_start_time as $key => $value) {
|
||||
if (!$value && $value !=' ') {
|
||||
continue;
|
||||
}
|
||||
$data = [];
|
||||
$data['start_time'] = $value;
|
||||
$data['title'] = $certificate_title[$key];
|
||||
$data['authority'] = $certificate_authority[$key];
|
||||
$data['remark'] = $certificate_remark[$key];
|
||||
$data['admin_id'] = $id;
|
||||
$data['types'] = 3;
|
||||
if($certificate_id[$key]>0){
|
||||
$data['id'] = $certificate_id[$key];
|
||||
$data['update_time'] = time();
|
||||
Db::name('AdminProfiles')->strict(false)->field(true)->update($data);
|
||||
}
|
||||
else{
|
||||
$data['create_uid'] = $this->uid;
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$eid = Db::name('AdminProfiles')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算机技能
|
||||
$skills_title = isset($param['skills_title']) ? $param['skills_title'] : '';
|
||||
$skills_know = isset($param['skills_know']) ? $param['skills_know'] : '';
|
||||
$skills_remark = isset($param['skills_remark']) ? $param['skills_remark'] : '';
|
||||
$skills_id = isset($param['skills_id']) ? $param['skills_id'] : 0;
|
||||
|
||||
if ($skills_title) {
|
||||
foreach ($skills_title as $key => $value) {
|
||||
if (!$value && $value !=' ') {
|
||||
continue;
|
||||
}
|
||||
$data = [];
|
||||
$data['title'] = $skills_title[$key];
|
||||
$data['know'] = $skills_know[$key];
|
||||
$data['remark'] = $skills_remark[$key];
|
||||
$data['admin_id'] = $id;
|
||||
$data['types'] = 4;
|
||||
if($skills_id[$key]>0){
|
||||
$data['id'] = $skills_id[$key];
|
||||
$data['update_time'] = time();
|
||||
Db::name('AdminProfiles')->strict(false)->field(true)->update($data);
|
||||
}
|
||||
else{
|
||||
$data['create_uid'] = $this->uid;
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$eid = Db::name('AdminProfiles')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//语言能力
|
||||
$language_title = isset($param['language_title']) ? $param['language_title'] : '';
|
||||
$language_know = isset($param['language_know']) ? $param['language_know'] : '';
|
||||
$language_remark = isset($param['language_remark']) ? $param['language_remark'] : '';
|
||||
$language_id = isset($param['language_id']) ? $param['language_id'] : 0;
|
||||
|
||||
if ($language_title) {
|
||||
foreach ($language_title as $key => $value) {
|
||||
if (!$value && $value !=' ') {
|
||||
continue;
|
||||
}
|
||||
$data = [];
|
||||
$data['title'] = $language_title[$key];
|
||||
$data['know'] = $language_know[$key];
|
||||
$data['remark'] = $language_remark[$key];
|
||||
$data['admin_id'] = $id;
|
||||
$data['types'] = 5;
|
||||
if($language_id[$key]>0){
|
||||
$data['id'] = $language_id[$key];
|
||||
$data['update_time'] = time();
|
||||
Db::name('AdminProfiles')->strict(false)->field(true)->update($data);
|
||||
}
|
||||
else{
|
||||
$data['create_uid'] = $this->uid;
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$eid = Db::name('AdminProfiles')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_log('edit', $id, $param);
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
return to_assign(1, '提交失败');
|
||||
}
|
||||
} else {
|
||||
$detail = get_admin($id);
|
||||
$detail['pname'] = Db::name('Admin')->where('id',$detail['pid'])->value('name');
|
||||
$detail['position'] = Db::name('Position')->where('id',$detail['position_id'])->value('title');
|
||||
$detail['department'] = Db::name('Department')->where('id',$detail['did'])->value('title');
|
||||
$department_ids = Db::name('DepartmentAdmin')->where('admin_id',$id)->column('department_id');
|
||||
$department_names = Db::name('Department')->whereIn('id',$department_ids)->column('title');
|
||||
$detail['department_names'] = implode(',',$department_names);
|
||||
|
||||
if($detail['file_ids'] !=''){
|
||||
$file_array = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
||||
$detail['file_array'] = $file_array;
|
||||
}
|
||||
|
||||
$edu = Db::name('AdminProfiles')->where(['types'=>1,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$work = Db::name('AdminProfiles')->where(['types'=>2,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$certificate = Db::name('AdminProfiles')->where(['types'=>3,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$skills = Db::name('AdminProfiles')->where(['types'=>4,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$language = Db::name('AdminProfiles')->where(['types'=>5,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
View::assign('edu', $edu);
|
||||
View::assign('work', $work);
|
||||
View::assign('skills', $skills);
|
||||
View::assign('certificate', $certificate);
|
||||
View::assign('language', $language);
|
||||
View::assign('detail', $detail);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id'])?$param['id']:0;
|
||||
$detail = get_admin($id);
|
||||
$detail['pname'] = Db::name('Admin')->where('id',$detail['pid'])->value('name');
|
||||
$detail['position'] = Db::name('Position')->where('id',$detail['position_id'])->value('title');
|
||||
$detail['department'] = Db::name('Department')->where('id',$detail['did'])->value('title');
|
||||
$department_ids = Db::name('DepartmentAdmin')->where('admin_id',$id)->column('department_id');
|
||||
$department_names = Db::name('Department')->whereIn('id',$department_ids)->column('title');
|
||||
$detail['department_names'] = implode(',',$department_names);
|
||||
if($detail['file_ids'] !=''){
|
||||
$file_array = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
||||
$detail['file_array'] = $file_array;
|
||||
}
|
||||
$edu = Db::name('AdminProfiles')->where(['types'=>1,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$work = Db::name('AdminProfiles')->where(['types'=>2,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$certificate = Db::name('AdminProfiles')->where(['types'=>3,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$skills = Db::name('AdminProfiles')->where(['types'=>4,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
$language = Db::name('AdminProfiles')->where(['types'=>5,'admin_id'=>$id,'delete_time'=>0])->select()->toArray();
|
||||
View::assign('edu', $edu);
|
||||
View::assign('work', $work);
|
||||
View::assign('skills', $skills);
|
||||
View::assign('certificate', $certificate);
|
||||
View::assign('language', $language);
|
||||
View::assign('detail', $detail);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\LaborContract as LaborContractModel;
|
||||
use app\user\validate\LaborContractValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Laborcontract extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new LaborContractModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if (!empty($param['status'])) {
|
||||
$where[] = ['status', '=', $param['status']];
|
||||
}
|
||||
if (!empty($param['types'])) {
|
||||
$where[] = ['types', '=', $param['types']];
|
||||
}
|
||||
if (!empty($param['cate'])) {
|
||||
$where[] = ['cate', '=', $param['cate']];
|
||||
}
|
||||
if (!empty($param['properties'])) {
|
||||
$where[] = ['properties', '=', $param['properties']];
|
||||
}
|
||||
if (!empty($param['uid'])) {
|
||||
$where[] = ['uid', '=', $param['uid']];
|
||||
}
|
||||
if (!empty($param['diff_time'])) {
|
||||
$diff_time =explode('~', $param['diff_time']);
|
||||
$where[] = ['sign_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
|
||||
}
|
||||
$list = $this->model->datalist($where, $param);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
$this->model::where([['end_time','<',time()],['status','=',1]])->update(['status'=>2]);
|
||||
View::assign('cate', $this->model::$laborcontract_cate);
|
||||
View::assign('types', $this->model::$laborcontract_types);
|
||||
View::assign('properties', $this->model::$laborcontract_properties);
|
||||
View::assign('status', $this->model::$laborcontract_status);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['sign_time'] = isset($param['sign_time']) ? strtotime($param['sign_time']) : 0;
|
||||
$param['start_time'] = isset($param['start_time']) ? strtotime($param['start_time']) : 0;
|
||||
$param['end_time'] = isset($param['end_time']) ? strtotime($param['end_time']) : 0;
|
||||
$param['trial_end_time'] = isset($param['trial_end_time']) ? strtotime($param['trial_end_time']) : 0;
|
||||
if($param['end_time']<=$param['start_time']){
|
||||
return to_assign(1,'合同失效时间需要大于开始时间');
|
||||
}
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(LaborContractValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
if($param['end_time']<time() && $param['status']==1){
|
||||
$param['status'] = 2;
|
||||
}
|
||||
if($param['end_time']>time() && $param['status']==2){
|
||||
$param['status'] = 1;
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(LaborContractValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
if($param['end_time']<time()){
|
||||
$param['status'] = 2;
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$cate_id = isset($param['cate_id']) ? $param['cate_id'] : 0;
|
||||
View::assign('properties', $this->model::$laborcontract_properties);
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getById($id);
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
if($detail['file_ids'] !=''){
|
||||
$file_array = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
||||
$detail['file_array'] = $file_array;
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
return view('edit');
|
||||
}
|
||||
$cate_title='';
|
||||
if($cate_id>0){
|
||||
$cate_title = $this->model::$laborcontract_cate[$cate_id-1]['title'];
|
||||
}
|
||||
View::assign('id', $id);
|
||||
View::assign('cate_id', $cate_id);
|
||||
View::assign('cate_title', $cate_title);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 续签合同
|
||||
*/
|
||||
public function add_renewal()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['sign_time'] = isset($param['sign_time']) ? strtotime($param['sign_time']) : 0;
|
||||
$param['start_time'] = isset($param['start_time']) ? strtotime($param['start_time']) : 0;
|
||||
$param['end_time'] = isset($param['end_time']) ? strtotime($param['end_time']) : 0;
|
||||
$param['trial_end_time'] = isset($param['trial_end_time']) ? strtotime($param['trial_end_time']) : 0;
|
||||
if($param['end_time']<=$param['start_time']){
|
||||
return to_assign(1,'合同失效时间需要大于开始时间');
|
||||
}
|
||||
if($param['end_time']<time()){
|
||||
$param['status'] = 3;
|
||||
}
|
||||
try {
|
||||
validate(LaborContractValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if($id>0){
|
||||
$detail = $this->model->getById($id);
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('properties', $this->model::$laborcontract_properties);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更合同
|
||||
*/
|
||||
public function add_change()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['sign_time'] = isset($param['sign_time']) ? strtotime($param['sign_time']) : 0;
|
||||
$param['start_time'] = isset($param['start_time']) ? strtotime($param['start_time']) : 0;
|
||||
$param['end_time'] = isset($param['end_time']) ? strtotime($param['end_time']) : 0;
|
||||
$param['trial_end_time'] = isset($param['trial_end_time']) ? strtotime($param['trial_end_time']) : 0;
|
||||
if($param['end_time']<=$param['start_time']){
|
||||
return to_assign(1,'合同失效时间需要大于开始时间');
|
||||
}
|
||||
if($param['end_time']<time()){
|
||||
$param['status'] = 3;
|
||||
}
|
||||
try {
|
||||
validate(LaborContractValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if($id>0){
|
||||
$detail = $this->model->getById($id);
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('properties', $this->model::$laborcontract_properties);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$detail = $this->model->getById($id);
|
||||
if (!empty($detail)) {
|
||||
$detail['cate_str'] = $this->model::$laborcontract_cate[$detail['cate']-1]['title'];
|
||||
$detail['types_str'] = $this->model::$laborcontract_types[$detail['types']];
|
||||
$detail['properties_str'] = $this->model::$laborcontract_properties[$detail['properties']];
|
||||
$detail['status_str'] = $this->model::$laborcontract_status[$detail['status']];
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
$detail['admin_name'] = Db::name('Admin')->where('id',$detail['admin_id'])->value('name');
|
||||
if($detail['file_ids'] !=''){
|
||||
$file_array = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
||||
$detail['file_array'] = $file_array;
|
||||
}
|
||||
if($detail['renewal_pid'] > 0){
|
||||
$detail['renewal_ptitle'] = Db::name('LaborContract')->where('id',$detail['renewal_pid'])->value('title');
|
||||
}
|
||||
if($detail['change_pid'] > 0){
|
||||
$detail['change_ptitle'] = Db::name('LaborContract')->where('id',$detail['change_pid'])->value('title');
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
View::assign('renewal', Db::name('LaborContract')->where(['renewal_pid'=>$id,'delete_time'=>0])->find());
|
||||
View::assign('change', Db::name('LaborContract')->where(['change_pid'=>$id,'delete_time'=>0])->find());
|
||||
return view();
|
||||
}
|
||||
else{
|
||||
throw new \think\exception\HttpException(404, '找不到页面');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if (request()->isDelete()) {
|
||||
$this->model->delById($id);
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解除、恢复
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$renewal = Db::name('LaborContract')->where(['renewal_pid'=> $param['id'],'delete_time'=>0])->count();
|
||||
$change = Db::name('LaborContract')->where(['change_pid'=> $param['id'],'delete_time'=>0])->count();
|
||||
if($renewal>0 || $change>0){
|
||||
return to_assign(1, "已续签或者已变更的合同不支持该操作");
|
||||
}
|
||||
$this->model::where('id', $param['id'])->strict(false)->field(true)->update(['status'=> $param['status']]);
|
||||
if($param['status']==3){
|
||||
add_log('secure',$param['id'], $param);
|
||||
}
|
||||
else{
|
||||
add_log('recovery', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\DepartmentChange as DepartmentChange;
|
||||
use app\user\model\PersonalQuit as PersonalQuit;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Personal extends BaseController
|
||||
{
|
||||
//调部门列表
|
||||
public function change()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$tab = isset($param['tab']) ? $param['tab'] : 0;
|
||||
$uid = $this->uid;
|
||||
$where=[];
|
||||
$whereOr=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if($tab == 0){
|
||||
//全部
|
||||
$auth = isAuth($uid,'office_admin','conf_1');
|
||||
if($auth == 0){
|
||||
$whereOr[] = ['admin_id', '=', $uid];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
$dids_a = get_leader_departments($uid);
|
||||
$dids_b = get_role_departments($uid);
|
||||
$dids = array_merge($dids_a, $dids_b);
|
||||
if(!empty($dids)){
|
||||
$whereOr[] = ['did','in',$dids];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($tab == 1){
|
||||
//我创建的
|
||||
$where[] = ['admin_id', '=', $this->uid];
|
||||
}
|
||||
if($tab == 2){
|
||||
//待我审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
}
|
||||
if($tab == 3){
|
||||
//我已审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
}
|
||||
if($tab == 4){
|
||||
//抄送给我的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
}
|
||||
if (isset($param['check_status']) && $param['check_status'] != "") {
|
||||
$where[] = ['check_status', '=', $param['check_status']];
|
||||
}
|
||||
if (!empty($param['did'])) {
|
||||
$where[] = ['did', '=',$param['did']];
|
||||
}
|
||||
//按时间检索
|
||||
if (!empty($param['move_time'])) {
|
||||
$move_time =explode('~', $param['move_time']);
|
||||
$where[] = ['move_time', 'between', [strtotime(urldecode($move_time[0])),strtotime(urldecode($move_time[1]))]];
|
||||
}
|
||||
$model = new DepartmentChange();
|
||||
$list = $model->datalist($param,$where,$whereOr);
|
||||
return table_assign(0, '', $list);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//新增&编辑调部门
|
||||
public function change_add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['move_time'] = isset($param['move_time']) ? strtotime($param['move_time']) : 0;
|
||||
$model = new DepartmentChange();
|
||||
if ($param['id'] > 0) {
|
||||
$model->edit($param);
|
||||
} else {
|
||||
$uid = $param['uid'];
|
||||
$map = [];
|
||||
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',leader_ids)")];
|
||||
$count = Db::name('Department')->where($map)->count();
|
||||
if($count>0){
|
||||
return to_assign(1,'请先撤销该员工的部门负责人头衔再申请');
|
||||
}
|
||||
$has = Db::name('DepartmentChange')->where(['uid'=>$param['uid'],'status'=>1,'delete_time'=>0])->count();
|
||||
if($has>0){
|
||||
return to_assign(1, "该员工有调动记录未完成,不能重复申请");
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$model->add($param);
|
||||
}
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$department = set_recursion(get_department());
|
||||
if ($id > 0) {
|
||||
$model = new DepartmentChange();
|
||||
$detail = $model->getById($id);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('department', $department);
|
||||
View::assign('id', $id);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/add_change');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//查看调部门申请
|
||||
public function change_view()
|
||||
{
|
||||
$param = get_params();
|
||||
$model = new DepartmentChange();
|
||||
$detail = $model->getById($param['id']);
|
||||
View::assign('detail', $detail);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/view_change');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
//删除调部门申请
|
||||
public function change_delete()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = $param['id'];
|
||||
if (request()->isDelete()) {
|
||||
$model = new DepartmentChange();
|
||||
$model->delById($id);
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//离职
|
||||
public function leave()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$tab = isset($param['tab']) ? $param['tab'] : 0;
|
||||
$uid = $this->uid;
|
||||
$where=[];
|
||||
$whereOr=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if($tab == 0){
|
||||
//全部
|
||||
$auth = isAuth($uid,'office_admin','conf_1');
|
||||
if($auth == 0){
|
||||
$whereOr[] = ['admin_id', '=', $this->uid];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
$dids_a = get_leader_departments($uid);
|
||||
$dids_b = get_role_departments($uid);
|
||||
$dids = array_merge($dids_a, $dids_b);
|
||||
if(!empty($dids)){
|
||||
$whereOr[] = ['did','in',$dids];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($tab == 1){
|
||||
//我创建的
|
||||
$where[] = ['admin_id', '=', $uid];
|
||||
}
|
||||
if($tab == 2){
|
||||
//待我审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
}
|
||||
if($tab == 3){
|
||||
//我已审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
}
|
||||
if($tab == 4){
|
||||
//抄送给我的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
}
|
||||
if (isset($param['check_status']) && $param['check_status'] != "") {
|
||||
$where[] = ['check_status', '=', $param['check_status']];
|
||||
}
|
||||
if (!empty($param['did'])) {
|
||||
$where[] = ['did', '=',$param['did']];
|
||||
}
|
||||
//按时间检索
|
||||
if (!empty($param['quit_time'])) {
|
||||
$quit_time =explode('~', $param['quit_time']);
|
||||
$where[] = ['quit_time', 'between', [strtotime(urldecode($quit_time[0])),strtotime(urldecode($quit_time[1]))]];
|
||||
}
|
||||
$model = new PersonalQuit();
|
||||
$list = $model->datalist($param,$where,$whereOr);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加离职申请
|
||||
public function leave_add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0;
|
||||
$model = new PersonalQuit();
|
||||
if ($param['id'] > 0) {
|
||||
$has = Db::name('PersonalQuit')->where([['uid','=',$param['uid']],['delete_time','=',0],['id','<>',$param['id']]])->count();
|
||||
if($has>0){
|
||||
return to_assign(1, "该员工已申请有离职记录,不能重复申请");
|
||||
}
|
||||
$detail = $model->edit($param);
|
||||
} else {
|
||||
$has = Db::name('PersonalQuit')->where(['uid'=>$param['uid'],'delete_time'=>0])->count();
|
||||
if($has>0){
|
||||
return to_assign(1, "该员工已申请有离职记录,不能重复申请");
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$detail = $model->add($param);
|
||||
}
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$uid = isset($param['uid']) ? $param['uid'] : 0;
|
||||
$detail=[];
|
||||
if($uid>0){
|
||||
$admin = get_admin($uid);
|
||||
$detail['name'] = $admin['name'];
|
||||
$detail['did'] = $admin['did'];
|
||||
$detail['department'] = $admin['department'];
|
||||
}
|
||||
if ($id>0) {
|
||||
$model = new PersonalQuit();
|
||||
$detail = $model->getById($id);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
View::assign('detail', $detail);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/add_leave');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//查看离职申请
|
||||
public function leave_view()
|
||||
{
|
||||
$param = get_params();
|
||||
$model = new PersonalQuit();
|
||||
$detail = $model->getById($param['id']);
|
||||
View::assign('detail', $detail);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/view_leave');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
|
||||
//删除离职申请
|
||||
public function leave_delete()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = $param['id'];
|
||||
if (request()->isDelete()) {
|
||||
$model = new PersonalQuit();
|
||||
$model->delById($id);
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\validate\PositionCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Position extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select()->toArray();
|
||||
foreach ($list as &$val) {
|
||||
$groupId = Db::name('PositionGroup')->where(['pid' => $val['id']])->column('group_id');
|
||||
$groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title');
|
||||
$val['groupName'] = implode(',', $groupName);
|
||||
}
|
||||
$res['data'] = $list;
|
||||
return table_assign(0, '', $res);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加&编辑
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
if($param['id']==1){
|
||||
return to_assign(1, '超级管理员不能编辑');
|
||||
}
|
||||
try {
|
||||
validate(PositionCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('Position')->where(['id' => $param['id']])->strict(false)->field(true)->update($param);
|
||||
Db::name('PositionGroup')->where(['pid' => $param['id']])->delete();
|
||||
foreach ($param['group_id'] as $k => $v) {
|
||||
$data[$k] = [
|
||||
'pid' => $param['id'],
|
||||
'group_id' => $v,
|
||||
'create_time' => time(),
|
||||
];
|
||||
}
|
||||
Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data);
|
||||
add_log('edit', $param['id'], $param);
|
||||
//清除菜单\权限缓存
|
||||
clear_cache('adminMenu');
|
||||
clear_cache('adminRules');
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return to_assign(1, '提交失败:' . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
validate(PositionCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
$uid = Db::name('Position')->strict(false)->field(true)->insertGetId($param);
|
||||
foreach ($param['group_id'] as $k => $v) {
|
||||
$data[$k] = [
|
||||
'pid' => $uid,
|
||||
'group_id' => $v,
|
||||
'create_time' => time(),
|
||||
];
|
||||
}
|
||||
Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data);
|
||||
add_log('add', $uid, $param);
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return to_assign(1, '提交失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
if ($id > 0) {
|
||||
$detail = Db::name('Position')->where(['id' => $id])->find();
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if (in_array($val['id'], $detail['group_id'])) {
|
||||
$val['checked'] = 1;
|
||||
} else {
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('group', $group);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$id = get_params('id');
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
$detail = Db::name('Position')->where(['id' => $id])->find();
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if (in_array($val['id'], $detail['group_id'])) {
|
||||
$val['checked'] = 1;
|
||||
} else {
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$rule = Db::name('AdminRule')->order('sort asc,id asc')->select()->toArray();
|
||||
$user_groups = Db::name('PositionGroup')
|
||||
->alias('a')
|
||||
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
|
||||
->where("a.pid='{$id}' and g.status='1'")
|
||||
->select()
|
||||
->toArray();
|
||||
$groups = $user_groups ?: [];
|
||||
|
||||
$rules = [];
|
||||
foreach ($groups as $g) {
|
||||
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
|
||||
}
|
||||
$rules = array_unique($rules);
|
||||
|
||||
$role_rule = create_tree_list(0, $rule, $rules);
|
||||
View::assign('role_rule', $role_rule);
|
||||
View::assign('detail', $detail);
|
||||
View::assign('group', $group);
|
||||
add_log('view', $id);
|
||||
return view();
|
||||
}
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if ($id == 1) {
|
||||
return to_assign(0, "超级岗位,不能删除");
|
||||
}
|
||||
$data['status'] = '-1';
|
||||
$data['id'] = $id;
|
||||
$data['update_time'] = time();
|
||||
if (Db::name('Position')->update($data) !== false) {
|
||||
add_log('delete', $id);
|
||||
return to_assign(0, "删除岗位成功");
|
||||
} else {
|
||||
return to_assign(1, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Rewards as RewardsModel;
|
||||
use app\user\validate\RewardsValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Rewards extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new RewardsModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where=[];
|
||||
$where[]=['delete_time','=',0];
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['id|thing|remark', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (!empty($param['status'])) {
|
||||
$where[] = ['status', '=', $param['status']];
|
||||
}
|
||||
if (!empty($param['types'])) {
|
||||
$where[] = ['types', '=', $param['types']];
|
||||
}
|
||||
if (!empty($param['rewards_cate'])) {
|
||||
$where[] = ['rewards_cate', '=', $param['rewards_cate']];
|
||||
}
|
||||
if (!empty($param['uid'])) {
|
||||
$where[] = ['uid', '=', $param['uid']];
|
||||
}
|
||||
if (!empty($param['diff_time'])) {
|
||||
$diff_time =explode('~', $param['diff_time']);
|
||||
$where[] = ['rewards_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
|
||||
}
|
||||
$list = $this->model->datalist($where, $param);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['rewards_time'] = isset($param['rewards_time']) ? strtotime($param['rewards_time']) : 0;
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(RewardsValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(RewardsValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getById($id);
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
$detail['rewards_time'] = to_date($detail['rewards_time'],'Y-m-d');
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$detail = $this->model->getById($id);
|
||||
if (!empty($detail)) {
|
||||
$detail['cate'] = Db::name('RewardsCate')->where('id',$detail['rewards_cate'])->value('title');
|
||||
$detail['user_name'] = Db::name('Admin')->where('id',$detail['uid'])->value('name');
|
||||
$detail['admin_name'] = Db::name('Admin')->where('id',$detail['admin_id'])->value('name');
|
||||
$detail['rewards_time'] = to_date($detail['rewards_time'],'Y-m-d');
|
||||
View::assign('detail', $detail);
|
||||
return view();
|
||||
}
|
||||
else{
|
||||
throw new \think\exception\HttpException(404, '找不到页面');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$this->model->delById($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\RewardsCate as RewardsCateModel;
|
||||
use app\user\validate\RewardsCateValidate;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Rewardscate extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new RewardsCateModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = $this->model->select();
|
||||
return to_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(RewardsCateValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(RewardsCateValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getCateById($id);
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
$param = get_params();
|
||||
$res = $this->model->strict(false)->field('id,status')->update($param);
|
||||
if ($res) {
|
||||
if($param['status'] == 0){
|
||||
add_log('disable', $param['id'], $param);
|
||||
}
|
||||
else if($param['status'] == 1){
|
||||
add_log('recovery', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
return to_assign(0, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Talent as TalentModel;
|
||||
use app\user\validate\TalentValidate;
|
||||
use think\exception\ValidateException;
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Talent extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
protected $model;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(); // 调用父类构造函数
|
||||
$this->model = new TalentModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
public function datalist()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$tab = isset($param['tab']) ? $param['tab'] : 0;
|
||||
$uid = $this->uid;
|
||||
$where = array();
|
||||
$whereOr = array();
|
||||
$where[]=['delete_time','=',0];
|
||||
if($tab == 0){
|
||||
//全部
|
||||
$auth = isAuth($uid,'office_admin','conf_1');
|
||||
if($auth == 0){
|
||||
$whereOr[] = ['admin_id', '=', $this->uid];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
$dids_a = get_leader_departments($uid);
|
||||
$dids_b = get_role_departments($uid);
|
||||
$dids = array_merge($dids_a, $dids_b);
|
||||
if(!empty($dids)){
|
||||
$whereOr[] = ['did','in',$dids];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($tab == 1){
|
||||
//我创建的
|
||||
$where[] = ['admin_id', '=', $this->uid];
|
||||
}
|
||||
if($tab == 2){
|
||||
//待我审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
|
||||
}
|
||||
if($tab == 3){
|
||||
//我已审核的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
|
||||
}
|
||||
if($tab == 4){
|
||||
//抄送给我的
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
|
||||
}
|
||||
if (isset($param['check_status']) && $param['check_status'] != "") {
|
||||
$where[] = ['check_status', '=', $param['check_status']];
|
||||
}
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['name|mobile', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (!empty($param['did'])) {
|
||||
$where[] = ['to_did', '=',$param['did']];
|
||||
}
|
||||
//按时间检索
|
||||
if (!empty($param['entry_time'])) {
|
||||
$entry_time =explode('~', $param['entry_time']);
|
||||
$where[] = ['entry_time', 'between', [strtotime(urldecode($entry_time[0])),strtotime(urldecode($entry_time[1]))]];
|
||||
}
|
||||
$list = $this->model->datalist($param,$where,$whereOr);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
View::assign('is_auth', isAuth($this->uid,'office_admin','conf_1'));
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['entry_time'] = empty($param['entry_time']) ? '0':strtotime($param['entry_time']);
|
||||
$count_a=0;
|
||||
$count_b=0;
|
||||
if(!empty($param['idcard'])){
|
||||
$count_a = Db::name('Blacklist')->where([['idcard','=',$param['idcard']],['delete_time','=',0]])->count();
|
||||
}
|
||||
if(!empty($param['mobile'])){
|
||||
$count_b = Db::name('Blacklist')->where([['mobile','=',$param['mobile']],['delete_time','=',0]])->count();
|
||||
}
|
||||
if($count_a>0 || $count_b>0){
|
||||
return to_assign(1, '该员工的信息已被列入黑名单,不支持申请');
|
||||
}
|
||||
$count_c = Db::name('Admin')->where([['mobile','=',$param['mobile']],['status','in',['0,1']],['delete_time','=',0]])->count();
|
||||
$count_d = Db::name('Admin')->where([['email','=',$param['email']],['status','in',['0,1']],['delete_time','=',0]])->count();
|
||||
if($count_c>0){
|
||||
return to_assign(1, '该手机号已被其他员工占用,不支持申请');
|
||||
}
|
||||
if($count_d>0){
|
||||
return to_assign(1, '该邮箱已被其他员工占用,不支持申请');
|
||||
}
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(IndexValidate::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$this->model->edit($param);
|
||||
} else {
|
||||
try {
|
||||
validate(IndexValidate::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['admin_id'] = $this->uid;
|
||||
$param['did'] = $this->did;
|
||||
$this->model->add($param);
|
||||
}
|
||||
}else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
if ($id>0) {
|
||||
$detail = $this->model->getById($id);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
$position = Db::name('Position')->where([['status', '>=', 0]])->order('create_time asc')->select();
|
||||
View::assign('position', $position);
|
||||
View::assign('id', $id);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/add_talent');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$detail = $this->model->getById($id);
|
||||
if (!empty($detail)) {
|
||||
$detail['department'] = Db::name('Department')->where('id', '=', $detail['to_did'])->value('title');
|
||||
$detail['position'] = Db::name('Position')->where('id', '=', $detail['position_id'])->value('title');
|
||||
View::assign('detail', $detail);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/view_talent');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
else{
|
||||
return view(EEEOR_REPORTING,['code'=>404,'warning'=>'找不到页面']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if (request()->isDelete()) {
|
||||
$this->model->delById($id);
|
||||
} else {
|
||||
return to_assign(1, "错误的请求");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 转为正式员工
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param['update_time'] = time();
|
||||
$param['entry_time'] = strtotime($param['entry_time']);
|
||||
Db::name('Talent')->strict(false)->field(true)->update($param);
|
||||
$detail = Db::name('Talent')->where('id', $param['id'])->find();
|
||||
$count_a = Db::name('Admin')->where([['status', 'in', [0,1]],['mobile','=',$detail['mobile']],['delete_time','=',0]])->count();
|
||||
if($count_a>0){
|
||||
return to_assign(1, "同样的手机号码已经存在,请检查一下是否被离职或者禁用员工占用");
|
||||
}
|
||||
$detail['nickname'] = $detail['name'];
|
||||
$char = $detail['name'];
|
||||
$username = Pinyin::name($char,'none')->join('');
|
||||
$detail['username'] = $this->create_name($username,0);
|
||||
$detail['did'] = $detail['to_did'];
|
||||
$detail['salt'] = set_salt(20);
|
||||
$detail['reg_pwd'] = $param['reg_pwd'];
|
||||
$detail['thumb'] = get_file($detail['thumb']);
|
||||
$detail['pwd'] = set_password($detail['reg_pwd'], $detail['salt']);
|
||||
$detail['talent_id'] = $detail['id'];
|
||||
unset($detail['id']);
|
||||
$uid = Db::name('Admin')->strict(false)->field(true)->insertGetId($detail);
|
||||
if($uid!==false){
|
||||
Db::name('Talent')->where('id',$param ['id'])->update(['status'=>2]);
|
||||
add_log('add', $uid, $param);
|
||||
return to_assign();
|
||||
}
|
||||
else {
|
||||
return to_assign(1, "操作失败");
|
||||
}
|
||||
}
|
||||
else{
|
||||
$position = Db::name('Position')->where([['status', '>=', 0]])->order('create_time asc')->select();
|
||||
$detail = $this->model->getById($param['id']);
|
||||
View::assign('position', $position);
|
||||
//初始化密码
|
||||
View::assign('reg_pwd', set_salt(6));
|
||||
View::assign('detail', $detail);
|
||||
if(is_mobile()){
|
||||
return view('qiye@/approve/set_talent');
|
||||
}
|
||||
return view();
|
||||
}
|
||||
}
|
||||
//生成登录名
|
||||
public function create_name($name,$id=0,$total=0,$old='')
|
||||
{
|
||||
$count = Db::name('Admin')->where([['username','=',$name],['id','<>',$id]])->count();
|
||||
if($total==0){
|
||||
$old = $name;
|
||||
}
|
||||
$total++;
|
||||
if($count>0){
|
||||
$newname = $old.$total;
|
||||
$name = $this->create_name($newname,$id,$total,$old);
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\base\BaseController;
|
||||
use app\user\model\Admin as AdminList;
|
||||
use app\user\model\Department as DepartmentModel;
|
||||
use app\user\validate\AdminCheck;
|
||||
use avatars\MDAvatars;
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class User extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = array();
|
||||
$whereOr = array();
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['a.id|a.username|a.name|a.nickname|a.mobile|a.desc', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (isset($param['status']) && $param['status']!='') {
|
||||
$where[] = ['a.status', '=', $param['status']];
|
||||
}
|
||||
else{
|
||||
$where[] = ['a.status', '=', 1];
|
||||
}
|
||||
if (!empty($param['type'])) {
|
||||
$where[] = ['a.type', '=', $param['type']];
|
||||
}
|
||||
if (!empty($param['did'])) {
|
||||
$admin_array = Db::name('DepartmentAdmin')->where('department_id',$param['did'])->column('admin_id');
|
||||
$map1=[
|
||||
['a.id','in',$admin_array],
|
||||
];
|
||||
$map2=[
|
||||
['a.did', '=', $param['did']],
|
||||
];
|
||||
$whereOr =[$map1,$map2];
|
||||
}
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$admin = AdminList::alias('a')
|
||||
->with('departments')
|
||||
->field('a.*,p.title as position,d.title as department')
|
||||
->join('Department d', 'd.id = a.did','left')
|
||||
->join('Position p', 'p.id = a.position_id','left')
|
||||
->where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->order('a.id desc')
|
||||
->each(function ($item, $key) {
|
||||
//遍历次要部门数据
|
||||
$departments = $item['departments']->toArray();
|
||||
if(empty($departments)){
|
||||
$item['departments'] = '-';
|
||||
}
|
||||
else{
|
||||
$item['departments'] = split_array_field($departments,'title');
|
||||
}
|
||||
$item['entry_time'] = to_date($item['entry_time'],'Y-m-d');
|
||||
$item['last_login_time'] = to_date($item['last_login_time'],'Y-m-d H:i');
|
||||
$item['last_login_ip'] = empty($item['last_login_ip']) ? '-' : $item['last_login_ip'];
|
||||
});
|
||||
return table_assign(0, '', $admin);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//生成登录名
|
||||
public function create_name($name,$id=0,$total=0,$old='')
|
||||
{
|
||||
$count = Db::name('Admin')->where([['username','=',$name],['id','<>',$id]])->count();
|
||||
if($total==0){
|
||||
$old = $name;
|
||||
}
|
||||
$total++;
|
||||
if($count>0){
|
||||
$newname = $old.$total;
|
||||
$name = $this->create_name($newname,$id,$total,$old);
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$id = isset($param['id'])?$param['id']:0;
|
||||
$param['entry_time'] = strtotime($param['entry_time']);
|
||||
$param['nickname'] = $param['name'];
|
||||
if ($id > 0) {
|
||||
if($id == 1){
|
||||
return to_assign(1, '超级管理员信息不支持编辑');
|
||||
}
|
||||
try {
|
||||
validate(AdminCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$detail = get_admin($param['id']);
|
||||
$department_ids = Db::name('DepartmentAdmin')->where('admin_id',$param['id'])->column('department_id');
|
||||
$detail['department_ids'] = implode(',',$department_ids);
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('Admin')->where(['id' => $id])->strict(false)->field(true)->update($param);
|
||||
if($detail['department_ids'] != $param['department_ids']){
|
||||
Db::name('DepartmentAdmin')->where('admin_id',$id)->whereIn('department_id', $detail['department_ids'])->delete();
|
||||
if(!empty($param['department_ids'])){
|
||||
$dids = explode(',',$param['department_ids']);
|
||||
foreach ($dids as $did) {
|
||||
Db::name('DepartmentAdmin')->insert(['admin_id'=>$param['id'],'department_id'=>$did,'create_time' => time()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($param['thumb'])){
|
||||
$char = mb_substr($param['name'], 0, 1, 'utf-8');
|
||||
Db::name('Admin')->where('id', $id)->update(['thumb' => $this->to_avatars($char)]);
|
||||
}
|
||||
$info = Db::name('Admin')->where('id', $id)->find();
|
||||
$model = new DepartmentModel();
|
||||
$auth_dids = $model->get_auth_departments($info);
|
||||
$son_dids = $model->get_son_departments($info);
|
||||
Db::name('Admin')->where('id',$id)->update(['auth_dids'=>$auth_dids,'son_dids'=>$son_dids]);
|
||||
add_log('edit', $id, $param);
|
||||
//清除菜单\权限缓存
|
||||
clear_cache('adminMenu');
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return to_assign(1, '提交失败:' . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$username = Pinyin::name($param['name'],'none')->join('');
|
||||
$param['username'] = $this->create_name($username,$id);
|
||||
try {
|
||||
validate(AdminCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = time();
|
||||
$param['salt'] = set_salt(20);
|
||||
$param['pwd'] = set_password($param['reg_pwd'], $param['salt']);
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
$uid = Db::name('Admin')->strict(false)->field(true)->insertGetId($param);
|
||||
if(!empty($param['department_ids'])){
|
||||
$dids = explode(',',$param['department_ids']);
|
||||
foreach ($dids as $did) {
|
||||
Db::name('DepartmentAdmin')->insert(['admin_id'=>$uid,'department_id'=>$did,'create_time' => time()]);
|
||||
}
|
||||
}
|
||||
if(empty($param['thumb'])){
|
||||
$char = mb_substr($param['name'], 0, 1, 'utf-8');
|
||||
Db::name('Admin')->where('id', $uid)->update(['thumb' => $this->to_avatars($char)]);
|
||||
}
|
||||
$info = Db::name('Admin')->where('id', $uid)->find();
|
||||
$model = new DepartmentModel();
|
||||
$auth_dids = $model->get_auth_departments($info);
|
||||
$son_dids = $model->get_son_departments($info);
|
||||
Db::name('Admin')->where('id',$uid)->update(['auth_dids'=>$auth_dids,'son_dids'=>$son_dids]);
|
||||
add_log('add', $uid, $param);
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return to_assign(1, '提交失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$department = set_recursion(get_department());
|
||||
$position = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select();
|
||||
if ($id > 0) {
|
||||
$detail = get_admin($id);
|
||||
$detail['pname'] = Db::name('Admin')->where('id',$detail['pid'])->value('name');
|
||||
$department_ids = Db::name('DepartmentAdmin')->where('admin_id',$param['id'])->column('department_id');
|
||||
$detail['department_ids'] = implode(',',$department_ids);
|
||||
View::assign('detail', $detail);
|
||||
} else {
|
||||
//初始化密码
|
||||
$reg_pwd = set_salt(6);
|
||||
View::assign('reg_pwd', $reg_pwd);
|
||||
}
|
||||
View::assign('department', $department);
|
||||
View::assign('position', $position);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
//生成头像
|
||||
public function to_avatars($char)
|
||||
{
|
||||
$defaultData = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾',
|
||||
'一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
|
||||
if (isset($char)) {
|
||||
$Char = $char;
|
||||
} else {
|
||||
$Char = $defaultData[mt_rand(0, count($defaultData) - 1)];
|
||||
}
|
||||
$OutputSize = min(512, empty($_GET['size']) ? 36 : intval($_GET['size']));
|
||||
|
||||
$Avatar = new MDAvatars($Char, 256, 1);
|
||||
$avatar_name = '/avatars/avatar_256_' . set_salt(10) . time() . '.png';
|
||||
$path = get_config('filesystem.disks.public.url') . $avatar_name;
|
||||
$res = $Avatar->Save('.' . $path, 256);
|
||||
$Avatar->Free();
|
||||
return $path;
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$id = get_params('id');
|
||||
$detail = get_admin($id);
|
||||
$department_ids = Db::name('DepartmentAdmin')->where('admin_id',$id)->column('department_id');
|
||||
$department_names = Db::name('Department')->whereIn('id',$department_ids)->column('title');
|
||||
$detail['department_names'] = implode(',',$department_names);
|
||||
$detail['pname'] = Db::name('Admin')->where('id',$detail['pid'])->value('name');
|
||||
//查询所有菜单和权限节点
|
||||
$menu = Db::name('AdminRule')->where(['menu' => 1])->order('sort asc,id asc')->select()->toArray();
|
||||
$rule = Db::name('AdminRule')->order('sort asc,id asc')->select()->toArray();
|
||||
|
||||
//查询用户拥有的菜单和节点
|
||||
$user_groups = Db::name('PositionGroup')
|
||||
->alias('a')
|
||||
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
|
||||
->where([['a.pid', '=', $detail["position_id"]], ['g.status', '=', 1]])
|
||||
->select()
|
||||
->toArray();
|
||||
$groups = $user_groups ?: [];
|
||||
|
||||
$rules = [];
|
||||
foreach ($groups as $g) {
|
||||
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
|
||||
}
|
||||
$rules = array_unique($rules);
|
||||
|
||||
//数据嵌套
|
||||
$role_rule = create_tree_list(0, $rule, $rules);
|
||||
|
||||
View::assign('role_rule', $role_rule);
|
||||
View::assign('detail', $detail);
|
||||
add_log('view', get_params('id'));
|
||||
return view();
|
||||
}
|
||||
//禁用,恢复
|
||||
public function set()
|
||||
{
|
||||
$type = get_params("type");
|
||||
$ids = get_params("ids");
|
||||
$idArray = explode(',', $ids);
|
||||
$list = [];
|
||||
foreach ($idArray as $key => $val) {
|
||||
if ($val == 1) {
|
||||
continue;
|
||||
}
|
||||
$list[] = [
|
||||
'status' => $type,
|
||||
'id' => $val,
|
||||
'update_time' => time(),
|
||||
];
|
||||
}
|
||||
foreach ($list as $key => $v) {
|
||||
if (Db::name('Admin')->update($v) !== false) {
|
||||
if ($type == 0) {
|
||||
add_log('disable', $v['id']);
|
||||
} else if ($type == 1) {
|
||||
add_log('recovery', $v['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return to_assign(0, '操作成功');
|
||||
}
|
||||
|
||||
//重置密码
|
||||
public function reset_psw()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if($id == 1){
|
||||
return to_assign(1, '该账号是超级管理员,不允许重置');
|
||||
}
|
||||
$new_pwd = set_salt(6);
|
||||
$salt = set_salt(20);
|
||||
$data = [
|
||||
'reg_pwd' => $new_pwd,
|
||||
'salt' => $salt,
|
||||
'pwd' => set_password($new_pwd, $salt),
|
||||
'id' => $id,
|
||||
'update_time' => time(),
|
||||
];
|
||||
if (Db::name('Admin')->update($data) !== false) {
|
||||
add_log('reset', $id);
|
||||
return to_assign(0, '操作成功');
|
||||
} else {
|
||||
return to_assign(1, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
//删除员工
|
||||
public function del()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if($id == 1){
|
||||
return to_assign(1, '该账号是超级管理员,不允许删除');
|
||||
}
|
||||
$data = [
|
||||
'id' => $id,
|
||||
'delete_time' => time(),
|
||||
];
|
||||
if (Db::name('Admin')->update($data) !== false) {
|
||||
add_log('delete', $id);
|
||||
return to_assign(0, '操作成功');
|
||||
} else {
|
||||
return to_assign(1, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
//管理员操作日志
|
||||
public function log()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = array();
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['name|rule_menu|param_id', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
if (!empty($param['title_cate'])) {
|
||||
$where['title'] = $param['title_cate'];
|
||||
}
|
||||
if (!empty($param['rule_menu'])) {
|
||||
$where['rule_menu'] = $param['rule_menu'];
|
||||
}
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$content = DB::name('AdminLog')
|
||||
->field("id,uid,name,action,title,content,rule_menu,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time")
|
||||
->order('create_time desc')
|
||||
->where($where)
|
||||
->paginate(['list_rows'=> $rows]);
|
||||
$content->toArray();
|
||||
foreach ($content as $k => $v) {
|
||||
$data = $v;
|
||||
$param_array = json_decode($v['param'], true);
|
||||
$param_value = '';
|
||||
foreach ($param_array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = implode(',', $value);
|
||||
}
|
||||
$param_value .= $key . ':' . $value . ' | ';
|
||||
}
|
||||
$data['param'] = $param_value;
|
||||
$content->offsetSet($k, $data);
|
||||
}
|
||||
return table_assign(0, '', $content);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user