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 = CommonService::get_item_list($module); $this->title = $this->get_module_list[$module].'审批流程'; $query = $this->_query($this->table) ->field('user_data',true) ->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 = CommonService::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 ($data) { // 编辑提交数据时 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")); } }