index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <!--
  2. revit业务空间
  3. -->
  4. <template>
  5. <div id="businessSpace">
  6. <!------------------------ 头部弹窗,选择楼层信息 -------------->
  7. <!-- <no-model-dialog :param="param" title="选择要进行空间管理的楼层" :isShow="floor" @close="close"></no-model-dialog> -->
  8. <influence-dialog ref="influence" :param="param" :tabsList="tabsList" title="受元空间变化影响的业务空间" :isShow="floor"></influence-dialog>
  9. <details-dialog ref="details" @del="delSuccess" :param="param" :tabsList="tabsList" title="业务空间详情" :isShow="floor" :activeTabType="activeTabType"></details-dialog>
  10. <not-related ref="notRelated" @createSuccess="createSuccess" :isShow="floor"></not-related>
  11. <facility-dialog ref="facility" :activeTabType="activeTabType" :isShow="floor"></facility-dialog>
  12. <!--------- 页面头部 -------------->
  13. <div class="saga-title">
  14. <!-- <div class="saga-build-mess">
  15. <p>
  16. <i class="iconfont icon-jianzhu"></i> {{buildMess.buildName}} - {{buildMess.name}}
  17. </p>
  18. <el-button class="saga-btn" type="text" @click="changeShow">切换楼层</el-button>
  19. </div> -->
  20. <div class="saga-build-mess">
  21. <span style="padding-right:12px">建筑楼层</span>
  22. <el-cascader
  23. :options="options"
  24. v-model="buildMess.selectd"
  25. :props="props"
  26. @change="close">
  27. </el-cascader>
  28. </div>
  29. <div class="saga-build-tab">
  30. <!-- <div class="tab-main" @click="tabList(1)" :class="isMyTab == 1 ? 'tab-active' : ''">
  31. <i class="iconfont icon-tupian"></i>
  32. <span>平面图</span>
  33. </div>
  34. <div class="tab-main" @click="tabList(2)" :class="isMyTab == 2 ? 'tab-active' : ''">
  35. <i class="iconfont icon-liebiao"></i>
  36. <span>列表</span>
  37. </div> -->
  38. <el-radio-group v-model="isMyTab" @change="changeRadio" style="width: 136px;">
  39. <el-radio-button label="1">平面图</el-radio-button>
  40. <el-radio-button label="2" class="space-own-radio" style="width: 68px;">列表</el-radio-button>
  41. </el-radio-group>
  42. </div>
  43. </div>
  44. <div v-show="isMyTab == 1" class="saga-business-sapce-main">
  45. <el-tabs v-model="activeName" @tab-click="tab1Click">
  46. <template v-for="(item,index) in tabsList">
  47. <el-tab-pane :name="item.code" :key="index" :disabled="item.code > 3">
  48. <span slot="label">{{item.name}}</span>
  49. <graphy
  50. @getSp="checkSpace"
  51. @dimension="checkSpace"
  52. @businessDetails="getBuinessDetails"
  53. :ref="'graphy' + item.code"
  54. :canvasId="item.code"
  55. ></graphy>
  56. </el-tab-pane>
  57. </template>
  58. </el-tabs>
  59. <!-- <space-graphy @dimension="checkSpace" :tabsList="tabsList" ref="graphy" :param="param"></space-graphy> -->
  60. </div>
  61. <div v-show="isMyTab == 2" class="saga-business-sapce-main">
  62. <el-tabs v-model="activeName" @tab-click="handleClick">
  63. <template v-for="(item,index) in tabsList">
  64. <el-tab-pane :name="item.code" :key="index" :disabled="item.code > 3">
  65. <span slot="label">{{item.name}}</span>
  66. <handsontable-main @lookEqu="lookEqu" :ref="'handsontable' + item.code" :id="'handsontable' + item.code" :param="param"></handsontable-main>
  67. </el-tab-pane>
  68. </template>
  69. </el-tabs>
  70. <!-- <space-handsontable :tabsList="tabsList" ref="spaceTable" :param="param"></space-handsontable> -->
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import noModelDialog from "@/components/business_space/dialogs/noModelDialog";
  76. import influenceDialog from "@/components/business_space/dialogs/influenceDialog";
  77. import detailsDialog from "@/components/business_space/dialogs/detailsDialog";
  78. import notRelated from "@/components/business_space/dialogs/notRelated";
  79. import facilityDialog from "@/components/business_space/dialogs/facilityDialog";
  80. // import spaceHandsontable from "@/components/business_space/business/spaceHandsontable";
  81. import graphy from "@/components/business_space/graphy/business";
  82. import handsontableMain from "@/components/business_space/business/handsontable";
  83. import {
  84. getTableHeader,
  85. getAllbusiness,
  86. getBussTypes,
  87. getSpaceFloor
  88. } from "@/api/scan/request";
  89. import tools from '@/utils/scan/tools'
  90. import {
  91. mapGetters,
  92. mapActions
  93. } from "vuex";
  94. export default {
  95. components: {
  96. noModelDialog,
  97. // spaceHandsontable,
  98. influenceDialog,
  99. detailsDialog,
  100. notRelated,
  101. graphy,
  102. handsontableMain,
  103. facilityDialog
  104. },
  105. computed: {
  106. ...mapGetters("peojMess", [
  107. "projectId",
  108. "secret",
  109. "userId"
  110. ])
  111. },
  112. data() {
  113. return {
  114. floor: {
  115. // dialogVisible: true, //选择楼层弹窗
  116. influence: false, //受影响的业务空间弹窗
  117. details: false, //详情弹窗
  118. notRelated: false,
  119. facility: false
  120. },
  121. param: {
  122. ProjId: this.projectId, //项目id
  123. UserId: this.userId, //用户id
  124. secret: this.secret
  125. },
  126. buildMess: {
  127. name: "--",
  128. code: "",
  129. selectd: [],
  130. map: "Fl110108000327d8f006c39f49feb40e24a7ef223232181009102258bim.json",
  131. isChild: true,
  132. buildName: "--",
  133. buildCode: ""
  134. },
  135. isMyTab: 1,
  136. activeName: "GeneralZone",
  137. tabsList: [],
  138. activeTabType: {
  139. "code": "GeneralZone",
  140. "name": "默认分区",
  141. "rel_type": "99"
  142. },
  143. options: [],
  144. props:{
  145. value: "code",
  146. label: "name",
  147. children: "children"
  148. }
  149. };
  150. },
  151. created() {
  152. this.param.ProjId = this.projectId
  153. this.param.UserId = this.userId
  154. this.param.secret = this.secret
  155. this.getFloor()
  156. this.getTypes()
  157. },
  158. mounted() {},
  159. methods: {
  160. changeRadio(){
  161. if(!this.buildMess.selectd.length){
  162. this.$message("请选择楼层")
  163. return false
  164. }
  165. this.tabClick(this.isMyTab)
  166. },
  167. //获取楼层
  168. getFloor() {
  169. let param = {
  170. ProjId: this.projectId,
  171. UserId: this.UserId,
  172. secret: this.secret
  173. };
  174. getSpaceFloor(param).then(res => {
  175. console.log(res, 'res')
  176. if (res.data.Result == 'success') {
  177. let data = this.changeArr(res.data.Content).map(item => {
  178. if (item.children && item.children.length) {
  179. item.children = tools.sortArr(item.children, "shunxu", false)
  180. }
  181. return item
  182. })
  183. console.log(data, 'res.data')
  184. this.options = data
  185. } else {
  186. this.$message.error(res.data.ResultMsg)
  187. }
  188. }).catch(() => {
  189. this.$message.error("请求出错")
  190. })
  191. },
  192. //修改已有数组
  193. changeArr(arr) {
  194. return arr.map(item => {
  195. console.log(item.floors)
  196. if (item.floors && item.floors.length) {
  197. return {
  198. code: item.id,
  199. name: item.infos.BuildLocalName,
  200. children: item.floors.map(i => {
  201. return {
  202. code: i.id,
  203. name: (i.infos.FloorLocalName || i.infos.FloorName || "未知") + this.myMess(i),
  204. map: i.infos.FloorMap || null,
  205. affected: i.affected,
  206. isChilren: 2,
  207. buildCode: item.id,
  208. buildName: item.infos.BuildLocalName,
  209. shunxu: i.infos.FloorSequenceID || 0
  210. }
  211. })
  212. }
  213. } else {
  214. return {
  215. code: item.id,
  216. name: item.infos.BuildLocalName,
  217. children: null,
  218. isChilren: 1,
  219. }
  220. }
  221. })
  222. },
  223. myMess(i) {
  224. if (i.affected) {
  225. return "(该业务空间受元空间变化影响)"
  226. } else {
  227. if (i.infos.FloorMap) {
  228. return ''
  229. } else {
  230. return "(请初始化平面图)"
  231. }
  232. }
  233. },
  234. //获取tabs的列表
  235. getTypes() {
  236. getBussTypes(res => {
  237. let arr = [{
  238. "code": "GeneralZone",
  239. "name": "默认分区",
  240. "rel_type": "99"
  241. },
  242. {
  243. "name": "供电分区",
  244. "rel_type": "1",
  245. "code": "PowerSupplyZone"
  246. },
  247. {
  248. "name": "照明分区",
  249. "rel_type": "2",
  250. "code": "LightingZone"
  251. },
  252. {
  253. "name": "空调分区",
  254. "rel_type": "4",
  255. "code": "AirConditioningZone"
  256. },
  257. ]
  258. this.tabsList = arr
  259. // console.log(res)
  260. // this.tabsList = res.Content
  261. })
  262. },
  263. checkSpace(list, build, graphyId) {
  264. this.floor.notRelated = true;
  265. this.$refs.notRelated.getIdList(list, build, graphyId, this.activeTabType);
  266. this.$refs["graphy" + this.activeName][0].getHasSpace();
  267. },
  268. changeShow() {
  269. this.floor.dialogVisible = true;
  270. console.log(this.buildMess, 'buildMess')
  271. },
  272. //成功关联平面图
  273. createSuccess() {
  274. this.$refs["graphy" + this.activeName][0].getHasSpace();
  275. this.$refs["graphy" + this.activeName][0].clearDimension();
  276. this.floor.notRelated = false;
  277. },
  278. //成功删除业务空间
  279. delSuccess() {
  280. this.floor.details = false;
  281. this.$refs["graphy" + this.activeName][0].getHasSpace();
  282. this.$refs["graphy" + this.activeName][0].clearDimension();
  283. },
  284. close() {
  285. this.buildMess = this.changeBuildMess(this.buildMess,this.options)
  286. if (this.buildMess.affected) {
  287. this.floor.influence = true;
  288. this.$nextTick(() => {
  289. this.$refs.influence.getData(this.buildMess);
  290. });
  291. }
  292. if (!this.buildMess.map) {
  293. this.isMyTab = 2;
  294. }
  295. if (this.isMyTab == 2) {
  296. this.initTabs(this.buildMess);
  297. } else {
  298. let data = this.getItemForType()
  299. this.$refs["graphy" + this.activeName][0].getData(this.buildMess.map, this.buildMess, this.activeTabType);
  300. }
  301. },
  302. //通过code查询options中的其他参数
  303. changeBuildMess(mess,options){
  304. options.map(item => {
  305. if(!!item.children && item.children.length){
  306. item.children.map(child => {
  307. if(child.code == mess.selectd[1]){
  308. console.log(child,mess)
  309. mess = Object.assign(mess,child)
  310. }
  311. })
  312. }
  313. })
  314. return mess
  315. },
  316. //查看业务空间详情
  317. getBuinessDetails(list) {
  318. this.floor.details = true;
  319. this.$refs.details.getData(list, this.buildMess);
  320. },
  321. lookEqu(infos) {
  322. this.floor.facility = true;
  323. this.$refs.facility.getData(infos, this.buildMess);
  324. },
  325. tabClick(num) {
  326. console.log(this.$refs)
  327. this.isMyTab = num;
  328. if (num == 2) {
  329. this.initTabs(this.buildMess);
  330. } else {
  331. let data = this.getItemForType()
  332. this.$refs["graphy" + this.activeName][0].getData(this.buildMess.map, this.buildMess, this.activeTabType);
  333. }
  334. },
  335. //获取初始化信息点
  336. initMessage() {
  337. getTableHeader({
  338. code: this.activeTabType.code,
  339. ProjId: this.param.ProjId
  340. }).then(res => {
  341. console.log(res)
  342. if (res.data.Result == "success") {
  343. console.log(res);
  344. let refFlag = "handsontable" + this.activeName;
  345. this.$refs[refFlag][0].getHeader(res.data.Content, this.activeTabType);
  346. // for (let i = 0; i < this.tabsList.length; i++) {
  347. // }
  348. this.getTableMain();
  349. } else {
  350. this.$message.error("请求错误");
  351. }
  352. });
  353. },
  354. getItemForType() {
  355. let data = {}
  356. this.tabsList.map(item => {
  357. if (item.code == this.activeName) {
  358. data = item
  359. }
  360. })
  361. return data
  362. },
  363. tab1Click() {
  364. this.activeTabType = this.getItemForType()
  365. this.$refs["graphy" + this.activeName][0].getData(this.buildMess.map, this.buildMess, this.activeTabType);
  366. },
  367. /**
  368. * tab标签被点击触发后的函数
  369. * @param tab tab实例
  370. * @param event tab的dom
  371. *
  372. */
  373. handleClick(tab, event) {
  374. this.activeTabType = this.getItemForType()
  375. this.initMessage();
  376. },
  377. /**
  378. * 选择楼层后初始化tabs
  379. * 由父级页面调用
  380. *
  381. * @param floorParam 父级传入的楼层信息
  382. */
  383. initTabs(floorParam) {
  384. // this.floor = floorParam;
  385. this.initMessage();
  386. },
  387. getTableMain() {
  388. let refFlag = "handsontable" + this.activeName;
  389. this.$nextTick(() => {
  390. this.$refs[refFlag][0].getData(this.buildMess);
  391. });
  392. // for (let i = 0; i < this.tabsList.length; i++) {
  393. // if (i == 0) {
  394. // }
  395. // }
  396. }
  397. },
  398. watch: {
  399. floor: {
  400. deep: true,
  401. handler: function() {
  402. if (this.floor.notRelated) {
  403. this.$refs["graphy" + this.activeName][0].clearDimension();
  404. }
  405. }
  406. }
  407. }
  408. };
  409. </script>
  410. <style lang="less">
  411. #businessSpace {
  412. position: relative;
  413. display: flex;
  414. flex-direction: column;
  415. .space-own-radio{
  416. .el-radio-button__inner{
  417. padding: 9px 21px;
  418. }
  419. }
  420. .el-dialog__body {
  421. max-height: 600px;
  422. overflow-y: auto;
  423. }
  424. .saga-title {
  425. height: 54px;
  426. background-color: #fff;
  427. font-size: 14px;
  428. position: relative;
  429. line-height: 54px;
  430. width: 100%;
  431. margin-bottom:10px;
  432. border: 1px solid #dfe6ec;
  433. .saga-build-mess {
  434. position: absolute;
  435. left: 10px;
  436. width: 500px;
  437. i {
  438. padding-right: 5px;
  439. }
  440. p {
  441. float: left;
  442. }
  443. .saga-btn {
  444. float: left;
  445. height: 40px;
  446. line-height: 40px;
  447. padding: 0 10px;
  448. }
  449. }
  450. .saga-build-tab {
  451. position: absolute;
  452. left: 50%;
  453. transform: translateX(-50%);
  454. .tab-main {
  455. float: left;
  456. width: 120px;
  457. padding: 0 5px;
  458. margin: 5px 0;
  459. border: 1px solid #ccc;
  460. background-color: #fff;
  461. height: 30px;
  462. box-sizing: border-box;
  463. text-align: center;
  464. cursor: pointer;
  465. overflow: hidden;
  466. i {
  467. font-size: 18px;
  468. padding-right: 10px;
  469. float: left;
  470. line-height: 30px;
  471. margin-left: 10px;
  472. }
  473. span {
  474. line-height: 30px;
  475. float: left;
  476. }
  477. }
  478. .tab-active {
  479. background-color: #409eff;
  480. color: #fff;
  481. }
  482. }
  483. }
  484. .saga-business-sapce-main {
  485. flex: 1;
  486. top: 40px;
  487. left: 0;
  488. right: 0;
  489. bottom: 0;
  490. overflow: hidden;
  491. overflow-y: auto;
  492. background: #fff;
  493. .el-tabs__nav{
  494. padding-left: 10px;
  495. }
  496. .el-tabs__active-bar{
  497. padding-left: 24px;
  498. }
  499. }
  500. }
  501. </style>