equip-detail-new.vue 18 KB

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