一厂MES,含注塑,喷涂,冲孔
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.

578 lines
23 KiB

3 months ago
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KeepRecord.aspx.cs" Inherits="MESWebSite.Manage.KeepRecord" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/CSS/Basics.css" rel="stylesheet" />
<link href="/Scripts/jquery-easyui-1.4.3/themes/metro/easyui.css" rel="stylesheet" type="text/css" />
<link href="/Scripts/jquery-easyui-1.4.3/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="/Scripts/jquery-easyui-1.4.3/themes/color.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-easyui-1.4.3/jquery.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-easyui-1.4.3/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/Scripts/MyJs.js" type="text/javascript"></script>
<title>设备保养管理</title>
</head>
<body>
<form id="form1" runat="server">
<div class="top">
<table style="width: 100%">
<tr style="display: flex;flex-direction: row; flex-wrap: wrap;">
<td><span class="title">设备保养管理</span>
</td>
<td style="width: 100px;"></td>
<td style="float: left">保养日期:
<input id="StartTime_s" class="easyui-datebox" style="width: 130px;" />&nbsp;至&nbsp;
<input id="EndTime_s" class="easyui-datebox" style="width: 130px;" />
&nbsp;&nbsp;保养设备:
<select id="device_id_s" class="easyui-combobox" style="width: 180px; height: 30px;"
data-options="valueField: 'DeviceID',textField: 'DeviceName'">
</select>
&nbsp;&nbsp;<a class="topsearchBtn" id="searchBtn">查询</a>
&nbsp;&nbsp;<a class="toppenBtn" id="recordEditBtn">编辑保养记录</a>
&nbsp;&nbsp;<a class="toppenBtn" id="recordSearchBtn">保养记录查看</a>
</td>
</tr>
</table>
</div>
<div id="ReportTable_div" style="float: left;width:100%">
<table id="tb" title="设备保养管理" style="width: 99%;">
</table>
</div>
<div id="Report_div" hidden="hidden" style="float: left; width: 100%">
<span id="ReportDate" style="float: left;"></span>
<span id="ReportP" style="float: left; margin-left: 100px;"></span>
<span id="ReportD" style="float: left; margin-left: 100px;"></span>
<span id="DeviceModel" style="float: left; margin-left: 100px;"></span>
<span id="FixNo" style="float: left; margin-left: 100px;"></span>
</div>
<div id="RecordDiv" style="float: left; margin-top: 20px;"></div>
<!-- 编辑窗口 -->
<div id="w" style="padding: 10px; visibility: hidden" title="编辑">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="title" style="width: 80px;">
<p>
保养日期:
</p>
</td>
<td>
<input id="KeepTime" class="easyui-datebox" style="width: 100px;" disabled />
</td>
<td class="title" style="width: 80px; padding-left: 20px;">
<p>
保养设备:
</p>
</td>
<td>
<select id="device_id" class="easyui-combobox" style="width: 150px; height: 25px;"
data-options="valueField: 'DeviceID',textField: 'DeviceName'" disabled>
</select>
</td>
<td class="title" style="width: 80px; padding-left: 20px;">
<p>
保养等级:
</p>
</td>
<td>
<select id="fl_id" class="easyui-combobox" style="width: 100px; height: 25px;"
data-options="valueField: 'valueField',textField: 'textField'" disabled>
</select>
</td>
<td class="title" style="width: 50px; padding-left: 20px;">
<p>
版本:
</p>
</td>
<td>
<select id="version_id" class="easyui-combobox" style="width: 100px; height: 25px;"
data-options="valueField: 'ID',textField: 'Version'">
</select>
</td>
</tr>
</table>
<div id="itable"></div>
<table border="1" width="900" cellspacing="0" cellpadding="5">
<tr>
<td width="200">检查者</td>
<td width="200">
<select class="easyui-combobox" id="CheckUserCombo" style="width: 200px; height: 25px;" data-options="valueField: 'UserID',textField: 'RealName'"></select></td>
<td width="200">确认者</td>
<td width="200">
<select class="easyui-combobox" id="ConfirmUserCombo" style="width: 200px; height: 25px;" data-options="valueField: 'UserID',textField: 'RealName'"></select></td>
</tr>
</table>
</div>
<!-- 编辑窗口 - footer -->
<div id="ft" style="padding: 10px; text-align: center; background-color: #f9f9f9; visibility: hidden">
<a class="saveBtn" id="saveBtn">保存</a> <a class="saveBtn" id="flashBtn">刷新</a>
<input id="KeepPlanID" type="text" hidden="hidden" runat="server" />
</div>
<div style="padding: 10px; text-align: center; background-color: #f9f9f9;">
</div>
<input id="UserID" type="text" hidden="hidden" runat="server" />
<script>
/**************** 全局变量 ***************/
var PrimaryID; //要编辑的id
var dg = $('#tb'); //表格
var isEdit = false; //是否为编辑状态
/**************** DOM加载 ***************/
$(function () {
$.ajaxSetup({
cache: false //关闭AJAX缓存
});
//初始化查询时间
var curr_time = new Date();
var str = curr_time.getFullYear() + "-";
str += curr_time.getMonth() + 1 + "-";
str += curr_time.getDate()
$('#StartTime_s').datebox('setValue', str + " 00:00:00");
$('#EndTime_s').datebox('setValue', str + " 23:59:59");
$('#BeginTime').datetimebox({
required: true,
showSeconds: true
});
//初始化查询下拉框数据
reloadfl_ids();
//编辑按钮点击
$('#recordEditBtn').first().click(function () {
isEdit = true;
reloadfl_id();
initEidtWidget();
});
//删除按钮
$('.topdelBtn').first().click(function () {
$.messager.confirm('提示框', '你确定要删除吗?', function (r) {
if (r) {
deleteInfos();
}
});
});
//搜索按钮
$('#searchBtn').first().click(function () {
$("#RecordDiv").attr("style", "display:none;");//隐藏div
$("#ReportTable_div").attr("style", "display:block;");//显示div
$('#Report_div').hide();
SearchInfo();
});
//保养记录查询
$('#recordSearchBtn').first().click(function () {
var selRows = dg.datagrid('getSelections');
if (selRows.length > 1) {
$.messager.alert('提示', '只能选择一条记录,请重新选取', 'warning');
return;
} else if (selRows.length == 0) {
$.messager.alert('提示', '请选择一条记录进行查看', 'warning');
return;
}
$("#ReportTable_div").attr("style", "display:none;");//隐藏div
$("#RecordDiv").attr("style", "display:block;");//显示div
$('#Report_div').show();
var row = selRows[0];
var pa = /.*\((.*)\)/;
var unixtime = row.KeepDay.match(pa)[1].substring(0, 10);
$('#ReportDate').html("保养日期:"+getTime(unixtime).substring(0, 10));
$('#ReportP').html("保养等级:" + row.KeepLevelName);
$.ajax({
url: "KeepRecord.aspx/GetRecordDate",
datatype: 'json',
type: "Post",
data: "{'PlanID':'" + row.ID + "'}",
contentType: "application/json; charset=utf-8",
success: function (data) {
$('#RecordDiv').html("");
if (data != null && data.d != "") {
try {
$('#RecordDiv').html(data.d);
} catch (e) {
}
}
}
});
$('#RecordDiv').html("123");
});
//保存按钮
$('#saveBtn').bind('click', function () {
SaveInfo();
});
$('#CheckUserCombo').combobox({
url: '/HttpHandlers/UserHandler.ashx?method=QueryForCombobox',
onLoadSuccess: function () {
var val = $(this).combobox('getData');
$(this).combobox('select', val[0].UserID);
}
});
$('#ConfirmUserCombo').combobox({
url: '/HttpHandlers/UserHandler.ashx?method=QueryForCombobox',
onLoadSuccess: function () {
var val = $(this).combobox('getData');
$(this).combobox('select', val[0].UserID);
}
});
//编辑窗口加载
$('#w').window({
modal: true,
closed: true,
minimizable: false,
maximizable: false,
collapsible: false,
width: 960,
height: 700,
footer: '#ft',
top: 20,
onBeforeClose: function () { clearw(); },
onBeforeOpen: function () {
$('#w').css('visibility', 'visible'); $('#ft').css('visibility', 'visible');
}
});
$('#flashBtn').bind('click', function () {
var VersionID = $('#version_id').combobox('getValue');
EditRecord(VersionID);
});
dg = $('#tb').datagrid({
fitColumns: true,
nowrap: false,
striped: true,
collapsible: false,
url: "/HttpHandlers/KeepPlanHandler.ashx?method=QueryList",
//sortName: 'sortNumber',
//sortOrder: 'asc',
remoteSort: false,
columns: [[
{ field: 'ID', title: 'ID', hidden: true },
{ field: 'KeepLevelID', title: 'KeepLevelID', hidden: true },
{ field: 'DeviceID', title: 'DeviceID', hidden: true },
{
field: 'KeepDay', title: '保养日期', sortable: 'true', width: 10,
formatter: function (date) {
var pa = /.*\((.*)\)/;
var unixtime = date.match(pa)[1].substring(0, 10);
return getTime(unixtime).substring(0, 10);
}
},
{ field: 'DeviceName', title: '设备', sortable: 'true', width: 10 },
{ field: 'KeepLevelName', title: '保养等级', sortable: 'true', width: 10 },
{ field: 'Des', title: '描述', sortable: 'true', width: 10 }
]],
pagination: true,//表示在datagrid设置分页
rownumbers: true,
singleSelect: true
});
});
/**************** 主要业务程序 ***************/
// 编辑
function EditRecord(VersionID) {
var KeepTime = $('#KeepTime').datetimebox('getValue');
var DeviceID = $('#device_id').combobox('getValue');
var KeepLevelID = $('#fl_id').combobox('getValue');
//获取点检内容
$.ajax({
url: "KeepRecord.aspx/GetDate",
datatype: 'json',
type: "Post",
data: "{'VersionID':'" + VersionID + "','KeepTime':'" + KeepTime + "','DeviceID':'" + DeviceID + "','KeepLevelID':'" + KeepLevelID + "'}",
contentType: "application/json; charset=utf-8",
success: function (data) {
$('#itable').html("");
if (data != null && data.d != "") {
try {
$('#itable').html(data.d);
var CheckUserID = $('#CheckUserID').val();
var ConfirmUserID = $('#ConfirmUserID').val();
if (CheckUserID != "") {
$('#CheckUserCombo').combobox('select', CheckUserID);
}
else {
$('#CheckUserCombo').combobox('clear');
}
if (ConfirmUserID != "") {
$('#ConfirmUserCombo').combobox('select', ConfirmUserID);
}
else {
$('#ConfirmUserCombo').combobox('clear');
}
} catch (e) {
}
}
}
});
}
function SaveInfo() {
var CommonlyInspection = "";
$("#itable").find("select").each(function (i, n) {
var obj = $(n)
CommonlyInspection += obj.attr('name') + ":" + obj.val() + ",";
});
$("#itable").find("input").each(function (i, n) {
var obj = $(n)
CommonlyInspection += obj.attr('name') + ":" + obj.val() + ",";
});
var CheckUserID = $('#CheckUserCombo').combo('getValue');
var ConfirmUserID = $('#ConfirmUserCombo').combo('getValue');
var CheckDate = $('#KeepTime').datetimebox('getValue');
//var CheckType = $('#CheckType').combobox('getValue');
var userid = $('#UserID').val();
//var ErrMes = $('#ErrMes').val();
var KeepPlanID = $('#KeepPlanID').val();
var method = "AddInfo";
if ($('#InspectionContentFlag').val() == "0") {
method = "AddInfo";
}
if ($('#InspectionContentFlag').val() == "1") {
method = "EditInfo";
}
var model = {
CommonlyInspection: CommonlyInspection,
CheckUserID: CheckUserID,
ConfirmUserID: ConfirmUserID,
UserID: userid,
CheckDate: CheckDate,
KeepPlanID: KeepPlanID,
//CheckType: CheckType,
//ErrMes: ErrMes,
method: method
};
SaveModel(model);
}
function SaveModel(model) {
$.ajax({
type: "POST",
async: false,
url: "/HttpHandlers/KeepRecordHandler.ashx",
data: model,
success: function (data) {
if (data == 'true') {
$.messager.alert('提示', '已保存', 'info');
$('#w').window('close');
}
else {
$.messager.alert('提示', '保存失败', 'warning');
}
},
error: function () {
}
});
}
//查询方法
function SearchInfo2() {
try {
var time = $('#start_time').datetimebox('getValue');
time = time.substr(0, 7);
var pl = "产线:" + $('#fl_id_s').combobox('getText');
var de = "设备:" + $('#device_id_s').combobox('getText');
var DeviceID = $('#device_id_s').combobox('getValue');
$('#ReportDate').html(time);
$('#ReportP').html(pl);
$('#ReportD').html(de);
$.ajax({
url: "CommonlyInspection.aspx/QueryOne",
datatype: 'json',
type: "Post",
data: "{'DeviceID':'" + DeviceID + "'}",
contentType: "application/json; charset=utf-8",
success: function (data) {
if (data != null && data.d != "") {
var obj = JSON.parse(data.d);
$('#FixNo').html("固定资产号:" + obj.FixNo);
$('#DeviceModel').html("设备型号:" + obj.DeviceModel);
}
}
});
$('#Report_div').show();
var VersionID = $('#version_id_s').combobox('getValue');
$.ajax({
url: "CommonlyInspection.aspx/GetReportDate",
datatype: 'json',
type: "Post",
data: "{'VersionID':'" + VersionID + "','CheckDate':'" + time + "'}",
contentType: "application/json; charset=utf-8",
success: function (data) {
$('#itable').html("");
if (data != null && data.d != "") {
$('#ReportTable_div').html(data.d);
}
else {
$('#ReportTable_div').html('');
}
}
});
} catch (e) {
}
}
//查询方法
function SearchInfo() {
var KeepLevelID = "";
var DeviceID = $('#device_id_s').combo('getValue');
var StartTime = $('#StartTime_s').datetimebox('getValue');
var EndTime = $('#EndTime_s').datetimebox('getValue');
var queryParams = {
KeepLevelID: KeepLevelID,
DeviceID: DeviceID,
StartTime: StartTime,
EndTime: EndTime
};
dg.datagrid({
queryParams: queryParams
});
dg.datagrid('reload');
}
function initEidtWidget() {
var selRows = dg.datagrid('getSelections');
if (selRows.length > 1) {
$.messager.alert('提示', '每次只能编辑一条记录,请重新选取', 'warning');
return;
} else if (selRows.length == 0) {
$.messager.alert('提示', '请选择一条记录进行编辑', 'warning');
return;
}
//窗体数据初始化
var row = selRows[0];
PrimaryID = row.ID;
var pa = /.*\((.*)\)/;
var unixtime = row.KeepDay.match(pa)[1].substring(0, 10);
$('#KeepPlanID').val(row.ID);
$('#KeepTime').datebox('setValue', getTime(unixtime).substring(0, 10))
$('#fl_id').combobox('select', row.KeepLevelID);
$('#device_id').combobox('select', row.DeviceID);
$('#version_id').combobox({
url: '/HttpHandlers/KeepVersionHandler.ashx?method=QueryForCombobox&&d_id=' + row.DeviceID + '',
onLoadSuccess: function () {
var val = $(this).combobox('getData');
$(this).combobox('select', val[0].ID);
EditRecord(val[0].ID);
},
onSelect: function (row) {
}
});
$('#w').window('open');
}
/**************** 辅助业务程序 ***************/
//编辑窗口关闭清空数据
function clearw() {
$('#fl_id').combobox('clear');
$('#device_id').combobox('clear');
$('#version_id').combobox('clear');
$('#CheckDate').datetimebox('setValue', '');
$('#itable').html('');
}
function ww4(date) {
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
}
function reloadfl_ids() {
$('#device_id_s').combobox('reload', '/HttpHandlers/DeviceHandler.ashx?method=QueryForCombobox');
}
function reloadfl_id() {
$('#fl_id').combobox('reload', '/HttpHandlers/KeepLevelHandler.ashx?method=QueryForCombobox');
$('#device_id').combobox('reload', '/HttpHandlers/DeviceHandler.ashx?method=QueryForCombobox');
}
</script>
</form>
</body>
</html>