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.

531 lines
18 KiB

  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/css/CommonReport/CommonReport.css" rel="stylesheet" />
  6. <script src="~/Content/js/CommonReport/CommonReport.js"></script>
  7. <style>
  8. .ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td {
  9. overflow:hidden;
  10. }
  11. .DropMenu {
  12. position: absolute;
  13. display: block;
  14. top: 5px;
  15. right: 10px;
  16. opacity: 0.3;
  17. z-index: 888;
  18. }
  19. .DropMenuHidden {
  20. position: absolute;
  21. display: none;
  22. top: 5px;
  23. right: 10px;
  24. opacity: 0.2;
  25. z-index: 1;
  26. }
  27. .HiddenDiv {
  28. position: absolute;
  29. display: block;
  30. top: 5px;
  31. right: 10px;
  32. opacity: 0;
  33. z-index:1;
  34. }
  35. .ShowDiv {
  36. position: absolute;
  37. display: block;
  38. top: 5px;
  39. right: 10px;
  40. opacity: 1;
  41. background: #1abc9c;
  42. border: 2px solid #1abc9c;
  43. text-align:center;
  44. width:200px;
  45. z-index: 888;
  46. }
  47. </style>
  48. <script>
  49. var _MenuID = "";//菜单ID
  50. var _SourceID = "";//数据源ID
  51. var _sqlTxt = "";//加上参数的sql
  52. var _sqlTxt_Condition = new Array();
  53. var _sqlTxt_AddCondition = "";//加上过滤条件的sql
  54. var _IsExistsDataSource = "";
  55. var _DBName = "";//s数据库
  56. var _Cols = new Array();//列
  57. var _ReportName = "";
  58. var _TempName = "";
  59. var _Filter = "";
  60. var _footerrow = false;//是否有合计项
  61. var _footercols = new Array();//合计项
  62. var _formatcols = new Array();//个性化项
  63. var _formatcols_Row = new Array();//个性化项的行
  64. var _Mergercols = new Array();//合并项
  65. var timer;
  66. var timer2;//刷新数据时间
  67. var GunDongRate = 10000;
  68. var GunDongRow = 0;
  69. var DataF = 15*60;
  70. // var CurrentscrollTop = 0;
  71. var IsFirstShow = false;
  72. $(function () {
  73. //fullScreen();
  74. _MenuID = $.request("_MenuID");
  75. _TempName = $.request("TempName");
  76. GetMenu();
  77. _sqlTxt_AddCondition = _sqlTxt;
  78. var _sqlTxt_ConditionStr = $.request("_sqlTxt_Condition");
  79. if (_sqlTxt_ConditionStr != undefined && _sqlTxt_ConditionStr != "") {
  80. var data;
  81. _sqlTxt_Condition = eval("data=" + _sqlTxt_ConditionStr);
  82. if (_sqlTxt_Condition != undefined && _sqlTxt_Condition.length > 0) {
  83. for (var i = 0; i < _sqlTxt_Condition.length; i++) {
  84. _sqlTxt_AddCondition = ReplaceALL(_sqlTxt_AddCondition, _sqlTxt_Condition[i].CIndex, _sqlTxt_Condition[i].Content);
  85. }
  86. }
  87. }
  88. gridList();
  89. $(window).resize(function () {
  90. $("#gridListW").setGridWidth($(window).width() * 0.99);
  91. $("#gridListW").setGridWidth(document.body.clientWidth * 0.99);
  92. $("#gridListW").setGridHeight($(window).height() - 82);
  93. $("#gridListW").setGridHeight(document.body.clientHeight - 82);
  94. GunDongRow = 0;
  95. });
  96. scrollBody();
  97. //刷新数据
  98. timer2 = setInterval(function () {
  99. gridList();
  100. }, DataF*1000);
  101. $('#gridListW').mouseover(function () {//添加over事件,停止滚动
  102. timer = window.clearInterval(timer);
  103. });
  104. $('#gridListW').mouseout(function (e) {//添加mouseout事件,继续滚动
  105. scrollBody();
  106. });
  107. });
  108. //自动滚动
  109. function scrollBody() {
  110. timer = setInterval(function () {
  111. var ob3 = $('#gridListW').getGridParam("records");
  112. var div = $('#gridListW').closest('.ui-jqgrid-bdiv')[0];
  113. var offsetHeight = div.offsetHeight;
  114. var scrollHeight = div.scrollHeight - offsetHeight;
  115. if (GunDongRow == 0)
  116. {
  117. var hh = offsetHeight;
  118. GunDongRow = Math.floor(hh / 30.3);
  119. }
  120. // div.scrollTop = div.scrollTop + 1;
  121. if (div.scrollTop >= scrollHeight) {//循环滚动
  122. scrollHeight = div.scrollHeight - offsetHeight;//如果在滚动过程中添加过数据,需要重新结算scrollHeight
  123. if (div.scrollTop >= scrollHeight) {
  124. div.scrollTop = 0; //循环滚动,重置滚动头即可
  125. IsFirstShow = true;
  126. }
  127. if (div.scrollTop >= ob3 * 30.4) {
  128. div.scrollTop = 0; //循环滚动,重置滚动头即可
  129. IsFirstShow = true;
  130. }
  131. }
  132. if (!IsFirstShow) {
  133. div.scrollTop = div.scrollTop + (GunDongRow * 30.3);
  134. }
  135. else { IsFirstShow = false;}
  136. }, GunDongRate);
  137. }
  138. //end 自动滚动
  139. function GetMenu() {
  140. $.ajax({
  141. url: "/SystemManage/CommonReport/GetMenu?MenuID=" + _MenuID + "&" + Math.random(),
  142. dataType: "json",
  143. async: false,
  144. success: function (data) {
  145. if (data != false && data != null) {
  146. _sqlTxt = data.sqlTxt;
  147. // _sqlTxt_AddCondition = data.sqlTxt;
  148. _DBName = data.DBName;
  149. _SourceID = data.SourceID;
  150. _IsExistsDataSource = data.IsExistsDataSource;
  151. _ReportName = data.ReportName;
  152. _Mergercols = eval(data.Mergercols);
  153. _formatcols = data.formatcols;
  154. _footerrow = data.footerrow;
  155. _footercols = eval(data.footercols);
  156. _Cols = SetCols(eval(data.Cols));
  157. }
  158. else {
  159. alert("获取菜单栏位等信息异常。" + data);
  160. }
  161. },
  162. error: function (aa) {
  163. //alert("异常:" + aa.responseText);
  164. $.modalAlertNew("WMS00015", aa.responseText);
  165. }
  166. });
  167. }
  168. function SetCols(datacols) {
  169. var cols = new Array();
  170. if (datacols != null && datacols.length > 0) {
  171. for (var i = 0; i < datacols.length; i++) {
  172. var ColCaption = datacols[i].ColCaption;
  173. var ColFiledName = datacols[i].ColFiledName;
  174. var DataType = datacols[i].DataType;
  175. var DataTypeStr = GetDataTypeByNum(DataType);
  176. var ColWidth = datacols[i].ColWidth;
  177. var DeciamlNum = datacols[i].DeciamlNum;
  178. var sortable = datacols[i].sortable;
  179. var ColMerFlag = datacols[i].ColMerFlag;
  180. var IsFormat = datacols[i].IsFormat;
  181. var obj = new Array();
  182. if (IsFormat == "1") {
  183. obj = {
  184. label: ColCaption,
  185. name: ColFiledName,
  186. width: ColWidth,
  187. align: "left",
  188. sortable: sortable,
  189. cellattr: addCellAttr,
  190. }
  191. }
  192. else {
  193. obj = {
  194. label: ColCaption,
  195. name: ColFiledName,
  196. width: ColWidth,
  197. align: "left",
  198. sortable: sortable,
  199. cellattr: addCellAttr_ID,
  200. }
  201. }
  202. switch (DataTypeStr) {
  203. case "数值型":
  204. var Formatoptions = new { decimalPlaces: DeciamlNum };
  205. obj.push({ formatter: "number" });
  206. obj.push({ formatoptions: Formatoptions });
  207. break;
  208. case "字符型":
  209. case "日期型":
  210. case "布尔值":
  211. break;
  212. }
  213. //if (IsFormat) {
  214. // obj.push({ cellattr: addCellAttr });
  215. //}
  216. cols.push(obj);
  217. }
  218. var collast = { label: "", name: "", width: "20", align: "left", sortable: false };
  219. cols.push(collast);
  220. }
  221. return cols;
  222. }
  223. function Getformatcol(formatcols, colname) {
  224. var formatList = new Array();
  225. if (formatcols != null && formatcols.length > 0) {
  226. for (var i = 0; i < formatcols.length; i++) {
  227. if (formatcols[i].ColFiledName == colname) {
  228. formatList.push(formatcols[i]);
  229. }
  230. }
  231. }
  232. return formatList;
  233. }
  234. //个性化栏位背景色
  235. function addCellAttr(rowId, val, rawObject, cm, rdata) {
  236. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  237. var formatList = Getformatcol(_formatcols, cm.name);//获取format所有条件
  238. if (formatList != null && formatList.length > 0) {
  239. for (var i = 0; i < formatList.length; i++) {
  240. var formatcol = formatList[i];//条件
  241. var IsRow = false;
  242. if (formatcol.AllRowFlag) {
  243. IsRow = true;
  244. var rr = {
  245. rowid: rowId - 1,
  246. backgroundcolor: formatcol.Color,
  247. }
  248. }
  249. var LogStr = GetLogStringByNum(parseInt(formatcol.LogStr));
  250. switch (LogStr) {
  251. case "等于": if (val == formatcol.SValue) {
  252. if (IsRow) { _formatcols_Row.push(rr); }
  253. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  254. }
  255. break;
  256. case "不等于": if (val != formatcol.SValue) {
  257. if (IsRow) { _formatcols_Row.push(rr); }
  258. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  259. }
  260. break;
  261. case "小于": if (val < formatcol.SValue) {
  262. if (IsRow) { _formatcols_Row.push(rr); }
  263. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  264. }
  265. break;
  266. case "大于": if (val > formatcol.SValue) {
  267. if (IsRow) { _formatcols_Row.push(rr); }
  268. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  269. }
  270. break;
  271. case "小于等于": if (val <= formatcol.SValue) {
  272. if (IsRow) { _formatcols_Row.push(rr); }
  273. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  274. }
  275. break;
  276. case "大于等于": if (val >= formatcol.SValue) {
  277. if (IsRow) { _formatcols_Row.push(rr); }
  278. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  279. }
  280. break;
  281. case "范围内": if (val >= formatcol.SValue && val <= formatcol.DValue) {
  282. if (IsRow) { _formatcols_Row.push(rr); }
  283. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  284. }
  285. break;
  286. case "范围外": if (val < formatcol.SValue || val > formatcol.DValue) {
  287. if (IsRow) { _formatcols_Row.push(rr); }
  288. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  289. }
  290. break;
  291. case "包含": if (val.indexOf(formatcol.SValue) != -1) {
  292. if (IsRow) { _formatcols_Row.push(rr); }
  293. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  294. }
  295. break;
  296. case "头部包含": if (val.indexOf(formatcol.SValue) == 0) {
  297. if (IsRow) { _formatcols_Row.push(rr); }
  298. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  299. }
  300. break;
  301. case "尾部包含": if (val.indexOf(formatcol.SValue) == formatcol.length - val.length) {
  302. if (IsRow) { _formatcols_Row.push(rr); }
  303. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  304. }
  305. break;
  306. case "不包含": if (val.indexOf(formatcol.SValue) == -1) {
  307. if (IsRow) { _formatcols_Row.push(rr); }
  308. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  309. }
  310. break;
  311. }
  312. }
  313. }
  314. return rr;
  315. }
  316. //个性化栏位背景色
  317. function addCellAttr_ID(rowId, val, rawObject, cm, rdata) {
  318. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  319. return rr;
  320. }
  321. function gridList() {
  322. //IsFirstShow = true;
  323. document.getElementById("gridPanel").innerHTML = ' <table id="gridListW"></table> <div id="gridPager"></div>';//重置grid
  324. _formatcols_Row = new Array();
  325. var $gridList = $("#gridListW");
  326. $gridList.dataGrid({
  327. url: "/SystemManage/CommonReport/GetGridJson",
  328. height: $(window).height() - 86,
  329. postData: { sqlTxt: _sqlTxt_AddCondition, DBName: _DBName, TempName: _TempName },
  330. colModel: _Cols,
  331. pager: "#gridPager",
  332. viewrecords: true,
  333. scroll: true,
  334. //altRows: true,
  335. //altclass: "ui-priority-secondary",
  336. jsonReader: {
  337. repeatitems: true,
  338. id: "0"
  339. },
  340. footerrow: _footerrow,
  341. gridComplete: function () {
  342. var strIds = $("#gridListW").jqGrid("getDataIDs");
  343. if (_formatcols_Row.length > 0) {
  344. for (var i = 0; i < _formatcols_Row.length; i++) {
  345. $("#" + strIds[_formatcols_Row[i].rowid] + " td").css("background-color", _formatcols_Row[i].backgroundcolor);
  346. }
  347. }
  348. //合并行
  349. if (_Mergercols != undefined && _Mergercols.length > 0) {
  350. for (var i = 0; i < _Mergercols.length; i++) {
  351. Merger("gridListW", _Mergercols[i]);
  352. }
  353. }
  354. //合计
  355. if (_footerrow == "True") {
  356. var footerData = {};
  357. for (var i = 0; i < _footercols.length; i++) {
  358. var total = 0;
  359. for (var j = 0; j < strIds.length; j++) {
  360. var qty = $("#gridListW").jqGrid("getCell", strIds[j], _footercols[i]);
  361. if (qty != "") {
  362. total += parseInt(qty);
  363. }
  364. }
  365. footerData[_footercols[i]] = total;
  366. }
  367. $("#gridListW").footerData('set', footerData);
  368. $("#gridListW").footerData('set', { "rn": "合计" });
  369. }
  370. },
  371. loadError: function (data) {
  372. //alert("异常:");
  373. $.modalAlertNew("WMS00015");
  374. }
  375. });
  376. }
  377. function btn_SetOther() {
  378. $("#SetDivMenu").removeClass("DropMenu");
  379. $("#SetDivMenu").addClass("DropMenuHidden");
  380. $("#GRate").val(GunDongRate / 1000);
  381. $("#GHang").val(GunDongRow);
  382. $("#DataFalsh").val(DataF);
  383. $("#SetDiv").removeClass("HiddenDiv");
  384. $("#SetDiv").addClass("ShowDiv");
  385. }
  386. function btn_SetOtherOK()
  387. {
  388. // var dd = document.getElementById("SetDiv");
  389. var rrate = $("#GRate").val();
  390. var rhang = $("#GHang").val();
  391. var DataFalsh = $("#DataFalsh").val();
  392. GunDongRate = Number(rrate) * 1000;
  393. GunDongRow = Number(rhang);
  394. DataF = Number(DataFalsh);
  395. $("#SetDiv").removeClass("ShowDiv");
  396. $("#SetDiv").addClass("HiddenDiv");
  397. $("#SetDivMenu").removeClass("DropMenuHidden");
  398. $("#SetDivMenu").addClass("DropMenu");
  399. //刷新数据
  400. timer2 = setInterval(function () {
  401. gridList();
  402. }, DataF * 1000);
  403. scrollBody();
  404. }
  405. function btn_SetOtherNO()
  406. {
  407. $("#SetDiv").removeClass("ShowDiv");
  408. $("#SetDiv").addClass("HiddenDiv");
  409. $("#SetDivMenu").removeClass("DropMenuHidden");
  410. $("#SetDivMenu").addClass("DropMenu");
  411. }
  412. </script>
  413. <form id="form1">
  414. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  415. <div class="gridPanel" id="gridPanel">
  416. <table id="gridListW"></table>
  417. <div id="gridPager"></div>
  418. </div>
  419. </div>
  420. <div class="DropMenu" id="SetDivMenu">
  421. <a id="NF-SetOther" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOther()"><i class="fa fa-caret-down"></i></a>
  422. </div>
  423. <div class="HiddenDiv" id="SetDiv">
  424. <table class="form">
  425. <tr>
  426. <th class="formTitle">数据刷新(秒):</th>
  427. <td>
  428. <input class="form-control" name="DataFalsh" id="DataFalsh" style="width: 50px" />
  429. </td>
  430. </tr>
  431. <tr>
  432. <th class="formTitle">滚动时间(秒):</th>
  433. <td>
  434. <input class="form-control" name="GRate" id="GRate" style="width: 50px" />
  435. </td>
  436. </tr>
  437. <tr>
  438. <th class="formTitle">滚动行数:</th>
  439. <td>
  440. <input class="form-control" name="GHang" id="GHang" style="width: 50px" />
  441. </td>
  442. </tr>
  443. <tr>
  444. <td></td>
  445. <td>
  446. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherNO()"><i class="fa fa-close"></i></a>
  447. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherOK()"><i class="fa fa-check"></i></a>
  448. </td>
  449. </tr>
  450. </table>
  451. </div>
  452. </form>