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.

417 lines
19 KiB

3 weeks ago
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <script src="~/Content/js/CommonReport/CommonReport.js"></script>
  6. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  7. <script>
  8. ;
  9. var _Closs = new Array();
  10. // 创建一个新的 Date 对象,表示当前日期和时间
  11. var currentDate = new Date();
  12. // 获取当前月份(注意:月份是从0开始计数的)
  13. var currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
  14. var currentyear = currentDate.getFullYear();
  15. $(function () {
  16. ;
  17. $("#txt_DateNow").val(currentyear + "-" + currentMonth)
  18. SetCols();
  19. gridList();
  20. $("#btn_search").click(function () {
  21. ;
  22. currentDate = new Date($("#txt_DateNow").val());
  23. currentMonth = currentDate.getMonth() + 1; // 加1以符合人类习惯
  24. currentyear = currentDate.getFullYear();
  25. //var queryJson = {
  26. // DateNow: $("#txt_DateNow").val(),
  27. //}
  28. //$gridList.jqGrid('setGridParam', {
  29. // postData: { queryJson: JSON.stringify(queryJson) },
  30. //}).trigger('reloadGrid');
  31. SetCols();
  32. gridList();
  33. });
  34. })
  35. //初始化所有grid
  36. function SetCols() {
  37. var cols = new Array();
  38. var collast = {
  39. label: "不良描述", name: "BRGDesc", width: 100, align: "center", sortable: false, frozen: true,
  40. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  41. //合并单元格
  42. return 'id=\'BRGDesc' + rowId + "\'";
  43. }
  44. };
  45. cols.push(collast);
  46. var collast = {
  47. label: "占比(%)", name: "Proportion", width: 120, align: "center", sortable: false, frozen: true,
  48. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  49. //合并单元格
  50. return 'id=\'Proportion' + rowId + "\'";
  51. }
  52. };
  53. cols.push(collast);
  54. var collast = {
  55. label: "不良原因", name: "BadReasonDesc", width: 100, align: "center", sortable: false, frozen: true,
  56. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  57. //合并单元格
  58. return 'id=\'BadReasonDesc' + rowId + "\'";
  59. }
  60. };
  61. cols.push(collast);
  62. var collast = {
  63. label: "改善对策", name: "Improvementmeasures", width: 120, align: "center", sortable: false, frozen: true,
  64. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  65. //合并单元格
  66. return 'id=\'Improvementmeasures' + rowId + "\'";
  67. }
  68. };
  69. cols.push(collast);//下面这句代码是加入图片的关键,
  70. var collast = {
  71. label: "责任部门", name: "Responsibledepartment", width: 100, align: "center", sortable: false, frozen: true,
  72. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  73. //合并单元格
  74. return 'id=\'Responsibledepartment' + rowId + "\'";
  75. }
  76. };
  77. cols.push(collast);
  78. var collast = {
  79. label: currentMonth + '月第1周', name: '周1', width: 90, align: "center", sortable: false, frozen: true,
  80. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  81. //合并单元格
  82. return 'id=\'周1' + rowId + "\'";
  83. }
  84. };
  85. cols.push(collast);
  86. var collast = {
  87. label: currentMonth + '月第2周', name: '周2', width: 90, align: "center", sortable: false, frozen: true,
  88. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  89. //合并单元格
  90. return 'id=\'周2' + rowId + "\'";
  91. }
  92. };
  93. cols.push(collast);
  94. var collast = {
  95. label: currentMonth + '月第3周', name: '周3', width: 90, align: "center", sortable: false,
  96. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  97. //合并单元格
  98. return 'id=\'周3' + rowId + "\'";
  99. }
  100. };
  101. cols.push(collast);
  102. var collast = {
  103. label: currentMonth + '月第4周', name: '周4', width: 90, align: "center", sortable: false,
  104. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  105. //合并单元格
  106. return 'id=\'周4' + rowId + "\'";
  107. }
  108. };
  109. cols.push(collast);
  110. var collast = {
  111. label: currentMonth + '月第5周', name: '周5', width: 90, align: "center", sortable: false,
  112. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  113. //合并单元格
  114. return 'id=\'周5' + rowId + "\'";
  115. }
  116. };
  117. cols.push(collast);
  118. var collast = {
  119. label: currentMonth + '月第6周', name: '周6', width: 90, align: "center", sortable: false,
  120. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  121. //合并单元格
  122. return 'id=\'周6' + rowId + "\'";
  123. }
  124. };
  125. cols.push(collast);
  126. var collast = {
  127. label: "合计", name: "ZBCount", width: 120, align: "center", sortable: false, frozen: true,
  128. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  129. //合并单元格
  130. return 'id=\'ZBCount' + rowId + "\'";
  131. }
  132. };
  133. cols.push(collast);
  134. var collast = {
  135. label: "年度累计", name: "YBCount", width: 120, align: "center", sortable: false, frozen: true,
  136. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  137. //合并单元格
  138. return 'id=\'YBCount' + rowId + "\'";
  139. }
  140. };
  141. cols.push(collast);
  142. var collast = {
  143. label: '1月', name: '月1', width: 90, align: "center", sortable: false, frozen: true,
  144. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  145. //合并单元格
  146. return 'id=\'Annualcumulative' + rowId + "\'";
  147. }
  148. };
  149. cols.push(collast);
  150. var collast = {
  151. label: '2月', name: '月2', width: 90, align: "center", sortable: false, frozen: true,
  152. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  153. //合并单元格
  154. return 'id=\'Annualcumulative' + rowId + "\'";
  155. }
  156. };
  157. cols.push(collast);
  158. var collast = {
  159. label: '3月', name: '月3', width: 90, align: "center", sortable: false, frozen: true,
  160. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  161. //合并单元格
  162. return 'id=\'Annualcumulative' + rowId + "\'";
  163. }
  164. };
  165. cols.push(collast);
  166. var collast = {
  167. label: '4月', name: '月4', width: 90, align: "center", sortable: false, frozen: true,
  168. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  169. //合并单元格
  170. return 'id=\'Annualcumulative' + rowId + "\'";
  171. }
  172. };
  173. cols.push(collast);
  174. var collast = {
  175. label: '5月', name: '月5', width: 90, align: "center", sortable: false, frozen: true,
  176. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  177. //合并单元格
  178. return 'id=\'Annualcumulative' + rowId + "\'";
  179. }
  180. };
  181. cols.push(collast);
  182. var collast = {
  183. label: '6月', name: '月6', width: 90, align: "center", sortable: false, frozen: true,
  184. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  185. //合并单元格
  186. return 'id=\'Annualcumulative' + rowId + "\'";
  187. }
  188. };
  189. cols.push(collast);
  190. var collast = {
  191. label: '7月', name: '月7', width: 90, align: "center", sortable: false, frozen: true,
  192. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  193. //合并单元格
  194. return 'id=\'Annualcumulative' + rowId + "\'";
  195. }
  196. };
  197. cols.push(collast);
  198. var collast = {
  199. label: '8月', name: '月8', width: 90, align: "center", sortable: false, frozen: true,
  200. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  201. //合并单元格
  202. return 'id=\'Annualcumulative' + rowId + "\'";
  203. }
  204. };
  205. cols.push(collast);
  206. var collast = {
  207. label: '9月', name: '月9', width: 90, align: "center", sortable: false, frozen: true,
  208. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  209. //合并单元格
  210. return 'id=\'Annualcumulative' + rowId + "\'";
  211. }
  212. };
  213. cols.push(collast);
  214. var collast = {
  215. label: '10月', name: '月10', width: 90, align: "center", sortable: false, frozen: true,
  216. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  217. //合并单元格
  218. return 'id=\'Annualcumulative' + rowId + "\'";
  219. }
  220. };
  221. cols.push(collast);
  222. var collast = {
  223. label: '11月', name: '月11', width: 90, align: "center", sortable: false, frozen: true,
  224. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  225. //合并单元格
  226. return 'id=\'Annualcumulative' + rowId + "\'";
  227. }
  228. };
  229. cols.push(collast);
  230. var collast = {
  231. label: '12月', name: '月12', width: 90, align: "center", sortable: false, frozen: true,
  232. cellattr: function (rowId, tv, rawObject, cm, rdata) {
  233. //合并单元格
  234. return 'id=\'Annualcumulative' + rowId + "\'";
  235. }
  236. };
  237. cols.push(collast);
  238. _Closs = cols;
  239. }
  240. function gridList() {
  241. ;
  242. document.getElementById("gridPanel").innerHTML = '<table id="gridList"></table><div id="gridPager"></div> ';//重置grid
  243. var $gridList = $("#gridList");
  244. var queryJson = {
  245. DateNow: $("#txt_DateNow").val(),
  246. }
  247. // 初始化表格
  248. $gridList.dataGrid({
  249. url: "/KBSWMS/ICSInspectionReports/GetPassFirstTime2" + "?" + Math.random(),
  250. postData: { queryJson: JSON.stringify(queryJson) },
  251. height: $(window).height() - 128,
  252. width: $(window).width() - 128,
  253. colModel: _Closs,
  254. rownumbers: true,
  255. footerrow: true,//启用底部行(对列汇总时要启用)第一步
  256. gridComplete: function () {
  257. var gridName = "gridList";
  258. Merger(gridName, 'BRGDesc');
  259. Merger1(gridName, 'ZBCount', 'BRGDesc');
  260. Merger1(gridName, 'Proportion', 'BRGDesc');
  261. Merger1(gridName, 'YBCount', 'BRGDesc');
  262. var Z1_total = $(this).getCol('周1', false, 'sum');
  263. var Z2_total = $(this).getCol('周2', false, 'sum');
  264. var Z3_total = $(this).getCol('周3', false, 'sum');
  265. var Z4_total = $(this).getCol('周4', false, 'sum');
  266. var Z5_total = $(this).getCol('周5', false, 'sum');
  267. var Z6_total = $(this).getCol('周6', false, 'sum');
  268. var Y1_total = $(this).getCol('月1', false, 'sum');
  269. var Y2_total = $(this).getCol('月2', false, 'sum');
  270. var Y3_total = $(this).getCol('月3', false, 'sum');
  271. var Y4_total = $(this).getCol('月4', false, 'sum');
  272. var Y5_total = $(this).getCol('月5', false, 'sum');
  273. var Y6_total = $(this).getCol('月6', false, 'sum');
  274. var Y7_total = $(this).getCol('月7', false, 'sum');
  275. var Y8_total = $(this).getCol('月8', false, 'sum');
  276. var Y9_total = $(this).getCol('月9', false, 'sum');
  277. var Y10_total = $(this).getCol('月10', false, 'sum');
  278. var Y11_total = $(this).getCol('月11', false, 'sum');
  279. var Y12_total = $(this).getCol('月12', false, 'sum');
  280. $(this).footerData('set', {
  281. "周1": Z1_total,//声明需要汇总的列并写自定义函数endMoney_total
  282. "周2": Z2_total,//声明需要汇总的列并写自定义函数endMoney_total
  283. "周3": Z3_total,//声明需要汇总的列并写自定义函数endMoney_total
  284. "周4": Z4_total,//声明需要汇总的列并写自定义函数endMoney_total
  285. "周5": Z5_total,//声明需要汇总的列并写自定义函数endMoney_total
  286. "周6": Z6_total,//声明需要汇总的列并写自定义函数endMoney_total
  287. "月1": Y1_total,//声明需要汇总的列并写自定义函数endMoney_total
  288. "月2": Y2_total,//声明需要汇总的列并写自定义函数endMoney_total
  289. "月3": Y3_total,//声明需要汇总的列并写自定义函数endMoney_total
  290. "月4": Y4_total,//声明需要汇总的列并写自定义函数endMoney_total
  291. "月5": Y5_total,//声明需要汇总的列并写自定义函数endMoney_total
  292. "月6": Y6_total,//声明需要汇总的列并写自定义函数endMoney_total
  293. "月7": Y7_total,//声明需要汇总的列并写自定义函数endMoney_total
  294. "月8": Y8_total,//声明需要汇总的列并写自定义函数endMoney_total
  295. "月9": Y9_total,//声明需要汇总的列并写自定义函数endMoney_total
  296. "月10": Y10_total,//声明需要汇总的列并写自定义函数endMoney_total
  297. "月11": Y11_total,//声明需要汇总的列并写自定义函数endMoney_total
  298. "月12": Y12_total,//声明需要汇总的列并写自定义函数endMoney_total
  299. });
  300. $(this).footerData('set', { "BadReasonDesc": "合计:" });
  301. },
  302. });
  303. // 搜索按钮点击事件
  304. }
  305. function Merger(gridName, CellName) {
  306. ;
  307. //得到显示到界面的id集合
  308. var mya = $("#" + gridName + "").getDataIDs();
  309. //当前显示多少条
  310. var length = mya.length;
  311. for (var i = 0; i < length; i++) {
  312. //从上到下获取一条信息
  313. var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
  314. //定义合并行数
  315. var rowSpanTaxCount = 1;
  316. for (j = i + 1; j <= length; j++) {
  317. //和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
  318. var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
  319. if (before[CellName] == end[CellName]) {
  320. rowSpanTaxCount++;
  321. $("#" + gridName + "").setCell(mya[j], CellName, '', { display: 'none' });
  322. } else {
  323. rowSpanTaxCount = 1;
  324. break;
  325. }
  326. $("#" + CellName + "" + mya[i] + "").attr("rowspan", rowSpanTaxCount);
  327. }
  328. }
  329. }
  330. function Merger1(gridName, CellName, CellName1) {
  331. debugger;
  332. //得到显示到界面的id集合
  333. var mya = $("#" + gridName + "").getDataIDs();
  334. //当前显示多少条
  335. var length = mya.length;
  336. for (var i = 0; i < length; i++) {
  337. //从上到下获取一条信息
  338. var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
  339. //定义合并行数
  340. var rowSpanTaxCount = 1;
  341. for (j = i + 1; j <= length; j++) {
  342. //和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
  343. var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
  344. if (before[CellName1] == end[CellName1]) {
  345. if (before[CellName] == end[CellName]) {
  346. rowSpanTaxCount++;
  347. $("#" + gridName + "").setCell(mya[j], CellName, '', { display: 'none' });
  348. } else {
  349. rowSpanTaxCount = 1;
  350. break;
  351. }
  352. $("#" + CellName + "" + mya[i] + "").attr("rowspan", rowSpanTaxCount);
  353. }
  354. }
  355. }
  356. }
  357. function btn_Export() {
  358. var data = "&DateNow=" + $("#txt_DateNow").val()
  359. $.download("/KBSWMS/ICSInspectionReports/ExportAll?" + Math.random(), data, 'post');
  360. }
  361. </script>
  362. <iframe id="ifrm" src="" width="0" height="0"></iframe>
  363. <div class="topPanel" style="height:50px">
  364. <div class="toolbar">
  365. <div class="btn-group">
  366. <a class="btn btn-primary" id="btn_search"><span class="glyphicon glyphicon-refresh"></span></a>
  367. <a id="NF-Export" authorize="yes" class="btn btn-primary" onclick="btn_Export()"><i class="fa fa-download"></i>当前页导出</a>
  368. </div>
  369. </div>
  370. <div class="search">
  371. <table>
  372. <tr>
  373. <th class="formTitle">
  374. <span style="color: red;">*</span>日期:
  375. </th>
  376. <td class="formValue">
  377. <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="日期" />
  378. </td>
  379. </tr>
  380. </table>
  381. </div>
  382. </div>
  383. <div class="gridPanel" id="gridPanel">
  384. <table id="gridList"></table>
  385. <div id="gridPager"></div>
  386. </div>