Merge remote-tracking branch 'origin/master'

This commit is contained in:
liu 2024-04-10 10:27:05 +08:00
commit fbe424e913
7 changed files with 553 additions and 555 deletions

View File

@ -0,0 +1,44 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\api\controller;
use think\facade\Db;
use app\project\model\ProjectTask as TaskList;
use app\project\validate\TaskCheck;
use think\exception\ValidateException;
class Api
{
//添加
public function task_add()
{
$param = get_params();
if (request()->isPost()) {
if (isset($param['end_time'])) {
$param['end_time'] = strtotime(urldecode($param['end_time']));
}
try {
validate(TaskCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['create_time'] = time();
$param['admin_id'] = 1;
if (!empty($param['md5']) && strlen($param['md5']) > 2) {
$id = TaskList::where('md5', $param['md5'])->where('flow_status',1)->value('id');
if ($id) {
return to_assign(1, '已存在');
}
}
TaskList::strict(false)->field(true)->insertGetId($param);
return json(['code'=>200,'msg'=>'ok']);
}
}
}

View File

@ -13,7 +13,6 @@ use Firebase\JWT\JWT;
use Firebase\JWT\Key; use Firebase\JWT\Key;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
class Demo extends BaseController class Demo extends BaseController
{ {
/** /**

View File

@ -1,10 +1,13 @@
<?php <?php
/** /**
* @copyright Copyright (c) 2021 勾股工作室 * @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0 * @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com * @link https://www.gougucms.com
*/ */
declare (strict_types = 1);
declare(strict_types=1);
namespace app\api\controller; namespace app\api\controller;
use app\api\BaseController; use app\api\BaseController;
@ -12,280 +15,276 @@ use think\facade\Db;
class Index extends BaseController class Index extends BaseController
{ {
//上传文件
public function upload()
{
$param = get_params();
//var_dump($param);exit;
$sourse = 'file';
if(isset($param['sourse'])){
$sourse = $param['sourse'];
}
if($sourse == 'file' || $sourse == 'tinymce'){
if(request()->file('file')){
$file = request()->file('file');
}
else{
return to_assign(1, '没有选择上传文件');
}
}
else{
if (request()->file('editormd-image-file')) {
$file = request()->file('editormd-image-file');
} else {
return to_assign(1, '没有选择上传文件');
}
}
// 获取上传文件的hash散列值
$sha1 = $file->hash('sha1');
$md5 = $file->hash('md5');
$rule = [
'image' => 'jpg,png,jpeg,gif',
'doc' => 'txt,doc,docx,ppt,pptx,xls,xlsx,pdf',
'file' => 'zip,gz,7z,rar,tar',
'video' => 'mpg,mp4,mpeg,avi,wmv,mov,flv,m4v',
];
$fileExt = $rule['image'] . ',' . $rule['doc'] . ',' . $rule['file'] . ',' . $rule['video'];
//1M=1024*1024=1048576字节
$fileSize = 100 * 1024 * 1024;
if (isset($param['type']) && $param['type']) {
$fileExt = $rule[$param['type']];
}
if (isset($param['size']) && $param['size']) {
$fileSize = $param['size'];
}
$validate = \think\facade\Validate::rule([
'image' => 'require|fileSize:' . $fileSize . '|fileExt:' . $fileExt,
]);
$file_check['image'] = $file;
if (!$validate->check($file_check)) {
return to_assign(1, $validate->getError());
}
// 日期前綴
$dataPath = date('Ym');
$use = 'thumb';
$filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) {
return $md5;
});
if ($filename) {
//写入到附件表
$data = [];
$path = get_config('filesystem.disks.public.url');
$data['filepath'] = $path . '/' . $filename;
$data['name'] = $file->getOriginalName();
$data['mimetype'] = $file->getOriginalMime();
$data['fileext'] = $file->extension();
$data['filesize'] = $file->getSize();
$data['filename'] = $filename;
$data['sha1'] = $sha1;
$data['md5'] = $md5;
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['action'] = app('request')->action();
$data['uploadip'] = app('request')->ip();
$data['create_time'] = time();
$data['user_id'] = $this->uid;
if ($data['module'] = 'admin') {
//通过后台上传的文件直接审核通过
$data['status'] = 1;
$data['admin_id'] = $data['user_id'];
$data['audit_time'] = time();
}
$data['use'] = request()->has('use') ? request()->param('use') : $use; //附件用处
$res['id'] = Db::name('file')->insertGetId($data);
$res['filepath'] = $data['filepath'];
$res['name'] = $data['name'];
$res['filename'] = $data['filename'];
$res['filesize'] = $data['filesize'];
$res['fileext'] = $data['fileext'];
add_log('upload', $data['user_id'], $data,'文件');
if($sourse == 'editormd'){
//editormd编辑器上传返回
return json(['success'=>1,'message'=>'上传成功','url'=>$data['filepath']]);
}
else if($sourse == 'tinymce'){
//tinymce编辑器上传返回
return json(['success'=>1,'message'=>'上传成功','location'=>$data['filepath']]);
}
else{
//普通上传返回
return to_assign(0, '上传成功', $res);
}
} else {
return to_assign(1, '上传失败,请重试');
}
}
//清空缓存 //上传文件
public function cache_clear() public function upload()
{ {
\think\facade\Cache::clear(); $param = get_params();
return to_assign(0, '系统缓存已清空'); //var_dump($param);exit;
} $sourse = 'file';
if (isset($param['sourse'])) {
$sourse = $param['sourse'];
}
if ($sourse == 'file' || $sourse == 'tinymce') {
if (request()->file('file')) {
$file = request()->file('file');
} else {
return to_assign(1, '没有选择上传文件');
}
} else {
if (request()->file('editormd-image-file')) {
$file = request()->file('editormd-image-file');
} else {
return to_assign(1, '没有选择上传文件');
}
}
// 获取上传文件的hash散列值
$sha1 = $file->hash('sha1');
$md5 = $file->hash('md5');
$rule = [
'image' => 'jpg,png,jpeg,gif',
'doc' => 'txt,doc,docx,ppt,pptx,xls,xlsx,pdf',
'file' => 'zip,gz,7z,rar,tar',
'video' => 'mpg,mp4,mpeg,avi,wmv,mov,flv,m4v',
];
$fileExt = $rule['image'] . ',' . $rule['doc'] . ',' . $rule['file'] . ',' . $rule['video'];
//1M=1024*1024=1048576字节
$fileSize = 100 * 1024 * 1024;
if (isset($param['type']) && $param['type']) {
$fileExt = $rule[$param['type']];
}
if (isset($param['size']) && $param['size']) {
$fileSize = $param['size'];
}
$validate = \think\facade\Validate::rule([
'image' => 'require|fileSize:' . $fileSize . '|fileExt:' . $fileExt,
]);
$file_check['image'] = $file;
if (!$validate->check($file_check)) {
return to_assign(1, $validate->getError());
}
// 日期前綴
$dataPath = date('Ym');
$use = 'thumb';
$filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) {
return $md5;
});
if ($filename) {
//写入到附件表
$data = [];
$path = get_config('filesystem.disks.public.url');
$data['filepath'] = $path . '/' . $filename;
$data['name'] = $file->getOriginalName();
$data['mimetype'] = $file->getOriginalMime();
$data['fileext'] = $file->extension();
$data['filesize'] = $file->getSize();
$data['filename'] = $filename;
$data['sha1'] = $sha1;
$data['md5'] = $md5;
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['action'] = app('request')->action();
$data['uploadip'] = app('request')->ip();
$data['create_time'] = time();
$data['user_id'] = $this->uid;
if ($data['module'] = 'admin') {
//通过后台上传的文件直接审核通过
$data['status'] = 1;
$data['admin_id'] = $data['user_id'];
$data['audit_time'] = time();
}
$data['use'] = request()->has('use') ? request()->param('use') : $use; //附件用处
$res['id'] = Db::name('file')->insertGetId($data);
$res['filepath'] = $data['filepath'];
$res['name'] = $data['name'];
$res['filename'] = $data['filename'];
$res['filesize'] = $data['filesize'];
$res['fileext'] = $data['fileext'];
add_log('upload', $data['user_id'], $data, '文件');
if ($sourse == 'editormd') {
//editormd编辑器上传返回
return json(['success' => 1, 'message' => '上传成功', 'url' => $data['filepath']]);
} else if ($sourse == 'tinymce') {
//tinymce编辑器上传返回
return json(['success' => 1, 'message' => '上传成功', 'location' => $data['filepath']]);
} else {
//普通上传返回
return to_assign(0, '上传成功', $res);
}
} else {
return to_assign(1, '上传失败,请重试');
}
}
// 测试邮件发送 //清空缓存
public function email_test() public function cache_clear()
{ {
$sender = get_params('email'); \think\facade\Cache::clear();
//检查是否邮箱格式 return to_assign(0, '系统缓存已清空');
if (!is_email($sender)) { }
return to_assign(1, '测试邮箱码格式有误');
}
$email_config = \think\facade\Db::name('config')->where('name', 'email')->find();
$config = unserialize($email_config['content']);
$content = $config['template'];
//所有项目必须填写
if (empty($config['smtp']) || empty($config['smtp_port']) || empty($config['smtp_user']) || empty($config['smtp_pwd'])) {
return to_assign(1, '请完善邮件配置信息');
}
$send = send_email($sender, '测试邮件', $content); // 测试邮件发送
if ($send) { public function email_test()
return to_assign(0, '邮件发送成功'); {
} else { $sender = get_params('email');
return to_assign(1, '邮件发送失败'); //检查是否邮箱格式
} if (!is_email($sender)) {
} return to_assign(1, '测试邮箱码格式有误');
}
$email_config = \think\facade\Db::name('config')->where('name', 'email')->find();
$config = unserialize($email_config['content']);
$content = $config['template'];
//所有项目必须填写
if (empty($config['smtp']) || empty($config['smtp_port']) || empty($config['smtp_user']) || empty($config['smtp_pwd'])) {
return to_assign(1, '请完善邮件配置信息');
}
//获取部门 $send = send_email($sender, '测试邮件', $content);
public function get_department() if ($send) {
{ return to_assign(0, '邮件发送成功');
$department = get_department(); } else {
return to_assign(0, '', $department); return to_assign(1, '邮件发送失败');
} }
}
//获取部门树形节点列表 //获取部门
public function get_department_tree() public function get_department()
{ {
$department = get_department(); $department = get_department();
$list = get_tree($department, 0, 2); return to_assign(0, '', $department);
$data['trees'] = $list; }
return json($data);
}
//获取部门树形节点列表2 //获取部门树形节点列表
public function get_department_select() public function get_department_tree()
{ {
$department = get_department();
$list = get_tree($department, 0, 2);
$data['trees'] = $list;
return json($data);
}
//获取部门树形节点列表2
public function get_department_select()
{
$keyword = get_params('keyword'); $keyword = get_params('keyword');
$selected = []; $selected = [];
if(!empty($keyword)){ if (!empty($keyword)) {
$selected = explode(",",$keyword); $selected = explode(",", $keyword);
} }
$department = get_department(); $department = get_department();
$list = get_select_tree($department, 0,0,$selected); $list = get_select_tree($department, 0, 0, $selected);
return to_assign(0, '',$list); return to_assign(0, '', $list);
} }
//获取子部门所有员工 //获取子部门所有员工
public function get_employee($did = 0) public function get_employee($did = 0)
{ {
$did = get_params('did'); $did = get_params('did');
if($did == 1){ if ($did == 1) {
$department = $did; $department = $did;
} } else {
else{
$department = get_department_son($did); $department = get_department_son($did);
} }
$employee = Db::name('admin') $employee = Db::name('admin')
->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department') ->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department')
->alias('a') ->alias('a')
->join('Department d', 'a.did = d.id') ->join('Department d', 'a.did = d.id')
->where(['a.status' => 1]) ->where(['a.status' => 1])
->where('a.id', ">", 1) ->where('a.id', ">", 1)
->where('a.did', "in", $department) ->where('a.did', "in", $department)
->select(); ->select();
return to_assign(0, '', $employee); return to_assign(0, '', $employee);
} }
//获取所有员工 //获取所有员工
public function get_personnel() public function get_personnel()
{ {
$param = get_params(); $param = get_params();
$where[] = ['a.status', '=', 1]; $where[] = ['a.status', '=', 1];
$where[] = ['a.id', '>', 1]; $where[] = ['a.id', '>', 1];
if (!empty($param['keywords'])) { if (!empty($param['keywords'])) {
$where[] = ['a.name', 'like', '%' . $param['keywords'] . '%']; $where[] = ['a.name', 'like', '%' . $param['keywords'] . '%'];
} }
if(!empty($param['ids'])){ if (!empty($param['ids'])) {
$where[] = ['a.id', 'notin', $param['ids']]; $where[] = ['a.id', 'notin', $param['ids']];
} }
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$list = Db::name('admin') $list = Db::name('admin')
->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department') ->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department')
->alias('a') ->alias('a')
->join('Department d', 'a.did = d.id') ->join('Department d', 'a.did = d.id')
->where($where) ->where($where)
->order('a.id desc') ->order('a.id desc')
->paginate($rows, false, ['query' => $param]); ->paginate($rows, false, ['query' => $param]);
return table_assign(0, '', $list); return table_assign(0, '', $list);
} }
//获取部门所有员工 //获取部门所有员工
public function get_employee_select() public function get_employee_select()
{ {
$keyword = get_params('keyword'); $keyword = get_params('keyword');
$selected = []; $selected = [];
if(!empty($keyword)){ if (!empty($keyword)) {
$selected = explode(",",$keyword); $selected = explode(",", $keyword);
} }
$employee = Db::name('admin') $employee = Db::name('admin')
->field('id as value,name') ->field('id as value,name')
->where(['status' => 1]) ->where(['status' => 1])
->select()->toArray(); ->select()->toArray();
foreach($employee as $k => &$v){ foreach ($employee as $k => &$v) {
$v['selected'] = ''; $v['selected'] = '';
if(in_array($v['value'],$selected)){ if (in_array($v['value'], $selected)) {
$v['selected'] = 'selected'; $v['selected'] = 'selected';
} }
} }
return to_assign(0, '', $employee); return to_assign(0, '', $employee);
} }
//获取角色列表 //获取角色列表
public function get_position() public function get_position()
{ {
$position = Db::name('Position')->field('id,title as name')->where([['status', '=', 1], ['id', '>', 1]])->select(); $position = Db::name('Position')->field('id,title as name')->where([['status', '=', 1], ['id', '>', 1]])->select();
return to_assign(0, '', $position); return to_assign(0, '', $position);
} }
//获取审核类型 //获取审核类型
public function get_flow_cate($type=0) public function get_flow_cate($type = 0)
{ {
$flows = Db::name('FlowType')->where(['type'=>$type,'status'=>1])->select()->toArray(); $flows = Db::name('FlowType')->where(['type' => $type, 'status' => 1])->select()->toArray();
return to_assign(0, '', $flows); return to_assign(0, '', $flows);
} }
//获取审核步骤人员 //获取审核步骤人员
public function get_flow_users($id=0) public function get_flow_users($id = 0)
{ {
$flow = Db::name('Flow')->where(['id' => $id])->find(); $flow = Db::name('Flow')->where(['id' => $id])->find();
$flowData = unserialize($flow['flow_list']); $flowData = unserialize($flow['flow_list']);
if(!empty($flowData)){ if (!empty($flowData)) {
foreach ($flowData as $key => &$val) { foreach ($flowData as $key => &$val) {
$val['user_id_info'] = Db::name('Admin')->field('id,name,thumb')->where('id','in',$val['flow_uids'])->select()->toArray(); $val['user_id_info'] = Db::name('Admin')->field('id,name,thumb')->where('id', 'in', $val['flow_uids'])->select()->toArray();
} }
} }
$data['copy_uids'] = $flow['copy_uids']; $data['copy_uids'] = $flow['copy_uids'];
$data['copy_unames'] =''; $data['copy_unames'] = '';
if($flow['copy_uids']!=''){ if ($flow['copy_uids'] != '') {
$copy_unames = Db::name('Admin')->where('id', 'in', $flow['copy_uids'])->column('name'); $copy_unames = Db::name('Admin')->where('id', 'in', $flow['copy_uids'])->column('name');
$data['copy_unames'] = implode(',', $copy_unames); $data['copy_unames'] = implode(',', $copy_unames);
} }
$data['flow_data'] = $flowData; $data['flow_data'] = $flowData;
return to_assign(0, '', $data); return to_assign(0, '', $data);
} }
//获取审核流程节点 //获取审核流程节点
public function get_flow_nodes($id=0,$type=1) public function get_flow_nodes($id = 0, $type = 1)
{ {
$flows = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'delete_time'=>0])->order('sort asc')->select()->toArray(); $flows = Db::name('FlowStep')->where(['action_id' => $id, 'type' => $type, 'delete_time' => 0])->order('sort asc')->select()->toArray();
foreach ($flows as $key => &$val) { foreach ($flows as $key => &$val) {
$user_id_info = Db::name('Admin')->field('id,name,thumb')->where('id','in',$val['flow_uids'])->select()->toArray(); $user_id_info = Db::name('Admin')->field('id,name,thumb')->where('id', 'in', $val['flow_uids'])->select()->toArray();
foreach ($user_id_info as $k => &$v) { foreach ($user_id_info as $k => &$v) {
$v['check_time'] = 0; $v['check_time'] = 0;
$v['content'] = ''; $v['content'] = '';
$v['status'] = 0; $v['status'] = 0;
$check_array = Db::name('FlowRecord')->where(['check_user_id' => $v['id'],'step_id' => $val['id']])->order('check_time desc')->select()->toArray(); $check_array = Db::name('FlowRecord')->where(['check_user_id' => $v['id'], 'step_id' => $val['id']])->order('check_time desc')->select()->toArray();
if(!empty($check_array)){ if (!empty($check_array)) {
$checked = $check_array[0]; $checked = $check_array[0];
$v['check_time'] = date('Y-m-d H:i', $checked['check_time']); $v['check_time'] = date('Y-m-d H:i', $checked['check_time']);
$v['content'] = $checked['content']; $v['content'] = $checked['content'];
@ -294,118 +293,110 @@ class Index extends BaseController
} }
$check_list = Db::name('FlowRecord') $check_list = Db::name('FlowRecord')
->field('f.*,a.name,a.thumb') ->field('f.*,a.name,a.thumb')
->alias('f') ->alias('f')
->join('Admin a', 'a.id = f.check_user_id', 'left') ->join('Admin a', 'a.id = f.check_user_id', 'left')
->where(['f.step_id' => $val['id']])->select()->toArray(); ->where(['f.step_id' => $val['id']])->select()->toArray();
foreach ($check_list as $kk => &$vv) { foreach ($check_list as $kk => &$vv) {
$vv['check_time_str'] = date('Y-m-d H:i', $vv['check_time']); $vv['check_time_str'] = date('Y-m-d H:i', $vv['check_time']);
} }
$val['user_id_info'] = $user_id_info; $val['user_id_info'] = $user_id_info;
$val['check_list'] = $check_list; $val['check_list'] = $check_list;
} }
return to_assign(0, '', $flows); return to_assign(0, '', $flows);
} }
//获取审核流程节点 //获取审核流程节点
public function get_flow_record($id=0,$type=1) public function get_flow_record($id = 0, $type = 1)
{ {
$check_list = Db::name('FlowRecord') $check_list = Db::name('FlowRecord')
->field('f.*,a.name,a.thumb') ->field('f.*,a.name,a.thumb')
->alias('f') ->alias('f')
->join('Admin a', 'a.id = f.check_user_id', 'left') ->join('Admin a', 'a.id = f.check_user_id', 'left')
->where(['f.action_id'=>$id,'f.type'=>$type]) ->where(['f.action_id' => $id, 'f.type' => $type])
->order('check_time asc') ->order('check_time asc')
->select()->toArray(); ->select()->toArray();
foreach ($check_list as $kk => &$vv) { foreach ($check_list as $kk => &$vv) {
$vv['check_time_str'] = date('Y-m-d H:i', $vv['check_time']); $vv['check_time_str'] = date('Y-m-d H:i', $vv['check_time']);
} }
return to_assign(0, '', $check_list); return to_assign(0, '', $check_list);
} }
//流程审核 //流程审核
public function flow_check() public function flow_check()
{ {
$param = get_params(); $param = get_params();
$id = $param['id']; $id = $param['id'];
$type = $param['type']; $type = $param['type'];
$detail = []; $detail = [];
$subject = '一个审批'; $subject = '一个审批';
if($type==1){ if ($type == 1) {
//日常审核 //日常审核
$detail = Db::name('Approve')->where(['id' => $id])->find(); $detail = Db::name('Approve')->where(['id' => $id])->find();
$subject = '一个日常审批'; $subject = '一个日常审批';
$msg_title_type = $detail['type']; $msg_title_type = $detail['type'];
} } else if ($type == 2) {
else if($type==2){
//报销审核 //报销审核
$detail = Db::name('Expense')->where(['id' => $id])->find(); $detail = Db::name('Expense')->where(['id' => $id])->find();
$subject = '一个报销审批'; $subject = '一个报销审批';
$msg_title_type = 22; $msg_title_type = 22;
} } else if ($type == 3) {
else if($type==3){
//发票审核 //发票审核
$detail = Db::name('Invoice')->where(['id' => $id])->find(); $detail = Db::name('Invoice')->where(['id' => $id])->find();
$subject = '一个发票审批'; $subject = '一个发票审批';
$msg_title_type = 23; $msg_title_type = 23;
} } else if ($type == 4) {
else if($type==4){
//合同审核 //合同审核
$detail = Db::name('Contract')->where(['id' => $id])->find(); $detail = Db::name('Contract')->where(['id' => $id])->find();
$subject = '一个合同审批'; $subject = '一个合同审批';
$msg_title_type = 24; $msg_title_type = 24;
} }
if (empty($detail)){ if (empty($detail)) {
return to_assign(1,'审批数据错误'); return to_assign(1, '审批数据错误');
} }
//当前审核节点详情 //当前审核节点详情
$step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>$detail['check_step_sort'],'delete_time'=>0])->find(); $step = Db::name('FlowStep')->where(['action_id' => $id, 'type' => $type, 'sort' => $detail['check_step_sort'], 'delete_time' => 0])->find();
//审核通过 //审核通过
if($param['check'] == 1){ if ($param['check'] == 1) {
$check_admin_ids = explode(",", strval($detail['check_admin_ids'])); $check_admin_ids = explode(",", strval($detail['check_admin_ids']));
if (!in_array($this->uid, $check_admin_ids)){ if (!in_array($this->uid, $check_admin_ids)) {
return to_assign(1,'您没权限审核该审批'); return to_assign(1, '您没权限审核该审批');
} }
//多人会签审批 //多人会签审批
if($step['flow_type'] == 4){ if ($step['flow_type'] == 4) {
//查询当前会签记录数 //查询当前会签记录数
$check_count = Db::name('FlowRecord')->where(['action_id'=>$id,'type'=>$type,'step_id'=>$step['id']])->count(); $check_count = Db::name('FlowRecord')->where(['action_id' => $id, 'type' => $type, 'step_id' => $step['id']])->count();
//当前会签记应有记录数 //当前会签记应有记录数
$flow_count = explode(',', $step['flow_uids']); $flow_count = explode(',', $step['flow_uids']);
if(($check_count+1) >=count($flow_count)){ if (($check_count + 1) >= count($flow_count)) {
$next_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']+1),'delete_time'=>0])->find(); $next_step = Db::name('FlowStep')->where(['action_id' => $id, 'type' => $type, 'sort' => ($detail['check_step_sort'] + 1), 'delete_time' => 0])->find();
if($next_step){ if ($next_step) {
//存在下一步审核 //存在下一步审核
if($next_step['flow_type'] == 1){ if ($next_step['flow_type'] == 1) {
$param['check_admin_ids'] = get_department_leader($detail['admin_id']); $param['check_admin_ids'] = get_department_leader($detail['admin_id']);
} } else if ($next_step['flow_type'] == 2) {
else if($next_step['flow_type'] == 2){ $param['check_admin_ids'] = get_department_leader($detail['admin_id'], 1);
$param['check_admin_ids'] = get_department_leader($detail['admin_id'],1); } else {
}
else{
$param['check_admin_ids'] = $next_step['flow_uids']; $param['check_admin_ids'] = $next_step['flow_uids'];
} }
$param['check_step_sort'] = $detail['check_step_sort']+1; $param['check_step_sort'] = $detail['check_step_sort'] + 1;
$param['check_status'] = 1; $param['check_status'] = 1;
} } else {
else{
//不存在下一步审核,审核结束 //不存在下一步审核,审核结束
$param['check_status'] = 2; $param['check_status'] = 2;
$param['check_admin_ids'] =''; $param['check_admin_ids'] = '';
} }
} } else {
else{
$param['check_status'] = 1; $param['check_status'] = 1;
$param['check_admin_ids'] = $step['flow_uids']; $param['check_admin_ids'] = $step['flow_uids'];
} }
} } else if ($step['flow_type'] == 0) {
else if($step['flow_type'] == 0){
//自由人审批 //自由人审批
if($param['check_node'] == 2){ if ($param['check_node'] == 2) {
$next_step = $detail['check_step_sort']+1; $next_step = $detail['check_step_sort'] + 1;
$flow_step = array( $flow_step = array(
'action_id' => $id, 'action_id' => $id,
'sort' => $next_step, 'sort' => $next_step,
@ -418,61 +409,53 @@ class Index extends BaseController
$param['check_admin_ids'] = $param['check_admin_ids']; $param['check_admin_ids'] = $param['check_admin_ids'];
$param['check_step_sort'] = $next_step; $param['check_step_sort'] = $next_step;
$param['check_status'] = 1; $param['check_status'] = 1;
} } else {
else{
//不存在下一步审核,审核结束 //不存在下一步审核,审核结束
$param['check_status'] = 2; $param['check_status'] = 2;
$param['check_admin_ids'] =''; $param['check_admin_ids'] = '';
} }
} } else {
else{ $next_step = Db::name('FlowStep')->where(['action_id' => $id, 'type' => $type, 'sort' => ($detail['check_step_sort'] + 1), 'delete_time' => 0])->find();
$next_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']+1),'delete_time'=>0])->find(); if ($next_step) {
if($next_step){
//存在下一步审核 //存在下一步审核
if($next_step['flow_type'] == 1){ if ($next_step['flow_type'] == 1) {
$param['check_admin_ids'] = get_department_leader($detail['admin_id']); $param['check_admin_ids'] = get_department_leader($detail['admin_id']);
} } else if ($next_step['flow_type'] == 2) {
else if($next_step['flow_type'] == 2){ $param['check_admin_ids'] = get_department_leader($detail['admin_id'], 1);
$param['check_admin_ids'] = get_department_leader($detail['admin_id'],1); } else {
}
else{
$param['check_admin_ids'] = $next_step['flow_uids']; $param['check_admin_ids'] = $next_step['flow_uids'];
} }
$param['check_step_sort'] = $detail['check_step_sort']+1; $param['check_step_sort'] = $detail['check_step_sort'] + 1;
$param['check_status'] = 1; $param['check_status'] = 1;
} } else {
else{
//不存在下一步审核,审核结束 //不存在下一步审核,审核结束
$param['check_status'] = 2; $param['check_status'] = 2;
$param['check_admin_ids'] =''; $param['check_admin_ids'] = '';
} }
} }
if($param['check_status'] == 1 && empty($param['check_admin_ids'])){ if ($param['check_status'] == 1 && empty($param['check_admin_ids'])) {
return to_assign(1,'找不到下一步的审批人该审批流程设置有问题请联系HR或者管理员'); return to_assign(1, '找不到下一步的审批人该审批流程设置有问题请联系HR或者管理员');
} }
//审核通过数据操作 //审核通过数据操作
$param['last_admin_id'] = $this->uid; $param['last_admin_id'] = $this->uid;
$param['flow_admin_ids'] = $detail['flow_admin_ids'].$this->uid.','; $param['flow_admin_ids'] = $detail['flow_admin_ids'] . $this->uid . ',';
if($type==1){ if ($type == 1) {
//日常审核 //日常审核
$res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 2) {
else if($type==2){
//报销审核 //报销审核
$res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 3) {
else if($type==3){
//发票审核 //发票审核
$res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 4) {
else if($type==4){
//合同审核 //合同审核
$res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} }
if($res!==false){ if ($res !== false) {
$checkData=array( $checkData = array(
'action_id' => $id, 'action_id' => $id,
'step_id' => $step['id'], 'step_id' => $step['id'],
'check_user_id' => $this->uid, 'check_user_id' => $this->uid,
@ -483,72 +466,66 @@ class Index extends BaseController
'create_time' => time() 'create_time' => time()
); );
$aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData);
add_log('check', $param['id'], $param,$subject); add_log('check', $param['id'], $param, $subject);
//发送消息通知 //发送消息通知
$msg=[ $msg = [
'create_time'=>date('Y-m-d H:i:s',$detail['create_time']), 'create_time' => date('Y-m-d H:i:s', $detail['create_time']),
'action_id'=>$id, 'action_id' => $id,
'title' => Db::name('FlowType')->where('id',$msg_title_type)->value('title'), 'title' => Db::name('FlowType')->where('id', $msg_title_type)->value('title'),
'from_uid'=>$detail['admin_id'] 'from_uid' => $detail['admin_id']
]; ];
if($param['check_status'] == 1){ if ($param['check_status'] == 1) {
$users = $param['check_admin_ids']; $users = $param['check_admin_ids'];
sendMessage($users,($type*10+11),$msg); sendMessage($users, ($type * 10 + 11), $msg);
} }
if($param['check_status'] == 2){ if ($param['check_status'] == 2) {
$users = $detail['admin_id']; $users = $detail['admin_id'];
sendMessage($users,($type*10+12),$msg); sendMessage($users, ($type * 10 + 12), $msg);
} }
return to_assign(); return to_assign();
} else {
return to_assign(1, '操作失败');
} }
else{ } else if ($param['check'] == 2) {
return to_assign(1,'操作失败');
}
}
else if($param['check'] == 2){
$check_admin_ids = explode(",", strval($detail['check_admin_ids'])); $check_admin_ids = explode(",", strval($detail['check_admin_ids']));
if (!in_array($this->uid, $check_admin_ids)){ if (!in_array($this->uid, $check_admin_ids)) {
return to_assign(1,'您没权限审核该审批'); return to_assign(1, '您没权限审核该审批');
} }
//拒绝审核,数据操作 //拒绝审核,数据操作
$param['check_status'] = 3; $param['check_status'] = 3;
$param['last_admin_id'] = $this->uid; $param['last_admin_id'] = $this->uid;
$param['flow_admin_ids'] = $detail['flow_admin_ids'].$this->uid.','; $param['flow_admin_ids'] = $detail['flow_admin_ids'] . $this->uid . ',';
$param['check_admin_ids'] =''; $param['check_admin_ids'] = '';
if($step['flow_type'] == 5){ if ($step['flow_type'] == 5) {
//获取上一步的审核信息 //获取上一步的审核信息
$prev_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']-1),'delete_time'=>0])->find(); $prev_step = Db::name('FlowStep')->where(['action_id' => $id, 'type' => $type, 'sort' => ($detail['check_step_sort'] - 1), 'delete_time' => 0])->find();
if($prev_step){ if ($prev_step) {
//存在上一步审核 //存在上一步审核
$param['check_step_sort'] = $prev_step['sort']; $param['check_step_sort'] = $prev_step['sort'];
$param['check_admin_ids'] = $prev_step['flow_uids']; $param['check_admin_ids'] = $prev_step['flow_uids'];
$param['check_status'] = 1; $param['check_status'] = 1;
} } else {
else{
//不存在上一步审核,审核初始化步骤 //不存在上一步审核,审核初始化步骤
$param['check_step_sort'] = 0; $param['check_step_sort'] = 0;
$param['check_admin_ids'] = ''; $param['check_admin_ids'] = '';
$param['check_status'] = 0; $param['check_status'] = 0;
} }
} }
if($type==1){ if ($type == 1) {
//日常审核 //日常审核
$res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 2) {
else if($type==2){
//报销审核 //报销审核
$res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 3) {
else if($type==3){
//发票审核 //发票审核
$res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} } else if ($type == 4) {
else if($type==4){
//合同审核 //合同审核
$res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param);
} }
if($res!==false){ if ($res !== false) {
$checkData=array( $checkData = array(
'action_id' => $id, 'action_id' => $id,
'step_id' => $step['id'], 'step_id' => $step['id'],
'check_user_id' => $this->uid, 'check_user_id' => $this->uid,
@ -559,48 +536,43 @@ class Index extends BaseController
'create_time' => time() 'create_time' => time()
); );
$aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData);
add_log('refue', $param['id'], $param,$subject); add_log('refue', $param['id'], $param, $subject);
//发送消息通知 //发送消息通知
$msg=[ $msg = [
'create_time'=>date('Y-m-d H:i:s',$detail['create_time']), 'create_time' => date('Y-m-d H:i:s', $detail['create_time']),
'action_id'=>$detail['id'], 'action_id' => $detail['id'],
'title' => Db::name('FlowType')->where('id',$msg_title_type)->value('title'), 'title' => Db::name('FlowType')->where('id', $msg_title_type)->value('title'),
'from_uid'=>$detail['admin_id'] 'from_uid' => $detail['admin_id']
]; ];
$users = $detail['admin_id']; $users = $detail['admin_id'];
sendMessage($users,($type*10+13),$msg); sendMessage($users, ($type * 10 + 13), $msg);
return to_assign(); return to_assign();
} else {
return to_assign(1, '操作失败');
} }
else{ } else if ($param['check'] == 3) {
return to_assign(1,'操作失败'); if ($detail['admin_id'] != $this->uid) {
} return to_assign(1, '你没权限操作');
}
else if($param['check'] == 3){
if($detail['admin_id'] != $this->uid){
return to_assign(1,'你没权限操作');
} }
//撤销审核,数据操作 //撤销审核,数据操作
$param['check_status'] = 4; $param['check_status'] = 4;
$param['check_admin_ids'] =''; $param['check_admin_ids'] = '';
$param['check_step_sort'] =0; $param['check_step_sort'] = 0;
if($type==1){ if ($type == 1) {
//日常审核 //日常审核
$res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param);
} } else if ($type == 2) {
else if($type==2){
//报销审核 //报销审核
$res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param);
} } else if ($type == 3) {
else if($type==3){
//发票审核 //发票审核
$res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param);
} } else if ($type == 4) {
else if($type==4){
//合同审核 //合同审核
$res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param);
} }
if($res!==false){ if ($res !== false) {
$checkData=array( $checkData = array(
'action_id' => $id, 'action_id' => $id,
'step_id' => 0, 'step_id' => 0,
'check_user_id' => $this->uid, 'check_user_id' => $this->uid,
@ -611,20 +583,20 @@ class Index extends BaseController
'create_time' => time() 'create_time' => time()
); );
$aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData);
add_log('back', $param['id'], $param,$subject); add_log('back', $param['id'], $param, $subject);
return to_assign(); return to_assign();
}else{ } else {
return to_assign(1,'操作失败'); return to_assign(1, '操作失败');
} }
} }
} }
//获取关键字 //获取关键字
public function get_keyword_cate() public function get_keyword_cate()
{ {
$keyword = Db::name('Keywords')->where(['status' => 1])->order('id desc')->select()->toArray(); $keyword = Db::name('Keywords')->where(['status' => 1])->order('id desc')->select()->toArray();
return to_assign(0, '', $keyword); return to_assign(0, '', $keyword);
} }
//读取报销类型 //读取报销类型
function get_expense_cate() function get_expense_cate()
@ -676,9 +648,9 @@ class Index extends BaseController
} }
//获取工作类型列表 //获取工作类型列表
public function get_work_cate() public function get_work_cate()
{ {
$cate = get_work_cate(); $cate = get_work_cate();
return to_assign(0, '', $cate); return to_assign(0, '', $cate);
} }
} }

View File

@ -1,42 +1,46 @@
<?php <?php
/** /**
* @copyright Copyright (c) 2021 勾股工作室 * @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0 * @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com * @link https://www.gougucms.com
*/ */
declare (strict_types = 1);
declare(strict_types=1);
namespace app\home\controller; namespace app\home\controller;
use app\api\BaseController; use app\api\BaseController;
use think\facade\Db; use think\facade\Db;
class api extends BaseController class api extends BaseController
{ {
//首页公告 //首页公告
public function get_note_list() public function get_note_list()
{ {
$list = Db::name('Note') $list = Db::name('Note')
->field('a.id,a.title,a.create_time,c.title as cate_title') ->field('a.id,a.title,a.create_time,c.title as cate_title')
->alias('a') ->alias('a')
->join('note_cate c', 'a.cate_id = c.id') ->join('note_cate c', 'a.cate_id = c.id')
->where(['a.status' => 1]) ->where(['a.status' => 1])
->order('a.end_time desc,a.sort desc,a.create_time desc') ->order('a.end_time desc,a.sort desc,a.create_time desc')
->limit(8) ->limit(8)
->select()->toArray(); ->select()->toArray();
foreach ($list as $key => $val) { foreach ($list as $key => $val) {
$list[$key]['create_time'] = date('Y-m-d H:i', $val['create_time']); $list[$key]['create_time'] = date('Y-m-d H:i', $val['create_time']);
} }
$res['data'] = $list; $res['data'] = $list;
return table_assign(0, '', $res); return table_assign(0, '', $res);
} }
//首页知识列表 //首页知识列表
public function get_article_list() public function get_article_list()
{ {
$prefix = get_config('database.connections.mysql.prefix');//判断是否安装了文章模块 $prefix = get_config('database.connections.mysql.prefix'); //判断是否安装了文章模块
$exist = Db::query('show tables like "'.$prefix.'article"'); $exist = Db::query('show tables like "' . $prefix . 'article"');
$res['data'] = []; $res['data'] = [];
if($exist){ if ($exist) {
$list = Db::name('Article') $list = Db::name('Article')
->field('a.id,a.title,a.create_time,a.read,c.title as cate_title') ->field('a.id,a.title,a.create_time,a.read,c.title as cate_title')
->alias('a') ->alias('a')
@ -55,7 +59,7 @@ class api extends BaseController
function isAuthProject($uid) function isAuthProject($uid)
{ {
if($uid == 1){ if ($uid == 1) {
return 1; return 1;
} }
$map = []; $map = [];
@ -64,17 +68,17 @@ class api extends BaseController
$count = Db::name('DataAuth')->where($map)->count(); $count = Db::name('DataAuth')->where($map)->count();
return $count; return $count;
} }
//首页项目 //首页项目
public function get_project_list() public function get_project_list()
{ {
$prefix = get_config('database.connections.mysql.prefix');//判断是否安装了项目模块 $prefix = get_config('database.connections.mysql.prefix'); //判断是否安装了项目模块
$exist = Db::query('show tables like "'.$prefix.'project"'); $exist = Db::query('show tables like "' . $prefix . 'project"');
$res['data'] = []; $res['data'] = [];
if($exist){ if ($exist) {
$project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id'); $project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id');
$where =[]; $where = [];
$where[] = ['a.delete_time', '=', 0]; $where[] = ['a.delete_time', '=', 0];
if($this->isAuthProject($this->uid)==0){ if ($this->isAuthProject($this->uid) == 0) {
$where[] = ['a.id', 'in', $project_ids]; $where[] = ['a.id', 'in', $project_ids];
} }
$list = Db::name('Project') $list = Db::name('Project')
@ -87,26 +91,25 @@ class api extends BaseController
->select()->toArray(); ->select()->toArray();
foreach ($list as $key => &$val) { foreach ($list as $key => &$val) {
$val['create_time'] = date('Y-m-d H:i', $val['create_time']); $val['create_time'] = date('Y-m-d H:i', $val['create_time']);
if($val['end_time']>0){ if ($val['end_time'] > 0) {
$val['plan_time'] = date('Y-m-d', $val['start_time']) . ' 至 ' . date('Y-m-d', $val['end_time']); $val['plan_time'] = date('Y-m-d', $val['start_time']) . ' 至 ' . date('Y-m-d', $val['end_time']);
} } else {
else{
$val['plan_time'] = '-'; $val['plan_time'] = '-';
} }
$val['status_name'] = \app\project\model\Project::$Status[(int) $val['status']]; $val['status_name'] = \app\project\model\Project::$Status[(int) $val['status']];
} }
$res['data'] = $list; $res['data'] = $list;
} }
return table_assign(0, '', $res); return table_assign(0, '', $res);
} }
//首页任务 //首页任务
public function get_task_list() public function get_task_list()
{ {
$prefix = get_config('database.connections.mysql.prefix');//判断是否安装了项目模块 $prefix = get_config('database.connections.mysql.prefix'); //判断是否安装了项目模块
$exist = Db::query('show tables like "'.$prefix.'project_task"'); $exist = Db::query('show tables like "' . $prefix . 'project_task"');
$res['data'] = []; $res['data'] = [];
if($exist){ if ($exist) {
$where = array(); $where = array();
$whereOr = array(); $whereOr = array();
$map1 = []; $map1 = [];
@ -115,77 +118,76 @@ class api extends BaseController
$map1[] = ['admin_id', '=', $this->uid]; $map1[] = ['admin_id', '=', $this->uid];
$map2[] = ['director_uid', '=', $this->uid]; $map2[] = ['director_uid', '=', $this->uid];
$map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$this->uid},assist_admin_ids)")]; $map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$this->uid},assist_admin_ids)")];
if($this->isAuthProject($this->uid)==0){ if ($this->isAuthProject($this->uid) == 0) {
$whereOr =[$map1,$map2,$map3]; $whereOr = [$map1, $map2, $map3];
} }
$where[] = ['delete_time', '=', 0]; $where[] = ['delete_time', '=', 0];
$list = Db::name('ProjectTask') $list = Db::name('ProjectTask')
->where(function ($query) use ($whereOr) { ->where(function ($query) use ($whereOr) {
if (!empty($whereOr)) if (!empty($whereOr))
$query->whereOr($whereOr); $query->whereOr($whereOr);
}) })
->where($where) ->where($where)
->withoutField('content,md_content') ->withoutField('content,md_content')
->order('flow_status asc') ->order('flow_status asc')
->order('id desc') ->order('id desc')
->limit(8) ->limit(8)
->select()->toArray(); ->select()->toArray();
foreach ($list as $key => &$val) { foreach ($list as $key => &$val) {
$val['director_name'] = Db::name('Admin')->where(['id' => $val['director_uid']])->value('name'); $val['director_name'] = Db::name('Admin')->where(['id' => $val['director_uid']])->value('name');
if($val['end_time']>0){ if ($val['end_time'] > 0) {
$val['end_time'] = date('Y-m-d', $val['end_time']); $val['end_time'] = date('Y-m-d', $val['end_time']);
} } else {
else{ $val['end_time'] = '-';
$val['end_time'] = '-';
}
$val['flow_name'] = \app\project\model\ProjectTask::$FlowStatus[(int) $val['flow_status']];
} }
$val['flow_name'] = \app\project\model\ProjectTask::$FlowStatus[(int) $val['flow_status']];
}
$res['data'] = $list; $res['data'] = $list;
} }
return table_assign(0, '', $res); return table_assign(0, '', $res);
} }
//获取访问记录 //获取访问记录
public function get_view_data() public function get_view_data()
{ {
$param = get_params(); $param = get_params();
$first_time = time(); $first_time = time();
$second_time = $first_time - 86400; $second_time = $first_time - 86400;
$three_time = $first_time - 86400 * 365; $three_time = $first_time - 86400 * 365;
$begin_first = strtotime(date('Y-m-d', $first_time) . " 00:00:00"); $begin_first = strtotime(date('Y-m-d', $first_time) . " 00:00:00");
$end_first = strtotime(date('Y-m-d', $first_time) . " 23:59:59"); $end_first = strtotime(date('Y-m-d', $first_time) . " 23:59:59");
$begin_second = strtotime(date('Y-m-d', $second_time) . " 00:00:00"); $begin_second = strtotime(date('Y-m-d', $second_time) . " 00:00:00");
$end_second = strtotime(date('Y-m-d', $second_time) . " 23:59:59"); $end_second = strtotime(date('Y-m-d', $second_time) . " 23:59:59");
$begin_three = strtotime(date('Y-m-d', $three_time) . " 00:00:00"); $begin_three = strtotime(date('Y-m-d', $three_time) . " 00:00:00");
$data_first = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select(); $data_first = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select();
$data_second = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select(); $data_second = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select();
$data_three = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select(); $data_three = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select();
return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three' => date_document($data_three)]); return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three' => date_document($data_three)]);
} }
//获取员工活跃数据 //获取员工活跃数据
public function get_view_log() public function get_view_log()
{ {
$times = strtotime("-30 day"); $times = strtotime("-30 day");
$where = []; $where = [];
$where[] = ['uid','<>',1]; $where[] = ['uid', '<>', 1];
$where[] = ['create_time', '>', $times]; $where[] = ['create_time', '>', $times];
$list = Db::name('AdminLog')->field("id,uid")->where($where)->select(); $list = Db::name('AdminLog')->field("id,uid")->where($where)->select();
$logs = array(); $logs = array();
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
$uid = $value['uid']; $uid = $value['uid'];
if (empty($logs[$uid])) { if (empty($logs[$uid])) {
$logs[$uid]['count'] = 1; $logs[$uid]['count'] = 1;
$logs[$uid]['name'] = Db::name('Admin')->where('id',$uid)->value('name'); $logs[$uid]['name'] = Db::name('Admin')->where('id', $uid)->value('name');
} else { } else {
$logs[$uid]['count'] += 1; $logs[$uid]['count'] += 1;
} }
} }
$counts = array_column($logs, 'count'); $counts = array_column($logs, 'count');
array_multisort($counts, SORT_DESC, $logs); array_multisort($counts, SORT_DESC, $logs);
//攫取前10 //攫取前10
$data_logs = array_slice($logs, 0, 10); $data_logs = array_slice($logs, 0, 10);
return to_assign(0, '', ['data_logs' => $data_logs]); return to_assign(0, '', ['data_logs' => $data_logs]);
} }
} }

View File

@ -19,11 +19,6 @@
<td class="info-td">执行时间限制</td> <td class="info-td">执行时间限制</td>
<td>{:get_system_info('max_execution_time')}</td> <td>{:get_system_info('max_execution_time')}</td>
</tr> </tr>
<tr>
<td class="info-td">勾股OA</td>
<td colspan="3">{:CMS_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:8px"
href="https://blog.gougucms.com/home/book/detail/bid/3.html" target="_blank">勾股OA文档</a></td>
</tr>
<tr> <tr>
<td class="info-td">ThinkPHP版本</td> <td class="info-td">ThinkPHP版本</td>
<td colspan="3">{$TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:8px" href="https://doc.thinkphp.cn/v8_0/preface.html" target="_blank">TP8文档</a></td> <td colspan="3">{$TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:8px" href="https://doc.thinkphp.cn/v8_0/preface.html" target="_blank">TP8文档</a></td>
@ -32,26 +27,6 @@
<td class="info-td">Layui版本</td> <td class="info-td">Layui版本</td>
<td colspan="3">{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:8px" href="https://layui.dev/docs/2/" target="_blank">Layui文档</a></td> <td colspan="3">{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:8px" href="https://layui.dev/docs/2/" target="_blank">Layui文档</a></td>
</tr> </tr>
<tr>
<td class="info-td">合作联系</td>
<td colspan="3"><i class="iconfont icon-weixin green"></i>微信号hdm588业务合作、功能定制请备注</td>
</tr>
<tr>
<td class="info-td">QQ交流群</td>
<td colspan="3">搜Q群24641076(满)46924914(满)295256660<br>或点击 <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=vb-Jdu0e-7iAAxbqGczDg1xFjxbdBsip&authKey=lwlNHAZiUOK2Rua5B14KhfwoYcvpQtHnlWMAJAbQRhfg3YQOUVIFEmfxpbhcCQw%2F&noverify=0&group_code=295256660" target="_blank" rel="nofollow"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="gougucms交流群" title="点击链接加入群聊【勾股开源交流群】" style="vertical-align:middle"></a></td>
</tr>
<tr>
<td class="info-td">同系列开源软件</td>
<td colspan="3"><a class="layui-badge layui-bg-blue" style="margin-right:8px" href="https://gitee.com/gouguopen/gougucms" target="_blank">勾股CMS</a><a class="layui-badge layui-bg-blue" style="margin-right:8px" href="https://gitee.com/gouguopen/blog" target="_blank">勾股BLOG</a><a class="layui-badge layui-bg-blue" href="https://gitee.com/gouguopen/dev" target="_blank" style="margin-right:8px">勾股DEV</a><a class="layui-badge layui-bg-blue" href="https://gitee.com/gouguopen/guoguadmin" target="_blank">勾股ADMIN</a></td>
</tr>
<tr>
<td colspan="4" style="text-align:center; color:#D2873D">🍗🍗 <strong>给作者加鸡腿 </strong>🍗🍗</td>
</tr>
<tr>
<td colspan="4">
<img src="https://www.gougucms.com/static/home/images/zfb.png" data-event="pay" style="width:50%; max-width:100%; cursor:pointer;" align=center /><img src="https://www.gougucms.com/static/home/images/wx.png" data-event="pay" style="width:50%; max-width:100%; cursor:pointer;" align=center />
</td>
</tr>
</table> </table>
</div> </div>
</div> </div>

View File

@ -138,6 +138,10 @@ class ProjectTask extends Model
$item['priority_name'] = self::$Priority[(int) $item['priority']]; $item['priority_name'] = self::$Priority[(int) $item['priority']];
$item['flow_name'] = self::$FlowStatus[(int) $item['flow_status']]; $item['flow_name'] = self::$FlowStatus[(int) $item['flow_status']];
$item['type_name'] = self::$Type[(int) $item['type']]; $item['type_name'] = self::$Type[(int) $item['type']];
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
if ($item['admin_id'] > 0) {
$item['admin_name'] = Db::name('Admin')->where(['id' => $item['admin_id']])->value('name');
}
return $item; return $item;
}); });
return $list; return $list;

View File

@ -96,33 +96,35 @@
} }
, { field: 'cate_name', title: '工作类型', width: 90, align: 'center' } , { field: 'cate_name', title: '工作类型', width: 90, align: 'center' }
,{ ,{
field: 'title', title: '任务主题',minWidth:240, rowspan: 2, templet: function (d) { field: 'title', title: '任务主题',minWidth:500, rowspan: 2, templet: function (d) {
var html = '<span class="layui-badge layui-bg-' + d.priority + '">' + d.priority_name + '</span> <a class="side-a" data-href="/project/task/view/id/' + d.id + '">' + d.title + '</a>'; var html = '<span class="layui-badge layui-bg-' + d.priority + '">' + d.priority_name + '</span> <a class="side-a" data-href="/project/task/view/id/' + d.id + '">' + d.title + '</a>';
return html; return html;
} }
} }
, { field: 'before_task', title: '前置任务编号',align: 'center', width: 110, templet: function (d) { // , { field: 'before_task', title: '前置任务编号',align: 'center', width: 110, templet: function (d) {
var html = '-'; // var html = '-';
if(d.before_task > 0){ // if(d.before_task > 0){
html = '<a class="side-a" data-href="/project/task/view/id/' + d.before_task + '">T' + d.before_task + '</a>'; // html = '<a class="side-a" data-href="/project/task/view/id/' + d.before_task + '">T' + d.before_task + '</a>';
} // }
return html; // return html;
} // }
} // }
, { field: 'after_num', title: '后置任务数', align: 'center',width: 100, templet: function (d) { // , { field: 'after_num', title: '后置任务数', align: 'center',width: 100, templet: function (d) {
var html = '-'; // var html = '-';
if(d.after_num > 0){ // if(d.after_num > 0){
html = '<a class="blue" lay-event="more" style="cursor:pointer;">'+d.after_num+'</a>'; // html = '<a class="blue" lay-event="more" style="cursor:pointer;">'+d.after_num+'</a>';
if(d.after_num == 1){ // if(d.after_num == 1){
html = ' <a class="side-a" data-href="/project/task/view/id/' + d.after_id + '">'+d.after_num+'</a>'; // html = ' <a class="side-a" data-href="/project/task/view/id/' + d.after_id + '">'+d.after_num+'</a>';
} // }
} // }
return html; // return html;
} // }
} // }
, { field: 'project_name', title: '关联项目', width: 300 } , { field: 'admin_name', title: '创建人',width: 100 }
, { field: 'create_time', title: '创建时间', width: 150}
, { field: 'project_name', title: '关联项目', width: 150 }
, { field: 'director_name', title: '负责人', align: 'center', width: 80 } , { field: 'director_name', title: '负责人', align: 'center', width: 80 }
, { field: 'assist_admin_names', title: '协作人', width: 200 } , { field: 'assist_admin_names', title: '协作人', width: 80 }
, { field: 'plan_hours', title: '预估工时', align: 'center', width: 80 } , { field: 'plan_hours', title: '预估工时', align: 'center', width: 80 }
, { , {
field: 'end_time', title: '计划完成日期', width: 150, templet: function (d) { field: 'end_time', title: '计划完成日期', width: 150, templet: function (d) {