| 
					
				 | 
			
			
				@@ -3,11 +3,11 @@ use Dever; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class Spec
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     # 获取规格数据
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function manage($app_func_id)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function manage($table, $field, $id)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $result = array();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if ($app_func_id) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $result = Dever::db('spec', 'api')->select(array('app_func_id' => $app_func_id));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($id) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $result = Dever::db($table)->select(array($field => $id));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if ($result) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 foreach ($result as $k => $v) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $result[$k]['type'] = 'show';
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,7 +15,7 @@ class Spec 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $result[$k]['show'] = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $result[$k]['fixed'] = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     $result[$k]['key'] = $v['name'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    $value = Dever::db('spec_value', 'api')->select(array('app_func_id' => $app_func_id, 'spec_id' => $v['id']));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $value = Dever::db($table . '_value')->select(array($field => $id, 'spec_id' => $v['id']));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if ($value) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         foreach ($value as $k1 => $v1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             $value[$k1]['parent'] = $result[$k]['key'];
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -34,4 +34,19 @@ class Spec 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return $result;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 获取列表
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function getList($where, $app)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['state'] = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $data = Dever::db('spec', $app)->select($where, array('col' => 'id,name'));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($data) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            foreach ($data as &$v) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $w = $where;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $w['spec_id'] = $v['id'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $v['value'] = Dever::db('spec_value', $app)->select($w, array('col' => 'id,value'));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return $data;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |