lvhao пре 1 месец
родитељ
комит
264e9a1e24
2 измењених фајлова са 291 додато и 356 уклоњено
  1. 225 305
      core/CoreApp/controllers/Whlabel.php
  2. 66 51
      template/erp/whlabel_typejs.html

+ 225 - 305
core/CoreApp/controllers/Whlabel.php

@@ -190,9 +190,10 @@ class Whlabel extends Start_Controller
 			$this->_excelrjs();
 		} else if($arg == 'excelctjs'){
 			$this->_excelctjs();
-		}else if($arg == 'excelcrjs'){
-			$this->_excelcrjs();
-		}else if($arg == "w_t_cs"){
+		}else if ($arg == 'exceljxcjs') //进销存信息导出
+		{
+			$this->_exceljxcjs();
+		} else if($arg == "w_t_cs"){
 			$this->_w_t_cs(); //首页
 		}else {
 			$this->_index();
@@ -7704,22 +7705,6 @@ class Whlabel extends Start_Controller
 				$list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
 			}
 			
-			// $list = [
-			// 	[
-			// 		'warehouse'=>"许昌仓",
-			// 		'sku'=>"123456",
-			// 		'title'=>"商品名称",
-			// 		'time'=>"2021-01-01 12:00:00",
-			// 		'number'=>"121-111121"
-			// 	],
-			// 	[
-			// 		'warehouse'=>"美仓",
-			// 		'sku'=>"353456",
-			// 		'title'=>"商品名称1",
-			// 		'time'=>"2021-01-01 12:01:00",
-			// 		'number'=>"121-1333121"
-			// 	],
-			// ];
 			if(empty($list)){
 				exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
 			}else{
@@ -7735,7 +7720,16 @@ class Whlabel extends Start_Controller
 				array_unshift($final_list,[
 					$title,"","","",""
 				]);
-				exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
+				$merges = [
+					[
+						"s"=>["r"=>0,"c"=>0],
+						"e"=>["r"=>0,"c"=>4]
+					]
+				];
+				$cols = [
+					["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
+				];
+				exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
 			}
 		}
 	}
@@ -8033,10 +8027,6 @@ class Whlabel extends Start_Controller
 				if(empty($final_list)){
 					exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
 				}else{
-					// $final_list = [];
-					// foreach($list as $v){
-					// 	$final_list[] = array_values($v);
-					// }
 					$end_list = [];
 					foreach($final_list as $v){
 						$end_list[] = array_values($v);
@@ -8047,32 +8037,23 @@ class Whlabel extends Start_Controller
 						"仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
 					]);
 					array_unshift($end_list,[
-						$title,"","","",""
+						$title,"","","","","","","","",""
 					]);
-					exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
+
+					$merges = [
+						[
+							"s"=>["r"=>0,"c"=>0],
+							"e"=>["r"=>0,"c"=>9]
+						]
+					];
+					$cols = [
+						["wch"=>"10"],["wch"=>"10"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
+					];
+					exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
+						'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
+					] )));
 				}
 
-				
-				
-				// $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
-				// $titlename = "<table border=1>
-                // <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
-                // <tr align='center'>
-				// <td>仓库</td>
-				// <td>供应商</td>
-			    // <td>SKU</td>
-                // <td>商品名称</td>
-				// <td>商品中文</td>
-                // <td>标签</td>
-                // <td>订单号</td>
-				// <td>订单编码</td>
-                // <td>运单号</td>
-			    // <td>" . $tl . "时间(中国时间)</td>
-                // </tr>
-                // </table>";
-				// $filename = $title . ".xls";
-				// $tail = "";
-				// $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
 			} else if ($type == 5) {
 				$info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
 				
@@ -8118,36 +8099,21 @@ class Whlabel extends Start_Controller
 						"仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
 					]);
 					array_unshift($final_list,[
-						$title,"","","",""
+						$title,"","","","","","",
 					]);
-					exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
-				}
-
-				// $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
-				// $titlename = "<table border=1>
-                // <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
-                // <tr align='center'>
-				// <td>仓库</td>
-				// <td>供应商</td>
-			    // <td>SKU</td>
-                // <td>商品名称</td>
-				// <td>商品中文</td>
-                // <td>标签</td>
-			    // <td>" . $tl . "时间(中国时间)</td>
-                // </tr>
-                // </table>";
-				// $filename = $title . ".xls";
-				// $tail = "";
-				// $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
+					$merges = [
+						[
+							"s"=>["r"=>0,"c"=>0],
+							"e"=>["r"=>0,"c"=>6]
+						]
+					];
+					$cols = [
+						["wch"=>"10"],["wch"=>"10"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"]
+					];
+					exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
+				}
+
 			} else {
-				/**
-				$info_list = $this->whlabel->find_all($where.$sidwhere,'*');
-				$rows = array();$list = array();
-				foreach ($info_list as $key=>$value) 
-		    	{
-					$rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
-		    	}
-				 **/
 				$wh = array();
 				$w = $this->warehouse->find_all('1=1', 'id,title');
 				foreach ($w as $v) {
@@ -8223,42 +8189,10 @@ class Whlabel extends Start_Controller
 
 					$features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
 					$features = explode('-', trim($features, '-'));
-					// $pm = $classid;
-					// foreach ($features as $k => $v) {
-					// 	if ($v != 0) {
-					// 		if (!isset($typeclass[$v])) {
-					// 			continue;
-					// 		}
-					// 		if (isset($pm[$typeclass[$v]['classid']])) {
-					// 			if (stripos($typeclass[$v]['zh'], '|') !== false) {
-					// 				$tz = explode('|', $typeclass[$v]['zh']);
-					// 				$pm[$typeclass[$v]['classid']] = $tz[0];
-					// 			} else {
-					// 				$pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
-					// 			}
-					// 			if (isset($jm[$typeclass[$v]['classid']])) {
-					// 				if ($typeclass[$v]['jm']) {
-					// 					$jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
-					// 				}
-					// 			}
-					// 		}
-					// 	}
-					// }
-					// $zh = implode(" ", $pm);
-					// $zh = str_replace('自然色 ', '', trim($zh, ' '));
-					// $zh = str_replace(array('        ', '       ', '      ', '     ', '    ', '   ', '  '), ' ', $zh);
-					// $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
-					// $rows[$key]['features'] = $zh;
-					// $jm = array_filter($jm); //去除空值
-					// $jm = implode("-", $jm);
-					// $rows[$key]['jm'] = $jm;
 					$rows[$key]['asd'] = $typeclass[$features[0]]['title'];
 				}
 				
 				$tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
-				// echo "<pre>";
-				// print_r($tmp_list);
-				// die;
 				$final_list =[];
 				foreach($tmp_list as $k=>$v){
 					$final_list[] = [
@@ -8299,216 +8233,202 @@ class Whlabel extends Start_Controller
 					array_unshift($end_list,[
 						$title,"","","",""
 					]);
-					exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
-				}
-
-				// $titlename = "<table border=1>
-            	// <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
-            	// <tr align='center'>
-				// <td>仓库</td>
-				// <td>供应商</td>
-				// <td>位置</td>
-			    // <td>库存编码</td>
-				// <td>SKU</td>
-            	// <td>商品名称</td>
-				// <td>商品中文</td>
-				// <td>产品备注</td>
-				// <td>说明</td>
-				// <td>类型</td>
-				// <td>入库总量</td>
-            	// <td>库存数量</td>
-            	// <td>销售数量</td>
-				// <td>退货数量</td>
-				// <td>占单数量</td>
-				// <td>料号</td>
-				// <td>重量</td>
-				// <td>类目</td>
-            	// </tr>
-            	// </table>";
-				// $filename = $title . ".xls";
-				// $tail = "";
-				// $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
+					$merges = [
+						[
+							"s"=>["r"=>0,"c"=>0],
+							"e"=>["r"=>0,"c"=>6]
+						]
+					];
+					$cols = [
+						["wch"=>"10"],["wch"=>"10"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"]
+					];
+					exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
+						'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
+					])));
+				}
+
 			}
 		}
 	}
 
-	//出库+入库数据整合
-	public function _excelcrjs()
-	{
-		if (isset($_GET['excel'])) {
-			$type = $this->input->get('excel', true);
-			$category = $this->input->get('category', true);
-			$size = $this->input->get('size', true);
-			$grade = $this->input->get('grade', true);
-			$color = $this->input->get('color', true);
-			$lowe = $this->input->get('lowe', true);
-			$sku = $this->input->get('sku', true);
-			$warehouse = $this->input->get('warehouse', true);
-			$purchase = $this->input->get('purchase', true);
-			$state = $this->input->get('state', true);
-			$sid = $this->input->get('sid', true);
-			$ktime = $this->input->get('ktime', true);
-			$jtime = $this->input->get('jtime', true);
-			$ktime = strtotime($ktime);
-			$jtime = strtotime($jtime);
-			$where = "1=1";
-			$gj = "";
-			$ck = "";
-			if ($category) {
-				$where  .= " and features like '%-$category-%'";
-			}
-			if ($size) {
-				$where  .= " and features like '%-$size-%'";
-			}
-			if ($grade) {
-				$where  .= " and features like '%-$grade-%'";
-			}
-			if ($color) {
-				$where  .= " and features like '%-$color-%'";
-			}
-			if ($lowe) {
-				$where  .= " and features like '%-$lowe-%'";
-			}
-			if ($warehouse) {
-				$where  .= " and warehouse = '$warehouse'";
-			}
-			if ($purchase) {
-				$where  .= " and purchase = '$purchase'";
-			}
-			if ($state) {
-				$where  .= " and state = '$state'";
-			}
-			if ($sku) {
-				$where  .= " and sku like '%$sku%'";
-			}
-			if ($ktime && $jtime) {
-				$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
-			}
-			$sidwhere = '';
-			if ($sid) {
-				$sd = "";
-				$s = explode(',', trim($sid, ','));
-				foreach ($s as $value) {
-					$sd .= " id = " . $value . " or";
-				}
-				$sidwhere  .= " and (" . rtrim($sd, 'or') . ")";
-			}
-
-			//取得信息列表
-			$timeread  = $ktime;
-			$timenum = ceil(($jtime - $ktime) / (24 * 3600));
-			$timelist = array();
-			for ($i = 0; $i < $timenum; $i++) {
-				$timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
-				$timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
+	public function _exceljxcjs(){
+		$classid = $this->classid->sku();
+		$pm = $classid;
+		$typeclass = array();
+		$tc = $this->typeclass->find_all();
+		foreach ($tc as $v) {
+			$typeclass[$v['id']] = $v;
+		}
+		$prc = array();
+		$purchase = $this->purchase->find_all();
+		foreach ($purchase as $k => $v) {
+			$prc[$v['id']] = $v['title'];
+		}
+		if(!isset($_GET['excel'])){
+			exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
+		}
+		
+		$where = "sku != 'Preset'";
+		//数据排序
+		$order_str = "id desc";
+		if (empty($page)) {
+			$start = 0;
+			$perpage = 1;
+		} else {
+			$start = ($page - 1) * $perpage;
+		}
+		$category = $this->input->get('category', true);
+		$warehouse = $this->input->get('warehouse', true);
+		$excelid = $this->input->get('sid', true);
+		if ($category) {
+			$where  .= " and features like '%-$category-%'";
+		}
+		if ($warehouse) {
+			$where  .= " and warehouse = '$warehouse'";
+		}
+		$xzid = '';
+		if ($excelid) {
+			$excelid = explode(',', trim($excelid, ','));
+			foreach ($excelid as $key => $value) {
+				$xzid .= " id = " . $value . " or";
 			}
+			$xzid = " and (" . rtrim($xzid, 'or') . ")";;
+		}
+		
 
-			$info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
-			//echo "<pre>";
-			//print_r($info_list);
-			//exit();
-			$rows = array();
-			$list = array();
-			foreach ($info_list as $key => $value) {
-				$thistime = $timelist;
-				if (isset($rows[strtolower($value['sku'])])) {
-					if ($value['outk'] > $ktime && $value['state'] < $jtime) {
-						$rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
-					}
-					if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
-						$rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
-					}
-				} else {
-					if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
-						$thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
+		$wt = array();
+		$whlabel_type = $this->whlabel_type->find_all();
+		foreach ($whlabel_type as $v) {
+			$wt[$v['id']] = $v['title'];
+		}
+		$wh = array();
+		$w = $this->warehouse->find_all('1=1', 'id,title');
+		foreach ($w as $v) {
+			$wh[$v['id']] = $v['title'];
+		}
+		$list = array();
+		$rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
+		foreach ($rows as $key => $value) {
+			if (isset($wt[$value['type']])) {
+				$rows[$key]['type'] = $wt[$value['type']];
+			} else {
+				$rows[$key]['type'] = '未设置';
+			}
+			$bm = '03';
+			$bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
+			$rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
+			$sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
+			$details = array();
+			$cpid = array();
+			$cpbz = array();
+			$c = 0;
+			$g = 0;
+			$x = 0;
+			$t = 0;
+			$s = 0;
+			$q = 0;
+			foreach ($sd as $k => $v) {
+				if ($v['state'] == 0) {
+					$c++;
+					if ($v['cpid'] != 0) {
+						$cpid[$v['cpid']] = $v['cpid'];
 					}
-					if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
-						$thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
+					if ($v['cpbz'] != '') {
+						$cpbz[$v['cpbz']] = $v['cpbz'];
 					}
-					$rows[strtolower($value['sku'])] = $thistime;
 				}
+				if ($v['state'] != 9) {
+					$g++;
+				}
+				if ($v['state'] == 1) {
+					$x++;
+				}
+				if ($v['state'] == 2) {
+					$t++;
+				}
+				if ($v['state'] == 8) {
+					$s++;
+				}
+				if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
+					$q++;
+				}
+				$details[$v['details']] = $v['details'];
 			}
+			$z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
+			$rows[$key]['details'] = implode("、", $details);
+			$rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
+			$number = $value['number'];
+			$ftime = time() - 15 * 24 * 3600;
+			$rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
+			$rows[$key]['number'] = $g;
+			$rows[$key]['c'] = $c;
+			$rows[$key]['x'] = $x;
+			$rows[$key]['t'] = $t;
+			$rows[$key]['s'] = $s;
+			$rows[$key]['q'] = $q;
+			$rows[$key]['z'] = $z;
 
-			if(empty($rows)){
-				exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
-			}else{
-				$final_list = [];
-				foreach($rows as $k=>$v){
-					$tmp = [];
-					$tmp[] = $k;
-					foreach($v as $kk=>$vv){
-						$tmp[] = $vv['c'];
-						$tmp[] = $vv['r'];
-					}
-					$final_list[] = $tmp;
-				}
-				$title = date("Y-m-d H:i:s"). "详情";
-				$first_line = [];
-				$first_line[] = "SKU";
-				$send_line = [];
-				$send_line[] = $title;
-				foreach ($timelist as $k => $v) {
-					$first_line[] = $k . "出库";
-					$first_line[] = $k . "入库";
-					$send_line[] = " ";
-					$send_line[] = " ";
-				}
-
-				array_unshift($final_list,$first_line);
-				array_unshift($final_list,$send_line);
-				
-				exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
-			}
-
-
-			// $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
-       	 	// <head>
-        	// <!--[if gte mso 9]><xml>
-        	// <x:ExcelWorkbook>
-       		// <x:ExcelWorksheets>
-       		// <x:ExcelWorksheet>
-        	// <x:Name>EXCEL</x:Name>
-       		// <x:WorksheetOptions>
-        	// <x:Print>
-        	// <x:ValidPrinterInfo />
-        	// </x:Print>
-        	// </x:WorksheetOptions>
-        	// </x:ExcelWorksheet>
-        	// </x:ExcelWorksheets>
-        	// </x:ExcelWorkbook>
-        	// </xml>
-        	// <![endif]-->
-        	// </head><body>";
-
-			// $str .= "<table border=1><tr><td>SKU</td>";
-			// foreach ($timelist as $k => $v) {
-			// 	$str .= "<td>" . $k . "出库</td>";
-			// 	$str .= "<td>" . $k . "入库</td>";
-			// }
-			// $str .=  "</tr></table>";
-			// $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
-			// foreach ($rows as $key => $val) {
-			// 	$str .= "<tr><td>" . strtoupper($key) . "</td>";
-			// 	foreach ($val as $k => $v) {
-			// 		$str .= "<td>" . $val[$k]['c'] . "</td>";
-			// 		if ($val[$k]['r'] > 0) {
-			// 			$str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
-			// 		} else {
-			// 			$str .= "<td>" . $val[$k]['r'] . "</td>";
-			// 		}
-			// 	}
-			// 	$str .=  "</tr>";
-			// }
-			// $str .= "</table>";
-			// $str .= "</body></html>";
-			// header("Content-Type: application/vnd.ms-excel; name='excel'");
-			// header("Content-type: application/octet-stream");
-			// header("Content-Disposition: attachment; filename=" . time() . '.xls');
-			// header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-			// header("Pragma: no-cache");
-			// header("Expires: 0");
-			// exit($str);
+			$features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
+			$features = explode('-', trim($features, '-'));
+			$rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
+		
+
+		}
+		$list  = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
+
+		$final_list = [];
+		foreach ($list as $k => $v) {
+			if (empty($v['sku'])) {
+				continue;
+			}
+			$final_list[] = [
+				 $v["warehouse"],
+				 $v["purchase"],
+				 $v["details"],
+				 $v["cpid"],
+				 $v["dbcontent"],
+				 $v["sku"],
+				 $v["bm"],
+				 $v["jm"],
+				 $v["title"],
+				 $v["pm"],
+				 $v["cpbz"],
+				 $v["sm"],
+				 $v["type"],
+				 $v["number"],
+				 $v["c"],
+				 $v["x"],
+				 $v["t"],
+				 $v["s"],
+				 $v["q"],
+				 $v["z"],
+				 $v['weight'],
+			];
+		}
+
+		if(empty($final_list)){
+			exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
 		}
+		$title = "总进销存统计表";
+
+		$first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
+		$merges = [
+			[
+				"s"=>["r"=>0,"c"=>0],
+				"e"=>["r"=>0,"c"=>21]
+			]
+		];
+		$cols = [
+			["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
+			["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
+			["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
+		];
+
+		array_unshift($final_list, $first_row);
+		array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
+
+		exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
+	
 	}
 
 }

+ 66 - 51
template/erp/whlabel_typejs.html

@@ -201,11 +201,11 @@
 <option data-url="excelct" value="4">导出出库+零售数据</option>
 <option data-url="excelcr" value="4">导出出库+入库合数据</option>
 </select>
-<a href="javascript:void(0);" data-url="exceljxc" data-id="1" class="whlabelexcel">导出进销存</a>
-<a href="javascript:void(0);" data-url="excelct" data-id="3" class="whlabelexcel">导出条件检索</a>
+<a href="javascript:void(0);" data-url="exceljxc" data-id="1" class="whlabelexceljs">导出进销存</a>
+<a href="javascript:void(0);" data-url="excelct" data-id="3" class="whlabelexceljs">导出条件检索</a>
 <a href="javascript:void(0);" class="summary">出库汇总</a>
 
-<a href="javascript:void(0);" data-url="presetout" data-id="3" class="whlabelexcel">导出库存模板</a>
+<a href="javascript:void(0);" data-url="presetout" data-id="3" class="whlabelexceljs">导出库存模板</a>
 <a href="javascript:void(0);" class="whlabeldr">导入库存</a>
 {if $vip > 0} {/if}
 <a href="javascript:void(0);" class="whlabelxq">导出数据详情</a>
@@ -279,10 +279,10 @@ $(this).find('td:eq(15)').css("width","12%");
 });}
 
 $(".whlabelxq").click(function() {
-window.location.href = "http://1.wepolicy.cn/whlabel/uck?excel=1";
+window.location.href = "/whlabel/uck?excel=1";
 });
 $(".whlabelexcelzh").click(function() {
-window.location.href = "http://1.wepolicy.cn/whlabel/whlabelexcelzh?excel=1";
+window.location.href = "/whlabel/whlabelexcelzh?excel=1";
 });
 $(".plszbhtype").click(function() {
             $(".systemwindow").show();
@@ -379,7 +379,7 @@ $(".dccrtype").click(function() {
         if($("select[name=dccz]").find("option:selected").data("url") == "excelcr"){
             layx.destroy('loadId');
             window.location.href = "/whlabel/"+$("select[name=dccz]").find("option:selected").data("url")+"?excel="+$("select[name=dccz]").find("option:selected").val()+"&"+f;
-	$("select[name=dccz] option:eq(0)").prop('selected','selected'); 
+	        $("select[name=dccz] option:eq(0)").prop('selected','selected'); 
 
         }else{
             let url = "/whlabel/"+$("select[name=dccz]").find("option:selected").data("url")+"js?excel="+$("select[name=dccz]").find("option:selected").val()+"&"+f;
@@ -387,7 +387,7 @@ $(".dccrtype").click(function() {
             $.get(url,{},function(res){
                 layx.destroy('loadId');
                 if(res.code == 1){
-                    importRukuData(res.data,res.title)
+                    importDataNoCol(res.data)
                 }else{
                     layx.alert('错误',res.msg,function(id,button){
                     },{dialogIcon:'error'});
@@ -397,58 +397,73 @@ $(".dccrtype").click(function() {
        
         
     });
-    //导出入库数据
-    function importRukuData(data,title){
-        const fileName = title+'.xlsx' ;
-        // 将数据转换为工作表
 
-        // 创建工作表
-        const worksheet = XLSX.utils.aoa_to_sheet(data);
 
-        // 定义合并区域
-        const merges = [
-            // 合并标题行 (A1:F1)
-            { s: { r: 0, c: 0 }, e: { r: 0, c: 4 } },
-        ];
-        worksheet['!cols'] = 
-        [
-            { wch: 15 }, 
-            { wch: 20 },  
-            { wch: 20 },  
-            { wch: 10 },  
-            { wch: 10 },  
-        ];
+$(".whlabelexceljs").click(function() {
+    var f = "";
+	var a = "";
+    $(".datatext input[name='check']:checked").each(function() {
+        a = a + $(this).val()+",";
+    });
+	f = f + "sid=" + a + "&";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+		
+		var str = $(this).val().replace(/\#/g,"%23");
+        f = f + $(this).attr("name") + "=" + str + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+    layx.load('loadId','导出中,请稍后',{shadable:0.6});
 
-        // 应用合并
-        worksheet["!merges"] = merges;
+	let url = excel+$(this).data("url")+"js?excel="+$(this).data("id")+"&"+f;
+    $.get(url,{},function(res){
+        layx.destroy('loadId');
+        if(res.code == 1){
+            importDataNoCol(res.data)
+        }else{
+            layx.alert('错误',res.msg,function(id,button){
+            },{dialogIcon:'error'});
+        }
+    },'json')
+});
+//导出第一行不含合并单元格的
+function importDataNoCol(data){
+    console.log(data.merges)
+    console.log(data.cols)
+    const fileName = data.title+'.xlsx' ;
+    // 将数据转换为工作表
 
-        // 设置标题样式(仅在Excel中可见)
-        worksheet.A1.s = {
-                font: { sz: 20, name: "微软雅黑", bold: true },
-                alignment: { horizontal: "center" }
-        };
-        // 创建工作簿
-        const workbook = XLSX.utils.book_new();
-        XLSX.utils.book_append_sheet(workbook, worksheet, title);
-        
-        // 导出文件
-        XLSX.writeFile(workbook, fileName);
-        
-        alert('合并报表已导出为 :'+fileName)
+    // 创建工作表
+    const worksheet = XLSX.utils.aoa_to_sheet(data.data);
 
+    // 定义合并区域
+    const merges = data.merges;
+    worksheet['!cols'] = data.cols;
 
-        return ;
-    
-       
+    // 应用合并
+    worksheet["!merges"] = merges;
 
-        // 将工作表添加到工作簿
-        XLSX.utils.book_append_sheet(workbook, worksheet, res.filename);
-        
-        // 导出文件
-        XLSX.writeFile(workbook, fileName);
-        layx.destroy('loadId');
-    }
+    // 设置标题样式(仅在Excel中可见)
+    worksheet.A1.s = {
+            font: { sz: 20, name: "微软雅黑", bold: true },
+            alignment: { horizontal: "center" }
+    };
+    // 创建工作簿
+    const workbook = XLSX.utils.book_new();
+    XLSX.utils.book_append_sheet(workbook, worksheet, data.title);
     
+    // 导出文件
+    XLSX.writeFile(workbook, fileName);
+    
+    alert('合并报表已导出为 :'+fileName)
+
+
+    return ;
+}
 </script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>
 <div style="display:none;">