|
@@ -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;
|
|
|
}
|
|
|
|
|
|
|