rabin 2 年 前
コミット
402203462f
10 ファイル変更506 行追加219 行削除
  1. 2 3
      database/category.php
  2. 52 14
      database/info.php
  3. 124 197
      database/info_sku.php
  4. 129 0
      database/info_spec.php
  5. 155 0
      database/info_spec_value.php
  6. 1 0
      database/unit.php
  7. 5 0
      lib/Manage.php
  8. 1 1
      src/Category.php
  9. 35 0
      src/Sku.php
  10. 2 4
      src/Unit.php

+ 2 - 3
database/category.php

@@ -82,7 +82,6 @@ return array
 			'match' 	=> 'is_numeric',
 			'match' 	=> 'is_numeric',
 		),
 		),
 
 
-		/*
 		'product-category_attr'=> array
 		'product-category_attr'=> array
 		(
 		(
 			'name' 		=> '属性设置',
 			'name' 		=> '属性设置',
@@ -93,7 +92,7 @@ return array
 			'sync'		=> array('id', 'category_id'),
 			'sync'		=> array('id', 'category_id'),
 			# 根据category字段的值,获取product/attr.search接口的内容
 			# 根据category字段的值,获取product/attr.search接口的内容
 			'update'	=> array(1),
 			'update'	=> array(1),
-		),*/
+		),
 
 
 		'level'		=> array
 		'level'		=> array
 		(
 		(
@@ -215,7 +214,7 @@ return array
 
 
 	'manage' => array
 	'manage' => array
 	(
 	(
-		//'lang' => 'name',
+		'lang' => 'name',
 		'tab' => array('基础设置', '前端样式'),
 		'tab' => array('基础设置', '前端样式'),
 		# 列表页的类型
 		# 列表页的类型
 		'list_type' => 'tree',
 		'list_type' => 'tree',

+ 52 - 14
database/info.php

@@ -31,6 +31,12 @@ $config = array
 		'audit' => $audit,
 		'audit' => $audit,
 	),
 	),
 
 
+	'start' => array
+    (
+        'insert' => 'product/lib/manage.check',
+        'update' => 'product/lib/manage.check',
+    ),
+
 	'end' => array
 	'end' => array
 	(
 	(
 		//'insert' => 'product/lib/manage.infoUpdate',
 		//'insert' => 'product/lib/manage.infoUpdate',
@@ -123,6 +129,28 @@ $config = array
 			'tab'		=> 1,
 			'tab'		=> 1,
 		),
 		),
 
 
+		'product-info_spec'=> array
+		(
+			'name' 		=> '规格设置',
+			'default' 	=> '',
+			'desc' 		=> '规格设置',
+			'match' 	=> 'option',
+			'sync'		=> array('id', 'info_id'),
+			'update'	=> 'sku',
+			'tab'		=> 2,
+		),
+
+		'spec_type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '规格类型',
+			'default' 	=> '1',
+			'desc' 		=> '规格类型',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> array(1 => '单规格', 2 => '多规格'),
+		), 
+
 		# 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
 		# 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧
 		'top_category_id'		=> array
 		'top_category_id'		=> array
 		(
 		(
@@ -163,20 +191,6 @@ $config = array
 			'place'		=> '500*500',
 			'place'		=> '500*500',
 		),
 		),
 
 
-		'audit'		=> array
-		(
-			'type' 		=> 'tinyint-1',
-			'name' 		=> '审核',
-			'default' 	=> '1',
-			'desc' 		=> '审核',
-			'match' 	=> 'is_numeric',
-			//'update'	=> 'select',
-			'option'	=> $audit,
-			//'search'	=> 'select',
-			//'list'		=> true,
-			'edit'		=> true,
-		),
-
 		'status'		=> array
 		'status'		=> array
 		(
 		(
 			'type' 		=> 'tinyint-1',
 			'type' 		=> 'tinyint-1',
@@ -261,6 +275,30 @@ $config = array
 	# 管理功能
 	# 管理功能
 	'manage' => array
 	'manage' => array
 	(
 	(
+		# 定义sku对应的表,不填写则默认为info_spec和info_sku
+		'sku' => array
+		(
+			# 定义表名
+			'spec' => 'info_spec', 
+			'sku' => 'info_sku',
+			# 定义字段
+			'col' => array
+			(
+				'pic' => array('name' => '图片', 'verify' => 'string', 'type' => 'image'),
+				'code' => array('name' => '商品编码', 'verify' => 'string', 'type' => 'input'),
+				'price' => array('name' => '销售价(元)', 'verify' => 'number', 'type' => 'input'),
+				'buy_price' => array('name' => '采购价(元)', 'verify' => 'number', 'type' => 'input'),
+				'cost_price' => array('name' => '成本价(元)', 'verify' => 'number', 'type' => 'input'),
+			),
+			# 接口
+			'api' => array
+			(
+				'spec' => 'product/sku.spec',
+				'sku' => 'product/sku.sku',
+				# 上传接口
+				'upload' => 'upload/save.start?key=1',
+			),
+		),
 		'tab' => array('基本设置', '属性设置', '规格设置'),
 		'tab' => array('基本设置', '属性设置', '规格设置'),
 		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
 		// 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css
 		'res' => array
 		'res' => array

+ 124 - 197
database/info_sku.php

@@ -1,138 +1,146 @@
 <?php
 <?php
 
 
-$col = 'id,info_id,`key`,price,s_price,code';
-
 $config = array
 $config = array
 (
 (
-	# 表名
-	'name' => 'info_sku',
-	# 显示给用户看的名称
-	'lang' => '商品规格设置',
-	'order' => 200,
-	'menu' => false,
-
-	# 数据结构 不同的字段放这里
-	'struct' => array
-	(
-		'id' 		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> 'ID',
-			'default' 	=> '',
-			'desc' 		=> '',
-			'match' 	=> 'is_numeric',
-			//'list'		=> true,
-		),
-
-		'info_id'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '商品ID',
-			'default' 	=> '',
-			'desc' 		=> '商品ID',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'text',
-			'list'		=> true,
-		),
+    # 表名
+    'name' => 'info_sku',
+    # 显示给用户看的名称
+    'lang' => '商品SKU设置',
+    'order' => 200,
+    'menu' => false,
+    //'check' => 'code',
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
 
 
-		'key'		=> array
-		(
-			'type' 		=> 'varchar-100',
-			'name' 		=> '规格标识',
-			'default' 	=> '-1',
-			'desc' 		=> '规格标识',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
+        'info_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品ID',
+            'default'   => '',
+            'desc'      => '商品ID',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
 
 
-		'attr'		=> array
-		(
-			'type' 		=> 'text-255',
-			'name' 		=> '规格组合规则',
-			'default' 	=> '',
-			'desc' 		=> '规格组合规则',
-			'match' 	=> 'is_string',
-			'update'	=> 'textarea',
-			'list'		=> true,
-		),
+        'key'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '规格id',
+            'default'   => '',
+            'desc'      => '规格id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
 
 
-		'code'      => array
+        'code'      => array
         (
         (
             'type'      => 'varchar-100',
             'type'      => 'varchar-100',
-            'name'      => '商品条码号',
+            'name'      => '商品编码',
             'default'   => '',
             'default'   => '',
-            'desc'      => '商品条码号',
+            'desc'      => '商品编码',
             'match'     => 'is_string',
             'match'     => 'is_string',
             'update'    => 'text',
             'update'    => 'text',
             'search'    => 'fulltext',
             'search'    => 'fulltext',
             'list'      => true,
             'list'      => true,
         ),
         ),
 
 
-		'price'		=> array
-		(
-			'type' 		=> 'decimal-10,2',
-			'name' 		=> '售价',
-			'default' 	=> '',
-			'desc' 		=> '售价',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'text',
-			'list'		=> true,
-		),
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '商品图',
+            'default'   => '',
+            'desc'      => '商品图',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
 
 
-		's_price'		=> array
-		(
-			'type' 		=> 'decimal-10,2',
-			'name' 		=> '原价',
-			'default' 	=> '',
-			'desc' 		=> '原价',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'text',
-			'list'		=> true,
-		),
+        'price'     => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售价',
+            'default'   => '',
+            'desc'      => '销售价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
 
 
-		'reorder'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '排序-数值越大越靠前,相当于置顶',
-			'default' 	=> '1',
-			'desc' 		=> '请输入排序',
-			'match' 	=> 'option',
-			//'update'	=> 'text',
-			'search'	=> 'order',
-			'list'		=> true,
-			'order'		=> 'desc',
-			'edit'		=> true,
-		),
+        'buy_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '门店采购价',
+            'default'   => '',
+            'desc'      => '采购价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
 
 
-		'state'		=> array
-		(
-			'type' 		=> 'tinyint-1',
-			'name' 		=> '数据状态',
-			'default' 	=> '1',
-			'desc' 		=> '请选择状态',
-			'match' 	=> 'is_numeric',
-		),
+        'cost_price'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '成本价',
+            'default'   => '',
+            'desc'      => '成本价',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
 
 
-		'cdate'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '发布时间',
-			'match' 	=> array('is_numeric', time()),
-			'desc' 		=> '',
-			# 只有insert时才生效
-			'insert'	=> true,
-			//'search'	=> 'date',
-			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
-		),
-	),
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
 
 
-	'manage' => array
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发布时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'  => 'date',
+            //'list'        => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id,`key`',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+    'manage' => array
     (
     (
         'insert' => false,
         'insert' => false,
         'edit' => false,
         'edit' => false,
         'delete' => false,
         'delete' => false,
         'num' => false,
         'num' => false,
-        'page_list_table' => 'sku',
+        //'page_list_table' => 'sku',
 
 
         # 自定义快捷新增和编辑
         # 自定义快捷新增和编辑
         'button' => array
         'button' => array
@@ -142,9 +150,9 @@ $config = array
     ),
     ),
 
 
     # request 请求接口定义
     # request 请求接口定义
-	'request' => array
-	(
-		# 后台搜索用到 也可以不加,自动生成
+    'request' => array
+    (
+        # 后台搜索用到 也可以不加,自动生成
         'search' => array
         'search' => array
         (
         (
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
@@ -156,27 +164,13 @@ $config = array
                 'state' => 1,
                 'state' => 1,
             ),
             ),
             'type' => 'all',
             'type' => 'all',
-            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'order' => array('id' => 'desc'),
             'limit' => '0,10',
             'limit' => '0,10',
             'col' => 'key as name, id, id as value, "" as selected, "" as disabled|id',
             'col' => 'key as name, id, id as value, "" as selected, "" as disabled|id',
         ),
         ),
 
 
         # 列表
         # 列表
-        'getData' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'info_id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'all',
-            'order' => array('id' => 'desc'),
-            'col' => $col,
-        ),
-
-        # 列表
-        'getDataByKeys' => array
+        'getAll' => array
         (
         (
             # 匹配的正则或函数 选填项
             # 匹配的正则或函数 选填项
             'option' => array
             'option' => array
@@ -186,76 +180,9 @@ $config = array
             ),
             ),
             'type' => 'all',
             'type' => 'all',
             'order' => array('id' => 'desc'),
             'order' => array('id' => 'desc'),
-            'col' => $col . '|key',
-        ),
-
-        # 获取单条数据
-        'getOne' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'info_id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'one',
-            'col' => $col,
-        ),
-
-        'getMinOne' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'info_id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'one',
-            'order' => array('price' => 'asc', 'id' => 'desc'),
-            'col' => $col,
+            'col' => '*|key',
         ),
         ),
-
-        'getMaxOne' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'info_id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'one',
-            'order' => array('price' => 'desc', 'id' => 'desc'),
-            'col' => $col,
-        ),
-
-        # 更新售出量
-        'updateSell' => array
-        (
-            'type' => 'update',
-            'where' => array
-            (
-                'id' => 'yes',
-            ),
-            'set' => array
-            (
-                'sell_num' => array('yes', '+='),
-            ),
-        ),
-
-        'like' => array
-        (
-            # 匹配的正则或函数 选填项
-            'option' => array
-            (
-                'code' => array('yes', 'like'),
-                'id' => 'yes',
-                'state' => 1,
-            ),
-            'type' => 'all',
-            'order' => array('reorder' => 'desc', 'id' => 'desc'),
-            'col' => '*|id',
-        ),
-	),
+    ),
 );
 );
 
 
 return $config;
 return $config;

+ 129 - 0
database/info_spec.php

@@ -0,0 +1,129 @@
+<?php
+
+$col = 'id,info_id,`key`,price,s_price,code';
+
+$config = array
+(
+	# 表名
+	'name' => 'info_spec',
+	# 显示给用户看的名称
+	'lang' => '商品规格设置',
+	'order' => 200,
+	'menu' => false,
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品ID',
+			'default' 	=> '',
+			'desc' 		=> '商品ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '规格名称',
+			'default' 	=> '',
+			'desc' 		=> '规格名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越小越靠前',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+	'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
+        ),
+    ),
+
+    # request 请求接口定义
+	'request' => array
+	(
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => 'id, name as title',
+		),
+	),
+);
+
+return $config;

+ 155 - 0
database/info_spec_value.php

@@ -0,0 +1,155 @@
+<?php
+
+$option = array
+(
+	1 => '选中',
+	2 => '未选中',
+);
+$config = array
+(
+	# 表名
+	'name' => 'info_spec_value',
+	# 显示给用户看的名称
+	'lang' => '商品规格值设置',
+	'order' => 200,
+	'menu' => false,
+
+	# 数据结构 不同的字段放这里
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'list'		=> true,
+		),
+
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '商品ID',
+			'default' 	=> '',
+			'desc' 		=> '商品ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'spec_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '规格ID',
+			'default' 	=> '',
+			'desc' 		=> '规格ID',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-500',
+			'name' 		=> '规格值',
+			'default' 	=> '',
+			'desc' 		=> '规格值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'is_checked'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否选中',
+			'default' 	=> '1',
+			'desc' 		=> '是否选中',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $option,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序-数值越小越靠前',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发布时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'index' => array
+    (
+        1 => array
+        (
+            # 索引名 => 索引id 如果有后缀.unique,则为建立索引的类型,如id,state.unique
+            'info' => 'info_id',
+        ),
+        
+        # 版本号 更改版本号会更新当前表的索引
+        'version' => 1,
+    ),
+
+	'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'自定义属性' => array('fast', 1, 'config&where_id=1'),
+        ),
+    ),
+
+    # request 请求接口定义
+	'request' => array
+	(
+		# 列表
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'spec_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'asc', 'id' => 'asc'),
+			'col' => 'id, value as title, case is_checked when 1 then true else false end as checked',
+		),
+	),
+);
+
+return $config;

+ 1 - 0
database/unit.php

@@ -21,6 +21,7 @@ return array
 			'desc' 		=> '',
 			'desc' 		=> '',
 			'match' 	=> 'is_numeric',
 			'match' 	=> 'is_numeric',
 			'list'		=> true,
 			'list'		=> true,
+			'order'		=> 'asc',
 		),
 		),
 
 
 		'name'		=> array
 		'name'		=> array

+ 5 - 0
lib/Manage.php

@@ -6,6 +6,11 @@ use Dever;
 
 
 class Manage
 class Manage
 {
 {
+    public function check($id,$name,$data)
+    {
+        //Dever::alert('reload');
+    }
+
     public function updateCategory($id, $name, $data)
     public function updateCategory($id, $name, $data)
     {
     {
         $info = Dever::param('category', $data);
         $info = Dever::param('category', $data);

+ 1 - 1
src/Category.php

@@ -73,7 +73,7 @@ class Category
             $data = Dever::db('product/category')->getAll($where);
             $data = Dever::db('product/category')->getAll($where);
         }
         }
 
 
-        if ($data || $level_num == 1) {
+        if ($data && $level_num == 1) {
             array_unshift($data, $default);
             array_unshift($data, $default);
         }
         }
 
 

+ 35 - 0
src/Sku.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Product\Src;
+
+use Dever;
+
+class Sku
+{
+    # 获取当前的规格
+    public function spec()
+    {
+    	$id = Dever::input('id');
+    	$result = array();
+    	if ($id) {
+    		$result = Dever::db('product/info_spec')->getAll(array('info_id' => $id));
+    		if ($result) {
+    			foreach ($result as $k => $v) {
+    				$result[$k]['child'] = Dever::db('product/info_spec_value')->getAll(array('info_id' => $id, 'spec_id' => $v['id']));
+    			}
+    		}
+    	}
+    	return $result;
+    }
+
+    # 获取当前的sku
+    public function sku()
+    {
+    	$id = Dever::input('id');
+    	$result = array();
+    	if ($id) {
+    		$result = Dever::db('product/info_sku')->getAll(array('info_id' => $id));
+    	}
+    	return $result;
+    }
+}

+ 2 - 4
src/Unit.php

@@ -13,12 +13,10 @@ class Unit
     	if (!$where['name']) {
     	if (!$where['name']) {
     		Dever::alert('请输入单位名称');
     		Dever::alert('请输入单位名称');
     	}
     	}
-    	return Dever::db('product/unit')->insert($where);
-    	return 'ok';
         $info = Dever::db('product/unit')->find($where);
         $info = Dever::db('product/unit')->find($where);
         if (!$info) {
         if (!$info) {
-        	Dever::db('product/unit')->insert($where);
+        	$info['id'] = Dever::db('product/unit')->insert($where);
         }
         }
-        return 'ok';
+        return $info;
     }
     }
 }
 }