You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

190 lines
6.7 KiB

@{
ViewData["Title"] = "清線明細維護";
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>
<input id="clearID" name="clearID" value="@ViewBag.ClearID" type="hidden" />
<input id="checkFlag" name="checkFlag" value="@ViewBag.checkFlag" type="hidden" />
</div>
</div>
</div>
<div class="layui-card-body">
<div id="tips">@Html.Raw(ViewData["Tips"])&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rev.A2</div>
<table class="layui-hide" id="test" name="test" lay-filter="test"> <thead><tr><th colspan="9">sdfsdfasdf</th></tr></thead></table>
</div>
</div>
@section Scripts{
<script type="text/javascript">
layui.config({
base: '../lib/layui_ext/',
}).extend({
excel: 'excel',
});
</script>
<script type="text/javascript">
layui.use(['form', 'table', 'excel'], function () {
table1 = layui.table;
form = layui.form;
excel = layui.excel;
});
//监听表单提交事件
hg.form.onsubmit('querysubmit', function (data) {
table && table.reload(data);
});
var tableCols = [[
{
field: 'clearDetailID',
width: 80,
title: '編號',
sort: true
},
{
field: 'stationName',
width: 160,
title: '站別名稱'
},
{
field: 'surplusFlag',
width: 120,
title: '是否缺料'
},
{
field: 'partNo',
title: '料號',
width: 160
},
{
field: 'qty',
title: '數量',
width: 80
},
{
field: 'reasonDesc',
title: '原因分析'
},
{
field: 'checkUser',
title: '確認人員',
width: 120
},
{
field: 'center',
width: 150,
title: '操作',
templet: function (d) {
if (checkFlag.value == 'Y') {
return ''
}
else {
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">修改</a> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">删除</a>'
}
}
}]
];
//通过行tool编辑,lay-event="edit"
function edit(obj) {
if (obj.data.clearDetailID) {
hg.open('修改清線明細', '/PCS/PCS037LU/' + obj.data.clearDetailID, 640, 480);
}
}
//通过行tool删除,lay-event="del"
function del(obj) {
var str = "刪除";
if (obj.data.clearDetailID) {
hg.confirm("清線明細:" + obj.data.clearDetailID + ",確定要" + str + "嗎?", function () {
$.ajax({
url: '/PCS/PCS037LD',
data: { id: obj.data.clearDetailID },
type: 'POST',
success: function (data) {
if (data.success) {
//obj.del(); //只删本地数据
hg.msghide(str + "成功!");
table && table.reload(data);
}
else {
hg.msg(data.msg);
}
},
error: function () {
hg.msg("网络请求失败!");
}
});
});
}
}
var toolbar = [{
text: '新增',
layuiicon: '&#xe608;',
class: 'layui-btn-normal',
handler: function () {
if (checkFlag.value != 'Y') {
hg.open('新增清線明细', '/PCS/PCS037LC/' + clearID.value, 640, 480);
}
}
},
{
text: '匯出Excel',
layuiicon: '',
class: 'layui-btn-normal',
handler: function () {
$.ajax({
url: '@Url.Action("GetWipClearDetails", "PCS")',
data: {
"id": clearID.value,
},
dataType: 'json',
type: "GET",
success(res) {
var data = res.data;
// 创建一个包含标题的 Excel 数据数组
var excelData = [];
var tipsText = $('#tips').text();
tipsText = tipsText.replace('Rev.A2', ' Rev.A2');
// 添加标题行
var titleRow = [
`${tipsText}`
];
excelData.push(titleRow);
// 将数据合并到 Excel 数据中
var filteredData = excel.filterExportData(data, [
'clearDetailID',
'stationName',
'surplusFlag',
'partNo',
'qty',
'reasonDesc',
'checkUser'
]);
filteredData.unshift({
clearDetailID: "編號", stationName: "站別名稱", surplusFlag: "是否缺料", partNo: "料號", qty: "數量", reasonDesc: "原因分析", checkUser: "確認人員"
});
excelData = excelData.concat(filteredData);
excel.downloadExcel(excelData, '清線資料Excel', 'xlsx');
}
, error() {
layer.alert('匯出失敗');
}
});
}
}];
//基本数据表格
var table = hg.table.datatable('test', '清線資料', '/PCS/GetWipClearDetails/' + clearID.value, {}, tableCols, toolbar, true, 'full-100', ['filter', 'print']);
</script>
}