first commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\Model;
|
||||
class Admin extends Model
|
||||
{
|
||||
public function position()
|
||||
{
|
||||
return $this->hasOne(Position::class);
|
||||
}
|
||||
// 定义与部门的多对多关联关系
|
||||
public function departments()
|
||||
{
|
||||
return $this->belongsToMany(Department::class, 'department_admin');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class Blacklist extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($param=[],$where=[],$whereOr=[])
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item['admin_name'] = Db::name('Admin')->where('id',$item['admin_id'])->value('name');
|
||||
$item['create_time'] = to_date($item['create_time']);
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$param['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class Care extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($where, $param)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item->cate = Db::name('CareCate')->where('id',$item->care_cate)->value('title');
|
||||
$item->user_name = Db::name('Admin')->where('id',$item->uid)->value('name');
|
||||
$item->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
|
||||
$item->care_time = to_date($item->care_time,'Y-m-d');
|
||||
$item->create_time = to_date($item->create_time,'Y-m-d H:i:s');
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['aid'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
$info['care_time'] = to_date($info['care_time'],'Y-m-d');
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
class CareCate extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function getList($where, $param)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)->order($order)->paginate(['list_rows'=> $rows]);
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['aid'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = slef::where('id', $id)->find();
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\Model;
|
||||
use think\facade\Db;
|
||||
class Department extends Model
|
||||
{
|
||||
// 定义与员工的多对多关联关系
|
||||
public function admins()
|
||||
{
|
||||
return $this->belongsToMany(Admin::class, 'department_admin');
|
||||
}
|
||||
|
||||
public function update_auth_dids_son_dids(){
|
||||
$admin = Db::name('Admin')->field('id,did,auth_did')->select()->toArray();
|
||||
foreach ($admin as $key => $val) {
|
||||
$auth_dids = $this->get_auth_departments($val);
|
||||
$son_dids = $this->get_son_departments($val);
|
||||
Db::name('Admin')->where('id',$val['id'])->update(['auth_dids'=>$auth_dids,'son_dids'=>$son_dids]);
|
||||
}
|
||||
}
|
||||
|
||||
/*获取某员工所能看的部门数据(dids)
|
||||
*传入某员工uid,输出部门数组,如:'1,2,3'。
|
||||
*超级管理员默认返回全部部门数据
|
||||
*/
|
||||
public function get_auth_departments($admin)
|
||||
{
|
||||
$str='';
|
||||
$uid = $admin['id'];
|
||||
$did = $admin['did'];
|
||||
$auth_did = $admin['auth_did'];
|
||||
$dids = Db::name('Department')->where('status',1)->column('id');
|
||||
$departments = Db::name('Department')->where('status',1)->select()->toArray();
|
||||
//次要部门did
|
||||
$secondary_dids = Db::name('DepartmentAdmin')->where('admin_id',$uid)->column('department_id');
|
||||
//全部可见部门
|
||||
$all_dids = array_merge($secondary_dids,[$did]);
|
||||
|
||||
//超级管理员||所有部门数据权限
|
||||
if($uid==1 || $auth_did==10){
|
||||
$str = implode(',',$dids);
|
||||
}
|
||||
//仅自己关联的数据
|
||||
if($auth_did==0){
|
||||
$str='';
|
||||
}
|
||||
|
||||
//所属主部门的数据
|
||||
if($auth_did==1){
|
||||
$str=$did;
|
||||
}
|
||||
|
||||
//所属次部门的数据
|
||||
if($auth_did==2){
|
||||
$str = implode(',',$secondary_dids);
|
||||
}
|
||||
|
||||
//仅所属主次部门数据
|
||||
if($auth_did==3){
|
||||
$str = implode(',',$all_dids);
|
||||
}
|
||||
|
||||
//所属主部门及其子部门数据
|
||||
if($auth_did==4){
|
||||
//获取子部门
|
||||
$department_list = get_data_node($departments, $did);
|
||||
$department_array = array_column($department_list, 'id');
|
||||
//包括自己部门在内
|
||||
$department_array[] = $did;
|
||||
$str = implode(',',$department_array);
|
||||
}
|
||||
|
||||
//所属次部门及其子部门数据
|
||||
if($auth_did==5){
|
||||
//获取子部门
|
||||
$list_array = [];
|
||||
foreach ($secondary_dids as $key => $value) {
|
||||
$department_list = get_data_node($departments, $value);
|
||||
$department_array = array_column($department_list, 'id');
|
||||
//包括自己部门在内
|
||||
$department_array[] = $value;
|
||||
$list_array = array_merge($list_array,$department_array);
|
||||
}
|
||||
$new_array = array_unique($list_array);
|
||||
$str = implode(',',$new_array);
|
||||
}
|
||||
|
||||
//所属主次部门及其子部门数据
|
||||
if($auth_did==6){
|
||||
//获取子部门
|
||||
$list_array = [];
|
||||
foreach ($all_dids as $key => $value) {
|
||||
$department_list = get_data_node($departments, $value);
|
||||
$department_array = array_column($department_list, 'id');
|
||||
//包括自己部门在内
|
||||
$department_array[] = $value;
|
||||
$list_array = array_merge($list_array,$department_array);
|
||||
}
|
||||
$new_array = array_unique($list_array);
|
||||
$str = implode(',',$new_array);
|
||||
}
|
||||
|
||||
//所属主部门所在顶级部门及其子部门数据
|
||||
if($auth_did==7){
|
||||
//获取顶级部门
|
||||
$top_did = get_department_top($did);
|
||||
$new_array = get_department_son($top_did,1);
|
||||
$str = implode(',',$new_array);
|
||||
}
|
||||
|
||||
//所属次部门所在顶级部门及其子部门数据
|
||||
if($auth_did==8){
|
||||
//获取顶级部门
|
||||
$top_dids =[];
|
||||
foreach ($secondary_dids as $key => $value) {
|
||||
array_push($top_dids, get_department_top($value));
|
||||
}
|
||||
|
||||
$list_array = [];
|
||||
foreach ($top_dids as $key => $value) {
|
||||
$list_array = array_merge($list_array,get_department_son($value,1));
|
||||
}
|
||||
$new_array = array_unique($list_array);
|
||||
$str = implode(',',$new_array);
|
||||
}
|
||||
|
||||
//所属主次部门所在顶级部门及其子部门数据
|
||||
if($auth_did==9){
|
||||
//获取顶级部门
|
||||
$top_dids =[];
|
||||
foreach ($all_dids as $key => $value) {
|
||||
array_push($top_dids, get_department_top($value));
|
||||
}
|
||||
|
||||
$list_array = [];
|
||||
foreach ($top_dids as $key => $value) {
|
||||
$list_array = array_merge($list_array,get_department_son($value,1));
|
||||
}
|
||||
$new_array = array_unique($list_array);
|
||||
$str = implode(',',$new_array);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/*获取某负责人所负责的部门的数据集(ids),传入某员工uid,输出部门字符串,如:1,2,3,
|
||||
*逻辑:先判断传入的uid是否是负责人,如果是负责人再读取对应的部门数据。
|
||||
*超级管理员默认返回全部部门数据
|
||||
*/
|
||||
public function get_son_departments($admin)
|
||||
{
|
||||
$str='';
|
||||
$uid = $admin['id'];
|
||||
$dids = Db::name('Department')->where('status',1)->column('id');
|
||||
$departments = Db::name('Department')->where('status',1)->select()->toArray();
|
||||
if($uid==1){
|
||||
$str = implode(',',$dids);
|
||||
}
|
||||
else{
|
||||
$map = [];
|
||||
$map[] = ['status','=',1];
|
||||
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',leader_ids)")];
|
||||
$leader_dids = Db::name('Department')->where($map)->column('id');
|
||||
//判断是否是部门负责人
|
||||
if(!empty($leader_dids)){
|
||||
//获取子部门
|
||||
$list_array = [];
|
||||
foreach ($leader_dids as $key => $value) {
|
||||
$department_list = get_data_node($departments, $value);
|
||||
$department_array = array_column($department_list, 'id');
|
||||
//包括自己部门在内
|
||||
$department_array[] = $value;
|
||||
$list_array = array_merge($list_array,$department_array);
|
||||
}
|
||||
$str = implode(',',$list_array);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\Model;
|
||||
use think\facade\Db;
|
||||
class DepartmentChange extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($param,$where,$whereOr)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item['check_status_str'] = check_status_name($item['check_status']);
|
||||
$item['check_user'] = '-';
|
||||
if($item['check_status']==1 && !empty($item['check_uids'])){
|
||||
$check_user = Db::name('Admin')->where('id','in',$item['check_uids'])->column('name');
|
||||
$item['check_user'] = implode(',',$check_user);
|
||||
}
|
||||
|
||||
$item['name'] = Db::name('Admin')->where('id','=',$item['uid'])->value('name');
|
||||
$item['create_time'] = to_date($item['create_time']);
|
||||
$item['admin_name'] = Db::name('Admin')->where('id','=',$item['admin_id'])->value('name');
|
||||
$item['from_department'] = Db::name('Department')->where(['id' => $item['from_did']])->value('title');
|
||||
$item['to_department'] = Db::name('Department')->where(['id' => $item['to_did']])->value('title');
|
||||
$item['move_time'] = to_date($item['move_time'],'Y-m-d');
|
||||
$status_str = '未执行';
|
||||
$connect_time_str = '-';
|
||||
if($item['status'] == 2){
|
||||
$status_str = '已执行';
|
||||
$connect_time_str = to_date($item['connect_time'],'Y-m-d');
|
||||
}
|
||||
$item['status_str'] = $status_str;
|
||||
$item['connect_time_str'] = $connect_time_str;
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=> $param['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
$info['name'] = Db::name('Admin')->where('id','=',$info['uid'])->value('name');
|
||||
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
|
||||
$info['from_department'] = Db::name('Department')->where(['id' => $info['from_did']])->value('title');
|
||||
$info['to_department'] = Db::name('Department')->where(['id' => $info['to_did']])->value('title');
|
||||
$info['move_time'] = to_date($info['move_time'],'Y-m-d');
|
||||
|
||||
$status_str = '未执行';
|
||||
$connect_time_str = '-';
|
||||
if($info['status'] == 2){
|
||||
$status_str = '已执行';
|
||||
$connect_time_str = to_date($info['connect_time'],'Y-m-d');
|
||||
}
|
||||
$info['status_str'] = $status_str;
|
||||
$info['connect_time_str'] = $connect_time_str;
|
||||
if(!empty($info['file_ids'])){
|
||||
$file_array = Db::name('File')->where('id','in',$info['file_ids'])->select();
|
||||
$info['file_array'] = $file_array;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\Model;
|
||||
class IndustryCate extends Model
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class LaborContract extends Model
|
||||
{
|
||||
//合同类别
|
||||
public static $laborcontract_cate = array(
|
||||
array('id' => 1, 'title' => '劳动合同'),
|
||||
array('id' => 2, 'title' => '劳务合同'),
|
||||
array('id' => 3, 'title' => '实习协议'),
|
||||
array('id' => 4, 'title' => '保密协议')
|
||||
);
|
||||
|
||||
//合同类型
|
||||
public static $laborcontract_types = ['','新签合同','续签合同','变更合同'];
|
||||
|
||||
//合同属性
|
||||
public static $laborcontract_properties = ['','初级职称','中级职称','高级职称'];
|
||||
|
||||
//合同状态
|
||||
public static $laborcontract_status = ['','正常','已到期','已解除'];
|
||||
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($where, $param)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item->cate_str = self::$laborcontract_cate[$item->cate-1]['title'];
|
||||
$item->types_str = self::$laborcontract_types[$item->types];
|
||||
$item->properties_str = self::$laborcontract_properties[$item->properties];
|
||||
$item->status_str = self::$laborcontract_status[$item->status];
|
||||
$item->enterprise = Db::name('Enterprise')->where('id',$item->enterprise_id)->value('title');
|
||||
$item->user_name = Db::name('Admin')->where('id',$item->uid)->value('name');
|
||||
$item->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
|
||||
$item->sign_time = date('Y-m-d',$item->sign_time);
|
||||
$item->start_time = date('Y-m-d',$item->start_time);
|
||||
$item->end_time = date('Y-m-d',$item->end_time);
|
||||
$item->diff_time = $item->start_time.' 至 '.$item->end_time;
|
||||
$item->renewal = Db::name('LaborContract')->where(['renewal_pid'=>$item->id,'delete_time'=>0])->count();
|
||||
$item->change = Db::name('LaborContract')->where(['change_pid'=>$item->id,'delete_time'=>0])->count();
|
||||
$item->create_time = to_date($item->create_time,'Y-m-d H:i:s');
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['aid'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
$info['cate_str'] = self::$laborcontract_cate[$info['cate']-1]['title'];
|
||||
$info['types_str'] = self::$laborcontract_types[$info['types']];
|
||||
$info['properties_str'] = self::$laborcontract_properties[$info['properties']];
|
||||
$info['status_str'] = self::$laborcontract_status[$info['status']];
|
||||
$info['enterprise'] = Db::name('Enterprise')->where('id',$info['enterprise_id'])->value('title');
|
||||
$info['user_name'] = Db::name('Admin')->where('id',$info['uid'])->value('name');
|
||||
$info['sign_time'] = date('Y-m-d',$info['sign_time']);
|
||||
$info['start_time'] = date('Y-m-d',$info['start_time']);
|
||||
$info['end_time'] = date('Y-m-d',$info['end_time']);
|
||||
if($info['trial_end_time']>0){
|
||||
$info['trial_end_time'] = date('Y-m-d',$info['trial_end_time']);
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class PersonalQuit extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($param,$where,$whereOr)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item['check_status_str'] = check_status_name($item['check_status']);
|
||||
$item['check_user'] = '-';
|
||||
if($item['check_status']==1 && !empty($item['check_uids'])){
|
||||
$check_user = Db::name('Admin')->where('id','in',$item['check_uids'])->column('name');
|
||||
$item['check_user'] = implode(',',$check_user);
|
||||
}
|
||||
$userinfo = Db::name('Admin')->where('id','=',$item->uid)->find();
|
||||
$item->name = $userinfo['name'];
|
||||
$item->department = Db::name('Department')->where('id',$userinfo['did'])->value('title');
|
||||
$item->position = Db::name('Position')->where('id',$userinfo['position_id'])->value('title');
|
||||
|
||||
$item->admin_name = Db::name('Admin')->where('id','=',$item->admin_id)->value('name');
|
||||
$item->lead_admin_name = Db::name('Admin')->where('id','=',$item->lead_admin_id)->value('name');
|
||||
$item->connect_name = Db::name('admin')->where(['id' => $item->connect_id])->value('name');
|
||||
$item->quit_time = date('Y-m-d',$item->quit_time);
|
||||
$item->create_time = to_date($item->create_time);
|
||||
$connect_time_str = '-';
|
||||
if($item->status == 2){
|
||||
$connect_time_str = to_date($item->connect_time,'Y-m-d');
|
||||
}
|
||||
$item->connect_time_str = $connect_time_str;
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=> $param['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
$userinfo = Db::name('Admin')->where('id',$info['uid'])->find();
|
||||
$info['name'] = $userinfo['name'];
|
||||
$info['department'] = Db::name('Department')->where('id',$userinfo['did'])->value('title');
|
||||
$info['position'] = Db::name('Position')->where('id',$userinfo['position_id'])->value('title');
|
||||
|
||||
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
|
||||
$info['lead_admin_name'] = Db::name('Admin')->where('id','=',$info['lead_admin_id'])->value('name');
|
||||
$connect_uids_name = Db::name('Admin')->where([['id','in', $info['connect_uids']]])->column('name');
|
||||
$info['connect_names'] = implode(',', $connect_uids_name);
|
||||
$info['quit_time'] = date('Y-m-d', $info['quit_time']);
|
||||
$info['connect_name'] = Db::name('admin')->where(['id' => $info['connect_id']])->value('name');
|
||||
$status_str = '未交接';
|
||||
$connect_time_str = '-';
|
||||
if($info['status'] == 2){
|
||||
$status_str = '已交接离职';
|
||||
$connect_time_str = to_date($info['connect_time'],'Y-m-d');
|
||||
}
|
||||
$info['status_str'] = $status_str;
|
||||
$info['connect_time_str'] = $connect_time_str;
|
||||
if(!empty($info['file_ids'])){
|
||||
$file_array = Db::name('File')->where('id','in',$info['file_ids'])->select();
|
||||
$info['file_array'] = $file_array;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class Rewards extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($where, $param)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item->cate = Db::name('RewardsCate')->where('id',$item->rewards_cate)->value('title');
|
||||
$item->user_name = Db::name('Admin')->where('id',$item->uid)->value('name');
|
||||
$item->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
|
||||
$item->rewards_time = to_date($item->rewards_time,'Y-m-d');
|
||||
$item->create_time = to_date($item->create_time,'Y-m-d H:i:s');
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['aid'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
class RewardsCate extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function getList($where, $param)
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = $this->where($where)->order($order)->paginate(['list_rows'=> $rows]);
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = $this->strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['aid'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
$this->where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = $this->where('id', $id)->find();
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/**
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
* @Author 勾股工作室 <hdm58@qq.com>
|
||||
+-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\user\model;
|
||||
use think\model;
|
||||
use think\facade\Db;
|
||||
class Talent extends Model
|
||||
{
|
||||
/**
|
||||
* 获取分页列表
|
||||
* @param $where
|
||||
* @param $param
|
||||
*/
|
||||
public function datalist($param=[],$where=[],$whereOr=[])
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'id desc' : $param['order'];
|
||||
try {
|
||||
$list = self::where($where)
|
||||
->where(function ($query) use($whereOr) {
|
||||
if (!empty($whereOr)){
|
||||
$query->whereOr($whereOr);
|
||||
}
|
||||
})
|
||||
->order($order)
|
||||
->paginate(['list_rows'=> $rows])
|
||||
->each(function ($item, $key){
|
||||
$item['admin_name'] = Db::name('Admin')->where('id',$item['admin_id'])->value('name');
|
||||
$item['check_status_str'] = check_status_name($item['check_status']);
|
||||
if($item['check_status']==1 && !empty($item['check_uids'])){
|
||||
$check_users = Db::name('Admin')->where('id','in',$item['check_uids'])->column('name');
|
||||
$item['check_users'] = implode(',',$check_users);
|
||||
}
|
||||
else{
|
||||
$item['check_users']='-';
|
||||
}
|
||||
if(!empty($item['check_copy_uids'])){
|
||||
$check_copy_users = Db::name('Admin')->where('id','in',$item['check_copy_uids'])->column('name');
|
||||
$item['check_copy_users'] = implode(',',$check_copy_users);
|
||||
}
|
||||
else{
|
||||
$item['check_copy_users']='-';
|
||||
}
|
||||
if($item['entry_time']>0){
|
||||
$item['entry_time'] = date('Y-m-d',$item['entry_time']);
|
||||
}
|
||||
else{
|
||||
$item['entry_time'] = '-';
|
||||
}
|
||||
if($item['position_id']>0){
|
||||
$item['position']= Db::name('Position')->where('id',$item['position_id'])->value('title');
|
||||
}
|
||||
if($item['to_did']>0){
|
||||
$item['department']= Db::name('Department')->where('id',$item['to_did'])->value('title');
|
||||
}
|
||||
if($item['political']==1){
|
||||
$item['political'] = '中共党员';
|
||||
}
|
||||
else if($item['political']==2){
|
||||
$item['political'] = '团员';
|
||||
}
|
||||
else{
|
||||
$item['political'] = '其他';
|
||||
}
|
||||
$item['create_time'] = to_date($item['create_time']);
|
||||
$item['thumb'] = get_file($item['thumb']);
|
||||
});
|
||||
return $list;
|
||||
} catch(\Exception $e) {
|
||||
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据
|
||||
* @param $param
|
||||
*/
|
||||
public function add($param)
|
||||
{
|
||||
$insertId = 0;
|
||||
try {
|
||||
$param['create_time'] = time();
|
||||
$insertId = self::strict(false)->field(true)->insertGetId($param);
|
||||
add_log('add', $insertId, $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$insertId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑信息
|
||||
* @param $param
|
||||
*/
|
||||
public function edit($param)
|
||||
{
|
||||
try {
|
||||
$param['update_time'] = time();
|
||||
self::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
return to_assign(0,'操作成功',['return_id'=>$param['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取信息
|
||||
* @param $id
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
$info = self::find($id);
|
||||
if($info['entry_time']>0){
|
||||
$info['entry_time'] = date('Y-m-d',$info['entry_time']);
|
||||
}
|
||||
else{
|
||||
$info['entry_time'] = '';
|
||||
}
|
||||
if($info['position_id']>0){
|
||||
$info['position']= Db::name('Position')->where('id',$info['position_id'])->value('title');
|
||||
}
|
||||
else{
|
||||
$info['position'] = '';
|
||||
}
|
||||
if($info['pid']>0){
|
||||
$info['pname']= Db::name('Admin')->where('id',$info['pid'])->value('name');
|
||||
}
|
||||
else{
|
||||
$info['pname'] = '';
|
||||
}
|
||||
if($info['position_name']>0){
|
||||
$info['position_name_str']= Db::name('BasicUser')->where('id',$info['position_name'])->value('title');
|
||||
}
|
||||
else{
|
||||
$info['position_name_str']='';
|
||||
}
|
||||
if($info['position_rank']>0){
|
||||
$info['position_rank_str']= Db::name('BasicUser')->where('id',$info['position_rank'])->value('title');
|
||||
}
|
||||
else{
|
||||
$info['position_rank_str']='';
|
||||
}
|
||||
if($info['to_did']>0){
|
||||
$info['department']= Db::name('Department')->where('id',$info['to_did'])->value('title');
|
||||
}
|
||||
else{
|
||||
$info['department']='';
|
||||
}
|
||||
if(!empty($info['to_dids'])){
|
||||
$departments= Db::name('Department')->where('id','in',$info['to_dids'])->column('title');
|
||||
$info['departments']= implode(',' ,$departments);
|
||||
}
|
||||
if(!empty($info['admin_id'])){
|
||||
$info['admin_name'] = Db::name('Admin')->where([['id','=',$info['admin_id']]])->value('name');
|
||||
}
|
||||
if($info['thumb'] !=''){
|
||||
$thumb_array = Db::name('File')->where('id','in',$info['thumb'])->select();
|
||||
$info['thumb_array'] = $thumb_array;
|
||||
}
|
||||
$info['create_time'] = to_date($info['create_time']);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除信息
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return array
|
||||
*/
|
||||
public function delById($id,$type=0)
|
||||
{
|
||||
if($type==0){
|
||||
//逻辑删除
|
||||
try {
|
||||
$param['delete_time'] = time();
|
||||
self::where('id', $id)->update(['delete_time'=>time()]);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
//物理删除
|
||||
try {
|
||||
self::destroy($id);
|
||||
add_log('delete', $id);
|
||||
} catch(\Exception $e) {
|
||||
return to_assign(1, '操作失败,原因:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user