equip-detail-new.vue 18 KB

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