Beispiel #1
0
 public function get_full_data($id)
 {
     if (!$this->check_params()) {
         $this->error = __('common.System Error');
         return false;
     }
     $meta = D($this->main_model, 'Model')->where(['id' => $id])->find();
     if (!$meta) {
         // @todo error_message
         return false;
     }
     if ($this->is_locked($meta['status'])) {
         $meta['locked'] = true;
     }
     $meta = Schema::data_format($meta, $this->main_table, true);
     $detail_model = D($this->detail_model, 'Model');
     $rows = $detail_model->where([$this->detail_main_foreign => $id])->select();
     // 本次出入库数量
     if ($this->include_this_time_quantity && $this->balance_direction) {
         foreach ($rows as $k => $v) {
             $this_time_quantity_field = sprintf('this_time_%s_quantity', $this->balance_direction);
             $rows[$k][$this_time_quantity_field] = round($v['quantity'] - $v['already_' . $this->balance_direction], DBC('decimal_scale'));
         }
     }
     $rows = Schema::data_format($rows, $this->detail_table, true);
     // 工作流进程
     $progress_service = D('Bpm/WorkflowProgress');
     $meta['workflow_progress'] = $progress_service->get_progress($meta['workflow_id'], $meta['id']);
     // 产品属性
     if (AppService::is_app_active('productAttribute')) {
         $rows = D('ProductAttribute/ProductAttribute')->assign_to_by_product_unique($rows, $this->detail_model_alias);
     }
     return ['meta' => $meta, 'rows' => $rows];
 }
 protected function response($data, $model = null, $is_table = false)
 {
     /*
      * 格式化数据
      * **/
     if ($model) {
         $data = Schema::data_format($data, $model, $is_table);
     }
     return parent::response($data, 'json');
 }
Beispiel #3
0
 public function get_workflow($workflow_id = null, $module = null)
 {
     if (!$module && !$workflow_id) {
         return false;
     }
     $map = [];
     if ($module) {
         $map['module'] = $module;
     }
     if ($workflow_id) {
         $map['id'] = $workflow_id;
     } else {
         $map['is_default'] = 1;
     }
     $workflow = $this->where($map)->find();
     if (!$workflow && $module) {
         $workflow = $this->where(['module' => $module])->find();
     }
     if (!$workflow) {
         $this->error = __('bpm.Can not find workflow');
         return false;
     }
     $workflow = Schema::data_format($workflow, 'workflow', true);
     $nodes = $this->get_nodes($workflow['id']);
     foreach ($nodes as $k => $node) {
         if ($node['node_type'] === 'start') {
             $workflow['start_node'] = $node;
         }
         //            $serialized_config = unserialize($node['widget_config']);
         //            $serialized_config = $serialized_config ? $serialized_config : [];
         //            $nodes[$k] = array_merge($node, $serialized_config);
     }
     $nodes = Schema::data_format($nodes, 'workflow_node', true);
     $workflow['nodes'] = $nodes;
     return $workflow;
 }
 public function get_full_data($id)
 {
     if (!$this->check_params()) {
         $this->error = __('common.System Error');
         return false;
     }
     $meta = D($this->main_model, 'Model')->where(['id' => $id])->find();
     if (!$meta) {
         // @todo error_message
         return false;
     }
     if ($this->is_locked($meta['status'])) {
         $meta['locked'] = true;
     }
     $meta = Schema::data_format($meta, $this->main_table, true);
     $detail_model = D($this->detail_model, 'Model');
     $rows = $detail_model->where([$this->detail_main_foreign => $id])->select();
     $rows = Schema::data_format($rows, $this->detail_table, true);
     // 工作流进程
     $progress_service = D('Bpm/WorkflowProgress');
     $meta['workflow_progress'] = $progress_service->get_progress($meta['workflow_id'], $meta['id']);
     // 产品属性
     if (AppService::is_app_active('productAttribute')) {
         $rows = D('ProductAttribute/ProductAttribute')->assign_to($rows, $this->detail_model_alias);
     }
     return ['meta' => $meta, 'rows' => $rows];
 }