Dataauth.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. declare (strict_types = 1);
  14. namespace app\home\controller;
  15. use app\base\BaseController;
  16. use think\exception\ValidateException;
  17. use think\facade\Db;
  18. use think\facade\View;
  19. class dataauth extends BaseController
  20. {
  21. public function index()
  22. {
  23. if (request()->isAjax()) {
  24. $list = Db::name('DataAuth')->select();
  25. return to_assign(0, '', $list);
  26. } else {
  27. return view();
  28. }
  29. }
  30. //编辑配置信息
  31. public function edit()
  32. {
  33. $param = get_params();
  34. if (request()->isAjax()) {
  35. $param['update_time'] = time();
  36. $res = Db::name('DataAuth')->strict(false)->field(true)->update($param);
  37. if ($res) {
  38. add_log('edit', $param['id'], $param);
  39. }
  40. return to_assign();
  41. } else {
  42. $id = isset($param['id']) ? $param['id'] : 0;
  43. $detail = $this->auth_detail($id);
  44. $module = strtolower(app('http')->getName());
  45. $class = strtolower(app('request')->controller());
  46. $action = strtolower(app('request')->action());
  47. $template = $module . '/view/' . $class . '/' . $detail['name'] . '.html';
  48. View::assign('detail', $detail);
  49. if (isTemplate($template)) {
  50. return view($detail['name']);
  51. } else {
  52. return view('../../base/view/common/errortemplate', ['file' => $template]);
  53. }
  54. }
  55. }
  56. public function auth_detail($id)
  57. {
  58. $detail = Db::name('DataAuth')->where('id',$id)->find();
  59. // 日常办公
  60. if($detail['name'] =='office_admin'){
  61. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  62. $detail['conf_1_str'] = implode(',', $conf_1_str);
  63. $conf_3_str = Db::name('Admin')->where('id', 'in', $detail['conf_3'])->column('name');
  64. $detail['conf_3_str'] = implode(',', $conf_3_str);
  65. }
  66. if($detail['name'] =='finance_admin'){
  67. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  68. $detail['conf_1_str'] = implode(',', $conf_1_str);
  69. $conf_2_str = Db::name('Admin')->where('id', 'in', $detail['conf_2'])->column('name');
  70. $detail['conf_2_str'] = implode(',', $conf_2_str);
  71. $conf_3_str = Db::name('Admin')->where('id', 'in', $detail['conf_3'])->column('name');
  72. $detail['conf_3_str'] = implode(',', $conf_3_str);
  73. $conf_4_str = Db::name('Admin')->where('id', 'in', $detail['conf_4'])->column('name');
  74. $detail['conf_4_str'] = implode(',', $conf_4_str);
  75. $conf_5_str = Db::name('Admin')->where('id', 'in', $detail['conf_5'])->column('name');
  76. $detail['conf_5_str'] = implode(',', $conf_5_str);
  77. }
  78. if($detail['name'] =='customer_admin'){
  79. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  80. $detail['conf_1_str'] = implode(',', $conf_1_str);
  81. }
  82. if($detail['name'] =='contract_admin'){
  83. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  84. $detail['conf_1_str'] = implode(',', $conf_1_str);
  85. }
  86. if($detail['name'] =='project_admin'){
  87. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  88. $detail['conf_1_str'] = implode(',', $conf_1_str);
  89. }
  90. if($detail['name'] =='disk_admin'){
  91. $conf_1_str = Db::name('Admin')->where('id', 'in', $detail['conf_1'])->column('name');
  92. $detail['conf_1_str'] = implode(',', $conf_1_str);
  93. }
  94. return $detail;
  95. }
  96. }