details.vue 15 KB

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