天津投入产出系统后端
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.

375 lines
14 KiB

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AppMaster.Master"
Inherits="System.Web.Mvc.ViewPage<QMAPP.MD.Web.Models.UserWithMachineModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
编辑修改
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%--<%=Html.QPEdit("信息", string.IsNullOrEmpty(Model.PID) ? QMFrameWork.WebUI.panelType.Add : QMFrameWork.WebUI.panelType.Update)%>--%>
<table id="editTable" cellpadding="0" cellspacing="0">
<tr>
<td>
<table>
<tr>
<th align="right">
<%=Html.QV(p => p.USERID)%>
</th>
<td>
<%=Html.QC(p => p.USERID, new { Readonly = "readonly" })%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table id="QDateGrid">
</table>
<%=Html.HiddenFor(p => p.MachineIds)%>
<%=Html.Hidden("EDITFLAG",1)%>
<%=Html.QPEnd() %>
<div id="addMachineWindow" class="easyui-window" title="新增设备信息" iconcls="icon-save"
closed="true" style="width: 400px; height: 300px; padding: 5px;">
<div class="easyui-layout" fit="true">
<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
<table id="Table3">
<tr>
<th align="right">
<%=Html.QV(p => p.MACHINEID)%>
</th>
<td>
<%=Html.QC(p => p.MACHINEID)%>
</td>
</tr>
</table>
</div>
<div region="north" border="false" style="text-align: left;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<%=Html.QTButtonSave("UserWithMachine", "TransitSave", "AddMachineSave()")%>
<%=Html.QTButtonBack("Home", "Index", "AddMachineCancel()")%>
</td>
</tr>
</table>
</div>
</div>
</div>
<script language="javascript" type="text/javascript">
$(function () {
$('#USERID').combobox({
url: "/Dict/GetUserComboxSource",
editable: 'false',
});
$('#QDateGrid').datagrid({
width: 350,
height: 300,
fit: true,
nowrap: false,
striped: true,
collapsible: false,
pagination: true,
rownumbers: false,
remoteSort: false,
idField: 'MACHINEID',
columns: [[
{ field: 'MACHINECODDE', title: '设备编码', align: 'center', width: 150 },
{ field: 'MACHINENAME', title: '设备名称', align: 'center', width: 180 },
{ field: 'MACHINEID', title: '设备主键', align: 'center', width: 150, hidden: true }
]],
//*************增加****************************
toolbar: [{
text: '添加',
iconCls: 'icon-add',
handler: function () {
var userid = $('#USERID').combobox('getValue');
if (userid == "") {
MSI("提示", "请填写用户信息!");
return false;
};
OpenAddMachine();
}
},
//************删除*****************************
{
text: '删除',
iconCls: 'icon-remove',
handler: function () {
var selectedRowIds = $('#QDateGrid').datagrid('getSelections');
var len = selectedRowIds.length;
if (len == 0) {
MSI("提示", "请选择要删除的设备信息!");
return false;
} else {
MSQ("提示", "确定要删除选中的记录吗?", function () {
var userid = $('#USERID').combobox('getValue');
var ids = "";
for (i = 0; i < len; i++) {
var ma = selectedRowIds[i].MACHINEID;
ids = ids + ";" + ma;
}
var machineids = ids.substring(1);
$.ajax
({
type: "post",
url: "/UserWithMachine/EditDelete?USERID=" + userid + "&MachineIds=" + machineids,
data: { QDateGrid: $("#MACHINEID").val() },
success: function () {
for (var i = 0; i < len; i++) {
var rowIndex = $('#QDateGrid').datagrid('getRowIndex', selectedRowIds[0]);
$("#QDateGrid").datagrid("deleteRow", rowIndex);
}
}
});
})
}
//********************************************
}
}
]
//**********************************************
});
//获取此用户code下的设备信息(MACHINEID)
$('#QDateGrid').datagrid("loadData", new Array());
var dataInfo = $('#QDateGrid').datagrid('getData');
var userid = $('#USERID').combobox('getValue')
var editflag = document.getElementById("EDITFLAG").value;
$.ajax({
url: "/UserWithMachine/GetListForEdit?userID=" + userid + "&EDITFLAG=" + editflag,
type: "post",
datatype: "json",
success: function (resultdata) {
var obj = eval("(" + resultdata + ")");
var ids = "";
for (i = 0; i < obj.total; i++) {
var mid = obj.rows[i].MACHINEID;
ids = ids + ";" + mid;
}
var machineids = ids.substring(1);
//*********************************************
$.ajax({
url: "/UserWithMachine/GetMachineInfoList?MachineIds=" + machineids,
type: "POST",
cache: false,
dataType: "json",
async: false,
success: function (data) {
if (data == null || data == '') {
//alert("!");
MSI("提示", "未查到数据!")
}
else {
for (var i = 0; i < data.total; i++) {
var insertInfo = {
MACHINECODDE: data.rows[i].MACHINECODDE,
MACHINENAME: data.rows[i].MACHINENAME,
MACHINEID: data.rows[i].PID
};
dataInfo.rows.push(insertInfo);
}
$('#QDateGrid').datagrid('loadData', dataInfo);
}
}
});
//*******************************
}
});
//**********************************************
});
//*********************打开新增物料信息界面*************
function OpenAddMachine() {
$('#addMachineWindow').window({
title: '新增设备信息',
modal: true,
shadow: false,
closed: true,
left: 10,
top: 10,
width: 350,
closable: true,
minimizable: false,
maximizable: false,
height: 280,
collapsible: false
});
$('#addMachineWindow').window('open');
//初始化设备信息下拉
//前台Grid表;
var matData = $('#QDateGrid').datagrid('getData');
if (matData.rows.length > 0)
{
//遍历所有,获取到设备ID
var strid = "";
for (i = 0; i < matData.rows.length; i++)
{
var sendplanDetail = matData.rows[i];
strid = strid + ";" + sendplanDetail.MACHINEID;
}
var machineids = strid.substring(1);
};
var data1;
$.ajax({
url: "/Dict/GetMachineInfo?machineids=" + machineids,
data: {
'MACHINEID': $('#MACHINEID').combobox('getValue')
},
type: "post",
datatype: "json",
success: function (resultdata) {
data1 = eval(resultdata);
if (data1.length == 1) {
$("#pl").hide();
}
else {
$('#MACHINEID').combobox({
data: data1,
editable: 'false',
valueField: 'PID',
textField: 'MACHINENAME'
});
$('#MACHINEID').combobox("setValue", "");
$("#pl").hide();
}
}
});
}
//*********************设备新增界面点击保存事件************************
function AddMachineSave() {
//获取设备号
var machinecode = $('#MACHINEID').combobox('getValue');
//当前页面中,用户信息
var userid = $('#USERID').combobox('getValue');
if (userid == "") {
MSI("提示", "请填写用户信息!");
return false;
};
if (machinecode == "") {
MSI("提示", "请选择设备信息!");
return false;
};
//前台Grid表信息
var matData = $('#QDateGrid').datagrid('getData');
//当Grid表存在信息时
if (matData.rows.length > 0) {
for (var i = 0; i < matData.rows.length; i++) {
var sendplanDetail = matData.rows[i];
if (sendplanDetail.MACHINEID == $('#MACHINEID').combobox('getValue')) {
MSI('提示', '已经添加了设备号为' + $('#MACHINEID').combobox('getValue') + '的信息设备!');
return false;
}
}
};
//*******************************提交************************************
var dataResultSubmit;
$.ajax({
url: "/UserWithMachine/AddMachineDetail",
data: {
'MACHINEID': $('#MACHINEID').combobox('getValue')
},
type: "GET",
cache: false,
dataType: "json",
async: false,
success: function (data) {
//将后台传递过来的Json串转成对象
dataResultSubmit = eval(data);
}
});
//新增失败时
if (dataResultSubmit.IsSuccess == false) {
MSI("提示", dataResultSubmit.Msg);
return false;
}
//设备信息
machinecodde = dataResultSubmit.MACHINECODDE;
machinename = dataResultSubmit.MACHINENAME;
machineID = dataResultSubmit.PID;
//********************************填充数据****************************
matData.rows.push({
MACHINECODDE: machinecodde,
MACHINENAME: machinename,
MACHINEID: machineID
});
$('#QDateGrid').datagrid('loadData', matData);
$('#addMachineWindow').window('close');
}
//**********************************************************************************
//关闭新增设备信息
function AddMachineCancel() {
$('#addMachineWindow').window('close');
}
//********************保存******************************************
function SaveUserWithMachine() {
//用户id(名称)
var userid = $('#USERID').combobox('getValue');
//用户编号
var usercdoe = $('#USERCODE').val();
//Grid表信息
var matData = $('#QDateGrid').datagrid('getData');
//当Grid表存在信息时
if (matData.rows.length > 0) {
var materialID = "";
for (var i = 0; i < matData.rows.length; i++) {
var materialDetail = matData.rows[i];
materialID = materialID + ";" + materialDetail.MACHINEID;
}
//将设备id存到字符串中
$('#MachineIds').val(materialID.substring(1));
submitByButton("UserWithMachineSave");
}
else {
MSI("提示", "请添加设备信息信息!");
return false;
}
}
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ToolContent" runat="server">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<%=Html.QTButtonSave("DoorPlankPlan", "Save", "return SaveUserWithMachine();")%>
<%=Html.QTButtonBack("close", "DashBoardPlanList", "parent.closeAppWindow1();return false;")%>
</td>
</tr>
</table>
</asp:Content>