details.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <view>
  3. <view class="title">基本信息</view>
  4. <view class="info">
  5. <view class="device-id" @click="copy(equipInfo)">
  6. <image class="logo" :src="`http://www.hnyfwlw.com:8006/bigdata_pc/equipdistribute/${equipInfo.type}.png`" mode=""></image>
  7. {{equipInfo.imei||equipInfo.device_id}}
  8. <image src="https://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode="" class="tishi">
  9. </image>
  10. <view :class="['float-right','yficonfont',equipInfo.is_online==1?'on icon-zaixian':'off icon-lixian']">
  11. {{equipInfo.is_online==1?'在线':'离线'}}
  12. </view>
  13. </view>
  14. <view class="info-list">
  15. <span class="float-left">设备名称:</span> <span class="float-right">{{equipInfo.device_name}}</span>
  16. </view>
  17. <view class="info-list" v-if="equipInfo.type==32">
  18. <span class="float-left">诱虫量:</span> <span class="float-right">{{equipInfo.bug_count?equipInfo.bug_count.join('/'):'0/0/0'}}</span>
  19. </view>
  20. <view class="info-list">
  21. <span class="float-left">最新上报时间:</span> <span class="float-right">{{equipInfo.addtime||equipInfo.uptime | timeFormat}}</span>
  22. </view>
  23. <view class="info-list">
  24. <span class="float-left">设备地址:</span> <span class="float-right">{{equipInfo.address?equipInfo.address:"--"}}</span>
  25. </view>
  26. <view class="info-list" v-if="equipInfo.type==34" @click="operate('jd')">
  27. <span class="float-left">卷带到期时间</span>
  28. <span> </span>
  29. <span class="float-right">
  30. <span v-if="equipInfo.jd_expire_time>0">
  31. {{ equipInfo.jd_expire_time | timeFormat}}
  32. </span>
  33. <span v-else> 暂未设置卷带 </span>
  34. <u-icon class="arrow" name="arrow-right" color="#666666" size="26"></u-icon>
  35. </span>
  36. </view>
  37. <u-calendar v-model="calendar_show" mode="date" :max-date="date" @change="timeChange($event)">
  38. </u-calendar>
  39. <u-toast ref="toast" />
  40. </view>
  41. <view class="title">基本操作</view>
  42. <view class="newState" >
  43. <view class="item" v-for="item in curEquip" @click="partClick(item.path)">
  44. <view class="item_info_img">
  45. <image :src="'https://www.hnyfwlw.com:8006/bigdata_app'+item.icon" mode="widthFix"></image>
  46. </view>
  47. <view class="info-text">
  48. {{item.tex}}
  49. </view>
  50. </view>
  51. </view>
  52. <view class="title">实时状态</view>
  53. <view class="newtishi" v-if="dataloadingtf">
  54. <p class="dataloading">加载中</p>
  55. </view>
  56. <view class="newtishi" v-else-if="newtishitf">
  57. 暂无数据
  58. </view>
  59. <view class="newState" v-else>
  60. <view class="item" v-for="item in curState">
  61. <view class="item_info_img">
  62. <image :src="'https://www.hnyfwlw.com:8006/bigdata_app'+item.icon" mode="widthFix"></image>
  63. </view>
  64. <view class="info-con">
  65. <view class="active">
  66. {{item.value | formatValue(item.txt,type)}}
  67. </view>
  68. <view class="val">
  69. {{item.txt}}
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import equipState from "../../static/js/equipState_dict.json"
  78. import {
  79. QueryPermission,getPermissionById,getUserPermission
  80. } from "../../util/QueryPermission.js"
  81. export default {
  82. data() {
  83. return {
  84. fieldstyle: {
  85. border: "2rpx solid #f6f6f6",
  86. "border-radius": "24px",
  87. "padding-left": "20rpx",
  88. "background-color": "#f6f6f6"
  89. },
  90. city: "",
  91. type: null, //设备类型
  92. device_status: null,
  93. equipInfo: {},
  94. cbd: [
  95. ],
  96. newState: {}, //设备最新状态
  97. setTimeShow: false,
  98. calendar_show: false,
  99. culErr: '',
  100. decoy: '',
  101. newtishitf: false, //暂无数据提示
  102. dataloadingtf: true, //加载中提示
  103. date: "", //日历最大可选日期
  104. operateType:''
  105. }
  106. },
  107. computed: {
  108. curEquip(){
  109. this.cbd = [{
  110. icon: '/image/cb/4.png',
  111. tex: '设备控制',
  112. path: '/pages/cb/cbd/equip-set/equip-set-new',
  113. tf: true
  114. }, {
  115. icon: '/image/cb/6.png',
  116. tex: 'sim卡详情',
  117. path: '/pages/prevention/sim',
  118. tf: true
  119. }, {
  120. icon: '/image/environment/7.png',
  121. tex: '一键报修',
  122. path: '/pages/afterSale/addafter',
  123. tf: true
  124. }]
  125. let permission = getPermissionById(getUserPermission(),this.equipInfo.pur_id)
  126. permission.forEach(item=>{
  127. if(item.purview_name =='查看图片'){
  128. this.cbd.unshift({
  129. icon: '/image/cb/1.png',
  130. tex: item.purview_name,
  131. path: '/pages/cb/cbd/equip-set/photo',
  132. tf: true
  133. })
  134. }else if(item.purview_name =='数据详情'){
  135. this.cbd.unshift({
  136. icon: '/image/cb/2.png',
  137. tex: item.purview_name,
  138. path: '/pages/cb/cbd/equip-set/newhistoryfile',
  139. tf: true
  140. })
  141. }else if(item.purview_name =='分析'){
  142. this.cbd.unshift({
  143. icon: '/image/cb/3.png',
  144. tex: item.purview_name,
  145. path: '/pages/cb/cbd/equip-set/new-analyse',
  146. tf: true
  147. })
  148. }
  149. })
  150. return this.cbd
  151. },
  152. curState() {
  153. return [{
  154. icon: '/image/cb/icon02.png',
  155. txt: '在线状态',
  156. value: this.newState.status,
  157. },
  158. {
  159. icon: '/image/cb/icon05.png',
  160. txt: '开关状态',
  161. value: Number(this.newState.ds) == 1 ? '开机' : '关机'
  162. },
  163. {
  164. icon: '/image/cb/icon08.png',
  165. txt: '环境温度(℃)',
  166. value: this.newState.tem
  167. }, {
  168. icon: '/image/cb/icon07.png',
  169. txt: '环境湿度(%)',
  170. value: this.newState.hum
  171. }, {
  172. icon: '/image/prevention/icon16.png',
  173. txt: '信号强度',
  174. value: this.newState.signal
  175. }, {
  176. icon: '/image/cb/icon12.png',
  177. txt: '设备版本',
  178. value: this.newState.dver_num
  179. },
  180. {
  181. icon: '/image/cb/icon17.png',
  182. txt: '雨控状态',
  183. value: this.newState.rps
  184. }, {
  185. icon: '/image/cb/icon14.png',
  186. txt: '温控状态',
  187. value: this.newState.tps
  188. }, {
  189. icon: '/image/cb/icon06.png',
  190. txt: '光控状态',
  191. value: this.newState.lps
  192. }, {
  193. icon: '/image/cb/icon18.png',
  194. txt: '控制模式',
  195. value: this.newState.control
  196. }
  197. ]
  198. },
  199. operateOptions(){
  200. return{
  201. yx:{
  202. title:'诱芯',
  203. url:'/api/api_gateway?method=new_gateway.device_info.youxin',
  204. field:'xy_expire_time'
  205. },
  206. sb:{
  207. title:'色板',
  208. url:'/api/api_gateway?method=new_gateway.device_info.sban',
  209. field:'sban_expire_time'
  210. },
  211. jd:{
  212. title:'卷带',
  213. url:'/api/api_gateway?method=new_gateway.device_info.syone_jd',
  214. field:'jd_expire_time'
  215. }
  216. }
  217. }
  218. },
  219. filters: {
  220. equipType(type) {
  221. switch (type) {
  222. case 3:
  223. return "虫情测报灯";
  224. case 7:
  225. return "孢子仪";
  226. case 4:
  227. return "性诱测报"
  228. }
  229. },
  230. formatValue(val, a1, a2) {
  231. if (a2 == 4 && a1 == "电池状态") {
  232. switch (Number(val)) {
  233. case 0:
  234. return '正常';
  235. break;
  236. case 1:
  237. return '欠压';
  238. break;
  239. case 2:
  240. return '过压';
  241. break;
  242. }
  243. } else {
  244. return val ? val : '无'
  245. }
  246. }
  247. },
  248. onLoad(option) {
  249. this.equipInfo = JSON.parse(option.info)
  250. this.getDeviceStatus()
  251. this.type = Number(this.equipInfo.type) || Number(this.equipInfo.equip_type) || Number(this.equipInfo
  252. .device_type_id)
  253. this.equipInfo.type = this.type
  254. this.device_status = this.equipInfo.is_online
  255. this.getState()
  256. // this.selectaddress(Number(this.equipInfo.lat), Number(this.equipInfo.lng))
  257. var times = new Date()
  258. this.date = times.getFullYear() + 1 + "-" + Number(times.getMonth() + 1) + "-" + times.getDate()
  259. },
  260. methods: {
  261. async getDeviceStatus() {
  262. const res = await this.$myRequest({
  263. url: '/api/api_gateway?method=new_gateway.device_info.devices_list',
  264. data: {
  265. device_type_id: this.equipInfo.type,
  266. id: this.equipInfo.imei|| this.equipInfo.device_id,
  267. page:1,
  268. size:999
  269. }
  270. })
  271. let newRes = res.device[0]
  272. this.equipInfo ={...this.equipInfo,...newRes}
  273. console.log('响应',this.equipInfo)
  274. },
  275. async getState() {
  276. this.dataloadingtf = true
  277. const res = await this.$myRequest({
  278. url: '/api/api_gateway?method=new_gateway.device_info.device_status',
  279. data: {
  280. device_type_id: this.equipInfo.type,
  281. id: this.equipInfo.d_id
  282. }
  283. })
  284. this.newState = res
  285. this.dataloadingtf = false
  286. console.log('res',res)
  287. },
  288. partClick(path) {
  289. console.log(path)
  290. var device_id = this.equipInfo.device_id || this.equipInfo.imei
  291. uni.navigateTo({
  292. url: path + '?d_id=' + this.equipInfo.d_id + "&device_id=" + device_id + "&device_type=" + this
  293. .type
  294. });
  295. },
  296. operate(type){
  297. this.calendar_show = true
  298. this.operateType = type
  299. },
  300. timeChange(e, filed) {
  301. // // 根据type_id,执行相应的操作
  302. // let typeId = this.equipInfo.type
  303. // let postData = {}
  304. // if(typeId===32){
  305. // // 添加诱芯
  306. // }else if(typeId === 33){
  307. // // 添加诱芯,更换色板
  308. // this.sbSubmit(e.result)
  309. // }else if(typeId === 34){
  310. // // 添加诱芯,更换卷带
  311. // this.jdSubmit(e.result)
  312. // }
  313. this.yxSubmit(e.result)
  314. },
  315. async yxSubmit(time) {
  316. let {title,url,field} = this.operateOptions[this.operateType]
  317. if (!time) {
  318. this.$refs.toast.show({
  319. title: '请填写'+title+'到期时间!',
  320. type: 'warning',
  321. })
  322. return false
  323. }
  324. let postData = {
  325. device_type_id: this.equipInfo.type,
  326. id: this.equipInfo.device_id
  327. }
  328. postData[field] = +new Date(time) / 1000
  329. const res = await this.$myRequest({
  330. url: url,
  331. data: postData
  332. })
  333. if (res) {
  334. this.$refs.toast.show({
  335. title: title+'时间设置成功!',
  336. type: 'success',
  337. })
  338. this.getDeviceStatus()
  339. }
  340. },
  341. // 色板
  342. async sbSubmit(time) {
  343. if (!time) {
  344. this.$refs.toast.show({
  345. title: '请填写色板到期时间!',
  346. type: 'warning',
  347. })
  348. return false
  349. }
  350. const res = await this.$myRequest({
  351. url: '/api/api_gateway?method=new_gateway.device_info.sban',
  352. data: {
  353. device_type_id: this.equipInfo.type,
  354. id: this.equipInfo.device_id,
  355. sban_expire_time: +new Date(time) / 1000
  356. }
  357. })
  358. if (res) {
  359. this.$refs.toast.show({
  360. title: '设置成功!',
  361. type: 'success',
  362. })
  363. this.getDeviceStatus()
  364. }
  365. },
  366. async jdSubmit(time) {
  367. if (!time) {
  368. this.$refs.toast.show({
  369. title: '请填写卷带到期时间!',
  370. type: 'warning',
  371. })
  372. return false
  373. }
  374. const res = await this.$myRequest({
  375. url: '/api/api_gateway?method=new_gateway.device_info.syone_jd',
  376. data: {
  377. device_type_id: this.equipInfo.type,
  378. id: this.equipInfo.device_id,
  379. jd_expire_time: +new Date(time) / 1000
  380. }
  381. })
  382. if (res) {
  383. this.$refs.toast.show({
  384. title: '设置成功!',
  385. type: 'success',
  386. })
  387. this.getDeviceStatus()
  388. }
  389. },
  390. selectaddress(lat, lng) { //获取分布位置
  391. uni.request({
  392. type: "GET",
  393. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  394. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  395. dataType: "json",
  396. complete: res => {
  397. console.log(res)
  398. this.city = res.data.regeocode.formatted_address
  399. }
  400. });
  401. },
  402. copy(item) {
  403. console.log(item)
  404. uni.setClipboardData({
  405. data: item.imei || item.device_id,
  406. success: function() {
  407. console.log('success');
  408. }
  409. });
  410. }
  411. },
  412. }
  413. </script>
  414. <style lang='scss'>
  415. page {
  416. padding: 0rpx 48rpx;
  417. box-sizing: border-box;
  418. background: #F7F7F7;
  419. .title{
  420. color: #999999;
  421. margin: 32rpx 0;
  422. }
  423. .logo{
  424. width: 36rpx;
  425. height: 36rpx;
  426. margin-right: 12rpx;
  427. position: relative;
  428. top: 8rpx;
  429. }
  430. .device-id{
  431. height: 60rpx;
  432. line-height: 60rpx;
  433. margin-bottom: 18rpx;
  434. color: #5C5C5C;
  435. .float-right{
  436. float: right;
  437. width: 88px;
  438. height: 30px;
  439. text-align: center;
  440. position: absolute;
  441. top: 0;
  442. right: 0;
  443. border-top-right-radius: 24rpx;
  444. }
  445. }
  446. .on {
  447. background-image: url('/static/images/cb/online.png');
  448. color: #fff;
  449. }
  450. .off {
  451. background-image: url('/static/images/cb/outline.png');
  452. color: #999999;
  453. }
  454. .info {
  455. position: relative;
  456. padding: 8rpx 32rpx 32rpx 32rpx;
  457. line-height: 50rpx;
  458. font-size: 26rpx;
  459. border-radius: 24rpx;
  460. background-color: #fff;
  461. box-sizing: border-box;
  462. width: 100%;
  463. .info-list{
  464. overflow: hidden;
  465. font-size: 12px;
  466. .float-right{
  467. float: right;
  468. color: #666;
  469. .arrow{
  470. margin-left: 10rpx;
  471. }
  472. }
  473. .float-left{
  474. float: left;
  475. color: #999;
  476. }
  477. }
  478. .tishi {
  479. width: 28rpx;
  480. height: 28rpx;
  481. margin: 0rpx 0 0 12rpx;
  482. position: relative;
  483. top: 6rpx;
  484. }
  485. }
  486. .tit {
  487. font-weight: 800;
  488. height: 50rpx;
  489. font-size: 30rpx;
  490. margin-bottom: 20rpx;
  491. display: flex;
  492. justify-content: space-between;
  493. .span {
  494. color: #6e6c76;
  495. font-size: 24rpx;
  496. display: flex;
  497. justify-content: space-between;
  498. /* margin-top: 12rpx; */
  499. }
  500. }
  501. .newtishi {
  502. width: 90%;
  503. margin: 0 auto;
  504. text-align: center;
  505. padding-top: 40rpx;
  506. font-size: 32rpx;
  507. .dataloading:after {
  508. overflow: hidden;
  509. display: inline-block;
  510. vertical-align: bottom;
  511. animation: ellipsis 2s infinite;
  512. content: "\2026";
  513. }
  514. @keyframes ellipsis {
  515. from {
  516. width: 2px;
  517. }
  518. to {
  519. width: 15px;
  520. }
  521. }
  522. }
  523. .newState {
  524. display: flex;
  525. flex-wrap: wrap;
  526. text-align: center;
  527. margin: 0 -10rpx;
  528. .item {
  529. display: flex;
  530. flex-wrap: nowrap;
  531. margin: 10rpx;
  532. width: 316rpx;
  533. justify-content: flex-start;
  534. padding: 20rpx 10rpx;
  535. box-sizing: border-box;
  536. border-radius: 4px;
  537. background-color: #fff;
  538. font-size: 24rpx;
  539. .info-text{
  540. line-height: 76rpx;
  541. padding-left: 30rpx;
  542. font-size: 14px;
  543. color: #666666;
  544. }
  545. .info-con {
  546. padding-left: 30rpx;
  547. text-align: left;
  548. line-height: 40rpx;
  549. color: #666666;
  550. .active{
  551. font-size: 36rpx;
  552. }
  553. .val{
  554. font-size: 24rpx;
  555. }
  556. }
  557. .item_info_img {
  558. width: 30%;
  559. text-align: center;
  560. image {
  561. width: 64rpx;
  562. height: 64rpx;
  563. margin-top: 10rpx;
  564. }
  565. }
  566. }
  567. }
  568. .btn-box {
  569. text-align: center;
  570. padding: 30rpx;
  571. }
  572. .field {
  573. /deep/.uni-input-input {
  574. border: 2rpx solid #FF0000;
  575. border-radius: 24rpx;
  576. width: 140px;
  577. padding-left: 10rpx;
  578. box-sizing: border-box;
  579. }
  580. }
  581. }
  582. /deep/.u-calendar__action {
  583. display: flex;
  584. justify-content: space-around;
  585. .u-calendar__action__text {
  586. line-height: 25px;
  587. }
  588. }
  589. .red {
  590. color: rgb(235, 103, 101);
  591. }
  592. </style>