rabin há 6 anos atrás
pai
commit
306016f8e5
4 ficheiros alterados com 187 adições e 19 exclusões
  1. 4 4
      database/cate.php
  2. 130 12
      database/info.php
  3. 1 1
      index.php
  4. 52 2
      src/Api.php

+ 4 - 4
database/cate.php

@@ -5,7 +5,7 @@ return array
 	# 表名
 	'name' => 'cate',
 	# 显示给用户看的名称
-	'lang' => '类管理',
+	'lang' => '类管理',
 	# 是否显示在后台菜单
 	'order' => 9,
 
@@ -26,9 +26,9 @@ return array
 		'name'		=> array
 		(
 			'type' 		=> 'varchar-150',
-			'name' 		=> '类名称',
+			'name' 		=> '类名称',
 			'default' 	=> '',
-			'desc' 		=> '类名称',
+			'desc' 		=> '类名称',
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
@@ -84,7 +84,7 @@ return array
 		'col' => 'name,state,cdate',
 		'value' => array
 		(
-			'"默认类",1,' . time(),
+			'"默认类",1,' . time(),
 		),
 	),
 

+ 130 - 12
database/info.php

@@ -11,6 +11,41 @@ $cate = function()
 	return $array;
 };
 
+$type = array
+(
+	1 => '单行输入框',
+	2 => '多行输入框',
+	3 => '图文编辑器',
+	4 => '单图片上传',
+	5 => '多图片上传',
+	6 => '地区选择器',
+	//7 => '多级分类',
+
+	10 => '单选框',
+	11 => '多选框',
+	12 => '单项选择框',
+);
+
+$option = array
+(
+	1 => '必填项',
+	2 => '选填项',
+);
+
+$data_type = array
+(
+	1 => '数字',
+	2 => '字符',
+	3 => '正则匹配',
+);
+
+$search = array
+(
+	1 => '可以作为搜索条件',
+	2 => '不作为搜索条件',
+);
+
+
 /*
 使用该组件,这么用
 $attr = function()
@@ -48,7 +83,7 @@ return array
 	# 表名
 	'name' => 'info',
 	# 显示给用户看的名称
-	'lang' => '属性列表',
+	'lang' => '属性设置',
 	# 是否显示在后台菜单
 	'order' => 10,
 
@@ -69,9 +104,9 @@ return array
 		'name'		=> array
 		(
 			'type' 		=> 'varchar-150',
-			'name' 		=> '属性名称',
+			'name' 		=> '中文名称',
 			'default' 	=> '',
-			'desc' 		=> '属性名称',
+			'desc' 		=> '中文名称',
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
@@ -79,30 +114,113 @@ return array
 			'edit'		=> true,
 		),
 
-		'icon'		=> array
+		'ename'		=> array
 		(
 			'type' 		=> 'varchar-150',
-			'name' 		=> '图标',
+			'name' 		=> '英文名称',
 			'default' 	=> '',
-			'desc' 		=> '请选择图标',
-			'match' 	=> 'option',
-			'update'	=> 'image',
-			'key' 		=> '1',
-			'place'		=> '150',
+			'desc' 		=> '英文名称',
+			'match' 	=> 'is_string',
+			//'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
 		),
 
 		'cate_id'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '选择分类',
+			'name' 		=> '属性类别',
 			'default' 	=> '1',
-			'desc' 		=> '选择分类',
+			'desc' 		=> '属性类别',
 			'match' 	=> 'is_numeric',
 			'update'	=> 'select',
 			'option'	=> $cate,
 			'list'		=> '{cate_id} > 0 ? Dever::load("attr/cate-one#name", {cate_id}) : "未选择"',
 		),
 
+		'type'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '属性类型',
+			'default' 	=> '1',
+			'desc' 		=> '属性类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+			'control'	=> 'type',
+		),
+
+		'type_option'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '属性可选项-多个值用换行隔开',
+            'default'   => '',
+            'desc'      => '属性可选项',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            //'list'      => true,
+            'show'      => 'type=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
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '数据类型-选择类型之后会自动验证数据有效性',
+			'default' 	=> '1',
+			'desc' 		=> '数据类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $data_type,
+			'search'	=> 'select',
+			//'list'		=> true,
+			'control' 	=> 'data_type',
+			'show'      => 'type=1',
+		),
+
+		'match'		=> array
+		(
+			'type' 		=> 'varchar-600',
+			'name' 		=> '正则匹配规则-直接输入正则表达式即可',
+			'default' 	=> '',
+			'desc' 		=> '正则匹配规则',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+			//'edit'		=> true,
+			'show'		=> array('data_type' => 3),
+		),
+
+		'search'	  => array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否作为搜索条件-如果选择作为搜索条件,将把该属性放入搜索引擎中,这里不宜选择过多,否则影响搜索速度。',
+			'default' 	=> '2',
+			'desc' 		=> '是否作为搜索条件',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $search,
+			'search'	=> 'select',
+			'show'      => 'type=1,6,10,11,12',
+			//'list'		=> true,
+		),
+
 		'reorder'		=> array
 		(
 			'type' 		=> 'int-11',

+ 1 - 1
index.php

@@ -4,5 +4,5 @@ define('DEVER_APP_NAME', 'attr');
 define('DEVER_APP_LANG', '属性管理');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DEVER_MANAGE_ORDER', 10);
-define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-hdd');
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-hdd layui-icon-table');
 include(DEVER_APP_PATH . '../boot.php');

+ 52 - 2
src/Api.php

@@ -27,7 +27,7 @@ class Api
 	}
 
 	/**
-	 * 获取属性详细信息
+	 * 获取属性详细信息,有类别
 	 *
 	 * @return mixed
 	 */
@@ -64,8 +64,58 @@ class Api
 				}
 			}
 		}
-		
 
 		return $result;
 	}
+
+	/**
+     * 获取属性的值,无类别
+     *
+     * @return mixed
+     */
+    public function getValue($ids, $value)
+    {
+        $result = array();
+		if ($ids) {
+			$where['ids'] = $ids;
+			$data = Dever::db('attr/info')->getAllByIds($where);
+
+			$ids = explode(',', $ids);
+			$value = explode(',', $value);
+			if ($data) {
+				foreach ($ids as $k => $v) {
+					if (isset($data[$v])) {
+						$result[$v] = $data[$v];
+						if (isset($value) && $value[$k]) {
+							$result[$v]['value'] = $value[$k];
+						} else {
+							$result[$v]['value'] = '';
+						}
+					}
+				}
+			}
+		}
+
+		return $result;
+    }
+
+    /**
+     * 获取属性的值,无类别
+     *
+     * @return mixed
+     */
+    public function string($ids, $value)
+    {
+        $result = $this->getInfo($ids, $value);
+
+        $table = array();
+        foreach ($result as $k => $v) {
+        	$table[$v['name']] = '';
+        	foreach ($v['attr'] as $k1 => $v1) {
+        		$table[$v['name']] .= $v1['name'] . "  ";
+        	}
+        }
+
+		return Dever::table($table);
+    }
 }