equip-detail-new.vue 15 KB

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