sensor.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <div class="sensor-page">
  3. <header>
  4. <div :class="activeId===item.id?'active item':'item'" v-for="item in items" :key="item.id" @click="changeHead(item)">{{ item.name }}</div>
  5. </header>
  6. <div class="tab">
  7. <el-select v-model="conditions.goafOrebelt" placeholder="矿带" @change="changeArea(1)" style="width:120px" clearable>
  8. <el-option v-for="(item,index) in goafOrebelts" :key="index" :value="item" :label="item" />
  9. </el-select>
  10. <el-select v-model="conditions.goafOrebody" placeholder="矿体" @change="changeArea(2)" style="width:120px;margin:0 12px;">
  11. <el-option v-for="(item,index) in goafOrebodys" :key="index" :value="item.goafOrebody" :label="item.goafOrebody" />
  12. </el-select>
  13. <el-select v-model="conditions.goafOreheight" placeholder="中段" @change="changeArea(3)" style="width:120px">
  14. <el-option v-for="(item,index) in goafOreheights" :key="index" :value="item.goafOreheight" :label="item.goafOreheight" />
  15. </el-select>
  16. <el-select v-model="conditions.goafId" placeholder="采空区编号" @change="changeArea(4)" style="width:210px;margin:0 12px;">
  17. <el-option v-for="item in goafNames" :key="item.goafId" :value="item.goafId" :label="item.goafName" />
  18. </el-select>
  19. </div>
  20. <div class="container">
  21. <div class="lf">
  22. <div class="search-container">
  23. <div class="search-item">
  24. <el-input v-model="conditions.goafDevName" class="input" placeholder="请输入设备编号" />
  25. </div>
  26. <div class="search-item">
  27. <span>预警等级:</span>
  28. <el-select v-model="conditions.hdangerLevel" placeholder="全部" style="width:120px;margin-right:14px;" clearable>
  29. <el-option
  30. v-for="item in hdangerLevels"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value"
  34. />
  35. </el-select>
  36. </div>
  37. <!-- <div class="search-item">
  38. <span>状态:</span>
  39. <el-select v-model="conditions.status" class="select" placeholder="全部">
  40. <el-option
  41. v-for="item in options"
  42. :key="item.value"
  43. :label="item.label"
  44. :value="item.value"
  45. />
  46. </el-select>
  47. </div> -->
  48. <div class="search-item">
  49. <!-- <span>预警开始时间:</span> -->
  50. <el-date-picker
  51. v-model="conditions.expectedStartDate"
  52. type="datetime"
  53. placeholder="预警开始时间"
  54. format="YYYY-MM-DD HH:mm:ss"
  55. value-format="YYYY-MM-DD HH:mm:ss"
  56. style="width:200px;margin-right: 14px;"
  57. />
  58. </div>
  59. <div class="search-item">
  60. <!-- <span>预警结束时间:</span> -->
  61. <el-date-picker
  62. v-model="conditions.expectedEndDate"
  63. type="datetime"
  64. placeholder="预警结束时间"
  65. style="width:200px;margin-right: 14px;"
  66. format="YYYY-MM-DD HH:mm:ss"
  67. value-format="YYYY-MM-DD HH:mm:ss"
  68. />
  69. </div>
  70. <!-- <div class="search-item">
  71. <span>数值范围:</span>
  72. <el-input-number v-model="conditions.start" :max="conditions.end" class="input" placeholder="开始" :controls="false" style="width:100px;" />
  73. <span>-</span>
  74. <el-input-number v-model="conditions.end" :min="conditions.start" placeholder="结束" :controls="false" style="width:100px;margin:0 10px;" />
  75. </div> -->
  76. <div class="bt search" @click="searchSubmit">查询</div>
  77. <div class="bt" @click="resetSubmit">重置</div>
  78. </div>
  79. <div class="lf-container">
  80. <div class="card-container">
  81. <div class="card" v-for="(item,index) in dataList" :key="index">
  82. <div class="title">{{item.goafDevTypename}}</div>
  83. <div class="info">
  84. <p>设备编号:{{item.goafDevName}}</p>
  85. <p>安装区域:{{ NumConvertLM(item.goafOrebelt) }}/{{ item.goafOrebody }}/{{ item.goafOreheight }}/{{ item.goafName }}</p>
  86. <p>安装位置:{{ item.goafDevLocation }}</p>
  87. <p>阈值:{{item.goafAlarmThreshold}}</p>
  88. <p>上报数据值:{{item.goafSensorValue}}</p>
  89. </div>
  90. <footer :class="'status-'+item.hdangerLevel">{{hdangerLevel(item.hdangerLevel)}}</footer>
  91. </div>
  92. </div>
  93. <div class="el-pagination-wrap">
  94. <el-pagination small layout="prev, pager, next"
  95. :total="total"
  96. @size-change="handleSizeChange"
  97. @current-change="handleCurrentChange" />
  98. </div>
  99. </div>
  100. </div>
  101. <div class="rt">
  102. <div class="head">
  103. <div class="name">传感器数据统计</div>
  104. <div class="number">{{statistics.total}}</div>
  105. </div>
  106. <div class="head-info">
  107. <div class="item total">
  108. <div class="name">总数</div>
  109. <div class="number">{{statistics.total}}</div>
  110. </div>
  111. <div class="item normal">
  112. <div class="name">正常</div>
  113. <div class="number">{{statistics.normal}}</div>
  114. </div>
  115. <div class="item error">
  116. <div class="name">异常</div>
  117. <div class="number">{{statistics.error}}</div>
  118. </div>
  119. </div>
  120. <div class="chart-wrap">
  121. <div class="title">报警统计</div>
  122. <alert-chart ref="alert-chart" />
  123. </div>
  124. <div class="chart-wrap">
  125. <div class="title">预警处理情况</div>
  126. <warn-chart ref="warn-chart" />
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. import AlertChart from './components/AlertChart.vue'
  134. import WarnChart from './components/WarnChart.vue'
  135. import { getSensorByPage,sensordatatatis } from '@/api/goaf/sensor'
  136. import { getGoafBaseInfo } from '@/api/goaf/info'
  137. import { NumConvertLM ,getTime} from '@/utils'
  138. export default {
  139. name:"sensor",
  140. components:{
  141. AlertChart,
  142. WarnChart
  143. },
  144. data(){
  145. return{
  146. activeId:'1',
  147. activetab:'1',
  148. conditions: {
  149. page: 1,
  150. limit: 8,
  151. goafId: '',
  152. goafOrebelt: '',
  153. goafOrebody: '',
  154. goafOreheight: '',
  155. goafName:"",
  156. goafDevName:"",
  157. hdangerLevel:"",
  158. goafDevTypename:"",
  159. expectedStartDate:getTime(),
  160. expectedEndDate:getTime(1),
  161. // start:0,
  162. // end:0
  163. },
  164. goafList: [],
  165. goafOrebelts: [],
  166. goafOrebodys: [],
  167. goafOreheights: [],
  168. goafNames: [],
  169. items:[
  170. {name:"首页",id:"1",path:"/particulars/sensor"},
  171. {name:"压力传感器",id:"2",path:"/particulars/check"},
  172. {name:"位移传感器",id:"3",path:"/particulars/goaf-info"},
  173. {name:"有害气体传感器",id:"4",path:"/particulars/goaf-info"},
  174. {name:"视频监控",id:"5",path:"/particulars/goaf-info"},
  175. ],
  176. options:[
  177. {label:1,value:2},
  178. {label:2,value:3},
  179. {label:3,value:4}
  180. ] ,
  181. hdangerLevels:[
  182. {label:"异常",value:0},
  183. {label:"威胁",value:1},
  184. {label:"危险",value:2},
  185. {label:"危急",value:3}
  186. ],
  187. dataList:[],
  188. total:0 ,
  189. statistics:{
  190. total:0,
  191. normal:0,
  192. error:0
  193. }
  194. }
  195. },
  196. created(){
  197. this.init()
  198. },
  199. methods:{
  200. NumConvertLM,
  201. hdangerLevel(val){
  202. let status=["异常","威胁","危险","危急"]
  203. return status[val]||'正常'
  204. },
  205. init(){
  206. this.$nextTick(()=>{
  207. this.$refs['alert-chart'].init();
  208. this.$refs['warn-chart'].init();
  209. })
  210. this.getData()
  211. getGoafBaseInfo().then((res) => {
  212. const goafOrebelts = res.data.map(item => item.goafOrebelt)
  213. this.goafOrebelts = [...new Set(goafOrebelts)]
  214. this.goafList = res.data
  215. })
  216. this.sensordatatatis()
  217. },
  218. sensordatatatis(){
  219. sensordatatatis().then((res)=>{
  220. let error=res.data.pressureAlarmNum+res.data.displacementAlarmNum+res.data.harmfulGasAlarmNum
  221. let normal=res.data.sensorDataTotalNum-error
  222. this.statistics={
  223. total:res.data.sensorDataTotalNum,
  224. normal,
  225. error
  226. }
  227. })
  228. },
  229. getData(){
  230. for(let key in this.conditions){
  231. if(this.conditions[key]===undefined||this.conditions[key]==="undefined"||this.conditions[key]===""){
  232. delete this.conditions[key]
  233. }
  234. }
  235. getSensorByPage(this.conditions).then((resp) => {
  236. this.listLoading = false
  237. const {data, total } = resp
  238. let tab=this.items.filter(item=>this.activeId===item.id)[0]
  239. this.dataList = this.activeId==='1'?data:data.filter(item=>item.goafDevTypename===tab.name)
  240. this.total = total
  241. })
  242. },
  243. changeHead(item){
  244. this.activeId=item.id
  245. if(item.id==='5'){
  246. this.$router.push('/particulars/particulars-video')
  247. }else{
  248. this.init()
  249. }
  250. },
  251. searchSubmit(){
  252. this.conditions.page=1
  253. this.getData()
  254. },
  255. resetSubmit(){
  256. this.conditions={
  257. page: 1,
  258. limit: 8,
  259. goafId: '',
  260. goafOrebelt: '',
  261. goafOrebody: '',
  262. goafOreheight: '',
  263. goafName:"",
  264. goafDevName:"",
  265. hdangerLevel:"",
  266. goafDevTypename:"",
  267. expectedStartDate:getTime(),
  268. expectedEndDate:getTime(1),
  269. // start:0,
  270. // end:0
  271. }
  272. this.goafOrebodys=[]
  273. this.goafOreheights=[]
  274. this.goafNames=[]
  275. this.getData()
  276. },
  277. handleSizeChange(limit){
  278. this.conditions.limit=limit
  279. this.getData()
  280. },
  281. handleCurrentChange(pageNumber){
  282. this.conditions.page=pageNumber
  283. },
  284. changeArea(type) {
  285. const goafs = this.deeepClone(this.goafList)
  286. let goafOrebodys = this.deeepClone(this.goafOrebodys)
  287. let goafOreheights = this.deeepClone(this.goafOreheights)
  288. let goafNames = this.deeepClone(this.goafNames)
  289. if (type === 1) {
  290. goafOrebodys = goafs.filter(item => item.goafOrebelt === this.conditions.goafOrebelt)
  291. goafOrebodys = this.unique(goafOrebodys, 'goafOrebody')
  292. this.goafOrebodys = goafOrebodys
  293. this.goafOreheights = []
  294. this.goafNames = []
  295. this.conditions.goafOrebody = ''
  296. this.conditions.goafOreheight = ''
  297. this.conditions.goafName = ''
  298. this.conditions.goafId = ''
  299. } else if (type === 2) {
  300. goafOreheights = goafs.filter(item => (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  301. goafOreheights = this.unique(goafOrebodys, 'goafOreheight')
  302. this.goafOreheights = goafOreheights
  303. this.goafNames = []
  304. this.conditions.goafOreheight = ''
  305. this.conditions.goafName = ''
  306. this.conditions.goafId = ''
  307. } else if (type === 3) {
  308. goafNames = goafs.filter(item => (item.goafOreheight === this.conditions.goafOreheight) && (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  309. this.goafNames = goafNames
  310. this.conditions.goafName = ''
  311. this.conditions.goafId = ''
  312. } else {
  313. for (let i = 0; i < goafNames.length; i++) {
  314. if (this.conditions.goafId === goafNames[i].goafId) {
  315. this.conditions.goafName = goafNames[i].goafName
  316. }
  317. }
  318. }
  319. this.$forceUpdate()
  320. },
  321. unique(arr = [], name = 'name') {
  322. const res = new Map()
  323. return arr.filter((item) => !res.has(item[name]) && res.set(item[name], 1))
  324. },
  325. deeepClone(params) {
  326. return JSON.parse(JSON.stringify(params))
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss" scoped>
  332. .sensor-page{
  333. .search-item{
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. margin-bottom: 14px;
  338. span{
  339. font-family: 'Ping Hei';
  340. font-size: 14px;
  341. line-height: 1;
  342. color: rgba(255, 255, 255, 0.7);
  343. }
  344. }
  345. .input,.select,.el-date-editor{
  346. width: 180px;
  347. margin-right:16px;
  348. color: #fff;
  349. }
  350. ::v-deep{
  351. .el-input__wrapper{
  352. background-color: rgba(8, 128, 255, 0.2);
  353. border: 0;
  354. box-shadow: none;
  355. }
  356. .el-input__inner{
  357. color: #fff;
  358. }
  359. }
  360. header{
  361. display: flex;
  362. justify-content: center;
  363. align-items: center;
  364. padding-top: 0.5vh;
  365. .item{
  366. width: 188px;
  367. height: 36px;
  368. line-height: 36px;
  369. text-align: center;
  370. background-image: url(@/assets/sensor/head.png);
  371. background-size: 100% 100%;
  372. background-repeat: no-repeat;
  373. margin-right: 12px;
  374. max-width: 20%;
  375. color: #7FCFF4;
  376. cursor: pointer;
  377. &.active{
  378. background-image: url(@/assets/sensor/head_active.png);
  379. color: #2AFFFF;
  380. }
  381. }
  382. }
  383. .tab{
  384. padding-top: 1.5vh;
  385. .item{
  386. display: inline-block;
  387. padding: 5px 10px;
  388. color: #fff;
  389. font-size: 16px;
  390. background: #003B7A;
  391. border: 1px solid #004EA2;
  392. letter-spacing: 0.6px;
  393. margin-right: 24px;
  394. border-radius: 4px 15px 8px 4px;
  395. cursor: pointer;
  396. &.active{
  397. background: #0083CF;
  398. border: 1px solid #0097DD;
  399. }
  400. }
  401. }
  402. .container{
  403. display: flex;
  404. .lf{
  405. width: 60%;
  406. padding-left: 100px;
  407. .search-container{
  408. padding:4.4vh 0 5vh 0;
  409. box-sizing: border-box;
  410. display: flex;
  411. flex-wrap: wrap;
  412. .bt{
  413. width: 100px;
  414. height: 36px;
  415. line-height: 36px;
  416. text-align: center;
  417. color: #fff;
  418. font-size: 14px;
  419. background: rgba(8, 128, 255, 0.2);
  420. border-radius: 4px;
  421. margin-top: 14px;
  422. cursor: pointer;
  423. margin-top: 0;
  424. &.search{
  425. background: linear-gradient(rgba(94, 226, 255, 1),rgba(79, 175, 255, 1));
  426. margin:0 10px 0 0;
  427. }
  428. }
  429. }
  430. .lf-container{
  431. .card-container{
  432. display: flex;
  433. justify-content: flex-start;
  434. flex-wrap: wrap;
  435. padding-left: 50px;
  436. .card{
  437. width: 22%;
  438. height: 25vh;
  439. background: rgba(35, 229, 254, 0.06);
  440. border: 1px solid #115C7C;
  441. margin:0 4% 10px 0;
  442. box-sizing: border-box;
  443. overflow: hidden;
  444. padding: 14px;
  445. color: #fff;
  446. position: relative;
  447. &:nth-child(4n){
  448. margin-right: 0;
  449. }
  450. .title{
  451. font-size: 18px;
  452. font-weight: bold;
  453. padding-bottom: 12px;
  454. text-align: center;
  455. }
  456. .info{
  457. font-size: 14px;
  458. p{
  459. line-height: 22px;
  460. word-break: break-all;
  461. }
  462. }
  463. footer{
  464. width: 100%;
  465. height: 36px;
  466. line-height: 36px;
  467. position: absolute;
  468. bottom: 0;
  469. left: 0;
  470. text-align: center;
  471. background: #0C6ECF;
  472. &.status-1{
  473. background: #DCBA3D;
  474. }
  475. &.status-2{
  476. background: #EC6B1D;
  477. }
  478. &.status-3{
  479. background: #F33737;
  480. }
  481. }
  482. }
  483. }
  484. .el-pagination-wrap{
  485. float: right;
  486. margin-top: 5vh;
  487. ::v-deep{
  488. .el-pager li,button{
  489. background-color: #00539F;
  490. margin-left: 10px;
  491. color: rgba(255, 255, 255, 0.75);
  492. &.is-active{
  493. background-color: rgba(0, 131, 207, 1);
  494. }
  495. }
  496. }
  497. }
  498. }
  499. }
  500. .rt{
  501. flex: 1;
  502. padding-left: 5%;
  503. box-sizing: border-box;
  504. .head{
  505. height: 32px;
  506. background-image: url(@/views/home/images/home/title.png);
  507. background-size: 100% 100%;
  508. background-repeat: no-repeat;
  509. color: #2affff;
  510. font-size: 20px;
  511. display: flex;
  512. justify-content: space-between;
  513. align-items: center;
  514. text-indent: 24px;
  515. padding: 0 14px;
  516. font-family: "YouSheBiaoTiHei";
  517. letter-spacing: 1px;
  518. margin-top: 4.8vh;
  519. }
  520. .head-info{
  521. display: flex;
  522. justify-content: center;
  523. align-items: center;
  524. padding-top: 20px;
  525. .item{
  526. width: 33.33%;
  527. display: flex;
  528. justify-content: center;
  529. align-items: center;
  530. flex-direction: column;
  531. color: #fff;
  532. font-size: 12px;
  533. &.total{
  534. display: block;
  535. font-weight: bold;
  536. text-align: left;
  537. .name{
  538. font-size: 14px;
  539. line-height: 20px;
  540. }
  541. .number{
  542. font-size: 20px;
  543. line-height: 38px;
  544. font-weight: 700;
  545. background: rgba(108, 128, 151, 0.1)
  546. }
  547. }
  548. &.normal{
  549. border-left:1px solid rgba(255, 255, 255, 0.12);
  550. border-right:1px solid rgba(255, 255, 255, 0.12);
  551. margin: 0 2%;
  552. height: 100%;
  553. .number{
  554. font-size: 20px;
  555. line-height: 28px;
  556. color: #3CD495;
  557. font-weight: 500;
  558. }
  559. }
  560. &.error{
  561. .number{
  562. font-size: 20px;
  563. line-height: 28px;
  564. color: #D4603C;
  565. font-weight: 500;
  566. }
  567. }
  568. }
  569. }
  570. .chart-wrap{
  571. padding-top: 0.8vh;
  572. .title{
  573. color: #fff;
  574. font-size: 18px;
  575. line-height: 20px;
  576. padding: 10px;
  577. position: relative;
  578. font-family: "YouSheBiaoTiHei";
  579. letter-spacing: 1px;
  580. margin-bottom: 2vh;
  581. &::after{
  582. display: block;
  583. content: "";
  584. width: 100%;
  585. height: 3px;
  586. position: absolute;
  587. bottom: 0;
  588. left: 0;
  589. background-image: url('./images/line.png');
  590. background-repeat: no-repeat;
  591. background-size: 100% 100%;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. </style>