equip-detail-new.vue 13 KB

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