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.

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