history.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="search-bar">
  3. <!-- <div v-for="device in devices"
  4. class="bo">
  5. <div class="bo-top">
  6. <div class="top-co1">
  7. <img src="../assets/images/on.png"
  8. width="20"
  9. v-if="device.DState == 1">
  10. <img src="../assets/images/off.png"
  11. width="20"
  12. v-else>
  13. </div>
  14. <div class="top-co2">
  15. <div class="row">
  16. <span class="t-font power ">操作人: {{device.SendTo}}</span>
  17. </div>
  18. <div class="row">
  19. <span class="t-font power">操作时间: {{jstimehandl(device.CreateOn)}}</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div> -->
  24. <el-table ref="singleTable"
  25. :data="devices"
  26. highlight-current-row
  27. width="100%">
  28. <el-table-column type="index"
  29. width="36">
  30. </el-table-column>
  31. <el-table-column property="SendTo"
  32. label="开锁人"
  33. align="center">
  34. </el-table-column>
  35. <el-table-column property="CreateOn"
  36. label="开锁时间"
  37. width="160"
  38. align="center">
  39. <template scope="scope">
  40. {{jstimehandl(scope.row.CreateOn)}}
  41. </template>
  42. </el-table-column>
  43. <el-table-column property="IsSend"
  44. label="开锁状态"
  45. align="center">
  46. <template scope="scope">
  47. <el-tag size="mini"
  48. type="success">{{'成功'}}</el-tag>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <el-pagination small
  53. @size-change="handleSizeChange"
  54. @current-change="handleCurrentChange"
  55. :current-page.sync="currentPage"
  56. :page-size="size"
  57. layout="total, prev, pager, next"
  58. :total="currentItemCount">
  59. </el-pagination>
  60. </div>
  61. </template>
  62. <script>
  63. import {
  64. Tab,
  65. TabItem,
  66. Loading,
  67. Datetime,
  68. Box,
  69. XButton,
  70. Popup,
  71. Group,
  72. Cell
  73. } from 'vux'
  74. import axios from 'axios'
  75. import DataChart from '../components/datachart.vue'
  76. // import moment from 'moment'
  77. export default {
  78. name: 'devicedetail',
  79. components: {
  80. Tab,
  81. TabItem,
  82. Loading,
  83. Datetime,
  84. Box,
  85. XButton,
  86. Popup,
  87. Group,
  88. Cell,
  89. DataChart
  90. },
  91. data () {
  92. return {
  93. isLoading: false,
  94. loadingText: '',
  95. devices: [],
  96. currentItemCount: 0,
  97. currentPage: 1,
  98. size: 20,
  99. cid: ''
  100. }
  101. },
  102. created () {
  103. let routeparams = this.$route.params.cid.split('_')
  104. this.cid = routeparams[0]
  105. this.initData(this.cid)
  106. // this.dataItem = routeparams[1]
  107. // this.cname = routeparams[2]
  108. // if (this.contains(this.items1, this.dataItem)) {
  109. // this.seriesData = [{name: '温度', unit: '℃'}, {name: '湿度', unit: '%'}]
  110. // } else if (this.contains(this.items2, this.dataItem)) {
  111. // this.seriesData = [{name: '温度', unit: '℃'}]
  112. // } else if (this.contains(this.itemo2Alone, this.dataItem)) {
  113. // this.seriesData = [{name: '氧气', unit: '%'}]
  114. // } else if (this.contains(this.itemo2, this.dataItem)) {
  115. // this.seriesData = [{name: '温度', unit: '℃'}, {name: '湿度', unit: '%'}, {name: '氧气', unit: '%'}]
  116. // } else if (this.contains(this.itemco2, this.dataItem)) {
  117. // this.seriesData = [{name: '温度', unit: '℃'}, {name: '湿度', unit: '%'}, {name: '二氧化碳', unit: '%'}]
  118. // } else if (this.contains(this.itemco2Alone, this.dataItem)) {
  119. // this.seriesData = [{name: '二氧化碳', unit: '%'}]
  120. // } else if (this.contains(this.itempower, this.dataItem)) {
  121. // this.seriesData = [{name: '功率', unit: 'W'}, {name: '电量', unit: 'V'}]
  122. // }
  123. // this.$services.channel.get('datavalue/' + this.cid, null)
  124. // .then(res => {
  125. // this.lastdata = res.data
  126. // this.lasttimeutc = this.getDate(this.lastdata.Time).getTime() / 1000 + ''
  127. // this.getChartData()
  128. // })
  129. },
  130. methods: {
  131. initData (code) {
  132. let _this = this
  133. // request
  134. axios.request({
  135. method: 'get',
  136. url: 'http://iot.labsop.cn:12001/api/remote_control/gettriggerhistory?current=' + this.currentPage + '&size=' + this.size + '&code=' + code
  137. }).then(res => {
  138. _this.devices = res.data.data.records
  139. _this.currentItemCount = res.data.data.total
  140. }).catch(error => {
  141. console.log(error)
  142. })
  143. },
  144. jstimehandl (val) {
  145. val = val.replace('T', ' ')
  146. return val.substring(0, 19)
  147. },
  148. handleSizeChange (value) {
  149. this.size = value
  150. this.currentPage = 1
  151. this.initData(this.cid)
  152. },
  153. handleCurrentChange (value) {
  154. this.currentPage = value
  155. this.initData(this.cid)
  156. },
  157. formatLongString (str, len) {
  158. return str.length > len ? str.substring(0, len) + '...' : str;
  159. }
  160. }
  161. }
  162. </script>
  163. <style type="text/css">
  164. html,
  165. body {
  166. background-color: #eeeeee;
  167. color: #424242;
  168. }
  169. .loadmore {
  170. text-align: center;
  171. padding: 10px;
  172. color: #9e9e9e;
  173. }
  174. .search-bar {
  175. border-bottom: 1px solid #e0e0e0;
  176. background-color: #f5f5f5;
  177. display: block;
  178. padding: 10px;
  179. }
  180. .search-input {
  181. padding: 4px 0;
  182. border-radius: 6px;
  183. background-color: white;
  184. height: 10px;
  185. }
  186. .bo {
  187. background-color: white;
  188. margin: 10px;
  189. border-radius: 2px;
  190. -webkit-box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.4);
  191. -moz-box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.4);
  192. box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.4);
  193. }
  194. .bo-top {
  195. padding: 10px;
  196. border-bottom: 1px solid #f5f5f5;
  197. border-top-left-radius: 2px;
  198. border-top-right-radius: 2px;
  199. }
  200. .top-co1 {
  201. width: 10%;
  202. display: table-cell;
  203. vertical-align: middle;
  204. }
  205. .top-co2 {
  206. width: 90%;
  207. display: table-cell;
  208. vertical-align: middle;
  209. }
  210. .top-co3 {
  211. width: 10%;
  212. display: table-cell;
  213. vertical-align: middle;
  214. }
  215. .top-co3 img {
  216. display: block;
  217. }
  218. .bo-bottom {
  219. text-align: left;
  220. padding: 10px;
  221. border-bottom-left-radius: 2px;
  222. border-bottom-right-radius: 2px;
  223. }
  224. .bo-cell {
  225. text-align: center;
  226. border-right: 1px solid #f5f5f5;
  227. display: inline-block;
  228. width: 32%;
  229. }
  230. .bo-cell:last-child {
  231. border: none;
  232. }
  233. .t-time {
  234. font-size: 14px;
  235. font-weight: light;
  236. color: #9e9e9e;
  237. }
  238. .t-font {
  239. display: block;
  240. font-size: 14px;
  241. font-weight: lighter;
  242. font-family: "Oswald";
  243. }
  244. .temperature {
  245. color: #ef5350;
  246. }
  247. .el-pagination {
  248. margin: 1rem 0 2rem;
  249. text-align: right;
  250. }
  251. .humidity {
  252. color: #29b6f6;
  253. }
  254. .co2 {
  255. color: #ffa726;
  256. }
  257. .o2 {
  258. color: #673ab7;
  259. }
  260. .power {
  261. color: #4caf50;
  262. }
  263. .t-desc {
  264. display: block;
  265. font-size: 11px;
  266. color: #9e9e9e;
  267. }
  268. .t-desc > img {
  269. margin-left: 4px;
  270. }
  271. .t-dot {
  272. color: #f44336;
  273. }
  274. .row {
  275. display: inline-block;
  276. width: 100%;
  277. height: 24px;
  278. line-height: 24px;
  279. }
  280. .row img {
  281. margin-top: 2px;
  282. margin-right: 4px;
  283. float: left;
  284. }
  285. .status-box {
  286. display: block;
  287. width: 16px;
  288. height: 16px;
  289. border-radius: 8px;
  290. margin-right: 8px;
  291. }
  292. .right-align {
  293. text-align: right;
  294. }
  295. </style>