fleet-contractor/Site/Maintenance/MachineMaintenanceInfo.aspx
2023-05-30 17:34:56 +08:00

634 lines
27 KiB
Plaintext

<%@ Page Title="" Language="C#" MasterPageFile="~/Maintenance/MaintenanceBase.master" AutoEventWireup="true" CodeFile="MachineMaintenanceInfo.aspx.cs" Inherits="Maintenance_MachineMaintenanceInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../css/jquery.datetimepicker.css" rel="stylesheet" />
<style type="text/css">
.return {
float: left;
width: 50px;
line-height: 56px;
font-style: normal;
text-align: left;
cursor: pointer;
}
.return:before {
content: '\e631';
}
.cupbutton {
background-color: rgb(249, 189, 117);
border: none;
padding-top: 5px;
padding-bottom: 5px;
margin-left: 10px;
cursor: pointer;
width: 60px;
}
.cupbutton:hover {
background: #d7690E;
}
.labeltdstyle {
text-align: right;
padding-top: 10px;
padding-left: 10px;
}
.inputtdstyle {
text-align: left;
padding-top: 10px;
}
.a {
text-decoration: none;
color: #2140fb;
}
.dialog .dialog-title .dialog-close {
float: right;
margin-right: 6px;
cursor: pointer;
}
.dialog .dialog-title .dialog-close:before {
content: '\e600';
}
.dialog-content table {
border-collapse: collapse;
width: 100%;
}
.dialog-content table td.label {
width: 150px;
text-align: right;
padding-right: 10px;
line-height: 24px;
height: 24px;
vertical-align: middle;
}
.dialog-content table td input,
.dialog-content table td textarea {
border: 1px solid #a9a9a9;
width: 200px;
height: 18px;
padding: 1px;
}
.dialog-content table td input[type="checkbox"] {
border: none;
}
.dialog-content table td textarea {
height: 100px;
max-width: 200px;
}
#dialogdatatb td {
padding-top: 5px;
}
#droptable td, th {
word-break: keep-all;
white-space: nowrap;
}
.sbutton {
font-size: 16px;
font-weight: bold;
}
.sbutton:before {
color: black;
}
</style>
<script src="../js/jquery.datetimepicker.full.js"></script>
<script src="<%=GetFileUrlWithVersion("js/inputdatactr.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/editableselect.js")%>" type="text/javascript"></script>
<%--<script src="<%=GetFileUrlWithVersion("js/attachments.js")%>" type="text/javascript"></script>--%>
<script type="text/javascript">
var assetid = "<%=AssetID %>";
$(function () {
InitGridData();
if (document.all) {
$('#dropDIV').css('left', 262);
}
GetTypesData();
$('#dialog_maintenance').prop('iframe', true).dialog(function () {
showmaskbg(false);
});
$('#dialog_mdate').click(function () { $('#dateformatspan').css('display', 'none'); }).blur(function () {
if ($.trim($(this).val()) == "") {
$('#dateformatspan').css('display', '');
}
else {
$('#dateformatspan').css('display', 'none');
}
}).datetimepicker({
timepicker: false,
format: 'm/d/Y',
enterLikeTab: false,
onSelectDate: function (v, inp) {
var date = new DateFormatter().formatDate(v, 'm/d/Y 00:00:00');
inp.parent().data('val', [date]);
}
})
InputControl($('#dialog_hours'));
$('#dialog_hours').change(function () { if (!inputValueFormat(this)) { $(this).val(''); } })
if (!assetid || assetid == "")
$('#searchinputtxt').bind('input propertychange', function () { SearchmachineList(false); }).click(function () { SearchmachineList(true); });
else {
$('#searchinputtxt').val(assetid).attr("disabled", "disabled");
$('#typeselectinput').attr("disabled", "disabled");
OnSearch();
}
$('#typeselectinput').change(function () { SearchmachineList(false); });
$('#dropDIV').mouseup(function (e) { e.stopPropagation(); });
$('#droptitle').mouseup(function (e) { e.stopPropagation(); });
$(document).mouseup(function (e) {
var targetE = e.target;
if (!targetE.id || (targetE.id != "searchinputtxt" && targetE.id != "dropDIV"))
$('#dropDIV').css('display', 'none');
});
$('#content').scroll(function () {
$('#dropDIV').css('display', 'none');
});
$('#dig_mtype').change(function () {
var logType = $(this).val();
if (logType === "Hours"
|| logType === "Undercarriage"
|| logType === "TimeOffRoad") {
$('#tr_distance').hide();
$('#tr_hours').show();
}
else {
$('#tr_hours').hide();
$('#tr_distance').show();
}
if (logType === "Undercarriage"
|| logType === "TimeOffRoad"
|| logType === "TimeOverRoad") {
$("#dialog_pmalerts").val("").attr("disabled", true);
}
else {
$("#dialog_pmalerts").attr("disabled", false);
}
});
$(window).resize(function () {
$("#recordlist").css("height", $(window).height() - $("#recordlist").offset().top - 15);
grid_dt && grid_dt.resize();
}).resize();
})
function leavedrpdiv(e) {
$(this).css('display', 'none');
}
function SearchmachineList(fromclick) {
if (!fromclick)
ClearMachinInfo();
var val = $('#searchinputtxt').val();
if (val.length > 100) {
val = val.substr(0, 100);
$('#searchinputtxt').val(val);
}
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
type: $('#typeselectinput').find("option:selected").val(),
searchtxt: htmlencode($.trim($('#searchinputtxt').val())),
MethodName: "SearchmachineList"
},
success: function (datastr) {
$('#machines_tbody').empty();
if (datastr != "") {
var machinesdata = eval("(" + datastr + ")");
$('#dropDIV').css('display', '');
var maxtcount = 50;
if (machinesdata.length <= 50)
maxtcount = machinesdata.length;
for (var i = 0; i < maxtcount; i++) {
var tr = $('<tr></tr>').attr({ 'rowindex': i, 'id': machinesdata[i].MachineID }).click(function () {
$('#searchinputtxt').val($(this)[0].attributes['id'].value);
$('#machines_tbody tr').each(function () {
$(this).removeClass("selected");
})
$(this).addClass("selected");
OnSearch();
$('#dropDIV').hide();
});
var tdid = $('<td></td>').text(machinesdata[i].MachineID);
var tdvin = $('<td></td>').text(machinesdata[i].VIN);
var tdname = $('<td></td>').text(machinesdata[i].DisplayName);
var tdmake = $('<td></td>').text(machinesdata[i].Make);
var tdmodel = $('<td></td>').text(machinesdata[i].Model);
var tdtype = $('<td></td>').text(machinesdata[i].MachineType);
tr.append(tdid, tdvin, tdname, tdmake, tdmodel, tdtype);
$('#machines_tbody').append(tr);
}
}
else {
$('#dropDIV').css('display', '');
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function GetTypesData() {
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
MethodName: "GetTypesData"
},
success: function (data) {
$('#typeselectinput').empty();
$("<option></option>").val("").text(GetTextByKey("P_SELECT_ALL", "All")).appendTo($("#typeselectinput"));
if (data != "" && data != "[]") {
var datattype = JSON.parse(data);
for (var i = 0; i < datattype.length; i++) {
$("<option></option>").val(datattype[i].Key).text(datattype[i].Value).appendTo($("#typeselectinput"));
}
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function GetRecordesbymachineID() {
showloading(true);
if ($('#mid').val() == "") {
showAlert(GetTextByKey("P_MRM_SAVEWORKORDERFIRST", "Please select an Asset."), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"));
return false;
}
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
machineID: $('#mid').val(),
MethodName: "GetRecordsbymachineID"
},
success: function (datastr) {
showloading(false);
if (datastr != "") {
var recordsdata = eval("(" + datastr + ")");
showRecordList(recordsdata);
}
},
error: function (msg) {
showloading(false);
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function showRecordList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
var distype = r.LogType;
if (r.LogType == "TimeOffRoad")
distype = 'Time/Off-Road';
else if (r.LogType == "TimeOverRoad")
distype = 'Time/Over Road';
for (var j in r) {
if (j === "LogType") {
r[j] = { DisplayValue: distype, Value: r[j] };
}
else if (j === "MaintenanceDate") {
r[j] = { DisplayValue: r["StrForMaintenanceDate"], Value: r[j] };
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_dt.setData(rows);
}
var grid_dt;
function InitGridData() {
grid_dt = new GridView('#recordlist');
grid_dt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
var list_columns = [
{ name: 'MaintenanceDate', caption: GetTextByKey("P_MRM_DATE", "Date"), valueIndex: 'MaintenanceDate', css: { 'width': 90, 'text-align': 'left' } },
{ name: 'LogType', caption: GetTextByKey("P_MRM_MAINTENANCETYPE", "Maintenance Type"), valueIndex: 'LogType', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'MaintenanceHours', caption: GetTextByKey("P_MRM_MAINTENANCEHOURS", "Maintenance Hours"), valueIndex: 'MaintenanceHours', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'ODOMeter', caption: GetTextByKey("P_MRM_MAINTENANCEDISTANCE", "Maintenance Distance"), valueIndex: 'ODOMeter', css: { 'width': 135, 'text-align': 'left' } },
{ name: 'ODOMemterUOM', caption: GetTextByKey("P_MRM_DISTANCEUOM", "Distance UOM"), valueIndex: 'ODOMemterUOM', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'Cost', caption: GetTextByKey("P_MRM_COST", "Cost"), valueIndex: 'Cost', css: { 'width': 100, 'text-align': 'left' } },
{ name: 'InvoiceNumber', caption: GetTextByKey("P_MRM_INVOICENUMBER", "Invoice Number"), valueIndex: 'InvoiceNumber', css: { 'width': 110, 'text-align': 'left' } },
{ name: 'CompletedByName', caption: GetTextByKey("P_MRM_COMPLETEDBY", "Completed By"), valueIndex: 'CompletedByName', css: { 'width': 110, 'text-align': 'left' } },
{ name: 'Notes', caption: GetTextByKey("P_MRM_DESCRIPTION", "Description"), valueIndex: 'Notes', css: { 'width': 190, 'text-align': 'left' } },
{ name: 'Edit', caption: "", css: { 'width': 30, 'text-align': 'center' } },
{ name: 'Delete', caption: "", css: { 'width': 30, 'text-align': 'center' } }
];
var columns = [];
// head
for (var hd in list_columns) {
var col = {};
col.name = list_columns[hd].name;
col.caption = list_columns[hd].caption;
col.visible = true;
col.sortable = true;
col.width = list_columns[hd].css.width;
col.align = list_columns[hd].css["text-align"]
col.key = list_columns[hd].valueIndex;
if (col.name === "Edit") {
col.isurl = true;
col.text = "\uf044";
col.events = {
onclick: function () {
OnEdit();
}
};
col.classFilter = function (e) {
return "icon-col";
}
col.attrs = { 'title': GetTextByKey("P_MRM_EDIT", 'Edit') };
}
else if (col.name === "Delete") {
col.isurl = true;
col.text = "\uf00d";
col.events = {
onclick: function () {
OnDelete(this);
}
};
col.classFilter = function (e) {
return "icon-col";
};
col.attrs = { 'title': GetTextByKey("P_MRM_DELETE", 'Delete') };
}
columns.push(col);
}
grid_dt.canMultiSelect = false;
grid_dt.columns = columns;
grid_dt.init();
grid_dt.rowdblclick = OnEdit;
grid_dt.selectedrowchanged = function (rowindex) {
var rowdata = grid_dt.source[rowindex];
if (rowdata) {
}
}
}
function OnSearch() {
var machineID = $.trim($('#searchinputtxt').val());
if (machineID.length == 0) {
SearchmachineList(true);
return;
}
ClearMachinInfo();
$.ajax(
{
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
machineID: htmldecode($.trim($('#searchinputtxt').val())),
MethodName: "GetmachineInfo"
},
success: function (datastr) {
if (datastr != "") {
var machinesdata = eval("(" + datastr + ")");
if (machinesdata.MachineID == -1) {
SearchmachineList(true);
return;
}
else {
refreshDom(machinesdata);
GetRecordesbymachineID();
}
}
},
error: function (msg) {
showAlert(msg.statusText, GetTextByKey("P_MRM_ERROR", 'Error'));
}
}
)
}
function ClearMachinInfo() {
$('#mid').val('');
$('#mpin').val('');
$('#mname').val('');
$('#mmake').val('');
$('#mmodel').val('');
$('#mtype').val('');
$('#mengine').val('');
//$('#records_tbody').empty();//TODO
}
function refreshDom(data) {
$('#mid').val(data.MachineID);
$('#mpin').val(data.VIN);
$('#mname').val(data.DisplayName);
$('#mmake').val(data.Make);
$('#mmodel').val(data.Model);
$('#mtype').val(data.MachineType);
$('#mengine').val(data.EngineHours);
}
//执行iframe中函数
var doIFrameFunc = function (v_mymethod, v_params, v_frmName) {
if (document.getElementById(v_frmName)) {
var fn = document.getElementById(v_frmName).contentWindow[v_mymethod];
if (fn) {
if (v_params == null)
return fn();
else {
return fn.apply(this, v_params);
}
}
return null;
}
}
function CloseDialog(type) {
$('#dialog_maintenancerecord').hideDialog();
if (type == 1) {
GetRecordesbymachineID();
}
else {
showmaskbg(false);
}
}
function DoubleClick(e) {
OnEdit();
}
function OnAdd() {
var machineid = $('#mid').val()
if (machineid == "") {
showAlert(GetTextByKey("P_MRM_SAVEWORKORDERFIRST", "Please select an Asset."), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"));
return false;
}
doIFrameFunc("init", [machineid], "iframemaintenancerecord");
showmaskbg(true);
$('#dialog_maintenancerecord')
.attr('act', 'add')
.showDialogRight();
}
function OnEdit() {
var record = grid_dt.source[grid_dt.selectedIndex].Values;
doIFrameFunc("init", [record.MachineID, record.MaintenanceID], "iframemaintenancerecord");
showmaskbg(true);
$('#dialog_maintenancerecord')
.attr('act', 'edit')
.showDialogRight();
}
function OnDelete(record) {
showConfirm(GetTextByKey("P_MRM_DELETETHERECORD", "Would you like to delete the record?"), GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information"), function () {
$.ajax({
type: "POST",
async: false,
datatype: "json",
url: "MachineMaintenanceInfo.aspx",
data: {
maintenanceid: record.MaintenanceID,
MethodName: "Deletemaintenance"
},
success: function (msg) {
GetRecordesbymachineID();
showAlert(GetTextByKey('P_MRM_DELETEDSUCCESSFULLY', 'Deleted Successfully.'), GetTextByKey("P_MRM_SYSTEMINFORMATION", GetTextByKey("P_MRM_SYSTEMINFORMATION", "System Information")));
},
error: function (msg) {
showAlert(GetTextByKey('P_MRM_FAILEDTODELETERECORD', 'Failed to delete record.'), GetTextByKey("P_MRM_ERROR", 'Error'));
}
})
}, function () { return false; });
}
function back() {
if (assetid && assetid !== "")
window.location.href = "MaintanceRecordsManagement.aspx?InDialog=" +<%=InDialog?"1": "0"%>+"&mid=" + assetid;
else
window.location.href = "MaintanceRecordsManagement.aspx";
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="content_main" style="min-width: 1000px; padding-left: 15px;">
<div class="page_title">
<span class="sbutton iconback" onclick="back();"></span>
<span data-lgid="P_MRM_ADDMAINTENANCERECORD">Add Maintenance Record</span>
</div>
<div class="clear"></div>
<div style="border: 1px solid #b0b0b0; padding: 0px; padding-top: 20px; padding-bottom: 20px; margin: 0px; margin-top: 10px; margin-bottom: 20px; position: relative; height: 30px;">
<span style="margin-left: 10px;" data-lgid="P_MRM_TYPE_COLON">Type: </span>&nbsp;
<select class="selectinput" id="typeselectinput" style="width: 150px;"></select>
<input id="searchinputtxt" autocomplete="off" style="width: 500px; padding: 0px; height: 18px; margin: 0px; border: 1px solid #b0b0b0;" />
<input class="search cupbutton" type="button" onclick="OnSearch();" value="Search" data-lgid="P_MRM_SEARCH" />
<span id="currentmachineID"></span>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MRM_SEARCHASSET">Search Asset</div>
<div id="dropDIV" style="border: 1px solid #b0b0b0; width: 500px; height: 400px; overflow: auto; position: absolute; top: 43px; left: 200px; background-color: Window; display: none; z-index: 10;">
<table id="droptable" class="main_table" style="border: none;">
<thead>
<tr id="droptitle" style="border-width: 0px; background-color: #d3d1d1;">
<th style="width: 100px;" data-lgid="P_MRM_ASSETID">&nbsp;AssetID</th>
<th style="width: 200px;" data-lgid="P_MRM_SN">&nbsp;SN</th>
<th data-lgid="P_MRM_ASSETNAME">&nbsp;Asset Name</th>
<th data-lgid="P_MRM_MAKE">&nbsp;Make</th>
<th data-lgid="P_MRM_MODEL">&nbsp;Model</th>
<th data-lgid="P_MRM_ASSETTYPE">&nbsp;Type</th>
</tr>
</thead>
<tbody id="machines_tbody">
</tbody>
</table>
</div>
</div>
<div style="border: 1px solid #b0b0b0; position: relative; margin-bottom: 20px; padding-bottom: 10px;">
<table>
<tr>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETID1_COLON">AssetID:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mid" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_SN_COLON">SN:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mpin" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETNAME_COLON">Asset Name:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mname" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ENGINEHOURS_COLON">Engine Hours:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mengine" disabled="disabled" /></td>
</tr>
<tr>
<td class="labeltdstyle" data-lgid="P_MRM_MAKE_COLON">Make:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mmake" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_MODEL_COLON">Model:</td>
<td class="inputtdstyle">
<input class="selectinput" id="mmodel" disabled="disabled" /></td>
<td class="labeltdstyle" data-lgid="P_MRM_ASSETTYPE_COLON">Type:</td>
<td class="inputtdstyle" colspan="3">
<input class="selectinput" id="mtype" style="width: 99.5%;" disabled="disabled" /></td>
<%-- <td class="labeltdstyle"></td>
<td class="inputtdstyle"></td>--%>
</tr>
</table>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MRM_ASSETINFORMATION">Asset Information</div>
</div>
<div style="border: 1px solid #b0b0b0; position: relative; padding-top: 0px; padding-bottom: 10px;">
<div style="float: right; margin-top: 10px; margin-bottom: 10px; padding-right: 20px;">
<input type="button" class="cupbutton" onclick="OnAdd();" value="Add" data-lgid="P_MRM_ADD" />
<input type="button" class="cupbutton" onclick="GetRecordesbymachineID();" value="Refresh" data-lgid="P_MRM_REFRESH" />
</div>
<div id="recordlist" style="margin-top: 50px;"></div>
<div style="position: absolute; top: -10px; left: 10px; background-color: Window;" data-lgid="P_MAINTENANCERECORDS">Maintenance Records</div>
</div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
<div class="dialog" id="dialog_maintenancerecord" style="display: none; height: 100%; border-bottom: 0; border-top: 0;">
<iframe id="iframemaintenancerecord" src="AddMaintenanceRecord.aspx" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
<div class="maskbg" style="display: none;"></div>
</div>
</asp:Content>