人事模块优化
This commit is contained in:
parent
963b0de0b7
commit
5dd6b3515c
@ -18,14 +18,14 @@ use think\facade\View;
|
||||
class Department extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = Db::name('Department')
|
||||
->field('d.*,a.name as leader')
|
||||
->alias('d')
|
||||
->join('Admin a', 'a.id = d.uid','LEFT')
|
||||
->order('create_time asc')
|
||||
->select();
|
||||
->field('d.*,a.name as leader')
|
||||
->alias('d')
|
||||
->join('Admin a', 'a.id = d.leader_id', 'LEFT')
|
||||
->order('id asc')
|
||||
->select();
|
||||
return to_assign(0, '', $list);
|
||||
} else {
|
||||
return view();
|
||||
@ -35,41 +35,23 @@ class Department extends BaseController
|
||||
//添加部门
|
||||
public function add()
|
||||
{
|
||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
||||
$pid = empty(get_params('pid')) ? 0 : get_params('pid');
|
||||
$department = set_recursion(get_department());
|
||||
if($id > 0) {
|
||||
$detail = Db::name('Department')->where(['id' => $id])->find();
|
||||
$users=Db::name('Admin')->where(['did'=>$id,'status'=>1])->select();
|
||||
View::assign('users', $users);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('department', $department);
|
||||
View::assign('pid', $pid);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
|
||||
public function post_submit()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
if ($param['id'] > 0) {
|
||||
try {
|
||||
validate(DepartmentCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$department_array=get_department_son($param['id']);
|
||||
if (in_array($param['pid'], $department_array)){
|
||||
return to_assign(1,'上级部门不能是该部门本身或其下属部门');
|
||||
}
|
||||
else{
|
||||
Db::name('Department')->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
}
|
||||
try {
|
||||
validate(DepartmentCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$department_array = get_department_son($param['id']);
|
||||
if (in_array($param['pid'], $department_array)) {
|
||||
return to_assign(1, '上级部门不能是该部门本身或其下属部门');
|
||||
} else {
|
||||
Db::name('Department')->strict(false)->field(true)->update($param);
|
||||
add_log('edit', $param['id'], $param);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
validate(DepartmentCheck::class)->scene('add')->check($param);
|
||||
@ -81,6 +63,20 @@ class Department extends BaseController
|
||||
add_log('add', $did, $param);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$pid = isset($param['pid']) ? $param['pid'] : 0;
|
||||
$department = set_recursion(get_department());
|
||||
if ($id > 0) {
|
||||
$detail = Db::name('Department')->where(['id' => $id])->find();
|
||||
$users = Db::name('Admin')->where(['did' => $id, 'status' => 1])->select();
|
||||
View::assign('users', $users);
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('department', $department);
|
||||
View::assign('pid', $pid);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,19 +84,19 @@ class Department extends BaseController
|
||||
public function delete()
|
||||
{
|
||||
$id = get_params("id");
|
||||
$count = Db::name('Department')->where([['pid','=',$id],['status','>=',0]])->count();
|
||||
$count = Db::name('Department')->where([['pid', '=', $id], ['status', '>=', 0]])->count();
|
||||
if ($count > 0) {
|
||||
return to_assign(1,"该部门下还有子部门,无法删除");
|
||||
return to_assign(1, "该部门下还有子部门,无法删除");
|
||||
}
|
||||
$users = Db::name('Admin')->where([['did','=',$id],['status','>=',0]])->count();
|
||||
$users = Db::name('Admin')->where([['did', '=', $id], ['status', '>=', 0]])->count();
|
||||
if ($users > 0) {
|
||||
return to_assign(1,"该部门下还有员工,无法删除");
|
||||
return to_assign(1, "该部门下还有员工,无法删除");
|
||||
}
|
||||
if (Db::name('Department')->delete($id) !== false) {
|
||||
add_log('delete',$id);
|
||||
return to_assign(0,"删除部门成功");
|
||||
add_log('delete', $id);
|
||||
return to_assign(0, "删除部门成功");
|
||||
} else {
|
||||
return to_assign(1,"删除失败");
|
||||
return to_assign(1, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,47 +20,24 @@ class Position extends BaseController
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$list = Db::name('Position')->where('status','>=',0)->order('create_time asc')->select()->toArray();
|
||||
foreach ($list as &$val) {
|
||||
$groupId = Db::name('PositionGroup')->where(['pid' => $val['id']])->column('group_id');
|
||||
$groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title');
|
||||
$val['groupName'] = implode(',', $groupName);
|
||||
}
|
||||
$res['data'] = $list;
|
||||
$list = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select()->toArray();
|
||||
foreach ($list as &$val) {
|
||||
$groupId = Db::name('PositionGroup')->where(['pid' => $val['id']])->column('group_id');
|
||||
$groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title');
|
||||
$val['groupName'] = implode(',', $groupName);
|
||||
}
|
||||
$res['data'] = $list;
|
||||
return table_assign(0, '', $res);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
//添加&编辑
|
||||
public function add()
|
||||
{
|
||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
if($id > 0) {
|
||||
$detail = Db::name('Position')->where(['id' => $id])->find();
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if(in_array($val['id'],$detail['group_id'])){
|
||||
$val['checked'] = 1;
|
||||
}
|
||||
else{
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('group', $group);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
|
||||
//提交添加
|
||||
public function post_submit()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(PositionCheck::class)->scene('edit')->check($param);
|
||||
@ -77,7 +54,7 @@ class Position extends BaseController
|
||||
$data[$k] = [
|
||||
'pid' => $param['id'],
|
||||
'group_id' => $v,
|
||||
'create_time' => time()
|
||||
'create_time' => time(),
|
||||
];
|
||||
}
|
||||
Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data);
|
||||
@ -107,7 +84,7 @@ class Position extends BaseController
|
||||
$data[$k] = [
|
||||
'pid' => $uid,
|
||||
'group_id' => $v,
|
||||
'create_time' => time()
|
||||
'create_time' => time(),
|
||||
];
|
||||
}
|
||||
Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data);
|
||||
@ -122,57 +99,75 @@ class Position extends BaseController
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
else{
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
if ($id > 0) {
|
||||
$detail = Db::name('Position')->where(['id' => $id])->find();
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if (in_array($val['id'], $detail['group_id'])) {
|
||||
$val['checked'] = 1;
|
||||
} else {
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
View::assign('group', $group);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$id = get_params('id');
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
{
|
||||
$id = get_params('id');
|
||||
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
|
||||
$detail = Db::name('Position')->where(['id' => $id])->find();
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if(in_array($val['id'],$detail['group_id'])){
|
||||
$val['checked'] = 1;
|
||||
}
|
||||
else{
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$menu = get_admin_menu();
|
||||
$rule = get_admin_rule();
|
||||
$user_groups = Db::name('PositionGroup')
|
||||
->alias('a')
|
||||
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
|
||||
->where("a.pid='{$id}' and g.status='1'")
|
||||
->select()
|
||||
->toArray();
|
||||
$groups = $user_groups ?: [];
|
||||
$detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id');
|
||||
foreach ($group as &$val) {
|
||||
if (in_array($val['id'], $detail['group_id'])) {
|
||||
$val['checked'] = 1;
|
||||
} else {
|
||||
$val['checked'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$menus = [];
|
||||
$rules = [];
|
||||
foreach ($groups as $g) {
|
||||
$menus = array_merge($menus, explode(',', trim($g['menus'], ',')));
|
||||
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
|
||||
}
|
||||
$menus = array_unique($menus);
|
||||
$rules = array_unique($rules);
|
||||
|
||||
$role_menu = create_tree_list(0, $menu, $menus);
|
||||
$role_rule = create_tree_list(0, $rule, $rules);
|
||||
$menu = get_admin_menu();
|
||||
$rule = get_admin_rule();
|
||||
$user_groups = Db::name('PositionGroup')
|
||||
->alias('a')
|
||||
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
|
||||
->where("a.pid='{$id}' and g.status='1'")
|
||||
->select()
|
||||
->toArray();
|
||||
$groups = $user_groups ?: [];
|
||||
|
||||
$menus = [];
|
||||
$rules = [];
|
||||
foreach ($groups as $g) {
|
||||
$menus = array_merge($menus, explode(',', trim($g['menus'], ',')));
|
||||
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
|
||||
}
|
||||
$menus = array_unique($menus);
|
||||
$rules = array_unique($rules);
|
||||
|
||||
$role_menu = create_tree_list(0, $menu, $menus);
|
||||
$role_rule = create_tree_list(0, $rule, $rules);
|
||||
View::assign('role_menu', $role_menu);
|
||||
View::assign('role_rule', $role_rule);
|
||||
View::assign('detail', $detail);
|
||||
View::assign('group', $group);
|
||||
add_log('view', $id);
|
||||
View::assign('group', $group);
|
||||
add_log('view', $id);
|
||||
return view();
|
||||
}
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
$id = get_params("id");
|
||||
if($id == 1){
|
||||
if ($id == 1) {
|
||||
return to_assign(0, "超级岗位,不能删除");
|
||||
}
|
||||
$data['status'] = '-1';
|
||||
|
@ -1,344 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 勾股工作室
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.gougucms.com
|
||||
*/
|
||||
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\home\BaseController;
|
||||
use app\home\model\Expense as ExpenseList;
|
||||
use app\home\model\ExpenseCate;
|
||||
use app\home\validate\ExpenseCateCheck;
|
||||
use app\home\validate\ExpenseCheck;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
class Expense extends BaseController
|
||||
{
|
||||
public function cate()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$cate = Db::name('ExpenseCate')->order('create_time asc')->select();
|
||||
return to_assign(0, '', $cate);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
//提交保存分类
|
||||
public function cate_add()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(ExpenseCateCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$data['update_time'] = time();
|
||||
$res = ExpenseCate::strict(false)->field(true)->update($param);
|
||||
if ($res) {
|
||||
add_log('edit', $param['id'], $param);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
try {
|
||||
validate(ExpenseCateCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = time();
|
||||
$insertId = ExpenseCate::strict(false)->field(true)->insertGetId($param);
|
||||
if ($insertId) {
|
||||
add_log('add', $insertId, $param);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get_list($param = [], $where = [])
|
||||
{
|
||||
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||
$expense = ExpenseList::where($where)
|
||||
->order('create_time asc')
|
||||
->paginate($rows, false, ['query' => $param])
|
||||
->each(function ($item, $key) {
|
||||
$item->income_month = empty($item->income_month) ? '-' : date('Y-m', $item->income_month);
|
||||
$item->expense_time = empty($item->expense_time) ? '-' : date('Y-m-d', $item->expense_time);
|
||||
$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->department = Db::name('Department')->where(['id' => $item->did])->value('title');
|
||||
$item->check_name = Db::name('Admin')->where(['id' => $item->check_admin_id])->value('name');
|
||||
$item->check_time = empty($item->check_time) ? '-' : date('Y-m-d H:i', $item->check_time);
|
||||
$item->pay_name = Db::name('Admin')->where(['id' => $item->pay_admin_id])->value('name');
|
||||
$item->pay_time = empty($item->pay_time) ? '-' : date('Y-m-d H:i', $item->pay_time);
|
||||
$item->amount = Db::name('ExpenseInterfix')->where(['exid' => $item->id])->sum('amount');
|
||||
});
|
||||
return $expense;
|
||||
}
|
||||
|
||||
public function detail($id = 0)
|
||||
{
|
||||
$expense = Db::name('Expense')->where(['id' => $id])->find();
|
||||
if ($expense) {
|
||||
$expense['income_month'] = empty($expense['income_month']) ? '-' : date('Y-m', $expense['income_month']);
|
||||
$expense['expense_time'] = empty($expense['expense_time']) ? '-' : date('Y-m-d', $expense['expense_time']);
|
||||
$expense['user_name'] = Db::name('Admin')->where(['id' => $expense['uid']])->value('name');
|
||||
$expense['department'] = Db::name('Department')->where(['id' => $expense['did']])->value('title');
|
||||
$expense['amount'] = Db::name('ExpenseInterfix')->where(['exid' => $expense['id']])->sum('amount');
|
||||
|
||||
if ($expense['check_admin_id'] > 0) {
|
||||
$expense['check_admin'] = Db::name('Admin')->where(['id' => $expense['check_admin_id']])->value('name');
|
||||
$expense['check_time'] = date('Y-m-d H:i:s', $expense['check_time']);
|
||||
}
|
||||
if ($expense['pay_admin_id'] > 0) {
|
||||
$expense['pay_admin'] = Db::name('Admin')->where(['id' => $expense['pay_admin_id']])->value('name');
|
||||
$expense['pay_time'] = date('Y-m-d H:i:s', $expense['pay_time']);
|
||||
}
|
||||
$expense['list'] = Db::name('ExpenseInterfix')
|
||||
->field('a.*,c.title as cate_title')
|
||||
->alias('a')
|
||||
->join('ExpenseCate c', 'a.cate_id = c.id')
|
||||
->where(['a.exid' => $expense['id']])
|
||||
->select();
|
||||
}
|
||||
return $expense;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = [];
|
||||
$where[] = ['status', '=', 1];
|
||||
//按时间检索
|
||||
$start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0;
|
||||
$end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0;
|
||||
if ($start_time > 0 && $end_time > 0) {
|
||||
$where[] = ['expense_time', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
$expense = $this->get_list($param, $where);
|
||||
return table_assign(0, '', $expense);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
function list() {
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where = [];
|
||||
$where[] = ['admin_id', '=', $this->uid];
|
||||
$where[] = ['status', '=', 1];
|
||||
//按时间检索
|
||||
$start_time = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0;
|
||||
$end_time = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0;
|
||||
if ($start_time > 0 && $end_time > 0) {
|
||||
$where[] = ['expense_time', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
$expense = $this->get_list($param, $where);
|
||||
return table_assign(0, '', $expense);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add()
|
||||
{
|
||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
||||
if ($id > 0) {
|
||||
$expense = $this->detail($id);
|
||||
View::assign('expense', $expense);
|
||||
}
|
||||
$expense_cate = Db::name('ExpenseCate')->where(['status' => 1])->select()->toArray();
|
||||
View::assign('user', get_admin($this->uid));
|
||||
View::assign('expense_cate', $expense_cate);
|
||||
View::assign('id', $id);
|
||||
return view();
|
||||
}
|
||||
|
||||
//提交添加
|
||||
public function post_submit()
|
||||
{
|
||||
$admin_id = $this->uid;
|
||||
$dbRes = false;
|
||||
$param = get_params();
|
||||
$param['admin_id'] = $admin_id;
|
||||
$param['income_month'] = isset($param['income_month']) ? strtotime(urldecode($param['income_month'])) : 0;
|
||||
$param['expense_time'] = isset($param['expense_time']) ? strtotime(urldecode($param['expense_time'])) : 0;
|
||||
$param['check_status'] = 1;
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
try {
|
||||
validate(ExpenseCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
if ($res !== false) {
|
||||
$exid = $param['id'];
|
||||
//相关内容多个数组;
|
||||
$amountData = isset($param['amount']) ? $param['amount'] : '';
|
||||
$remarksData = isset($param['remarks']) ? $param['remarks'] : '';
|
||||
$cateData = isset($param['cate_id']) ? $param['cate_id'] : '';
|
||||
$idData = isset($param['expense_id']) ? $param['expense_id'] : 0;
|
||||
if ($amountData) {
|
||||
foreach ($amountData as $key => $value) {
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['id'] = $idData[$key];
|
||||
$data['exid'] = $exid;
|
||||
$data['admin_id'] = $admin_id;
|
||||
$data['amount'] = $amountData[$key];
|
||||
$data['cate_id'] = $cateData[$key];
|
||||
$data['remarks'] = $remarksData[$key];
|
||||
if ($data['amount'] == 0) {
|
||||
Db::rollback();
|
||||
return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零');
|
||||
}
|
||||
if ($data['id'] > 0) {
|
||||
$data['update_time'] = time();
|
||||
$resa = Db::name('ExpenseInterfix')->strict(false)->field(true)->update($data);
|
||||
} else {
|
||||
$data['create_time'] = time();
|
||||
$eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_log('edit', $exid, $param);
|
||||
Db::commit();
|
||||
$dbRes = true;
|
||||
} else {
|
||||
Db::rollback();
|
||||
}
|
||||
} catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
||||
Db::rollback();
|
||||
return to_assign(1, $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
validate(ExpenseCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = time();
|
||||
Db::startTrans();
|
||||
try {
|
||||
$exid = ExpenseList::strict(false)->field(true)->insertGetId($param);
|
||||
if ($exid) {
|
||||
//相关内容多个数组;
|
||||
$amountData = isset($param['amount']) ? $param['amount'] : '';
|
||||
$remarksData = isset($param['remarks']) ? $param['remarks'] : '';
|
||||
$cateData = isset($param['cate_id']) ? $param['cate_id'] : '';
|
||||
if ($amountData) {
|
||||
foreach ($amountData as $key => $value) {
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['exid'] = $exid;
|
||||
$data['admin_id'] = $admin_id;
|
||||
$data['amount'] = $amountData[$key];
|
||||
$data['cate_id'] = $cateData[$key];
|
||||
$data['remarks'] = $remarksData[$key];
|
||||
$data['create_time'] = time();
|
||||
if ($data['amount'] == 0) {
|
||||
Db::rollback();
|
||||
return to_assign(1, '第' . ($key + 1) . '条报销金额不能为零');
|
||||
}
|
||||
$eid = Db::name('ExpenseInterfix')->strict(false)->field(true)->insertGetId($data);
|
||||
}
|
||||
}
|
||||
add_log('add', $exid, $param);
|
||||
Db::commit();
|
||||
$dbRes = true;
|
||||
} else {
|
||||
Db::rollback();
|
||||
}
|
||||
} catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
||||
Db::rollback();
|
||||
return to_assign(1, $e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($dbRes == true) {
|
||||
return to_assign();
|
||||
} else {
|
||||
return to_assign(1, '保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
//查看
|
||||
public function view()
|
||||
{
|
||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
||||
$expense = $this->detail($id);
|
||||
View::assign('uid', $this->uid);
|
||||
View::assign('expense', $expense);
|
||||
return view();
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete()
|
||||
{
|
||||
$id = get_params("id");
|
||||
$expense = $this->detail($id);
|
||||
if ($expense['check_status'] == 2) {
|
||||
return to_assign(1, "已审核的报销记录不能删除");
|
||||
}
|
||||
if ($expense['check_status'] == 3) {
|
||||
return to_assign(1, "已打款的报销记录不能删除");
|
||||
}
|
||||
$data['status'] = '-1';
|
||||
$data['id'] = $id;
|
||||
$data['update_time'] = time();
|
||||
if (Db::name('expense')->update($data) !== false) {
|
||||
add_log('delete', $id);
|
||||
return to_assign(0, "删除成功");
|
||||
} else {
|
||||
return to_assign(1, "删除失败");
|
||||
}
|
||||
}
|
||||
//设置
|
||||
public function check()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
if ($param['check_status'] == 2 || $param['check_status'] == 0) {
|
||||
$param['check_admin_id'] = $this->uid;
|
||||
$param['check_time'] = time();
|
||||
}
|
||||
if ($param['check_status'] == 3) {
|
||||
$param['pay_admin_id'] = $this->uid;
|
||||
$param['pay_time'] = time();
|
||||
}
|
||||
$res = ExpenseList::where('id', $param['id'])->strict(false)->field(true)->update($param);
|
||||
if ($res !== false) {
|
||||
return to_assign();
|
||||
} else {
|
||||
return to_assign(1, "操作失败");
|
||||
}
|
||||
} else {
|
||||
$expense = $this->detail($param['id']);
|
||||
View::assign('expense', $expense);
|
||||
View::assign('uid', $this->uid);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,9 +12,9 @@
|
||||
<td class="layui-td-gray2">上级部门<font>*</font></td>
|
||||
<td>
|
||||
<select name="pid" lay-verify="required" lay-reqText="请选择上级部门">
|
||||
<option value="">作为顶级部门</option>
|
||||
<option value="0">作为顶级部门</option>
|
||||
{volist name="department" id="v"}
|
||||
<option value="{$v.id}">{$v.title}</option>
|
||||
<option value="{$v.id}" {eq name="$pid" value="$v.id"} selected{/eq}>{$v.title}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
@ -34,9 +34,9 @@
|
||||
<td class="layui-td-gray2">上级部门<font>*</font></td>
|
||||
<td>
|
||||
<select name="pid" lay-verify="required" lay-reqText="请选择上级部门">
|
||||
<option value="">作为顶级部门</option>
|
||||
<option value="0">作为顶级部门</option>
|
||||
{volist name="department" id="v"}
|
||||
<option value="{$v.id}" {eq name="detail.pid" value="$v.id"} selected{/eq}>{$v.title}</option>
|
||||
<option value="{$v.id}" {eq name="$detail.pid" value="$v.id"} selected{/eq}>{$v.title}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
@ -78,7 +78,7 @@
|
||||
//监听提交
|
||||
form.on('submit(webform)', function(data) {
|
||||
$.ajax({
|
||||
url: "{:url('home/department/post_submit')}",
|
||||
url: "{:url('home/department/add')}",
|
||||
type: 'post',
|
||||
data: data.field,
|
||||
success: function(e) {
|
||||
|
@ -5,22 +5,22 @@
|
||||
{if condition="$id eq 0"}
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray2">岗位名称<font>*</font></td>
|
||||
<td class="layui-td-gray">岗位名称<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入岗位名称" lay-reqText="请输入岗位名称" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray2">岗位工时单价<font>*</font></td>
|
||||
<td class="layui-td-gray3">岗位工时单价(元)<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="work_price" lay-verify="required|number" placeholder="请输入岗位工时单价" lay-reqText="请输入岗位工时单价" autocomplete="off" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray2">状态<font>*</font></td>
|
||||
<td class="layui-td-gray">状态<font>*</font></td>
|
||||
<td>
|
||||
<input type="radio" name="status" value="1" title="正常" checked>
|
||||
<input type="radio" name="status" value="0" title="禁用">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray2">权限角色<font>*</font></td>
|
||||
<td class="layui-td-gray">权限角色<font>*</font></td>
|
||||
<td colspan="5">
|
||||
{volist name="$group" id="v"}
|
||||
<input type="checkbox" name="group_id[]" title="{$v.title}" value="{$v.id}" lay-skin="primary">
|
||||
@ -28,7 +28,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray2">岗位备注</td>
|
||||
<td class="layui-td-gray">岗位备注</td>
|
||||
<td colspan="5">
|
||||
<textarea name="remark" placeholder="请输入岗位备注" class="layui-textarea"></textarea>
|
||||
</td>
|
||||
@ -37,22 +37,22 @@
|
||||
{else/}
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray2">岗位名称<font>*</font></td>
|
||||
<td class="layui-td-gray">岗位名称<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="title" value="{$detail.title}" lay-verify="required" autocomplete="off" placeholder="请输入岗位名称" lay-reqText="请输入岗位名称" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray2">岗位工时单价<font>*</font></td>
|
||||
<td class="layui-td-gray3">岗位工时单价(元)<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="work_price" value="{$detail.work_price}" lay-verify="required|number" placeholder="请输入岗位工时单价" lay-reqText="请输入岗位工时单价" autocomplete="off" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray2">状态<font>*</font></td>
|
||||
<td class="layui-td-gray">状态<font>*</font></td>
|
||||
<td>
|
||||
<input type="radio" name="status" value="1" title="正常" {eq name="$detail.status" value="1"}checked{/eq}>
|
||||
<input type="radio" name="status" value="0" title="禁止登录" {eq name="$detail.status" value="0"}checked{/eq}>
|
||||
<input type="radio" name="status" value="0" title="禁止" {eq name="$detail.status" value="0"}checked{/eq}>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray2">权限角色<font>*</font></td>
|
||||
<td class="layui-td-gray">权限角色<font>*</font></td>
|
||||
<td colspan="5">
|
||||
{volist name="$group" id="v"}
|
||||
<input type="checkbox" name="group_id[]" title="{$v.title}" value="{$v.id}" {eq name="$v.checked" value="1" }checked{/eq} lay-skin="primary">
|
||||
@ -60,7 +60,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray2">岗位备注</td>
|
||||
<td class="layui-td-gray">岗位备注</td>
|
||||
<td colspan="5">
|
||||
<textarea name="remark" placeholder="请输入岗位备注" class="layui-textarea">{$detail.remark}</textarea>
|
||||
</td>
|
||||
@ -88,7 +88,7 @@
|
||||
//监听提交
|
||||
form.on('submit(webform)', function (data) {
|
||||
$.ajax({
|
||||
url: "{:url('home/position/post_submit')}",
|
||||
url: "{:url('home/position/add')}",
|
||||
type: 'post',
|
||||
data: data.field,
|
||||
success: function (e) {
|
||||
|
@ -49,9 +49,9 @@
|
||||
title: '权限角色'
|
||||
},{
|
||||
field: 'work_price',
|
||||
title: '岗位工时单价',
|
||||
title: '岗位工时单价(元)',
|
||||
align: 'center',
|
||||
width: 160
|
||||
width: 150
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
@ -62,7 +62,7 @@
|
||||
field: 'right',
|
||||
title: '操作',
|
||||
toolbar: '#barDemo',
|
||||
width: 150,
|
||||
width: 136,
|
||||
align: 'center'
|
||||
}
|
||||
]
|
||||
|
@ -67,7 +67,7 @@ CREATE TABLE `oa_admin_group` (
|
||||
-- ----------------------------
|
||||
-- Records of cms_admin_group
|
||||
-- ----------------------------
|
||||
INSERT INTO `oa_admin_group` VALUES ('1', '超级员工', '1', '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113', '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43', '超级员工,系统自动分配所有可操作权限及菜单。', '0', '0');
|
||||
INSERT INTO `oa_admin_group` VALUES ('1', '超级员工权限', '1', '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113', '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43', '超级员工权限,拥有系统的最高权限,不可修改', '0', '0');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for oa_admin_log
|
||||
@ -448,6 +448,25 @@ CREATE TABLE `oa_department` (
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '部门组织';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of oa_department
|
||||
-- ----------------------------
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (1, '董事会', 0, 0, '13688888888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (2, '人事部', 1, 0, '13688888889', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (3, '财务部', 1, 0, '13688888898', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (4, '市场部', 1, 0, '13688888988', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (5, '销售部', 1, 0, '13688889888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (6, '技术部', 1, 0, '13688898888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (7, '客服部', 1, 0, '13688988888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (8, '销售一部', 5, 0, '13688998888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (9, '销售二部', 5, 0, '13688999888', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (10, '销售三部', 5, 0, '13688999988', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (11, '产品部', 6, 0, '13688888886', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (12, '设计部', 6, 0, '13688888866', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (13, '研发部', 6, 0, '13688888666', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (14, '客服一部', 7, 0, '13688888885', '', 1, 0, 0);
|
||||
INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (15, '客服二部', 7, 0, '13688888855', '', 1, 0, 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for oa_expense
|
||||
-- ----------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user