dever 5 년 전
부모
커밋
f68c723056
2개의 변경된 파일41개의 추가작업 그리고 40개의 파일을 삭제
  1. 9 2
      lib/Info.php
  2. 32 38
      lib/Manage.php

+ 9 - 2
lib/Info.php

@@ -278,7 +278,7 @@ class Info
     }
 
     # 获取需求基本信息
-    public function info($info, $key = 'list_reorder')
+    public function info($info, $key = 'list_reorder', $is_sell = false)
     {
         $attr = $this->setAttr($info['category'], $key);
         $attr_data = $attr->one($info['id']);
@@ -303,7 +303,14 @@ class Info
                     } else {
                         $v['bg'] = 'background-image: url('.$v['icon'].')';
                         $v['pic'] = '<img src="'.$v['icon'].'" width="18" />';
-                        $info['attr'][] = $v;
+                        if ($is_sell > 0) {
+                            if ($is_sell == $v['is_sell']) {
+                                $info['attr'][] = $v;
+                            }
+                            
+                        } else {
+                            $info['attr'][] = $v;
+                        }
                     }
                 }
             }

+ 32 - 38
lib/Manage.php

@@ -158,64 +158,58 @@ class Manage
 
         $info = Dever::db('goods/info')->one($id);
 
-        $info = Info::init(-1)->info($info, 'list_reorder');
+        $info = Info::init(-1)->info($info, 'list_reorder', 2);
 
         if ($info['attr']) {
             $head = '<thead><tr>';
             $body = '<tbody>';
+            $option = array();
             foreach ($info['attr'] as $k => $v) {
                 $head .= '<th>'.$v['name'].'</th>';
+                foreach($v['option'] as $k1 => $v1) {
+                    $option[$k][$k1] = array
+                    (
+                        'id' => $v1['id'],
+                        'attr_id' => $v1['info_id'],
+                        'name' => $v1['name']
+                    );
+                }
             }
 
             $head .= '<th>原价</th>';
             $head .= '<th>现价</th>';
             $head .= '<th>库存</th>';
             $head .= '</tr></thead>';
-        }
-
-        $data = array(
-         array('白色','银色','玫瑰金'),
-         array('64G','128G'),
-         array('移动','电信','联通'),
-         array('国行','港版')
-        );
-
-        //打印结果
-        $result = $this->Cartesian($info['attr']);
-        print_r($result);die;
 
-       // print_r($option);die;
+            if ($option) {
+                $option = Dever::cartesian($option, function($option, $index)
+                {
+                    print_r($option);die;
+                    $html = '<tr data-row="' .($index+1). '">';
 
-        $html = $head . $body;
+                    foreach ($option['name'] as $k => $v) {
+                        $rows = 1;
+                        $html .= '<td width="50" rowspan="'.$rows.'">'.$v.'</td>';
+                    }
+                    $html .= '<td width="30"><input type="text" class="layui-input" name="price[]" /></td>';
+                    $html .= '<td width="30"><input type="text" class="layui-input" name="price[]" /></td>';
+                    $html .= '<td width="30"><input type="text" class="layui-input" name="price[]" /></td>';
+                    $html .= '</tr>';
+                    return $html;
+                });
 
-        return $html;
-    }
+                print_r($option);die;
 
-    function Cartesian($data){
-        $len = count($data);
-
-        // 取第一个集合数组值
-        $result = $data[0]['option'];
-        for ($i = 0; $i< $len-1; $i++) {
-            $arr1 = $result;
-            $result = [];
-            // 数组第一个值和第二个值组合
-            foreach ($arr1 as $res) {
-                //数组第二个值...$i+1
-                foreach($data[$i+1] as $k => $v){ 
-                    if(!is_array($res)) {
-                        $res = array($res);
-                    }
-                    if(!is_array($v)){
-                        $sec = array($v['option']);
-                    }
-                    $result[] = array_merge_recursive($res,$sec);
-                }
+                $body .= implode('', $option);
             }
 
+            $body .= '</tbody>';
+            
         }
 
-        return $result;
+        $html = $head . $body;
+
+        return $html;
     }