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.
386 lines
21 KiB
386 lines
21 KiB
@{
|
|
ViewBag.Title = "Index";
|
|
Layout = "~/Views/Shared/_Index.cshtml";
|
|
}
|
|
|
|
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
|
|
<!--引入 element-ui 的样式,-->
|
|
<link rel="stylesheet" href="~/Content/element-ui/lib/theme-chalk/index.css">
|
|
<script src="~/Content/vue/dist/vue.js"></script>
|
|
<script src="~/Content/element-ui/lib/index.js"></script>
|
|
|
|
<script src="~/Content/axios.min.js"></script>
|
|
<style>
|
|
</style>
|
|
<form id="form1">
|
|
<div id="app">
|
|
<div class="topPanel" style="height:100px;">
|
|
<div class="toolbar">
|
|
<div class="btn-group">
|
|
<input id="FileUp" name="FileUp" type="file" style="display:none;" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
|
|
<input id='FileUp2' type='file' style="display: none" />
|
|
<a id="NF-Add" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btn_Add()"><i class="fa fa-pencil-square-o"></i>新增</a>
|
|
<a id="NF-Remove" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btn_Remove()"><i class="fa fa-pencil-square-o"></i>删除</a>
|
|
<a id="NF-Edit" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btn_Edit()"><i class="fa fa-pencil-square-o"></i>修改</a>
|
|
<a id="NF-Introduction" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_UPload()">导入</a>
|
|
<a href="~/File/IQC/物料关联检验项目.xlsx" id="NF-IntroductionMould" authorize="no" class="btn btn-primary dropdown-text"><i class="fa fa-file-excel-o"></i>导入模板下载</a>
|
|
<a id="NF-ExportAll" authorize="no" class="btn btn-primary"><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_InvCode"> 物料编码</label>:</td>
|
|
<td class="HideItems">
|
|
<div class="input-group HideItems">
|
|
<input id="txt_InvCode" type="text" class="form-control HideItems" style="width: 200px;">
|
|
</div>
|
|
</td>
|
|
<td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_InvName"> 物料名称</label>:</td>
|
|
<td class="HideItems">
|
|
<div class="input-group HideItems">
|
|
<input id="txt_InvName" type="text" class="form-control HideItems" style="width: 200px;">
|
|
</div>
|
|
</td>
|
|
<td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_GroupCode"> 检验项目组编码</label>:</td>
|
|
<td class="HideItems">
|
|
<div class="input-group HideItems">
|
|
<input id="txt_GroupCode" type="text" class="form-control HideItems" style="width: 200px;">
|
|
</div>
|
|
</td>
|
|
<td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_GroupName"> 检验项目组名称</label>:</td>
|
|
<td class="HideItems">
|
|
<div class="input-group HideItems">
|
|
<input id="txt_GroupName" type="text" class="form-control HideItems" style="width: 200px;">
|
|
</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>
|
|
</form>
|
|
|
|
<script type="text/javascript">
|
|
function btn_UPload() {
|
|
$("#FileUp").click();
|
|
}
|
|
|
|
function UpLoadClick() {
|
|
var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow');
|
|
if (ids.length != 1) {
|
|
$.modalAlertNew("WMS00050");
|
|
return;
|
|
}
|
|
$("#FileUp2").click();
|
|
}
|
|
|
|
$(function () {
|
|
var service = {
|
|
isCanEditDate: false,
|
|
Init: function () {
|
|
var that = this;
|
|
that.initControl();
|
|
that.loadGrid();
|
|
that.loadEvent();
|
|
},
|
|
initControl: function () {
|
|
let that = this;
|
|
let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
|
|
},
|
|
// 1. 主表加载:仅保留物料核心字段,开启子表
|
|
loadGrid: function () {
|
|
var that = this;
|
|
var queryJson = {
|
|
InvCode: $("#txt_InvCode").val(),
|
|
InvName: $("#txt_InvName").val(),
|
|
GroupCode: $("#txt_GroupCode").val(),
|
|
GroupName: $("#txt_GroupName").val(),
|
|
// 筛选条件简化:仅保留物料相关,检验项目筛选移到子表(如需子表筛选需额外开发)
|
|
}
|
|
|
|
var $gridList = $("#gridList");
|
|
$gridList.dataGrid({
|
|
url: "/DHAY/IQCQuality/GetItemMainGridJson" + "?" + Math.random(), // 主表接口:需返回汇总后的物料数据
|
|
postData: { queryJson: JSON.stringify(queryJson) },
|
|
mtype: "POST",
|
|
height: $(window).height() - 200,
|
|
width: $(window).width() - 300,
|
|
cellEdit: false, // 主表仅展示,关闭单元格编辑
|
|
cellsubmit: "clientArray",
|
|
colModel: [
|
|
{ label: "物料编码", name: "InvCode", width: 120, align: 'left', sortable: true },
|
|
{ label: "物料名称", name: "InvName", width: 180, align: 'left', sortable: true },
|
|
{ label: "检验项目组编码", name: "GroupCode", width: 180, align: 'left', sortable: true },
|
|
{ label: "检验项目组名称", name: "GroupName", width: 180, align: 'left', sortable: true },
|
|
{ label: "维护人", name: "MUSERName", width: 100, align: 'left' },
|
|
{ label: "维护时间", name: "MTIME", width: 160, align: 'left', formatter: "datetime", formatoptions: { newformat: "Y-m-d H:i:s" } }
|
|
],
|
|
shrinkToFit: true,
|
|
width: "100%",
|
|
autowidth: true,
|
|
gridComplete: function () {
|
|
// 主表加载完成后无额外操作(如需高亮等可在此添加)
|
|
},
|
|
pager: "#gridPager",
|
|
sortname: 'MTIME',
|
|
sortorder: "desc",
|
|
viewrecords: true,
|
|
multiselect: true,
|
|
subGrid: true, // 2. 开启子表功能
|
|
// 3. 子表展开事件:加载当前物料的检验项目数据
|
|
subGridRowExpanded: function (subgrid_id, rowid) {
|
|
// 取消主表行选中(避免冲突)
|
|
$("#gridList").jqGrid("setSelection", rowid, false);
|
|
// 加载子表
|
|
that.bindSubGrid(subgrid_id, rowid);
|
|
}
|
|
});
|
|
},
|
|
// 4. 子表加载:原主表的检验项目字段全部移到子表
|
|
bindSubGrid: function (subgrid_id, rowid) {
|
|
var that = this;
|
|
// 子表容器ID和分页容器ID
|
|
var subgrid_table_id = subgrid_id + "_t";
|
|
var subgrid_pager_id = subgrid_id + "_pgr";
|
|
|
|
// 创建子表DOM结构
|
|
$("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
|
|
|
|
// 获取主表当前行的物料编码(子表查询条件)
|
|
var invCode = $("#gridList").jqGrid('getRowData', rowid).InvCode;
|
|
var invName = $("#gridList").jqGrid('getRowData', rowid).InvName;
|
|
|
|
// 子表初始化:原主表的所有检验项目字段移到这里
|
|
$("#" + subgrid_table_id).dataGrid({
|
|
url: "/DHAY/IQCQuality/GetItemSubGridJson" + "?" + Math.random(), // 子表接口:按物料编码查检验项目
|
|
postData: {
|
|
InvCode: invCode, // 子表查询条件:物料编码
|
|
InvName: invName // 可选:物料名称辅助筛选
|
|
},
|
|
mtype: "POST",
|
|
height: "auto", // 子表高度自适应内容
|
|
width: $("#gridList").width() - 40, // 子表宽度比主表略窄(避免滚动条)
|
|
cellEdit: false, // 子表仅展示(如需编辑需额外开发)
|
|
cellsubmit: "clientArray",
|
|
colModel: [
|
|
{ label: "检验项目主键", name: "ID", hidden: true, key: true }, // 子表唯一标识
|
|
{ label: "检验类型(编码)", name: "EATTRIBUTE6", width: 100, align: 'left', hidden: true },
|
|
{ label: "检验类型", name: "Type", width: 100, align: 'left' },
|
|
{ label: "检验项目代码", name: "ListCode", width: 120, align: 'left' },
|
|
{ label: "检验项目名称", name: "ListName", width: 180, align: 'left' },
|
|
{ label: "标准下限", name: "SetValueMin", width: 100, align: 'left' },
|
|
{ label: "标准上限", name: "SetValueMax", width: 100, align: 'left' },
|
|
{ label: "单位", name: "Unit", width: 80, align: 'left' },
|
|
{ label: "检验标准", name: "EATTRIBUTE1", width: 150, align: 'left' },
|
|
{ label: "抽样水准", name: "EATTRIBUTE2", width: 100, align: 'left' },
|
|
{ label: "允收标准", name: "EATTRIBUTE3", width: 100, align: 'left' },
|
|
{ label: "必填标识(编码)", name: "EATTRIBUTE4", width: 100, align: 'left', hidden: true },
|
|
{ label: "抽检实际值是否必填", name: "CEATTRIBUTE4", width: 150, align: 'left' },
|
|
{ label: "AQL代码", name: "EATTRIBUTE5", width: 100, align: 'left' },
|
|
{ label: "是否可用", name: "CEnable", width: 100, align: 'left' },
|
|
{ label: "维护人", name: "MUSERName", width: 100, align: 'left' },
|
|
{ label: "维护时间", name: "MTIME", width: 160, align: 'left', formatter: "date", formatoptions: { newformat: "Y-m-d H:i:s" } }
|
|
],
|
|
shrinkToFit: true,
|
|
multiselect: false, // 子表不支持多选(避免与主表冲突)
|
|
viewrecords: true,
|
|
pager: subgrid_pager_id, // 子表独立分页
|
|
rowNum: 10, // 子表每页条数
|
|
sortname: 'ListCode',
|
|
sortorder: "asc"
|
|
});
|
|
},
|
|
// 5. 搜索逻辑:仅筛选主表的物料数据
|
|
query: function () {
|
|
var queryJson = {
|
|
InvCode: $("#txt_InvCode").val(),
|
|
InvName: $("#txt_InvName").val(),
|
|
GroupCode: $("#txt_GroupCode").val(),
|
|
GroupName: $("#txt_GroupName").val(),
|
|
}
|
|
$("#gridList").jqGrid('setGridParam', {
|
|
postData: { queryJson: JSON.stringify(queryJson) },
|
|
}).trigger('reloadGrid');
|
|
},
|
|
// 6. 事件绑定:保持原逻辑不变(编辑仍传物料编码)
|
|
loadEvent: function () {
|
|
var that = this;
|
|
// 搜索按钮
|
|
$("#btn_search").click(function () {
|
|
that.query();
|
|
});
|
|
// 新增按钮
|
|
$("#NF-Add").click(function () {
|
|
$.modalOpen({
|
|
id: "Form",
|
|
title: "物料关联检验项目",
|
|
url: "/DHAY/IQCQuality/Item2CheckItemGroupBind",
|
|
width: "1200px",
|
|
height: "800px",
|
|
callBack: function (iframeId) {
|
|
top.frames[iframeId].submitForm();
|
|
}
|
|
});
|
|
});
|
|
// 编辑按钮:仍按物料编码打开子页面
|
|
$("#NF-Edit").click(function () {
|
|
var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow');
|
|
if (ids.length != 1) {
|
|
$.modalMsg("请选择一条数据", "warning");
|
|
return;
|
|
}
|
|
var selectInvCode = $("#gridList").jqGrid('getRowData', ids[0]).InvCode;
|
|
$.modalOpen({
|
|
id: "Form",
|
|
title: "编辑",
|
|
url: "/DHAY/IQCQuality/Item2CheckItemGroupEdit?INVCode=" + selectInvCode + "",
|
|
width: "1000px",
|
|
height: "800px",
|
|
callBack: function (iframeId) {
|
|
top.frames[iframeId].submitForm();
|
|
}
|
|
});
|
|
});
|
|
// 删除按钮:按主表选中行删除(需确保接口支持按物料编码批量删除)
|
|
$("#NF-Remove").click(function () {
|
|
var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow');
|
|
if (ids.length < 1) {
|
|
$.modalMsg("请选择数据", "warning");
|
|
return;
|
|
}
|
|
// 收集选中行的物料编码(而非原主键)
|
|
let invCodeList = [];
|
|
for (var i = 0; i < ids.length; i++) {
|
|
var invCode = $("#gridList").jqGrid('getRowData', ids[i]).InvCode;
|
|
invCodeList.push(invCode);
|
|
}
|
|
$.ajax({
|
|
url: "/DHAY/IQCQuality/DeleteItem2CheckItem",
|
|
type: "POST",
|
|
dataType: "json",
|
|
async: false,
|
|
data: {
|
|
keyValue: JSON.stringify(invCodeList) // 传物料编码列表到接口
|
|
},
|
|
success: function (data) {
|
|
if (data.state == "success") {
|
|
$.modalMsg("操作成功", "success");
|
|
that.query();
|
|
} else {
|
|
$.modalMsg(data.message, "warning");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// 导出按钮:按物料筛选条件导出(如需导出子表需额外处理)
|
|
$("#NF-ExportAll").click(function () {
|
|
let queryJson = {
|
|
InvCode: $("#txt_InvCode").val(),
|
|
InvName: $("#txt_InvName").val(),
|
|
};
|
|
var postData = "&InvCode=" + queryJson.InvCode + "";
|
|
postData += "&InvName=" + queryJson.InvName;
|
|
$.download("/DHAY/IQCQuality/ExportAllItem2CheckItem" + "?" + Math.random(), postData, 'post');
|
|
});
|
|
// 导入按钮:保持原逻辑
|
|
$("#FileUp").on("change", function (up) {
|
|
var form = new FormData(document.getElementById("form1"));
|
|
$.ajax({
|
|
url: "/DHAY/IQCQuality/ImportItem2CheckGroup?" + Math.random(),
|
|
type: "post",
|
|
data: form,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (data) {
|
|
if (data == "true" || data == true) {
|
|
alert("导入成功");
|
|
that.query();
|
|
} else {
|
|
alert(data);
|
|
}
|
|
},
|
|
error: function (aa) {
|
|
alert("导入失败:" + aa);
|
|
}
|
|
});
|
|
});
|
|
// FileUp2上传:保持原逻辑(需确保接口支持按物料编码关联文件)
|
|
$("#FileUp2").on("change", function (e) {
|
|
var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
|
|
if (objList.length != 1) {
|
|
$.modalMsg("请选择一条数据", "warning");
|
|
return;
|
|
}
|
|
var rowData = $("#gridList").jqGrid('getRowData', objList[0]);
|
|
var invCode = rowData.InvCode; // 传物料编码而非原ID
|
|
var files = e.target.files;
|
|
if (files.length == 0) return;
|
|
var data = new FormData();
|
|
jQuery.each(jQuery('#FileUp2')[0].files, function (i, file) {
|
|
data.append('file-' + i, file);
|
|
});
|
|
data.append("InvCode", invCode); // 传物料编码到接口
|
|
$.modalConfirm("确定上传文件吗?", function (r) {
|
|
if (r) {
|
|
$.ajax({
|
|
url: "/DHAY/IQCQuality/UpLoadItemRuleFile" + "?" + Math.random(),
|
|
type: "post",
|
|
data: data,
|
|
contentType: false,
|
|
processData: false,
|
|
dataType: "json",
|
|
success: function (data) {
|
|
if (data.message == "上传成功!") {
|
|
$.modalMsg("操作成功", "success");
|
|
that.query();
|
|
} else {
|
|
$.modalMsg(data.message, "warning");
|
|
}
|
|
},
|
|
error: function (aa) {
|
|
$.modalAlertNew("WMS00016", aa);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
// 查看文件按钮:保持原逻辑(需接口支持按物料编码查文件)
|
|
$("#NF-ViewFile").click(function () {
|
|
var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow');
|
|
if (ids.length != 1) {
|
|
$.modalMsg("请选择一条数据", "warning");
|
|
return;
|
|
}
|
|
var invCode = $("#gridList").jqGrid('getRowData', ids[0]).InvCode;
|
|
$.modalOpen({
|
|
id: "Form",
|
|
title: "质量履历文件查看",
|
|
url: "/DHAY/IQCQuality/Item2AqlFileView?invCode=" + invCode + "", // 传物料编码
|
|
width: "1200px",
|
|
height: "400px",
|
|
callBack: function (iframeId) {
|
|
top.frames[iframeId].submitForm();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
service.Init();
|
|
})
|
|
</script>
|