123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\approve\controller;
- use app\common\constant\CommonConstant;
- use app\common\constant\EvectionConstant;
- use app\common\constant\LeaveConstant;
- use app\common\constant\MaintainConstant;
- use app\common\service\UserService;
- use library\Controller;
- /**
- * 审批流程设置
- */
- class ApproveFlow extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'ApproveFlow';
- /**
- * 控制器初始化
- */
- protected function initialize()
- {
- $this->get_module_list = CommonConstant::get_module_list();
- $this->get_type_list = CommonConstant::get_type_list();
- $this->get_user_type_list = CommonConstant::get_user_type_list();
- $this->get_user_type_list_json = json_encode($this->get_user_type_list,JSON_UNESCAPED_UNICODE);
- }
- /**
- * 列表
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function index()
- {
- $module = input('module');
- $this->get_item_list = self::get_item_list($module);
- $this->title = $this->get_module_list[$module].'审批流程';
- $query = $this->_query($this->table)
- ->where('module',$module);
- $query->page(false);
- }
- /**
- * 列表数据处理
- * @param array $data
- * @throws \Exception
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as &$value) {
- }
- }
- /**
- * 编辑
- * @auth true
- */
- public function edit()
- {
- $this->title = '编辑';
- $this->_form($this->table, 'form');
- }
- /**
- * 表单处理
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _form_filter(&$data)
- {
- if($this->request->isGet()) {
- if($data){
- $data['user_data_text'] = json_decode($data['user_data'],true);
- $this->get_item_list = self::get_item_list($data['module']);
- $this->user_list = UserService::get_list(1);
- $this->user_list_json = json_encode($this->user_list,JSON_UNESCAPED_UNICODE);
- }
- }
- if($this->request->isPost()) {
- if(!isset_full($data,'user_data')){
- $this->error('请添加审批层级');
- }
- $user_data = array_filter($data['user_data']);
- if(!$user_data){
- $this->error('请添加审批层级!');
- }
- $save_data = [];
- foreach ($user_data as $key=>$val){
- $save_data[] = [
- 'user_type'=>$val['user_type'],
- 'userid'=>$val['user_type'] == CommonConstant::USER_TYPE_1 ? '' : $val['userid'],
- ];
- }
- $data['user_data'] = json_encode($save_data,JSON_UNESCAPED_UNICODE);
- }
- }
- /**
- * 列表
- */
- public function flow()
- {
- $this->title = '审批流';
- $list = $this->get_module_list;
- return $this->fetch('', compact("list"));
- }
- /**
- * 根据模块获取审批流项
- **/
- public function get_item_list($module){
- $get_item_list = [];
- switch ($module){
- case CommonConstant::MODULE_5:
- $get_item_list = EvectionConstant::get_type_list();
- break;
- case CommonConstant::MODULE_6:
- $get_item_list = LeaveConstant::get_time_list();
- break;
- case CommonConstant::MODULE_8:
- $get_item_list = MaintainConstant::get_type_list();
- break;
- }
- return $get_item_list;
- }
- }
|