index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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-button type="primary" class="search-btn" @click="mixins_search" icon="el-icon-search">查询 </el-button>
  9. <div class="search-icon">
  10. <el-tooltip class="item" effect="light" placement="bottom" content="新增">
  11. <i class="zoniot_font zoniot-icon-tianjia2" @click="addOrEdit('add')"></i>
  12. </el-tooltip>
  13. </div>
  14. </div>
  15. <zz-table
  16. :cols="cols"
  17. :settings="{ showIndex: true, stripe: true }"
  18. :loading="mixins_onQuery"
  19. :data="mixins_list"
  20. :pageset="mixins_pageset"
  21. @page-change="pageChange"
  22. >
  23. <template slot="pointQrcode">
  24. <i class="zoniot_font zoniot-icon-erweimachakan" style="cursor: inherit"></i>
  25. </template>
  26. <template slot-scope="scope" slot="opt">
  27. <div class="opt">
  28. <el-tooltip effect="light" placement="bottom" content="下载二维码">
  29. <i class="zoniot_font zoniot-icon-erweimaxiazai" @click="lookImg(scope.row)"></i>
  30. </el-tooltip>
  31. <el-tooltip effect="light" placement="bottom" content="编辑">
  32. <i class="zoniot_font zoniot-icon-bianji" @click="addOrEdit('edit', scope.row)"></i>
  33. </el-tooltip>
  34. <el-tooltip effect="light" placement="bottom" content="删除">
  35. <i class="zoniot_font zoniot-icon-shanchu redText" @click="deleteOne(scope.row.id)"></i>
  36. </el-tooltip>
  37. </div>
  38. </template>
  39. </zz-table>
  40. <el-dialog title="下载二维码" :visible.sync="centerDialogVisible" width="400px">
  41. <div class="QRImg" ref="QRImg">
  42. <img :src="QRImg" alt="门禁设备二维码" />
  43. <div>{{ pointName }} - {{ pointNo }}</div>
  44. </div>
  45. <span slot="footer" class="dialog-footer">
  46. <el-button type="primary" @click="downImg">下载</el-button>
  47. </span>
  48. </el-dialog>
  49. </div>
  50. </template>
  51. <script>
  52. import list from '@utils/list.js';
  53. import html2canvas from 'html2canvas';
  54. import scheduling from './popups/scheduling.vue';
  55. export default {
  56. mixins: [list],
  57. name: 'patrolManagement',
  58. components: {
  59. scheduling
  60. },
  61. data() {
  62. let _this = this;
  63. return {
  64. communityArr: [],
  65. communityTre: [],
  66. cols: [
  67. {
  68. label: '所属社区',
  69. prop: 'communityName'
  70. },
  71. {
  72. label: '楼栋',
  73. prop: 'buildingName'
  74. },
  75. {
  76. label: '单元',
  77. prop: 'unit'
  78. },
  79. {
  80. label: '巡更点名称',
  81. prop: 'pointName'
  82. },
  83. {
  84. label: '位置编号',
  85. prop: 'pointNo'
  86. },
  87. {
  88. label: '巡更点二维码',
  89. prop: 'pointQrcode',
  90. slot: 'pointQrcode'
  91. },
  92. {
  93. label: '操作',
  94. prop: 'id',
  95. slot: 'opt'
  96. }
  97. ],
  98. findUser: [],
  99. centerDialogVisible: false,
  100. mixins_post: 'post',
  101. pointName: '',
  102. pointNo: ''
  103. };
  104. },
  105. created() {
  106. this.getorgTree();
  107. this.mixins_dataUrl = '/sc-community/patrol/point/page';
  108. this.mixins_query = {};
  109. this.mixins_search();
  110. this.getUserList();
  111. this.getCommunity();
  112. },
  113. mounted() {},
  114. methods: {
  115. getorgTree() {
  116. this.$http
  117. .get('/sc-community/assets/community/list')
  118. .then((data) => {
  119. this.communityArr = data.data;
  120. this.$store.commit('setAreaSelect', data.data);
  121. })
  122. .catch(function () {});
  123. },
  124. getUserList() {
  125. this.$http.get('/sc-user-center/user/findUserList').then(({ data, status, msg }) => {
  126. this.findUser = data;
  127. });
  128. },
  129. getCommunity() {
  130. this.$http.get('/sc-community/assets/tree/community/find').then(({ data, status, msg }) => {
  131. this.communityTre = data;
  132. });
  133. },
  134. lookImg(row) {
  135. let _this = this;
  136. this.pointName = row.pointName;
  137. this.pointNo = row.pointNo;
  138. this.getBinary('/sc-community/device/generateQRCodeImage', { id: row.id, type: 'PATROLPOINT' }, function (data) {
  139. _this.QRImg = window.URL.createObjectURL(data);
  140. _this.centerDialogVisible = !_this.centerDialogVisible;
  141. });
  142. },
  143. downImg() {
  144. html2canvas(this.$refs.QRImg).then((canvas) => {
  145. let dataURL = canvas.toDataURL('image/png');
  146. let a = document.createElement('a');
  147. a.download = `${this.pointName} - ${this.pointNo}`;
  148. a.href = dataURL;
  149. document.body.appendChild(a);
  150. a.click();
  151. document.body.removeChild(a);
  152. this.centerDialogVisible = !this.centerDialogVisible;
  153. });
  154. // let a = document.createElement('a');
  155. // a.download = `${this.DeviceName}${this.deviceNo}.png`;
  156. // a.href = this.QRImg;
  157. // document.body.appendChild(a);
  158. // a.click();
  159. // document.body.removeChild(a);
  160. // this.centerDialogVisible = !this.centerDialogVisible;
  161. },
  162. getBinary(url, args, success) {
  163. var xmlhttp = new XMLHttpRequest();
  164. var data = eval(args);
  165. var i = 0;
  166. for (var key in data) {
  167. if (i++ === 0) {
  168. url += '?' + key + '=' + data[key];
  169. } else {
  170. url += '&' + key + '=' + data[key];
  171. }
  172. }
  173. xmlhttp.open('GET', url, true);
  174. xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('SC_token'));
  175. xmlhttp.responseType = 'blob';
  176. xmlhttp.onload = function () {
  177. success(this.response);
  178. };
  179. xmlhttp.send();
  180. },
  181. addOrEdit(todo, row) {
  182. let title = '添加巡更点';
  183. if (todo == 'edit') {
  184. title = '修改巡更点';
  185. }
  186. new Promise((resolve) => {
  187. this.$store.dispatch('addPopup', {
  188. url: '/patrolManagement/popups/addPoint.vue',
  189. width: '500px',
  190. height: '500px',
  191. props: {
  192. callback: resolve,
  193. communityArr: this.communityArr,
  194. communityTre: this.communityTre,
  195. data: row,
  196. todo
  197. },
  198. title: title
  199. });
  200. }).then(() => {
  201. this.mixins_search();
  202. });
  203. },
  204. deleteOne(id) {
  205. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  206. .then(() => {
  207. this.$http.get('/sc-community/patrol/point/delete', { id: id }).then(({ status, data, msg }) => {
  208. if (0 === status) {
  209. this.$message({
  210. type: 'success',
  211. message: '删除成功!'
  212. });
  213. this.mixins_search();
  214. }
  215. });
  216. })
  217. .catch(() => {});
  218. }
  219. }
  220. };
  221. </script>
  222. <style scoped lang='scss'>
  223. .QRImg > div {
  224. position: absolute;
  225. width: 100%;
  226. bottom: 0;
  227. text-align: center;
  228. left: 50%;
  229. transform: translateX(-50%);
  230. }
  231. </style>