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.

390 lines
18 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. <div id="app">
  16. <div class="topPanel" style="height:100px;">
  17. <div class="toolbar">
  18. <div class="btn-group">
  19. <input id="FileUp" name="FileUp" type="file" style="display:none;" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
  20. <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>
  21. <a id="NF-Remove" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btn_Remove()"><i class="fa fa-trash-o"></i>删除</a>
  22. <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>
  23. <a id="NF-ExportAll" authorize="no" class="btn btn-primary"><i class="fa fa-download"></i>导出</a>
  24. <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
  25. </div>
  26. <div class="btn-group" style="display:block;padding-left:2px;">
  27. <a class="btn btn-primary" id="downPrintControl" href="~/PrintActivex.exe" style="display:none">点击下载打印组件</a>
  28. </div>
  29. @*<script>$('.toolbar').authorizeButton()</script>*@
  30. </div>
  31. <div class="search">
  32. <table>
  33. <tr>
  34. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_MoCode">&nbsp;&nbsp;&nbsp;&nbsp;AQL编码</label>:</td>
  35. <td class="HideItems">
  36. <div class="input-group HideItems">
  37. <input id="txt_RulesCode" type="text" class="form-control HideItems" style="width: 200px;">
  38. </div>
  39. </td>
  40. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_MoCode">&nbsp;&nbsp;&nbsp;&nbsp;AQL名称</label>:</td>
  41. <td class="HideItems">
  42. <div class="input-group HideItems">
  43. <input id="txt_RulesName" type="text" class="form-control HideItems" style="width: 200px;">
  44. </div>
  45. </td>
  46. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_MoCode">&nbsp;&nbsp;&nbsp;&nbsp;是否启用</label>:</td>
  47. <td class="HideItems">
  48. <div class="input-group HideItems">
  49. <select id="txt_Enable" class="form-control select2" style="width: 135px; height: 20px;">
  50. <option value="" selected>全部</option>
  51. <option value="1">是</option>
  52. <option value="0">否</option>
  53. </select>
  54. </div>
  55. </td>
  56. <td>
  57. <span class="input-group-btn">
  58. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  59. </span>
  60. </td>
  61. </tr>
  62. </table>
  63. </div>
  64. </div>
  65. <div class="gridPanel">
  66. <table id="gridList"></table>
  67. <div id="gridPager"></div>
  68. </div>
  69. </div>
  70. </form>
  71. <script type="text/javascript">
  72. $(function () {
  73. var service = {
  74. isCanEditDate: false,
  75. Init: function () {
  76. var that = this;
  77. $("#txt_CheckFixtureNo").val('');
  78. that.initControl();
  79. that.loadGrid();
  80. that.loadEvent();
  81. //that.loadViewGrid();
  82. },
  83. initControl: function () {
  84. let that = this;
  85. let orgName = '';
  86. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  87. },
  88. loadGrid: function () {
  89. var that = this;
  90. var queryJson = {
  91. RulesCode: $("#txt_RulesCode").val(),
  92. RulesName: $("#txt_RulesName").val(),
  93. Enable: $("#txt_Enable").val(),
  94. }
  95. var $gridList = $("#gridList");
  96. $gridList.dataGrid({
  97. url: "/BBWMS/IQCQuality/GetGridJsonChengPing" + "?" + Math.random(),
  98. postData: { queryJson: JSON.stringify(queryJson) },
  99. mtype: "POST",
  100. height: $(window).height() - 200,
  101. width: $(window).width() - 300,
  102. cellEdit: true,
  103. cellsubmit: "clientArray",
  104. colModel: [
  105. { label: "主键", name: "ID", hidden: true, key: true },
  106. { label: 'Aql代码', name: 'RulesCode', width: 100, align: 'left' },
  107. { label: 'Aql名称', name: 'RulesName', width: 100, align: 'left' },
  108. { label: 'Aql描述', name: 'RulesDesc', width: 100, align: 'left' },
  109. { label: '类别', name: 'Type', width: 100, align: 'left' },
  110. { label: '最后操作时间', name: 'MTIME', width: 100, align: 'left' },
  111. { label: '维护人', name: 'MUSERName', width: 100, align: 'left' },
  112. { label: '是否启用', name: 'EnableText', width: 100, align: 'left' },
  113. ],
  114. shrinkToFit: true,//宽度自适应
  115. width: "100%",
  116. autowidth: true,
  117. gridComplete: function () {
  118. //if (!that.isCanEditDate) {
  119. // var obj_Item1 = $("#gridList");
  120. // var rowIds_Item1 = obj_Item1.getDataIDs();
  121. // for (var i = 0; i < rowIds_Item1.length; i++) {
  122. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell');
  123. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell');
  124. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell');
  125. // }
  126. //}
  127. },
  128. pager: "#gridPager",
  129. sortname: 'MTIME',
  130. sortorder: "desc",
  131. viewrecords: true,
  132. multiselect: true,
  133. subGrid: true, // (1)开启子表格支持
  134. subGridRowExpanded: function (subgrid_id, rowid) { // (2)子表格容器的id和需要展开子表格的行id,将传入此事件函数
  135. // console.log(subgrid_id, rowid);
  136. //
  137. $("#gridList").jqGrid("setSelection", rowid, false);
  138. that.bindSubGrid3(subgrid_id, rowid);
  139. }
  140. });
  141. },
  142. query: function () {
  143. //console.log("点击查询");
  144. var queryJson = {
  145. RulesCode: $("#txt_RulesCode").val(),
  146. RulesName: $("#txt_RulesName").val(),
  147. Enable: $("#txt_Enable").val(),
  148. }
  149. // that.loadGrid(queryJson);
  150. $("#gridList").jqGrid('setGridParam', {
  151. postData: { queryJson: JSON.stringify(queryJson) },
  152. }).trigger('reloadGrid');
  153. },
  154. bindSubGrid3: function (subgrid_id, rowid) {
  155. //
  156. $("#gridList").jqGrid("setSelection", rowid, false);
  157. var subgrid_table_id;
  158. subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
  159. var subgrid_pager_id;
  160. subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
  161. $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
  162. var MOCode = $("#gridList").jqGrid('getRowData', rowid).ID;
  163. // var MoSeq = $("#gridList").jqGrid('getRowData', rowid).MoSeq;
  164. // (6)创建jqGrid对象
  165. $("#" + subgrid_table_id).dataGrid({
  166. cellEdit: true,
  167. mtype: "GET",
  168. url: "/BBWMS/IQCQuality/GetAqlSubGridJsonList?id=" + MOCode + "&" + Math.random(), // (7)子表格数据对应的url,注意传入的contact.id参数
  169. colModel: [
  170. { label: "主键", name: "ID", hidden: true, key: true },
  171. { label: '批量下限', name: 'SetValueMin', width: 150, align: 'left' },
  172. { label: '批量上限', name: 'SetValueMax', width: 150, align: 'left' },
  173. { label: '取样数量', name: 'SampleQuantity', width: 150, align: 'left' },
  174. { label: '允许不良数(关键)', name: 'EATTRIBUTE1', width: 150, align: 'left' },
  175. { label: '允许不良数(主要)', name: 'EATTRIBUTE2', width: 150, align: 'left' },
  176. { label: '允许不良数(次要)', name: 'EATTRIBUTE3', width: 150, align: 'left' },
  177. { label: '维护人', name: 'MUSERName', width: 100, align: 'left' },
  178. { label: '维护时间', name: 'MTIME', width: 100, align: 'left' },
  179. ],
  180. //colModel: ColModelSub,
  181. shrinkToFit: true,//宽度自适应
  182. multiselect: true,
  183. prmNames: { search: "search" },
  184. viewrecords: true,
  185. height: "100%",
  186. //rowNum: 20,
  187. //pager: subgrid_pager_id,
  188. });
  189. },
  190. loadEvent: function () {
  191. var that = this;
  192. $("#btn_search").click(function () {
  193. that.query();
  194. });
  195. $("#NF-Add").click(function () {
  196. // debugger;
  197. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  198. $.modalOpen({
  199. id: "Form",
  200. title: "新增Aql",
  201. url: "/BBWMS/IQCQuality/AqlEdit?ids=",
  202. width: "1200px",
  203. height: "800px",
  204. callBack: function (iframeId) {
  205. top.frames[iframeId].submitForm();
  206. }
  207. });
  208. });
  209. $("#NF-Print").click(function () {
  210. console.log("打印条码");
  211. // debugger;
  212. var objArr = '';
  213. var arr = [];
  214. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  215. for (var i = 0; i < objList.length; i++) {
  216. var rowId = objList[i];
  217. var rowData = $("#gridList").jqGrid('getRowData', rowId);
  218. objArr += "'" + rowData.CheckFixtureNo + "',";
  219. }
  220. objArr = objArr.slice(0, objArr.length - 1);
  221. if (objArr == "") {
  222. $.modalAlertNew("WMS00003");
  223. return;
  224. }
  225. objArr = "" + objArr + "|";
  226. arr.push(objArr);
  227. $.modalOpen({
  228. id: "PrintLot",
  229. title: "打印",
  230. url: "/BBWMS/Print/PrintView?Arguments=" + encodeURI(encodeURI(arr)) + "&mold=JY0001&" + Math.random(),
  231. width: "550px",
  232. height: "1000px",
  233. callBack: function (iframeId) {
  234. top.frames[iframeId].submitForm();
  235. }
  236. });
  237. });
  238. $("#NF-Edit").click(function () {
  239. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  240. if (ids.length != 1) {
  241. $.modalMsg("请选择一条数据", "warning");
  242. return;
  243. }
  244. let obj = {
  245. ids: ids[0],
  246. };
  247. //debugger;
  248. //if (!obj.orderDate) {
  249. // obj.orderDate = new Date().toLocaleDateString();
  250. //}
  251. // consol.log();
  252. $.modalOpen({
  253. id: "Form",
  254. title: "编辑Aql",
  255. url: "/BBWMS/IQCQuality/AqlEdit?ids=" + ids[0]+"",
  256. width: "1200px",
  257. height: "800px",
  258. callBack: function (iframeId) {
  259. top.frames[iframeId].submitForm();
  260. }
  261. });
  262. });
  263. $("#txt_SSName").change(function (event,handle) {
  264. //console.log( $("#txt_SSName").val());
  265. // console.log(val);
  266. // console.log("值改变了");
  267. let val = $("#txt_SSName").val();
  268. if (!val) {
  269. $("#NF-PrintLabel").attr("disabled", "disabled");
  270. }
  271. else {
  272. $("#NF-PrintLabel").removeAttr("disabled");
  273. }
  274. });
  275. $("#NF-Remove").click(function () {
  276. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  277. if (ids.length < 1) {
  278. $.modalMsg("请选择数据", "warning");
  279. return;
  280. }
  281. let keyList = [];
  282. for (var i = 0; i < ids.length; i++) {
  283. keyList.push(ids[i]);
  284. }
  285. //let obj = {
  286. // ids: ids[0],
  287. //};
  288. $.ajax({
  289. url: "/BBWMS/IQCQuality/DeleteAql",
  290. type: "POST",
  291. dataType: "json",
  292. async: false,
  293. data: {
  294. keyValue: JSON.stringify(keyList)
  295. },
  296. success: function (data) {
  297. //
  298. // console.log(data);
  299. if (data.state == "success") {
  300. $.modalMsg("操作成功", "success");
  301. that.query();
  302. }
  303. else
  304. $.modalMsg(data.message, "warning");
  305. }
  306. });
  307. });
  308. $("#NF-ExportAll").click(function () {
  309. let queryJson = {
  310. RulesCode: $("#txt_RulesCode").val(),
  311. RulesName: $("#txt_RulesName").val(),
  312. Enable: $("#txt_Enable").val(),
  313. };
  314. var postData = "&id=" + queryJson.RulesCode + "";
  315. postData += "&CheckFixtureName=" + queryJson.RulesName;
  316. postData += "&Status=" + queryJson.Enable;
  317. $.download("/BBWMS/IQCQuality/ExportAllAqlList" + "?" + Math.random(), postData, 'post');
  318. });
  319. $("#FileUp").on("change", function (up) {
  320. // let that = this;
  321. var form = new FormData(document.getElementById("form1"));
  322. $.ajax({
  323. url: "/BBWMS/CheckingFixture/UploadFile?" + Math.random(),
  324. type: "post",
  325. data: form,
  326. contentType: false,
  327. processData: false,
  328. success: function (data) {
  329. if (data == "true" || data == true) {
  330. alert("导入成功");
  331. that.query();
  332. }
  333. else {
  334. alert(data);
  335. }
  336. },
  337. error: function (aa) {
  338. alert("导入失败:" + aa);
  339. }
  340. });
  341. });
  342. }
  343. }
  344. service.Init();
  345. })
  346. </script>