sensor.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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.getData()
  253. },
  254. resetSubmit(){
  255. this.conditions={
  256. page: 1,
  257. limit: 8,
  258. goafId: '',
  259. goafOrebelt: '',
  260. goafOrebody: '',
  261. goafOreheight: '',
  262. goafName:"",
  263. goafDevName:"",
  264. hdangerLevel:"",
  265. goafDevTypename:"",
  266. expectedStartDate:getTime(),
  267. expectedEndDate:getTime(1),
  268. // start:0,
  269. // end:0
  270. }
  271. this.goafOrebodys=[]
  272. this.goafOreheights=[]
  273. this.goafNames=[]
  274. this.getData()
  275. },
  276. handleSizeChange(limit){
  277. this.conditions.limit=limit
  278. this.getData()
  279. },
  280. handleCurrentChange(pageNumber){
  281. this.conditions.page=pageNumber
  282. },
  283. changeArea(type) {
  284. const goafs = this.deeepClone(this.goafList)
  285. let goafOrebodys = this.deeepClone(this.goafOrebodys)
  286. let goafOreheights = this.deeepClone(this.goafOreheights)
  287. let goafNames = this.deeepClone(this.goafNames)
  288. if (type === 1) {
  289. goafOrebodys = goafs.filter(item => item.goafOrebelt === this.conditions.goafOrebelt)
  290. goafOrebodys = this.unique(goafOrebodys, 'goafOrebody')
  291. this.goafOrebodys = goafOrebodys
  292. this.goafOreheights = []
  293. this.goafNames = []
  294. this.conditions.goafOrebody = ''
  295. this.conditions.goafOreheight = ''
  296. this.conditions.goafName = ''
  297. this.conditions.goafId = ''
  298. } else if (type === 2) {
  299. goafOreheights = goafs.filter(item => (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  300. goafOreheights = this.unique(goafOrebodys, 'goafOreheight')
  301. this.goafOreheights = goafOreheights
  302. this.goafNames = []
  303. this.conditions.goafOreheight = ''
  304. this.conditions.goafName = ''
  305. this.conditions.goafId = ''
  306. } else if (type === 3) {
  307. goafNames = goafs.filter(item => (item.goafOreheight === this.conditions.goafOreheight) && (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  308. this.goafNames = goafNames
  309. this.conditions.goafName = ''
  310. this.conditions.goafId = ''
  311. } else {
  312. for (let i = 0; i < goafNames.length; i++) {
  313. if (this.conditions.goafId === goafNames[i].goafId) {
  314. this.conditions.goafName = goafNames[i].goafName
  315. }
  316. }
  317. }
  318. this.$forceUpdate()
  319. },
  320. unique(arr = [], name = 'name') {
  321. const res = new Map()
  322. return arr.filter((item) => !res.has(item[name]) && res.set(item[name], 1))
  323. },
  324. deeepClone(params) {
  325. return JSON.parse(JSON.stringify(params))
  326. }
  327. }
  328. }
  329. </script>
  330. <style lang="scss" scoped>
  331. .sensor-page{
  332. .search-item{
  333. display: flex;
  334. justify-content: center;
  335. align-items: center;
  336. margin-bottom: 14px;
  337. span{
  338. font-family: 'Ping Hei';
  339. font-size: 14px;
  340. line-height: 1;
  341. color: rgba(255, 255, 255, 0.7);
  342. }
  343. }
  344. .input,.select,.el-date-editor{
  345. width: 180px;
  346. margin-right:16px;
  347. color: #fff;
  348. }
  349. ::v-deep{
  350. .el-input__wrapper{
  351. background-color: rgba(8, 128, 255, 0.2);
  352. border: 0;
  353. box-shadow: none;
  354. }
  355. .el-input__inner{
  356. color: #fff;
  357. }
  358. }
  359. header{
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. padding-top: 0.5vh;
  364. .item{
  365. width: 188px;
  366. height: 36px;
  367. line-height: 36px;
  368. text-align: center;
  369. background-image: url(@/assets/sensor/head.png);
  370. background-size: 100% 100%;
  371. background-repeat: no-repeat;
  372. margin-right: 12px;
  373. max-width: 20%;
  374. color: #7FCFF4;
  375. cursor: pointer;
  376. &.active{
  377. background-image: url(@/assets/sensor/head_active.png);
  378. color: #2AFFFF;
  379. }
  380. }
  381. }
  382. .tab{
  383. padding-top: 1.5vh;
  384. .item{
  385. display: inline-block;
  386. padding: 5px 10px;
  387. color: #fff;
  388. font-size: 16px;
  389. background: #003B7A;
  390. border: 1px solid #004EA2;
  391. letter-spacing: 0.6px;
  392. margin-right: 24px;
  393. border-radius: 4px 15px 8px 4px;
  394. cursor: pointer;
  395. &.active{
  396. background: #0083CF;
  397. border: 1px solid #0097DD;
  398. }
  399. }
  400. }
  401. .container{
  402. display: flex;
  403. .lf{
  404. width: 60%;
  405. padding-left: 100px;
  406. .search-container{
  407. padding:4.4vh 0 5vh 0;
  408. box-sizing: border-box;
  409. display: flex;
  410. flex-wrap: wrap;
  411. .bt{
  412. width: 100px;
  413. height: 36px;
  414. line-height: 36px;
  415. text-align: center;
  416. color: #fff;
  417. font-size: 14px;
  418. background: rgba(8, 128, 255, 0.2);
  419. border-radius: 4px;
  420. margin-top: 14px;
  421. cursor: pointer;
  422. margin-top: 0;
  423. &.search{
  424. background: linear-gradient(rgba(94, 226, 255, 1),rgba(79, 175, 255, 1));
  425. margin:0 10px 0 0;
  426. }
  427. }
  428. }
  429. .lf-container{
  430. .card-container{
  431. display: flex;
  432. justify-content: flex-start;
  433. flex-wrap: wrap;
  434. padding-left: 50px;
  435. .card{
  436. width: 22%;
  437. height: 25vh;
  438. background: rgba(35, 229, 254, 0.06);
  439. border: 1px solid #115C7C;
  440. margin:0 4% 10px 0;
  441. box-sizing: border-box;
  442. overflow: hidden;
  443. padding: 14px;
  444. color: #fff;
  445. position: relative;
  446. &:nth-child(4n){
  447. margin-right: 0;
  448. }
  449. .title{
  450. font-size: 18px;
  451. font-weight: bold;
  452. padding-bottom: 12px;
  453. text-align: center;
  454. }
  455. .info{
  456. font-size: 14px;
  457. p{
  458. line-height: 22px;
  459. word-break: break-all;
  460. }
  461. }
  462. footer{
  463. width: 100%;
  464. height: 36px;
  465. line-height: 36px;
  466. position: absolute;
  467. bottom: 0;
  468. left: 0;
  469. text-align: center;
  470. background: #0C6ECF;
  471. &.status-1{
  472. background: #DCBA3D;
  473. }
  474. &.status-2{
  475. background: #EC6B1D;
  476. }
  477. &.status-3{
  478. background: #F33737;
  479. }
  480. }
  481. }
  482. }
  483. .el-pagination-wrap{
  484. float: right;
  485. margin-top: 5vh;
  486. ::v-deep{
  487. .el-pager li,button{
  488. background-color: #00539F;
  489. margin-left: 10px;
  490. color: rgba(255, 255, 255, 0.75);
  491. &.is-active{
  492. background-color: rgba(0, 131, 207, 1);
  493. }
  494. }
  495. }
  496. }
  497. }
  498. }
  499. .rt{
  500. flex: 1;
  501. padding-left: 5%;
  502. box-sizing: border-box;
  503. .head{
  504. height: 32px;
  505. background-image: url(@/views/home/images/home/title.png);
  506. background-size: 100% 100%;
  507. background-repeat: no-repeat;
  508. color: #2affff;
  509. font-size: 20px;
  510. display: flex;
  511. justify-content: space-between;
  512. align-items: center;
  513. text-indent: 24px;
  514. padding: 0 14px;
  515. font-family: "YouSheBiaoTiHei";
  516. letter-spacing: 1px;
  517. margin-top: 4.8vh;
  518. }
  519. .head-info{
  520. display: flex;
  521. justify-content: center;
  522. align-items: center;
  523. padding-top: 20px;
  524. .item{
  525. width: 33.33%;
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. flex-direction: column;
  530. color: #fff;
  531. font-size: 12px;
  532. &.total{
  533. display: block;
  534. font-weight: bold;
  535. text-align: left;
  536. .name{
  537. font-size: 14px;
  538. line-height: 20px;
  539. }
  540. .number{
  541. font-size: 20px;
  542. line-height: 38px;
  543. font-weight: 700;
  544. background: rgba(108, 128, 151, 0.1)
  545. }
  546. }
  547. &.normal{
  548. border-left:1px solid rgba(255, 255, 255, 0.12);
  549. border-right:1px solid rgba(255, 255, 255, 0.12);
  550. margin: 0 2%;
  551. height: 100%;
  552. .number{
  553. font-size: 20px;
  554. line-height: 28px;
  555. color: #3CD495;
  556. font-weight: 500;
  557. }
  558. }
  559. &.error{
  560. .number{
  561. font-size: 20px;
  562. line-height: 28px;
  563. color: #D4603C;
  564. font-weight: 500;
  565. }
  566. }
  567. }
  568. }
  569. .chart-wrap{
  570. padding-top: 0.8vh;
  571. .title{
  572. color: #fff;
  573. font-size: 18px;
  574. line-height: 20px;
  575. padding: 10px;
  576. position: relative;
  577. font-family: "YouSheBiaoTiHei";
  578. letter-spacing: 1px;
  579. margin-bottom: 2vh;
  580. &::after{
  581. display: block;
  582. content: "";
  583. width: 100%;
  584. height: 3px;
  585. position: absolute;
  586. bottom: 0;
  587. left: 0;
  588. background-image: url('./images/line.png');
  589. background-repeat: no-repeat;
  590. background-size: 100% 100%;
  591. }
  592. }
  593. }
  594. }
  595. }
  596. }
  597. </style>