纽威
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.

529 lines
18 KiB

3 years ago
  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. }
  165. });
  166. }
  167. function SetCols(datacols) {
  168. var cols = new Array();
  169. if (datacols != null && datacols.length > 0) {
  170. for (var i = 0; i < datacols.length; i++) {
  171. var ColCaption = datacols[i].ColCaption;
  172. var ColFiledName = datacols[i].ColFiledName;
  173. var DataType = datacols[i].DataType;
  174. var DataTypeStr = GetDataTypeByNum(DataType);
  175. var ColWidth = datacols[i].ColWidth;
  176. var DeciamlNum = datacols[i].DeciamlNum;
  177. var sortable = datacols[i].sortable;
  178. var ColMerFlag = datacols[i].ColMerFlag;
  179. var IsFormat = datacols[i].IsFormat;
  180. var obj = new Array();
  181. if (IsFormat == "1") {
  182. obj = {
  183. label: ColCaption,
  184. name: ColFiledName,
  185. width: ColWidth,
  186. align: "left",
  187. sortable: sortable,
  188. cellattr: addCellAttr,
  189. }
  190. }
  191. else {
  192. obj = {
  193. label: ColCaption,
  194. name: ColFiledName,
  195. width: ColWidth,
  196. align: "left",
  197. sortable: sortable,
  198. cellattr: addCellAttr_ID,
  199. }
  200. }
  201. switch (DataTypeStr) {
  202. case "数值型":
  203. var Formatoptions = new { decimalPlaces: DeciamlNum };
  204. obj.push({ formatter: "number" });
  205. obj.push({ formatoptions: Formatoptions });
  206. break;
  207. case "字符型":
  208. case "日期型":
  209. case "布尔值":
  210. break;
  211. }
  212. //if (IsFormat) {
  213. // obj.push({ cellattr: addCellAttr });
  214. //}
  215. cols.push(obj);
  216. }
  217. var collast = { label: "", name: "", width: "20", align: "left", sortable: false };
  218. cols.push(collast);
  219. }
  220. return cols;
  221. }
  222. function Getformatcol(formatcols, colname) {
  223. var formatList = new Array();
  224. if (formatcols != null && formatcols.length > 0) {
  225. for (var i = 0; i < formatcols.length; i++) {
  226. if (formatcols[i].ColFiledName == colname) {
  227. formatList.push(formatcols[i]);
  228. }
  229. }
  230. }
  231. return formatList;
  232. }
  233. //个性化栏位背景色
  234. function addCellAttr(rowId, val, rawObject, cm, rdata) {
  235. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  236. var formatList = Getformatcol(_formatcols, cm.name);//获取format所有条件
  237. if (formatList != null && formatList.length > 0) {
  238. for (var i = 0; i < formatList.length; i++) {
  239. var formatcol = formatList[i];//条件
  240. var IsRow = false;
  241. if (formatcol.AllRowFlag) {
  242. IsRow = true;
  243. var rr = {
  244. rowid: rowId - 1,
  245. backgroundcolor: formatcol.Color,
  246. }
  247. }
  248. var LogStr = GetLogStringByNum(parseInt(formatcol.LogStr));
  249. switch (LogStr) {
  250. case "等于": if (val == formatcol.SValue) {
  251. if (IsRow) { _formatcols_Row.push(rr); }
  252. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  253. }
  254. break;
  255. case "不等于": if (val != formatcol.SValue) {
  256. if (IsRow) { _formatcols_Row.push(rr); }
  257. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  258. }
  259. break;
  260. case "小于": if (val < formatcol.SValue) {
  261. if (IsRow) { _formatcols_Row.push(rr); }
  262. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  263. }
  264. break;
  265. case "大于": if (val > formatcol.SValue) {
  266. if (IsRow) { _formatcols_Row.push(rr); }
  267. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  268. }
  269. break;
  270. case "小于等于": if (val <= formatcol.SValue) {
  271. if (IsRow) { _formatcols_Row.push(rr); }
  272. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  273. }
  274. break;
  275. case "大于等于": if (val >= formatcol.SValue) {
  276. if (IsRow) { _formatcols_Row.push(rr); }
  277. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  278. }
  279. break;
  280. case "范围内": if (val >= formatcol.SValue && val <= formatcol.DValue) {
  281. if (IsRow) { _formatcols_Row.push(rr); }
  282. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  283. }
  284. break;
  285. case "范围外": if (val < formatcol.SValue || val > formatcol.DValue) {
  286. if (IsRow) { _formatcols_Row.push(rr); }
  287. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  288. }
  289. break;
  290. case "包含": if (val.indexOf(formatcol.SValue) != -1) {
  291. if (IsRow) { _formatcols_Row.push(rr); }
  292. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  293. }
  294. break;
  295. case "头部包含": if (val.indexOf(formatcol.SValue) == 0) {
  296. if (IsRow) { _formatcols_Row.push(rr); }
  297. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  298. }
  299. break;
  300. case "尾部包含": if (val.indexOf(formatcol.SValue) == formatcol.length - val.length) {
  301. if (IsRow) { _formatcols_Row.push(rr); }
  302. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  303. }
  304. break;
  305. case "不包含": if (val.indexOf(formatcol.SValue) == -1) {
  306. if (IsRow) { _formatcols_Row.push(rr); }
  307. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  308. }
  309. break;
  310. }
  311. }
  312. }
  313. return rr;
  314. }
  315. //个性化栏位背景色
  316. function addCellAttr_ID(rowId, val, rawObject, cm, rdata) {
  317. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  318. return rr;
  319. }
  320. function gridList() {
  321. //IsFirstShow = true;
  322. document.getElementById("gridPanel").innerHTML = ' <table id="gridListW"></table> <div id="gridPager"></div>';//重置grid
  323. _formatcols_Row = new Array();
  324. var $gridList = $("#gridListW");
  325. $gridList.dataGrid({
  326. url: "/SystemManage/CommonReport/GetGridJson",
  327. height: $(window).height() - 86,
  328. postData: { sqlTxt: _sqlTxt_AddCondition, DBName: _DBName, TempName: _TempName },
  329. colModel: _Cols,
  330. pager: "#gridPager",
  331. viewrecords: true,
  332. scroll: true,
  333. //altRows: true,
  334. //altclass: "ui-priority-secondary",
  335. jsonReader: {
  336. repeatitems: true,
  337. id: "0"
  338. },
  339. footerrow: _footerrow,
  340. gridComplete: function () {
  341. var strIds = $("#gridListW").jqGrid("getDataIDs");
  342. if (_formatcols_Row.length > 0) {
  343. for (var i = 0; i < _formatcols_Row.length; i++) {
  344. $("#" + strIds[_formatcols_Row[i].rowid] + " td").css("background-color", _formatcols_Row[i].backgroundcolor);
  345. }
  346. }
  347. //合并行
  348. if (_Mergercols != undefined && _Mergercols.length > 0) {
  349. for (var i = 0; i < _Mergercols.length; i++) {
  350. Merger("gridListW", _Mergercols[i]);
  351. }
  352. }
  353. //合计
  354. if (_footerrow == "True") {
  355. var footerData = {};
  356. for (var i = 0; i < _footercols.length; i++) {
  357. var total = 0;
  358. for (var j = 0; j < strIds.length; j++) {
  359. var qty = $("#gridListW").jqGrid("getCell", strIds[j], _footercols[i]);
  360. if (qty != "") {
  361. total += parseInt(qty);
  362. }
  363. }
  364. footerData[_footercols[i]] = total;
  365. }
  366. $("#gridListW").footerData('set', footerData);
  367. $("#gridListW").footerData('set', { "rn": "合计" });
  368. }
  369. },
  370. loadError: function (data) {
  371. alert("异常:");
  372. }
  373. });
  374. }
  375. function btn_SetOther() {
  376. $("#SetDivMenu").removeClass("DropMenu");
  377. $("#SetDivMenu").addClass("DropMenuHidden");
  378. $("#GRate").val(GunDongRate / 1000);
  379. $("#GHang").val(GunDongRow);
  380. $("#DataFalsh").val(DataF);
  381. $("#SetDiv").removeClass("HiddenDiv");
  382. $("#SetDiv").addClass("ShowDiv");
  383. }
  384. function btn_SetOtherOK()
  385. {
  386. // var dd = document.getElementById("SetDiv");
  387. var rrate = $("#GRate").val();
  388. var rhang = $("#GHang").val();
  389. var DataFalsh = $("#DataFalsh").val();
  390. GunDongRate = Number(rrate) * 1000;
  391. GunDongRow = Number(rhang);
  392. DataF = Number(DataFalsh);
  393. $("#SetDiv").removeClass("ShowDiv");
  394. $("#SetDiv").addClass("HiddenDiv");
  395. $("#SetDivMenu").removeClass("DropMenuHidden");
  396. $("#SetDivMenu").addClass("DropMenu");
  397. //刷新数据
  398. timer2 = setInterval(function () {
  399. gridList();
  400. }, DataF * 1000);
  401. scrollBody();
  402. }
  403. function btn_SetOtherNO()
  404. {
  405. $("#SetDiv").removeClass("ShowDiv");
  406. $("#SetDiv").addClass("HiddenDiv");
  407. $("#SetDivMenu").removeClass("DropMenuHidden");
  408. $("#SetDivMenu").addClass("DropMenu");
  409. }
  410. </script>
  411. <form id="form1">
  412. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  413. <div class="gridPanel" id="gridPanel">
  414. <table id="gridListW"></table>
  415. <div id="gridPager"></div>
  416. </div>
  417. </div>
  418. <div class="DropMenu" id="SetDivMenu">
  419. <a id="NF-SetOther" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOther()"><i class="fa fa-caret-down"></i></a>
  420. </div>
  421. <div class="HiddenDiv" id="SetDiv">
  422. <table class="form">
  423. <tr>
  424. <th class="formTitle">数据刷新(秒):</th>
  425. <td>
  426. <input class="form-control" name="DataFalsh" id="DataFalsh" style="width: 50px" />
  427. </td>
  428. </tr>
  429. <tr>
  430. <th class="formTitle">滚动时间(秒):</th>
  431. <td>
  432. <input class="form-control" name="GRate" id="GRate" style="width: 50px" />
  433. </td>
  434. </tr>
  435. <tr>
  436. <th class="formTitle">滚动行数:</th>
  437. <td>
  438. <input class="form-control" name="GHang" id="GHang" style="width: 50px" />
  439. </td>
  440. </tr>
  441. <tr>
  442. <td></td>
  443. <td>
  444. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherNO()"><i class="fa fa-close"></i></a>
  445. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherOK()"><i class="fa fa-check"></i></a>
  446. </td>
  447. </tr>
  448. </table>
  449. </div>
  450. </form>