groupScoreStatistics.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7. <title>隐患详情</title>
  8. <link rel="stylesheet" href="../../../assets/libs/layui/css/layui.css"/>
  9. <link rel="stylesheet" href="../../../assets/module/formSelects/formSelects-v4.css"/>
  10. <link rel="stylesheet" href="../../../assets/module/admin.css?v=312"/>
  11. <link rel="stylesheet" href="../../../assets/module/uParas.css?v=312"/>
  12. </head>
  13. <body>
  14. <style type="text/css">
  15. /*table th{*/
  16. /* color: #ffb800;*/
  17. /*}*/
  18. table tr th, td {
  19. text-align: center;
  20. }
  21. .one {
  22. border-bottom: 1px solid indianred;
  23. color: #FF4B28;
  24. }
  25. .two {
  26. border-bottom: 1px solid #148ef1;
  27. color: #FF6C00;
  28. }
  29. .three {
  30. border-bottom: 1px solid #FFDF0E;
  31. color: #FFDF0E;
  32. }
  33. .four {
  34. border-bottom: 1px solid #00C0FF;
  35. color: #00C0FF;
  36. }
  37. </style>
  38. <!-- 加载动画 -->
  39. <div class="page-loading">
  40. <div class="ball-loader">
  41. <span></span><span></span><span></span><span></span>
  42. </div>
  43. </div>
  44. <!-- 正文开始 -->
  45. <div class="layui-fluid">
  46. <div class="layui-card">
  47. <div class="layui-card-body">
  48. <form class="layui-form m-top10px m-bottom10px" lay-filter="filterForm" id="filterForm">
  49. <div class="layui-card-header">
  50. <div class="layui-inline layui-col-md2 text-left" style="margin-left: -40px;">
  51. <label class="layui-form-label">部门</label>
  52. <div class="layui-input-block">
  53. <input type="text" id="currentGroupName" class="layui-input" name="currentGroupName"
  54. value=""
  55. placeholder="全部部门"
  56. class="form-control" readonly>
  57. <input type="hidden" id="selectedGroup" name="selectedGroup" readonly>
  58. <div id="menuContent" class="menuContent">
  59. <ul id="groupTree" class="ztree" style="margin-top:0;"></ul>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="layui-inline layui-col-md2 ">
  64. <label class="layui-form-label">日期</label>
  65. <div class="layui-input-block">
  66. <input type="text" name="yearStr" id="yearStr"
  67. placeholder="选择年份" lay-verify="datetime" autocomplete="off" class="layui-input work-flow-review-hint">
  68. </div>
  69. </div>
  70. <!-- <div class="layui-inline layui-col-md2 ">-->
  71. <!-- <div class="layui-input-block" style="margin-left: 0px;margin-top: -3px;">-->
  72. <!-- <button id="formSubSearch" class="layui-btn icon-btn bg-c-add">-->
  73. <!-- <i class="layui-icon">&#xe615;</i>-->
  74. <!-- </button>-->
  75. <!-- </div>-->
  76. <!-- </div>-->
  77. </div>
  78. <div class="layui-card-body overflow-y-680px">
  79. <div class="layui-tab layui-tab-brief ">
  80. <!--统计图-->
  81. <div id="groupScoreStatistics" class="m-top10px" style="height:550px;"></div>
  82. </div>
  83. </div>
  84. </form>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- js部分 -->
  89. <script type="text/javascript" src="../../../assets/libs/layui/layui.js"></script>
  90. <script type="text/javascript" src="../../../assets/js/common.js?v=312"></script>
  91. <script type="text/javascript" src="../../../assets/libs/echarts/echarts.min.js?v=312"></script>
  92. <script type="text/javascript" src="../../../assets/libs/jquery/jquery-3.2.1.min.js"></script>
  93. <script>
  94. layui.use(['layer', 'form', 'table', 'util', 'zTree','_groupTree','laydate', 'admin', 'uParas', 'element', 'laytpl'], function () {
  95. var $ = layui.jquery;
  96. var layer = layui.layer;
  97. var form = layui.form;
  98. var util = layui.util;
  99. var table = layui.table;
  100. var admin = layui.admin;
  101. var uParas = layui.uParas;
  102. var element = layui.element, laytpl = layui.laytpl;
  103. var _groupTree = layui._groupTree;
  104. var laydate = layui.laydate;
  105. var insTb;
  106. /*日期*/
  107. laydate.render({
  108. elem: '#yearStr',
  109. format: 'yyyy',
  110. type: 'year',
  111. value: new Date().getFullYear(), //初始化值
  112. btns: false, //隐藏按钮
  113. change: function(value, date){ //监听日期被切换
  114. $("#yearStr").val(value);
  115. findByStatistics($("#selectedGroup").val(), $("#yearStr").val());
  116. /*更新数据表*/
  117. var data = {"yearStr":$("#yearStr").val(),"gId":$("#selectedGroup").val()};
  118. insTb.reload({where: data}, 'data');
  119. }
  120. });
  121. findByStatistics($("#selectedGroup").val(), $("#yearStr").val());
  122. /**
  123. * 部门过滤
  124. * ztree 文本下拉
  125. */
  126. admin.req(uParas.baseUrl + '/admin/common/getGroupLists', null, function (res) {
  127. if (res.code == 1) {
  128. $.fn.zTree.init($('#groupTree'), settingMAP, res.data);
  129. $.fn.zTree.getZTreeObj("groupTree").expandAll(true);
  130. layer.closeAll('loading');
  131. hideMenuMap();
  132. }
  133. }, 'get');
  134. $("#currentGroupName").click(function () {
  135. $("#menuContent").slideDown("fast");
  136. $("body").bind("mousedown", onBodyDown);
  137. });
  138. function onBodyDown(event) {
  139. if (!(event.target.id === "selectedGroup" || event.target.id === "menuContent" || $(event.target).parents("#menuContentMap").length > 0)) {
  140. hideMenuMap();
  141. }
  142. }
  143. var settingMAP = {
  144. check: {
  145. enable: false,
  146. chkboxType: {"Y": "", "N": ""}
  147. },
  148. view: {
  149. dblClickExpand: false
  150. },
  151. data: {
  152. simpleData: {
  153. enable: true,
  154. idKey: "gId",
  155. pIdKey: "groupParent",
  156. rootPId: null
  157. },
  158. key: {
  159. name: "groupName"
  160. }
  161. },
  162. callback: {
  163. onClick: onClickMap
  164. }
  165. };
  166. function onClickMap(event, treeId, treeNode, clickFlag) {
  167. var zTree = $.fn.zTree.getZTreeObj("groupTree"),
  168. nodes = zTree.getSelectedNodes(),
  169. v = "", idlist = "";
  170. for (var i = 0, l = nodes.length; i < l; i++) {
  171. v += nodes[i].groupName + ",";
  172. idlist += nodes[i].gId + ",";
  173. }
  174. if (v.length > 0) {
  175. v = v.substring(0, v.length - 1);
  176. idlist = idlist.substring(0, idlist.length - 1);
  177. }
  178. var cityObj = $("#currentGroupName");
  179. if (cityObj.val() == v) {
  180. cityObj.attr("value", "");
  181. $("#gId").attr("value", "");
  182. } else {
  183. cityObj.attr("value", v);
  184. $("#gId").attr("value", idlist);
  185. }
  186. hideMenuMap();
  187. var groupId_ = idlist;
  188. if (groupId_ != "-1") {
  189. var Obj = new Object();
  190. Obj.gId = groupId_;
  191. }
  192. if (insTb != null && insTb != undefined && insTb != '') {
  193. /*更新数据表*/
  194. insTb.reload({where: Obj}, 'data');
  195. }
  196. /*更新统计*/
  197. findByStatistics(groupId_, $("#yearStr").val());
  198. }
  199. function hideMenuMap() {
  200. $("#menuContent").fadeOut("fast");
  201. $("body").unbind("mousedown", onBodyDown);
  202. }
  203. /**结束*/
  204. /*搜索*/
  205. // $('#formSubSearch').click(function () {
  206. // var data = {"hiddenYear":$("#yearStr").val(),"groupId":$("#selectedGroup").val()};
  207. // // insTb.reload({where: data}, 'data');
  208. // // initTable(data);
  209. // // insTb.reload({where: data}, 'data');
  210. // findByStatistics($("#selectedGroup").val(), $("#yearStr").val());
  211. // });
  212. // $("#yearStr").change(function () {
  213. // findByStatistics($("#selectedGroup").val(), $("#yearStr").val());
  214. // });
  215. /*统计数据*/
  216. function findByStatistics(groupId, yearStr) {
  217. var url = "/ent/performanceScore/findScoreMonthStatistics";
  218. var dataMap = {
  219. "gId": groupId,
  220. "yearStr": yearStr,
  221. "isMyself": 0, //0部门统计
  222. };
  223. admin.req(uParas.baseUrl + url, dataMap, function (res) {
  224. if (res.code == 1) {
  225. /*绘制统计图*/
  226. initChartStatcs(res.data.monthScore);
  227. }
  228. }, 'get');
  229. }
  230. /*初始化统计图*/
  231. function initChartStatcs(monthScore) {
  232. var dataArray = [];
  233. var seriesArray = [];
  234. seriesArray[0] = {
  235. name: '分数',
  236. barGap: 0,
  237. type: 'line', //line 折线图;bar柱状图
  238. barGap:'-100%',
  239. barCategoryGap:'60%',
  240. label: {show: true,position: 'top'},
  241. data: monthScore,
  242. };
  243. var seriesLabel = [];
  244. var colorArray = [];
  245. seriesLabel[0] = {
  246. label: {show: true,position: 'top'},
  247. };
  248. colorArray[0] = '#00C0FF';
  249. var myChart = echarts.init(document.getElementById('groupScoreStatistics'));
  250. echarts.config = {
  251. align: 'center',
  252. verticalAlign: 'middle',
  253. distance: 15,
  254. onChange: function () {
  255. myChart.setOption({
  256. series: seriesLabel
  257. // series: [{
  258. // label: labelOption
  259. // }, {
  260. // label: labelOption
  261. // }, {
  262. // label: labelOption
  263. // }, {
  264. // label: labelOption
  265. // }]
  266. });
  267. }
  268. };
  269. option = {
  270. title: {
  271. left: "2%",
  272. text: $("#yearStr").val() + '年-月度统计',
  273. //subtext: 'eeee',
  274. x: 'left'
  275. },
  276. tooltip: {
  277. trigger: 'axis',
  278. axisPointer: {
  279. type: 'cross',
  280. crossStyle: {
  281. color: '#999'
  282. }
  283. }
  284. },
  285. // color: ['#FF4B28', '#FF6C00', '#FFDF0E', '#00C0FF'],
  286. color: colorArray,
  287. toolbox: {
  288. itemSize: 18,
  289. itemGap: 15,
  290. right: '50',
  291. feature: {
  292. show: true,
  293. orient: 'vertical',
  294. mark: {
  295. show: true,
  296. },
  297. dataView: {
  298. show: false,
  299. optionToContent: function (opt) {
  300. // console.log(11111);
  301. var xaisName = opt.xAxis[0].name;
  302. var axisData = opt.xAxis[0].data;
  303. var series = opt.series;
  304. var tableDom = document.createElement("table");
  305. tableDom.setAttribute("id", "test");
  306. tableDom.setAttribute("class", "table-data-table");
  307. var table = '<table id="test" style="width:100%;height:200px; text-align:center;border: 3px solid;">';
  308. var table = '<thead><tr style="height: 40px;">'
  309. + '<td style="width: 200px;height: 30px;">' + xaisName + '</td>'
  310. + '<td class="one" style="width: 200px;height: 30px;">' + series[0].name + '</td>'
  311. + '<td class="two" style="width: 200px;height: 30px;">' + series[1].name + '</td>'
  312. + '<td class="three" style="width: 200px;height: 30px;">' + series[2].name + '</td>'
  313. + '<td class="four" style="width: 200px;height: 30px;">' + series[3].name + '</td>'
  314. + '</tr></thead><tbody>';
  315. for (var i = 0, l = axisData.length; i < l; i++) {
  316. table += '<tr style="height: 35px;">'
  317. + '<td style="height: 30px;">' + axisData[i] + '</td>'
  318. + '<td class="one" style="height: 30px;">' + series[0].data[i] + '</td>'
  319. + '<td class="two" style="height: 30px;">' + series[1].data[i] + '</td>'
  320. + '<td class="three" style="height: 30px;">' + series[2].data[i] + '</td>'
  321. + '<td class="four" style="height: 30px;">' + series[3].data[i] + '</td>'
  322. + '</tr>';
  323. }
  324. table += '</tbody>';
  325. tableDom.innerHTML = table;
  326. return tableDom;
  327. },
  328. readOnly: true, //是否可以编辑
  329. lang: ['数据视图', '关闭', '刷新'],
  330. buttonColor: '#cccccc',
  331. buttonTextColor: '#000',
  332. },
  333. magicType: {show: true, type: ['line', 'bar']},
  334. restore: {show: false},
  335. saveAsImage: {show: true}
  336. }
  337. },
  338. legend: {
  339. left: 'center',
  340. // data: ['重大隐患总数', '较大隐患总数', '一般隐患总数', '较低隐患总数']
  341. data: dataArray
  342. },
  343. xAxis: [
  344. {
  345. name: '共12个周期',
  346. type: 'category',
  347. axisTick: {show: false},
  348. data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
  349. axisPointer: {
  350. type: 'shadow'
  351. }
  352. }
  353. ],
  354. yAxis: [
  355. {
  356. type: 'value',
  357. name: '分数',
  358. },
  359. ],
  360. grid: {
  361. // width:"50%",
  362. left: "2%",
  363. right: "6%",
  364. bottom: "40",
  365. top: "12%",
  366. containLabel: true
  367. },
  368. calculable: true,
  369. series: seriesArray
  370. };
  371. myChart.setOption(option);
  372. setTimeout(function () {
  373. window.onresize = function () {
  374. myChart.resize();
  375. }
  376. }, 200);
  377. }
  378. });
  379. </script>
  380. </body>
  381. </html>