details.vue 16 KB

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