index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="index-content">
  3. <div
  4. class="img-content"
  5. :class="{ mouseStyle: openCur == 1 }"
  6. ref="divImg"
  7. :style="`backgroundImage:url(${modelPictureUrl});backgroundSize: 100% 100%;`"
  8. @click="openCur == 1 ? paintingPoint($event) : null"
  9. ></div>
  10. <div class="point" :style="`left:${item.xcoordinate}%;top:${item.ycoordinate}%`" v-for="(item, index) in points" :key="index">
  11. <span class="point-type" :class="`point-type${item.deviceType}`" @click="openCur !== 2 ? togglePop(item) : null"></span>
  12. <span class="textStyle">{{ item.deviceName }}</span>
  13. <span class="pointClose" @click="pointClose(item)" v-if="openCur == 2">x</span>
  14. </div>
  15. <div class="index-content-left" v-if="showChart">
  16. <last-month-alarm></last-month-alarm>
  17. <alarm-trend-analysis></alarm-trend-analysis>
  18. <proportion-of-alarm-types></proportion-of-alarm-types>
  19. <work-order-processing-status></work-order-processing-status>
  20. </div>
  21. <div class="index-content-right-buttom" @click="toggleShow"><span></span>{{ !showChart ? '显示' : '隐藏' }}图表</div>
  22. <div class="index-dotting-list" :class="showChart ? '' : 'showChart'" v-if="menuListShow">
  23. <div class="list-type" @click="addPoint()" :class="{ thisDotting: openCur == 1 }">
  24. <span class="zoniot_font zoniot-icon-tianjia1"></span>添加
  25. </div>
  26. <div class="list-type" @click="editPoint" :class="{ thisDotting: openCur == 2 }">
  27. <span class="zoniot_font zoniot-icon-bianji3"></span>编辑
  28. </div>
  29. <!-- <div class="list-type" @click="submitPoint" :class="{ thisDotting: openCur == 3 }">
  30. <span class="zoniot_font zoniot-icon-baocun"></span>保存
  31. </div> -->
  32. </div>
  33. <div class="rightFloatType" :class="showChart ? '' : 'showChart'">
  34. <el-checkbox-group v-model="showPointArr">
  35. <el-checkbox :class="'typeIcon' + items.type" v-for="items in deviceArr" :label="items.type" :key="items.type">{{
  36. items.label
  37. }}</el-checkbox>
  38. </el-checkbox-group>
  39. </div>
  40. <div class="index-content-right" v-if="showChart">
  41. <water-consumption></water-consumption>
  42. <power-consumption></power-consumption>
  43. <patrol-task-completion-rate></patrol-task-completion-rate>
  44. <key-areas></key-areas>
  45. </div>
  46. <div class="index-content-buttom" v-if="showChart">
  47. <passenger-flow-statistics></passenger-flow-statistics>
  48. </div>
  49. <modular-loading :loadding="false" tipsText="地图加载中"></modular-loading>
  50. </div>
  51. </template>
  52. <script>
  53. import smallModuleIndex from '@views/smallModule/index.js';
  54. import { mapState } from 'vuex';
  55. export default {
  56. mixins: [smallModuleIndex],
  57. data() {
  58. return {
  59. showChart: true,
  60. loadding: true,
  61. openCur: null,
  62. modelPictureUrl: '',
  63. deviceArr: [
  64. {
  65. type: 1,
  66. label: '摄像头'
  67. },
  68. {
  69. type: 2,
  70. label: '门禁机'
  71. },
  72. {
  73. type: 3,
  74. label: '停车道闸'
  75. },
  76. {
  77. type: 4,
  78. label: '水表'
  79. },
  80. {
  81. type: 5,
  82. label: '电表'
  83. }
  84. ],
  85. mixins_query: {
  86. communityId: ''
  87. },
  88. showPointArr: [1, 2, 3, 4, 5],
  89. point: [],
  90. imgUrl: require('@/assets/img/homeIcon/bg_bottom.png')
  91. };
  92. },
  93. computed: {
  94. ...mapState(['homeCommunityAll']),
  95. points() {
  96. let showArr = [];
  97. this.point.map((item) => {
  98. if (this.showPointArr.includes(item.deviceType)) {
  99. showArr.push(item);
  100. }
  101. });
  102. return showArr;
  103. },
  104. menuListShow() {
  105. if (
  106. !!this.$store.getters['getMenuList'] &&
  107. !!this.$store.getters['getMenuList'][0] &&
  108. !!this.$store.getters['getMenuList'][0].children &&
  109. !!this.$store.getters['getMenuList'][0].children[0].name == '添加点位'
  110. ) {
  111. return true;
  112. } else {
  113. return false;
  114. }
  115. }
  116. },
  117. watch: {
  118. //全局社区接口调用
  119. homeCommunityAll(val) {
  120. try {
  121. this.mixins_query.communityId = val;
  122. this.getData();
  123. this.getImg();
  124. } catch {}
  125. }
  126. },
  127. methods: {
  128. addPoint() {
  129. if (this.openCur == 1) {
  130. this.openCur = null;
  131. } else {
  132. this.openCur = 1;
  133. }
  134. },
  135. editPoint() {
  136. if (this.openCur == 2) {
  137. this.openCur = null;
  138. } else {
  139. this.openCur = 2;
  140. }
  141. },
  142. submitPoint() {
  143. this.openCur = 3;
  144. },
  145. togglePop(row) {
  146. let url = '',
  147. width = '2.89rem',
  148. height = '2.25rem',
  149. showHide = false;
  150. if (row.deviceType == 1) {
  151. url = 'typeCamera';
  152. } else if (row.deviceType == 2) {
  153. url = 'typeAccessControl';
  154. } else if (row.deviceType == 3) {
  155. url = 'typeCard';
  156. showHide = true;
  157. } else if (row.deviceType == 4) {
  158. url = 'typeHydropower';
  159. height = '2.65rem';
  160. } else if (row.deviceType == 5) {
  161. url = 'typeHydropower';
  162. height = '1.2rem';
  163. }
  164. new Promise((resolve) => {
  165. this.$store.dispatch('addPopup', {
  166. url: `/commandDispatch/pop/${url}.vue`,
  167. title: row.deviceName,
  168. notip: true,
  169. width: width,
  170. height: height,
  171. fullscreen: false,
  172. showFooter: true,
  173. showAlarm: true,
  174. showHide: showHide,
  175. props: {
  176. row,
  177. callback: resolve
  178. }
  179. });
  180. }).then(() => {});
  181. },
  182. paintingPoint(e) {
  183. let width = window.getComputedStyle(this.$refs.divImg).width.replace(/px/, ''),
  184. height = window.getComputedStyle(this.$refs.divImg).height.replace(/px/, '');
  185. let pointObj = {
  186. xcoordinate: Number(((e.x / width) * 100).toFixed(6)),
  187. ycoordinate: Number(((e.y / height) * 100).toFixed(6))
  188. };
  189. new Promise((resolve) => {
  190. this.$store.dispatch('addPopup', {
  191. url: '/commandDispatch/pop/dottingEquipment.vue',
  192. title: '添加设备',
  193. notip: true,
  194. width: '3.89rem',
  195. height: '2.25rem',
  196. props: {
  197. pointObj,
  198. deviceArr: this.deviceArr,
  199. callback: resolve
  200. }
  201. });
  202. }).then(() => {
  203. this.getData();
  204. });
  205. },
  206. pointClose(item) {
  207. this.$msgBox(`删除`, '删除后将无法恢复,请问是否继续?')
  208. .then(() => {
  209. this.$http.get('/sc-community/community/layer/delete', { id: item.id }).then(({ status, data, msg }) => {
  210. if (0 === status) {
  211. this.$message({
  212. type: 'success',
  213. message: '删除成功!'
  214. });
  215. this.getData();
  216. }
  217. });
  218. })
  219. .catch(() => {});
  220. },
  221. toggleShow() {
  222. this.showChart = !this.showChart;
  223. },
  224. getData() {
  225. this.$http
  226. .post('/sc-community/community/layer/list', this.mixins_query)
  227. .then(({ status, data, msg }) => {
  228. if (status == 0 && !!data) {
  229. this.point = data;
  230. } else {
  231. this.$message.error(msg);
  232. }
  233. loading.close();
  234. })
  235. .catch(() => {});
  236. },
  237. getImg() {
  238. this.$http
  239. .get('/sc-community/assets/community/find/' + this.mixins_query.communityId)
  240. .then(({ status, data, msg }) => {
  241. if (status == 0 && !!data) {
  242. this.modelPictureUrl = data.modelPictureUrl;
  243. } else {
  244. this.$message.error(msg);
  245. }
  246. })
  247. .catch(() => {});
  248. }
  249. },
  250. created() {
  251. if (!!this.mixins_query.communityId) {
  252. this.getImg();
  253. this.getData();
  254. }
  255. }
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. @import '@views/commandDispatch/style.scss';
  260. </style>