illegalDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div class="main" v-cloak>
  3. <Header/>
  4. <div class="main_t">
  5. <div class="main_t_t">
  6. <i class="main_t_t_l">当前位置:首页 &gt;</i>
  7. <i>人员违规统计</i>
  8. </div>
  9. <div class="main_t_b" id="illegal_chart"></div>
  10. </div>
  11. <div class="main_b">
  12. <!--查询条件-->
  13. <el-form :model="editForm" ref="queryParams" class="form-box" :inline="true" style="margin:20px;">
  14. <el-form-item label="实验室" prop="dangerId" label-width="98px">
  15. <el-select v-model="editForm.subId" popper-class="select-big-data" placeholder="请选择实验室">
  16. <el-option
  17. v-for="item in labList"
  18. :key="item.id"
  19. :label="item.name"
  20. :value="item.id">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="违规原因" prop="dangerId" label-width="98px">
  25. <el-select v-model="editForm.violationType" popper-class="select-big-data" placeholder="请选择违规原因">
  26. <el-option
  27. v-for="item in causeList"
  28. :key="item.id"
  29. :label="item.violationName"
  30. :value="item.id">
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="日期" prop="dateRange" label-width="68px">
  35. <el-date-picker
  36. popper-class="select-big-data-time"
  37. v-model="dateRange"
  38. size="small"
  39. style="width: 240px"
  40. value-format="yyyy-MM-dd"
  41. type="daterange"
  42. range-separator="-"
  43. start-placeholder="开始日期"
  44. end-placeholder="结束日期"
  45. ></el-date-picker>
  46. </el-form-item>
  47. <el-form-item label-width="0">
  48. <el-button type="primary" @click.native.prevent="onSearch" native-type="submit">查询</el-button>
  49. <el-button @click="resetForm('searchForm')">重置</el-button>
  50. </el-form-item>
  51. </el-form>
  52. <!--列表-->
  53. <el-table :data="tableData" style="width: 100%" height="420" :row-class-name="tableRowClassName">
  54. <el-table-column align="center" header-align='center' type="index" :index="indexMethod" label="序号" width="60"></el-table-column>
  55. <el-table-column align="center" header-align='center' prop="subName" label="实验室"></el-table-column>
  56. <el-table-column align="center" header-align='center' prop="typeName" label="安全分类"></el-table-column>
  57. <el-table-column align="center" header-align='center' prop="classifiedName" label="安全分级"></el-table-column>
  58. <el-table-column align="center" header-align='center' prop="content" label="违规原因"></el-table-column>
  59. <el-table-column align="center" header-align='center' prop="num" label="违规次数"></el-table-column>
  60. </el-table>
  61. <el-pagination
  62. style="margin-top: 14px"
  63. background
  64. @current-change="handleCurrentChange"
  65. :page-sizes="[10, 20, 30, 40]"
  66. :current-page.sync="param.pageNo"
  67. :page-size="param.pageSize"
  68. layout="total,prev, pager, next"
  69. :total="totalNum">
  70. </el-pagination>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import {
  76. departmentsList,
  77. detailColumnar,
  78. detailSubList,
  79. getDictViolation,
  80. getSubjectDict,
  81. } from "../api/http"
  82. import Header from '@/components/header.vue'
  83. export default {
  84. components: {
  85. Header
  86. },
  87. data() {
  88. return {
  89. //查询条件
  90. param:{
  91. pageNo:1,
  92. pageSize:5
  93. },
  94. editForm:{
  95. deptLevel:'',//这个是登陆后,刘波给你的院校的类型
  96. subId:'',//实验室
  97. violationType:'',//违规类型
  98. beginTimeStr:'',//开始时间
  99. endTimeStr:'',//结束时间
  100. },
  101. subjectOptions:[],//院系
  102. causeList:[],//违规原因
  103. dateRange:[],//时间
  104. totalNum:0,
  105. tableData:[],
  106. labList:[],//实验室
  107. endDay:new Date(2019,11,0).getDate()
  108. }
  109. },
  110. methods: {
  111. back(){
  112. this.$router.push('/')
  113. },
  114. tableRowClassName({ rowIndex}) {
  115. if (rowIndex%2 === 0) {
  116. return 'success-row';
  117. } else{
  118. return 'warning-row';
  119. }
  120. },
  121. indexMethod(index) {
  122. return (this.param.pageNo - 1) * this.param.pageSize + index + 1;
  123. },
  124. //请求列表
  125. getAjaxList:function (){
  126. let _this=this;
  127. //列表
  128. let obj={
  129. 'subjectId':this.editForm.subId,
  130. 'violationType':this.editForm.violationType,
  131. 'beginTimeStr':this.editForm.beginTimeStr,
  132. 'endTimeStr':this.editForm.endTimeStr,
  133. }
  134. detailSubList(obj).then((res) =>{
  135. if(res.code==200){
  136. let data = res.rows;
  137. if(data && data.length>0){
  138. _this.tableData = data;
  139. _this.totalNum = res.total;
  140. }else{
  141. _this.tableData = [];
  142. _this.totalNum = 0;
  143. }
  144. }
  145. })
  146. },
  147. getAjaxData: function () {
  148. let _this=this;
  149. //人员违规统计图表
  150. let obj={
  151. 'deptLevel':localStorage.getItem('deptLevel'),
  152. 'subjectId':this.editForm.subId,
  153. 'violationType':this.editForm.violationType,
  154. 'beginTimeStr':this.editForm.beginTimeStr,
  155. 'endTimeStr':this.editForm.endTimeStr,
  156. }
  157. detailColumnar(obj).then((res) =>{
  158. if(res.code==200){
  159. var illegalDetailData=[];
  160. let data=res.data;
  161. let dataLength=0;
  162. let dataNum=[];
  163. if(data.length<=1){
  164. illegalDetailData=[
  165. ['product', '离开未打卡', '未佩戴护目镜', '未佩戴实验手套', '非法闯入', '未穿着实验服','实验室清洁'],
  166. ['第一季度', 0, 0, 0,0,0,0],
  167. ['第二季度', 0, 0, 0,0,0,0],
  168. ['第三季度', 0, 0, 0,0,0,0],
  169. ['第四季度', 0, 0, 0,0,0,0],
  170. ]
  171. dataNum= [
  172. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} ,"label": {"normal": {"show": true,"position": "top",fontSize: 14,color: '#fff',}},},
  173. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}},
  174. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} },
  175. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}},
  176. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} },
  177. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}}
  178. ]
  179. }else{
  180. illegalDetailData=data
  181. illegalDetailData[0].unshift('product')
  182. dataLength=illegalDetailData[0].length-1
  183. for(var i=0;i<dataLength;i++){
  184. dataNum.push({ type: 'bar',barMaxWidth: "20", itemStyle: { normal: { barBorderRadius: 8}},"label": {"normal": {"show": true,"position": "top",fontSize: 14,color: '#fff',}}, },)
  185. }
  186. }
  187. _this.illegalDetailFun(illegalDetailData,dataNum)
  188. }
  189. })
  190. //查询院系
  191. departmentsList().then((res) =>{
  192. if(res.code==200){
  193. let data=res.data;
  194. _this.subjectOptions=data
  195. }
  196. })
  197. //查询实验室
  198. getSubjectDict().then((res) =>{
  199. if(res.code==200){
  200. let data=res.data;
  201. _this.labList=data
  202. }
  203. })
  204. //查询违规原因
  205. getDictViolation().then((res) =>{
  206. if(res.code==200){
  207. let data=res.data;
  208. _this.causeList=data
  209. }
  210. })
  211. },
  212. /*查询*/
  213. onSearch() {
  214. if(this.dateRange.length>0){
  215. this.editForm.beginTimeStr = this.dateRange[0];
  216. this.editForm.endTimeStr = this.dateRange[1];
  217. }
  218. this.getAjaxList();
  219. this.getAjaxData();
  220. },
  221. /*重置*/
  222. resetForm() {
  223. this.editForm.subId = "";
  224. this.editForm.violationType = "";
  225. this.editForm.beginTimeStr=this.getdate()+'-1'
  226. this.editForm.endTimeStr=this.getdate()+'-'+this.endDay
  227. this.dateRange = [];
  228. this.onSearch();
  229. },
  230. handleCurrentChange(val) {
  231. this.param.pageNo = val;
  232. // this.getAjaxList();
  233. },
  234. getdate() {
  235. var date = new Date();
  236. var year = date.getFullYear();
  237. var month = date.getMonth() + 1;
  238. var strDate = date.getDate();
  239. if (month >= 1 && month <= 9) {
  240. month = "0" + month;
  241. }
  242. if (strDate >= 0 && strDate <= 9) {
  243. strDate = "0" + strDate;
  244. }
  245. var currentdate = year + "-" + month;
  246. return currentdate;
  247. },
  248. /*安全隐患详情图表*/
  249. illegalDetailFun:function(illegalDetailData,dataNum) {
  250. let illegalOption = {
  251. color: ['#05A3CD','#1CB146','#822FDF','#C65A18','#18C4C6','#055ACD'],
  252. legend: {
  253. type: 'scroll',
  254. itemGap:20,
  255. itemWidth :14,
  256. textStyle:{
  257. color:'#fff'
  258. },
  259. right: '5%',
  260. top: '2%',
  261. },
  262. tooltip: {},
  263. grid: {
  264. left: '3%',
  265. right: '4%',
  266. bottom: '3%',
  267. top: '20%',
  268. containLabel: true
  269. },
  270. dataset: {
  271. /*source: [
  272. ['product', '离开未打卡', '未佩戴护目镜', '未佩戴实验手套', '非法闯入', '为穿着实验服','实验室清洁'],
  273. ['第一季度', 43.3, 85.8, 93.7,12,12,34],
  274. ['第二季度', 83.1, 73.4, 55.1,12,12,34],
  275. ['第三季度', 86.4, 65.2, 82.5,12,12,34],
  276. ['第四季度', 72.4, 53.9, 39.1,12,12,34]
  277. ]*/
  278. source:illegalDetailData
  279. },
  280. xAxis: {
  281. type: 'category',
  282. axisLabel: {
  283. textStyle: {//改变X轴字体颜色
  284. color: '#fff',
  285. }
  286. },
  287. axisTick:{//去掉X轴刻度
  288. show:false,
  289. },
  290. axisLine:{
  291. lineStyle:{
  292. color:'#2E4C74',//改变X轴颜色
  293. width: 2,
  294. }
  295. },
  296. },
  297. yAxis: {
  298. axisLabel: {
  299. textStyle: {//改变X轴字体颜色
  300. color: '#fff',
  301. }
  302. },
  303. splitLine: { // 分隔线
  304. show: false, // 默认显示,属性show控制显示与否
  305. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  306. color: ['#fff'],
  307. width: 1,
  308. type: 'solid',
  309. opacity:0.15
  310. },
  311. },
  312. axisTick:{//去掉X轴刻度
  313. show:false,
  314. },
  315. axisLine:{
  316. show:true,
  317. lineStyle:{
  318. color:'#2E4C74',//改变X轴颜色
  319. width: 2,
  320. }
  321. },
  322. },
  323. // Declare several bar series, each will be mapped
  324. // to a column of dataset.source by default.
  325. series:dataNum
  326. /* series: [
  327. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} ,"label": {"normal": {"show": true,"position": "top",fontSize: 14,color: '#fff',}},},
  328. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}},
  329. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} },
  330. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}},
  331. { type: 'bar', itemStyle: { normal: { barBorderRadius: 8}} },
  332. { type: 'bar' , itemStyle: { normal: { barBorderRadius: 8}}}
  333. ]*/
  334. };
  335. var illegal_chart = this.$echarts.init(document.getElementById('illegal_chart'));
  336. illegal_chart.setOption(illegalOption);
  337. }
  338. },
  339. beforeMount(){
  340. let _this=this
  341. _this.editForm.beginTimeStr=_this.getdate()+'-1'
  342. _this.editForm.endTimeStr=_this.getdate()+'-'+_this.endDay
  343. },
  344. mounted() {
  345. this.getAjaxData()
  346. this.getAjaxList()
  347. },
  348. }
  349. </script>
  350. <!-- Add "scoped" attribute to limit CSS to this component only -->
  351. <style lang="scss" scoped>
  352. @function rw($px){
  353. @return $px*100/1920 *1vw;
  354. }
  355. @function rh($px){
  356. @return $px*100/1080 *1vh;
  357. }
  358. * {
  359. padding: 0;
  360. margin: 0;
  361. box-sizing: border-box;
  362. }
  363. .main {
  364. width: rw(1920);
  365. height: rh(1080);
  366. /* background: url("../img/index_bg.png") no-repeat;
  367. background-size: 100% 100%;*/
  368. position: relative;
  369. left: 0;
  370. top: 0;
  371. z-index: 50;
  372. background: #062338;
  373. .header {
  374. width: 100%;
  375. position: absolute;
  376. left: rw(0);
  377. top: rh(0);
  378. z-index: 100;
  379. display: flex;
  380. justify-content: flex-start;
  381. .header_l {
  382. width: rw(182);
  383. height: rh(44);
  384. margin: rh(10) 0 0 rw(40);
  385. }
  386. .header_c {
  387. width: rw(1180);
  388. height: rh(152);
  389. margin-left: rw(136);
  390. background: url("~@/assets/image/index_icon2.png") no-repeat;
  391. background-size: 100% 100%;
  392. font-size: rh(30);
  393. font-family: Microsoft YaHei;
  394. font-weight: bold;
  395. color: #FFFFFF;
  396. line-height: rh(30);
  397. text-align: center;
  398. padding-top: rh(26);
  399. }
  400. .header_r {
  401. margin-left: rw(264);
  402. width: rw(82);
  403. height: rh(32);
  404. margin-top: rh(18);
  405. }
  406. }
  407. .main_t{
  408. background: rgba(9, 55, 81, 0.6);
  409. width: rw(1852);
  410. height: rh(352);
  411. position: absolute;
  412. left: rw(34);
  413. top: rh(86);
  414. z-index: 200;
  415. .main_t_t{
  416. margin: rh(20) 0 0 rw(18);
  417. >i{
  418. font-size: rh(16);
  419. font-family: Microsoft YaHei;
  420. font-weight: bold;
  421. color: #FFFFFF;
  422. line-height: rh(16);
  423. }
  424. >i:nth-of-type(1){
  425. }
  426. >i:nth-of-type(2){
  427. color: #1ED0F8;
  428. }
  429. }
  430. .main_t_b{
  431. width: rw(1852);
  432. height: rh(302);
  433. }
  434. }
  435. .main_b{
  436. background: rgba(9, 55, 81, 0.6);
  437. padding: 0 rw(32);
  438. width: rw(1852);
  439. height: rh(602);
  440. position: absolute;
  441. left: rw(34);
  442. top: rh(468);
  443. z-index: 200;
  444. }
  445. }
  446. </style>
  447. <style lang="scss">
  448. li{list-style:none}
  449. i,em,b{font-style:normal;font-weight:100;}
  450. body{margin: 0}
  451. </style>