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.
356 lines
14 KiB
356 lines
14 KiB
1 year ago
|
@{
|
||
|
ViewData["Title"] = "外包廠工時大表";
|
||
|
Layout = "~/Views/Shared/_AMESLayout.cshtml";
|
||
|
}
|
||
|
|
||
|
<div class="layui-card">
|
||
|
<div class="layui-card-header">
|
||
|
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div>
|
||
|
</div>
|
||
|
<div class="layui-form">
|
||
|
<div class="layui-form">
|
||
|
<div class="layui-form-item">
|
||
|
<div class="layui-inline" style="margin-right:0px;">
|
||
|
<label class="layui-inline layui-form-label" style="width:80px;">製程單位</label>
|
||
|
<div class="layui-input-inline" style="width: 90px; margin-right: 5px;">
|
||
|
@if (@ViewBag.FactoryUnitNo != null)
|
||
|
{
|
||
|
<select style="width:90px;" lay-filter="unitNo" lay-submit id="unitNo" lay-search name="unitNo">
|
||
|
@foreach (var indexFactoryUnit in @ViewBag.FactoryUnit)
|
||
|
{
|
||
|
@if (indexFactoryUnit.Value == @ViewBag.FactoryUnitNo)
|
||
|
{
|
||
|
<option value="@ViewBag.FactoryUnitNo" selected>@indexFactoryUnit.Text</option>
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
<option value="@indexFactoryUnit.Value">@indexFactoryUnit.Text</option>
|
||
|
}
|
||
|
}
|
||
|
</select>
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
<select style="width:90px;" lay-filter="unitNo" lay-submit id="unitNo" lay-search name="unitNo" asp-items="@ViewBag.FactoryUnit">
|
||
|
</select>
|
||
|
}
|
||
|
</div>
|
||
|
<input id="unitId" type="hidden" name="unitId" />
|
||
|
</div>
|
||
|
<div class="layui-inline" style="margin-right:5px;">
|
||
|
<label class="layui-inline layui-form-label">料號</label>
|
||
|
<div class="layui-input-inline">
|
||
|
<input type="text" name="modelname" id="modelname" placeholder="请输入料號" autocomplete="off" class="layui-input" value=@ViewBag.modelname>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-inline" style="margin-left:0px;">
|
||
|
<button id="btnSearch" class="layui-btn">
|
||
|
<i class="layui-icon"></i>搜索
|
||
|
</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group form-inline my-sm-1">
|
||
|
<button type="button" id="btnSubmit" class="layui-btn layui-btn-normal layui-btn-sm">確認</button>
|
||
|
</div>
|
||
|
<table id="MydataTable" class="layui-table">
|
||
|
<thead id="MyTabletHead">
|
||
|
<tr>
|
||
|
<th style="width:5%;">#</th>
|
||
|
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody id="MyTableTbody">
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
@section Scripts{
|
||
|
<script type="text/javascript">
|
||
|
var rdoUnitTypeValue = null;
|
||
|
var modelname = null;
|
||
|
var unit = null;
|
||
|
var lineID = null;
|
||
|
var meditID = null;
|
||
|
layui.use(['form', 'layer', 'laydate'], function () {
|
||
|
form = layui.form;
|
||
|
form.on('select(unitNo)', function (data) {
|
||
|
var data = $("#unitNo").val();
|
||
|
//console.log(data);
|
||
|
getableHeader(data);
|
||
|
|
||
|
});
|
||
|
form.on('button(btnSearch)', function (data) {
|
||
|
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
//function ttAddSelect(UnitType, ItemNo, Unit, LineId) {
|
||
|
// $.ajax({
|
||
|
|
||
|
// url: "/WHS/GetStandardWorkTimesAddDefault",
|
||
|
// data: {
|
||
|
// "UnitType": UnitType,
|
||
|
// "ItemNo": ItemNo,
|
||
|
// "Unit": Unit,
|
||
|
// "LineId": LineId,
|
||
|
// },
|
||
|
// dataType: 'json',
|
||
|
// type: 'GET',
|
||
|
// success: function (result) {
|
||
|
// $("#MydataTable").load("/WHS/GetStandardWorkTimesAddDefault");
|
||
|
// },
|
||
|
// error: function () {
|
||
|
// alert("Found error when using Ajax!!");
|
||
|
// }
|
||
|
// });
|
||
|
//};
|
||
|
|
||
|
|
||
|
//function Remove(i) {
|
||
|
// var table = document.getElementById('MydataTable');
|
||
|
// var _StandardID = null;
|
||
|
// for (var a = 1, row; row = table.rows[a]; a++) {
|
||
|
// var col = row.cells;
|
||
|
// if (a - 1 == i) {
|
||
|
// _StandardID = col[0].innerText;
|
||
|
// }
|
||
|
// }
|
||
|
// hg.confirm("系統:" + _StandardID + ",確定要刪除嗎?", function () {
|
||
|
|
||
|
// $.ajax({
|
||
|
// url: '/WHS/WHS003D',
|
||
|
// data: { id: _StandardID },
|
||
|
// type: 'POST',
|
||
|
// success: function (res) {
|
||
|
// if (res.success) {
|
||
|
// //obj.del(); //只删本地数据
|
||
|
// hg.msghide("刪除成功!", {
|
||
|
// icon: 6
|
||
|
// });
|
||
|
// modelname = $("#modelname").val();
|
||
|
// unit = $("#unitNo").val();
|
||
|
// lineID = $('#lineID').val();
|
||
|
// var url = '/WHS/WHS003?modelname=' + modelname + '&unitNo=' + unit + '&lineID=' + lineID;
|
||
|
// window.location.href = url;
|
||
|
// }
|
||
|
// else {
|
||
|
// hg.msg(data.msg);
|
||
|
// }
|
||
|
// },
|
||
|
// error: function () {
|
||
|
// hg.msg("网络请求失败!");
|
||
|
// }
|
||
|
// });
|
||
|
// });
|
||
|
//};
|
||
|
|
||
|
//通过行tool编辑,lay-event="del"
|
||
|
//function del(obj) {
|
||
|
// if (obj.data.standardID) {
|
||
|
// var str;
|
||
|
// str = "刪除";
|
||
|
// hg.confirm("系統:" + obj.data.standardID + ",確定要" + str + "嗎?", function () {
|
||
|
// $.ajax({
|
||
|
// url: '/WHS/WHS003D',
|
||
|
// data: { id: obj.data.standardID },
|
||
|
// type: 'POST',
|
||
|
// success: function (res) {
|
||
|
// if (res.success) {
|
||
|
// obj.del(); //只删本地数据
|
||
|
// hg.msghide(str + "成功!", {
|
||
|
// icon: 6
|
||
|
// });
|
||
|
// layui.table.reload('test', { page: { curr: $(".layui-laypage-em").next().html() } })
|
||
|
// }
|
||
|
// else {
|
||
|
// hg.msg(data.msg);
|
||
|
// }
|
||
|
// },
|
||
|
// error: function () {
|
||
|
// hg.msg("网络请求失败!");
|
||
|
// }
|
||
|
// });
|
||
|
// });
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
//function edit(i) {
|
||
|
// var label = document.getElementById("StandardWorkTimes[" + i + "].StandardID");
|
||
|
// meditID = label.innerText;
|
||
|
// var rowCount = $('#MydataTable tr').length;
|
||
|
// for (var x = 0; x < rowCount; x++) {
|
||
|
// if (x != i) {
|
||
|
// $("select[id='tabunitNo[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("select[id='tablineID[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("select[id='tabstationID[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("select[id='tabside[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("input[id='oc[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("input[id='ft[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("input[id='tct[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("input[id='ct[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("input[id='mct[" + x + "]']").attr("disabled", true).attr("readonly", true);
|
||
|
// $("a[id='edit[" + x + "]']").addClass("layui-btn-disabled");
|
||
|
// $("a[id='Remove[" + x + "]']").addClass("layui-btn-disabled");
|
||
|
// }
|
||
|
// else {
|
||
|
// $("select[id='tabunitNo[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// getTabLineInfoes("tabunitNo[" + x + "]");
|
||
|
// $("select[id='tablineID[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// getTabStations("tabunitNo[" + x + "]");
|
||
|
// $("select[id='tabstationID[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("select[id='tabside[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("input[id='oc[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("input[id='ft[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("input[id='tct[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("input[id='ct[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("input[id='mct[" + x + "]']").attr("readonly", false).attr("disabled", false);
|
||
|
// $("a[id='edit[" + x + "]']").removeClass("layui-btn-disabled");
|
||
|
// $("a[id='Remove[" + x + "]']").removeClass("layui-btn-disabled");
|
||
|
// }
|
||
|
// }
|
||
|
// layui.form.render("select");//重新渲染 固定寫法
|
||
|
//}
|
||
|
|
||
|
////搜索
|
||
|
$('#btnSearch').click(function () {
|
||
|
hg.msghide("刷新数据!");
|
||
|
var ModelName = $("#modelname").val();
|
||
|
var UnitNo = $("#unitNo").val();
|
||
|
var UserId = @ViewBag.UserID;
|
||
|
seachtableData(UnitNo, ModelName, UserId);
|
||
|
});
|
||
|
|
||
|
$('#btnSubmit').click(function (obj) {
|
||
|
var gettabData = gettableData();
|
||
|
var ModelName = $("#modelname").val();
|
||
|
var UnitNo = $("#unitNo").val();
|
||
|
var UserId = @ViewBag.UserID;
|
||
|
console.log(UnitNo, ModelName, gettabData, UserId);
|
||
|
addChangetableData(UnitNo, ModelName, gettabData, UserId);
|
||
|
|
||
|
|
||
|
});
|
||
|
function getableHeader(sUnitNo) {
|
||
|
$.ajax({
|
||
|
url: '/WHS/WHS022ColumnNameQuery',
|
||
|
data: { sUnitNo: sUnitNo },
|
||
|
type: 'GET',
|
||
|
success: function (res) {
|
||
|
//console.log(res);
|
||
|
var tableHeaders;
|
||
|
$.each(res.data, function (i, val) {
|
||
|
tableHeaders += '<th id="COLUMN_' + (res.count - 1 - i) + '" name="' + (i+1) + '">' + val.columN_NAME + '</th>';
|
||
|
});
|
||
|
$("#MyTabletHead").empty();
|
||
|
$("#MyTableTbody").empty();
|
||
|
$("#MyTabletHead").append('<tr>' + tableHeaders + '</tr>');
|
||
|
},
|
||
|
error: function () {
|
||
|
hg.msg("网络请求失败!");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function seachtableData(UnitNo, ModelName, UserId) {
|
||
|
|
||
|
$.ajax({
|
||
|
url: '/WHS/WHS022OWByUserQuery',
|
||
|
cache: false,
|
||
|
data: {
|
||
|
sUnitNo: UnitNo,
|
||
|
sItemNo: ModelName,
|
||
|
sUserId: UserId
|
||
|
},
|
||
|
type: 'GET',
|
||
|
success: function (res) {
|
||
|
var tableColumn = "";
|
||
|
$("#MyTableTbody").empty();
|
||
|
const HeadCount = document.getElementById('COLUMN_0').getAttribute("name")
|
||
|
$.each(res.data, function (i, val) {
|
||
|
tableColumn += '<td><input class="layui-input" ';
|
||
|
if (i <= HeadCount )
|
||
|
tableColumn += ' disabled="enabled"';
|
||
|
var tabColData = val.outsourcE_VALUE
|
||
|
if (tabColData == null)
|
||
|
tabColData = '';
|
||
|
tableColumn += ' value="' + tabColData + '"></td>';
|
||
|
if ((i+1) % HeadCount == 0) {
|
||
|
$("#MyTableTbody").append('<tr>' + tableColumn + '</tr>');
|
||
|
tableColumn = "";
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
error: function () {
|
||
|
hg.msg("网络请求失败!");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function addtableData(UnitNo, ModelName, tabData, UserId) {
|
||
|
|
||
|
$.ajax({
|
||
|
url: '/WHS/WHS022OWAddData',
|
||
|
data: {
|
||
|
sUnitNo: UnitNo,
|
||
|
sItemNo: ModelName,
|
||
|
sData: tabData,
|
||
|
sUserId: UserId
|
||
|
},
|
||
|
type: 'POST',
|
||
|
success: function (data) {
|
||
|
if (data.success) {
|
||
|
hg.msghide("新增成功!");
|
||
|
}
|
||
|
else {
|
||
|
hg.msg(data.msg);
|
||
|
}
|
||
|
},
|
||
|
error: function () {
|
||
|
hg.msg("网络请求失败!");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function addChangetableData(UnitNo, ModelName, tabData, UserId) {
|
||
|
|
||
|
$.ajax({
|
||
|
url: '/WHS/WHS022OWAddChangeData',
|
||
|
data: {
|
||
|
sUnitNo: UnitNo,
|
||
|
sItemNo: ModelName,
|
||
|
sUserId: UserId
|
||
|
},
|
||
|
type: 'POST',
|
||
|
success: function (data) {
|
||
|
if (data.success) {
|
||
|
hg.msghide("新增成功!");
|
||
|
addtableData(UnitNo, ModelName, tabData, UserId);
|
||
|
}
|
||
|
else {
|
||
|
hg.msg(data.msg);
|
||
|
}
|
||
|
},
|
||
|
error: function () {
|
||
|
hg.msg("网络请求失败!");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function gettableData() {
|
||
|
var table = document.getElementById('MydataTable');
|
||
|
for (var i = 2, row; row = table.rows[i]; i++) {
|
||
|
var col = row.cells;
|
||
|
var jsonObj = "";
|
||
|
for (var ii = 0, col; _col = col[ii]; ii++) {
|
||
|
jsonObj += _col.children[0].value + ",";
|
||
|
}
|
||
|
}
|
||
|
return jsonObj;
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
}
|