electricityMeter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div class="main">
  3. <div class="search">
  4. <el-input placeholder="输入设备编号/名称/地址" class="search-input" clearable v-model="mixins_query.name"></el-input>
  5. <el-select v-model="mixins_query.communityId" placeholder="选择社区" clearable>
  6. <el-option v-for="(item, index) in communityArr" :key="index" :label="item.communityName" :value="item.id"></el-option>
  7. </el-select>
  8. <el-select v-model="mixins_query.useType" placeholder="选择用途" clearable>
  9. <el-option label="房间表" :value="1"></el-option>
  10. <el-option label="公摊表" :value="2"></el-option>
  11. </el-select>
  12. <el-select placeholder="选择状态" v-model="mixins_query.deviceStatus" clearable>
  13. <el-option v-for="(item, index) in deviceStatus" :key="index" :label="item.label" :value="item.status"></el-option>
  14. </el-select>
  15. <el-button type="primary" class="search-btn" @click="mixins_search" icon="el-icon-search">查询 </el-button>
  16. <div class="search-icon">
  17. <el-tooltip class="item" effect="light" placement="bottom" content="关阀">
  18. <i class="zoniot_font zoniot-icon-guan" @click="exportExcel"></i>
  19. </el-tooltip>
  20. <el-tooltip class="item" effect="light" placement="bottom" content="开阀">
  21. <i class="zoniot_font zoniot-icon-kai" @click="exportExcel"></i>
  22. </el-tooltip>
  23. <el-tooltip class="item" effect="light" placement="bottom" content="删除">
  24. <i class="iconfont" @click="deluserbyidFn()">&#xe63b;</i>
  25. </el-tooltip>
  26. <el-tooltip class="item" effect="light" placement="bottom" content="导出">
  27. <i class="zoniot_font zoniot-icon-daochu2" @click="exportExcel"></i>
  28. </el-tooltip>
  29. <el-dropdown type="primary" @command="addCommand">
  30. <span class="iconfont">&#xe641;</span>
  31. <el-dropdown-menu slot="dropdown" hide-on-click="false" class="device-search-dropdown">
  32. <el-dropdown-item command="add">单个添加</el-dropdown-item>
  33. <el-dropdown-item command="batchAdd">
  34. <div class="upload_div">
  35. <xk-upload class="upload_class" @callback="mixins_search" :params="{ importType: 'DEVICE' }">
  36. <span class="upload_text" slot="content">批量添加</span>
  37. </xk-upload>
  38. </div>
  39. </el-dropdown-item>
  40. <el-dropdown-item command="template">下载模板</el-dropdown-item>
  41. </el-dropdown-menu>
  42. </el-dropdown>
  43. </div>
  44. </div>
  45. <div class="roles-wrap">
  46. <zz-table
  47. :cols="cols"
  48. :settings="{ showCheckbox: true, showIndex: true, stripe: true }"
  49. :loading="mixins_onQuery"
  50. :data="mixins_list"
  51. :pageset="mixins_pageset"
  52. @page-change="pageChange"
  53. @selection-change="selectionChange"
  54. >
  55. <template slot-scope="scope" slot="opt">
  56. <div class="opt">
  57. <el-tooltip class="item" effect="light" placement="bottom" content="查看">
  58. <i class="zoniot_font zoniot-icon-xiangqing" @click="lookPage(scope.row)"></i>
  59. </el-tooltip>
  60. <el-tooltip effect="light" placement="bottom" content="编辑">
  61. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope.row)"></i>
  62. </el-tooltip>
  63. <el-tooltip effect="light" placement="bottom" :content="scope.row.deviceStatus === 5 ? '已报废' : '报废'">
  64. <i v-if="scope.row.deviceStatus === 5" class="zoniot_font zoniot-icon-baofei ashText"></i>
  65. <i v-else class="zoniot_font zoniot-icon-baofei redText" @click="Scrap(scope.row.id)"></i>
  66. </el-tooltip>
  67. </div>
  68. </template>
  69. </zz-table>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import list from '@utils/list.js';
  75. export default {
  76. mixins: [list],
  77. data() {
  78. return {
  79. selectRow: [],
  80. // 数据列表
  81. deviceStatus: [
  82. {
  83. status: 1,
  84. label: '正常'
  85. },
  86. {
  87. status: 2,
  88. label: '告警'
  89. },
  90. {
  91. status: 3,
  92. label: '离线'
  93. },
  94. {
  95. status: 4,
  96. label: '未启用'
  97. },
  98. {
  99. status: 5,
  100. label: '报废'
  101. }
  102. ],
  103. cols: [
  104. {
  105. label: '所属社区',
  106. prop: 'communityName'
  107. },
  108. {
  109. label: '地址',
  110. prop: 'address'
  111. },
  112. {
  113. label: '设备编号',
  114. prop: 'deviceNo'
  115. },
  116. {
  117. label: '设备名称',
  118. prop: 'deviceName'
  119. },
  120. {
  121. label: '用途',
  122. prop: 'useType',
  123. format(val, data) {
  124. return val == 1 ? '房间表' : '公摊表';
  125. }
  126. },
  127. {
  128. label: '当前读数',
  129. prop: 'readData'
  130. },
  131. {
  132. label: '设备状态',
  133. prop: 'deviceStatus',
  134. format(val, data) {
  135. switch (val) {
  136. case 1:
  137. return '正常';
  138. case 2:
  139. return '告警';
  140. case 3:
  141. return '离线';
  142. case 4:
  143. return '未启用';
  144. case 5:
  145. return '报废';
  146. default:
  147. return '-';
  148. }
  149. }
  150. },
  151. {
  152. label: '电闸状态',
  153. prop: 'valveStatus',
  154. format(val, data) {
  155. switch (val) {
  156. case 0:
  157. return '关';
  158. case 1:
  159. return '开';
  160. case 2:
  161. return '无闸';
  162. default:
  163. return '-';
  164. }
  165. }
  166. },
  167. {
  168. label: '最后上报时间',
  169. prop: 'lastReceiveTime'
  170. },
  171. {
  172. label: '操作',
  173. prop: 'id',
  174. slot: 'opt'
  175. }
  176. ],
  177. mixins_post: 'get',
  178. productOptions: [],
  179. defaultProps: {
  180. value: 'id', // 唯一标识
  181. label: 'label', // 标签显示
  182. children: 'children' // 子级
  183. },
  184. viewParams: {},
  185. communityArr: []
  186. };
  187. },
  188. created() {
  189. this.getorgTree();
  190. this.mixins_dataUrl = '/sc-energy/device/getPage';
  191. this.mixins_query = {
  192. categoryId: 2
  193. };
  194. this.mixins_search();
  195. },
  196. mounted() {
  197. this.getProductOptions();
  198. },
  199. methods: {
  200. getorgTree() {
  201. this.$http
  202. .get('/sc-community/assets/community/list')
  203. .then((data) => {
  204. this.communityArr = data.data;
  205. this.$store.commit('setAreaSelect', data.data);
  206. })
  207. .catch(function () {});
  208. },
  209. deluserbyidFn(id) {
  210. let ids = [];
  211. if (!this.selectRow.length) {
  212. this.$message.error('您尚未选择要删除的记录,请选择后再操作批量删除');
  213. return;
  214. }
  215. this.selectRow.forEach((v) => {
  216. ids.push(v.id);
  217. });
  218. const h = this.$createElement;
  219. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  220. .then(() => {
  221. this.$http.post('/sc-energy/device/batchDelete', ids).then(({ status, data, msg }) => {
  222. if (0 === status) {
  223. this.$message({
  224. type: 'success',
  225. message: '删除成功!'
  226. });
  227. this.mixins_search();
  228. }
  229. });
  230. })
  231. .catch(() => {});
  232. },
  233. Scrap(id) {
  234. this.$msgBox(`确认提示`, '设备报废后将无法正常接收数据,请问是否继续?')
  235. .then(() => {
  236. this.$http.post('/sc-energy/device/edit/status', { id: id, deviceStatus: 5 }).then(({ status, data, msg }) => {
  237. if (0 === status) {
  238. this.$message({
  239. type: 'success',
  240. message: '报废成功!'
  241. });
  242. this.mixins_search();
  243. }
  244. });
  245. })
  246. .catch(() => {});
  247. },
  248. addOrEdit(todo, data = {}) {
  249. new Promise((resolve) => {
  250. let title = '添加电表';
  251. if (todo !== 'add') {
  252. title = '修改电表';
  253. }
  254. this.$store.dispatch('addPopup', {
  255. url: '/instrumentManagement/popups/addDeviceManagement.vue',
  256. width: '500px',
  257. height: '490px',
  258. props: {
  259. data,
  260. todo,
  261. mixins_query: this.mixins_query,
  262. productOptions: this.productOptions,
  263. callback: resolve
  264. },
  265. title: title
  266. });
  267. }).then(() => {
  268. this.mixins_search();
  269. });
  270. },
  271. addCommand(command) {
  272. if (command === 'add') {
  273. this.addOrEdit('add');
  274. }
  275. if (command === 'template') {
  276. this.__exportExcel('/sc-energy/device/downTemplate', { categoryId: 2 });
  277. return;
  278. }
  279. },
  280. exportExcel() {
  281. this.__exportExcel('/sc-energy/device/getDeviceExcel', this.mixins_query);
  282. },
  283. selectionChange(val) {
  284. this.selectRow = val;
  285. },
  286. getProductOptions() {
  287. this.$http.postForm('/sc-energy/product/tree', { categoryId: 2 }).then((data) => {
  288. this.productOptions = data;
  289. });
  290. },
  291. valveToggle(satus) {
  292. if (!this.selectRow.length) {
  293. this.$message.error('您尚未选择要操作的记录,请选择后再操作');
  294. return;
  295. } else if (this.selectRow.length > 1) {
  296. this.$message.error('请选择单条数据操作');
  297. return;
  298. }
  299. this.$http
  300. .post('/sc-energy/api/valveControl', {
  301. categoryId: this.mixins_query.categoryId,
  302. valveStatus: satus,
  303. houseId: this.selectRow[0].houseId
  304. })
  305. .then(({ status, data, msg }) => {
  306. if (status === 0) {
  307. this.$message.success(msg);
  308. this.mixins_search();
  309. } else {
  310. this.$message.error(msg);
  311. }
  312. });
  313. },
  314. lookPage(row) {
  315. this.$router.push({
  316. path: '/instrumentViewDetail',
  317. query: {
  318. id: row.id,
  319. type: this.mixins_query.categoryId
  320. }
  321. });
  322. }
  323. }
  324. };
  325. </script>