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.

288 lines
11 KiB

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