device-list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="container">
  3. <div style="padding:6px 15px 0">
  4. <more title='设备列表' nomore></more>
  5. </div>
  6. <div style="margin:0px 0px 15px">
  7. <tab @click="select" :list="tabList" width="4.4rem"></tab>
  8. </div>
  9. <div v-if="$isNotEmpty(list)" class="device" v-loading="loading" style="height:100%">
  10. <div class="card" style="padding:13px 20px;" @click.stop="clickDevice(item)" v-for="(item,index) in list"
  11. :key="index">
  12. <div class="left">
  13. <div class="name text-cut">
  14. {{handelData(item).name}}
  15. </div>
  16. <div class="address text-cut" style="display:flex">
  17. <span v-if="$isEmpty(handelData(item).latitude)||$isEmpty(handelData(item).longitude)"
  18. style="color:#fa3534;margin-right:4px">
  19. [未设置坐标]</span>
  20. <img v-else src="/img/icon/location2.png"
  21. style="width:16px;height:16px;margin-right:2px;margin-top:2px"></img>
  22. {{handelData(item).address}}
  23. </div>
  24. </div>
  25. <!-- 中间菜单 -->
  26. <div class="right">
  27. <div class="status">
  28. <span :style="{color:handelData(item).statusColor}">{{handelData(item).statusName}}</span>
  29. <el-dropdown>
  30. <i class="el-icon-s-operation" style="color:#3b8ff4;margin-left:10px"></i>
  31. <el-dropdown-menu slot="dropdown">
  32. <el-dropdown-item @click.native="dropdownClick(item,item1)" v-for="(item1,index1) in operationList"
  33. :key="index1" :icon="item1.icon">
  34. {{item1.name}}
  35. </el-dropdown-item>
  36. </el-dropdown-menu>
  37. </el-dropdown>
  38. </div>
  39. <div class="time">
  40. {{item.createTime | formatDate}}
  41. </div>
  42. </div>
  43. </div>
  44. <div class="pagination" v-if="page.pages!=1&&page.pages!=0" style="display:flex;justify-content: flex-end">
  45. <el-pagination @current-change="currentChange" small background :page-count="page.pages"
  46. layout="prev, pager, next">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. <avue-empty v-else style="margin-top: 150px;"></avue-empty>
  51. </div>
  52. </template>
  53. <script>
  54. import dateTime from "@/util/dateTime.js"
  55. import tab from "@/components/tab.vue"
  56. import more from "@/components/more.vue"
  57. import {
  58. getList as getDoorDeviceList
  59. } from "@/api/device/doordevice.js"
  60. import {
  61. getList as getVideoDeviceList
  62. } from "@/api/device/gb/gbdevicechannel.js"
  63. export default {
  64. components: {
  65. tab,
  66. more
  67. },
  68. data() {
  69. return {
  70. loading: false,
  71. page: {
  72. current: 1,
  73. size: 10,
  74. pages: 0
  75. },
  76. activeIndex: 0,
  77. list: [],
  78. tabList: [{
  79. label: "门禁设备",
  80. value: 0
  81. },
  82. {
  83. label: "监控设备",
  84. value: 1
  85. }
  86. ],
  87. operationList: [{
  88. index: 0,
  89. icon: 'el-icon-view',
  90. name: '详情',
  91. },
  92. {
  93. index: 1,
  94. icon: 'el-icon-edit',
  95. name: '编辑'
  96. },
  97. {
  98. index: 2,
  99. icon: 'el-icon-delete',
  100. name: '删除'
  101. }
  102. ]
  103. }
  104. },
  105. computed: {
  106. handelData() {
  107. return item => {
  108. let obj = {
  109. name: '',
  110. statusName: '',
  111. statusColor: '',
  112. latitude: '',
  113. longitude: '',
  114. address: '',
  115. }
  116. if (this.activeIndex == 0) {
  117. obj.name = item.name
  118. obj.longitude = item.longitude
  119. obj.latitude = item.latitude
  120. obj.address = item.address
  121. if (item.deviceStatus == 0) {
  122. obj.statusName = '离线'
  123. obj.statusColor = '#fa3534'
  124. } else if (item.deviceStatus == 1) {
  125. obj.statusName = '在线'
  126. obj.statusColor = '#19be6b'
  127. } else {
  128. obj.statusName = '未知'
  129. obj.statusColor = '#82848a'
  130. }
  131. } else if (this.activeIndex == 1) {
  132. obj.name = item.name
  133. obj.longitude = item.longitude
  134. obj.latitude = item.latitude
  135. obj.address = item.address
  136. obj.statusColor = '#82848a'
  137. if (item.ptzType == 0) {
  138. obj.statusName = '未知'
  139. } else if (item.deviceStatus == 1) {
  140. obj.statusName = '球机'
  141. } else if (item.deviceStatus == 2) {
  142. obj.statusName = '半球'
  143. } else if (item.deviceStatus == 3) {
  144. obj.statusName = '固定枪机'
  145. } else if (item.deviceStatus == 4) {
  146. obj.statusName = '遥控枪机'
  147. }
  148. }
  149. return obj
  150. }
  151. }
  152. },
  153. created() {
  154. this.fetchDeviceList()
  155. },
  156. filters: {
  157. formatDate(date) {
  158. if (!date) {
  159. return "未知"
  160. }
  161. return dateTime.format(new Date(date), 'mm-dd HH:MM:SS')
  162. }
  163. },
  164. methods: {
  165. select(item) {
  166. this.activeIndex = item.value
  167. this.fetchDeviceList()
  168. this.$emit('select', this.activeIndex)
  169. },
  170. dropdownClick(item,item1) {
  171. let obj={
  172. name:item1.name,
  173. data:item
  174. }
  175. this.$emit('dropdownClick',obj)
  176. },
  177. clickDevice(data) {
  178. this.list.forEach(item => {
  179. item.id == data.id ? item.show = true : item.show = false
  180. })
  181. this.$emit('click', data)
  182. },
  183. async fetchDeviceList() {
  184. this.loading = true
  185. let data = {}
  186. if (this.activeIndex == 0) {
  187. data = (await getDoorDeviceList(this.page.current, this.page.size)).data.data
  188. } else if (this.activeIndex == 1) {
  189. data = (await getVideoDeviceList(this.page.current, this.page.size)).data.data
  190. }
  191. this.initData(data)
  192. this.loading = false
  193. },
  194. initData(data) {
  195. let list = data.records
  196. list.forEach(item => {
  197. item.show = false
  198. })
  199. this.list = list
  200. this.page.pages = data.pages
  201. },
  202. currentChange(current) {
  203. this.page.current = current
  204. this.fetchDeviceList()
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. * {
  211. box-sizing: border-box;
  212. }
  213. /* 设备列表 */
  214. .container {
  215. border-top: 1px solid #f2f1ed;
  216. background-color: #fff;
  217. position: absolute;
  218. top: 0;
  219. right: 0;
  220. width: 22%;
  221. height: 100%;
  222. }
  223. .card {
  224. cursor: pointer;
  225. padding: 15px;
  226. border-bottom: 1px solid #eee;
  227. background-color: #fff;
  228. display: flex;
  229. justify-content: space-between;
  230. width: 100%;
  231. .left {
  232. width: 65%
  233. }
  234. .center-menu {
  235. width: 100%;
  236. height: 100%
  237. }
  238. .right {
  239. width: 28%;
  240. text-align: right
  241. }
  242. }
  243. .card:active {
  244. transform: scale(1.009);
  245. }
  246. .pagination {
  247. padding-top: 20px;
  248. }
  249. .name {
  250. width: 100%;
  251. color: #272727;
  252. font-size: 15px;
  253. font-weight: 500
  254. }
  255. .status {
  256. font-size: 14px;
  257. color: #fa3534
  258. }
  259. .time {
  260. padding-top: 5px;
  261. font-size: 14px;
  262. font-weight: 300
  263. }
  264. .address {
  265. padding-top: 5px;
  266. font-size: 13px;
  267. font-weight: 300
  268. }
  269. </style>