72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* @copyright Copyright (c) 2021 勾股工作室
|
|
* @license https://opensource.org/licenses/GPL-3.0
|
|
* @link https://www.gougucms.com
|
|
*/
|
|
declare (strict_types = 1);
|
|
namespace app\api\controller;
|
|
|
|
use app\api\ApiController;
|
|
use app\api\middleware\Auth;
|
|
use think\facade\Db;
|
|
|
|
class Common extends ApiController
|
|
{
|
|
|
|
protected $middleware = [
|
|
Auth::class => ['except' => []]
|
|
];
|
|
|
|
//获取部门
|
|
public function get_department()
|
|
{
|
|
$department = get_department();
|
|
return to_assign(0, '', $department);
|
|
}
|
|
|
|
//获取部门树形节点列表
|
|
public function get_department_tree()
|
|
{
|
|
$department = get_department();
|
|
$list = get_tree($department, 0, 2);
|
|
$data['trees'] = $list;
|
|
$this->apiSuccess('获取成功', $data);
|
|
}
|
|
|
|
//获取子部门所有员工
|
|
public function get_employee($did = 0)
|
|
{
|
|
$did = get_params('did');
|
|
if($did == 1){
|
|
$department = $did;
|
|
}
|
|
else{
|
|
$department = get_department_son($did);
|
|
}
|
|
$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')
|
|
->alias('a')
|
|
->join('Department d', 'a.did = d.id')
|
|
->where(['a.status' => 1])
|
|
->where('a.id', ">", 1)
|
|
->where('a.did', "in", $department)
|
|
->select();
|
|
$this->apiSuccess('获取成功', $employee);
|
|
}
|
|
|
|
//获取报销类型
|
|
public function get_expense_cate()
|
|
{
|
|
$expense_cate = Db::name('ExpenseCate')->where(['status' => 1])->field(['id', 'title'])->select()->toArray();
|
|
$this->apiSuccess('获取成功', $expense_cate);
|
|
}
|
|
|
|
//获取开票主体
|
|
public function get_invoice_subject()
|
|
{
|
|
$subject = Db::name('InvoiceSubject')->where(['status' => 1])->order('id desc')->select()->toArray();
|
|
$this->apiSuccess('获取成功', $subject);
|
|
}
|
|
}
|