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

609 lines
21 KiB

1 year 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. body {
  48. height: 100%;
  49. /*FONT-SIZE: 20px;*/
  50. }
  51. .PanelTop {
  52. height:70px;
  53. }
  54. .logoclass {
  55. height:65px;
  56. width:100%;
  57. }
  58. .TopName {
  59. vertical-align:middle;
  60. text-align:center;
  61. font-size: 32px;
  62. font-weight: 700;
  63. }
  64. .time {
  65. vertical-align:middle;
  66. text-align:center;
  67. font-size:26px;
  68. }
  69. .formdiv {
  70. height: 100% !important;
  71. margin-bottom:2px;
  72. margin-top: 10px; margin-left: 10px; margin-right: 10px;
  73. }
  74. /*表标题颜色*/
  75. .table > thead:first-child > tr:first-child > th {
  76. background-color: #a5c1e8 ;
  77. /*color:black;*/
  78. }
  79. </style>
  80. <script>
  81. var _MenuID = "";//菜单ID
  82. var _SourceID = "";//数据源ID
  83. var _sqlTxt = "";//加上参数的sql
  84. var _sqlTxt_Condition = new Array();
  85. var _sqlTxt_AddCondition = "";//加上过滤条件的sql
  86. var _IsExistsDataSource = "";
  87. var _DBName = "";//s数据库
  88. var _Cols = new Array();//列
  89. var _ReportName = "";
  90. var _TempName = "";
  91. var _Filter = "";
  92. var _footerrow = false;//是否有合计项
  93. var _footercols = new Array();//合计项
  94. var _formatcols = new Array();//个性化项
  95. var _formatcols_Row = new Array();//个性化项的行
  96. var _Mergercols = new Array();//合并项
  97. var timer;
  98. var timer2;//刷新数据时间
  99. var GunDongRate = 10000;
  100. var GunDongRow = 0;
  101. var DataF = 15*60;
  102. // var CurrentscrollTop = 0;
  103. var IsFirstShow = false;
  104. $(function () {
  105. //fullScreen();
  106. _MenuID = $.request("_MenuID");
  107. _TempName = $.request("TempName");
  108. //显示时间
  109. getTime();
  110. GetMenu();
  111. _sqlTxt_AddCondition = _sqlTxt;
  112. var _sqlTxt_ConditionStr = $.request("_sqlTxt_Condition");
  113. if (_sqlTxt_ConditionStr != undefined && _sqlTxt_ConditionStr != "") {
  114. var data;
  115. _sqlTxt_Condition = eval("data=" + _sqlTxt_ConditionStr);
  116. if (_sqlTxt_Condition != undefined && _sqlTxt_Condition.length > 0) {
  117. for (var i = 0; i < _sqlTxt_Condition.length; i++) {
  118. _sqlTxt_AddCondition = ReplaceALL(_sqlTxt_AddCondition, _sqlTxt_Condition[i].CIndex, _sqlTxt_Condition[i].Content);
  119. }
  120. }
  121. }
  122. gridList();
  123. $(window).resize(function () {
  124. $("#gridListW").setGridWidth($(window).width() * 0.99);
  125. $("#gridListW").setGridWidth(document.body.clientWidth * 0.99);
  126. $("#gridListW").setGridHeight($(window).height() - 155);
  127. $("#gridListW").setGridHeight(document.body.clientHeight - 155);
  128. GunDongRow = 0;
  129. });
  130. scrollBody();
  131. //刷新数据
  132. timer2 = setInterval(function () {
  133. gridList();
  134. }, DataF*1000);
  135. $('#gridListW').mouseover(function () {//添加over事件,停止滚动
  136. timer = window.clearInterval(timer);
  137. });
  138. $('#gridListW').mouseout(function (e) {//添加mouseout事件,继续滚动
  139. scrollBody();
  140. });
  141. });
  142. //自动滚动
  143. function scrollBody() {
  144. timer = setInterval(function () {
  145. var ob3 = $('#gridListW').getGridParam("records");
  146. var div = $('#gridListW').closest('.ui-jqgrid-bdiv')[0];
  147. var offsetHeight = div.offsetHeight;
  148. var scrollHeight = div.scrollHeight - offsetHeight;
  149. if (GunDongRow == 0)
  150. {
  151. var hh = offsetHeight;
  152. GunDongRow = Math.floor(hh / 30.3);
  153. }
  154. // div.scrollTop = div.scrollTop + 1;
  155. if (div.scrollTop >= scrollHeight) {//循环滚动
  156. scrollHeight = div.scrollHeight - offsetHeight;//如果在滚动过程中添加过数据,需要重新结算scrollHeight
  157. if (div.scrollTop >= scrollHeight) {
  158. div.scrollTop = 0; //循环滚动,重置滚动头即可
  159. IsFirstShow = true;
  160. }
  161. if (div.scrollTop >= ob3 * 30.4) {
  162. div.scrollTop = 0; //循环滚动,重置滚动头即可
  163. IsFirstShow = true;
  164. }
  165. }
  166. if (!IsFirstShow) {
  167. div.scrollTop = div.scrollTop + (GunDongRow * 30.3);
  168. }
  169. else { IsFirstShow = false;}
  170. }, GunDongRate);
  171. }
  172. //end 自动滚动
  173. function GetMenu() {
  174. $.ajax({
  175. url: "/SystemManage/CommonReport/GetMenu?MenuID=" + _MenuID + "&" + Math.random(),
  176. dataType: "json",
  177. async: false,
  178. success: function (data) {
  179. if (data != false && data != null) {
  180. _sqlTxt = data.sqlTxt;
  181. // _sqlTxt_AddCondition = data.sqlTxt;
  182. _DBName = data.DBName;
  183. _SourceID = data.SourceID;
  184. _IsExistsDataSource = data.IsExistsDataSource;
  185. _ReportName = data.ReportName;
  186. $("#TopName").val(_ReportName);
  187. _Mergercols = eval(data.Mergercols);
  188. _formatcols = data.formatcols;
  189. _footerrow = data.footerrow;
  190. _footercols = eval(data.footercols);
  191. _Cols = SetCols(eval(data.Cols));
  192. }
  193. else {
  194. alert("获取菜单栏位等信息异常。" + data);
  195. }
  196. },
  197. error: function (aa) {
  198. alert("异常:" + aa.responseText);
  199. }
  200. });
  201. }
  202. function SetCols(datacols) {
  203. var cols = new Array();
  204. if (datacols != null && datacols.length > 0) {
  205. for (var i = 0; i < datacols.length; i++) {
  206. var ColCaption = datacols[i].ColCaption;
  207. var ColFiledName = datacols[i].ColFiledName;
  208. var DataType = datacols[i].DataType;
  209. var DataTypeStr = GetDataTypeByNum(DataType);
  210. var ColWidth = datacols[i].ColWidth;
  211. var DeciamlNum = datacols[i].DeciamlNum;
  212. var sortable = datacols[i].sortable;
  213. var ColMerFlag = datacols[i].ColMerFlag;
  214. var IsFormat = datacols[i].IsFormat;
  215. var obj = new Array();
  216. if (IsFormat == "1") {
  217. obj = {
  218. label: ColCaption,
  219. name: ColFiledName,
  220. width: ColWidth,
  221. align: "left",
  222. sortable: sortable,
  223. cellattr: addCellAttr,
  224. }
  225. }
  226. else {
  227. obj = {
  228. label: ColCaption,
  229. name: ColFiledName,
  230. width: ColWidth,
  231. align: "left",
  232. sortable: sortable,
  233. cellattr: addCellAttr_ID,
  234. }
  235. }
  236. switch (DataTypeStr) {
  237. case "数值型":
  238. var Formatoptions = new { decimalPlaces: DeciamlNum };
  239. obj.push({ formatter: "number" });
  240. obj.push({ formatoptions: Formatoptions });
  241. break;
  242. case "字符型":
  243. case "日期型":
  244. case "布尔值":
  245. break;
  246. }
  247. //if (IsFormat) {
  248. // obj.push({ cellattr: addCellAttr });
  249. //}
  250. cols.push(obj);
  251. }
  252. var collast = { label: "", name: "", width: "20", align: "left", sortable: false };
  253. cols.push(collast);
  254. }
  255. return cols;
  256. }
  257. function Getformatcol(formatcols, colname) {
  258. var formatList = new Array();
  259. if (formatcols != null && formatcols.length > 0) {
  260. for (var i = 0; i < formatcols.length; i++) {
  261. if (formatcols[i].ColFiledName == colname) {
  262. formatList.push(formatcols[i]);
  263. }
  264. }
  265. }
  266. return formatList;
  267. }
  268. //个性化栏位背景色
  269. function addCellAttr(rowId, val, rawObject, cm, rdata) {
  270. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  271. var formatList = Getformatcol(_formatcols, cm.name);//获取format所有条件
  272. if (formatList != null && formatList.length > 0) {
  273. for (var i = 0; i < formatList.length; i++) {
  274. var formatcol = formatList[i];//条件
  275. var IsRow = false;
  276. if (formatcol.AllRowFlag) {
  277. IsRow = true;
  278. var rr = {
  279. rowid: rowId - 1,
  280. backgroundcolor: formatcol.Color,
  281. }
  282. }
  283. var LogStr = GetLogStringByNum(parseInt(formatcol.LogStr));
  284. switch (LogStr) {
  285. case "等于": if (val == formatcol.SValue) {
  286. if (IsRow) { _formatcols_Row.push(rr); }
  287. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  288. }
  289. break;
  290. case "不等于": if (val != formatcol.SValue) {
  291. if (IsRow) { _formatcols_Row.push(rr); }
  292. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  293. }
  294. break;
  295. case "小于": if (val < formatcol.SValue) {
  296. if (IsRow) { _formatcols_Row.push(rr); }
  297. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  298. }
  299. break;
  300. case "大于": if (val > formatcol.SValue) {
  301. if (IsRow) { _formatcols_Row.push(rr); }
  302. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  303. }
  304. break;
  305. case "小于等于": if (val <= formatcol.SValue) {
  306. if (IsRow) { _formatcols_Row.push(rr); }
  307. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  308. }
  309. break;
  310. case "大于等于": if (val >= formatcol.SValue) {
  311. if (IsRow) { _formatcols_Row.push(rr); }
  312. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  313. }
  314. break;
  315. case "范围内": if (val >= formatcol.SValue && val <= formatcol.DValue) {
  316. if (IsRow) { _formatcols_Row.push(rr); }
  317. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  318. }
  319. break;
  320. case "范围外": if (val < formatcol.SValue || val > formatcol.DValue) {
  321. if (IsRow) { _formatcols_Row.push(rr); }
  322. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  323. }
  324. break;
  325. case "包含": if (val.indexOf(formatcol.SValue) != -1) {
  326. if (IsRow) { _formatcols_Row.push(rr); }
  327. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  328. }
  329. break;
  330. case "头部包含": if (val.indexOf(formatcol.SValue) == 0) {
  331. if (IsRow) { _formatcols_Row.push(rr); }
  332. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  333. }
  334. break;
  335. case "尾部包含": if (val.indexOf(formatcol.SValue) == formatcol.length - val.length) {
  336. if (IsRow) { _formatcols_Row.push(rr); }
  337. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  338. }
  339. break;
  340. case "不包含": if (val.indexOf(formatcol.SValue) == -1) {
  341. if (IsRow) { _formatcols_Row.push(rr); }
  342. else { rr += "style='background-color:" + formatcol.Color + "'"; return rr; }
  343. }
  344. break;
  345. }
  346. }
  347. }
  348. return rr;
  349. }
  350. //个性化栏位背景色
  351. function addCellAttr_ID(rowId, val, rawObject, cm, rdata) {
  352. var rr = ' id=\'' + cm.name + '' + rowId + "\' ";
  353. return rr;
  354. }
  355. function gridList() {
  356. //IsFirstShow = true;
  357. document.getElementById("gridPanel").innerHTML = ' <table id="gridListW"></table> <div id="gridPager"></div>';//重置grid
  358. _formatcols_Row = new Array();
  359. var $gridList = $("#gridListW");
  360. $gridList.dataGrid({
  361. url: "/SystemManage/CommonReport/GetGridJson",
  362. height: $(window).height() - 155,
  363. postData: { sqlTxt: _sqlTxt_AddCondition, DBName: _DBName, TempName: _TempName },
  364. colModel: _Cols,
  365. pager: "#gridPager",
  366. viewrecords: true,
  367. scroll: true,
  368. //altRows: true,
  369. //altclass: "ui-priority-secondary",
  370. jsonReader: {
  371. repeatitems: true,
  372. id: "0"
  373. },
  374. footerrow: _footerrow,
  375. gridComplete: function () {
  376. var strIds = $("#gridListW").jqGrid("getDataIDs");
  377. if (_formatcols_Row.length > 0) {
  378. for (var i = 0; i < _formatcols_Row.length; i++) {
  379. $("#" + strIds[_formatcols_Row[i].rowid] + " td").css("background-color", _formatcols_Row[i].backgroundcolor);
  380. }
  381. }
  382. //合并行
  383. if (_Mergercols != undefined && _Mergercols.length > 0) {
  384. for (var i = 0; i < _Mergercols.length; i++) {
  385. Merger("gridListW", _Mergercols[i]);
  386. }
  387. }
  388. //合计
  389. if (_footerrow == "True") {
  390. var footerData = {};
  391. for (var i = 0; i < _footercols.length; i++) {
  392. var total = 0;
  393. for (var j = 0; j < strIds.length; j++) {
  394. var qty = $("#gridListW").jqGrid("getCell", strIds[j], _footercols[i]);
  395. if (qty != "") {
  396. total += parseInt(qty);
  397. }
  398. }
  399. footerData[_footercols[i]] = total;
  400. }
  401. $("#gridListW").footerData('set', footerData);
  402. $("#gridListW").footerData('set', { "rn": "合计" });
  403. }
  404. },
  405. loadError: function (data) {
  406. alert("异常:");
  407. }
  408. });
  409. }
  410. function getTime() {
  411. var days = new Array("日", "一", "二", "三", "四", "五", "六");
  412. var currentDT = new Date();
  413. var y, m, date, day, hs, ms, ss, theDateStr;
  414. y = currentDT.getFullYear(); //四位整数表示的年份
  415. m = currentDT.getMonth() < 10 ? '0' + (currentDT.getMonth() + 1) : (currentDT.getMonth() + 1); //月
  416. date = currentDT.getDate() < 10 ? '0' + currentDT.getDate() : currentDT.getDate(); //日
  417. day = currentDT.getDay(); //星期
  418. hs = currentDT.getHours() < 10 ? '0' + currentDT.getHours() : currentDT.getHours(); //时
  419. ms = currentDT.getMinutes() < 10 ? '0' + currentDT.getMinutes() : currentDT.getMinutes(); //分
  420. ss = currentDT.getSeconds() < 10 ? '0' + currentDT.getSeconds() : currentDT.getSeconds(); //秒
  421. theDateStr = y + "-" + m + "-" + date + " " + hs + ":" + ms + ":" + ss;
  422. //填充到组件中
  423. $("#timeStr").text(theDateStr);
  424. // setTimeout 在执行时,是在载入后延迟指定时间后,去执行一次表达式,仅执行一次
  425. window.setTimeout(getTime, 1000);
  426. }
  427. function btn_SetOther() {
  428. $("#SetDivMenu").removeClass("DropMenu");
  429. $("#SetDivMenu").addClass("DropMenuHidden");
  430. $("#GRate").val(GunDongRate / 1000);
  431. $("#GHang").val(GunDongRow);
  432. $("#DataFalsh").val(DataF);
  433. $("#SetDiv").removeClass("HiddenDiv");
  434. $("#SetDiv").addClass("ShowDiv");
  435. }
  436. function btn_SetOtherOK()
  437. {
  438. // var dd = document.getElementById("SetDiv");
  439. var rrate = $("#GRate").val();
  440. var rhang = $("#GHang").val();
  441. var DataFalsh = $("#DataFalsh").val();
  442. GunDongRate = Number(rrate) * 1000;
  443. GunDongRow = Number(rhang);
  444. DataF = Number(DataFalsh);
  445. $("#SetDiv").removeClass("ShowDiv");
  446. $("#SetDiv").addClass("HiddenDiv");
  447. $("#SetDivMenu").removeClass("DropMenuHidden");
  448. $("#SetDivMenu").addClass("DropMenu");
  449. //刷新数据
  450. timer2 = setInterval(function () {
  451. gridList();
  452. }, DataF * 1000);
  453. scrollBody();
  454. }
  455. function btn_SetOtherNO()
  456. {
  457. $("#SetDiv").removeClass("ShowDiv");
  458. $("#SetDiv").addClass("HiddenDiv");
  459. $("#SetDivMenu").removeClass("DropMenuHidden");
  460. $("#SetDivMenu").addClass("DropMenu");
  461. }
  462. </script>
  463. <form id="form1">
  464. <div class="formdiv">
  465. <table class="form">
  466. <tr>
  467. <td>
  468. <label class="radio-inline">
  469. <img src="~/Content/img/Panellogo.png" border="0" class="logoclass" />
  470. </label>
  471. </td>
  472. <td>
  473. <div class="TopName" id="TopName">看板</div>
  474. </td>
  475. <td>
  476. <div class="time" id="timeStr"></div>
  477. </td>
  478. </tr>
  479. </table>
  480. </div>
  481. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  482. <div class="gridPanel" id="gridPanel">
  483. <table id="gridListW"></table>
  484. <div id="gridPager"></div>
  485. </div>
  486. </div>
  487. <div class="DropMenu" id="SetDivMenu">
  488. <a id="NF-SetOther" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOther()"><i class="fa fa-caret-down"></i></a>
  489. </div>
  490. <div class="HiddenDiv" id="SetDiv">
  491. <table class="form">
  492. <tr>
  493. <th class="formTitle">数据刷新(秒):</th>
  494. <td>
  495. <input class="form-control" name="DataFalsh" id="DataFalsh" style="width: 50px" />
  496. </td>
  497. </tr>
  498. <tr>
  499. <th class="formTitle">滚动时间(秒):</th>
  500. <td>
  501. <input class="form-control" name="GRate" id="GRate" style="width: 50px" />
  502. </td>
  503. </tr>
  504. <tr>
  505. <th class="formTitle">滚动行数:</th>
  506. <td>
  507. <input class="form-control" name="GHang" id="GHang" style="width: 50px" />
  508. </td>
  509. </tr>
  510. <tr>
  511. <td></td>
  512. <td>
  513. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherNO()"><i class="fa fa-close"></i></a>
  514. <a authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_SetOtherOK()"><i class="fa fa-check"></i></a>
  515. </td>
  516. </tr>
  517. </table>
  518. </div>
  519. </form>