dever 5 anos atrás
pai
commit
d869fcc070
4 arquivos alterados com 174 adições e 12 exclusões
  1. 7 3
      database/info.php
  2. 120 0
      database/search.php
  3. 14 3
      database/value.php
  4. 33 6
      src/Api.php

+ 7 - 3
database/info.php

@@ -132,7 +132,7 @@ return array
 			'match' 	=> 'is_numeric',
 			'update'	=> 'select',
 			'option'	=> $cate,
-			'list'		=> '{cate_id} > 0 ? Dever::load("attr/cate-one#name", {cate_id}) : "未选择"',
+			//'list'		=> '{cate_id} > 0 ? Dever::load("attr/cate-one#name", {cate_id}) : "未选择"',
 		),
 
 		'is_must'	  => array
@@ -355,8 +355,12 @@ return array
 
 	'manage' => array
 	(
-		# 列表页的类型
-		
+		# 列表
+		'list_button' => array
+		(
+			'list1' => array('属性值设置', '"value&project=attr&search_type=4&search_option_info_id={id}&oper_table=info&oper_project=attr"' , '{type} > 9'),
+			'list2' => array('搜索值设置', '"search&project=attr&search_type=4&search_option_info_id={id}&oper_table=info&oper_project=attr"' , '{type} == 1 || {type} == 9'),
+		),
 	),
 
 	'request' => array

+ 120 - 0
database/search.php

@@ -0,0 +1,120 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'search',
+    # 显示给用户看的名称
+    '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'      => '搜索名称-如设置为100万以下',
+            'default'   => '',
+            'desc'      => '搜索名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'value'      => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '搜索值-可以设置为{v}<=100,{v}为当前值,如果是区间输入框,则{s}为区间最小值,{e}为区间最大值',
+            'default'   => '',
+            'desc'      => '搜索值',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+            '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' => '*',
+        ),
+    )
+);

+ 14 - 3
database/value.php

@@ -37,7 +37,7 @@ return array
         'name'      => array
         (
             'type'      => 'varchar-1000',
-            'name'      => '属性值名称',
+            'name'      => '属性值名称-如绿色',
             'default'   => '',
             'desc'      => '属性值名称',
             'match'     => 'is_string',
@@ -50,16 +50,27 @@ return array
         'value'      => array
         (
             'type'      => 'varchar-1000',
-            'name'      => '属性值',
+            'name'      => '属性值-如#000000,可以为空',
             'default'   => '',
             'desc'      => '属性值',
-            'match'     => 'is_string',
+            'match'     => 'option',
             'update'    => 'text',
             'search'    => 'fulltext',
             'list'      => true,
             'edit'      => true,
         ),
 
+        'icon'      => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图标',
+            'default'   => '',
+            'desc'      => '图标',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => 1,
+        ),
+
         'reorder'       => array
         (
             'type'      => 'int-11',

+ 33 - 6
src/Api.php

@@ -120,14 +120,15 @@ class Api
 
 				$k = 'attr_' . $v['id'];
 				$config['struct'][$k] = array();
-
+				/*
 				$option = array();
 				if ($v['type_option']) {
 					$v['type_option'] = explode("\n", $v['type_option']);
 					foreach ($v['type_option'] as $k1 => $v1) {
 						$option[$k1+1] = $v1;
 					}
-				}
+				}*/
+				$option = Dever::db('attr/value')->getData(array('info_id' => $v['id']));
 
 				$config['struct'][$k]['name'] = $v['name'];
 				$config['struct'][$k]['default'] = '';
@@ -208,7 +209,7 @@ class Api
 						}
 				}
 
-				if ($v['option_type'] && $v['option_type'] == 2) {
+				if ($v['is_must'] && $v['is_must'] == 2) {
 					$config['struct'][$k]['match'] = 'option';
 				}
 
@@ -282,7 +283,14 @@ class Api
 		} elseif ($info['type'] == 9 && $info['value']) {
 			$info['value'] = explode(',', $info['value']);
 			$info['value'] = $info['value'][0];
-		} elseif ($info['type'] >= 9 && $info['value']) {
+		} elseif ($info['type'] > 9 && $info['value']) {
+			$value = Dever::db('attr/value')->getData(array('info_id' => $info['id']));
+			if ($value) {
+				if (isset($value[$info['value']])) {
+					$info['value'] = $value[$info['value']]['name'];
+				}
+			}
+			/*
 			$temp = explode("\n", $info['type_option']);
 			if ($temp) {
 				$info['value'] = $info['value'] - 1;
@@ -294,6 +302,7 @@ class Api
 					}
 				}
 			}
+			*/
 		}
 
 		if ($info['unit']) {
@@ -337,9 +346,12 @@ class Api
 		if ($attr) {
 			foreach ($attr as $k => $v) {
 				$sort[$k] = $v[$reorder];
+				$attr[$k]['option'] = Dever::db('attr/value')->getData(array('info_id' => $v['id']));
+				/*
 				if ($v['type_option']) {
                     $attr[$k]['option'] = explode("\n", $v['type_option']);
                 }
+                */
 			}
 			array_multisort($sort, SORT_DESC, $attr);
 		}
@@ -379,7 +391,7 @@ class Api
 	public function getSearch($ids, $cate = true, $city = false, $search_value = false, $total = 3)
 	{
 		$value = array();
-		$search_value = Dever::preInput('attr_', $search_value);
+		$search_value = Dever::preInput('attr_', array(), $search_value);
 
 		if ($cate && $ids && Dever::project('category')) {
 			$data = $this->getAttrByCate($ids, 'search_reorder', $total);
@@ -401,6 +413,8 @@ class Api
 				if ($v['type'] == 7 && $city > 0) {
 					# 获取地区,获取最后一个级别的地区
 					$data[$k]['option'] = Dever::db('area/county')->state(array('city_id' => $city));
+				} elseif ($v['type'] == 1 || $v['type'] == 9) {
+					$data[$k]['option'] = Dever::db('attr/search')->getData(array('info_id' => $v['id']));
 				} else {
 					$data[$k]['option'] = Dever::db('attr/value')->getData(array('info_id' => $v['id']));
 				}
@@ -461,7 +475,12 @@ class Api
                             }
                         }
                     }
-                } elseif ($v['type'] == 1 && $v['type_option']) {
+                //} elseif ($v['type'] == 1 && $v['type_option']) {
+                } elseif ($v['type'] == 1) {
+
+                	$search = Dever::db('attr/search')->getData(array('info_id' => $v['id']));
+                	print_r($where[$key]);die;
+                	/*
                     $temp = explode("\n", $v['type_option']);
                     if (isset($temp[$where[$key]-1])) {
                         $temp = explode(',', $temp[$where[$key]-1]);
@@ -473,7 +492,14 @@ class Api
                         $match = str_replace('{v}', $tname . '.' . $key, $match);
                         $sql[] = $match;
                     }
+                    */
+                //} elseif ($v['type'] == 9 && $v['type_option']) {
                 } elseif ($v['type'] == 9 && $v['type_option']) {
+
+                	$search = Dever::db('attr/search')->getData(array('info_id' => $v['id']));
+                	print_r($where[$key]);die;
+
+                	/*
                     $temp = explode("\n", $v['type_option']);
                     if (isset($temp[$where[$key]-1])) {
                         $temp = explode(',', $temp[$where[$key]-1]);
@@ -487,6 +513,7 @@ class Api
                         $match = str_replace('{v}', $tname . '.' . $key . '_e', $match);
                         $sql[] = $match;
                     }
+                    */
                 } else {
                     $sql[] = ' '.$tname.'.'.$key.' = "'.$where[$key].'"';
                 }