elevationMap.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div v-loading="load" class="saga-elevation">
  3. <div v-if="elevationData.length" class="saga-floor">
  4. <div class="saga-rf">
  5. <p class="saga-floorName">RF</p>
  6. <div class="saga-spaceList">
  7. <div class="saga-group" v-for="(winth, index) in groupWidth" :key="index" :style="`width: ${100*winth}px;`"></div>
  8. </div>
  9. </div>
  10. <div class="saga-floor-item" v-for="floor in elevationData" :key="floor.FloorID">
  11. <p class="saga-floorName" :title="floor.FloorLocalName?floor.FloorLocalName:floor.FloorName">
  12. {{floor.FloorLocalName?floor.FloorLocalName:floor.FloorName}}
  13. <i class="el-icon-right"></i>
  14. </p>
  15. <div class="saga-spaceList">
  16. <div class="saga-group" v-for="(group, groupIndex) in floor.group" :style="`width: ${100*groupWidth[groupIndex]}px;`">
  17. <div class="saga-spaceItem"
  18. :class="[spaceItem.IsAI?spaceItem.checked?'saga-spaceItem-checked':'saga-spaceItem-ai':'']"
  19. v-for="spaceItem in group.spaceList"
  20. :key="spaceItem.RoomID"
  21. :title="spaceItem.RoomLocalName?spaceItem.RoomLocalName:spaceItem.RoomName"
  22. @click="handleClickCheck(spaceItem)"
  23. >
  24. {{spaceItem.RoomLocalName?spaceItem.RoomLocalName:spaceItem.RoomName}}
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <div v-else class="saga-center">
  31. <i class="icon-wushuju iconfont"></i>
  32. 暂无数据
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { shaftVerticalSpace, shaftZoneLink } from "@/api/scan/request"
  38. import {mapGetters} from 'vuex'
  39. export default {
  40. data () {
  41. return {
  42. elevationData: [],
  43. groupWidth: {},
  44. checkedList: [],
  45. load: false,
  46. }
  47. },
  48. computed: {
  49. ...mapGetters("layout", ["projectId"])
  50. },
  51. props: {
  52. params: Object,
  53. onlyRead: Boolean,
  54. isEdit: Boolean,
  55. isAI: Boolean,
  56. },
  57. methods: {
  58. init () { //获取数据并格式化数据
  59. this.elevationData = [];
  60. //根据isAI判断请求参数是否包含AI推介数据(暂未完成)
  61. this.params.aiSwitch = this.isAI
  62. this.load = true;
  63. // 查询竖井关联的空间垂直交通关系
  64. shaftVerticalSpace(this.params, (res) => {
  65. let data = res.Content?res.Content:[];
  66. let max = 0, idMap = {}, groupMap = {}, copyData = JSON.parse(JSON.stringify(data));
  67. this.groupWidth = {};
  68. copyData.reverse().forEach(floor => {
  69. if (floor.ZoneSpaceList && floor.ZoneSpaceList.length) {
  70. floor.ZoneSpaceList.forEach(space => {
  71. if (idMap[space.RoomID]) { // 该业务空间在映射列表中
  72. groupMap[idMap[space.RoomID]].push(space)
  73. space.SpaceIdList.forEach(RoomID =>{
  74. if (!idMap[RoomID]) {
  75. idMap[RoomID] = idMap[space.RoomID];
  76. }
  77. })
  78. } else { // 该业务空间不在映射列表中
  79. max++;
  80. idMap[space.RoomID] = max;
  81. groupMap[max] = [];
  82. this.groupWidth[max] = 0;
  83. groupMap[max].push(space);
  84. space.SpaceIdList.forEach(RoomID =>{
  85. if (!idMap[RoomID]) {
  86. idMap[RoomID] = max;
  87. }
  88. })
  89. }
  90. })
  91. }
  92. })
  93. data.forEach((floor, index) =>{
  94. floor.group = {};
  95. Object.keys(groupMap).forEach(groupIndex =>{
  96. let max = 0;
  97. floor.group[groupIndex] = {
  98. spaceList: []
  99. };
  100. if (floor.ZoneSpaceList && floor.ZoneSpaceList.length) {
  101. floor.ZoneSpaceList.forEach(space => {
  102. if (groupMap[groupIndex].find(item => { return space.RoomID == item.RoomID })) {
  103. space.checked = false;
  104. floor.group[groupIndex].spaceList.push(space);
  105. max++;
  106. }
  107. })
  108. }
  109. if (max > this.groupWidth[groupIndex]) {
  110. this.groupWidth[groupIndex] = max;
  111. }
  112. })
  113. });
  114. this.elevationData = data
  115. console.log(this.elevationData)
  116. this.load = false;
  117. })
  118. },
  119. handleClickCheck (sapceItem) { //点选推介的业务空间
  120. console.log(this.isEdit)
  121. if (sapceItem.IsAI && this.isEdit && !this.onlyRead) { //是AI推荐并且编辑模式下
  122. sapceItem.checked = sapceItem.checked? false: true;
  123. if (sapceItem.checked) {
  124. this.checkedList.push(sapceItem);
  125. // 选中平面图的对应空间
  126. this.$emit('elevationChecked',sapceItem.RoomID);
  127. } else {
  128. let index = this.checkedList.findIndex(item =>{ return item.RoomID == sapceItem.RoomID })
  129. if (index != -1) { // 找到对应的数据
  130. this.checkedList.splice(index,1);
  131. // 取消选中平面图的对应空间
  132. this.$emit('elevationUncheck',sapceItem.RoomID);
  133. }
  134. }
  135. }
  136. },
  137. savaEdit () {// 接口保存数据和业务空间的关系
  138. let params = {
  139. type: this.params.ObjectType,
  140. data: {
  141. ShaftId: this.params.ShaftId,
  142. SpaceIdList: this.checkedList.map(item => {
  143. return item.RoomID
  144. })
  145. }
  146. }
  147. console.log(params);
  148. shaftZoneLink(params, res =>{
  149. this.$message.success("保存成功");
  150. this.init();
  151. })
  152. }
  153. },
  154. watch: {
  155. projectId() {
  156. if (this.params.BuildingId && this.params.ObjectType && this.params.ShaftId) {
  157. this.init();
  158. }
  159. console.log(this.projectId)
  160. },
  161. // isAI() {
  162. // if (this.params.BuildingId && this.params.ObjectType && this.params.ShaftId) {
  163. // this.init();
  164. // }
  165. // },
  166. params: {
  167. handler() {
  168. if (this.params.BuildingId && this.params.ObjectType && this.params.ShaftId) {
  169. this.init();
  170. }
  171. },
  172. immediate: true,
  173. deep: true,
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="less">
  179. .saga-elevation {
  180. height: 100%;
  181. position: relative;
  182. .saga-center{
  183. position: absolute;
  184. top: 50%;
  185. left: 50%;
  186. transform: translate(-50%,-60%);
  187. text-align: center;
  188. }
  189. .saga-floor {
  190. display: flex;
  191. box-sizing: border-box;
  192. flex-direction: column;
  193. justify-content: flex-end;
  194. padding: 60px 10px 20px 0px;
  195. .saga-rf {
  196. display: flex;
  197. flex-direction: row;
  198. font-size: 12px;
  199. color: blue;
  200. }
  201. .saga-floor-item {
  202. display: flex;
  203. flex-direction: row;
  204. font-size: 12px;
  205. height: 60px;
  206. line-height: 60px;
  207. }
  208. .saga-floorName {
  209. min-width: 80px;
  210. text-align: right;
  211. overflow: hidden;
  212. text-overflow: ellipsis;
  213. white-space: nowrap;
  214. }
  215. .saga-spaceList {
  216. display: flex;
  217. flex-direction: row;
  218. flex: 1;
  219. border-bottom: 2px solid #c1c6d2;
  220. box-sizing: border-box;
  221. .saga-group {
  222. display: flex;
  223. flex-direction: row;
  224. margin-left: 25px;
  225. box-sizing: border-box;
  226. .saga-spaceItem {
  227. width: 100px;
  228. margin-left: 1px;
  229. text-align: center;
  230. overflow: hidden;
  231. text-overflow:ellipsis;
  232. white-space: nowrap;
  233. background-color: #ffcc00;
  234. border: 1px solid #333333;
  235. }
  236. .saga-spaceItem-ai{
  237. cursor: pointer;
  238. box-sizing: border-box;
  239. background-color: #eaeae9;
  240. border: 1px dashed #333333;
  241. }
  242. .saga-spaceItem-checked {
  243. cursor: pointer;
  244. box-sizing: border-box;
  245. background-color: #1abc9c;
  246. border: 1px dashed #333333;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. </style>