示例#1
0
 public function actionField()
 {
     $pro = isset($_GET['p']) ? $_GET['p'] : '';
     $view_id = isset($_GET['view_id']) ? $_GET['view_id'] : '';
     // 查询模块视图的配置字段
     $model_view = new \app\model\Model_view();
     if (($view = $model_view->get_model_view($view_id)) == false) {
         echo '模块视图不存在';
         exit;
     }
     // 查询项目的配置信息
     $project_obj = new \app\model\Project();
     if (($project_info = $project_obj->get_project('project_name', $pro)) == false) {
         echo '项目不存在';
         exit;
     }
     // 查询项目的配置信息
     $config_field = array();
     $pro_config_obj = new \app\model\Project_config();
     $config_info = $pro_config_obj->get_field_config($project_info['id'], $view['id']);
     if ($config_info && !empty($config_info['config_field'])) {
         $config_field = explode(',', $config_info['config_field']);
     }
     // 查询所有字段信息
     $field_obj = new \app\model\Field();
     $field_info = $field_obj->get_info_fieldid($view['field']);
     foreach ($field_info as $vk => $vv) {
         $extra = '';
         $field_info[$vk]['group'] = $vv['field_group'];
         if (!empty($vv['extra']) && ($extra_arr = unserialize($vv['extra'])) != false) {
             foreach ($extra_arr as $ek => $ev) {
                 $extra .= $ek . ':' . $ev . ';';
             }
         }
         $field_info[$vk]['extra_info'] = $extra;
         if (in_array($vv['id'], $config_field)) {
             $field_info[$vk]['checked'] = true;
         } else {
             $field_info[$vk]['checked'] = false;
         }
     }
     $data = array("total" => count($field_info), "rows" => $field_info, 'project_info' => $project_info);
     echo json_encode($data);
 }
示例#2
0
 public function actionIndex()
 {
     if (isset($_POST["project_name"])) {
         $project_name = !empty($_POST['project_name']) ? $_POST['project_name'] : '';
         if (empty($project_name)) {
             echo '项目名为空';
             exit;
         }
         $project = new \app\model\Project();
         $project_info['project_name'] = $project_name;
         $re = $project->save_project($project_info);
         if (!$re) {
             echo '添加失败';
         } else {
             echo '添加成功';
         }
     } else {
         return $this->render('index');
     }
 }