index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <div class="page-container">
  3. <div class="head-card">
  4. <div class="head-card-item">
  5. <div class="item">
  6. <div class="count">{{ cardCount.org }}</div>
  7. <div class="label">区域统计</div>
  8. </div>
  9. <div class="logo">
  10. <img src="/@/assets/icon-org.png" class="img">
  11. </div>
  12. </div>
  13. <div class="head-card-item">
  14. <div class="item">
  15. <div class="count">{{ cardCount.plot }}</div>
  16. <div class="label">小区统计</div>
  17. </div>
  18. <div class="logo">
  19. <img src="/@/assets/icon-plot.png" class="img">
  20. </div>
  21. </div>
  22. <div class="head-card-item">
  23. <div class="item">
  24. <div class="count">{{ cardCount.resident }}</div>
  25. <div class="label">住户统计</div>
  26. </div>
  27. <div class="logo">
  28. <img src="/@/assets/icon-resident.png" class="img">
  29. </div>
  30. </div>
  31. </div>
  32. <div class="panel">
  33. <div class="left-panel">
  34. <el-input v-model="filterText" size="default" placeholder="搜索区域" />
  35. <el-tree :data="treeList" node-key="id" default-expand-all :props="{
  36. children: 'children'
  37. }" @node-click="onNodeClick" :expand-on-click-node="false">
  38. <template #default="{ data }">
  39. <span class="custom-tree-node" :class="{ active: `${data.id}-${data.orgType}` === `${curNode.id}-${curNode.orgType}` }">
  40. <img src="/src/assets/icon-org.png" v-if="data.orgType === 'org'">
  41. <img src="/src/assets/icon-plot.png" v-else-if="data.orgType === 'plot'">
  42. <img src="/src/assets/icon-floor.png" v-else-if="data.orgType === 'floor'">
  43. <img src="/src/assets/icon-unit.png" v-else-if="data.orgType === 'unit'">
  44. <span class="name" :title="data.orgName">{{ data.orgName }}</span>
  45. </span>
  46. </template>
  47. </el-tree>
  48. </div>
  49. <div class="right-panel">
  50. <!-- 小区 -->
  51. <Regional v-if="curNode.orgType === 'org'" :organizationId="curNode.id" @finish="initPage()" />
  52. <!-- 楼宇 -->
  53. <Floor v-else-if="curNode.orgType === 'plot'" :nodeId="curNode.id" @finish="initPage()" />
  54. <!-- 单元 -->
  55. <Unit v-else-if="curNode.orgType === 'floor'" :nodeId="curNode.id" @finish="initPage()" />
  56. <!-- 住户 -->
  57. <Resident v-else-if="curNode.orgType === 'unit'" :nodeId="curNode.id" @finish="initPage()" />
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script lang="ts">
  63. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  64. import api from '/@/api/heatingDistrict';
  65. import Regional from './children/regional/index.vue'
  66. import Floor from './children/floor/index.vue'
  67. import Unit from './children/unit/index.vue'
  68. import Resident from './children/resident/index.vue'
  69. export default defineComponent({
  70. name: '',
  71. components: {
  72. Regional,
  73. Floor,
  74. Unit,
  75. Resident
  76. },
  77. setup() {
  78. const treeList = ref([])
  79. const state = reactive({
  80. filterText: '',
  81. cardCount: {
  82. org: 0,
  83. plot: 0,
  84. resident: 0
  85. },
  86. curNode: {}
  87. });
  88. // 获取区域树
  89. const getTreeData = () => {
  90. api.heatingDistrict.getTree({})
  91. .then((res: any) => {
  92. treeList.value = res || []
  93. if (!state.curNode.id) {
  94. state.curNode = treeList.value[0]
  95. }
  96. })
  97. }
  98. // 获取组织数量
  99. const getOrgCount = () => {
  100. api.heatingDistrict.getOrganizationCount({})
  101. .then((res: any) => {
  102. console.log(res)
  103. state.cardCount.org = res.Count
  104. })
  105. }
  106. // 获取小区数量
  107. const getPlotCount = () => {
  108. api.heatingDistrict.getPlotCount({})
  109. .then((res: any) => {
  110. console.log(res)
  111. state.cardCount.plot = res.Count
  112. })
  113. }
  114. // 获取组织数量
  115. const getResidentCount = () => {
  116. api.heatingDistrict.getResidentCount({})
  117. .then((res: any) => {
  118. console.log(res)
  119. state.cardCount.resident = res.Count
  120. })
  121. }
  122. const initPage = () => {
  123. getTreeData()
  124. getOrgCount()
  125. getPlotCount()
  126. getResidentCount()
  127. }
  128. const onNodeClick = (data: any, node: any) => {
  129. // console.log(data)
  130. // console.log(node)
  131. if (data.orgType === 'floor') {
  132. data.plotId = node.parent.data.id
  133. } else if (data.orgType === 'unit') {
  134. data.floorId = node.parent.data.id
  135. data.plotId = node.parent.parent.data.id
  136. }
  137. state.curNode = data
  138. }
  139. // 页面加载时
  140. onMounted(() => {
  141. initPage()
  142. });
  143. return {
  144. treeList,
  145. onNodeClick,
  146. getTreeData,
  147. initPage,
  148. ...toRefs(state),
  149. };
  150. },
  151. });
  152. </script>
  153. <style lang="scss" scoped>
  154. .page-container {
  155. background-color: #fff;
  156. .panel {
  157. display: grid;
  158. grid-template-columns: 250px 1fr;
  159. border: 1px solid #ddd;
  160. // &::before {
  161. // content: " ";
  162. // display: block;
  163. // clear: both;
  164. // }
  165. }
  166. .left-panel {
  167. padding: 20px;
  168. }
  169. .right-panel {
  170. display: flex;
  171. flex-direction: column;
  172. padding: 20px;
  173. border-left: 1px solid #ddd;
  174. position: relative;
  175. }
  176. }
  177. .custom-tree-node {
  178. display: grid;
  179. grid-template-columns: 20px 1fr;
  180. align-items: center;
  181. img {
  182. width: 16px;
  183. height: 16px;
  184. }
  185. .name {
  186. overflow: hidden;
  187. text-overflow: ellipsis;
  188. }
  189. &.active {
  190. color: var(--el-color-primary);
  191. // background: var(--el-color-primary-light-9);
  192. }
  193. }
  194. .head-card {
  195. display: grid;
  196. grid-template-columns: 1fr 1fr 1fr;
  197. padding: 20px;
  198. &-item {
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. .item {
  203. text-align: center;
  204. // margin-right: 10px;
  205. .count {
  206. font-size: 32px;
  207. font-weight: 700;
  208. color: #101010;
  209. margin-bottom: 5px;
  210. }
  211. }
  212. .logo {
  213. width: 72px;
  214. height: 72px;
  215. border-radius: 50%;
  216. // border: 1px solid #ddd;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. .img {
  221. width: 32px;
  222. height: 32px;
  223. }
  224. }
  225. }
  226. }
  227. :deep(.system-dic-container) {
  228. position: absolute;
  229. width: calc(100% - 40px);
  230. }
  231. </style>