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.

470 lines
21 KiB

3 weeks ago
  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Index.cshtml";
  5. }
  6. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  7. <!--引入 element-ui 的样式,-->
  8. <link rel="stylesheet" href="~/Content/element-ui/lib/theme-chalk/index.css">
  9. <script src="~/Content/vue/dist/vue.js"></script>
  10. <script src="~/Content/element-ui/lib/index.js"></script>
  11. <script src="~/Content/axios.min.js"></script>
  12. <style>
  13. </style>
  14. <form id="form1">
  15. <input id='FileUp3' type='file' style="display: none" onchange="UpLoadLabelFile(this)" />
  16. <div id="app">
  17. <div class="topPanel" style="height:100px;">
  18. <div class="toolbar">
  19. <div class="btn-group">
  20. <input id="FileUp" name="FileUp" type="file" style="display:none;" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
  21. <input id='FileUp2' type='file' style="display: none" />
  22. <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>
  23. <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>
  24. <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>
  25. <a id="NF-Introduction" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_UPload()">导入</a>
  26. <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>
  27. <a id="NF-ExportAll" authorize="no" class="btn btn-primary"><i class="fa fa-download"></i>导出</a>
  28. <a id="NF-Uploading" authorize="yes" class="btn btn-primary dropdown-text" onclick="UpLoadClick1()"><i class="fa fa-file-excel-o"></i>检验标准上传</a>
  29. <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
  30. </div>
  31. <div class="btn-group" style="display:block;padding-left:2px;">
  32. <a class="btn btn-primary" id="downPrintControl" href="~/PrintActivex.exe" style="display:none">点击下载打印组件</a>
  33. </div>
  34. @*<script>$('.toolbar').authorizeButton()</script>*@
  35. </div>
  36. <div class="search">
  37. <table>
  38. <tr>
  39. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_InvCode">&nbsp;&nbsp;&nbsp;&nbsp;物料编码</label>:</td>
  40. <td class="HideItems">
  41. <div class="input-group HideItems">
  42. <input id="txt_InvCode" type="text" class="form-control HideItems" style="width: 200px;">
  43. </div>
  44. </td>
  45. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_InvName">&nbsp;&nbsp;&nbsp;&nbsp;物料名称</label>:</td>
  46. <td class="HideItems">
  47. <div class="input-group HideItems">
  48. <input id="txt_InvName" type="text" class="form-control HideItems" style="width: 200px;">
  49. </div>
  50. </td>
  51. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ListCode">&nbsp;&nbsp;&nbsp;&nbsp;检验项目编码</label>:</td>
  52. <td class="HideItems">
  53. <div class="input-group HideItems">
  54. <input id="txt_ListCode" type="text" class="form-control HideItems" style="width: 200px;">
  55. </div>
  56. </td>
  57. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ListName">&nbsp;&nbsp;&nbsp;&nbsp;检验项目名称</label>:</td>
  58. <td class="HideItems">
  59. <div class="input-group HideItems">
  60. <input id="txt_ListName" type="text" class="form-control HideItems" style="width: 200px;">
  61. </div>
  62. </td>
  63. <td>
  64. <span class="input-group-btn">
  65. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  66. </span>
  67. </td>
  68. </tr>
  69. </table>
  70. </div>
  71. </div>
  72. <div class="gridPanel">
  73. <table id="gridList"></table>
  74. <div id="gridPager"></div>
  75. </div>
  76. </div>
  77. </form>
  78. <script type="text/javascript">
  79. function btn_UPload() {
  80. $("#FileUp").click();
  81. }
  82. function UpLoadClick() {
  83. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  84. if (ids.length != 1) {
  85. $.modalAlertNew("WMS00050");
  86. return;
  87. }
  88. $("#FileUp2").click();
  89. }
  90. $(function () {
  91. var service = {
  92. isCanEditDate: false,
  93. Init: function () {
  94. var that = this;
  95. // $("#txt_RulesCode").val('');
  96. that.initControl();
  97. that.loadGrid();
  98. that.loadEvent();
  99. //that.loadViewGrid();
  100. },
  101. initControl: function () {
  102. let that = this;
  103. let orgName = '';
  104. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  105. },
  106. loadGrid: function () {
  107. var that = this;
  108. var queryJson = {
  109. InvCode: $("#txt_InvCode").val(),
  110. InvName: $("#txt_InvName").val(),
  111. ListCode: $("#txt_ListCode").val(),
  112. ListName: $("#txt_ListName").val(),
  113. }
  114. var $gridList = $("#gridList");
  115. $gridList.dataGrid({
  116. url: "/BBWMS/IQCQuality/GetItem2CheckItemPageList" + "?" + Math.random(),
  117. postData: { queryJson: JSON.stringify(queryJson) },
  118. mtype: "POST",
  119. height: $(window).height() - 200,
  120. width: $(window).width() - 300,
  121. cellEdit: true,
  122. cellsubmit: "clientArray",
  123. colModel: [
  124. { label: "主键", name: "ID", hidden: true, key: true },
  125. { label: '物料代码', name: 'InvCode', width: 100, align: 'left' },
  126. { label: '物料名称', name: 'InvName', width: 100, align: 'left' },
  127. { label: '检验项目编码', name: 'ListCode', width: 150, align: 'left' },
  128. { label: '检验项目描述', name: 'ListName', width: 150, align: 'left' },
  129. { label: '检验属性', name: 'CheckAttrText', width: 100, align: 'left' },
  130. { label: '检验方法', name: 'EATTRIBUTE1', width: 100, align: 'left' },
  131. { label: '最大值', name: 'SetValueMax', width: 100, align: 'left' },
  132. { label: '最小值', name: 'SetValueMin', width: 100, align: 'left' },
  133. { label: '单位', name: 'Unit', width: 100, align: 'left' },
  134. { label: '维护人', name: 'MUSERName', width: 100, align: 'left' },
  135. { label: '最后操作时间', name: 'MTIME', width: 100, align: 'left' },
  136. ],
  137. shrinkToFit: true,//宽度自适应
  138. width: "100%",
  139. autowidth: true,
  140. gridComplete: function () {
  141. //if (!that.isCanEditDate) {
  142. // var obj_Item1 = $("#gridList");
  143. // var rowIds_Item1 = obj_Item1.getDataIDs();
  144. // for (var i = 0; i < rowIds_Item1.length; i++) {
  145. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell');
  146. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell');
  147. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell');
  148. // }
  149. //}
  150. },
  151. pager: "#gridPager",
  152. sortname: 'MTIME',
  153. sortorder: "desc",
  154. viewrecords: true,
  155. multiselect: true,
  156. subGrid: false, // (1)开启子表格支持
  157. });
  158. },
  159. query: function () {
  160. //console.log("点击查询");
  161. var queryJson = {
  162. InvCode: $("#txt_InvCode").val(),
  163. InvName: $("#txt_InvName").val(),
  164. ListCode: $("#txt_ListCode").val(),
  165. ListName: $("#txt_ListName").val(),
  166. }
  167. // that.loadGrid(queryJson);
  168. $("#gridList").jqGrid('setGridParam', {
  169. postData: { queryJson: JSON.stringify(queryJson) },
  170. }).trigger('reloadGrid');
  171. },
  172. loadEvent: function () {
  173. var that = this;
  174. $("#btn_search").click(function () {
  175. that.query();
  176. });
  177. $("#NF-Add").click(function () {
  178. // debugger;
  179. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  180. $.modalOpen({
  181. id: "Form",
  182. title: "物料关联检验项目",
  183. url: "/BBWMS/IQCQuality/Item2CheckItemGroupBind",
  184. width: "1200px",
  185. height: "800px",
  186. callBack: function (iframeId) {
  187. top.frames[iframeId].submitForm();
  188. }
  189. });
  190. });
  191. $("#NF-Edit").click(function () {
  192. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  193. if (ids.length != 1) {
  194. $.modalMsg("请选择一条数据", "warning");
  195. return;
  196. }
  197. let obj = {
  198. ids: ids[0],
  199. };
  200. //debugger;
  201. //if (!obj.orderDate) {
  202. // obj.orderDate = new Date().toLocaleDateString();
  203. //}
  204. // consol.log();
  205. $.modalOpen({
  206. id: "Form",
  207. title: "编辑",
  208. url: "/BBWMS/IQCQuality/Item2CheckItemEdit?ids=" + ids[0]+"",
  209. width: "800px",
  210. height: "400px",
  211. callBack: function (iframeId) {
  212. top.frames[iframeId].submitForm();
  213. }
  214. });
  215. });
  216. $("#txt_SSName").change(function (event,handle) {
  217. //console.log( $("#txt_SSName").val());
  218. // console.log(val);
  219. // console.log("值改变了");
  220. let val = $("#txt_SSName").val();
  221. if (!val) {
  222. $("#NF-PrintLabel").attr("disabled", "disabled");
  223. }
  224. else {
  225. $("#NF-PrintLabel").removeAttr("disabled");
  226. }
  227. });
  228. $("#NF-Remove").click(function () {
  229. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  230. if (ids.length < 1) {
  231. $.modalMsg("请选择数据", "warning");
  232. return;
  233. }
  234. let keyList = [];
  235. for (var i = 0; i < ids.length; i++) {
  236. keyList.push(ids[i]);
  237. }
  238. //let obj = {
  239. // ids: ids[0],
  240. //};
  241. $.ajax({
  242. url: "/BBWMS/IQCQuality/DeleteItem2CheckItem",
  243. type: "POST",
  244. dataType: "json",
  245. async: false,
  246. data: {
  247. keyValue: JSON.stringify(keyList)
  248. },
  249. success: function (data) {
  250. //
  251. // console.log(data);
  252. if (data.state == "success") {
  253. $.modalMsg("操作成功", "success");
  254. that.query();
  255. }
  256. else
  257. $.modalMsg(data.message, "warning");
  258. }
  259. });
  260. });
  261. $("#NF-ExportAll").click(function () {
  262. let queryJson = {
  263. InvCode: $("#txt_InvCode").val(),
  264. InvName: $("#txt_InvName").val(),
  265. ListCode: $("#txt_ListCode").val(),
  266. ListName: $("#txt_ListName").val(),
  267. };
  268. var postData = "&InvCode=" + queryJson.InvCode + "";
  269. postData += "&InvName=" + queryJson.InvName;
  270. postData += "&ListCode=" + queryJson.ListCode;
  271. postData += "&ListName=" + queryJson.ListName;
  272. $.download("/BBWMS/IQCQuality/ExportAllItem2CheckItem" + "?" + Math.random(), postData, 'post');
  273. });
  274. $("#FileUp").on("change", function (up) {
  275. debugger;
  276. // let that = this;
  277. var form = new FormData(document.getElementById("form1"));
  278. $.ajax({
  279. url: "/BBWMS/IQCQuality/ImportItem2CheckGroup?" + Math.random(),
  280. type: "post",
  281. data: form,
  282. contentType: false,
  283. processData: false,
  284. success: function (data) {
  285. if (data == "true" || data == true) {
  286. alert("导入成功");
  287. that.query();
  288. }
  289. else {
  290. alert(data);
  291. }
  292. },
  293. error: function (aa) {
  294. alert("导入失败:" + aa);
  295. }
  296. });
  297. });
  298. $("#FileUp2").on("change", function (e) {
  299. debugger;
  300. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  301. for (var i = 0; i < objList.length; i++) {
  302. var rowId = objList[i];
  303. var rowData = $("#gridList").jqGrid('getRowData', rowId);
  304. var ID = rowData.ID;
  305. //var LableName = rowData.LableName;
  306. }
  307. var files = e.target.files;
  308. var fileName = files[0].name;
  309. if (fileName != null && fileName != "") {
  310. var data = new FormData();
  311. jQuery.each(jQuery('#FileUp2')[0].files, function (i, file) {
  312. data.append('file-' + i, file);
  313. });
  314. data.append("ID", ID);
  315. // data.append("LableName", LableName);
  316. $.modalConfirm("确定上传文件吗?", function (r) {
  317. if (r) {
  318. $.ajax({
  319. url: "/BBWMS/IQCQuality/UpLoadItemRuleFile" + "?" + Math.random(),
  320. type: "post",
  321. data: data,
  322. contentType: false,
  323. processData: false,
  324. dataType: "json",
  325. success: function (data) {
  326. // console.log(data);
  327. if (data.message == "上传成功!") {
  328. $.modalMsg("操作成功", "success");
  329. $.currentWindow().$("#gridList").trigger("reloadGrid");
  330. }
  331. else {
  332. $.modalMsg(data.message, "warning");
  333. }
  334. },
  335. error: function (aa) {
  336. $.modalAlertNew("WMS00016", aa);
  337. }
  338. });
  339. }
  340. });
  341. }
  342. });
  343. $("#NF-ViewFile").click(function () {
  344. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  345. if (ids.length != 1) {
  346. $.modalMsg("请选择一条数据", "warning");
  347. return;
  348. }
  349. let obj = {
  350. ids: ids[0],
  351. };
  352. $.modalOpen({
  353. id: "Form",
  354. title: "质量履历文件查看",
  355. url: "/BBWMS/IQCQuality/Item2AqlFileView?ids=" + ids[0] + "",
  356. width: "1200px",
  357. height: "400px",
  358. callBack: function (iframeId) {
  359. top.frames[iframeId].submitForm();
  360. }
  361. });
  362. });
  363. }
  364. }
  365. service.Init();
  366. })
  367. function UpLoadClick1() {
  368. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  369. if (objList.length != 1) {
  370. $.modalAlertNew("WMS00050");
  371. return;
  372. }
  373. $("#FileUp3").click();
  374. }
  375. function UpLoadLabelFile(fileinfo) {
  376. debugger;
  377. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  378. //if (objList.length != 1) {
  379. // $.modalAlertNew("WMS00050");
  380. // return;
  381. //}
  382. var rowData = $("#gridList").jqGrid('getRowData', objList[0]);
  383. var id = rowData.InvCode;
  384. var batchCode = 1001;
  385. var files = fileinfo.files;
  386. var fileName = files[0].name;
  387. if (fileName != null && fileName != "") {
  388. var data = new FormData();
  389. jQuery.each(jQuery('#FileUp3')[0].files, function (i, file) {
  390. data.append('file-' + i, file);
  391. });
  392. $.modalConfirm("确定上传文件吗?", function (r) {
  393. if (r) {
  394. $.ajax({
  395. url: "/BBWMS/IQCQuality/UpLoadLabelFile?id=" + id + "&batchCode=" + batchCode,
  396. type: "post",
  397. data: data,
  398. contentType: false,
  399. processData: false,
  400. success: function (data) {
  401. debugger;
  402. if (data.state != "error") {
  403. $.modalAlertNew("WMS00014");
  404. $.currentWindow().$("#gridList").trigger("reloadGrid");
  405. }
  406. else {
  407. $.modalAlertNew("WMS00015", data);
  408. }
  409. },
  410. error: function (aa) {
  411. $.modalAlertNew("WMS00016", aa);
  412. }
  413. });
  414. }
  415. });
  416. }
  417. document.getElementById("FileUp3").value = "";
  418. }
  419. </script>