示例#1
0
 public function actionSave()
 {
     $fields = isset($_GET['fields']) ? $_GET['fields'] : '';
     $project_id = isset($_GET['project_id']) ? $_GET['project_id'] : '';
     $view_id = isset($_GET['view_id']) ? $_GET['view_id'] : '';
     if (empty($project_id) || empty($view_id)) {
         echo json_encode(array('code' => 0, 'data' => 'failure'));
         exit;
     }
     // 		$fields_arr = explode(',', $fields);
     // 		$item_arr = array();
     // 		foreach ($fields_arr as $fk=>$fv) {
     // 			$item = explode('/', $fv);
     // 			$item_arr[$item[1]][] = $item[0];
     // 		}
     $field_arr['project_id'] = $project_id;
     $field_arr['model_view_id'] = $view_id;
     $field_arr['config_field'] = !empty($fields) ? $fields : '';
     $project_config = new \app\model\Project_config();
     $re = $project_config->save_config($field_arr);
     if ($re) {
         echo json_encode(array('code' => 1, 'data' => 'success'));
     } else {
         echo json_encode(array('code' => 0, 'data' => 'failure'));
     }
 }
示例#2
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);
 }