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.

341 lines
15 KiB

3 weeks ago
  1. 
  2. @{
  3. ViewBag.Title = "不良现象组查询";
  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_BRGCode">&nbsp;&nbsp;&nbsp;&nbsp;不良现象组编码</label>:</td>
  35. <td class="HideItems">
  36. <div class="input-group HideItems">
  37. <input id="txt_BRGCode" 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_BRGDesc">&nbsp;&nbsp;&nbsp;&nbsp;不良现象组描述</label>:</td>
  41. <td class="HideItems">
  42. <div class="input-group HideItems">
  43. <input id="txt_BRGDesc" type="text" class="form-control HideItems" style="width: 200px;">
  44. </div>
  45. </td>
  46. <td>
  47. <span class="input-group-btn">
  48. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  49. </span>
  50. </td>
  51. </tr>
  52. </table>
  53. </div>
  54. </div>
  55. <div class="gridPanel">
  56. <table id="gridList"></table>
  57. <div id="gridPager"></div>
  58. </div>
  59. </div>
  60. </form>
  61. <script type="text/javascript">
  62. $(function () {
  63. var service = {
  64. isCanEditDate: false,
  65. Init: function () {
  66. var that = this;
  67. //$("#txt_CheckFixtureNo").val('');
  68. that.initControl();
  69. that.loadGrid();
  70. that.loadEvent();
  71. //that.loadViewGrid();
  72. },
  73. initControl: function () {
  74. let that = this;
  75. let orgName = '';
  76. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  77. },
  78. loadGrid: function () {
  79. var that = this;
  80. var queryJson = {
  81. BRGCode: $("#txt_BRGCode").val(),
  82. BRGDesc: $("#txt_BRGDesc").val(),
  83. //Enable: $("#txt_Enable").val(),
  84. }
  85. var $gridList = $("#gridList");
  86. $gridList.dataGrid({
  87. url: "/BBWMS/IQCQuality/GetBadReasonGroupPageList" + "?" + Math.random(),
  88. postData: { queryJson: JSON.stringify(queryJson) },
  89. mtype: "POST",
  90. height: $(window).height() - 200,
  91. width: $(window).width() - 300,
  92. cellEdit: true,
  93. cellsubmit: "clientArray",
  94. colModel: [
  95. { label: "主键", name: "ID", hidden: true, key: true },
  96. { label: '不良现象组编码', name: 'BRGCode', width: 100, align: 'left' },
  97. { label: '不良现象组描述', name: 'BRGDesc', width: 100, align: 'left' },
  98. { label: '维护人', name: 'MUSERName', width: 100, align: 'left' },
  99. { label: '维护时间', name: 'MTIME', width: 100, align: 'left' },
  100. { label: '自定义字段1', name: 'EATTRIBUTE1', width: 100, align: 'left' },
  101. { label: '自定义字段2', name: 'EATTRIBUTE2', width: 100, align: 'left' },
  102. { label: '自定义字段3', name: 'EATTRIBUTE3', width: 100, align: 'left' },
  103. { label: '自定义字段4', name: 'EATTRIBUTE4', width: 100, align: 'left' },
  104. ],
  105. shrinkToFit: true,//宽度自适应
  106. width: "100%",
  107. autowidth: true,
  108. gridComplete: function () {
  109. //if (!that.isCanEditDate) {
  110. // var obj_Item1 = $("#gridList");
  111. // var rowIds_Item1 = obj_Item1.getDataIDs();
  112. // for (var i = 0; i < rowIds_Item1.length; i++) {
  113. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell');
  114. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell');
  115. // $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell');
  116. // }
  117. //}
  118. },
  119. pager: "#gridPager",
  120. sortname: 'MTIME',
  121. sortorder: "desc",
  122. viewrecords: true,
  123. multiselect: true,
  124. subGrid: true, // (1)开启子表格支持
  125. subGridRowExpanded: function (subgrid_id, rowid) { // (2)子表格容器的id和需要展开子表格的行id,将传入此事件函数
  126. // console.log(subgrid_id, rowid);
  127. //
  128. $("#gridList").jqGrid("setSelection", rowid, false);
  129. that.bindSubGrid3(subgrid_id, rowid);
  130. }
  131. });
  132. },
  133. query: function () {
  134. //console.log("点击查询");
  135. var queryJson = {
  136. BRGCode: $("#txt_BRGCode").val(),
  137. BRGDesc: $("#txt_BRGDesc").val(),
  138. }
  139. // that.loadGrid(queryJson);
  140. $("#gridList").jqGrid('setGridParam', {
  141. postData: { queryJson: JSON.stringify(queryJson) },
  142. }).trigger('reloadGrid');
  143. },
  144. bindSubGrid3: function (subgrid_id, rowid) {
  145. //
  146. $("#gridList").jqGrid("setSelection", rowid, false);
  147. var subgrid_table_id;
  148. subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
  149. var subgrid_pager_id;
  150. subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
  151. $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
  152. var MOCode = $("#gridList").jqGrid('getRowData', rowid).ID;
  153. // var MoSeq = $("#gridList").jqGrid('getRowData', rowid).MoSeq;
  154. // (6)创建jqGrid对象
  155. $("#" + subgrid_table_id).dataGrid({
  156. cellEdit: true,
  157. mtype: "GET",
  158. url: "/BBWMS/IQCQuality/GetBadReasonDetailList?id=" + MOCode + "&" + Math.random(), // (7)子表格数据对应的url,注意传入的contact.id参数
  159. colModel: [
  160. { label: "主键", name: "ID", hidden: true, key: true },
  161. { label: '不良现象编码', name: 'BadReasonCode', width: 150, align: 'left' },
  162. { label: '不良现象描述', name: 'BadReasonDesc', width: 150, align: 'left' },
  163. { label: '维护人', name: 'MUSERName', width: 100, align: 'left' },
  164. { label: '维护时间', name: 'MTIME', width: 100, align: 'left' },
  165. ],
  166. //colModel: ColModelSub,
  167. shrinkToFit: true,//宽度自适应
  168. multiselect: true,
  169. prmNames: { search: "search" },
  170. viewrecords: true,
  171. height: "100%",
  172. //rowNum: 20,
  173. //pager: subgrid_pager_id,
  174. });
  175. },
  176. loadEvent: function () {
  177. var that = this;
  178. $("#btn_search").click(function () {
  179. that.query();
  180. });
  181. $("#NF-Add").click(function () {
  182. // debugger;
  183. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  184. $.modalOpen({
  185. id: "Form",
  186. title: "新增不良现象",
  187. url: "/BBWMS/IQCQuality/BadReasonGroupEdit?ids=",
  188. width: "1200px",
  189. height: "800px",
  190. callBack: function (iframeId) {
  191. top.frames[iframeId].submitForm();
  192. }
  193. });
  194. });
  195. $("#NF-Edit").click(function () {
  196. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  197. if (ids.length != 1) {
  198. $.modalMsg("请选择一条数据", "warning");
  199. return;
  200. }
  201. let obj = {
  202. ids: ids[0],
  203. };
  204. //debugger;
  205. //if (!obj.orderDate) {
  206. // obj.orderDate = new Date().toLocaleDateString();
  207. //}
  208. // consol.log();
  209. $.modalOpen({
  210. id: "Form",
  211. title: "编辑不良现象",
  212. url: "/BBWMS/IQCQuality/BadReasonGroupEdit?ids=" + ids[0]+"",
  213. width: "1200px",
  214. height: "800px",
  215. callBack: function (iframeId) {
  216. top.frames[iframeId].submitForm();
  217. }
  218. });
  219. });
  220. $("#txt_SSName").change(function (event,handle) {
  221. //console.log( $("#txt_SSName").val());
  222. // console.log(val);
  223. // console.log("值改变了");
  224. let val = $("#txt_SSName").val();
  225. if (!val) {
  226. $("#NF-PrintLabel").attr("disabled", "disabled");
  227. }
  228. else {
  229. $("#NF-PrintLabel").removeAttr("disabled");
  230. }
  231. });
  232. $("#NF-Remove").click(function () {
  233. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  234. if (ids.length < 1) {
  235. $.modalMsg("请选择数据", "warning");
  236. return;
  237. }
  238. let keyList = [];
  239. for (var i = 0; i < ids.length; i++) {
  240. keyList.push(ids[i]);
  241. }
  242. //let obj = {
  243. // ids: ids[0],
  244. //};
  245. $.ajax({
  246. url: "/BBWMS/IQCQuality/DeleteBadReasonGroup",
  247. type: "POST",
  248. dataType: "json",
  249. async: false,
  250. data: {
  251. keyValue: JSON.stringify(keyList)
  252. },
  253. success: function (data) {
  254. //
  255. // console.log(data);
  256. if (data.state == "success") {
  257. $.modalMsg("操作成功", "success");
  258. that.query();
  259. }
  260. else
  261. $.modalMsg(data.message, "warning");
  262. }
  263. });
  264. });
  265. $("#NF-ExportAll").click(function () {
  266. let queryJson = {
  267. BRGCode: $("#txt_BRGCode").val(),
  268. BRGDesc: $("#txt_BRGDesc").val(),
  269. };
  270. var postData = "&BRGCode=" + queryJson.BRGCode + "";
  271. postData += "&BRGDesc=" + queryJson.BRGDesc;
  272. $.download("/BBWMS/IQCQuality/ExportAllBadReasonGroup" + "?" + Math.random(), postData, 'post');
  273. });
  274. $("#FileUp").on("change", function (up) {
  275. // let that = this;
  276. var form = new FormData(document.getElementById("form1"));
  277. $.ajax({
  278. url: "/BBWMS/CheckingFixture/UploadFile?" + Math.random(),
  279. type: "post",
  280. data: form,
  281. contentType: false,
  282. processData: false,
  283. success: function (data) {
  284. if (data == "true" || data == true) {
  285. alert("导入成功");
  286. that.query();
  287. }
  288. else {
  289. alert(data);
  290. }
  291. },
  292. error: function (aa) {
  293. alert("导入失败:" + aa);
  294. }
  295. });
  296. });
  297. }
  298. }
  299. service.Init();
  300. })
  301. </script>