一厂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.

660 lines
27 KiB

3 months ago
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InjectionPlan.aspx.cs" Inherits="MESWebSite.Manage.InjectionPlan" %>
<!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>
<style>
#w td {
padding: 5px 5px;
text-align: left;
vertical-align: middle;
}
#w .title {
vertical-align: middle;
text-align: right;
width: 80px;
height: 40px;
}
p {
padding: 5px;
font-size: small;
font-family: 微软雅黑;
}
.datagrid {
text-align: center;
}
</style>
<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="width: 260px;">机台:
<select id="fl_id_s" class="easyui-combobox" style="width: 160px; height: 30px;"
data-options="valueField: 'StationID',textField: 'StationNo'">
</select></td>
<td style="width: 260px;">配置:
<input type="text" id="StockNo_s" style="width: 140px;" /></td>
<td style="width: 80px;"><a class="topsearchBtn">查询</a></td>
<td style="width: 80px">
<a class="topaddBtn">新增</a>
</td>
<td style="width: 80px">
<a class="toppenBtn">编辑</a>
</td>
<td style="width: 80px">
<a class="topdelBtn">删除</a>
</td>
</tr>
</table>
</div>
<table id="tb" title="注塑计划" style="width: 99%;">
</table>
<!-- 编辑窗口 -->
<div id="w" style="padding: 10px; visibility: hidden" title="编辑">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="title" style="width: 110px;">
<p>
机台:
</p>
</td>
<td colspan="2">
<select id="fl_id" class="easyui-combobox" style="width: 234px; height: 36px;"
data-options="valueField: 'StationID',textField: 'StationNo'">
</select><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
</td>
</tr>
<tr>
<td class="title" style="width: 110px;">
<p>
配置:
</p>
</td>
<td colspan="2">
<select id="fl_id_p2" class="easyui-combobox" style="width: 234px; height: 36px;">
</select>
<%-- <select id="fl_id_p" class="easyui-combobox" style="width: 234px; height: 36px;"
data-options="valueField: 'c_id',textField: 'c_name'">
</select><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>--%>
</td>
</tr>
<%-- <tr>
<td class="title" style="width: 110px;">
<p>
零件号:
</p>
</td>
<td colspan="2">
<input id="PartNo" type="text" class="text" style="width: 230px; height: 30px;" disabled />
</td>
</tr>--%>
<tr>
<td class="title" style="width: 110px;">
<p>
计划开始时间:
</p>
</td>
<td colspan="2">
<input id="BeginTime" type="text" style="width: 234px; height: 36px;" />
</td>
</tr>
<tr>
<td class="title" style="width: 110px;">
<p>
计划数量:
</p>
</td>
<td colspan="2">
<input id="PlanCount" type="text" class="text" style="width: 230px; height: 30px;" />
</td>
</tr>
<tr>
<td class="title" style="width: 110px;">
<p>
计划停机时间:
</p>
</td>
<td colspan="2">
<input id="EndTime" type="text" class="text" style="width: 230px; height: 30px;" disabled />
</td>
</tr>
<tr>
<td class="title" style="width: 110px;">
<p>
实际周期:
</p>
</td>
<td colspan="2">
<input id="RealCycle" type="text" class="text" style="width: 230px; height: 30px;" />
</td>
</tr>
<tr>
<td class="title" style="width: 110px;">
<p>
产品性质:
</p>
</td>
<td colspan="2">
<select id="ProductNature" class="easyui-combobox" style="width: 100px; height: 30px;">
<option value='正常件'>正常件</option>
<option value='售后件'>售后件</option>
</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>
</div>
<div hidden="hidden">
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</div>
<input id="UserID" type="text" hidden="hidden" runat="server" />
<input id="PartNo_h" type="text" hidden="hidden" runat="server" />
<script>
/**************** 全局变量 ***************/
var PrimaryID; //要编辑的id
var dg = $('#tb'); //表格
var isEdit = false; //是否为编辑状态
/**************** DOM加载 ***************/
$(function () {
$.ajaxSetup({
cache: false //关闭AJAX缓存
});
$('#BeginTime').datetimebox({
required: true,
showSeconds: true
});
$("#PlanCount").blur(function () {
var StationID = $('#fl_id').combobox('getValue');
var PartNo = $('#fl_id_p2').combobox('getValues').join(",");
var BeginTime = $('#BeginTime').datetimebox('getValue');
var PlanCount = $('#PlanCount').val();
var model = {
StationID: StationID,
PartNo: PartNo,
BeginTime: BeginTime,
PlanCount: PlanCount,
method: 'GetEndTime'
};
$.ajax({
type: "POST",
async: false,
url: "/HttpHandlers/InjectionPlanHandler.ashx",
data: model,
success: function (data) {
if (data == null || data == "") {
alert("未维护标准周期");
} else {
if (BeginTime == data) {
alert("开始时间等于结束时间,未维护标准周期");
return
}
$('#EndTime').val(data);
}
},
error: function () {
}
});
});
$('#fl_id').combobox({
url: '/HttpHandlers/StationHandler.ashx?method=QueryForCombobox&StationNo=IM',
onLoadSuccess: function () {
},
onSelect: function (row) {
var model = {
StationID: row.StationID,
method: 'GetStartTime'
};
$.ajax({
type: "POST",
async: false,
url: "/HttpHandlers/InjectionPlanHandler.ashx",
data: model,
success: function (data) {
$('#BeginTime').datetimebox('setValue', data);
},
error: function () {
}
});
$('#fl_id_p2').combobox({
editable: false,// 不能直接输入到列表框
missingMesage: '请选择',
valueField: 'c_id',
textField: 'c_text',
multiple: true,// 设置下拉框的值可以多选
url: '/HttpHandlers/PlasticHandler.ashx?method=QueryForCombobox&StationID=' + row.StationID,
type: "post",
queryParams: {
},
onShowPanel: function () {
var v = $(this).combobox('panel')[0].childElementCount;
// 判断下拉框高度(如果下拉框的数值小于10个,那么下拉框高度自动显示,如果大于10个,下拉框高度最高200)
if (v <= 10) {
$(this).combobox('panel')
.height("auto");
} else {
$(this).combobox('panel')
.height(200);
}
},
onLoadSuccess: function (res) {
//// 下拉框默认选择第一项
//if (res) {
// var val = $(this).combobox('getData');
// $(this).combobox('select', val[0]['c_id']); //这个数据根据自己情况来设定
//}
},
onSelect: function (record) {
//$('#PartNo').val($('#PartNo').val()+","+record.c_text);
}
});
$('#fl_id_p2').combobox('enable');//解决修改界面选择机台后配置无法选择的BUG
}
});
//开始时间选择
$('#BeginTime').datetimebox({
stopFirstChangeEvent: true,
onChange: function () {
var options = $(this).datetimebox('options');
if (options.stopFirstChangeEvent) {
options.stopFirstChangeEvent = false;
return;
}
var BeginTime = $('#BeginTime').datetimebox('getValue');
var PlanCount = $('#PlanCount').val();
var StationID = $('#fl_id').combobox('getValue');
var PartNo = $('#fl_id_p2').combobox('getValues').join(",");
//alert(BeginTime);
var model = {
StationID: StationID,
PartNo: PartNo,
BeginTime: BeginTime,
PlanCount: PlanCount,
method: 'GetEndTime'
};
$.ajax({
type: "POST",
async: false,
url: "/HttpHandlers/InjectionPlanHandler.ashx",
data: model,
success: function (data) {
//alert(data);
if (data == null || data == "") {
//alert("未维护标准周期");
} else {
//if (BeginTime == data) {
// alert("开始时间等于结束时间,未维护标准周期");
// return;
//}
var s = new Date(Date.parse(BeginTime.replace(/-/g, "/")));
var e = new Date(Date.parse(data.replace(/-/g, "/")));
if (s >= e) {
$.messager.alert('提示', '开始时间不能大于结束时间=,请重新输入', 'warning');
return;
}
$('#EndTime').val(data);
}
},
error: function () {
}
});
}
});
//下拉框加载
reloadfl_ids();
//新增按钮点击
$('.topaddBtn').first().click(function () {
isEdit = false;
$('#w').window('open');
$('#RealCycle').attr("disabled", false)//将input元素设置为disabled
$('#fl_id').combobox('enable');
$('#fl_id_p2').combobox('enable');
$('#BeginTime').datetimebox('enable');
$('#ProductNature').combobox('enable');
});
//编辑按钮点击
$('.toppenBtn').first().click(function () {
isEdit = true;
initEidtWidget();
});
//删除按钮
$('.topdelBtn').first().click(function () {
$.messager.confirm('提示框', '你确定要删除吗?', function (r) {
if (r) {
deleteInfos();
}
});
});
//搜索按钮
$('.topsearchBtn').first().click(function () {
SearchInfo();
});
//保存按钮
$('#saveBtn').bind('click', function () {
SaveInfo(isEdit);
});
//编辑窗口加载
$('#w').window({
modal: true,
closed: true,
minimizable: false,
maximizable: false,
collapsible: false,
width: 460,
height: 620,
footer: '#ft',
top: 20,
onBeforeClose: function () { clearw(); },
onBeforeOpen: function () {
$('#w').css('visibility', 'visible'); $('#ft').css('visibility', 'visible');
}
});
dg = $('#tb').datagrid({
fitColumns: true,
nowrap: false,
striped: true,
collapsible: false,
url: "/HttpHandlers/InjectionPlanHandler.ashx?method=QueryList",
//sortName: 'sortNumber',
//sortOrder: 'asc',
remoteSort: false,
columns: [[
{ field: 'InjectionPlanID', title: 'InjectionPlanID', hidden: true },
{ field: 'StationNo', title: '机台', sortable: 'true', width: 10 },
{ field: 'BeginTime', title: '开始时间', sortable: 'true', width: 10 },
{ field: 'PartNo', title: '零件号', sortable: 'true', width: 10 },
{ field: 'ProductName', title: '名称', sortable: 'true', width: 10 },
{ field: 'PlanCount', title: '计划数', sortable: 'true', width: 10 },
{ field: 'EndTime', title: '结束时间', sortable: 'true', width: 10 },
{ field: 'RealCycle', title: '实际周期', sortable: 'true', width: 10 },
{ field: 'ProductNature', title: '产品性质', sortable: 'true', width: 10 }
]],
pagination: true,//表示在datagrid设置分页
rownumbers: true,
singleSelect: true
});
dg.datagrid('getPager').pagination({
pageSize: 10,
pageNumber: 1,
pageList: [10, 20, 30, 40, 50],
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
});
});
/**************** 主要业务程序 ***************/
//新增 / 编辑
function SaveInfo(isEdit) {
var InjectionPlanID = isEdit == true ? PrimaryID : 0;
var StationID = $('#fl_id').combobox('getValue');
var ProductNature = $('#ProductNature').combobox('getValue');
var StockNo = '';
var BeginTime = $('#BeginTime').datetimebox('getValue');
var EndTime = $('#EndTime').val();
var PlanCount = $('#PlanCount').val();
var RealCycle = $('#RealCycle').val();
var PartNo = $('#fl_id_p2').combobox('getValues').join(",");
var PlanDate = "";
if (StationID == "") {
$.messager.alert('提示', '机号不能为空,请重新输入', 'warning');
return;
}
if (PartNo == "") {
$.messager.alert('提示', '配置不能为空,请重新输入', 'warning');
return;
}
//var re = /^\d+(?:\.\d{1,2})?$/;//小数最多2位
//var re = /^[+-]?\d+(?:\.\d{1,2})?$/;//分正负小数最多2位
var re = /^[0-9]+$/;
if (!re.test(PlanCount)) {
$.messager.alert('提示', '计划数量:请输入正确的数值!', 'warning');
return;
}
if (BeginTime == "") {
$.messager.alert('提示', '开始时间不能为空,请重新输入', 'warning');
return;
}
if (EndTime == "") {
$.messager.alert('提示', '结束时间不能为空,请重新输入', 'warning');
return;
}
if (BeginTime == EndTime) {
$.messager.alert('提示', '开始时间不能等于结束时间,未维护标准周期,请重新输入', 'warning');
return;
}
var s = new Date(Date.parse(BeginTime.replace(/-/g, "/")));
var e = new Date(Date.parse(EndTime.replace(/-/g, "/")));
if (s >= e) {
$.messager.alert('提示', '开始时间不能大于结束时间=,请重新输入', 'warning');
return;
}
var model = {
InjectionPlanID: InjectionPlanID,
StationID: StationID,
StockNo: StockNo,
BeginTime: BeginTime,
EndTime: EndTime,
PlanCount: PlanCount,
PlanDate: PlanDate,
RealCycle: RealCycle,
PartNo: PartNo,
ProductNature: ProductNature,
method: 'SaveInfo'
};
SaveModel(model);
}
function SaveModel(model) {
$.ajax({
type: "POST",
async: false,
url: "/HttpHandlers/InjectionPlanHandler.ashx",
data: model,
success: function (data) {
if (data == 'true') {
$.messager.alert('提示', '已保存', 'info');
dg.datagrid('reload');
$('#w').window('close');
}
else {
$.messager.alert('提示', '保存失败,请查看是否编号重复,或计划执行时间区间是否已经与正在执行的计划重叠', 'warning');
}
},
error: function () {
}
});
}
//查询方法
function SearchInfo() {
var StationID = $('#fl_id_s').combobox('getValue');
var StockNo = $('#StockNo_s').val();
var queryParams = {
StationID: StationID,
StockNo: StockNo
};
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.InjectionPlanID;
$('#fl_id').combobox('select', row.StationID);
$('#ProductNature').combobox('select', row.ProductNature);
$('#fl_id_p2').combobox('setValues', row.PartNo.split(','))
$('#PlanCount').val(row.PlanCount);
$('#EndTime').val(row.EndTime);
$('#RealCycle').val(row.RealCycle);
$('#RealCycle').attr("disabled", true)//将input元素设置为disabled
$('#fl_id').combobox('disable');
$('#fl_id_p2').combobox('disable');
$('#BeginTime').datetimebox('disable');
$('#ProductNature').combobox('disable');
setTimeout(function () {
$('#BeginTime').datetimebox('setValue', row.BeginTime);
}, 500);
$('#w').window('open');
}
//删除方法
function deleteInfos() {
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];
var model = {
InjectionPlanID: row.InjectionPlanID,
method: 'DelInfo'
};
$.ajax({
url: "/HttpHandlers/InjectionPlanHandler.ashx",
data: model,
async: false,
success: function (data) {
if (data == 'true') {
$.messager.alert('提示', '已删除', 'info');
dg.datagrid('reload');
}
else {
$.messager.alert('提示', '由于有关联数据,删除失败', 'warning');
}
},
error: function () {
}
});
}
/**************** 辅助业务程序 ***************/
/**********************************************/
/***************** 窗体程序 *******************/
/**********************************************/
//编辑窗口关闭清空数据
function clearw() {
$('#fl_id').combobox('clear');
$('#ProductNature').combobox('clear');
$('#BeginTime').datetimebox('setValue', '');//设值
$('#fl_id_p').combobox('clear');
$('#PlanCount').val('');
$('#EndTime').val('');
$('#RealCycle').val('');
}
function reloadfl_ids() {
$('#fl_id_s').combobox('reload', '/HttpHandlers/StationHandler.ashx?method=QueryForCombobox&StationNo=IM');
}
</script>
</form>
</body>
</html>