@page
@model KTCPLC.Pages.UI.DTFillerPageModel
@{
}
<style>
.hide {
display: none;
}
</style>
<script>
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script type="text/javascript" src="~/lib/My97DatePicker/WdatePicker.js"></script>
<hr />
@Html.AntiForgeryToken()
<div style="width:90%;margin-left:5%">
<table runat="server" id="tabForm" style="border-collapse:separate; width:96%; border-spacing:12px 5px;">
<tr>
<td> <label id="lcShift">Shift</label> </td>
<td> @Html.DropDownList("ddlShift", ViewData["ShiftList"] as IEnumerable<SelectListItem>, new { @class = "form-control" }) </td>
<td> <label id="lcLineID">LineID</label> </td>
<td>
<select class="form-control" id="txtLineID">
<option>CL1</option>
<option>BL1</option>
</select>
</td>
<td> <label id="lcStart_time">Start_time</label> </td>
<td> <input type="text" id="txtStart_time" name="txtStart_time" class="form-control" onClick="WdatePicker({ el: this, dateFmt: 'yyyy-MM-dd' })" /> </td>
<td> <label id="lcEnd_time">End_time</label> </td>
<td> <input type="text" id="txtEnd_time" name="txtEnd_time" class="form-control" onClick="WdatePicker({ el: this, dateFmt: 'yyyy-MM-dd' })" /> </td>
</tr>
</table>
<br />
<div class="row">
<div class="col-2">
</div>
<div class="col-3">
<button type="button" id="btnquery" class="btn btn-primary" name="btnquery" value="Query">Query</button>
</div>
<div class="col-2">
<button type="button" id="btnclear" class="btn btn-primary" name="btnclear" value="Clear">Clear</button>
</div>
</div>
</div>
<button type="button" id="btntest" class="btn btn-primary" name="btntest" value="Test">Test</button>
<br />
<table id="maincontent" class="table table-bordered table-striped" style="width:96%; margin-left:2%">
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
<script>
function UpdateRowData(index, data) {
}
</script>
<script>
$(document).ready(function () {
QMPop.QMPopInit();
$("#ddlFtp option[text='FtpPassword']").attr("selected", true);
$("#ddlFtp").find("option[text='FtpPassword']").attr("selected", true);
// $('#ddlFtp')[0].selectedIndex = 3;
$("#ddlFtp").attr("value", 'qmftp@it06');
$("#ddlFtp option:contains('qmftp@it06')").prop("selected", true);
$('#ddlFtp').attr('value', 'qmftp@it06');
var street = 'FtpUserID';
QMPage.SetDDLTextRead('ddlFtp', street);
var ddl = "ddlFtp";
//$("#" + ddl).prop("disabled", true);
// console.log('DDLFtp Selected : ' + $("#ddlFtp").find("option:selected").text());
});
</script>
<script>
function UpdateRefid( data) {
table.rows().nodes().each(function (row, i) {
if ($(row).find("td").eq(0).text().trim() == data.refid) {
$(row).find("td").eq(2).text(data.shift);
$(row).find("td").eq(7).text(data.category);
$(row).find("td").eq(8).text(data.lev1);
$(row).find("td").eq(9).text(data.lev2);
$(row).find("td").eq(10).text(data.brand);
$(row).find("td").eq(11).text(data.cbrand);
// $(row).find("td").eq(12).text(data.ctype);
$(row).find("td").eq(12).text(data.stand_time);
$(row).find("td").eq(13).text(data.reason);
}
})
}
function GetRowsByRefid(col, refid) {
//var t1 = $('#maincontent').DataTable();
var index = 0;
//console.log("refid=== " + refid);
//t1.column(col).nodes().each(function (cell, i) {
// // console.log(cell.innerHTML);
// if (cell.innerHTML == refid) {
// index = i;
// console.log("Index " + index);
// }
//});
var t3 = $('#maincontent').DataTable();
var data = t3.data().toArray();
data.forEach(function (row, i) {
//row.forEach(function (column, j) {
// console.log('row ' + i + ' column ' + j + ' value ' + column);
//});
});
console.log("Return " + index);
return index;
}
function getTableContent() {
table.column(6).nodes().each(function (cell, i) {
console.log(cell.innerHTML);
if (cell.innerHTML == "59") {
console.log("Row Number " + i);
return i;
}
})
SetVV();
}
function test(refid ) {
table.rows().nodes().each(function (row, i) {
//var tdcols = row.children();
// console.log(tdcols.eq(1).innerHTML);
// console.log(row );
console.log($(row).find("td").eq(0).text());
if($(row).find("td").eq(1).text() == refid){
$(row).find("td").eq(6).text("KKK9999");
$(row).find("td").eq(7).text("7777777");
}
console.log($(row).find("td").eq(1).text());
console.log($(row).find("td").eq(6).text());
})
}
function test1() {
table= $('#maincontent').DataTable();
table.rows().data().each(function (value, index) {
//console.log(index + " " + JSON.stringify(value));
if (value.refid == '8') {
console.log(value.duration);
var row = table.rows(index).nodes();//.to$().childNodes;
console.log(row);
console.log("Index " + index);
console.log( table.rows(index).data()[0]);
$(row).find("td").eq(6).text("AAA");
$(row).find("td").eq(7).text("BBB");
value.lev1 = "111";
value.lev2 = "222";
}
})
}
function SetVV() {
table.column(7).nodes().each(function (cell, i) {
cell.innerHTML = "999";
})
}
</script>
<script>
$("body").on("click", "#btntest", function () {
// console.log(table.columns('refid').search('5').row(this).data());
test(8);
//var t1 = $('#maincontent').DataTable();
// var index = GetRowsByRefid(1, 8);
// var rowdata = t1.rows(index).data()[0];
// console.log(rowdata);
// console.log(rowdata.duration);
// console.log(rowdata.status);
});
$("body").on("change", "#ddlFtp", function () {
$('#ddlsub').empty();
var url = "/UI/DTFillerPage/?handler=DDLFtpSubList"; //规则是控制器/方法/参数
//alert(url);
var data1 = GetDDLFtpData();
QMAjax.AjaxFormCallBackNC({
url: url,
data: data1,
okfunc: function (rsp) {
$.each(rsp.data, function (i, item) {
$('#ddlsub').append("<option value='" + item.parameter_value + "'>" + item.parameter_name + "</option>");
});
}
});
});
$("body").on("change", "#ddlCate", function () {
$('#ddlLev1').empty();
$('#ddlLev2').empty();
var url = "/UI/DTFillerPage/?handler=DDLLev1List"; //规则是控制器/方法/参数
if ($('#ddlCate').val() != '') {
var data1 = GetDDLCateData();
QMAjax.AjaxFormCallBackNC({
url: url,
data: data1,
okfunc: function (rsp) {
$.each(rsp.data, function (i, item) {
$('#ddlLev1').append("<option value='" + item.name + "'>" + item.value + "</option>");
});
}
});
}
});
$("body").on("change", "#ddlLev1", function () {
$('#ddlLev2').empty();
var url = "/UI/DTFillerPage/?handler=DDLLev2List"; //规则是控制器/方法/参数
if ($('#ddlLev1').val() != '') {
var data1 = GetDDLLev1Data();
QMAjax.AjaxFormCallBackNC({
url: url,
data: data1,
okfunc: function (rsp) {
$.each(rsp.data, function (i, item) {
$('#ddlLev2').append("<option value='" + item.name + "'>" + item.value + "</option>");
});
}
});
}
});
$("body").on("click", "#btnpopcancel", function () {
QMPop.ClosePopup();
});
$("body").on("click", "#btnpopsubmit", function () {
PopEdit();
});
$("body").on("click", "#btnpopdel", function () {
PopDel();
});
$("body").on("click", "#btnquery", function () {
FormQuery();
});
$("body").on("click", "#btnclear", function () {
FormClear();
});
</script>
<script>
var table;
var delrownum;
var delrefid;
var qmcolumns = [
{
data: "refid", defaultContent: '', title: "编辑", width: "5%", class: "text-center",
render: function (data, type, row, meta) {
return "<div style=\"display:none\">"+data+"</div>"+ " <a value='"+data+"' href=\"javascript:;\" onclick=\"DTEdit('" + meta.row + "','" + row.refid + "')\" style='font-size:1.2em; color:RGB(18,184,134);' id='btnedit' ><i class='fas fa-pen'></i></a> ";
}
},
{
data: "", width: "5%", title: "序号",
render: function (data, type, row, meta) {
return meta.row + 1;
}
},
{ data: 'shift', title: '班别', 'visible': true, },
{
data: 'pDate', title: '日期', 'visible': true,
render: function (data, type, row, meta) {
return data.substring(0, 10);
}
},
{
data: 'start_time', title: '开始时间', 'visible': true,
render: function (data, type, row, meta) {
return data.substring(11, 19);
}
},
{
data: 'end_time', title: '结束时间', 'visible': true,
render: function (data, type, row, meta) {
return data.substring(11, 19);
}
},
{
data: 'duration', title: '持续时间', 'visible': true,
render: function (data, type, row, meta) {
return Math.round(data);
}
},
{ data: 'category', title: '分类', 'visible': true, },
{ data: 'lev1', title: '一级分类', 'visible': true, },
{ data: 'lev2', title: '二级分类', 'visible': true, },
{ data: 'brand', title: '品种', 'visible': true, },
{ data: 'cBrand', title: '换线品种', 'visible': true, },
{ data: 'stand_time', title: '标准时间', 'visible': true, },
{ data: 'reason', title: '故障描述', 'visible': true, },
{ data: 'status', title: '设备状态', 'visible': true, }
];
function ClearDataTable() {
if (table != null) {
table.clear().draw();
}
}
function GetDDLFtpData() {
var postdata = {};
postdata["parent"] = $('#ddlFtp').val();
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetDDLCateData() {
var postdata = {};
postdata["Cate"] = $('#ddlCate').val();
console.log("Cate Value: " + $('#ddlCate').val());
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetDDLLev1Data() {
var postdata = {};
postdata["Lev1"] = $('#ddlLev1').val();
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetHeadFormData() {
var postdata = {};
postdata["LineID"] = $('#txtLineID').val();
postdata["Shift"] = $('#ddlShift').val();
postdata["Start_time"] = $('#txtStart_time').val();
postdata["End_time"] = $('#txtEnd_time').val();
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetRowFormData(index) {
var rowdata = table.rows(index).data()[0];
var postdata = {};
postdata["oprefid"] = rowdata.refid;
postdata["refid"] = rowdata.refid;
postdata["LineID"] = rowdata.LineID;
postdata["IsDown"] = rowdata.IsDown;
postdata["Shift"] = rowdata.Shift;
postdata["Model"] = rowdata.Model;
postdata["Start_time"] = rowdata.Start_time;
postdata["End_time"] = rowdata.End_time;
postdata["Duration"] = rowdata.Duration;
postdata["Category"] = rowdata.Category;
postdata["Lev1"] = rowdata.Lev1;
postdata["Lev2"] = rowdata.Lev2;
postdata["Brand"] = rowdata.Brand;
postdata["CBrand"] = rowdata.CBrand;
postdata["Ctype"] = "";
postdata["stand_time"] = rowdata.stand_time;
postdata["Reason"] = rowdata.Reason;
postdata["Memo"] = rowdata.Memo;
postdata["status"] = rowdata.status;
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetRowJsonData(index) {
var rowdata = table.rows(index).data()[0];
var jsondata = {
"refid": rowdata.refid,
"shift": rowdata.shift,
"model": rowdata.model,
"start_time": rowdata.start_time,
"end_time": rowdata.end_time,
"duration": rowdata.duration,
"category": rowdata.category,
"lev1": rowdata.lev1,
"lev2": rowdata.lev2,
"brand": rowdata.brand,
"cBrand": rowdata.cBrand,
"ctype": "",
"stand_time": rowdata.stand_time,
"reason": rowdata.reason,
"memo": rowdata.memo,
"status": rowdata.status,
"create_by": rowdata.create_by,
"create_time": rowdata.create_time,
"update_by": rowdata.update_by,
"update_time": rowdata.update_time,
"index": index
};
return jsondata;
}
function FormQuery() {
$('#btnquery').attr("disabled", "disabled");
var data1 = GetHeadFormData();
var url = '/UI/DTFillerPage?handler=query';
QMAjax.AjaxFormCallBack({
url: url,
data: data1,
okfunc: function (rsp) {
QMTable.loaddata(rsp.data);
}
});
$('#btnquery').removeAttr("disabled");
}
function FormClear() {
$('#txtLineID').val('');
$('#txtShift').val('');
$('#txtModel').val('');
$('#txtStart_time').val('');
$('#txtEnd_time').val('');
$('#txtDuration').val('');
$('#txtCategory').val('');
$('#txtLev1').val('');
$('#txtLev2').val('');
$('#txtBrand').val('');
$('#txtCBrand').val('');
// $('#txtCtype').val('');
$('#txtstand_time').val('');
$('#txtReason').val('');
// $('#txtMemo').val('');
$('#txtstatus').val('');
}
function DTEdit(index, refid) {
// QMPop.PopupXS("Edit Data", $('#divpopcontent').html());
//$(".ddlsub1 option[text='FtpPassword']").attr("selected", true);
//$("#ddlFtp").find("option:contains('ftpuser')").attr("selected", true);
// $("#ddlFtp option[text='FtpPassword']").attr("selected", true);
//$(".ddlsub1").find("option[text='FtpPassword']").attr("selected", true);
//layer.open({
// type: 1,
// title: 'Edit',
// shadeClose: true,
// shade: 0.5,
// area: ['60%', '90%'],
// content: $('#divpopcontent')
//});
// $('#divpopcontent').modal('show');
// $("a[name='btnpopsubmit']").css({ "display": "block" });
// SetPopData(GetRowJsonData(index));
layer.open({
type: 2,
area: ['860px', '500px'],
fixed: false, //不固定
maxmin: true,
content: './DTFillerModel?refid=' + refid
});
}
function DTView(index, refid) {
QMPop.PopupXS("View Data", $('#divpopcontent').html());
$("a[name='btnpopsubmit']").css({ "display": "none" });
SetPopData(GetRowJsonData(index));
}
function DTDel(index, refid) {
delrownum = index;
delrefid = refid;
QMPop.PopupXS("Delete Data", $('#divpopcontent').html());
$("a[name='btnpopsubmit']").css({ "display": "none" });
$("a[name='btnpopdel']").css({ "display": "block" });
SetPopData(GetRowJsonData(index));
}
function PageCloseQMPop() {
$("a[name='btnpopsubmit']").css({ "display": "none" });
$("a[name='btnpopdel']").css({ "display": "none" });
}
function PopDel() {
var url = "./UI/DTFillerPage?handler=Del";
var data1 = GetPopDelData();
if (QMAjax.QMConfirm()) {
QMAjax.AjaxFormCallBack({
url: url,
data: data1,
okfunc: function (rsp) {
QMPop.ClosePopup();
QMTable.loaddata(rsp.data);
$("a[name='btnpopdel']").css({ "display": "none" });
}
});
}
else {
}
}
function PopEdit() {
var url = "/UI/DTFillerPage?handler=Edit";
var data1 = GetPopEditData();
QMAjax.AjaxFormCallBack({
url: url,
data: data1,
okfunc: function (rsp) {
$('#divpopcontent').modal('hide');
QMTable.loaddata(rsp.data);
}
});
}
function SetPopData(json) {
console.log(json);
$("input[name='txtpoprefid']").val(json.refid);
// $("#txtpopDeviceID").val(json.deviceID);
$("input[name='txtpopShift']").val(json.shift);
$("input[name='txtpopModel']").val(json.model);
$("input[name='txtpopStart_time']").val(json.start_time);
$("input[name='txtpopEnd_time']").val(json.end_time);
$("input[name='txtpopDuration']").val(json.duration);
//$("input[name='txtpopCategory']").val(json.Category);
$("input[name='txtpopLev1']").val(json.lev1);
$("input[name='txtpopLev2']").val(json.lev2);
$("input[name='txtpopBrand']").val(json.brand);
$("input[name='txtpopCBrand']").val(json.cBrand);
// $("input[name='txtpopCtype']").val(json.ctype);
$("input[name='txtpopstand_time']").val(json.stand_time);
$("input[name='txtpopReason']").val(json.reason);
// $("input[name='txtpopMemo']").val(json.memo);
$("input[name='txtpopstatus']").val(json.status);
//$("input[name='txtpopcreate_by']").val(json.create_by);
//$("input[name='txtpopcreate_time']").val(json.create_time);
//$("input[name='txtpopupdate_by']").val(json.update_by);
//$("input[name='txtpopupdate_time']").val(json.update_time);
}
function GetPopEditData() {
var postdata = {};
postdata["refid"] = $('#txtpoprefid').val();
// postdata["DeviceID"] = $('#txtpopDeviceID').val();
postdata["Shift"] = $("#ddlpopShift").val();
postdata["Start_time"] = $("#txtpopStart_time").val();
postdata["End_time"] = $("#txtpopEnd_time").val();
postdata["Duration"] = $("#txtpopDuration").val();
postdata["Category"] = $("#ddlCate").val();
postdata["Lev1"] = $("#ddlLev1").val();
postdata["Lev2"] = $("#ddlLev2").val();
postdata["Brand"] = $("#txtpopBrand").val();
postdata["CBrand"] = $("#txtpopCBrand").val();
postdata["Ctype"] = "";
postdata["stand_time"] = $("#txtpopstand_time").val();
postdata["Reason"] = $("#txtpopReason").val();
//postdata["Memo"] = $("#txtpopMemo").val();
postdata["status"] = $("#txtpopstatus").val();
postdata["update_by"] = 'sys';
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
function GetPopDelData() {
var rowdata = table.rows(delrownum).data()[0];
var postdata = {};
postdata["refid"] = $('#txtrefid').val();
postdata["LineID"] = $('#txtLineID').val();
postdata["IsDown"] = $('#txtIsDown').val();
postdata["Shift"] = $('#txtShift').val();
postdata["Model"] = $('#txtModel').val();
postdata["Start_time"] = $('#txtStart_time').val();
postdata["End_time"] = $('#txtEnd_time').val();
postdata["Duration"] = $('#txtDuration').val();
postdata["Category"] = $('#txtCategory').val();
postdata["Lev1"] = $('#txtLev1').val();
postdata["Lev2"] = $('#txtLev2').val();
postdata["Brand"] = $('#txtBrand').val();
postdata["CBrand"] = $('#txtCBrand').val();
postdata["Ctype"] = "";
postdata["stand_time"] = $('#txtstand_time').val();
postdata["Reason"] = $('#txtReason').val();
// postdata["Memo"] = $('#txtMemo').val();
postdata["status"] = $('#txtstatus').val();
postdata["create_by"] = $('#txtcreate_by').val();
postdata["create_time"] = $('#txtcreate_time').val();
postdata["update_by"] = $('#txtupdate_by').val();
postdata["update_time"] = $('#txtupdate_time').val();
postdata["__RequestVerificationToken"] = $('input:hidden[name="__RequestVerificationToken"]').val();
return postdata;
}
</script>
@section OutBody{
<div id="divpopcontent" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Down Time Edit</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="text" name="txtpoprefid" value="" id="txtpoprefid" class="form-control" style="display:none">
<table runat="server" id="tabPop" width="96%" style="border-collapse:separate; border-spacing:12px 5px;">
<tr>
<td> <lable id="lcpopShift">Shift </lable> </td>
<td> @Html.DropDownList("ddlpopShift", ViewData["ShiftList"] as IEnumerable<SelectListItem>, new { @class = "form-control" }) </td>
<td> <lable id="lcpopStart_time">Start_time </lable> </td>
<td> <input type="text" name="txtpopStart_time" value="" id="txtpopStart_time" onClick="WdatePicker({ el: this, dateFmt: 'yyyy-MM-dd' })" class="form-control"> </td>
<td> <lable id="lcpopEnd_time">End_time </lable> </td>
<td> <input type="text" name="txtpopEnd_time" value="" id="txtpopEnd_time" onClick="WdatePicker({ el: this, dateFmt: 'yyyy-MM-dd' })" class="form-control"> </td>
</tr>
<tr>
<td> <lable id="lcpopDuration">Duration </lable> </td>
<td> <input type="text" name="txtpopDuration" value="" id="txtpopDuration" class="form-control"> </td>
<td> <lable id="lcpopCategory">Category </lable> </td>
<td> @Html.DropDownList("ddlCate", ViewData["CateList"] as IEnumerable<SelectListItem>, new { @class = "form-control", @style = "width:100%" }) </td>
<td> <lable id="lcpopLev1">Lev1 </lable> </td>
<td> @Html.DropDownList("ddlLev1", ViewData["Lev1List"] as IEnumerable<SelectListItem>, new { @class = "form-control", style = "width:100%" }) </td>
</tr>
<tr>
<td> <lable id="lcpopLev2">Lev2 </lable> </td>
<td> @Html.DropDownList("ddlLev2", ViewData["Lev2List"] as IEnumerable<SelectListItem>, new { @class = "form-control" }) </td>
<td> <lable id="lcpopBrand">Brand </lable> </td>
<td> <input type="text" name="txtpopBrand" value="" id="txtpopBrand" class="form-control"> </td>
<td> <lable id="lcpopCBrand">CBrand </lable> </td>
<td> <input type="text" name="txtpopCBrand" value="" id="txtpopCBrand" class="form-control"> </td>
</tr>
<tr>
<td> <lable id="lcpopCtype">Ctype </lable> </td>
<td> <input type="text" name="txtpopCtype" value="" id="txtpopCtype" class="form-control"> </td>
<td> <lable id="lcpopstand_time">stand_time </lable> </td>
<td> <input type="text" name="txtpopstand_time" value="" id="txtpopstand_time" class="form-control"> </td>
<td> <lable id="lcpopstatus">status </lable> </td>
<td> <input type="text" name="txtpopstatus" value="" readonly="readonly" id="txtpopstatus" class="form-control"> </td>
</tr>
<tr>
<td> <lable id="lcpopReason">Reason </lable> </td>
<td colspan="5"> <input type="text" name="txtpopReason" value="" id="txtpopReason" class="form-control"> </td>
</tr>
</table>
<div class="container">
<br />
<div class="row">
<div class="col-md-2"> </div>
<div class="col-md-3"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div>
<div class="col-md-2"> </div>
<div class="col-md-3"> <button type="button" id="btnpopsubmit" class="btn btn-primary">Save changes</button></div>
</div>
</div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
}