first commit

This commit is contained in:
2026-07-23 09:40:36 +08:00
commit 090abf48fa
989 changed files with 145728 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\Model;
class AdminGroup extends Model
{
}
+39
View File
@@ -0,0 +1,39 @@
<?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\home\model;
use think\Model;
use think\facade\Db;
use dateset\Dateset;
class AdminLog extends Model
{
public function get_log_list($param = [])
{
$rows = empty($param['limit']) ? get_config('app.pages') : $param['limit'];
$list = Db::name('AdminLog')
->field("a.id,a.uid,a.type,a.subject,a.action,a.create_time,u.name")
->alias('a')
->join('Admin u', 'a.uid = u.id')
->order('a.create_time desc')
->paginate(['list_rows'=> $rows])
->each(function($item, $key){
$item['content'] = $item['name']. $item['action'] . '了' . $item['subject'];
$item['times'] = (new Dateset())->time_trans($item['create_time']);
return $item;
});
return $list;
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\Model;
// 关键字模型
class File extends Model
{
protected $autoWriteTimestamp=false;
}
+121
View File
@@ -0,0 +1,121 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\model;
use think\facade\Db;
class Leaves 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->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
});
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['start_date'] = date('Y-m-d H:i',$info['start_date']);
$info['end_date'] = date('Y-m-d H:i',$info['end_date']);
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
$info['department'] = Db::name('Department')->where('id','=',$info['did'])->value('title');
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();
}
}
+153
View File
@@ -0,0 +1,153 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\Model;
use think\facade\Db;
class Message 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->send_time_str = empty($item->send_time) ? '草稿' : date('Y-m-d H:i:s', $item->send_time);
if(empty($item->uids)){
$item->to_name = '-';
}
else{
$to_name = Db::name('Admin')->where([['id','in',$item->uids]])->column('name');
$item->to_name = implode(',',$to_name);
}
if(empty($item->dids)){
$item->to_department = '-';
}
else{
$to_department = Db::name('Department')->where([['id','in',$item->dids]])->column('title');
$item->to_department = implode(',',$to_department);
}
if(empty($item->pids)){
$item->to_position = '-';
}
else{
$to_position = Db::name('Position')->where([['id','in',$item->pids]])->column('title');
$item->to_position = implode(',',$to_position);
}
if(empty($item->copy_uids)){
$item->copy_names = '-';
}
else{
$copy_name = Db::name('Admin')->where([['id','in',$item->copy_uids]])->column('name');
$item->copy_names = implode(',',$copy_name);
}
$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()];
}
}
//发件箱消息详情
public function detail($id)
{
$detail = self::find($id);
if(!empty($detail)){
if ($detail['types'] == 1) { //人员
$users = Db::name('Admin')->where('status', 1)->where('id', 'in', $detail['uids'])->column('name');
$detail['unames'] = implode(',',$users);
} elseif ($detail['types'] == 2) { //部门
$departments = Db::name('Department')->where('id', 'in', $detail['dids'])->column('title');
$detail['dnames'] = implode(',',$departments);
} elseif ($detail['types'] == 3) { //角色
$positions = Db::name('Position')->where('id', 'in', $detail['pids'])->column('title');
$detail['pnames'] = implode(',',$positions);
}
$copy_users = Db::name('Admin')->where('status', 1)->where('id', 'in', $detail['copy_uids'])->column('name');
$detail['copy_names'] = implode(',',$copy_users);
//消息附件
$file_array = Db::name('File')->order('create_time desc')->where([['id','in',$detail['file_ids']]])->select()->toArray();
$detail['file_array'] = $file_array;
//引用消息附件
if($detail['msg_id']>0){
$from_msg = Db::name('Msg')->field('content,file_ids,template,action_id')->where(['id' => $detail['msg_id']])->find();
$detail['from_template'] = $from_msg['template'];
$detail['from_action_id'] = $from_msg['action_id'];
$detail['from_content'] = $from_msg['content'];
$detail['from_file_ids'] = $from_msg['file_ids'];
$detail['from_file_array'] = Db::name('File')->order('create_time desc')->where([['id','in',$detail['from_file_ids']]])->select()->toArray();
}
}
return $detail;
}
//发送消息
public function send($id)
{
//查询要发的消息
$msg = self::find($id);
$users = [];
//查询全部收件人
if ($msg['types'] == 1) { //人员
$users = Db::name('Admin')->where('status', 1)->where('id', 'in', $msg['uids'])->column('id');
} elseif ($msg['types'] == 2) { //部门
$users = Db::name('Admin')->where('status', 1)->where('did', 'in', $msg['dids'])->column('id');
} elseif ($msg['types'] == 3) { //角色
$users = Db::name('Admin')->where('status', 1)->where('position_id', 'in', $msg['pids'])->column('id');
} elseif ($msg['types'] == 4) { //全部
$users = Db::name('Admin')->where('status', 1)->column('id');
}
if(!empty($msg['copy_uids'])){
$copy_uids = explode(',',$msg['copy_uids']);
$users_tem = array_merge($users,$copy_uids);
$users = array_unique($users_tem);
}
//组合要发的消息
$send_data = [];
foreach ($users as $key => $value) {
if ($value == $msg['from_uid']) {
continue;
}
$send_data[] = array(
'message_id' => $msg['id'],//来源发件箱关联id
'to_uid' => $value,//接收人
'msg_id' => $msg['msg_id'],//转发或回复消息关联id
'title' => $msg['title'],
'content' => $msg['content'],
'file_ids' => $msg['file_ids'],
'from_uid' => $msg['from_uid'],//发送人
'create_time' => time()
);
}
$res = Db::name('Msg')->strict(false)->field(true)->insertAll($send_data);
if ($res!==false) {
//草稿消息变成已发消息
self::where(['id' => $msg['id']])->update(['is_draft' => '1', 'send_time' => time(), 'update_time' => time()]);
add_log('send',$msg['id'],[],'消息');
return true;
} else {
return false;
}
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\Model;
use think\facade\Db;
class Msg 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->from_name = '系统';
$item->thumb = '/static/home/images/icon.png';
$item['create_time'] = to_date($item['create_time'],'Y-m-d H:i:s');
if($item->from_uid>0){
$from_name = Db::name('Admin')->where('id',$item->from_uid)->find();
$item->from_name = $from_name['name'];
$item->thumb = $from_name['thumb'];
}
if(!empty($item->uids)){
$to_name = Db::name('Admin')->where(['id','in',$item->uids])->column('name');
$item->to_name = implode(',',$to_name);
}
else{
$item->to_name = '-';
}
});
return $list;
} catch(\Exception $e) {
return ['code' => 1, 'data' => [], 'msg' => $e->getMessage()];
}
}
//消息详情
public function detail($id)
{
$detail = self::find($id);
if(!empty($detail)){
//消息附件
$file_array = Db::name('File')->order('create_time desc')->where([['id','in',$detail['file_ids']]])->select()->toArray();
$detail['file_array'] = $file_array;
//引用消息附件
if($detail['msg_id']>0){
$from_msg = Db::name('Msg')->find($detail['msg_id']);
if(!empty($from_msg)){
$detail['from_template'] = $from_msg['template'];
$detail['from_action_id'] = $from_msg['action_id'];
$detail['from_content'] = $from_msg['content'];
$detail['from_file_ids'] = $from_msg['file_ids'];
$from_file_array = Db::name('File')->order('create_time desc')->where([['id','in',$detail['from_file_ids']]])->select()->toArray();
$detail['from_file_array'] = $from_file_array;
}
}
$detail['create_time'] = to_date($detail['create_time'],'Y-m-d H:i:s');
}
return $detail;
}
}
+121
View File
@@ -0,0 +1,121 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\model;
use think\facade\Db;
class Outs 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->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
});
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['start_date'] = date('Y-m-d H:i',$info['start_date']);
$info['end_date'] = date('Y-m-d H:i',$info['end_date']);
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
$info['department'] = Db::name('Department')->where('id','=',$info['did'])->value('title');
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();
}
}
+121
View File
@@ -0,0 +1,121 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\model;
use think\facade\Db;
class Overtimes 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->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
});
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['start_date'] = date('Y-m-d H:i',$info['start_date']);
$info['end_date'] = date('Y-m-d H:i',$info['end_date']);
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
$info['department'] = Db::name('Department')->where('id','=',$info['did'])->value('title');
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();
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\model;
use think\facade\Db;
class Template 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->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
$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,'操作成功',['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();
}
}
+122
View File
@@ -0,0 +1,122 @@
<?php
/**
+-----------------------------------------------------------------------------------------------
* GouGuOPEN [ 左手研发,右手开源,未来可期!]
+-----------------------------------------------------------------------------------------------
* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
+-----------------------------------------------------------------------------------------------
* @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
+-----------------------------------------------------------------------------------------------
* @Author 勾股工作室 <hdm58@qq.com>
+-----------------------------------------------------------------------------------------------
*/
namespace app\home\model;
use think\model;
use think\facade\Db;
class Trips 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->admin_name = Db::name('Admin')->where('id',$item->admin_id)->value('name');
});
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['start_date'] = date('Y-m-d H:i',$info['start_date']);
$info['end_date'] = date('Y-m-d H:i',$info['end_date']);
$info['admin_name'] = Db::name('Admin')->where('id','=',$info['admin_id'])->value('name');
$info['department'] = Db::name('Department')->where('id','=',$info['did'])->value('title');
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();
}
}