ApproveFlow.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\approve\controller;
  15. use app\common\constant\CommonConstant;
  16. use app\common\service\CommonService;
  17. use app\common\service\UserService;
  18. use library\Controller;
  19. /**
  20. * 审批流程设置
  21. */
  22. class ApproveFlow extends Controller
  23. {
  24. /**
  25. * 绑定数据表
  26. * @var string
  27. */
  28. protected $table = 'ApproveFlow';
  29. /**
  30. * 控制器初始化
  31. */
  32. protected function initialize()
  33. {
  34. $this->get_module_list = CommonConstant::get_module_list();
  35. $this->get_type_list = CommonConstant::get_type_list();
  36. $this->get_user_type_list = CommonConstant::get_user_type_list();
  37. $this->get_user_type_list_json = json_encode($this->get_user_type_list,JSON_UNESCAPED_UNICODE);
  38. }
  39. /**
  40. * 列表
  41. * @auth true
  42. * @menu true
  43. * @throws \think\Exception
  44. * @throws \think\db\exception\DataNotFoundException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. * @throws \think\exception\DbException
  47. */
  48. public function index()
  49. {
  50. $module = input('module');
  51. $this->get_item_list = CommonService::get_item_list($module);
  52. $this->title = $this->get_module_list[$module].'审批流程';
  53. $query = $this->_query($this->table)
  54. ->field('user_data',true)
  55. ->where('module',$module);
  56. $query->page(false);
  57. }
  58. /**
  59. * 列表数据处理
  60. * @param array $data
  61. * @throws \Exception
  62. */
  63. protected function _index_page_filter(&$data)
  64. {
  65. foreach ($data as &$value) {
  66. }
  67. }
  68. /**
  69. * 编辑
  70. * @auth true
  71. */
  72. public function edit()
  73. {
  74. $this->title = '编辑';
  75. $this->_form($this->table, 'form');
  76. }
  77. /**
  78. * 表单处理
  79. * @param array $data
  80. * @throws \think\db\exception\DataNotFoundException
  81. * @throws \think\db\exception\ModelNotFoundException
  82. * @throws \think\exception\DbException
  83. */
  84. protected function _form_filter(&$data)
  85. {
  86. if ($this->request->isGet()) {
  87. if ($data) {
  88. // 编辑获取数据时
  89. $data['user_data_text'] = json_decode($data['user_data'], true);
  90. $this->get_item_list = CommonService::get_item_list($data['module']);
  91. $this->user_list = UserService::get_list(1);
  92. $this->user_list_json = json_encode($this->user_list, JSON_UNESCAPED_UNICODE);
  93. }
  94. }
  95. if ($this->request->isPost()) {
  96. if ($data) {
  97. // 编辑提交数据时
  98. if (!isset_full($data, 'user_data')) {
  99. $this->error('请添加审批层级');
  100. }
  101. $user_data = array_filter($data['user_data']);
  102. if (!$user_data) {
  103. $this->error('请添加审批层级!');
  104. }
  105. $save_data = [];
  106. foreach ($user_data as $key => $val) {
  107. $save_data[] = [
  108. 'user_type' => $val['user_type'],
  109. 'userid' => $val['user_type'] == CommonConstant::USER_TYPE_1 ? '' : $val['userid'],
  110. ];
  111. }
  112. $data['user_data'] = json_encode($save_data, JSON_UNESCAPED_UNICODE);
  113. }
  114. }
  115. }
  116. /**
  117. * 列表
  118. */
  119. public function flow()
  120. {
  121. $this->title = '审批流';
  122. $list = $this->get_module_list;
  123. return $this->fetch('', compact("list"));
  124. }
  125. }