AI销管
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

490 lines
12 KiB

  1. <template>
  2. <view class="cented">
  3. <view class="header">
  4. <view style="width: 690rpx;margin: 0 auto;margin-top: 20rpx;">
  5. <u-search @search='shecs()' :show-action='false' placeholder="请输入设备编号或领用人进行搜索" v-model="imei">
  6. </u-search>
  7. </view>
  8. <view class="tab-box">
  9. <u-tabs-swiper ref="tabs" font-size="30" :bold="true" swiper-width="700" :current="activeClass"
  10. @change="clocktab()" inactive-color="#b1b1b1" active-color="#008ef2" :list="tablist"
  11. :is-scroll="true">
  12. </u-tabs-swiper>
  13. </view>
  14. </view>
  15. <view class="infoet">
  16. <view class="infoviewbox" v-for="(item,index) in newListdata" :key="index">
  17. <view class="infobox1">
  18. <view class="box1-zuo">领用人:{{item.accName || '--'}}</view>
  19. <view class="box1-you">
  20. <view class="you1" v-if="item.electricity>20">
  21. <view class="youimg" :style="{ height: item.electricity + '%' }"></view>
  22. </view>
  23. <view class="you11" v-if="item.electricity<20">
  24. <view class="youimg" :style="{ height: item.electricity + '%' }"></view>
  25. </view>
  26. <view class="you2">电量:
  27. <text v-if="item.electricity>20">{{item.electricity}}%</text>
  28. <text v-if="item.electricity<20" style="color: red;">{{item.electricity}}%</text>
  29. </view>
  30. <view class="you3">
  31. <image v-if="item.signalDevice==''" class="youimg"
  32. src="../../../static/images/newimg/xinhao0.png" mode=""></image>
  33. <image v-if="item.signalDevice<20 && item.signalDevice>0" class="youimg"
  34. src="../../../static/images/newimg/xinhao1.png" mode=""></image>
  35. <image v-if="item.signalDevice<50 && item.signalDevice>=20" class="youimg"
  36. src="../../../static/images/newimg/xinhao2.png" mode=""></image>
  37. <image v-if="item.signalDevice<70 && item.signalDevice>=50" class="youimg"
  38. src="../../../static/images/newimg/xinhao3.png" mode=""></image>
  39. <image v-if="item.signalDevice<90 && item.signalDevice>=70" class="youimg"
  40. src="../../../static/images/newimg/xinhao4.png" mode=""></image>
  41. <image v-if="item.signalDevice<=100 && item.signalDevice>=90" class="youimg"
  42. src="../../../static/images/newimg/xinhao5.png" mode=""></image>
  43. </view>
  44. <view class="you4" v-if="item.signalDevice=='' ">信号:0</view>
  45. <view class="you4" v-else>信号:{{item.signalDevice}}</view>
  46. </view>
  47. </view>
  48. <view class="infobox2">
  49. <view class="box2-zuo">设备编号</view>
  50. <view class="box2-you">{{item.imei}}</view>
  51. </view>
  52. <view class="infobox2">
  53. <view class="box2-zuo">录音状态</view>
  54. <view class="box2-you" v-if="item.audioStatus=='false'">关闭</view>
  55. <view class="box2-you" v-if="item.audioStatus=='true'">开启</view>
  56. <view class="box2-you" v-if="!item.audioStatus">关闭</view>
  57. </view>
  58. <view class="infobox2">
  59. <view class="box2-zuo">待上传</view>
  60. <template v-if="item.fileCount && item.fileCount > 0">
  61. <text class="stayupload box2-you">{{ item.fileCount }}条</text>
  62. </template>
  63. <template v-else>
  64. <text class="box2-you">0</text>
  65. </template>
  66. </view>
  67. <view class="infobox2">
  68. <view class="box2-zuo">更新时间</view>
  69. <view class="box2-you">{{item.updateTime}}</view>
  70. </view>
  71. <view class="infobox2" v-if="activeClass==1">
  72. <view class="box2-zuo">最后在线时间</view>
  73. <view class="box2-you" style="font-size: 28rpx;color: red;">{{item.updateTime | formatDate}}</view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 选择项目 -->
  78. <u-select :mask-close-able="false" label-name="propertyName" value-name="id" v-model="showTemplates"
  79. mode="single-column" :list="houseList" @cancel="showTemplates = false" @confirm="templateConfirms">
  80. </u-select>
  81. </view>
  82. </template>
  83. <script>
  84. var util = require("../../../utils/util.js");
  85. var config = require("@/config");
  86. export default {
  87. data() {
  88. return {
  89. tablist: [{
  90. name: "全部(0)",
  91. },
  92. {
  93. name: "在线(0)",
  94. },
  95. {
  96. name: "低电量(0)",
  97. },
  98. {
  99. name: "今日活跃(0)",
  100. },
  101. {
  102. name: "离线(0)",
  103. },
  104. {
  105. name: "项目",
  106. id: 5,
  107. }
  108. ],
  109. activeClass: 0,
  110. pageNum: 1,
  111. pageSize: 20,
  112. imei: "",
  113. orgcode: "",
  114. newListdata: [],
  115. buildingID: '',
  116. jump: '',
  117. houseList: [], // 项目列表
  118. showTemplates: false, // 项目列表选择框
  119. houseListId: '', // 选择的项目
  120. };
  121. },
  122. onReachBottom() {
  123. this.pageNum += 1;
  124. this.init()
  125. },
  126. onPullDownRefresh() {
  127. this.init()
  128. setTimeout(function() {
  129. uni.stopPullDownRefresh();
  130. }, 1000);
  131. },
  132. onLoad(options) {
  133. this.getHouseList()
  134. if (options.active) {
  135. this.activeClass = options.active
  136. } else {
  137. this.activeClass = 0
  138. }
  139. this.newListdata = []
  140. this.pageNum = 1;
  141. this.pageSize = 20;
  142. this.init()
  143. },
  144. methods: {
  145. // 选择楼盘
  146. templateConfirms(e) {
  147. console.log(e)
  148. let index = this.tablist.findIndex(item => item.id == 5)
  149. this.tablist[index].name = e[0].label
  150. this.houseListId = e[0].value
  151. this.pageNum = 1;
  152. this.init()
  153. this.$forceUpdate()
  154. },
  155. // 获取楼盘列表
  156. getHouseList() {
  157. uni.request({
  158. url: config.service.getUser,
  159. method: "GET",
  160. data: {},
  161. header: {
  162. 'content-type': 'application/json',
  163. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  164. },
  165. success: (res) => {
  166. this.houseList = res.data.data.houseList
  167. console.log(this.houseList)
  168. }
  169. })
  170. },
  171. shecs() {
  172. this.newListdata = []
  173. this.pageNum = 1;
  174. this.pageSize = 20;
  175. this.init()
  176. },
  177. // tab
  178. clocktab(index) {
  179. let i = this.tablist.findIndex(item => item.id == 5)
  180. if (index == i) {
  181. this.showTemplates = true
  182. } else {
  183. this.activeClass = index;
  184. this.newListdata = []
  185. this.pageNum = 1;
  186. this.pageSize = 20;
  187. this.init()
  188. }
  189. },
  190. init() {
  191. this.buildingID = uni.getStorageSync('buildingID').id;
  192. const parames = {
  193. pageNum: this.pageNum,
  194. pageSize: this.pageSize,
  195. query: {
  196. imei: this.imei,
  197. onLine: this.activeClass,
  198. propertyId: this.houseListId ? this.houseListId : this.buildingID,
  199. orderType: 1,
  200. accountId: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  201. }
  202. }
  203. if (this.activeClass == 0) {
  204. parames.query.onLine = null
  205. }
  206. this.$u.post("/equipment/apiFindByPage", parames).then(res => {
  207. this.tablist[0].name = "全部(" + res.allCount + ")";
  208. this.tablist[1].name = "在线(" + res.eqOnLineCount + ")";
  209. this.tablist[2].name = "低电量(" + res.lowElectricityCount + ")";
  210. this.tablist[3].name = "今日活跃(" + res.activeCount + ")";
  211. this.tablist[4].name = "离线(" + res.eqOffLineCount + ")";
  212. if (res.obj.list.results == null) {
  213. if (this.pageNum == 1) {
  214. return
  215. } else {
  216. uni.showToast({
  217. title: '已经到底了!',
  218. icon: 'none',
  219. duration: 2000
  220. });
  221. }
  222. } else {
  223. res.obj.list.results.forEach(item => {
  224. if (item.onLine == 0) {
  225. item.signalDevice = 0
  226. }
  227. if (item.electricity == '') {
  228. item.electricity = 0
  229. }
  230. if (item.electricity > 100) {
  231. item.electricity = 100
  232. }
  233. let num = this.ascformatDate(item.updateTime)
  234. if (num > 12) {
  235. item.electricity = 0
  236. }
  237. })
  238. if (this.pageNum == 1) {
  239. this.newListdata = res.obj.list.results
  240. } else {
  241. this.newListdata = [...this.newListdata, ...res.obj.list.results];
  242. }
  243. }
  244. })
  245. },
  246. ascformatDate(dateTimeStamp) {
  247. let newDate = new Date(dateTimeStamp.replace(/-/g, '/')).getTime();
  248. let minute = 1000 * 60;
  249. let hour = minute * 60;
  250. let day = hour * 24;
  251. let halfamonth = day * 15;
  252. let month = day * 30;
  253. let now = new Date().getTime();
  254. let diffValue = now - newDate;
  255. let result = diffValue / hour;
  256. return result;
  257. }
  258. },
  259. filters: {
  260. formatDate: (dateTimeStamp) => {
  261. var newDate = new Date(dateTimeStamp.replace(/-/g, '/')).getTime();
  262. var minute = 1000 * 60;
  263. var hour = minute * 60;
  264. var day = hour * 24;
  265. var halfamonth = day * 15;
  266. var month = day * 30;
  267. var now = new Date().getTime();
  268. var diffValue = now - newDate;
  269. if (diffValue < 0) {
  270. return;
  271. }
  272. var monthC = diffValue / month;
  273. var weekC = diffValue / (7 * day);
  274. var dayC = diffValue / day;
  275. var hourC = diffValue / hour;
  276. var minC = diffValue / minute;
  277. var result = '';
  278. if (weekC >= 1) {
  279. result = "1周前";
  280. } else if (dayC >= 1) {
  281. result = "" + parseInt(dayC) + "天前";
  282. } else if (hourC >= 1) {
  283. result = "" + parseInt(hourC) + "小时前";
  284. } else if (minC >= 1) {
  285. result = "" + parseInt(minC) + "分钟前";
  286. } else {
  287. result = "刚刚";
  288. }
  289. return result;
  290. }
  291. },
  292. }
  293. </script>
  294. <style lang="scss">
  295. .cented {
  296. width: 100%;
  297. min-height: 100vh;
  298. background: #FFFFFF;
  299. .header {
  300. position: sticky;
  301. top: var(--window-top);
  302. z-index: 999;
  303. }
  304. }
  305. .tab-box {
  306. width: 100%;
  307. .tab-item-wrap {
  308. height: 88rpx;
  309. line-height: 88rpx;
  310. display: flex;
  311. justify-content: space-around;
  312. font-size: 4vw;
  313. background: linear-gradient(180deg, #e5e5e5, #e5e5e5, rgba(229, 229, 229, 0)) bottom left no-repeat;
  314. background-size: 100% 1px;
  315. color: #959dad;
  316. }
  317. }
  318. .bottom {
  319. color: #209fff;
  320. position: relative;
  321. }
  322. .bottomLine {
  323. position: absolute;
  324. width: 156rpx;
  325. height: 6rpx;
  326. top: 80rpx;
  327. background-color: #298dff;
  328. border-radius: 8rpx 8rpx 0rpx 0rpx;
  329. left: 16rpx;
  330. }
  331. .infoet {
  332. width: 100%;
  333. .infoviewbox {
  334. width: 690rpx;
  335. padding-bottom: 20rpx;
  336. background: #FFFFFF;
  337. box-shadow: 0px 0px 8rpx 6rpx rgba(0, 0, 0, 0.06);
  338. border-radius: 20rpx;
  339. margin: 0 auto;
  340. margin-top: 20rpx;
  341. .infobox1 {
  342. width: 652rpx;
  343. height: 88rpx;
  344. border-bottom: 1rpx solid #D9D9D9;
  345. margin: 0 auto;
  346. display: flex;
  347. .box1-zuo {
  348. width: 50%;
  349. height: 100%;
  350. font-size: 30rpx;
  351. color: #333333;
  352. line-height: 88rpx;
  353. }
  354. .box1-you {
  355. width: 50%;
  356. height: 100%;
  357. display: flex;
  358. align-items: center;
  359. .you1 {
  360. width: 20rpx;
  361. height: 28rpx;
  362. margin-left: 32rpx;
  363. background-image: url(../../../static/images/newimg/dianliang.png);
  364. background-size: 100% 100%;
  365. display: flex;
  366. flex-direction: column-reverse;
  367. .youimg {
  368. width: 100%;
  369. background-color: #333333;
  370. }
  371. }
  372. .you11 {
  373. width: 20rpx;
  374. height: 28rpx;
  375. margin-left: 32rpx;
  376. background-image: url(../../../static/images/newimg/dianliang456.png);
  377. background-size: 100% 100%;
  378. display: flex;
  379. flex-direction: column-reverse;
  380. .youimg {
  381. width: 100%;
  382. background-color: red;
  383. }
  384. }
  385. .you2 {
  386. width: 114rpx;
  387. height: 30rpx;
  388. font-size: 20rpx;
  389. color: #333333;
  390. margin-left: 6rpx;
  391. }
  392. .you22 {
  393. width: 114rpx;
  394. height: 30rpx;
  395. font-size: 20rpx;
  396. color: red;
  397. margin-left: 6rpx;
  398. }
  399. .you3 {
  400. width: 30rpx;
  401. height: 28rpx;
  402. margin-left: 16rpx;
  403. .youimg {
  404. display: block;
  405. width: 30rpx;
  406. height: 28rpx;
  407. }
  408. }
  409. .you4 {
  410. width: 100rpx;
  411. height: 30rpx;
  412. font-size: 20rpx;
  413. color: #333333;
  414. margin-left: 6rpx;
  415. }
  416. }
  417. }
  418. .infobox2 {
  419. width: 652rpx;
  420. height: 33rpx;
  421. margin: 0 auto;
  422. display: flex;
  423. margin-top: 19rpx;
  424. .box2-zuo {
  425. width: 40%;
  426. height: 100%;
  427. line-height: 33rpx;
  428. font-size: 24rpx;
  429. color: #333333;
  430. }
  431. .box2-you {
  432. width: 60%;
  433. height: 100%;
  434. line-height: 33rpx;
  435. font-size: 24rpx;
  436. color: #333333;
  437. .stayupload {
  438. display: block;
  439. color: #F41313;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. </style>