|
|
@{ ViewBag.Title = "MoProducePlan"; Layout = "~/Views/Shared/_Form.cshtml"; } <script src="~/Content/js/datepicker/WdatePicker.js"></script> <script>
$(function () {
var service = { isCanEditDate: false, Init: function () { var that = this; $("#txt_ItemCode").val(''); $("#txt_ItemName").val(''); $("#txt_SSName").val('');
that.initControl(); that.loadGrid(); that.loadEvent(); that.loadViewGrid();
}, initControl: function () { let that = this; let orgName = '';
let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName'; $.ajax({ url: "/OMAY/Aps/GetOrgAName" + "?" + Math.random(), type: "Get", dataType: "json", async: false,
success: function (data) { // console.log(data); if (data.state == "success") { orgName = data.message; }
} });
if (userName.indexOf('L') > -1 || userName.indexOf('C') > -1) { $("#txt_SSName").val(userName.substr(0, 2)); $("#txt_SSName").attr("disabled", "disabled"); $("#NF-UpdateMoPlan").attr("disabled", "disabled"); } else { $("#NF-PrintLabel").attr("disabled", "disabled"); } if (orgName == "生产主管") { //生产主管 that.isCanEditDate = true; //$("#txt_SSName2").css("display", "block"); //$("#lbl_SSName2").css("display", "block"); } else if (orgName == "生产人员") { //生产人员 that.isCanEditDate = false; $("#txt_SSName2").css("display", "none"); $("#lbl_SSName2").css("display", "none"); } else { that.isCanEditDate = false; $("#txt_SSName2").css("display", "none"); $("#lbl_SSName2").css("display", "none"); }
if (!that.isCanEditDate) { var obj_Item1 = $("#gridList"); var rowIds_Item1 = obj_Item1.getDataIDs();
for (var i = 0; i < rowIds_Item1.length; i++) { $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell'); $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell'); $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell'); } } }, addArriveDateCellAttr(rowId, val, rawObject, cm, rdata) { //if (rdata.ApsOrderDate != "" && rdata.ApsOrderDate != null) { // if (rdata.Free5 == "" || rdata.Free5 == null) { // //var nowDate = GetNowDate(); // //var pass = new Date(rdata.PreArriveDate).getDate() - new Date(rdata.ArriveDate).getDate(); // var pass = daysBetween(rdata.PreArriveDate, rdata.ArriveDate); // if (pass <= 3 && pass >= 0) { // //return "style='background-color:darkgray'"; // return "style='background-color:yellow'"; // } // else if (pass > 3) { // return "style='background-color:darkgray'"; // } // else { // return "style='background-color:red'"; // } // } //} //else { // return "style='background-color:null'"; //} }, loadGrid: function () { var that = this;
var queryJson = { ItemCode: $("#txt_ItemCode").val(), ItemName: $("#txt_ItemName").val(), SSName: $("#txt_SSName").val(), SSName2: $("#txt_SSName2").val(), MoCode: $("#txt_MoCode").val(), OrderStatus: $("#txt_OrderStatus").val(), }
var $gridList = $("#gridList"); $gridList.dataGrid({ url: "/OMAY/Aps/GetGridJsonChengPing" + "?" + Math.random(), postData: { queryJson: JSON.stringify(queryJson) }, mtype: "POST", height: 400, width: $(window).width() - 300, cellEdit: true, cellsubmit: "clientArray", colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '预订单号', name: 'PreOrderNo', width: 100, align: 'left' }, { label: '业务员', name: 'BusinessName', width: 100, align: 'left' }, { label: '工单', name: 'MOCode', width: 100, align: 'left' }, { label: '工单行', name: 'MoSeq', width: 100, align: 'left' }, { label: '工单类型', name: 'MoTypeValue', hidden: true, width: 100, align: 'left' }, { label: '部门', name: 'DepName', width: 100, align: 'left' }, { label: '生产日期', name: 'CreateDateTime', width: 150, align: 'left' }, { label: '包装要求', name: 'PackageAsk', width: 100, align: 'left' }, { label: '特殊要求', name: 'SpecialAsk', width: 100, align: 'left' }, { label: '用途', name: 'Useage', width: 100, align: 'left' }, { label: '存货编码', name: 'ItemCode', width: 100, align: 'left' }, { label: '存货名称', name: 'ItemName', width: 100, align: 'left' }, { label: '存货代码', name: 'ItemAddCode', width: 100, align: 'left' }, { label: '规格', name: 'ItemStd', width: 150, align: 'left' }, { label: '单位', name: 'ItemUnit', width: 100, align: 'left' }, { label: '同步状态', name: 'APSStatus', width: 100, align: 'left' }, { label: '订单状态', name: 'OrderStatus', width: 100, align: 'left' }, { label: '数量', name: 'Amount', width: 100, align: 'left' }, { label: '计划开始时间', name: 'PlanStartDate', width: 150, align: 'left', editable: true, editoptions: { dataInit: function (el) { console.log(that.isCanEditDate); if (!that.isCanEditDate) return; $(el).click(function () { WdatePicker({ dateFmt: "yyyy-MM-dd"//时间显示格式 }); })
} }, }, { label: '计划结束时间', name: 'PlanEndDate', width: 150, align: 'left', editable: true, editoptions: { dataInit: function (el) { $(el).click(function () { WdatePicker({ dateFmt: "yyyy-MM-dd"//时间显示格式 }); })
} }, }, { label: '排序时间', name: 'ApsOrderDate', align: 'left', width: 150, editable: true, editoptions: { dataInit: function (el) { $(el).click(function () { WdatePicker({ dateFmt: "yyyy-MM-dd HH:mm:ss"//时间显示格式 }); }) } }, },
], shrinkToFit: true,//宽度自适应 width: "100%", autowidth: true, gridComplete: function () { if (!that.isCanEditDate) { var obj_Item1 = $("#gridList"); var rowIds_Item1 = obj_Item1.getDataIDs();
for (var i = 0; i < rowIds_Item1.length; i++) { $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell'); $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell'); $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell'); } } }, pager: "#gridPager", sortname: 'ApsOrderDate,PlanStartDate', sortorder: "asc", viewrecords: true, multiselect: true, subGrid: true, // (1)开启子表格支持 subGridRowExpanded: function (subgrid_id, rowid) { // (2)子表格容器的id和需要展开子表格的行id,将传入此事件函数 // console.log(subgrid_id, rowid); // $("#gridList").jqGrid("setSelection", rowid, false); that.bindSubGrid3(subgrid_id, rowid); } });
}, loadViewGrid: function () { var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow'); if (objList.length == 0) { objList = ['-1']; }
var $gridList = $("#gridList2"); $gridList.dataGrid({ url: "/OMAY/Aps/GetApsPlanSelectSubItemList" + "?" + Math.random(), postData: { ids: objList.join() }, mtype: "POST", height: 280, width: $(window).width() - 300, colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '子件料号', name: 'SubItemCode', width: 150, align: 'left' }, { label: '子件名称', name: 'SubItemName', width: 150, align: 'left' }, { label: '子件规格', name: 'SubItemStd', width: 150, align: 'left' }, { label: '主数量', name: 'Quantity', width: 100, align: 'left' }, { label: '主单位', name: 'InvUnit', width: 100, align: 'left' }, { label: '辅计量', name: 'Amount', width: 100, align: 'left' }, { label: '辅单位', name: 'AmountUnit', width: 100, align: 'left' },
], shrinkToFit: true,//宽度自适应 width: "100%", autowidth: true, gridComplete: function () {
}, pager: "#gridPager2", sortname: 'MOCode,MoSeq', sortorder: "asc", viewrecords: true, multiselect: false
}); }, bindSubGrid3: function (subgrid_id, rowid) { // $("#gridList").jqGrid("setSelection", rowid, false); var subgrid_table_id; subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
var subgrid_pager_id; subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
$("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>"); var MOCode = $("#gridList").jqGrid('getRowData', rowid).MOCode; var MoSeq = $("#gridList").jqGrid('getRowData', rowid).MoSeq; // (6)创建jqGrid对象 $("#" + subgrid_table_id).dataGrid({ cellEdit: true, mtype: "GET", url: "/OMAY/Aps/GetApsPlanSubGridJsonList?moCode=" + MOCode + "&moSeq=" + MoSeq + "&" + Math.random(), // (7)子表格数据对应的url,注意传入的contact.id参数 colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '子件行号', name: 'SubSeq', width: 150, align: 'left' }, { label: '子件料号', name: 'SubItemCode', width: 150, align: 'left' }, { label: '子件名称', name: 'SubItemName', width: 150, align: 'left' }, { label: '子件规格', name: 'SubItemDtd', width: 150, align: 'left' }, { label: '比例', name: 'Rate', width: 100, align: 'left' }, { label: '主数量', name: 'Quantity', width: 100, align: 'left' }, { label: '主单位', name: 'InvUnit', width: 100, align: 'left' }, { label: '辅计量', name: 'Amount', width: 100, align: 'left' }, { label: '辅单位', name: 'AmountUnit', width: 100, align: 'left' }, ], //colModel: ColModelSub, shrinkToFit: true,//宽度自适应 multiselect: true, prmNames: { search: "search" }, viewrecords: true, height: "100%", //rowNum: 20, //pager: subgrid_pager_id,
}); }, query: function () { console.log("点击查询"); let queryJson = { ItemCode: $("#txt_ItemCode").val(), ItemName: $("#txt_ItemName").val(), SSName: $("#txt_SSName").val(), SSName2: $("#txt_SSName2").val(), MoCode: $("#txt_MoCode").val(), OrderStatus: $("#txt_OrderStatus").val(), }; // that.loadGrid(queryJson);
$("#gridList").jqGrid('setGridParam', { postData: { queryJson: JSON.stringify(queryJson) }, }).trigger('reloadGrid'); }, loadEvent: function () { var that = this; $("#btn_search").click(function () { that.query(); }); $("#NF-InstructionBill").click(function () {
var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
if (objList.length == 0) { $.modalMsg("请选择一条数据", "warning"); return; }
let lines = []; for (var i = 0; i < objList.length; i++) { let line = $("#gridList").jqGrid('getRowData', objList[i]).DepName;
lines.push(line); } if (lines.length==0) { $.modalMsg("请选择一条数据", "warning"); return; } if (!lines.every(x => x == lines[0])) { $.modalMsg("不同产线订单无法下发", "warning"); return; } var idstr = objList.join(); // return; $.modalOpen({ id: "Form", title: "指令单", url: "/OMAY/Aps/EditInstructionBill?ids=" + idstr + "&line=" + lines[0], width: "600px", height: "400px", callBack: function (iframeId) { top.frames[iframeId].submitForm(); } });
}); $("#NF-ViewSubItem").click(function () { console.log("点击预览"); //let queryJson = { // ItemCode: $("#txt_ItemCode").val(), // ItemName: $("#txt_ItemName").val(), // SSName: $("#txt_SSName").val(), //}; // that.loadGrid(queryJson);
var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow'); // console.log(objList); if (objList.length == 0) { $.modalMsg("请选择一条数据", "warning"); return; } console.log(objList); $("#gridList2").jqGrid('setGridParam', { postData: { ids: objList.join() }, }).trigger('reloadGrid'); }); $("#NF-PrintLabel").click(function () { console.log("打印条码"); var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据 if (ids.length != 1) { $.modalMsg("请选择一条数据", "warning"); return; } var POCode = ""; var PORow = "";
for (var i in ids) { MODetailID = $("#gridList").jqGrid('getRowData', ids[i]).MODetailID; MOCode = $("#gridList").jqGrid('getRowData', ids[i]).MOCode; Sequence = $("#gridList").jqGrid('getRowData', ids[i]).MoSeq; InvCode = $("#gridList").jqGrid('getRowData', ids[i]).ItemCode; MoTypeValue = $("#gridList").jqGrid('getRowData', ids[i]).MoTypeValue; } $.modalOpen({ id: "FormAddItemLot", title: "成品条码产生", url: "/OMAY/ICSMoCreateLot/From?MOCode=" + encodeURI(encodeURI(MOCode)) + "&Sequence=" + Sequence + "&InvCode=" + InvCode + "&Type=" + 3 + "&MODetailID=" + MODetailID + "&MoTypeValue=" + MoTypeValue + "&" + Math.random(), width: "550px", height: "1000px", callBack: function (iframeId) { top.frames[iframeId].submitForm(); } });
}); $("#NF-UpdateMoPlan").click(function () { // console.log('@NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode'); // return; var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据 if (ids.length != 1) { $.modalMsg("请选择一条数据", "warning"); return; }
let obj = { isCanUpdateStatus:false, ids: ids[0], line: $("#gridList").jqGrid('getRowData', ids[0]).DepName, planStartDate: $("#gridList").jqGrid('getRowData', ids[0]).PlanStartDate, planEndDate: $("#gridList").jqGrid('getRowData', ids[0]).PlanEndDate, orderDate: $("#gridList").jqGrid('getRowData', ids[0]).ApsOrderDate, }; //if (!obj.orderDate) { // $.modalMsg("排序时间格式错误", "warning"); // return; //} //if (!obj.planStartDate) { // $.modalMsg("计划开始时间必填", "warning"); // return; //} //if (!obj.planEndDate) { // $.modalMsg("计划结束时间必填", "warning"); // return; //} if (new Date(obj.planStartDate) > new Date(obj.planEndDate)) { $.modalMsg("计划开始时间不能大于结束时间", "warning"); return; } //if (!obj.orderDate) { // obj.orderDate = new Date().toLocaleDateString(); //} $.ajax({ url: "/OMAY/Aps/UpdateMoPlan" + "?" + Math.random(), type: "POST", dataType: "json", async: false, data: { keyValue: JSON.stringify(obj) }, success: function (data) { // console.log(data); if (data.state == "success") { $.modalMsg("修改成功", "success"); that.query(); } else $.modalMsg(data.message, "warning"); } }); }); $("#txt_SSName").change(function (event,handle) { //console.log( $("#txt_SSName").val()); // console.log(val); // console.log("值改变了"); let val = $("#txt_SSName").val(); if (!val) { $("#NF-PrintLabel").attr("disabled", "disabled"); } else { $("#NF-PrintLabel").removeAttr("disabled"); } }); $("#NF-UpdateMoOrderStatus").click(function () {
var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据 if (ids.length == 0) { $.modalMsg("请选择一条数据", "warning"); return; }
let status = $("#txt_OrderStatus").val(); let obj = { ids: ids.join(), orderStatus: status==''?'Close':'' };
$.ajax({ url: "/OMAY/Aps/UpdateMoOrderStatus" + "?" + Math.random(), type: "POST", dataType: "json", async: false, data: { keyValue: JSON.stringify(obj) }, success: function (data) { // console.log(data); if (data.state == "success") { $.modalMsg("变更成功", "success"); that.query(); } else $.modalMsg(data.message, "warning"); } }); });
$("#NF-CancelMoPlan").click(function () { var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据 if (ids.length == 0) { $.modalMsg("请选择一条数据", "warning"); return; }
// let status = $("#txt_OrderStatus").val(); let obj = { ids: ids.join() }; let apsStatus = $("#gridList").jqGrid('getRowData', ids[0]).APSStatus;
if (apsStatus != 'Y') { $.modalMsg("未下发,不能取消下发", "warning"); return; }
$.ajax({ url: "/OMAY/Aps/CancelSendMo" + "?" + Math.random(), type: "POST", dataType: "json", async: false, data: { keyValue: JSON.stringify(obj) }, success: function (data) { // console.log(data); if (data.state == "success") { $.modalMsg("取消成功", "success"); that.query(); } else $.modalMsg(data.message, "warning"); } }); }); }
} service.Init(); })
</script> <iframe id="ifrm" src="" width="0" height="0"></iframe> <script>
</script>
<div class="topPanel" style="height:100px;"> <div class="toolbar"> <div class="btn-group"> <a id="NF-InstructionBill" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>指令单</a> <a id="NF-ViewSubItem" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>预览子料</a> <a id="NF-PrintLabel" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>生成条码</a> <a id="NF-UpdateMoPlan" authorize="yes" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>修改</a> <a id="NF-CancelMoPlan" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>取消下发</a> <a id="NF-UpdateMoOrderStatus" authorize="yes" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>变更订单状态</a> @*<a id="NF-ExportAll" authorize="yes" class="btn btn-default" onclick="btn_ExportAll()"><i class="fa fa-download"></i>导出</a>*@ <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
</div> <div class="btn-group" style="display:block;padding-left:2px;"> <a class="btn btn-primary" id="downPrintControl" href="~/PrintActivex.exe" style="display:none">点击下载打印组件</a> </div> @*<script>$('.toolbar').authorizeButton()</script>*@ </div> <div class="search"> <table> <tr> <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_MoCode"> 生产工单</label>:</td> <td class="HideItems"> <div class="input-group HideItems"> <input id="txt_MoCode" type="text" class="form-control HideItems" style="width: 100px;"> </div> </td> <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ItemCode"> 存货编码</label>:</td> <td class="HideItems"> <div class="input-group HideItems"> <input id="txt_ItemCode" type="text" class="form-control HideItems" style="width: 100px;"> </div> </td>
<td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ItemName"> 存货名称</label>:</td> <td class="HideItems"> <div class="input-group HideItems"> <input id="txt_ItemName" type="text" class="form-control HideItems" style="width: 100px;"> </div> </td> <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_SSName"> 已下发产线</label>:</td> <td class="HideItems"> <div class="input-group HideItems"> @*<input id="txt_SSName" type="text" class="form-control HideItems" style="width: 100px;">*@ <select id="txt_SSName" name="ssName" class="form-control select2 required" style="width: 200px;"> <option value=""></option> <option value="L1">L1</option> <option value="L2">L2</option> <option value="L3">L3</option> <option value="L4">L4</option> <option value="L5">L5</option> <option value="L6">L6</option> <option value="L7">L7</option> <option value="C1">C1</option> <option value="C2">C2</option> </select> </div> </td> <td class="HideItems" style="text-align:right;"><label id="lbl_SSName2" class="lglabel HideItems" for="txt_SSName">未下发产线</label>:</td> <td class="HideItems"> <div class="input-group HideItems"> @*<input id="txt_SSName" type="text" class="form-control HideItems" style="width: 100px;">*@ <select id="txt_SSName2" name="ssName2" class="form-control select2 required" style="width: 200px;"> <option value=""></option> <option value="L1">L1</option> <option value="L2">L2</option> <option value="L3">L3</option> <option value="L4">L4</option> <option value="L5">L5</option> <option value="L6">L6</option> <option value="L7">L7</option> <option value="C1">C1</option> <option value="C2">C2</option> </select> </div> </td> <td class="HideItems" style="text-align:right;"> 订单状态</td> <td class="HideItems"> <div class="input-group HideItems"> <select id="txt_OrderStatus" name="OrderStatus" class="form-control select2 required" style="width: 200px;"> <option value="">打开</option> <option value="Close">关闭</option> </select> </div> </td> <td> <span class="input-group-btn"> <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button> </span> </td> </tr>
</table> </div> </div> <div class="gridPanel"> <table id="gridList"></table> <div id="gridPager"></div> </div> <div class="gridPane2"> <table id="gridList2"></table> <div id="gridPager2"></div> </div>
|