dever 5 years ago
parent
commit
c67b583930
3 changed files with 236 additions and 69 deletions
  1. 110 68
      database/info.php
  2. 120 0
      database/value.php
  3. 6 1
      src/Api.php

+ 110 - 68
database/info.php

@@ -28,12 +28,18 @@ $type = array
 	12 => '单项选择框',
 );
 
-$option = array
+$is_must = array
 (
 	1 => '必填项',
 	2 => '选填项',
 );
 
+$is_sell = array
+(
+	1 => '普通属性',
+	2 => '销售属性',
+);
+
 $data_type = array
 (
 	1 => '数字',
@@ -97,6 +103,13 @@ return array
 			'list'		=> true,
 		),
 
+		'hr1'		=> array
+		(
+			'name' 		=> '基本配置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
 		'name'		=> array
 		(
 			'type' 		=> 'varchar-150',
@@ -110,60 +123,6 @@ return array
 			'edit'		=> true,
 		),
 
-		'unit'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '单位-填写属性单位,选填项',
-			'default' 	=> '',
-			'desc' 		=> '单位',
-			'match' 	=> 'option',
-			'update'	=> 'text',
-		),
-
-		'ename'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '英文标识-该标识一般为前端样式名称,选填项',
-			'default' 	=> '',
-			'desc' 		=> '英文名称',
-			'match' 	=> 'option',
-			'update'	=> 'text',
-			//'search'	=> 'fulltext',
-			//'list'		=> true,
-			//'edit'		=> true,
-		),
-
-		'icon'		=> array
-		(
-			'type' 		=> 'varchar-150',
-			'name' 		=> '图标',
-			'default' 	=> '',
-			'desc' 		=> '图标',
-			'match' 	=> 'option',
-			'update'	=> 'image',
-			'key'		=> 1,
-		),
-
-		'color'		=> array
-		(
-			'type' 		=> 'varchar-10',
-			'name' 		=> '字体颜色-请填写颜色代码',
-			'default' 	=> '',
-			'desc' 		=> '字体颜色',
-			'match' 	=> 'option',
-			'update'	=> 'color',
-		),
-
-		'bgcolor'		=> array
-		(
-			'type' 		=> 'varchar-10',
-			'name' 		=> '背景颜色-请填写颜色代码',
-			'default' 	=> '',
-			'desc' 		=> '背景颜色',
-			'match' 	=> 'option',
-			'update'	=> 'color',
-		),
-
 		'cate_id'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -176,6 +135,32 @@ return array
 			'list'		=> '{cate_id} > 0 ? Dever::load("attr/cate-one#name", {cate_id}) : "未选择"',
 		),
 
+		'is_must'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否必填',
+			'default' 	=> '1',
+			'desc' 		=> '是否必填',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $is_must,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'is_sell'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否销售属性',
+			'default' 	=> '1',
+			'desc' 		=> '是否销售属性',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $is_sell,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
 		'type'	  => array
 		(
 			'type' 		=> 'tinyint-11',
@@ -190,6 +175,7 @@ return array
 			'control'	=> 'type',
 		),
 
+		/*
 		'type_option'      => array
         (
             'type'      => 'varchar-800',
@@ -201,19 +187,7 @@ return array
             //'list'      => true,
             'show'      => 'type=1,9,10,11,12',
         ),
-
-        'option_type'	  => array
-		(
-			'type' 		=> 'tinyint-1',
-			'name' 		=> '是否必填',
-			'default' 	=> '1',
-			'desc' 		=> '是否必填',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'radio',
-			'option'	=> $option,
-			'search'	=> 'select',
-			'list'		=> true,
-		),
+        */
 
         'data_type'	  => array
 		(
@@ -244,6 +218,13 @@ return array
 			'show'		=> array('data_type' => 3),
 		),
 
+		'hr2'		=> array
+		(
+			'name' 		=> '排序规则',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
 		'list_reorder'	  => array
 		(
 			'type' 		=> 'int-11',
@@ -288,6 +269,67 @@ return array
 			'edit'		=> true,
 			'list'		=> true,
 		),
+
+		'hr3'		=> array
+		(
+			'name' 		=> '扩展设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'unit'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '单位-填写属性单位,选填项',
+			'default' 	=> '',
+			'desc' 		=> '单位',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+		),
+
+		'ename'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '英文标识-该标识一般为前端样式名称,选填项',
+			'default' 	=> '',
+			'desc' 		=> '英文名称',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'icon'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '图标',
+			'default' 	=> '',
+			'desc' 		=> '图标',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key'		=> 1,
+		),
+
+		'color'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '字体颜色-请填写颜色代码',
+			'default' 	=> '',
+			'desc' 		=> '字体颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+		),
+
+		'bgcolor'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '背景颜色-请填写颜色代码',
+			'default' 	=> '',
+			'desc' 		=> '背景颜色',
+			'match' 	=> 'option',
+			'update'	=> 'color',
+		),
 		
 		'state'		=> array
 		(

+ 120 - 0
database/value.php

@@ -0,0 +1,120 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'value',
+    # 显示给用户看的名称
+    'lang' => '属性值设置',
+    # 是否显示在后台菜单
+    'order' => 9,
+    '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'   => '1',
+            'desc'      => '属性id',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id'),
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性值名称',
+            'default'   => '',
+            'desc'      => '属性值名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'value'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '属性值',
+            'default'   => '',
+            'desc'      => '属性值',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            '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})',
+        ),
+    ),
+
+    'manage' => array
+    (
+
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    )
+);

+ 6 - 1
src/Api.php

@@ -401,7 +401,11 @@ class Api
 				if ($v['type'] == 7 && $city > 0) {
 					# 获取地区,获取最后一个级别的地区
 					$data[$k]['option'] = Dever::db('area/county')->state(array('city_id' => $city));
-				} elseif ($v['type_option']) {
+				} else {
+					$data[$k]['option'] = Dever::db('attr/value')->getData(array('info_id' => $v['id']));
+				}
+				/*
+				elseif ($v['type_option']) {
 					$temp = explode("\n", $v['type_option']);
 					foreach ($temp as $k1 => $v1) {
 						$v1 = explode(',', $v1);
@@ -416,6 +420,7 @@ class Api
 						}
 					}
 				}
+				*/
 
 				if (isset($search_value[$data[$k]['key']])) {
 					$data[$k]['option_value'] = $search_value[$data[$k]['key']];