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.

342 lines
13 KiB

3 weeks ago
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <style>
  6. </style>
  7. <script src="~/Content/js/CommonReport/CommonReport.js"></script>
  8. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  9. <script>
  10. var _Clos = new Array();
  11. // 创建一个新的 Date 对象,表示当前日期和时间
  12. var currentDate = new Date();
  13. // 获取当前月份(注意:月份是从0开始计数的)
  14. var currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
  15. var currentyear = currentDate.getFullYear();
  16. $(function () {
  17. $("#txt_DateNow").val(currentyear + "-" + currentMonth)
  18. SetCols();
  19. gridList();
  20. // 搜索按钮点击事件
  21. $("#btn_search").click(function () {
  22. currentDate = new Date($("#txt_DateNow").val());
  23. currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
  24. currentyear = currentDate.getFullYear();
  25. SetCols();
  26. gridList();
  27. });
  28. })
  29. //初始化所有grid
  30. function SetCols() {
  31. var cols = new Array();
  32. var colModel = [
  33. {
  34. label: '材料类别', name: 'Decomposition1', width: 240, align: "center",
  35. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  36. //合并单元格
  37. return 'id=\'Decomposition1' + rowId + "\'";
  38. }
  39. },
  40. { label: '类别', name: 'Decomposition2', width: 240, align: "center" },
  41. {
  42. label: currentMonth + '月第1周', name: 'Week1', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  43. if (rowObject.Decomposition2 == '不良率') {
  44. // 在这里添加百分号
  45. return cellvalue + '%';
  46. }
  47. return cellvalue
  48. }
  49. },
  50. {
  51. label: currentMonth + '月第2周', name: 'Week2', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  52. if (rowObject.Decomposition2 == '不良率') {
  53. // 在这里添加百分号
  54. return cellvalue + '%';
  55. }
  56. return cellvalue
  57. }
  58. },
  59. {
  60. label: currentMonth + '月第3周', name: 'Week3', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  61. if (rowObject.Decomposition2 == '不良率') {
  62. // 在这里添加百分号
  63. return cellvalue + '%';
  64. }
  65. return cellvalue
  66. }
  67. },
  68. {
  69. label: currentMonth + '月第4周', name: 'Week4', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  70. if (rowObject.Decomposition2 == '不良率') {
  71. // 在这里添加百分号
  72. return cellvalue + '%';
  73. }
  74. return cellvalue
  75. }
  76. },
  77. {
  78. label: currentMonth + '月第5周', name: 'Week5', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  79. if (rowObject.Decomposition2 == '不良率') {
  80. // 在这里添加百分号
  81. return cellvalue + '%';
  82. }
  83. return cellvalue
  84. }
  85. },
  86. {
  87. label: currentMonth + '月第6周', name: 'Week6', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  88. if (rowObject.Decomposition2 == '不良率') {
  89. // 在这里添加百分号
  90. return cellvalue + '%';
  91. }
  92. return cellvalue
  93. }
  94. },
  95. {
  96. label: '当月累计', name: 'MonthlyCumulative', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  97. if (rowObject.Decomposition2 == '不良率') {
  98. // 在这里添加百分号
  99. return cellvalue + '%';
  100. }
  101. return cellvalue
  102. }
  103. },
  104. {
  105. label: '1月', name: 'Month1', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  106. if (rowObject.Decomposition2 == '不良率') {
  107. // 在这里添加百分号
  108. return cellvalue + '%';
  109. }
  110. return cellvalue
  111. }
  112. },
  113. {
  114. label: '2月', name: 'Month2', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  115. if (rowObject.Decomposition2 == '不良率') {
  116. // 在这里添加百分号
  117. return cellvalue + '%';
  118. }
  119. return cellvalue
  120. }
  121. },
  122. {
  123. label: '3月', name: 'Month3', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  124. if (rowObject.Decomposition2 == '不良率') {
  125. // 在这里添加百分号
  126. return cellvalue + '%';
  127. }
  128. return cellvalue
  129. }
  130. },
  131. {
  132. label: '4月', name: 'Month4', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  133. if (rowObject.Decomposition2 == '不良率') {
  134. // 在这里添加百分号
  135. return cellvalue + '%';
  136. }
  137. return cellvalue
  138. }
  139. },
  140. {
  141. label: '5月', name: 'Month5', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  142. if (rowObject.Decomposition2 == '不良率') {
  143. // 在这里添加百分号
  144. return cellvalue + '%';
  145. }
  146. return cellvalue
  147. }
  148. },
  149. {
  150. label: '6月', name: 'Month6', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  151. if (rowObject.Decomposition2 == '不良率') {
  152. // 在这里添加百分号
  153. return cellvalue + '%';
  154. }
  155. return cellvalue
  156. }
  157. },
  158. {
  159. label: '7月', name: 'Month7', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  160. if (rowObject.Decomposition2 == '不良率') {
  161. // 在这里添加百分号
  162. return cellvalue + '%';
  163. }
  164. return cellvalue
  165. }
  166. },
  167. {
  168. label: '8月', name: 'Month8', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  169. if (rowObject.Decomposition2 == '不良率') {
  170. // 在这里添加百分号
  171. return cellvalue + '%';
  172. }
  173. return cellvalue
  174. }
  175. },
  176. {
  177. label: '9月', name: 'Month9', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  178. if (rowObject.Decomposition2 == '不良率') {
  179. // 在这里添加百分号
  180. return cellvalue + '%';
  181. }
  182. return cellvalue
  183. }
  184. },
  185. {
  186. label: '10月', name: 'Month10', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  187. if (rowObject.Decomposition2 == '不良率') {
  188. // 在这里添加百分号
  189. return cellvalue + '%';
  190. }
  191. return cellvalue
  192. }
  193. },
  194. {
  195. label: '11月', name: 'Month11', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  196. if (rowObject.Decomposition2 == '不良率') {
  197. // 在这里添加百分号
  198. return cellvalue + '%';
  199. }
  200. return cellvalue
  201. }
  202. },
  203. {
  204. label: '12月', name: 'Month12', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  205. if (rowObject.Decomposition2 == '不良率') {
  206. // 在这里添加百分号
  207. return cellvalue + '%';
  208. }
  209. return cellvalue
  210. }
  211. },
  212. {
  213. label: '年度累计', name: 'AnnualAccumulation', width: 90, align: "center", formatter: function (cellvalue, options, rowObject) {
  214. if (rowObject.Decomposition2 == '不良率') {
  215. // 在这里添加百分号
  216. return cellvalue + '%';
  217. }
  218. return cellvalue
  219. }
  220. },
  221. ];
  222. cols.push(colModel);
  223. _Clos = colModel;
  224. }
  225. // 仓库
  226. function gridList() {
  227. debugger;
  228. document.getElementById("gridPanel").innerHTML = '<table id="gridList"></table><div id="gridPager"></div> ';//重置grid
  229. var $gridList = $("#gridList");
  230. var queryJson = {
  231. DateNow: $("#txt_DateNow").val(),
  232. }
  233. // 初始化表格
  234. $gridList.dataGrid({
  235. url: "/KBSWMS/ICSInspectionReports/GetPassFirstTime3" + "?" + Math.random(),
  236. height: $(window).height() - 128,
  237. width: $(window).width() - 128,
  238. postData: { queryJson: JSON.stringify(queryJson) },
  239. colModel: _Clos,
  240. rownumbers: false,
  241. rowNum: 2000,
  242. gridComplete: function () {
  243. var gridName = "gridList";
  244. Merger(gridName, 'Decomposition1');
  245. },
  246. });
  247. $gridList.jqGrid('setGroupHeaders', {
  248. useColSpanStyle: true,
  249. groupHeaders: [
  250. { startColumnName: 'Week1', numberOfColumns: 6, titleText: '实际(周/月/年累计)' },
  251. { startColumnName: 'Jan', numberOfColumns: 12, titleText: '各月度推移' },
  252. ]
  253. });
  254. }
  255. //公共调用方法
  256. function Merger(gridName, CellName) {
  257. debugger;
  258. //得到显示到界面的id集合
  259. var mya = $("#" + gridName + "").getDataIDs();
  260. //当前显示多少条
  261. var length = mya.length;
  262. for (var i = 0; i < length; i++) {
  263. //从上到下获取一条信息
  264. var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
  265. //定义合并行数
  266. var rowSpanTaxCount = 1;
  267. for (j = i + 1; j <= length; j++) {
  268. //和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
  269. var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
  270. if (before[CellName] == end[CellName]) {
  271. rowSpanTaxCount++;
  272. $("#" + gridName + "").setCell(mya[j], CellName, '', { display: 'none' });
  273. } else {
  274. rowSpanTaxCount = 1;
  275. break;
  276. }
  277. $("#" + CellName + "" + mya[i] + "").attr("rowspan", rowSpanTaxCount);
  278. }
  279. }
  280. }
  281. function btn_Export() {
  282. var data = "&DateNow=" + $("#txt_DateNow").val()
  283. $.download("/KBSWMS/ICSInspectionReports/ExportAll3?" + Math.random(), data, 'post');
  284. }
  285. </script>
  286. <iframe id="ifrm" src="" width="0" height="0"></iframe>
  287. <div class="topPanel" style="height:50px">
  288. <div class="toolbar">
  289. <div class="btn-group">
  290. <a class="btn btn-primary" id="btn_search"><span class="glyphicon glyphicon-refresh"></span></a>
  291. <a id="NF-Export" authorize="yes" class="btn btn-primary" onclick="btn_Export()"><i class="fa fa-download"></i>当前页导出</a>
  292. </div>
  293. </div>
  294. <div class="search">
  295. <table>
  296. <tr>
  297. <th class="formTitle">
  298. <span style="color: red;">*</span>日期:
  299. </th>
  300. <td class="formValue">
  301. <input type="text" name="txt_DateNow" id="txt_DateNow" class="form-control" style="width: 100px;height:13px" maxlength="10" onclick="WdatePicker({ dateFmt: 'yyyy-MM' })" placeholder="日期" />
  302. </td>
  303. </tr>
  304. </table>
  305. </div>
  306. </div>
  307. <div class="gridPanel" id="gridPanel">
  308. <table id="gridList"></table>
  309. <div id="gridPager"></div>
  310. </div>