Browse Source

no message

lvhao 1 tháng trước cách đây
mục cha
commit
09f6eab339
1 tập tin đã thay đổi với 108 bổ sung30 xóa
  1. 108 30
      core/CoreApp/controllers/Color.php

+ 108 - 30
core/CoreApp/controllers/Color.php

@@ -473,48 +473,126 @@ class Color extends Start_Controller {
 				{
 					$info_list[$key]['type'] = '未选择';
 				}
-				/**
+			
 				$colorimg = explode('|',$value['img']);
 				$v = $colorimg[0];
-				//foreach ($colorimg as $v) 
-		       // {
+				$img_list =[];
+				foreach ($colorimg as $v) 
+		        {
 					$lx = explode(".",$v);
 					$lx = strtolower(end($lx));
 					if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
 					{
-						$info_list[$key]['img'] = '<video src="'.$v.'" controls="controls"';
+						$img_list[] = '<video width="80" height="auto" src="'.$v.'" controls="controls"';
 					}
 					else if($v != '')
 					{
-			 		   $info_list[$key]['img'] = "<img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=200&h=100' data-src='".$v."'>";
-					}
-					else
-					{
-						$info_list[$key]['img'] = '';
+			 		   $img_list[] = "<img width='80' height='auto' src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=200&h=100' data-src='".$v."'>";
 					}
-				//}
-				**/
-				$info_list[$key]['img'] = '<a href="http://'.$_SERVER['HTTP_HOST'].'/color/see/'.$value['id'].'" target="_blank">点击查看</a>';
+					
+				}
+				$info_list[$key]['img'] = $img_list;
 				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
 				unset($info_list[$key]['id']);
 			}
-		    $title = "新品/新色配图"; 
-            $titlename = "<table border=1>
-            <tr align='center'>
-			<td>标题</td>
-			<td>是否在售</td>
-			<td>配图类型</td>
-			<td>色号</td>
-			<td>曲度</td>
-			<td>备注</td>
-			<td style='height:100px;width:200px;'>图片</td>
-			<td>开发人</td>
-			<td>工艺流程</td>
-			<td>添加时间</td>
-            </tr>
-            </table>";
-            $filename = $title.".xls";
-			$tail = "";
-            $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
+			$title = "新品/新色配图"; 
+			$this->_excel($info_list,$title.".xls");
+			// echo "<pre>";
+			// var_dump($info_list);
+			// die;
+		    // $title = "新品/新色配图"; 
+            // $titlename = "<table border=1>
+            // <tr align='center'>
+			// <td>标题</td>
+			// <td>是否在售</td>
+			// <td>配图类型</td>
+			// <td>色号</td>
+			// <td>曲度</td>
+			// <td>备注</td>
+			// <td style='height:100px;width:200px;'>图片</td>
+			// <td>开发人</td>
+			// <td>工艺流程</td>
+			// <td>添加时间</td>
+            // </tr>
+            // </table>";
+            // $filename = $title.".xls";
+			// $tail = "";
+            // $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
     }
+
+
+	private function _excel($info_list,$filename){
+		$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
+		<head>
+		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
+		<!--[if gte mso 9]>
+		<xml>
+			<x:ExcelWorkbook>
+				<x:ExcelWorksheets>
+					<x:ExcelWorksheet>
+						<x:Name>新品/新色配图</x:Name>
+						<x:WorksheetOptions>
+							<x:Print>
+								<x:ValidPrinterInfo />
+							</x:Print>
+						</x:WorksheetOptions>
+					</x:ExcelWorksheet>
+				</x:ExcelWorksheets>
+			</x:ExcelWorkbook>
+		</xml>
+		<![endif]-->
+		<style>
+			tr { mso-height-source: auto; }
+			.fixed-height { 
+				height: 100px; /* 设置固定行高 */
+				mso-height-source: userset; /* 强制Excel使用设定高度 */
+			}
+				
+			
+			
+		</style>
+		</head>
+		<body>";
+		
+		$str .= "<table border='1' cellspacing='0' style='border-collapse: collapse; font-family: Microsoft Yahei; font-size: 13px;'>"; 
+		$str .= " 
+		<tr align='center'>
+		<td>标题</td>
+		<td>是否在售</td>
+		<td>配图类型</td>
+		<td>色号</td>
+		<td>曲度</td>
+		<td>备注</td>
+		<td>图片</td>
+		<td>开发人</td>
+		<td>工艺流程</td>
+		<td>添加时间</td>
+		</tr>";
+		foreach($info_list as $key => $value){
+			$str .= "<tr class='fixed-height'>"; 
+			$str .= "<td>".$value['title']."</td>";   
+			$str .= "<td>".$value['state']."</td>";   
+			$str .= "<td>".$value['type']."</td>";   
+			$str .= "<td>".$value['color']."</td>";
+			$str .= "<td>".$value['lowe']."</td>";
+			$str .= "<td>".$value['content']."</td>";
+			$str .= '<td ><table border="0"><tr class="fixed-height" >';
+				foreach($value['img'] as $v){
+					$str .= "<td >".$v."</td>";
+				}
+			
+			$str .='</table></td>';    
+			$str .= "</tr>";
+		}
+		
+		
+		$str .= "</table></body></html>"; 
+		
+		header("Content-Type: application/vnd.ms-excel; charset=utf-8"); 
+		header("Content-Disposition: attachment; filename=".$filename); 
+		header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
+		header("Pragma: no-cache"); 
+		header("Expires: 0"); 
+		exit($str); 
+	}
 }