312 lines
11 KiB
JavaScript
312 lines
11 KiB
JavaScript
|
|
|
|||
|
|
function gotoDetailPartialNew(id) {
|
|||
|
|
$("#pPlanInterBox_Content").empty();
|
|||
|
|
removePPInfo();
|
|||
|
|
// Ajax提交数据
|
|||
|
|
$.ajax({
|
|||
|
|
url: "/APP/PPlan/PPlanInternalDetailsNew",//"@Url.Action("PPlanInternalDetailsNew", "PPlan")",//"APP/login/login", // 提交到controller的url路径
|
|||
|
|
type: "post", // 提交方式
|
|||
|
|
data: { "id": id }, // data为String类型,必须为 Key/Value 格式。
|
|||
|
|
dataType: "json", // 服务器端返回的数据类型
|
|||
|
|
success: function (res) { // 请求成功后的回调函数,其中的参数data为controller返回的map,也就是说,然后通过data这个参数取JSON数据中的值
|
|||
|
|
|
|||
|
|
if (res.Status == 200) {
|
|||
|
|
setPPInfo(res);
|
|||
|
|
if (res.Data.rows) {
|
|||
|
|
//填充数据
|
|||
|
|
var jsonArray = res.Data.rows;
|
|||
|
|
var headArray = [];
|
|||
|
|
|
|||
|
|
//循环取字段名
|
|||
|
|
for (var i in jsonArray[0]) {
|
|||
|
|
headArray[headArray.length] = i;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var div = document.getElementById("pPlanInterBox_Content");
|
|||
|
|
var table = document.createElement("table");
|
|||
|
|
table.id = "new_table";
|
|||
|
|
table.setAttribute("class", "table table-striped table-bordered table-hover dataTables-example");
|
|||
|
|
|
|||
|
|
var theadH = document.createElement("thead");
|
|||
|
|
var thead = document.createElement("tr");
|
|||
|
|
|
|||
|
|
for (var count = 1; count < headArray.length; count++) {
|
|||
|
|
var td = document.createElement("th");
|
|||
|
|
td.innerHTML = headArray[count];
|
|||
|
|
thead.appendChild(td);
|
|||
|
|
}
|
|||
|
|
theadH.appendChild(thead);
|
|||
|
|
table.appendChild(theadH);
|
|||
|
|
|
|||
|
|
var theadY = document.createElement("tbody");
|
|||
|
|
|
|||
|
|
for (var tableRowNo = 0; tableRowNo < jsonArray.length; tableRowNo++) {
|
|||
|
|
|
|||
|
|
var tr = document.createElement("tr");
|
|||
|
|
for (var headCount = 1; headCount < headArray.length; headCount++) {
|
|||
|
|
var cell = document.createElement("td");
|
|||
|
|
|
|||
|
|
cell.setAttribute("class", jsonArray[tableRowNo][headArray[0]] + " " + headArray[headCount]);
|
|||
|
|
cell.innerHTML = jsonArray[tableRowNo][headArray[headCount]];
|
|||
|
|
//cell.data("station", headArray[headCount]);
|
|||
|
|
cell.dataset.station = headArray[headCount];
|
|||
|
|
cell.dataset.datetime = jsonArray[tableRowNo][headArray[1]];
|
|||
|
|
tr.appendChild(cell);
|
|||
|
|
}
|
|||
|
|
theadY.appendChild(tr);
|
|||
|
|
table.appendChild(theadY);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
div.appendChild(table);
|
|||
|
|
|
|||
|
|
|
|||
|
|
newTable(table.id);
|
|||
|
|
|
|||
|
|
$('.ToDay.Date').css({ 'border-bottom': '1px solid #FFF' });
|
|||
|
|
$('.Total').css({ 'border-bottom': '1px solid #333' });
|
|||
|
|
$('.Total:not(.Date)').css({ 'font-weight': '600', 'font-style': 'italic' });
|
|||
|
|
//$("#pPlanInterBox_Content").focus();
|
|||
|
|
//location.href = "#ppInfo";
|
|||
|
|
//$('html, body').animate({ scrollTop: $('#ppInfo').offset().top }, 1000);
|
|||
|
|
//for (var tableRowNo = 1; tableRowNo <= (jsonArray.length / 2); tableRowNo++) {
|
|||
|
|
|
|||
|
|
// mergeCell('new_table', tableRowNo * 2 - 1, tableRowNo * 2, 0);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$("#pPlanInterBox_Content").html("<small><strong> 暂无生产计划</strong ></small >");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function mergeCell(table1, startRow, endRow, col) {
|
|||
|
|
var tb = document.getElementById(table1);
|
|||
|
|
if (!tb || !tb.rows || tb.rows.length <= 0) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (col >= tb.rows[0].cells.length || (startRow >= endRow && endRow != 0)) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (endRow == 0) {
|
|||
|
|
endRow = tb.rows.length - 1;
|
|||
|
|
}
|
|||
|
|
for (var i = startRow; i < endRow; i++) {
|
|||
|
|
if (tb.rows[startRow].cells[col].innerHTML == tb.rows[i + 1].cells[col].innerHTML) { //如果相等就合并单元格,合并之后跳过下一行
|
|||
|
|
tb.rows[i + 1].removeChild(tb.rows[i + 1].cells[col]);
|
|||
|
|
tb.rows[startRow].cells[col].rowSpan = (tb.rows[startRow].cells[col].rowSpan) + 1;
|
|||
|
|
} else {
|
|||
|
|
mergeCell(table1, i + 1, endRow, col);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var oTable;
|
|||
|
|
function newTable(tbid) {
|
|||
|
|
oTable = $('#' + tbid).DataTable({
|
|||
|
|
"bFilter": false, //过滤功能
|
|||
|
|
"info": false,
|
|||
|
|
"ordering": false,
|
|||
|
|
"lengthChange": false,
|
|||
|
|
"bAutoWidth": false,//自动宽度
|
|||
|
|
"bPaginate": false, //翻页功能
|
|||
|
|
|
|||
|
|
//表头固定
|
|||
|
|
//"fixedHeader": true,
|
|||
|
|
//"scrollX": "500px",
|
|||
|
|
//"scrollY": "400px",
|
|||
|
|
//"scrollCollapse": true,
|
|||
|
|
////固定首列,需要引入相应 dataTables.fixedColumns.min.js
|
|||
|
|
//"fixedColumns": {
|
|||
|
|
// "leftColumns": 2
|
|||
|
|
//},
|
|||
|
|
//"columnDefs": [{
|
|||
|
|
// targets: 0, //第1列
|
|||
|
|
// createdCell: function (td, cellData, rowData, row, col) {
|
|||
|
|
|
|||
|
|
// var rowspan = (row+1)%2;
|
|||
|
|
// if (rowspan == 0) {
|
|||
|
|
// $(td).remove();
|
|||
|
|
// }
|
|||
|
|
// else {
|
|||
|
|
// $(td).attr('rowspan', 2);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}],
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//即时编辑
|
|||
|
|
oTable.$('td:not(.Date,.Total,.DataType)').editable(function (value, settings) {
|
|||
|
|
var station = this.dataset.station;//站
|
|||
|
|
|
|||
|
|
var datetime = this.dataset.datetime;//日期
|
|||
|
|
var oiID = $("#oiID").val();//内部单号
|
|||
|
|
var projectID = $("#projectID").val();//机型
|
|||
|
|
SetPPCount(projectID, oiID, station, datetime, value);//修改数量
|
|||
|
|
return (value);
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"indicator": '保存中...',//提交处理过程中显示的提示文字
|
|||
|
|
"tooltip": '单击编辑...',//鼠标悬停时的提示信息
|
|||
|
|
//"cssclass": 'form-control',
|
|||
|
|
"width": "60px",
|
|||
|
|
"height": "100%",
|
|||
|
|
"placeholder": "0",
|
|||
|
|
//"style": 'input:{width:60px;}',
|
|||
|
|
//"onblur": 'ignore',//方便调试样式
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$.editable.addInputType('birthday', {
|
|||
|
|
element: function (settings, original) {
|
|||
|
|
var input = $('<input type="text" size="8" readonly>').datetimepicker({
|
|||
|
|
language: 'zh-CN',
|
|||
|
|
//locale: moment.locale('zh-CN'),
|
|||
|
|
format: 'yyyy/mm/dd',
|
|||
|
|
autoclose: 1,
|
|||
|
|
startView: 2,
|
|||
|
|
minView: 2,
|
|||
|
|
});
|
|||
|
|
$(this).append(input);
|
|||
|
|
return (input);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//即时编辑
|
|||
|
|
oTable.$('.Date:not(.Total)').editable(function (value, settings) {
|
|||
|
|
var datetime = this.dataset.datetime;//日期
|
|||
|
|
var oiID = $("#oiID").val();//内部单号
|
|||
|
|
var projectID = $("#projectID").val();//机型
|
|||
|
|
SetPPDate(projectID, oiID, datetime, value);
|
|||
|
|
return (value);
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"cancel": '取消',//取消编辑按钮的文字
|
|||
|
|
"submit": '确定',//确认提交按钮的文字
|
|||
|
|
|
|||
|
|
"indicator": '保存中...',//提交处理过程中显示的提示文字
|
|||
|
|
"tooltip": '单击编辑...',//鼠标悬停时的提示信息
|
|||
|
|
//"cssclass": 'form-control',
|
|||
|
|
"width": "60px",
|
|||
|
|
"height": "100%",
|
|||
|
|
"placeholder": "0",
|
|||
|
|
"type": 'birthday',
|
|||
|
|
//"style": 'input:{width:60px;}',
|
|||
|
|
"onblur": 'ignore',//方便调试样式
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置计划信息
|
|||
|
|
function setPPInfo(res) {
|
|||
|
|
$("#customerAbbr").html(res.Data.CustomerAbbr);
|
|||
|
|
$("#projectName").html(res.Data.ProjectName);
|
|||
|
|
$("#orderNo").html(res.Data.OrderNo);
|
|||
|
|
$("#internalNo").html(res.Data.InternalNo);
|
|||
|
|
$("#deliveryTime").html(res.Data.DeliveryTimeStr);
|
|||
|
|
$("#stationText").html(res.Data.StationText);
|
|||
|
|
$("#oiID").val(res.Data.ID);
|
|||
|
|
$("#projectID").val(res.Data.ProjectID);
|
|||
|
|
|
|||
|
|
$("#ppInfo").attr("style", "display:block;");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//清除计划信息
|
|||
|
|
function removePPInfo() {
|
|||
|
|
$("#customerAbbr").html("");
|
|||
|
|
$("#projectName").html("");
|
|||
|
|
$("#orderNo").html("");
|
|||
|
|
$("#internalNo").html("");
|
|||
|
|
$("#deliveryTime").html("");
|
|||
|
|
$("#stationText").html("");
|
|||
|
|
$("#oiID").val("");
|
|||
|
|
$("#projectID").val("");
|
|||
|
|
|
|||
|
|
$("#ppInfo").attr("style", "display:none;");
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//新增行
|
|||
|
|
function fnClickAddRow() {
|
|||
|
|
var oiID = $("#oiID").val();//内部单号
|
|||
|
|
var projectID = $("#projectID").val();//机型
|
|||
|
|
$.ajax({
|
|||
|
|
url: "/APP/PPlan/AddPPlanForTB", //"@Url.Action("AddPPlanForTB", "PPlan")",
|
|||
|
|
type: "post",
|
|||
|
|
data: { "projectID": projectID, "oiID": oiID },
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (res) {
|
|||
|
|
if (res.Status == 200) {
|
|||
|
|
$.toastr.success('提交成功',
|
|||
|
|
{
|
|||
|
|
position: 'top-center',
|
|||
|
|
time: 550,
|
|||
|
|
});
|
|||
|
|
gotoDetailPartialNew(oiID);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$.toastr.error('提交失败! <br />' + res.Message, {
|
|||
|
|
time: 3000,
|
|||
|
|
position: 'top-center'
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function SetPPCount(projectID, oiID, station, datetime, value) {
|
|||
|
|
$.ajax({
|
|||
|
|
url: "/APP/PPlan/EditPPlanForTB",//"@Url.Action("EditPPlanForTB", "PPlan")",
|
|||
|
|
type: "post",
|
|||
|
|
data: { "projectID": projectID, "oiID": oiID, "stationName": station, "datetime": datetime, "count": value },
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (res) {
|
|||
|
|
if (res.Status == 200) {
|
|||
|
|
$.toastr.success('提交成功',
|
|||
|
|
{
|
|||
|
|
position: 'top-center',
|
|||
|
|
time: 550,
|
|||
|
|
});
|
|||
|
|
gotoDetailPartialNew(oiID);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$.toastr.error('提交失败! <br />' + res.Message, {
|
|||
|
|
time: 3000,
|
|||
|
|
position: 'top-center'
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
function SetPPDate(projectID, oiID, datetime, value) {
|
|||
|
|
$.ajax({
|
|||
|
|
url: "/APP/PPlan/EditPPlanDate",//"@Url.Action("EditPPlanDate", "PPlan")",
|
|||
|
|
type: "post",
|
|||
|
|
data: { "projectID": projectID, "oiID": oiID, "datetime": datetime, "upDate": value },
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (res) {
|
|||
|
|
if (res.Status == 200) {
|
|||
|
|
$.toastr.success('提交成功',
|
|||
|
|
{
|
|||
|
|
position: 'top-center',
|
|||
|
|
time: 550,
|
|||
|
|
});
|
|||
|
|
gotoDetailPartialNew(oiID);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$.toastr.error('提交失败! <br />' + res.Message, {
|
|||
|
|
time: 3000,
|
|||
|
|
position: 'top-center'
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|