UploadIndicatorRecordIndex.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. function startTime(time) {
  2. const nowTimeDate = new Date(time);
  3. return nowTimeDate.setHours(0, 0, 0, 0);
  4. }
  5. function endTime(time) {
  6. const nowTimeDate = new Date(time);
  7. return nowTimeDate.setHours(23, 59, 59, 999);
  8. }
  9. function getTodayStartTimeAndEndTime(time) {
  10. time = time ? time : new Date();
  11. return {
  12. startTime: new Date(time.setHours(0, 0, 0, 0)),
  13. endTime: new Date(time.setHours(23, 59, 59, 999)),
  14. };
  15. }
  16. function getCurrentWeekStartTimeAndEndTime(time) {
  17. const current = time ? time : new Date();
  18. // current是本周的第几天
  19. let nowDayOfWeek = current.getDay();
  20. if (nowDayOfWeek === 0) nowDayOfWeek = 7;
  21. const dayNum = 1 * 24 * 60 * 60 * 1000;
  22. // 获取本周星期一的时间,星期一作为一周的第一天
  23. const firstDate = new Date(current.valueOf() - (nowDayOfWeek - 1) * dayNum);
  24. // 获取本周星期天的时间,星期天作为一周的最后一天
  25. const lastDate = new Date(new Date(firstDate).valueOf() + 6 * dayNum);
  26. return {
  27. startTime: new Date(startTime(firstDate)),
  28. endTime: new Date(endTime(lastDate)),
  29. };
  30. }
  31. function viewModel() {
  32. this.ID = "";
  33. this.init = function () {
  34. //setInterval(function () {
  35. // InitTable();
  36. //}, 1000*60);
  37. //更多条件
  38. $("#btn-more").bind("click", function () {
  39. var that = this;
  40. //多窗口模式,层叠置顶
  41. index = layer.open({
  42. type: 1
  43. , id: "one"
  44. , title: '条件'
  45. , area: ['800px', '350px']
  46. , shade: 0
  47. , anim: 1
  48. , shadeClose: true
  49. , maxmin: true
  50. , shade: 0.3
  51. , offset: '50px'
  52. , content: $("#inteform")
  53. , btn: ['确认', '关闭']
  54. , yes: function () {
  55. InitTable();
  56. layer.close(index);
  57. }
  58. , btn2: function () {
  59. layer.close(index);
  60. }
  61. , zIndex: 1 //重点1
  62. });
  63. })
  64. //渠道
  65. $("#QDID").combobox({
  66. url: '/Problem/GetChannelByAuth',
  67. valueField: 'ID',
  68. textField: '名称',
  69. limitToList: true,
  70. onChange: function (value) {
  71. $("#XMID").combobox({
  72. url: '/PersonManager/GetProject?id=' + value,
  73. valueField: 'ID',
  74. textField: '名称',
  75. limitToList: true,
  76. })
  77. }
  78. })
  79. //项目
  80. $("#XMID").combobox({
  81. url: '/Problem/GetProjectByInfo',
  82. valueField: 'ID',
  83. textField: '名称',
  84. limitToList: true,
  85. })
  86. //指标类型
  87. $("#ZBLX").combobox({
  88. url: '/ProManager/GetIndicatorInformationType',
  89. valueField: 'ID',
  90. textField: '显示名',
  91. limitToList: true
  92. })
  93. //指标状态
  94. $("#ZT").combobox({
  95. url: '/ProManager/GetIndicatorInformationStatu',
  96. valueField: 'ID',
  97. textField: '显示名',
  98. limitToList: true,
  99. value:"2"
  100. })
  101. $("#SJDXZ").combobox({
  102. data: [{
  103. "ID": 0,
  104. "名称": "当天",
  105. },
  106. {
  107. "ID": 3,
  108. "名称": "昨天",
  109. },
  110. {
  111. "ID": 4,
  112. "名称": "近三天",
  113. }, {
  114. "ID": 1,
  115. "名称": "本周",
  116. },
  117. {
  118. "ID": 2,
  119. "名称": "本月",
  120. },
  121. {
  122. "ID": -1,
  123. "名称": "自定义",
  124. }],
  125. valueField: 'ID',
  126. textField: '名称',
  127. limitToList: true,
  128. value: "0",
  129. onChange: function (value, index) {
  130. if (value == -1) {
  131. //自定义时间
  132. $(".Custom").css("display", "");
  133. } else {
  134. //定时
  135. $(".Custom").css("display", "none");
  136. }
  137. }
  138. })
  139. //刷新
  140. $('#Ref').click(function () {
  141. InitTable();
  142. });
  143. InitTable();
  144. }
  145. };
  146. function InitTable() {
  147. var params = ZLPMS.FormToObject('inteform');
  148. params.CONTENT = $("#userAccount").val();
  149. //时间
  150. let type = $("#SJDXZ").val();
  151. let sTime = "";
  152. let eTime = "";
  153. switch (type) {
  154. case "0": {
  155. //本日
  156. sTime = new Date().format("yyyy-MM-ddT00:00:00");
  157. eTime = new Date().format("yyyy-MM-ddT23:59:59");
  158. break;
  159. }
  160. case "1": {
  161. //本周
  162. sTime = getCurrentWeekStartTimeAndEndTime().startTime.format("yyyy-MM-ddThh:mm:ss");
  163. eTime = getCurrentWeekStartTimeAndEndTime().endTime.format("yyyy-MM-ddThh:mm:ss");
  164. break;
  165. }
  166. case "2": {
  167. //本月
  168. sTime = new Date().format("yyyy-MM-01T00:00:00");
  169. eTime = new Date().format("yyyy-MM-ddThh:mm:ss");
  170. break;
  171. }
  172. case "3": {
  173. //昨天
  174. var day1 = new Date();
  175. day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000);
  176. sTime = new Date(day1).format("yyyy-MM-ddT00:00:00");
  177. eTime = new Date(day1).format("yyyy-MM-ddT23:59:59");
  178. break;
  179. }
  180. case "4": {
  181. //近三天
  182. var day1 = new Date();
  183. day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000 * 3);
  184. sTime = new Date(day1).format("yyyy-MM-ddT00:00:00");
  185. eTime = new Date().format("yyyy-MM-ddThh:mm:ss");
  186. break;
  187. }
  188. case "-1": {
  189. //自定义
  190. sTime = $("#KSSJ").val();
  191. eTime = $("#JSSJ").val();
  192. break;
  193. }
  194. }
  195. params.KSSJ = sTime;
  196. params.JSSJ = eTime;
  197. //初始化树形表格
  198. $("#treegrid").datagrid({
  199. url: '/CloudMonitor/GetPushIndexData',
  200. idField: 'ID',
  201. queryParams: params,
  202. method: 'POST',
  203. fit: true,
  204. pageSize: 20,
  205. toolbar: '#Channeltb',
  206. rownumbers: true,
  207. //底部显示分页工具栏
  208. pagination: true,
  209. collapsible: true,
  210. //列名称
  211. columns: [[
  212. { field: '渠道名称', title: '渠道', width: 180 },
  213. { field: '项目名称', title: '项目', width: 180, align: 'center' },
  214. { field: '服务器IP', title: '服务器IP', width: 120 },
  215. { field: '类型显示', title: '指标类型', width: 120 },
  216. { field: '创建时间', title: '上传时间', width: 150, formatter: ZLPMS.formatterData },
  217. {
  218. field: '预警ID', title: '是否预警', width: 100, align: 'center',
  219. formatter: function (value, rowData, index) {
  220. if (value) {
  221. return "报警"
  222. }
  223. }
  224. },
  225. {
  226. field: '状态', title: '状态', width: 100, align: 'center',
  227. formatter: function (value, rowData, index) {
  228. switch (value) {
  229. case 1: {
  230. return '正常';
  231. }
  232. default: {
  233. return '异常';
  234. }
  235. }
  236. }
  237. }
  238. ]],
  239. singleSelect: true,
  240. onClickRow: function (index, row) {
  241. if (row.状态 != 1) {
  242. $("#MS").html(row.上报原始数据);
  243. } else {
  244. try {
  245. var json = JSON.parse(row.上报原始数据);
  246. $("#MS").html(JSON.stringify(json, null, 4));
  247. }
  248. catch (ex) {
  249. $("#MS").html(row.上报原始数据);
  250. }
  251. }
  252. }
  253. });
  254. }
  255. //提交表单信息
  256. var Forms = {
  257. Submit: function (index, layero) {
  258. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  259. //调用子页面的方法,得到子页面返回的ids
  260. var param = iframeWin.Forms.PostData();
  261. },
  262. //读取数据
  263. PostData: function () {
  264. //执行提交验证
  265. var r = $("#ff").form('validate');
  266. if (r) {
  267. var param = ZLPMS.FormToObject('ff');
  268. return param;
  269. }
  270. return null;
  271. }
  272. };
  273. //重新刷新页面 7
  274. var List = {
  275. //重新加载页面所有信息
  276. Reload: function () {
  277. InitTable();
  278. }
  279. };
  280. //回车提交查询
  281. function Enter_Submit() {
  282. InitTable();
  283. }