用户数据汇总
This commit is contained in:
parent
49ead6539f
commit
c0f36c907e
|
@ -24,85 +24,36 @@ class HomeIndex extends ApiController
|
|||
Auth::class => ['except' => []]
|
||||
];
|
||||
|
||||
public function index()
|
||||
public function data_total()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$admin_id = $this->uid;
|
||||
//未读消息统计
|
||||
$msg_map[] = ['to_uid', '=', $admin_id];
|
||||
$msg_map[] = ['read_time', '=', 0];
|
||||
$msg_map[] = ['status', '=', 1];
|
||||
$msg_count = Db::name('Message')->where($msg_map)->count();
|
||||
$statistics['msg_num'] = $msg_count;
|
||||
return to_assign(0, 'ok', $statistics);
|
||||
} else {
|
||||
$admin = Db::name('Admin')->where('id',$this->uid)->find();
|
||||
if (get_cache('menu' . $this->uid)) {
|
||||
$list = get_cache('menu' . $this->uid);
|
||||
} else {
|
||||
$adminGroup = Db::name('PositionGroup')->where(['pid' => $admin['position_id']])->column('group_id');
|
||||
$adminMenu = Db::name('AdminGroup')->where('id', 'in', $adminGroup)->column('rules');
|
||||
$adminMenus = [];
|
||||
foreach ($adminMenu as $k => $v) {
|
||||
$v = explode(',', $v);
|
||||
$adminMenus = array_merge($adminMenus, $v);
|
||||
}
|
||||
$menu = Db::name('AdminRule')->where(['menu' => 1, 'status' => 1])->where('id', 'in', $adminMenus)->order('sort asc,id asc')->select()->toArray();
|
||||
$list = list_to_tree($menu);
|
||||
\think\facade\Cache::tag('adminMenu')->set('menu' . $this->uid, $list);
|
||||
}
|
||||
View::assign('menu', $list);
|
||||
View::assign('theme',$admin['theme']);
|
||||
View::assign('web',get_system_config('web'));
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
public function main()
|
||||
{
|
||||
$install = false;
|
||||
if (file_exists(CMS_ROOT . 'app/install')) {
|
||||
$install = true;
|
||||
}
|
||||
$total = [];
|
||||
$adminCount = Db::name('Admin')->where('status', '1')->count();
|
||||
$approveCount = Db::name('Approve')->count();
|
||||
$noteCount = Db::name('Note')->where('status', '1')->count();
|
||||
$expenseCount = Db::name('Expense')->where('delete_time', '0')->count();
|
||||
$invoiceCount = Db::name('Invoice')->where('delete_time', '0')->count();
|
||||
$total[] = array(
|
||||
'name' => '员工',
|
||||
'num' => $adminCount,
|
||||
);
|
||||
$total[] = array(
|
||||
'name' => '公告',
|
||||
'type' => 'note',
|
||||
'num' => $noteCount,
|
||||
);
|
||||
$total[] = array(
|
||||
'name' => '审批',
|
||||
'type' => 'approve',
|
||||
'num' => $approveCount,
|
||||
);
|
||||
$total[] = array(
|
||||
'name' => '报销',
|
||||
'type' => 'expense',
|
||||
'num' => $expenseCount,
|
||||
);
|
||||
$total[] = array(
|
||||
'name' => '发票',
|
||||
'type' => 'invoice',
|
||||
'num' => $invoiceCount,
|
||||
);
|
||||
|
||||
$handle=[
|
||||
'approve'=>Db::name('Approve')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")]])->count(),
|
||||
'expenses'=>Db::name('Expense')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count(),
|
||||
'invoice'=>Db::name('Invoice')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count(),
|
||||
'income'=>Db::name('Invoice')->where([['is_cash', '<', 2],['admin_id','=',$this->uid],['check_status', '=', 5],['delete_time', '=', 0]])->count(),
|
||||
'contract'=>0,
|
||||
'task'=>0
|
||||
];
|
||||
|
||||
$this->uid = JWT_UID;
|
||||
$module = Db::name('AdminModule')->column('name');
|
||||
if (in_array('customer', $module)) {
|
||||
|
||||
$whereCustomer = array();
|
||||
$whereCustomerOr = array();
|
||||
$uid = $this->uid;
|
||||
|
@ -122,6 +73,7 @@ class HomeIndex extends ApiController
|
|||
->count();
|
||||
$total[] = array(
|
||||
'name' => '客户',
|
||||
'type' => 'customer',
|
||||
'num' => $customerCount,
|
||||
);
|
||||
}
|
||||
|
@ -147,12 +99,11 @@ class HomeIndex extends ApiController
|
|||
->count();
|
||||
$total[] = array(
|
||||
'name' => '合同',
|
||||
'type' => 'contract',
|
||||
'num' => $contractCount,
|
||||
);
|
||||
$handle['contract'] = Db::name('Contract')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count();
|
||||
}
|
||||
if (in_array('project', $module)) {
|
||||
|
||||
$project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id');
|
||||
$whereProject = [];
|
||||
$whereProject[] = ['delete_time', '=', 0];
|
||||
|
@ -180,43 +131,24 @@ class HomeIndex extends ApiController
|
|||
|
||||
$total[] = array(
|
||||
'name' => '项目',
|
||||
'type' => 'project',
|
||||
'num' => $projectCount,
|
||||
);
|
||||
$total[] = array(
|
||||
'name' => '任务',
|
||||
'type' => 'task',
|
||||
'num' => $taskCount,
|
||||
);
|
||||
$handle['task'] = Db::name('ProjectTask')->where([['director_uid', '=', $this->uid],['flow_status', '<', 3],['delete_time', '=', 0]])->count();
|
||||
}
|
||||
if (in_array('article', $module)) {
|
||||
$articleCount = Db::name('Article')->where([['delete_time', '=', 0],['uid', '=', $this->uid]])->count();
|
||||
$total[] = array(
|
||||
'name' => '文章',
|
||||
'type' => 'article',
|
||||
'num' => $articleCount,
|
||||
);
|
||||
}
|
||||
|
||||
$adminGroup = Db::name('PositionGroup')->where(['pid' => $this->pid])->column('group_id');
|
||||
$adminLayout = Db::name('AdminGroup')->where('id', 'in', $adminGroup)->column('layouts');
|
||||
$adminLayouts = [];
|
||||
foreach ($adminLayout as $k => $v) {
|
||||
$v = explode(',', $v);
|
||||
$adminLayouts = array_merge($adminLayouts, $v);
|
||||
}
|
||||
$layouts = get_config('layout');
|
||||
$layout_selected = [];
|
||||
foreach ($layouts as $key =>$vo) {
|
||||
if (!empty($adminLayouts) and in_array($vo['id'], $adminLayouts)) {
|
||||
$layout_selected[] = $vo;
|
||||
}
|
||||
}
|
||||
// 首页统计
|
||||
View::assign('layout_selected',$layout_selected);
|
||||
View::assign('total', $total);
|
||||
View::assign('handle', $handle);
|
||||
View::assign('install', $install);
|
||||
View::assign('TP_VERSION', \think\facade\App::version());
|
||||
return View();
|
||||
$this->apiSuccess('', $total);
|
||||
}
|
||||
|
||||
//修改个人信息
|
||||
|
|
Loading…
Reference in New Issue