修改匯出流程
This commit is contained in:
		
							parent
							
								
									2c3704f5a6
								
							
						
					
					
						commit
						06d0e84782
					
				| @ -84,6 +84,7 @@ | ||||
|         initApp.buildNavigation($('#js_nested_list')); | ||||
| 
 | ||||
|         loadTable(null); | ||||
| 		$(`[onclick="setDateType('today')"]`).click(); | ||||
|     }); | ||||
| 
 | ||||
|     function initList() { | ||||
| @ -186,12 +187,12 @@ | ||||
| 		var edt = new Date(new Date().setDate(sdt.getDate() + 1)); | ||||
|         start = start ?? sdt.toLocaleDateString(); | ||||
|         end = end ?? edt.toLocaleDateString(); | ||||
|         getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, | ||||
| 			new Date(start).getTime(), | ||||
| 			new Date(end).getTime(), | ||||
| 			pageAct.deviceName, | ||||
|             "Mitsubishi_Sup", | ||||
| 		    callBackFromHistory); | ||||
|    //     getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, | ||||
| 			//new Date(start).getTime(), | ||||
| 			//new Date(end).getTime(), | ||||
| 			//pageAct.deviceName, | ||||
|    //         "Mitsubishi_Sup", | ||||
| 		 //   callBackFromHistory); | ||||
|     } | ||||
| 
 | ||||
|     function callBackFromHistory(res) { | ||||
| @ -290,7 +291,7 @@ | ||||
| 		let column_defs = [ | ||||
| 			{ "targets": [0], "width": "20%", "sortable": true }, | ||||
| 			{ "targets": [1], "width": "20%", "sortable": true }, | ||||
| 			{ "targets": [2], "width": "20%", "sortable": true }, | ||||
|             { "targets": [2], "width": "20%", "sortable": true } | ||||
| 		]; | ||||
| 
 | ||||
| 		let columns = [ | ||||
| @ -308,7 +309,7 @@ | ||||
|                 "render": function (date) { | ||||
| 					return displayDate(date, "datetime"); | ||||
| 				} | ||||
| 			}, | ||||
|             } | ||||
|         ]; | ||||
| 
 | ||||
| 		historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); | ||||
| @ -316,8 +317,16 @@ | ||||
| 
 | ||||
|     function exportExcel() { | ||||
|         let url = baseApiUrl + "/History/OpeExportExcel"; | ||||
|         objSendData.Data = $('#historyTable').dataTable().fnGetData();; | ||||
|         objSendData.Data = $('#historyTable').dataTable().fnGetData(); | ||||
|          | ||||
|         $.each(objSendData.Data, function (i, v) { | ||||
| 			v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#startdate').val())); | ||||
|             v.endtime = $('#enddate input').val() === "" ? null : new Date($('#enddate input').val()); | ||||
|             v.dateType = pageAct.dateType; | ||||
|         }); | ||||
| 
 | ||||
|         ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) { | ||||
|             if (rel.code == "0000") | ||||
| 			    location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization"); | ||||
|         }, null, "POST").send(); | ||||
| 	} | ||||
|  | ||||
| @ -55,7 +55,8 @@ namespace FrontendWebApi.ApiControllers | ||||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 var fileName = "廠商資料.xlsx"; | ||||
|                 var fileDateName = lhe.FirstOrDefault().dateType == "month" ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM") : lhe.FirstOrDefault().endtime == null ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") : lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") + "_" + ((DateTime)lhe.FirstOrDefault().endtime).ToString("yyyy-MM-dd"); | ||||
|                 var fileName = "廠商資料_"+fileDateName+".xlsx"; | ||||
|                 var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", "history"); | ||||
| 
 | ||||
|                 if (!System.IO.Directory.Exists(filePath)) | ||||
|  | ||||
| @ -268,5 +268,8 @@ namespace FrontendWebApi.Models | ||||
|         public string deviceName { get; set; } | ||||
|         public int value { get; set; } | ||||
|         public DateTime timestamp { get; set; } | ||||
|         public DateTime starttime { get; set; } | ||||
|         public DateTime? endtime { get; set; } | ||||
|         public string dateType { get; set; } | ||||
|     } | ||||
| } | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user