4 changed files with 346 additions and 2 deletions
@ -0,0 +1,146 @@ |
|||
@{ |
|||
ViewData["Title"] = "工單KeyParts查詢2"; |
|||
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
|||
} |
|||
|
|||
<div class="layui-card"> |
|||
<div class="layui-card-header"> |
|||
<div class="layui-form"> |
|||
<div class="layui-form-item "> |
|||
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
|||
</div> |
|||
<div class="layui-form-item layui-layout-left"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">工單號碼:</label> |
|||
<div class="layui-input-inline" style="width:150px"> |
|||
<input id="wipNO" name="wipNo" autocomplete="off" class="layui-input" placeholder="請輸入工單號碼"> |
|||
<input id="factoryNo" type="hidden" name="factoryNo" value="@ViewBag.UserFactory" /> |
|||
</div> |
|||
</div> |
|||
<div class="layui-inline layui-show-xs-block"> |
|||
<button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="querysubmit" onclick="result()"> |
|||
<i class="layui-icon layui-icon-sm"></i> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-card-body"> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
@section Scripts{ |
|||
<script type="text/javascript"> |
|||
layui.config({ |
|||
base: '../lib/layui_ext/', |
|||
}).extend({ |
|||
excel: 'excel', |
|||
}); |
|||
</script> |
|||
|
|||
<script type="text/javascript"> |
|||
|
|||
function formatJSONDate(jsonDate) { |
|||
if (jsonDate == null) { |
|||
return ""; |
|||
} |
|||
else { |
|||
var date = eval(jsonDate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)")); |
|||
var myDate = new Date(date); |
|||
var yy = myDate.getFullYear(); |
|||
var mm = (myDate.getMonth() + 1 < 10 ? '0' : '') + (myDate.getMonth() + 1); |
|||
var dd = (myDate.getDate() < 10 ? '0' : '') + myDate.getDate(); |
|||
var h = (myDate.getHours() < 10 ? '0' : '') + myDate.getHours(); |
|||
var m = (myDate.getMinutes() < 10 ? '0' : '') + myDate.getMinutes(); |
|||
var s = (myDate.getSeconds() < 10 ? '0' : '') + myDate.getSeconds(); |
|||
//mm + "/" + dd + " " + |
|||
//var output = yy + "-" + mm + "-" + dd + " " + h + ":" + m + ":" + s; |
|||
var output = yy + mm + dd + h + m + s; |
|||
// myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds(); |
|||
return output; |
|||
} |
|||
} |
|||
|
|||
layui.use(['jquery', 'excel', 'layer'], function () { |
|||
var $ = layui.jquery; |
|||
var layer = layui.layer; |
|||
var excel = layui.excel; |
|||
|
|||
$('#btnExport').on('click', function () { |
|||
|
|||
$.ajax({ |
|||
url: '@Url.Action("QRS013A", "QRS")', |
|||
data: { "wipNO": $("#wipNO").val() }, |
|||
dataType: 'json', |
|||
success(res) { |
|||
var data = res.data; |
|||
|
|||
var keys = []; |
|||
var cols1 = []; |
|||
var cols2 = []; |
|||
var cols = {}; |
|||
var i = 0; |
|||
var cols_title = ""; |
|||
for (var item in data[0]) |
|||
{ |
|||
//alert(item); |
|||
//alert(data[0][item]); |
|||
keys.push(item); |
|||
|
|||
cols1[i] = item; |
|||
cols_title = cols_title + item.toString() + ","; |
|||
//cols2[i] = item.toString() + ":\"" + item.toString() + "\""; |
|||
//cols2[i] = item + ":" + item.toString(); |
|||
i = i + 1; |
|||
cols2.push(item); |
|||
} |
|||
|
|||
var cols_header = cols_title.substring(0, cols_title.length - 1); |
|||
|
|||
|
|||
//data.unshift({ wipno: "wipno" }); |
|||
|
|||
//data = excel.filterExportData(data, cols2); |
|||
//data.unshift({ keys }); |
|||
//data.unshift(cols1); |
|||
data.unshift({ wipno: "WipNo", barcodeno: "BarcodeNo", extrabarcodeno: "ExtraBarcodeNo", modelno: "ModelNo", itemno: "ItemNo" }); |
|||
|
|||
var timestart = Date.now(); |
|||
excel.downloadExcel(data, '組件明細' + formatJSONDate(Date.now().toString()), 'xlsx'); |
|||
|
|||
//excel.exportExcel(data, '組件明細' + formatJSONDate(Date.now().toString()) + '.xlsx', 'xlsx'); |
|||
|
|||
var timeend = Date.now(); |
|||
|
|||
var spent = (timeend - timestart) / 1000; |
|||
layer.alert('導出數據耗時 ' + spent + ' s'); |
|||
} |
|||
, error() { |
|||
layer.alert('導出數據失敗'); |
|||
} |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
layui.use(['form', 'layer'], function () { |
|||
form = layui.form; |
|||
}); |
|||
|
|||
function result() |
|||
{ |
|||
var wipNO = $("#wipNO").val(); |
|||
|
|||
|
|||
var query = "?wipNO=" + wipNO; |
|||
hg.open('工單KeyParts查詢2', '/QRS/QRS017A' + query, '', '', true); |
|||
|
|||
}; |
|||
|
|||
//监听表单提交事件 |
|||
hg.form.onsubmit('querysubmit', function (data) { |
|||
table && table.reload(data); |
|||
}); |
|||
|
|||
</script> |
|||
} |
@ -0,0 +1,65 @@ |
|||
@{ |
|||
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
|||
} |
|||
|
|||
<div class="layui-card"> |
|||
<div class="layui-card-header"> |
|||
<div class="layui-form"> |
|||
<div class="layui-form-item "> |
|||
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
<div class="layui-card-body"> |
|||
<button type="button" onclick="tableToExcel('kplist','組件明細')" class="layui-btn layui-btn-normal layui-btn-sm"><i class="fa fa-file-excel-o"></i>導出Excel</button> |
|||
<br /> |
|||
<br /> |
|||
@Html.Raw(ViewData["KpDataList"]) |
|||
</div> |
|||
</div> |
|||
<script type="text/javascript"> |
|||
|
|||
function formatJSONDate(jsonDate) { |
|||
if (jsonDate == null) { |
|||
return ""; |
|||
} |
|||
else { |
|||
var date = eval(jsonDate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)")); |
|||
var myDate = new Date(date); |
|||
var yy = myDate.getFullYear(); |
|||
var mm = (myDate.getMonth() + 1 < 10 ? '0' : '') + (myDate.getMonth() + 1); |
|||
var dd = (myDate.getDate() < 10 ? '0' : '') + myDate.getDate(); |
|||
var h = (myDate.getHours() < 10 ? '0' : '') + myDate.getHours(); |
|||
var m = (myDate.getMinutes() < 10 ? '0' : '') + myDate.getMinutes(); |
|||
var s = (myDate.getSeconds() < 10 ? '0' : '') + myDate.getSeconds(); |
|||
//mm + "/" + dd + " " + |
|||
//var output = yy + "-" + mm + "-" + dd + " " + h + ":" + m + ":" + s; |
|||
var output = yy + mm + dd + h + m + s; |
|||
// myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds(); |
|||
return output; |
|||
} |
|||
} |
|||
|
|||
function base64(content) |
|||
{ |
|||
return window.btoa(unescape(encodeURIComponent(content))); |
|||
} |
|||
|
|||
function tableToExcel(tableID, fileName) { |
|||
var table = document.getElementById(tableID); |
|||
var excelContent = table.innerHTML; |
|||
var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>"; |
|||
excelFile += "<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head>"; |
|||
excelFile += "<body><table>"; |
|||
excelFile += excelContent; |
|||
excelFile += "</table></body>"; |
|||
excelFile += "</html>"; |
|||
var link = "data:application/vnd.ms-excel;base64," + base64(excelFile); |
|||
var a = document.createElement("a"); |
|||
a.download = fileName + formatJSONDate(Date.now().toString()) + ".xls"; |
|||
a.href = link; |
|||
a.click(); |
|||
} |
|||
|
|||
</script> |
Loading…
Reference in new issue