rabin 2 سال پیش
والد
کامیت
67a225bbd7
5فایلهای تغییر یافته به همراه323 افزوده شده و 168 حذف شده
  1. 138 1
      assets/layadmin/html/map.html
  2. 0 136
      assets/layadmin/html/project/database/update.html
  3. 8 8
      database/admin.php
  4. 176 22
      src/Database.php
  5. 1 1
      src/Lib/Input.php

+ 138 - 1
assets/layadmin/html/map.html

@@ -25,4 +25,141 @@
 <div id="panel"></div>
 <script type="text/javascript" src="../script/lib/map/gaode.js"></script>
 </body>
-</html>
+</html>
+</script>
+/*
+    $('select').each(function() {
+        if ($(this).attr('xm-value')) {
+          formSelects.value($(this).attr('xm-select'), $(this).attr('xm-value'));
+        }
+    });
+    */
+
+    /*
+    var obj = layui.skuTable.render({
+            //规格类型 0统一规格 1多规格
+            isAttributeValue: 0,
+            //规格类型容器id
+            isAttributeElemId: 'sku_spec_type',
+            //规格表容器id
+            specTableElemId: 'sku_spec_table',
+            //sku表容器id
+            skuTableElemId: 'sku_table',
+            //规格拖拽排序
+            sortable: false,
+            //sku表相同属性值是否合并行
+            rowspan: true,
+            //请求成功返回状态码值
+            requestSuccessCode: 200,
+            //上传接口地址
+            //接口要求返回格式参考 upload.json
+            uploadUrl: './json/upload.json',
+            //统一规格配置项
+            singleSkuTableConfig: {
+                thead: [
+                    {title: '商品编码', icon: 'layui-icon-cols'},
+                    {title: '销售价(元)', icon: 'layui-icon-cols'},
+                    {title: '采购价(元)', icon: 'layui-icon-cols'},
+                    {title: '成本价(元)', icon: 'layui-icon-cols'},
+                ],
+                tbody: [
+                    {type: 'input', field: 'code', value: '', verify: 'required', reqtext: '商品编码不能为空'},
+                    {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'},
+                    {type: 'input', field: 'buy_price', value: '0', verify: 'required|number', reqtext: '采购价不能为空'},
+                    {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
+                ]
+            },
+            //多规格配置项
+            multipleSkuTableConfig: {
+                thead: [
+                    {title: '图片', icon: ''},
+                    {title: '商品编码', icon: 'layui-icon-cols'},
+                    {title: '销售价(元)', icon: 'layui-icon-cols'},
+                    {title: '采购价(元)', icon: 'layui-icon-cols'},
+                    {title: '成本价(元)', icon: 'layui-icon-cols'},
+                ],
+                tbody: [
+                    {type: 'image', field: 'pic', value: '', verify: '', reqtext: ''},
+                    {type: 'input', field: 'code', value: '', verify: 'required', reqtext: '商品编码不能为空'},
+                    {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'},
+                    {type: 'input', field: 'buy_price', value: '0', verify: 'required|number', reqtext: '采购价不能为空'},
+                    {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
+                ]
+            },
+            //商品id 配合specDataUrl和skuDataUrl使用
+            productId: '11',
+            //规格数据, 一般从后台获取
+            specData: [
+                {
+                    id: "1",
+                    title: "颜色",
+                    child: [
+                        {id: "1", title: "红", checked: true},
+                        {id: "2", title: "黄", checked: false},
+                        {id: "3", title: "蓝", checked: false}
+                    ]
+                }, {
+                    id: "2",
+                    title: "尺码",
+                    child: [
+                        {id: "4", title: "S", checked: true},
+                        {id: "5", title: "M", checked: true},
+                        {id: "6", title: "L", checked: false},
+                        {id: "7", title: "XL", checked: false}
+                    ]
+                }, {
+                    id: "3",
+                    title: "款式",
+                    child: [
+                        {id: "8", title: "男款", checked: true},
+                        {id: "9", title: "女款", checked: true}
+                    ]
+                }
+            ],
+            specData: [],
+            //获取规格数据接口地址,如果为空或者不配置则使用 specData 参数配置
+            //接口要求返回格式参考 specData.json
+            // specDataUrl: './json/specData.json',
+            //sku数据
+            //新增的时候为空对象
+            //编辑的时候可以从后台接收,会自动填充sku表,可以去掉注释看效果
+            //多规格格式
+            // skuData: {
+            //     "skus[1-4-8][picture]": "https://www.baidu.com/img/flexible/logo/pc/result.png",
+            //     "skus[1-4-8][price]": "100",
+            //     "skus[1-4-8][market_price]": "200",
+            //     "skus[1-4-8][cost_price]": "50",
+            //     "skus[1-4-8][stock]": "18",
+            //     "skus[1-4-8][status]": "0",
+            //     "skus[1-4-9][picture]": "",
+            //     "skus[1-4-9][price]": "0",
+            //     "skus[1-4-9][market_price]": "0",
+            //     "skus[1-4-9][cost_price]": "0",
+            //     "skus[1-4-9][stock]": "0",
+            //     "skus[1-4-9][status]": "1",
+            //     "skus[1-5-8][picture]": "",
+            //     "skus[1-5-8][price]": "0",
+            //     "skus[1-5-8][market_price]": "0",
+            //     "skus[1-5-8][cost_price]": "0",
+            //     "skus[1-5-8][stock]": "0",
+            //     "skus[1-5-8][status]": "1",
+            //     "skus[1-5-9][picture]": "",
+            //     "skus[1-5-9][price]": "0",
+            //     "skus[1-5-9][market_price]": "0",
+            //     "skus[1-5-9][cost_price]": "0",
+            //     "skus[1-5-9][stock]": "0",
+            //     "skus[1-5-9][status]": "1"
+            // },
+            //统一规格格式
+            // skuData: {
+            //     'price': '80',
+            //     'market_price': '100',
+            //     'cost_price': '60',
+            //     'stock': '999',
+            //     'status': '0',
+            // }
+            //获取SKU数据接口地址,如果为空或者不配置则使用skuData配置
+            //接口要求返回格式参考 skuData.json
+            // skuDataUrl: './json/skuData.json',
+        });*/
+</script>

+ 0 - 136
assets/layadmin/html/project/database/update.html

@@ -91,142 +91,6 @@
         sku($('#sku_spec_type'));
     }
 
-    /*
-    $('select').each(function() {
-        if ($(this).attr('xm-value')) {
-          formSelects.value($(this).attr('xm-select'), $(this).attr('xm-value'));
-        }
-    });
-    */
-
-    /*
-    var obj = layui.skuTable.render({
-            //规格类型 0统一规格 1多规格
-            isAttributeValue: 0,
-            //规格类型容器id
-            isAttributeElemId: 'sku_spec_type',
-            //规格表容器id
-            specTableElemId: 'sku_spec_table',
-            //sku表容器id
-            skuTableElemId: 'sku_table',
-            //规格拖拽排序
-            sortable: false,
-            //sku表相同属性值是否合并行
-            rowspan: true,
-            //请求成功返回状态码值
-            requestSuccessCode: 200,
-            //上传接口地址
-            //接口要求返回格式参考 upload.json
-            uploadUrl: './json/upload.json',
-            //统一规格配置项
-            singleSkuTableConfig: {
-                thead: [
-                    {title: '商品编码', icon: 'layui-icon-cols'},
-                    {title: '销售价(元)', icon: 'layui-icon-cols'},
-                    {title: '采购价(元)', icon: 'layui-icon-cols'},
-                    {title: '成本价(元)', icon: 'layui-icon-cols'},
-                ],
-                tbody: [
-                    {type: 'input', field: 'code', value: '', verify: 'required', reqtext: '商品编码不能为空'},
-                    {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'},
-                    {type: 'input', field: 'buy_price', value: '0', verify: 'required|number', reqtext: '采购价不能为空'},
-                    {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
-                ]
-            },
-            //多规格配置项
-            multipleSkuTableConfig: {
-                thead: [
-                    {title: '图片', icon: ''},
-                    {title: '商品编码', icon: 'layui-icon-cols'},
-                    {title: '销售价(元)', icon: 'layui-icon-cols'},
-                    {title: '采购价(元)', icon: 'layui-icon-cols'},
-                    {title: '成本价(元)', icon: 'layui-icon-cols'},
-                ],
-                tbody: [
-                    {type: 'image', field: 'pic', value: '', verify: '', reqtext: ''},
-                    {type: 'input', field: 'code', value: '', verify: 'required', reqtext: '商品编码不能为空'},
-                    {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'},
-                    {type: 'input', field: 'buy_price', value: '0', verify: 'required|number', reqtext: '采购价不能为空'},
-                    {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
-                ]
-            },
-            //商品id 配合specDataUrl和skuDataUrl使用
-            productId: '11',
-            //规格数据, 一般从后台获取
-            specData: [
-                {
-                    id: "1",
-                    title: "颜色",
-                    child: [
-                        {id: "1", title: "红", checked: true},
-                        {id: "2", title: "黄", checked: false},
-                        {id: "3", title: "蓝", checked: false}
-                    ]
-                }, {
-                    id: "2",
-                    title: "尺码",
-                    child: [
-                        {id: "4", title: "S", checked: true},
-                        {id: "5", title: "M", checked: true},
-                        {id: "6", title: "L", checked: false},
-                        {id: "7", title: "XL", checked: false}
-                    ]
-                }, {
-                    id: "3",
-                    title: "款式",
-                    child: [
-                        {id: "8", title: "男款", checked: true},
-                        {id: "9", title: "女款", checked: true}
-                    ]
-                }
-            ],
-            specData: [],
-            //获取规格数据接口地址,如果为空或者不配置则使用 specData 参数配置
-            //接口要求返回格式参考 specData.json
-            // specDataUrl: './json/specData.json',
-            //sku数据
-            //新增的时候为空对象
-            //编辑的时候可以从后台接收,会自动填充sku表,可以去掉注释看效果
-            //多规格格式
-            // skuData: {
-            //     "skus[1-4-8][picture]": "https://www.baidu.com/img/flexible/logo/pc/result.png",
-            //     "skus[1-4-8][price]": "100",
-            //     "skus[1-4-8][market_price]": "200",
-            //     "skus[1-4-8][cost_price]": "50",
-            //     "skus[1-4-8][stock]": "18",
-            //     "skus[1-4-8][status]": "0",
-            //     "skus[1-4-9][picture]": "",
-            //     "skus[1-4-9][price]": "0",
-            //     "skus[1-4-9][market_price]": "0",
-            //     "skus[1-4-9][cost_price]": "0",
-            //     "skus[1-4-9][stock]": "0",
-            //     "skus[1-4-9][status]": "1",
-            //     "skus[1-5-8][picture]": "",
-            //     "skus[1-5-8][price]": "0",
-            //     "skus[1-5-8][market_price]": "0",
-            //     "skus[1-5-8][cost_price]": "0",
-            //     "skus[1-5-8][stock]": "0",
-            //     "skus[1-5-8][status]": "1",
-            //     "skus[1-5-9][picture]": "",
-            //     "skus[1-5-9][price]": "0",
-            //     "skus[1-5-9][market_price]": "0",
-            //     "skus[1-5-9][cost_price]": "0",
-            //     "skus[1-5-9][stock]": "0",
-            //     "skus[1-5-9][status]": "1"
-            // },
-            //统一规格格式
-            // skuData: {
-            //     'price': '80',
-            //     'market_price': '100',
-            //     'cost_price': '60',
-            //     'stock': '999',
-            //     'status': '0',
-            // }
-            //获取SKU数据接口地址,如果为空或者不配置则使用skuData配置
-            //接口要求返回格式参考 skuData.json
-            // skuDataUrl: './json/skuData.json',
-        });*/
-
     init();
   });
   </script>

+ 8 - 8
database/admin.php

@@ -157,7 +157,7 @@ return array
 		'manage/admin_role' => array
 		(
 			# 更新时的条件,另外一个表的字段 => 本表的字段
-			'where' => array('admin_id', 'id'),
+			'where' => array('admin_id' => 'id'),
 			# 要更新的数据
 			'update' => array('role_id' => 'role'),
 			# 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
@@ -167,7 +167,7 @@ return array
 		'manage/admin_group' => array
 		(
 			# 更新时的条件,另外一个表的字段 => 本表的字段
-			'where' => array('admin_id', 'id'),
+			'where' => array('admin_id' => 'id'),
 			# 要更新的数据
 			'update' => array('group_id' => 'group'),
 			# 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
@@ -326,7 +326,7 @@ return array
 		),
 
 		//当前的字段属于另外一个表,主要不要有type,当name不存在时,此处直接复用整个role_test表里的struct
-		'manage-role_test-name'=> array
+		'manage/role_test-one#name'=> array
 		(
 			'name' 		=> '测试名',
 			'default' 	=> '',
@@ -334,19 +334,19 @@ return array
 			'match' 	=> 'option',
 			'update'	=> 'text',//直接复制name的值
 			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段,当前表、关联表
-			'sync'		=> array('id', 'role_id'),
+			'sync'		=> array('role_id' => 'id'),
 			'list'		=> true,
 			//'list'      => 'Dever::load("setting/role-find#name", "{manage-role_test-name}")',
 		),
 		//同时设置另外一个表的数据,设置同上,只有update的值不同
-		'manage-role_test' => array
+		'manage/role_test' => array
         (
             'type'      => 'text-1000',
             'name'      => '属性设置',
             'default'   => '',
             'desc'      => '属性设置',
             'match'     => 'is_string',
-            'sync'      => array('id', 'category_id'),
+            'sync'      => array('category_id' => 'id'),
             'update'    => array(1),
         ),
 		
@@ -442,14 +442,14 @@ return array
 			'tab'		=> 1,
 		),
 
-		'product-info_attr'=> array
+		'product/info_attr'=> array
 		(
 			'name' 		=> '属性设置',
 			'default' 	=> '',
 			'desc' 		=> '请先选择属性分类',
 			'match' 	=> 'option',
 			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
-			'sync'		=> array('id', 'info_id'),
+			'sync'		=> array('info_id' => 'id'),
 			# 根据category字段的值,获取product/attr.search接口的内容
 			'update'	=> 'load',
 			'update_load' => array('product/attr.getManageByCate', 'category'),

+ 176 - 22
src/Database.php

@@ -2153,9 +2153,9 @@ class Database
                         $body[$j][$i] = '';
                         //if (isset($vi[$k])) {
                         # 处理同步
-                        if (isset($v['sync']) && strpos($k, '-')) {
+                        # 兼容旧版,之后去掉
+                        if (isset($v['sync']) && isset($v['sync'][0]) && (strstr($k, '-') || strstr($k, '.'))) {
                             $temp = explode('-', $k);
-
                             if ($vi[$v['sync'][0]] > 0) {
                                 $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $v['sync'][1] => $vi[$v['sync'][0]]));
                             } else {
@@ -2165,6 +2165,9 @@ class Database
                             if (isset($temp[2])) {
                                 $data[$ki][$k] = $vi[$k] = isset($load[$temp[2]]) ? $load[$temp[2]] : $v['default'];
                             }
+                        } elseif (isset($v['sync']) && (strstr($k, '-') || strstr($k, '.'))) {
+                            $v['sync']['dever-read'] = $vi;
+                            $data[$ki][$k] = Dever::load($k, $v['sync']);
                         }
                         if (true) {
                             $value = $vi[$k];
@@ -2450,17 +2453,14 @@ class Database
                 if (is_string($v)) {
                     $v = ltrim(rtrim($v));
                 }
-                
-                if (strpos($k, '-') !== false) {
+                if (strstr($k, '-') || strstr($k, '.')) {
                     $k = str_replace('search_option_', '', $k);
-                    $temp = explode('-', $k);
-                    if (isset($config['struct'][$k]) && isset($config['struct'][$k]['sync'])) {
-                        
-                    }
                     $struct = $config['struct'][$k];
                     if (isset($struct['search_col']) && $struct['search_col']) {
                         $param[$struct['search_col']] = $v;
-                    } else {
+                    } elseif (isset($struct['sync']) && isset($struct['sync'][0])) {
+                        # 兼容旧版,之后去掉
+                        $temp = explode('-', $k);
                         $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $struct['sync'][1] => $v));
                         /*
                         if ($v[$vi['sync'][0]] > 0) {
@@ -2474,8 +2474,14 @@ class Database
                             $v = isset($load[$temp[2]]) ? $load[$temp[2]] : $struct['default'];
                             $param[str_replace('search_', '', $k)] = $v;
                         }
+                    }elseif (isset($struct['sync'])) {
+                        $struct['sync']['dever-read']['id'] = $v;
+                        $v = Dever::load($k, $struct['sync']);
+                        if (!$v) {
+                            $v = $struct['default'];
+                        }
+                        $param[str_replace('search_', '', $k)] = $v;
                     }
-                    
                 } elseif (strpos($k, 'dever_') !== false) {
                     continue;
                 } elseif (strpos($k, 'option_') !== false) {
@@ -2757,7 +2763,8 @@ class Database
 
                 foreach ($config['struct'] as $ki => $vi) {
                     # 处理同步
-                    if (isset($vi['sync']) && strpos($ki, '-')) {
+                    # 兼容处理,之后删除
+                    if (isset($vi['sync']) && (isset($vi['sync'][0]) && strpos($ki, '-')) {
                         $temp = explode('-', $ki);
                         if ($v[$vi['sync'][0]] > 0) {
                             $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $vi['sync'][1] => $v[$vi['sync'][0]]));
@@ -2769,6 +2776,13 @@ class Database
                         if (isset($temp[2])) {
                             $data[$k][$ki] = $v[$ki] = isset($load[$temp[2]]) ? $load[$temp[2]] : $vi['default'];
                         }
+                    } elseif (isset($vi['sync']) && (strstr($ki, '-') || strstr($ki, '.'))) {
+                        $vi['sync']['dever-read'] = $v;
+                        $v[$ki] = Dever::load($ki, $vi['sync']);
+                        if (!$v[$ki]) {
+                            $v[$ki] = $vi['default'];
+                        }
+                        $data[$k][$ki] = $v[$ki];
                     }
 
                     if (isset($vi['list']) && $vi['list']) {
@@ -3458,7 +3472,7 @@ class Database
             $upload_call = $this->value($config['manage']['upload'], $data);
         }
         foreach ($config['struct'] as $k => $v) {
-            if (isset($config['manage']['lang']) && $this->lang_set && isset($v['sync']) && strpos($k, '-')) {
+            if (isset($config['manage']['lang']) && $this->lang_set && isset($v['sync']) && (strstr($k, '-') || strstr($k, '.'))) {
                 continue;
             }
             $state = false;
@@ -3578,7 +3592,7 @@ class Database
                 foreach ($param[$key] as $k => $v) {
                     if ($k == 'no') {
                         $child[$k . '_' . $v] = $key . '_no';
-                    } elseif (strpos($v, '/')) {
+                    } elseif (strstr($v, '/')) {
                         $parent[$k] = $key . '_' . $k;
                         $k = $k . '_ajax';
                         $value = '';
@@ -3633,6 +3647,8 @@ class Database
     {
         $result = '';
 
+        $this->update_key($key, $value);
+
         $value['ext'] = $value['col'] = $key;
 
         $value['update'] = $value['update'] ? $value['update'] : 'text';
@@ -3650,6 +3666,21 @@ class Database
         return $result;
     }
 
+    private function update_key(&$key, &$value)
+    {
+        if (strstr($key, '/')) {
+            if (strstr($key, '-')) {
+                $temp = explode('-', $key);
+                $value['api'] = $temp[0];
+                $value['method'] = $temp[1];
+            } else {
+                $value['api'] = $key;
+            }
+
+            $key = str_replace('/', '--', $key);
+        }
+    }
+
     /**
      * update_html
      *
@@ -3714,8 +3745,8 @@ class Database
                 $param['default'] = $this->option($param['default']);
             }
 
-            # 处理同步
-            if (isset($param['sync']) && strpos($key, '-') && $param['update'] != 'load') {
+            # 处理关联数据 兼容处理,以后删除
+            if (isset($param['sync']) && isset($param['sync'][0]) && strpos($key, '-') && $param['update'] != 'load') {
                 $temp = explode('-', $key);
                 if (isset($data[$param['sync'][0]])) {
                     if (isset($temp[2])) {
@@ -3757,6 +3788,31 @@ class Database
                     }
                     //$param['value'] = Dever::db($temp[0] . '/' . $temp[1]);
                 }
+            } elseif (isset($param['sync']) && isset($param['api']) && $param['update'] != 'load') {
+                $param['sync']['dever-read'] = $data;
+                $param['value'] = Dever::load($param['api'], $param['sync']);
+                if (is_array($param['update'])) {
+                    $order = false;
+                    if (isset($param['update'][0]) && is_string($param['update'][0]) && strstr($param['update'][0], '.')) {
+                        if (isset($param['update'][1]) && $param['update'][1]) {
+                            $param['update_load'] = $param['update'][0];
+                            $param['update'] = 'load';
+                        } else {
+                            $param['update'] = Dever::load($param['update'][0]);
+                        }
+                    } else {
+                        $config = Dever::db($param['api'])->config;
+                        $param['update'] = $config['struct']; 
+                    }
+                    
+                    if (isset($config['manage']['tab'])) {
+                        $param['prefix'] = $prefix;
+                        $param['tab_config'] = $config['manage']['tab'];
+                        if (isset($config['manage']['lang'])) {
+                            $param['lang'] = $config['manage']['lang'];
+                        }
+                    }
+                }
             }
 
             $method = $param['update'];
@@ -3775,9 +3831,12 @@ class Database
                     $table_body = '<tbody>';
                     $table_key = '';
                     if (isset($param['option'])) {
-                        if (!isset($param['value'])) {
+                        $table_key = '1';
+                        if (isset($param['value']) && $param['value']) {
+                            $table_body .= '<tr class="table_copy" style="display:none;">';
+                            $table_up = 'up';
+                        } else {
                             $table_body .= '<tr>';
-                            $table_key = '1';
                             $table_up = 'update';
                         }
                     } else {
@@ -3791,6 +3850,7 @@ class Database
                             if (isset($hv['col'])) {
                                 $hk = $hv['col'];
                             }
+                            $this->update_key($hk, $hv);
                             if ($this->id && $hk === 'id') {
                                 $hv['update'] = 'hidden';
                             }
@@ -3830,6 +3890,7 @@ class Database
                                 if (isset($hv['col'])) {
                                     $hk = $hv['col'];
                                 }
+                                $this->update_key($hk, $hv);
                                 if ($this->id && $hk === 'id') {
                                     $hv['update'] = 'hidden';
                                 }
@@ -3848,7 +3909,9 @@ class Database
                                     }
                                 }
                             }
-                            $table_body .= '<td><a href="javascript:;" onclick="var self = $(this);var index = layer.confirm(\'确定进行此项操作吗?\', function(i, l){self.parent().parent().remove();layer.close(index);});" class="layui-btn layui-btn-xs">删除</a></td>';
+                            if ($table_key == '-1') {
+                                $table_body .= '<td><a href="javascript:;" onclick="var self = $(this);var index = layer.confirm(\'确定进行此项操作吗?\', function(i, l){self.parent().parent().remove();layer.close(index);});" class="layui-btn layui-btn-xs">删除</a></td>';
+                            }
                             $table_body .= '</tr>';
                         }
                     }
@@ -3867,6 +3930,7 @@ class Database
                         if (isset($hv['col'])) {
                             $hk = $hv['col'];
                         }
+                        $this->update_key($hk, $hv);
                         if ($this->id && $hk === 'id') {
                             $hv['update'] = 'hidden';
                         }
@@ -3900,6 +3964,7 @@ class Database
                                 if (isset($hv['col'])) {
                                     $hk = $hv['col'];
                                 }
+                                $this->update_key($hk, $hv);
                                 if ($this->id && $hk === 'id') {
                                     $hv['update'] = 'hidden';
                                 }
@@ -3948,7 +4013,10 @@ class Database
                         array_unshift($method, $order);
 
                         if (isset($param['value']) && $param['value']) {
-                            $value = Dever::array_decode($param['value']);
+                            $value = $param['value'];
+                            if (!is_array($value)) {
+                                $value = Dever::json_decode($value);
+                            }
                             $param['value'] = array();
                             if (!$value) {
                                 foreach ($param['option'] as $k => $v) {
@@ -3982,7 +4050,6 @@ class Database
                                 $param['value'][$v]['main_' . $key] = $k;
                             }
                         }
-
                     } else {
                         $result .= '<ul class="nav nav-tabs '.$c.'" style="height:100%;">{tab}<li style="margin:0px;padding:0 15px;"><a href="javascript:;" class="dever_form_add" toggle_key="' . $key . '">增加一条</a></li></ul>';
 
@@ -4313,7 +4380,9 @@ class Database
 
                         if (strpos($h, '-')) {
                             $h = str_replace('update_', '', $h);
-                            if (isset($config['struct'][$h]) && isset($config['struct'][$h]['sync'])) {
+                            $h = str_replace('--', '/', $h);
+                            # 兼容处理 之后删除
+                            if (isset($config['struct'][$h]) && isset($config['struct'][$h]['sync']) && isset($config['struct'][$h]['sync'][0])) {
                                 $s_col = $config['struct'][$h]['sync'][0];
                                 $m_col = $config['struct'][$h]['sync'][1];
                                 if ($s_col == 'id') {
@@ -4340,6 +4409,35 @@ class Database
                                 if ($this->id && $temp[1] == 'id') {
                                     $update_id[$i][$index][$num]['id'] = $v;
                                 }
+                            } elseif (isset($config['struct'][$h]) && isset($config['struct'][$h]['sync'])) {
+                                $t = explode('-', $h);
+                                $index = $t[0];
+
+                                if (Dever::zero($v)) {
+                                    $v = (string) $v;
+                                } elseif (!$v) {
+                                    $v = 'null';
+                                }
+                                $update_set[$i][$index][$num]['set_' . $temp[1]] = $v;
+                                $update_add[$i][$index][$num]['add_' . $temp[1]] = $v;
+                                if ($this->id && $temp[1] == 'id') {
+                                    $update_id[$i][$index][$num]['id'] = $v;
+                                }
+                                
+                                foreach ($config['struct'][$h]['sync'] as $ks => $vs) {
+                                    if ($vs == 'id') {
+                                        $vs = $this->id;
+                                        $update_col[$i][$index] = $ks;
+                                    } else {
+                                        $s_one = $this->load('one', $this->id);
+                                        if (isset($s_one[$vs])) {
+                                            $vs = $s_one[$vs];
+                                        }
+                                    }
+                                    $update_add[$i][$index][$num]['add_' . $ks] = $vs;
+                                    $update_deletes[$i][$index][$ks] = $vs;
+                                    $update_id[$i][$index][$num][$ks] = $vs;
+                                }
                             }
                         } else {
                             $update[$i][$k][$num][$temp[1]] = $v;
@@ -4372,7 +4470,7 @@ class Database
                             $temp = explode('l-l', $k);
                             $k = str_replace('_', '', $temp[2]);
                             $update_other[$i][$temp[1]][$k] = $v;
-                        } elseif (strpos($k, '-')) {
+                        } elseif (strpos($k, '-') && isset($config['struct'][$k]['sync'][0])) {
                             $k = str_replace('update_', '', $k);
                             if (isset($config['struct'][$k]) && isset($config['struct'][$k]['sync'])) {
                                 $s_col = $config['struct'][$k]['sync'][0];
@@ -4423,6 +4521,61 @@ class Database
                                     }
                                 }
                             }
+                        } elseif (strpos($k, '#')) {
+                            $k = str_replace('update_', '', $k);
+                            $k = str_replace('--', '/', $k);
+                            # 此处需要改造 ---
+                            if (isset($config['struct'][$k]) && isset($config['struct'][$k]['sync'])) {
+                                $temp = explode('-', $k);
+                                $index = $temp[0];
+                                $temp = explode('#', $temp[1]);
+                                $c_col = $temp[1];
+
+
+                                $update_set[$i][$index][0]['set_' . $c_col] = $v;
+                                $update_add[$i][$index][0]['add_' . $c_col] = $v;
+
+                                foreach ($config['struct'][$k]['sync'] as $ks => $vs) {
+                                    if ($vs == 'id') {
+                                        $vs = $this->id;
+                                        $update_col[$i][$index] = $ks;
+                                    } else {
+                                        $s_one = $this->load('one', $this->id);
+                                        if (isset($s_one[$vs])) {
+                                            $vs = $s_one[$vs];
+                                        }
+                                    }
+                                    $update_add[$i][$index][0]['add_' . $ks] = $vs;
+                                    $update_id[$i][$index][0][$ks] = $vs;
+                                }
+                            } else {
+                                $temp = explode('-', $k);
+                                $k = $index = $temp[0];
+                                $temp = explode('#', $temp[1]);
+                                $c_col = $temp[1];
+                                if (isset($config['struct'][$k]) && isset($config['struct'][$k]['sync'])) {
+                                    $c_col = ltrim($c_col, '_');
+                                    $temp = explode('_', $c_col);
+                                    $up = array();
+                                    $up['add_' . $temp[0] . '_id'] = $temp[1];
+                                    $up['add_' . $temp[0] . '_value'] = $v;
+                                    
+                                    foreach ($config['struct'][$k]['sync'] as $ks => $vs) {
+                                        if ($vs == 'id') {
+                                            $vs = $this->id;
+                                            $update_col[$i][$index] = $ks;
+                                        } else {
+                                            $s_one = $this->load('one', $this->id);
+                                            if (isset($s_one[$vs])) {
+                                                $vs = $s_one[$vs];
+                                            }
+                                        }
+                                        $up['add_' . $ks] = $vs;
+                                        $update_delete[$i][$index][][$ks] = $vs;
+                                    }
+                                    $update_add[$i][$index][] = $up;
+                                }
+                            }
                         } else {
                             if (is_array($v)) {
                                 $k = str_replace('update_', '', $k);
@@ -4450,6 +4603,7 @@ class Database
                     }
                 }
             }
+            //print_r($update_col);
             //print_r($update_set);
             //print_r($update_id);
             //print_r($update_add);die;

+ 1 - 1
src/Lib/Input.php

@@ -1658,7 +1658,7 @@ class Input
     public static function _show($param, $class = '')
     {
         $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
-        if (isset($param['option']) && $param['option']) {
+        if (isset($param['option']) && $param['option'] && is_array($param['option'])) {
             foreach ($param['option'] as $k => $v) {
                 if (is_array($v)) {
                     if ($v['id'] == $value) {