index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="main">
  3. <div class="search">
  4. <el-input placeholder="设备名称或编号" class="search-input" clearable v-model="mixins_query.deviceNo"></el-input>
  5. <el-select slot="status" v-model="mixins_query.deviceStatus" clearable>
  6. <el-option v-for="(item, index) in deviceStatus" :key="index" :label="item.label" :value="item.status">{{
  7. item.label
  8. }}</el-option>
  9. </el-select>
  10. <el-button type="primary" class="search-btn" @click="mixins_search" icon="el-icon-search">查询 </el-button>
  11. <div class="search-icon">
  12. <i class="iconfont" @click="deluserbyidFn()" v-txt-tip data-txt="删除">&#xe63b;</i>
  13. <i class="iconfont" @click="addOrEdit('add')" v-left-txt-tip data-txt="新增">&#xe641;</i>
  14. </div>
  15. </div>
  16. <div class="roles-wrap">
  17. <zz-table
  18. :cols="cols"
  19. :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
  20. :loading="mixins_onQuery"
  21. :data="mixins_list"
  22. :pageset="mixins_pageset"
  23. @page-change="pageChange"
  24. @selection-change="selectionChange"
  25. >
  26. <template slot-scope="scope" slot="opt">
  27. <div class="opt">
  28. <el-tooltip class="item" effect="light" placement="bottom" content="编辑">
  29. <img class="optImg" @click="addOrEdit('edit', scope.row)" src="@/assets/img/btn_bianji.png" />
  30. </el-tooltip>
  31. <el-tooltip class="item" effect="light" placement="bottom" content="删除">
  32. <img class="optImg" @click="deluserbyidFn(scope.row.id)" src="@/assets/img/btn_shanchu.png" />
  33. </el-tooltip>
  34. </div>
  35. </template>
  36. </zz-table>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import list from '@utils/list.js';
  42. export default {
  43. mixins: [list],
  44. data() {
  45. let _this = this;
  46. return {
  47. selectRow: [],
  48. // 数据列表
  49. deviceStatus: [
  50. {
  51. status: 1,
  52. label: '正常'
  53. },
  54. {
  55. status: 2,
  56. label: '告警'
  57. },
  58. {
  59. status: 3,
  60. label: '离线'
  61. },
  62. {
  63. status: 4,
  64. label: '未启用'
  65. },
  66. {
  67. status: 5,
  68. label: '报废'
  69. }
  70. ],
  71. cols: [
  72. {
  73. label: '所属小区',
  74. prop: 'communityId',
  75. format(val) {
  76. let va = '';
  77. _this.$store.getters['getAreaSelect'].forEach((element) => {
  78. if (element.id === val) {
  79. va = element.communityName;
  80. }
  81. });
  82. return va;
  83. }
  84. },
  85. {
  86. label: '设备类型',
  87. prop: 'deviceTypeName'
  88. },
  89. {
  90. label: '设备编号',
  91. prop: 'deviceNo'
  92. },
  93. {
  94. label: '设备名称',
  95. prop: 'deviceName'
  96. },
  97. {
  98. label: '设备地址',
  99. prop: 'address'
  100. },
  101. {
  102. label: '添加日期',
  103. prop: 'createDate'
  104. },
  105. {
  106. label: '设备状态',
  107. prop: 'deviceStatus',
  108. format(val) {
  109. if (val == '1') {
  110. return '正常';
  111. } else if (val == '2') {
  112. return '告警';
  113. } else if (val == '3') {
  114. return '离线';
  115. } else if (val == '4') {
  116. return '未启用';
  117. } else if (val == '5') {
  118. return '报废';
  119. }
  120. }
  121. },
  122. {
  123. label: '二维码',
  124. prop: 'deviceQrcode'
  125. },
  126. {
  127. label: '操作',
  128. prop: 'id',
  129. slot: 'opt'
  130. }
  131. ],
  132. mixins_post: 'post',
  133. productOptions: []
  134. };
  135. },
  136. created() {
  137. if (this.$store.getters['getAreaSelect'].length === 0) {
  138. this.getorgTree();
  139. }
  140. this.mixins_dataUrl = '/device/page';
  141. this.mixins_query = {};
  142. this.mixins_search();
  143. },
  144. mounted() {
  145. this.getProductOptions();
  146. },
  147. methods: {
  148. getorgTree() {
  149. this.$http
  150. .get('/sc-community/assets/community/list')
  151. .then((data) => {
  152. this.$store.commit('setAreaSelect', data.data);
  153. })
  154. .catch(function () {});
  155. },
  156. deluserbyidFn(id) {
  157. let ids = [];
  158. if (!!id) {
  159. ids = [id];
  160. } else {
  161. if (!this.selectRow.length) {
  162. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  163. return;
  164. }
  165. this.selectRow.forEach((v) => {
  166. ids.push(v.id);
  167. });
  168. }
  169. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  170. .then(() => {
  171. this.$http.post('/facility/delete', ids).then(({ status, data, msg }) => {
  172. if (0 === status) {
  173. this.$message({
  174. type: 'success',
  175. message: '删除成功!'
  176. });
  177. this.mixins_search();
  178. }
  179. });
  180. })
  181. .catch(() => {});
  182. },
  183. addOrEdit(todo, data = {}) {
  184. new Promise((resolve) => {
  185. let title = '添加设备管理';
  186. if (todo == 'add') {
  187. // title = this.mixins_query.alarmCategory == '2' ? '添加离线规则' : '添加告警';
  188. } else {
  189. title = '修改设备管理';
  190. }
  191. this.$store.dispatch('addPopup', {
  192. url: '/deviceManagement/popups/addDeviceManagement.vue',
  193. width: '500px',
  194. height: '700px',
  195. props: {
  196. data,
  197. todo,
  198. productOptions: this.productOptions,
  199. callback: resolve
  200. },
  201. title: title
  202. });
  203. }).then(() => {
  204. this.mixins_search();
  205. });
  206. },
  207. selectionChange(val) {
  208. this.selectRow = val;
  209. },
  210. getProductOptions() {
  211. this.$http.postForm('/devicetype/selectList', { name: '' }).then((data) => {
  212. this.productOptions = data;
  213. });
  214. }
  215. }
  216. };
  217. </script>
  218. <style lang='scss' scoped>
  219. .new-select-tree {
  220. vertical-align: top;
  221. display: inline-block;
  222. margin-right: 25px;
  223. }
  224. table i {
  225. cursor: pointer;
  226. }
  227. </style>